Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 12-15-2005, 07:16 PM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
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:
if (actionserverside)
{
addweapon #p(0);
destroy;
}

//#CLIENTSIDE
if (actiondrop)
{
//code not reated to my problem removed - this part works
}

if (
playertouchsme)  
{
triggeraction 0,0,serverside,weaponpickup,#p(1); //also tried doing it on x and y

Any help would be greatly appreciated.
__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such
Reply With Quote
  #2  
Old 12-15-2005, 07:32 PM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
Because it's not a weapon. You have to triggeraction the x/y of the NPC.

Why not just check for playertouchsme on serverside?
Reply With Quote
  #3  
Old 12-15-2005, 07:53 PM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
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:
if (actionserverside)
{
message i say #p(0);
}

//#CLIENTSIDE
if (playertouchsme)
{
triggeraction x,y,serverside,hi there;

playertouchsme done serveride does not carry over the variable that was set clientside. (#p(1) from the actiondrop)
__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such
Reply With Quote
  #4  
Old 12-15-2005, 07:56 PM
Skyld Skyld is offline
Script-fu
Skyld's Avatar
Join Date: Jan 2002
Location: United Kingdom
Posts: 3,914
Skyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud ofSkyld has much to be proud of
Send a message via AIM to Skyld
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).
__________________
Skyld
Reply With Quote
  #5  
Old 12-15-2005, 08:13 PM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
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.
__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such
Reply With Quote
  #6  
Old 12-15-2005, 09:13 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
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) {
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
  #7  
Old 12-16-2005, 12:36 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
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;
putnpc2 somex,somey,{ join fruits; };
with(npcs[npcscount-1]) {
setstring this.img,#s(thiso.fruit).png;
}



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.
Reply With Quote
  #8  
Old 12-16-2005, 12:38 AM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
Quote:
Originally Posted by prozac424242
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.
That'd be like, totally insecure, maaaan.
Reply With Quote
  #9  
Old 12-16-2005, 07:14 AM
prozac424242 prozac424242 is offline
Registered User
prozac424242's Avatar
Join Date: May 2001
Location: Gone crazy: back soon
Posts: 356
prozac424242 is on a distinguished road
Send a message via ICQ to prozac424242 Send a message via AIM to prozac424242
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]
__________________

Useful links:
Graal Stats
Client Script Functions-GS1 to GS2
Serverside Script Functions-Gscript page
Particle Engine-Player Attributes
Server Options-Admin rights-Gmaps
Quote:
Originally Posted by Admins
Thanks for developing and improving playerworlds and such
Reply With Quote
  #10  
Old 12-16-2005, 08:02 AM
Lance Lance is offline
dark overlord
Lance's Avatar
Join Date: Sep 2003
Location: Space Jam Mountain
Posts: 5,072
Lance is on a distinguished road
Quote:
Originally Posted by prozac424242
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]
If you just add an NPC with putnpc, it will have the highest index in the npcs array. If you immediately access that NPC, you can set flags.
Reply With Quote
  #11  
Old 12-16-2005, 08:48 AM
Rick Rick is offline
PipBoy Extraordinaire!
Rick's Avatar
Join Date: Jul 2004
Location: Long Beach, California.
Posts: 831
Rick is on a distinguished road
Quote:
Originally Posted by prozac424242
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]
The reason for this is because the NPC server is not threaded. It may seem like that, but it really isn't.

HOWEVER:

With GScript2 you have a new alternative, this will probably be easier to understand:

HTML Code:
this.fruit = "strawberry";
temp.npc = this.level.putNPC2(somex, somey, "join fruits;");
temp.npc.img = this.fruit @ ".png";
OR:

HTML Code:
this.fruit = "strawberry";

with (this.level.putNPC2(somex, somey, "join fruits;"))
{
  this.img = thiso.fruit @ ".png";
}
Reply With Quote
  #12  
Old 12-16-2005, 08:07 PM
ApothiX ApothiX is offline
Okiesmokie
Join Date: May 2004
Posts: 1,447
ApothiX is on a distinguished road
Quote:
Originally Posted by prozac424242
[moves on to something that might actually be usefull]
I think learning how to interact with NPCs is quite a useful thing o_o
__________________


[06:24:19] * Parts: Skyld (i=silent@unaffiliated/skyld) ("Perhaps Okiesmokie did not realise that I like the boys. ")
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 12:32 AM.


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