GetSVarType

From SA-MP Wiki

Jump to: navigation, search


Description:

Gets the type (integer, float or string) of a server variable.


Parameters:
(varname[])
varnameThe name of the server variable to get the type of.


Return Values:

Returns the type of the SVar. See table below.


Variable Types

ID Type
0 SERVER_VARTYPE_NONE (sVar with name given does not exist)
1 SERVER_VARTYPE_INT
2 SERVER_VARTYPE_STRING
3 SERVER_VARTYPE_FLOAT

Example Usage:

stock PrintSVar(varname[])
{
    switch(GetSVarType(varname))
    {
        case SERVER_VARTYPE_NONE:
        {
            return 0;
        }
        case SERVER_VARTYPE_INT:
        {
            printf("Integer SVar '%s': %i", varname, GetSVarInt(varname));
        }
        case SERVER_VARTYPE_FLOAT:
        {
            printf("Float SVar '%s': %f", varname, GetSVarFloat(varname));
        }
        case SERVER_VARTYPE_STRING:
        {
            new varstring[256];
            GetSVarString(varname, varstring);
 
            printf("String SVar '%s': %s", varname, varstring);
        }
    }
    return 1;
}

Related Functions

The following functions may be useful, as they are related to this function in one way or another.

  • 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.
Personal tools
Navigation
Toolbox