Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   New Scripting Engine (GS2) (https://forums.graalonline.com/forums/forumdisplay.php?f=153)
-   -   passing objects through triggeractions (https://forums.graalonline.com/forums/showthread.php?t=64951)

projectigi 03-25-2006 06:12 PM

passing objects through triggeractions
 
Hi,

NPC Code:

function onCreated(){
thiso.objtest=NULL;
thiso.objtest=new TStaticVar();
echo("before:" SPC thiso.objtest.test1);
thiso.objtest.test1="blah";
echo("after:" SPC thiso.objtest.test1);
findplayer("projectigi").triggerclient("-trgtest",thiso.objtest);
}
//#CLIENTSIDE
function onActionClientSide(){
player.chat="s" SPC params[0].test1;
}



don't works, is there any way to correctly pass an object through a triggeraction?

ApothiX 03-25-2006 06:45 PM

Quote:

Originally Posted by projectigi
Hi,

NPC Code:

function onCreated(){
thiso.objtest=NULL;
thiso.objtest=new TStaticVar();
echo("before:" SPC thiso.objtest.test1);
thiso.objtest.test1="blah";
echo("after:" SPC thiso.objtest.test1);
findplayer("projectigi").triggerclient("-trgtest",thiso.objtest);
}
//#CLIENTSIDE
function onActionClientSide(){
player.chat="s" SPC params[0].test1;
}



don't works, is there any way to correctly pass an object through a triggeraction?

I have noticed this too. The only way I could partially do this was to do something like this:

PHP Code:

// In actionserverside
temp.varray NULL;
for(
temp.vnamethis.objtest.getvarnames()) {
  
temp.varray.add(temp.vname "=" this.objtest.(temp.vname));
}

player.triggerclient("gui""-trgtest"temp.varray); 

PHP Code:

// In actionclientside
temp.varray.loadvarsfromarray(params[0]);
echo(
temp.varray.test); 


Ajira 03-25-2006 09:08 PM

Quote:

Originally Posted by projectigi
Hi,

NPC Code:

function onCreated(){
thiso.objtest=NULL;
thiso.objtest=new TStaticVar();
echo("before:" SPC thiso.objtest.test1);
thiso.objtest.test1="blah";
echo("after:" SPC thiso.objtest.test1);
findplayer("projectigi").triggerclient("-trgtest",thiso.objtest);
}
//#CLIENTSIDE
function onActionClientSide(){
player.chat="s" SPC params[0].test1;
}



don't works, is there any way to correctly pass an object through a triggeraction?

If this is inside a weapon, it obviously will not work because onCreated() and such events are not called on the serverside in a weapon.

projectigi 03-25-2006 09:54 PM

they are called if youu update the script
else it wouldnt say
before:
after: blah

in my rc...right? XP

ApothiX 03-26-2006 09:19 PM

You can't pass objects through triggeractions. The method I told you works, but is probably not efficient for most cases.

Also, your triggerclient is not using correct syntax. it should be triggerclient("gui", ..)

Ajira 03-27-2006 02:14 AM

Quote:

Originally Posted by projectigi
they are called if youu update the script
else it wouldnt say
before:
after: blah

in my rc...right? XP

onCreated and onPlayerEnters events are not called serverside in a weapon. >.>

projectigi 03-27-2006 02:17 PM

well you're wrong

Ajira 03-28-2006 01:49 AM

Quote:

Originally Posted by projectigi
well you're wrong

Dude, I'm not.

Projectshifter 03-28-2006 02:48 AM

Quote:

Originally Posted by projectigi
well you're wrong

I'm sorry but in this case you are wrong. Stefan has said this many times before, serverside weapons are technically not "created". I cannot verify for sure if onCreated() will work serverside or not, I know at one point it worked but only because it was a catch that I think stefan put in iirc. What you shoudl be doing if you require something to have serverside things activated when the weapon is updated/someone logs on/has the weapon added to them you should have an trigger on the client like: triggeraction(0,0,"serverside","init"); Although I do think there is a triggerserver() and triggerclient() now (I'm just coming back and trying to catch up myself).

It would be nice if you could pass objects through a trigger though. I don't know if this so much qualifies as a bug but moreso as a feature that should be added if possible.

projectigi 03-28-2006 08:43 PM

It is called serverside if you UPDATE the SCRIPT
how else my rc would generate the output...

ApothiX 03-30-2006 04:11 PM

projectgi is right in this case. onCreated() is sent to a WNPC when you update the script in NC.

Ajira 04-01-2006 09:21 PM

Quote:

Originally Posted by ApothiX
projectgi is right in this case. onCreated() is sent to a WNPC when you update the script in NC.

Then that is related to NC updates only. If there is an onCreated() block in the serverside part of a weapon script, and a player logs on, I highly doubt onCreated() will still be called on the serverside.

projectigi 04-01-2006 10:40 PM

Quote:

Originally Posted by Ajira
Then that is related to NC updates only. If there is an onCreated() block in the serverside part of a weapon script, and a player logs on, I highly doubt onCreated() will still be called on the serverside.

I never said it will be called if a player logs in O_o

ApothiX 04-02-2006 09:03 AM

Quote:

Originally Posted by Ajira
Then that is related to NC updates only. If there is an onCreated() block in the serverside part of a weapon script, and a player logs on, I highly doubt onCreated() will still be called on the serverside.

He didn't, he's been telling you the whole time that it is called when he updates the script from his RC. Ajira needs some glasses :cool:


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

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