SA-MP Forums Archive
Question about variables... - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Question about variables... (/showthread.php?tid=282279)



Question about variables... - Whizion - 10.09.2011

Let's say that i declared a variable named 'Candy' in my gamemode, and let's say i created a filterscript that has to use the 'Candy' variable.

How to read/write values to that variable throw my filterscript?

Thanks.


Re: Question about variables... - Sasino97 - 10.09.2011

I suggest you to use the GVar Plug-In by Incognito.
https://sampforum.blast.hk/showthread.php?tid=151076

(Currently is the one with the last reply, the first in the list)

Then use SetGVarInt("Candy", 0);


Re: Question about variables... - Lorenc_ - 10.09.2011

PVars and GVar can be used, however they're memory consumers.


Re: Question about variables... - Vince - 10.09.2011

As said, PVar and GVar, but also CallRemoteFunction and setproperty/getproperty.


Re: Question about variables... - Whizion - 10.09.2011

I know about PVar's and GVar's but the problem is my old gamemode doesn't use those (it uses regular variables) and i can't recompile because i don't have the .pwn for it. So is there a way i can read/write to those regular variables?

Can i do it with setproperty/getproperty Vince mentioned? If yes, can i have an example please?

Thanks.


Re: Question about variables... - Whizion - 10.09.2011

BUMP. :/


Re: Question about variables... - Max_Coldheart - 10.09.2011

Quote:
Originally Posted by Lorenc_
View Post
however they're memory consumers.
Ofcourse PVars are memory consumers, they are cross script variables, so they eat more memory.

Have a nice day !


Re: Question about variables... - Whizion - 10.09.2011

Quote:
Originally Posted by Whizion
View Post
I know about PVar's and GVar's but the problem is my old gamemode doesn't use those (it uses regular variables) and i can't recompile because i don't have the .pwn for it. So is there a way i can read/write to those regular variables?

Can i do it with setproperty/getproperty Vince mentioned? If yes, can i have an example please?

Thanks.
^ Bump.


Re: Question about variables... - Sasino97 - 10.09.2011

Quote:
Originally Posted by Whizion
View Post
^ Bump.
The syntax is written in the "core.inc" include by ITB CompuPhase.

pawn Code:
native getproperty(id, const name[], value=cellmin, string[], size=sizeof (string));
native setproperty(id, const name[], value=cellmin, const string[]);
native deleteproperty(id, const name[], value=cellmin);
native existproperty(id, const name[], value=cellmin);
Example

pawn Code:
setproperty(0, "Candy", cellmin, "Hello");

new str[256];
getproperty(0, "Candy", cellmin, str);

printf("The value of Candy is %s", str);
If you haven't the source of your old GameMode, you can't get that variable... It must be public