Update player statistics in the textdraw
#4

You go like this, then just call UpdateHud() in the places where you code makes changes. If you have a lot of function calls where this data is changed like SetPlayerMoney() you just need to hook that function or create new ones that performs the task and calls the update. I doubt there is going to many places where level, exp, clan are changed so you just need to make sure to call UpdateHud() whenever a change is made. You can add any sqlite/mysql update queries you have here as well.

Code:
#define         UPDATE_TYPE_MONEY       0
#define         UPDATE_TYPE_LEVEL       1
#define         UPDATE_TYPE_EXP         2
#define         UPDATE_TYPE_CLAN        3

UpdateHud(playerid, type)
{
    new str[64];
	switch(type)
	{
	    case UPDATE_TYPE_MONEY:
	    {
		    format(str, sizeof str, "$%d", PLAYER_MONEY[playerid]); //jn+
		    PlayerTextDrawSetString(playerid, TD_HUD[playerid][0], str);
	    }
	
	    case UPDATE_TYPE_LEVEL:
	    {
		    format(str, sizeof str, "- %d -", PLAYER_LEVEL[playerid]); //LEVEL
		    PlayerTextDrawSetString(playerid, TD_HUD[playerid][1], str);
	    }
	    
	    case UPDATE_TYPE_EXP:
	    {
		    format(str, sizeof str, "- %.3f -", PLAYER_EXP[playerid]); //EXP
		    PlayerTextDrawSetString(playerid, TD_HUD[playerid][2], str);
	    }
	    
	    case UPDATE_TYPE_CLAN:
	    {
		    format(str, sizeof str, "- %s -", PLAYER_CLAN[playerid]); //CLAN
		    PlayerTextDrawSetString(playerid, TD_HUD[playerid][3], str);
	    }
	}
	return 1;
}
Reply


Messages In This Thread
Update player statistics in the textdraw - by N3mesiS - 11.02.2019, 00:13
Re: Update player statistics in the textdraw - by Pottus - 11.02.2019, 00:33
Re: Update player statistics in the textdraw - by N3mesiS - 11.02.2019, 00:46
Re: Update player statistics in the textdraw - by Pottus - 11.02.2019, 01:13
Re: Update player statistics in the textdraw - by N3mesiS - 11.02.2019, 11:50
Re: Update player statistics in the textdraw - by N3mesiS - 11.02.2019, 22:14
Re: Update player statistics in the textdraw - by SymonClash - 11.02.2019, 22:30
Re: Update player statistics in the textdraw - by Pottus - 11.02.2019, 22:31
Re: Update player statistics in the textdraw - by SymonClash - 12.02.2019, 20:18
Re: Update player statistics in the textdraw - by N3mesiS - 12.02.2019, 20:32

Forum Jump:


Users browsing this thread: 1 Guest(s)