23.12.2013, 22:01
OnPlayerUpdate, in terms of modern hardware, isn't something that's TOO frequent, I suppose (a lot of operations go a lot deeper into the timing). But what the source of problems in this code is that in way too often cases you update the textdraw string. It does not show visually to the player since it is a textdraw, but if you would have it as a client message, you would see the hell it causes in your chatbox.
There is a wide range of stuff you should not do so frequently and when communicating with the player through an API of some kind, it is good to remember that you should interact with it as little as possible.
I'm not sure about the speed of the natives causing any trouble here, but the actual formatting and the internal commands that these natives issue. So only update when necessary, and don't do it so often!
// EDIT:
wrong with the loop is that you don't have a playerid to operate on. For this, you must loop through all players.
(Note that I don't run an IsPlayerConnected check because I can be sure that GetPlayerWantedLevel returns 0 for disconnected players)
There is a wide range of stuff you should not do so frequently and when communicating with the player through an API of some kind, it is good to remember that you should interact with it as little as possible.
I'm not sure about the speed of the natives causing any trouble here, but the actual formatting and the internal commands that these natives issue. So only update when necessary, and don't do it so often!
// EDIT:
wrong with the loop is that you don't have a playerid to operate on. For this, you must loop through all players.
pawn Код:
for(int playerid = 0; playerid != MAX_PLAYERS; playerid++)
{
if(GetPlayerWantedLevel(playerid) > 0)
{
// code
}
}