11.02.2019, 00:13
Update player statistics in this way is fine? I understand that I can use 'OnPlayerUpdate' or use a timer in 'OnGameModeInit' but "I BELIEVE" that there is some recommended and best way to do this.
PHP Code:
public OnPlayerSpawn(playerid)
{
KillTimer(TIMER[playerid]);
TIMER[playerid] = SetTimerEx("UpdateHud", 1000, true, "i", playerid);
return 1;
}
////////////////
UpdateHud(playerid)
{
new str[64];
format(str, sizeof str, "$%d", PLAYER_MONEY[playerid]); //MONEY
PlayerTextDrawSetString(playerid, TD_HUD[playerid][0], str);
format(str, sizeof str, "- %d -", PLAYER_LEVEL[playerid]); //LEVEL
PlayerTextDrawSetString(playerid, TD_HUD[playerid][1], str);
format(str, sizeof str, "- %.3f -", PLAYER_EXP[playerid]); //EXP
PlayerTextDrawSetString(playerid, TD_HUD[playerid][2], str);
format(str, sizeof str, "- %s -", PLAYER_CLAN[playerid]); //CLAN
PlayerTextDrawSetString(playerid, TD_HUD[playerid][3], str);
return 1;
}