Variables across scripts - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Variables across scripts (
/showthread.php?tid=231197)
Variables across scripts -
littlegrimlin1 - 25.02.2011
Hey yall.. I was wondering what the best way to access/change variables that are in different scripts is.
My current method is by using remote function calls, but im sure there is a much better method that makes me feel retarded. Please halp me out.
Re: Variables across scripts -
Calgon - 25.02.2011
You can use PVars for player variables, or you can use get/set property.
https://sampwiki.blast.hk/wiki/Setproperty
https://sampwiki.blast.hk/wiki/Getproperty
https://sampwiki.blast.hk/wiki/Per-player_variable_system
Re: Variables across scripts -
littlegrimlin1 - 25.02.2011
hmmmm... that get/set property looks pretty messy... lol. However the PVar system look pretty appealing.. is this what alot of the good scripts use?
Re: Variables across scripts -
Krx17 - 25.02.2011
Get/Setproperty are a lot older. They have been there since 0.1 and they may be a bit harder to use.
PVars are limited in a way that you can only use them for players, an example would be like having an array called PlayerVehicle[MAX_PLAYERS];
Re: Variables across scripts -
Calgon - 25.02.2011
Also, you can use Incognito's GVars (global variables) plugin.
https://sampforum.blast.hk/showthread.php?tid=151076
Re: Variables across scripts -
littlegrimlin1 - 25.02.2011
Most of the stuff I need across the scripts are just player variables.. like money, level, etc..
i can just use CallRemoteFunction when I need a global variable
Thank you guys.
Oh wow.. that Gvar looks nice... ill use that alongside Pvar... thanks for solving all my probs for now

DD
Re: Variables across scripts -
Krx17 - 25.02.2011
If you've ever programmed in C# or Java, you can also use that GVar plugin like a makeshift ArrayList.
Re: Variables across scripts -
littlegrimlin1 - 25.02.2011
Also, is it normal to have many filterscripts for your server? I like to have a separate one for handling different things... like one that manages the Moneysystem, the database, chatting, claymores (fun little scripted claymore for unsuspecting people

).. Im just wondering if too many filterscripts is a problem. Adding all of these FS names to the server.cfg kinda worries me.
- Thanx Guise - littleG
[I have changed all of my CallRemoteFunctions into just Set/Get PVars and seems to be working greatly.. thanks you all!]