PDA

View Full Version : GS2: triggeraction(), bug or am I doing something wrong?


Fry
05-24-2005, 08:43 PM
I don't know why it won't work, but I am not exactly sure whether it should work and whether it's a bug:
function onActionfoo() {
player.chat = "works.., " @ params[0];
}
function onActionserverside() {
player.chat = "onActionServerside";
triggeraction(player.x+1.5, player.y+2, "foo", "test");
}

//#CLIENTSIDE
if (weaponfired)
triggeraction 0,0,serverside,#w;
in a weapon.

the serverside trigger arrives, the "foo" trigger doesn't. Neither on the serverside, nor on the clientside.
It also doesn't work when I replace "player" with some other player that also has the weapon.

Velox Cruentus
05-24-2005, 09:50 PM
It's case sensitive. Try:

function onactionservreside()
{
}

And... The weapon shouldn't be able to trigger himself like that...

Your best bet is calling a function:
foo({param[0],param[1]});

and
function foo(params)
{
player.chat := params[0];
}

Fry
05-24-2005, 10:03 PM
It's case sensitive. Try:

function onactionservreside()
{
}

Already tried it.


And... The weapon shouldn't be able to trigger himself like that...

If it isn't possible to do it yet, then it should be added. I also (or initially) tried triggering other players with the same weapon.


Your best bet is calling a function:
foo({param[0],param[1]});

and
function foo(params)
{
player.chat := params[0];
}
It is not, sadly, because there are cases where the function doesn't exist which would result in errors in the RC.
I would've used .trigger(..), but it isn't working correctly at the moment.
What I wanted to do is do a triggeraction for weapon attacks, I initially did it by cycling through the players/npcs and using callweapon/callnpc on those who were infront of the player, because I was concerned about the security of triggeraction.
I'd be fine when obj.trigger() would be working correctly.

Ajira
05-24-2005, 10:14 PM
I would've used .trigger(..), but it isn't working correctly at the moment. What I wanted to do is do a triggeraction for weapon attacks, I initially did it by cycling through the players/npcs and using callweapon/callnpc on those who were infront of the player, because I was concerned about the security of triggeraction.
I'd be fine when obj.trigger() would be working correctly.
I thought I showed you how to use trigger() so it works with attacking etc o_O

Fry
05-24-2005, 10:25 PM
I thought I showed you how to use trigger() so it works with attacking etc o_O
As I told you, it didn't work and it was a terrible workaround.
I shouldn't have to be forced to use workarounds for everything, so I am reporting these bugs so they can be fixed and I can use things as they are supposed to be used.

Admins
05-25-2005, 03:39 PM
I don't see bugs there. The control-npc and the weapon npcs are not supposed to stay in the level where the action happens, so triggeraction is not even checking for them. They are only "warped" temporary to the location of the player to be able to easy check for near players and npcs.
The obj.trigger(action,params) or obj.scheduleevent(delay,action,params) functions should work fine in case you want to invoke an event.

Fry
05-25-2005, 04:52 PM
Didn't think it was supposed to work, just wasn't sure so I asked.

obj.trigger() works on the current player, but not if you get another one with findplayer() or something.

Velox Cruentus
05-25-2005, 05:12 PM
Make the object the weapon.

WEAPON.trigger(x,y);

To think about it... I had some problems a while ago with some scripts. I'm at school, so I can't get them. I'll post later.

The Weapon.trigger() should work rather then player.trigger. You are triggering the weapon, and not the player (that is where I believe you could've made a mistake).

EDIT: For executing on another player, you would probably have to do:

with (findplayer(x)) WEAPON.trigger();

Or, have it that the trigger is in a player class, so that findplayer(x).trigger() executes a function the player can have.

Something I do for that is a public function and simply do player.reset(); For example.

Fry
05-25-2005, 05:44 PM
Make the object the weapon.

WEAPON.trigger(x,y);

Hm, yes, but I already tried it, and getting someone elses weapon object is a bit problematic, like you've shown below:
1. Only weapon names that don't contain characters like - / or whatever work, otherwise you have to use makevar()/etc
2. As you said, in order to access the weapon of someone else you have to use with() which I remember shouldn't be used anymore
EDIT: Okay, with() should still be used, yet someplayer.weaponname/findweapon() not working doesn't make sense.

I'd suggest a findweapon for other players, not just the current one, also a .trigger() on a player should go to all weapons.


Or, have it that the trigger is in a player class, so that findplayer(x).trigger() executes a function the player can have.

Something I do for that is a public function and simply do player.reset(); For example.
Thank you very very much for helping, but the thing isn't that I can't find a way to work around these things, it's just that I want to use things like they should work or were supposed to work (atleast I think that that they were to work this way).

Admins
05-26-2005, 01:57 PM
I have some problems to follow.

If you do trigger(action,params) it will send an event to the current npc/weapon.
If you want do a trigger for another player, you can pass the player object as parameter or you do stuff like with (findplayer(account)) thiso.trigger(action,params); which then will automatically set the "current player" once the event is triggered.

Triggering yourself doesn't make a lot of sense though, you can call the function directly.

Velox Cruentus
05-26-2005, 02:08 PM
What I retrieved was:

findplayer(x).WEAPON.function();


You can easily do it with:

with(findplayer("Fry"))
FrenchFries.trigger("cook");



=---=
Use of thiso.trigger():

with (findplayer(x))
{
hp -= dam;
if (hp < 0)
thiso.trigger("kill",player.account);
}

Fry
05-26-2005, 02:42 PM
Oh well.. you did read the part where I said I do know how to work around the nonexcistance of a direct .trigger()?
Don't tell me findplayer("Velox Cruentus").findweapon("Cookie System").trigger("eat", 10); makes less sense to you than with (findplayer("Velox Cruentus")) ("Cookie System").trigger("eat", 10); or you'd prefer the latter one..?
.trigger()ing other Level NPCs works fine, so why shouldn't a .trigger() for other player[weapon]s be added?

Stefan: What I want is to do findplayer("someplayer").findweapon("someweapon").trigger("stuff", "parameters");

Admins
05-26-2005, 05:07 PM
Nonexistense? You have a lot of functions to get the weapon object, get the player, doing triggers. You can use findweapon(), findweaponnpc(), makevar, use trigger, scheduleevent, directly call functions of the weapon npc, or call functions from a class.
If you really want to put the code for eating into a weapon npc script and you want some random player eat something then you probably need to retrieve the player object and weapon object and call the script function or trigger an event. I don't understand why you make it that complicated though, and I don't know what kind of trigger you are missing (nor why you need to use triggers in this case).

Fry
05-26-2005, 07:20 PM
It was a very bad example I guess, sorry.
I was in the believe that findweapon() did not work because I always though I got the weapon of the current player, not the one I was using the findweapon() on, but then I figured that the code which gets called by directly calling a function in a weapon npc uses the player that called this function as "player" object, so it seems I was misusing them. Sorry.

Inverness
05-26-2005, 08:49 PM
it would be nice if it was possible to trigger functions serverside -> clientside and clientside -> serverside. Since I don't really like using triggeraction >_>

Fry
05-26-2005, 09:37 PM
There's player.triggerclient("weaponname", parameters); and if I remember correctly it is planned to add triggerserver too. They just replace triggeraction(0, 0, "serverside"/"clientside", stuff); though.

Admins
05-26-2005, 10:06 PM
Yes its planned sometime soon to make it like in Graal3D where you can directly trigger an onActionBlabla function instead of onActionClientside.