new string2[128];
new Score = GetPlayerScore(playerid);
format(string2, sizeof(string2), "Score: %i", Score);
Textdraw2[playerid] = CreatePlayerTextDraw(playerid, 3.999998, 185.173278, string2);
PlayerTextDrawLetterSize(playerid, Textdraw2[playerid], 0.449999, 1.600000);
PlayerTextDrawAlignment(playerid, Textdraw2[playerid], 1);
PlayerTextDrawColor(playerid, Textdraw2[playerid], -1);
PlayerTextDrawSetShadow(playerid, Textdraw2[playerid], 0);
PlayerTextDrawSetOutline(playerid, Textdraw2[playerid], 2);
PlayerTextDrawBackgroundColor(playerid, Textdraw2[playerid], 51);
PlayerTextDrawFont(playerid, Textdraw2[playerid], 2);
PlayerTextDrawSetProportional(playerid, Textdraw2[playerid], 1);
Textdraw2 = TextDrawCreate(3.999998, 185.173278, "Score:");
TextDrawLetterSize(Textdraw2, 0.449999, 1.600000);
TextDrawAlignment(Textdraw2, 1);
TextDrawColor(Textdraw2, -1);
TextDrawSetShadow(Textdraw2, 0);
TextDrawSetOutline(Textdraw2, 1);
TextDrawBackgroundColor(Textdraw2, 51);
TextDrawFont(Textdraw2, 2);
TextDrawSetProportional(Textdraw2, 1);
public OnPlayerConnect(playerid)
{
new string2[41];
GetPlayerName(playerid, string2, 41);
format(string2, sizeof(string2), "Score: %i", GetPlayerScore(playerid));
TextDrawSetString(Textdraw2, string2);
return 1;
}
stock hook_SetPlayerScore(playerid, score)
{
if(!IsPlayerConnected(playerid)) return 0;
SetPlayerScore(playerid, score);
// Update the TD here using TextDrawSetString
return 1;
}
#if defined _ALS_SetPlayerScore
#undef SetPlayerScore
#else
#define _ALS_SetPlayerScore
#endif
#define SetPlayerScore hook_SetPlayerScore
new string2[41]; GetPlayerName(playerid, string2, 41); format(string2, sizeof(string2), "Score: %i", GetPlayerScore(playerid)); TextDrawSetString(Textdraw2, string2); |
That's a stupid idea. It's going to update it hundreds of times a minute, instead of possibly less than once a minute (when ever their score changes)..
If you have this approach towards things then your server is going to be quite laggy. OnPlayerUpdate should only be used when needed - it's called extremely often even for just one player - imagine 100.. |