GetPVarString

GetPVarString

Description:
Function GetPVarString gets a player variable as a string.
Variables aren't reset until after OnPlayerDisconnect is called, so the values are still accessible in OnPlayerDisconnect.
If length of string is zero (value not set), string_return text will not be updated or set to anything and will remain with old data, neccesying that you clear the variable to blank value if GetPVarString returns 0 if that behavior is undesired.


Parameters:
(playerid, varname[], string_return[], len)
int playerid The ID of the player whose player variable to get.
string varname The name of the player variable, set by SetPVarString.
string string_return The array in which to store the string value in, passed by reference.
int len The maximum length of the returned string.


Return Values:
The length of the string.


Examples:
public OnPlayerConnect(playerid,reason)
{
    new playerName[MAX_PLAYER_NAME+1];
    GetPlayerName(playerid, playerName, MAX_PLAYER_NAME);
    SetPVarString(playerid, "PlayerName", playerName);
    return 1;
}
 
public OnPlayerDeath(playerid, killerid, reason)
{
    new playerName[MAX_PLAYER_NAME+1];
    GetPVarString(playerid, "PlayerName", playerName, sizeof(playerName));
 
    printf("%s died.", playerName);
}


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