PDA

View Full Version : passing objects through triggeractions


projectigi
03-25-2006, 06:12 PM
Hi,


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
Hi,


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:


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

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



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

Ajira
03-25-2006, 09:08 PM
Hi,


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, 10: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, 03:14 AM
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, 03:17 PM
well you're wrong

Ajira
03-28-2006, 02:49 AM
well you're wrong
Dude, I'm not.

Projectshifter
03-28-2006, 03:48 AM
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, 09:43 PM
It is called serverside if you UPDATE the SCRIPT
how else my rc would generate the output...

ApothiX
03-30-2006, 05: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, 10:21 PM
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, 11:40 PM
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, 10:03 AM
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: