SA-MP Forums Archive
Help with this code. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Help with this code. (/showthread.php?tid=409813)



Help with this code. - EmuS - 23.01.2013

Hello, I have a good stat textdraw is using a timer to actualize, but the problem is that titilea lot when there is a bit of lag -.- And annoying haha.
pawn Код:
new Text:Stats[MAX_PLAYERS];
new Estadisticas[MAX_PLAYERS];

Estadisticas[playerid] = SetTimerEx("Actualizar",400,1,"e",playerid);

    for(new playerid; playerid < MAX_PLAYERS; playerid++) {
    Stats[playerid] = TextDrawCreate(.........................
    }
forward Actualizar(playerid);
public Actualizar(playerid)
{
     new strr[128];
     TextDrawHideForPlayer(playerid,Stats[playerid]);
    format(strr, sizeof(strr), " ~r~Score: ~w~%d ~g~Kills: ~w~%d ~b~Deaths: ~w~%d",PlayerInfo[playerid][Score],PlayerInfo[playerid][Kills],PlayerInfo[playerid][Deaths]);
    TextDrawSetString(Stats[playerid],strr);
    TextDrawShowForPlayer(playerid,Stats[playerid]);
    return 1;
}



Re: Help with this code. - AphexCCFC - 23.01.2013

Define the problem more clearly, I have no idea what you mean.


Re: Help with this code. - jonrb - 23.01.2013

Some thoughts:
Do you really need to update the textdraw every 400ms?
I don't think that it changes that quickly...


Just update the textdraw when the stats change.

Also, having that many timers is bad.


Re: Help with this code. - SuperViper - 23.01.2013

Either change the timer to 10 seconds or only update the textdraw when the stats actually change which is the best way. Also, you don't need to hide and show the textdraw, you can just set the string.