GetPVarString
From SA-MP Wiki
Description:
Gets a player variable as a string.
Note | Variables aren't reset until after OnPlayerDisconnect is called, so the values are still accessible in OnPlayerDisconnect. |
(playerid, varname[], string_return[], len)
playerid | The ID of the player whose player variable to get. |
varname | The name of the player variable, set by SetPVarString. |
&string_return | The array in which to store the string value in, passed by reference. |
len | The maximum length of the returned string. |
Return Values:
The length of the string.
Example: Save the player's name in a pVar
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.
- SetPVarString: Set a string for a player variable.
- SetPVarInt: Set an integer for a player variable.
- GetPVarInt: Get the previously set integer from a player variable.
- SetPVarFloat: Set a float for a player variable.
- GetPVarFloat: Get the previously set float from a player variable.
- DeletePVar: Delete a player variable.