![]() |
serverside triggeraction in class placed with putnpc2
Here is my situation:
A weapon places a class with putnpc2. The same weapon also does a triggeraction which the class npc recieves clientside with paramaters. That works. What does not work is when the action is detected clientside in the class, the class npc is supposed to do a triggeraction serverside on itself, becasue the addweapon command has to be done serverside. Why does the putnpc2 class not do a triggeraction on itself, but this same code works in a weapon? actiondrop gets called succesfully, but the serverside part in the class here does not get called at all. #p(1) in the actiondrop is the weapon name passed from the weapon. The class is called weaponpickup PHP Code:
|
Because it's not a weapon. You have to triggeraction the x/y of the NPC.
Why not just check for playertouchsme on serverside? |
triggeraction on the x and y did not work. the triggeraction does not happen at all with actionserverside.
Even something as simple as this does not work in a putnpc2 class npc PHP Code:
|
You will probably need to give the NPC a shape (setshape on the serverside), and triggeraction onto that surface.
Also, I would add some additional security to that addweapon, such as a clientr.flag check, or even specifying the weapon name on the serverside instead of #p(n). |
I actually did try using a setshape when the npc is created, and doing a triggeraction on the x and y.
But no matter what I do, the big problem is that any variable set clientside is not carried over to the serverside part of the script, be it in playertouchsme or a triggeraction. |
What exactly is happening? Is it triggering the action and not getting the parameters, or not triggering at all?
If it's not triggering at all, you might want to try to use x+1.5, y+1.5 to make sure it hits on an actual pixel, and not a transparent part. (I'm not sure if this still applies, but I use it anyway :P) [EDIT] You should also try using a different event name, such as 'pickup' and do: if(actionpickup) { instead of: if(actionserverside) { |
That is not only horribly insecure but horribly inefficient as well. Instead of trying to circumvent the "No, you can't add any weapon you want clientside" security, you should try to do it right.
Perhaps instead you should use the standard put-the-npc-then-use-with-and-set-the-flag method. This is even easier in GS2. gs1 example: NPC Code:setstring this.fruit,strawberry; this.img in the placed NPC will be strawberry.png :) Other than that, you were using a reserved action name (actionserverside is reserved for weapon npcs, actionserver[anythingelse] is reserved for control-npc). Please take the secure approach, though. Explicitly specify the weapon name, don't trust the client. |
Quote:
|
hmm
aparently my "problem" with coming up with this script idea is that I do not expect the worst from people right off the bat ... as many who post here apparently do. forget it then. thanks for the help but im not going to use code that, even when explained to me, I don't understand how it works (the code Lance posted) I just can't wrap my mind around through where the npcscount and that count-1 can be a constant referal point but to different putnpc2 class items that are separate from the npc which is controlled by the player performing the putnpc2 action. [moves on to something that might actually be usefull] |
Quote:
|
Quote:
HOWEVER: With GScript2 you have a new alternative, this will probably be easier to understand: HTML Code:
this.fruit = "strawberry";HTML Code:
this.fruit = "strawberry"; |
Quote:
|
| All times are GMT +2. The time now is 09:11 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.