GetPVarType

GetPVarType

Description:
Function GetPVarType gets the type (integer, float or string) of a player variable.


Parameters:
(playerid, varname[])
int playerid The ID of the player whose player variable to get the type of.
string varname The name of the player variable to get the type of.


Return Values:
Returns the type of the PVar. See table below.


Variable Types:
ID Type
0 PLAYER_VARTYPE_NONE (pVar with name given does not exist)
1 PLAYER_VARTYPE_INT
2 PLAYER_VARTYPE_STRING
3 PLAYER_VARTYPE_FLOAT


Examples:
stock PrintPVar(playerid, varname[])
{
    switch(GetPVarType(playerid, varname))
    {
        case PLAYER_VARTYPE_NONE:
        {
            return 0;
        }
        case PLAYER_VARTYPE_INT:
        {
            printf("Integer PVar '%s': %i", varname, GetPVarInt(playerid, varname));
        }
        case PLAYER_VARTYPE_FLOAT:
        {
            printf("Float PVar '%s': %f", varname, GetPVarFloat(playerid, varname));
        }
        case PLAYER_VARTYPE_STRING:
        {
            new varstring[256];
            GetPVarString(playerid, varname, varstring);
 
            printf("String PVar '%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.