SA-MP Forums Archive
Player Variables are not fast enough - 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: Player Variables are not fast enough (/showthread.php?tid=524989)



Player Variables are not fast enough - Battlezone - 09.07.2014

I got a kills textdraw that shows kills variable value ( PlayerInfo[playerid][Kills] ).
I made a stock that updates the kills textdraw and other textdraws, but when i use it under OnPlayerDeath ( PlayerInfo[killerid][Kills]++), and update the textdraws, the kills textdraw value remains the same and update on the next kill to show the previous value, so it's kinda slow, here is the textdraws stock:
pawn Код:
stock TDsUp(playerid)
{
    format(kstr, sizeof kstr, "K: %i", PlayerInfo[playerid][Kills]);
    PlayerTextDrawSetString(playerid, KTD, kstr);
    //rest
    return 1;
}
Is there a way to make those variable faster?


AW: Player Variables are not fast enough - NaS - 09.07.2014

That should not happen, variables do not have a delay.

Do you update the TextDraw before incrementing the Kills variable? Otherwise this wouldn't make sense.

Maybe you could show us the code in OnPlayerDeath.


Re: Player Variables are not fast enough - Battlezone - 09.07.2014

I did that ofc, but now I am surprised! i changed the stock to a public function and it works fine now!


AW: Player Variables are not fast enough - NaS - 09.07.2014

Try without stock or public, does it work then too?


Re: Player Variables are not fast enough - Battlezone - 09.07.2014

works too


Re: Player Variables are not fast enough - Ihateyou - 09.07.2014

maybe u need to show textdraw again after u update it? idk its thats the problem i dont remmeber if u have to


Re: Player Variables are not fast enough - Crayder - 10.07.2014

It doesn't actually matter, but I just hide it before raising the players kill count and show it after that... It makes more since to do it this way for numerous reasons...


AW: Player Variables are not fast enough - NaS - 10.07.2014

You don't need to reshow a textdraw when setting the text, only if you change it (like size, color, proportional etc). But it seems like a stock is handled different than publics/normal functions, because this had nothing to do with the textdraws.


Re: Player Variables are not fast enough - Threshold - 10.07.2014

If you're going to use a function in a timer, it should be public...

Using a timer wouldn't be the most efficient way to update the textdraw anyway, all you need to do is update when the value goes up or down as suggested by Crayder.


Re: Player Variables are not fast enough - Battlezone - 10.07.2014

Im not using a timer, however it got fixed by using a public function