Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 06-15-2009, 12:03 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Trigger Client NPC

Is there any way to trigger a clientside-function in an NPC?
Reply With Quote
  #2  
Old 06-15-2009, 03:49 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
There have been many threads about this already, please use the forum search function. You'll also have to be more specific as to what type of NPC (level NPC?) or a little bit more about what it does.
__________________
Skyld
Reply With Quote
  #3  
Old 06-15-2009, 04:56 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by Skyld View Post
There have been many threads about this already, please use the forum search function. You'll also have to be more specific as to what type of NPC (level NPC?) or a little bit more about what it does.
Sorry, didn't use the search function :

PHP Code:
function onCreated() {
  if (
blablabla) {
    
// trigger the client
  
}
}
//#CLIENTSIDE
function onClientSideFunction() {
  
// Stuff

Something like this
Reply With Quote
  #4  
Old 06-15-2009, 06:10 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
No, you normally can't trigger client like that. Think about it: It'd have to trigger client for every player in the level, right? Unless of course you did something like player.triggerclient.

However, I don't think it works for DB NPCs (putnpc2, for example).

I could be wrong, though.
__________________
Reply With Quote
  #5  
Old 06-15-2009, 07:36 PM
salesman salesman is offline
Finger lickin' good.
salesman's Avatar
Join Date: Nov 2008
Location: Colorado
Posts: 1,865
salesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud ofsalesman has much to be proud of
Quote:
Originally Posted by Pelikano View Post
Sorry, didn't use the search function :

PHP Code:
function onCreated() {
  if (
blablabla) {
    
// trigger the client
  
}
}
//#CLIENTSIDE
function onClientSideFunction() {
  
// Stuff

Something like this
In that example you could just have the onCreated() function on the clientside, no trigger needed (I'm assuming it's a DBNPC via putnpc?).

If the conditional statement 'if (blablabla)' can only be read serverside, I suggest storing the data in some other way where it could be read on the client.

Edit: what I'm trying to say is that there's most likely a way to do it without needing a server->client trigger and you should be more specific with your problem.
Reply With Quote
  #6  
Old 06-15-2009, 07:57 PM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Quote:
Originally Posted by salesman View Post
In that example you could just have the onCreated() function on the clientside, no trigger needed (I'm assuming it's a DBNPC via putnpc?).

If the conditional statement 'if (blablabla)' can only be read serverside, I suggest storing the data in some other way where it could be read on the client.

Edit: what I'm trying to say is that there's most likely a way to do it without needing a server->client trigger and you should be more specific with your problem.

I don't have a problem, it would just be handy if you could trigger a function on the Client in a level NPC ;D
Reply With Quote
  #7  
Old 06-15-2009, 08:04 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
could you not just do

NPC Code:

triggeraction(this.x, this.y, "clientside", "params");
//#CLIENTSIDE
function onActionClientside() {

}



etc?
__________________

Reply With Quote
  #8  
Old 06-15-2009, 08:06 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Quote:
Originally Posted by Robin View Post
could you not just do

NPC Code:

triggeraction(this.x, this.y, "clientside", "params");
//#CLIENTSIDE
function onActionClientside() {

}



etc?
Doesn't work with NPCs that don't have a shape(aka non-blocking), and if there are other NPC's at the same space, they will get the triggeraction instead.
Reply With Quote
  #9  
Old 06-15-2009, 08:11 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
Quote:
Originally Posted by DustyPorViva View Post
Doesn't work with NPCs that don't have a shape(aka non-blocking), and if there are other NPC's at the same space, they will get the triggeraction instead.
So what do you suggest? I was looking for something like this the other day actually.
__________________

Reply With Quote
  #10  
Old 06-15-2009, 08:19 PM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
It's fairly easy to send data from serverside > clientside via attr[]'s. You can do checks like that if you'd like.

What I also did was set-up a DBNPC that would intercept the triggerserver's/triggerclient's from the local NPC, and then do the communication in the DBNPC itself and then resend the function. However, I only did this for clientside > serverside, so I'm not particularly sure of how that'd work the other way around

DBNPC:
PHP Code:
function onActionServerside(cmd,lvl,checkid) {
  if (
cmd == "checkhit") {
    for (
temp.ifindlevel(lvl).npcs) {
      if (
i.id == checkid) {
        
i.test();
        break;
      }
    }
  }

And in the level itself(from the clientside):
PHP Code:
triggerserver("npc","mydbnpc","checkhit",this.level.name,this.id); 
Reply With Quote
  #11  
Old 06-15-2009, 08:31 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
http://forums.graalonline.com/forums...=triggerclient

could have sworn triggerclient() worked?
__________________

Reply With Quote
  #12  
Old 06-16-2009, 01:31 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
It does, but not in the way I think you want it too.

NPC Code:
triggerClient( "gui", name, params...);



PHP Code:
function onCreated()
{

  for ( 
temp.plallplayers)
  {

    
pl.triggerClient"gui"name"Hello World");

  }
}

//#CLIENTSIDE

function onActionClientside()
{

  
player.chat params0];


I know you can replace "gui" with "weapon" but it still does the same. Can someone enlighten us if there is any difference.

For level NPC's you just have to define the shape, such as
NPC Code:
setshape( 0, 16 * 2, 16 * 3);

0 being non-blocking.

Then you can do the triggerAction();

example

PHP Code:
function onCreated()
{

  
triggerActionthis.xthis.y"Clientside""Hello World");

}

//#CLIENTSIDE

function onCreated()
{

  
setShape016 216 3);

}

