Player Variables are not fast enough
#1

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?
Reply
#2

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.
Reply
#3

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

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

works too
Reply
#6

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

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...
Reply
#8

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.
Reply
#9

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.
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)