17.01.2010, 22:25
Since having big code in OnPlayerUpdate will cause your server to lagg, I decided to make my own with a timer and a function.
But the problem is, I want to use playerid in it so I have to use settimerex. But I can only put that under onplayerconnect (gamemodeinit doesnt have playerid)
My question is: Will it cause lagg? Because it creates a new timer for every player in the server?
And if it causes lagg, what can I do to make it better?
My code:
Thanks!
But the problem is, I want to use playerid in it so I have to use settimerex. But I can only put that under onplayerconnect (gamemodeinit doesnt have playerid)
My question is: Will it cause lagg? Because it creates a new timer for every player in the server?
And if it causes lagg, what can I do to make it better?
My code:
pawn Код:
//On top:
new playerupdatetimer[MAX_PLAYERS];
forward PlayerUpdate(playerid);
// OnPlayerConnect:
playerupdatetimer[playerid] = SetTimerEx("PlayerUpdate", 450, 1, "i", playerid);
//OnPlayerDisconnect:
KillTimer(playerupdatetimer[playerid]);
//The UpdatePlayer function
public PlayerUpdate(playerid)
{
return 1;
}