function 
onActionClientside()
{

  
player.chat params0];


Also, you dont have to use "Clientside" since it's a triggerAction(); So replace that with something like "Data" then the function would be onActionData()
__________________
Deep into the Darkness peering...

Last edited by Angel_Light; 06-16-2009 at 01:42 AM..
Reply With Quote
  #13  
Old 06-16-2009, 03:16 AM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
It really does need a way of directly calling a function on the clientside of the current DBNPC / Level NPC.
__________________

Reply With Quote
  #14  
Old 06-16-2009, 04:49 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
My first method works for dbNPCs and second for levelNPCs. Both methods have worked for me.
__________________
Deep into the Darkness peering...
Reply With Quote
  #15  
Old 06-16-2009, 09:09 AM
Pelikano Pelikano is offline
Registered User
Pelikano's Avatar
Join Date: Oct 2008
Posts: 1,133
Pelikano has a little shameless behaviour in the past
Thanks Angel,

but your second method doesn't work.
You cannot use triggeraction() from server to client as it seems..

Last edited by Pelikano; 06-16-2009 at 09:24 AM..
Reply With Quote
  #16  
Old 06-16-2009, 02:59 PM
Robin Robin is offline
The secret of NIMH
Robin's Avatar
Join Date: Apr 2005
Location: Wales, UK
Posts: 515
Robin will become famous soon enough
Send a message via AIM to Robin
Quote:
Originally Posted by Pelikano View Post
Thanks Angel,

but your second method doesn't work.
You cannot use triggeraction() from server to client as it seems..
Yes you can.. ?
__________________

Reply With Quote
  #17  
Old 06-21-2009, 05:16 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
you might want to put this.x + 0.5 and this.y + 0.5 in the triggeraction since it is calling it on the border. I found doing that usually fixes it.
__________________
Deep into the Darkness peering...
Reply With Quote
  #18  
Old 06-22-2009, 12:33 PM
xXziroXx xXziroXx is offline
Malorian
xXziroXx's Avatar
Join Date: May 2004
Posts: 5,289
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Quote:
Originally Posted by Angel_Light View Post
you might want to put this.x + 0.5 and this.y + 0.5 in the triggeraction since it is calling it on the border. I found doing that usually fixes it.
Sounds like you never setshape on the serversided part of the NPC tbh.
__________________
Follow my work on social media post-Graal:Updated august 2025.
Reply With Quote
  #19  
Old 06-23-2009, 02:17 AM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
Quote:
Originally Posted by xXziroXx View Post
Sounds like you never setshape on the serversided part of the NPC tbh.
Both work, but probably setting setshape may sound more efficient.
__________________
Deep into the Darkness peering...
Reply With Quote
  #20  
Old 06-23-2009, 02:19 AM
DustyPorViva DustyPorViva is offline
Will work for food. Maybe
DustyPorViva's Avatar
Join Date: Sep 2003
Location: Maryland, USA
Posts: 9,589
DustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond reputeDustyPorViva has a reputation beyond repute
Send a message via AIM to DustyPorViva Send a message via MSN to DustyPorViva
Triggeraction probably won't work if the shape of the NPC isn't set on the serverside. This is because without a serverside setshape, the NPC server won't be able to 'find' the NPC when you do the triggeraction(since triggeraction uses blocking space only to trigger, and non-blocking will not register).
Reply With Quote
  #21  
Old 06-23-2009, 10:50 PM
Angel_Light Angel_Light is offline
Varia Developer
Angel_Light's Avatar
Join Date: Nov 2005
Location: Knoxville, TN
Posts: 1,684
Angel_Light is on a distinguished road
Send a message via AIM to Angel_Light Send a message via MSN to Angel_Light
setshape isnt always blocking per sei, if you just do setshape( 0, 32, 32); zero will make it non-blocking
__________________
Deep into the Darkness peering...
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:01 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.