11.02.2019, 00:46
Then how would I do it correctly? This is what I have right now in my game mode.
PHP Code:
public OnPlayerSpawn(playerid)
{
ShowHud(playerid)
return 1;
}
ShowHud(playerid)
{
PlayerTextDrawShow(playerid, TD_HUD[playerid][0]);
PlayerTextDrawShow(playerid, TD_HUD[playerid][1]);
PlayerTextDrawShow(playerid, TD_HUD[playerid][2]);
PlayerTextDrawShow(playerid, TD_HUD[playerid][3]);
KillTimer(TIMER[playerid]);
TIMER[playerid] = SetTimerEx("UpdateHud", 1000, true, "i", playerid);
return 1;
}
PHP Code:
UpdateHud(playerid)
{
if(PLAYER_EXP[playerid] >= PLAYER_LEVEL[playerid] * 12)
{
PLAYER_LEVEL[playerid] ++;
PLAYER_EXP[playerid] = 1;
new Query[256];
format(Query, sizeof Query, "UPDATE PLAYERS SET LEVEL = '%d', EXP = '%d' WHERE PLAYER_ID = '%d';", PLAYER_LEVEL[playerid], PLAYER_EXP[playerid], PLAYER_ID[playerid]);
db_query(DT_DB, Query);
}
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;
}