note Help Needed
This wiki is the result of an ongoing community effort — thank you all for helping!
If you want to provide changes to this page then please click here.
Server variable system
The server variable system (put short, SVar) is a new way of creating global server variables efficient and dynamically, meaning that they can be used in server's gamemode and filterscripts at the same time.
They are similar to PVars, but are not tied to a player ID.
warning
This system was introduced in SA-MP 0.3.7 R2-1 and will not work in earlier versions!
note
The SVar system is the same as the PVars, although the variables created are server-wide, not attached to any player ID, and persist through gamemode changes.
Advantages
SVars can be shared/accessed across gamemode scripts and filterscripts.
You can easily enumerate and print/store the SVar list. This makes debugging easier.
Even if a SVar hasn't been created, it still will return a default value of 0.
SVars can hold very large strings using dynamically allocated memory.
You can Set, Get, Create SVars ingame.
Drawbacks
- SVars are several times slower than regular variables. It is generally more favorable to trade in memory for speed, rather than the other way round.
Related Functions
- SetSVarInt: set an integer for a server variable.
- GetSVarInt: get a player server as an integer.
- SetSVarString: set a string for a server variable.
- GetSVarString: get the previously set string from a server variable.
- SetSVarFloat: set a float for a server variable.
- GetSVarFloat: get the previously set float from a server variable
- DeleteSVar: delete a server variable.