Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   triggering beetween wnpcs (https://forums.graalonline.com/forums/showthread.php?t=71641)

Chompy 01-23-2007 04:06 PM

triggering beetween wnpcs
 
Well, I've been experimenting, but I can't get something like this to work..

// -Master
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
this.wnpc = "Chompy/Test";
  
triggerserver( "gui", this.wnpc, "actiontest", "foo");
} 

// Chompy/Test
PHP Code:

function onActionServerside()
{
  if ( 
params[ 0] == "actiontest")
    echo( 
params[ 1]);
} 

This isn't working for me, anyone have any ideas?
I dunno if I am doing anything wrong..
(Doesn't output the echo in rc chat)

Twinny 01-23-2007 04:29 PM

I've never triggered accross weapons. I've always just triggered the current one and use a public function ^^.

Chompy 01-23-2007 04:33 PM

Well, is it possible to do this?
Actually the 'this.wnpc' is from variable saved on the player, that was just an example.
Just wondering if it is possible, would make my work easier :O

(I am planning on having one master script to control other wnpcs (each wnpc with a different ability/functons etc.), so making lots of public functions inside the master script would just look messy)

The stuff I am doing would look more like,.. :

PHP Code:

//#CLIENTSIDE
function _trigger( wnpc, function, array)
  
triggerserver( "gui", temp.wnpc, temp.function, temp.array; 


JkWhoSaysNi 01-23-2007 05:16 PM

I did something similar a while ago.

I have a weapon script which creates an NPC using putnpc2. When that NPC is touched it triggers an action on the weapon NPC.


In the placed npc I just have triggeraction(0,0,"serverside","npc name",params);


I'm pretty sure that works,

if not, you can always use findweapon.

Master
NPC Code:

//#CLIENTSIDE
function onCreated(){
findweapon("Chompy/Test").trigger();
}




Chompy/Test
NPC Code:

function onActionServerside()
{
if ( params[ 0] == "actiontest")
echo( params[ 1]);
}
//#CLIENTSIDE
public function trigger() {
triggeraction(0,0,"serverside","Chompy/Test","actiontest");

}


Chompy 01-23-2007 06:41 PM

its not, it must use a variable instead of the real wnpc name, thats my problem..

like triggerserver( "gui", "Chompy/Test", ...); works fine, but if I take out 'Chompy/Test' and replace with a variable it won't work..

I don't know what type it needs, if its an object or a string..

Skyld 01-23-2007 06:57 PM

Quote:

Originally Posted by Chompy (Post 1267952)
its not, it must use a variable instead of the real wnpc name, thats my problem..

like triggerserver( "gui", "Chompy/Test", ...); works fine, but if I take out 'Chompy/Test' and replace with a variable it won't work..

I don't know what type it needs, if its an object or a string..

Well, think about it. "Chompy/Test" is a string, therefore it logically will expect a string.

Chompy 01-23-2007 08:21 PM

Quote:

Originally Posted by Skyld (Post 1267956)
Well, think about it. "Chompy/Test" is a string, therefore it logically will expect a string.

But, it doesn't work, like the example in the first post..

What I am saying is that, my problem is something like this:

This works
PHP Code:

//#CLIENTSIDE
function onCreated()
  
triggerserver( "gui", "Chompy/Test", "actiontest", "foo"); 

But this doesn't..
PHP Code:

//#CLIENTSIDE
function onCreated()
{
  
temp.wnpc = "Chompy/Test";
  
triggerserver( "gui", temp.wnpc, "actiontest", "foo");
} 


Skyld 01-23-2007 08:23 PM

PHP Code:

this.wnpc = "Chompy/Test",; 

... won't work if you keep that comma there.

Chompy 01-23-2007 08:25 PM

Quote:

Originally Posted by Skyld (Post 1268005)
PHP Code:

this.wnpc = "Chompy/Test",; 

... won't work if you keep that comma there.

Opps, well I removed the comma, but it still won't work (see post that is two posts above this)

Chandler 01-23-2007 09:47 PM

Quote:

Originally Posted by Chompy (Post 1268006)
Opps, well I removed the comma, but it still won't work (see post that is two posts above this)

The player has BOTH weapons, yes?

Chompy 01-23-2007 09:52 PM

Quote:

Originally Posted by Chandler (Post 1268032)
The player has BOTH weapons, yes?

Yes, the player has both weapons.

Chandler 01-23-2007 09:56 PM

Triggering script:
HTML Code:

//#CLIENTSIDE
function onPlayerChats()
{
  temp.curToks = player.chat.tokenize();
  triggerserver("weapon", temp.curToks[0], temp.curToks[1]);
}

Finding script:
HTML Code:

function onActionServerside(curOption)
{
  echo(curOption);
}

Works perfect for me o-o

This also works too:
HTML Code:

//#CLIENTSIDE
function onPlayerChats()
{
  temp.curNPC = "CT";
  triggerserver("weapon", temp.curNPC, player.chat);
}

Am I not understanding what you're trying to do?

Chompy 01-23-2007 10:00 PM

Quote:

Originally Posted by Chandler (Post 1268034)
Triggering script:
HTML Code:

//#CLIENTSIDE
function onPlayerChats()
{
  temp.curToks = player.chat.tokenize();
  triggerserver("weapon", temp.curToks[0], temp.curToks[1]);
}

Finding script:
HTML Code:

function onActionServerside(curOption)
{
  echo(curOption);
}

Works perfect for me o-o

This also works too:
HTML Code:

//#CLIENTSIDE
function onPlayerChats()
{
  temp.curNPC = "CT";
  triggerserver("weapon", temp.curNPC, player.chat);
}

Am I not understanding what you're trying to do?

Hmm, I think you found it :] Thanks
( 'weapon' instead of 'gui', will check if it works on my server)

Admins 01-23-2007 10:47 PM

"weapon" and "gui" are the same though. For me the only possible solution is that the player actually doesn't have both weapons.

Chandler 01-23-2007 10:50 PM

Quote:

Originally Posted by Stefan (Post 1268052)
"weapon" and "gui" are the same though. For me the only possible solution is that the player actually doesn't have both weapons.

That's how I see it...

godofwarares 01-24-2007 02:31 AM

It works fine for me, Even with the variable calling o.O

Hikaru/Test
PHP Code:

//#CLIENTSIDE
function onCreated() {
this.wnpc = "Hikaru/Test2";
triggerserver("weapon", this.wnpc, "actiontest", "foo");
} 

Hikaru/Test2
PHP Code:

function onActionServerSide(cmd, option) {
switch(
cmd) {
case 
"actiontest":
echo(
option);
break;
}
} 


Chompy 01-24-2007 04:06 PM

hmm, weird..


All times are GMT +2. The time now is 06:23 PM.

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