Server variable system

From SA-MP Wiki

Jump to: navigation, search

The server variable system (put short, SVar) is a new way of creating server variables in an efficient dynamically created method globally, meaning 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.
See the last 2 posts in this thread to read about the difference between pawn properties and SVars. The thread is about PVars, but the explanation applies to SVars as well.



The SVar system is the same as the PVars, although the variables created are server-wide, not attached to any playerid, and persist through gamemode changes.

— Originally by Kalcor, source


The new system was introduced in SA-MP 0.3.7 R2-1.

  • 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.


  • 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.


The functions for setting and retrieving the server variables are:

  • SetSVarInt: Set an integer for a server variable.
  • GetSVarString: Get the previously set string from a server variable.
  • GetSVarFloat: Get the previously set float from a server variable.

Functions that allow you to enumerate and do other sorts of magic with server variables are:

Personal tools