Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Passing variables to classes... (https://forums.graalonline.com/forums/showthread.php?t=40317)

Twusk 11-14-2002 10:26 AM

Passing variables to classes...
 
Alright, here's my problem...
I'm using a weapon with putnpc2 that is a "join class;" but I want to pass a variable to that class from the weapon, I know you can pass the variable from a weapon to putnpc2 through via
NPC Code:

putnpc2 x,y,{ message #v(this.test); join class; };
with (npcs[npcscount-1]) { this.test=3; }


but that variable (this.test) doesn't pass onto the class... and I want to know I can pass that variable onto the class. Can that be done?

Python523 11-14-2002 01:36 PM

its doing the message #v(this.test) before you even set the this.test variable

NPC Code:

putnpc2 x,y,{
if(done){
message #v(this.test);
join class;
}
}
with(npcs[npcscount-1]){
this.test = 3;
callnpc npcscount-1,done;
}



might work or just try setting this.test on the putnpc2 part?

Twusk 11-15-2002 07:12 AM

Quote:

Originally posted by Python523
its doing the message #v(this.test) before you even set the this.test variable

might work or just try setting this.test on the putnpc2 part?

Tried both, neither work. And actually that message #v(this.test) part would work, my problem is sending the variable to the class, I don't believe it has to do with time, it's just not going through. I guess you can't send variables to classes :/

Python523 11-15-2002 07:42 AM

post teh class

Twusk 11-15-2002 10:18 AM

Ok, here's the basic of what I have...

WEAPON:
NPC Code:

if (actionserverside) {
putnpc2 playerx,playery,{join class;};
with (npcs[npcscount-1]) { this.test=3; }
}
//#CLIENTSIDE
if (weaponfired) { triggeraction 0,0,serverside,weapon; }



CLASS:
NPC Code:

//#CLIENTSIDE
if (created) { message #v(this.test); }



That's not my actual script, it's much longer, but you get the idea, that still won't work.

Python523 11-15-2002 10:37 AM

normal vars set serverside cant be accessed clientside, use a save var for your script ( save[0] = 3 )

Twusk 11-15-2002 01:36 PM

Quote:

Originally posted by Python523
normal vars set serverside cant be accessed clientside, use a save var for your script ( save[0] = 3 )
Ahh, thank you...

Com013 11-15-2002 07:05 PM

Why do you need to do it clientside at all?
The class you posted would be fine serverside.

Twusk 11-16-2002 07:19 AM

Quote:

Originally posted by Com013
Why do you need to do it clientside at all?
The class you posted would be fine serverside.

I knew someone was going to say that... that was just an example, my real class is much longer and has a timeout of .05, that's why it needs to be clientside :)


All times are GMT +2. The time now is 06:08 AM.

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