OnPlayerUpdate Can I use 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: OnPlayerUpdate Can I use this code? (
/showthread.php?tid=319776)
OnPlayerUpdate Can I use this code? -
milanosie - 20.02.2012
so, I never used OnPlayerUpdate, but will this code lag it or is it small enough?
pawn Код:
public OnPlayerUpdate(playerid)
{
if(iscracked[playerid] == 0)
{
new Float:h;
GetPlayerHealth(playerid, h);
if(h < 11)
{
new Float:u, Float:u2, Float:u3;
GetPlayerPos(playerid, u, u2, u3);
iscracked[playerid] = 1;
TogglePlayerControllable(id, 0);
ApplyAnimation(playerid, "CRACK", "crckdeth2", 4.0, 1, 0, 0, 0, 0); // Dieing of Crack
SetTimerEx("uncrack", 240000, false, "i", playerid);
CrackLabel[playerid] = Create3DTextLabel("Injured", COLOR_BLUE, u, u2, u3 + 2, 10, 0);
}
}
return 1;
}
Re: OnPlayerUpdate Can I use this code? -
PrawkC - 20.02.2012
Yeah, the only thing you really want to avoid is large calculations, or time consuming functions.
Re: OnPlayerUpdate Can I use this code? -
Max_Coldheart - 20.02.2012
the code wont lag even if it's 1000 lines long, if it's well written, so there's no reason to ask will this code lag because of this amount of code.
Re: OnPlayerUpdate Can I use this code? -
milanosie - 20.02.2012
Quote:
Originally Posted by ******
Have you TESTED it? If you run your server on a 386 then it will probably lag. If you run your server on Jaguar then it probably won't lag. Why should we know? We aren't your server!
|
It's more that I mean, I heared a lot about OnPlayerUpdate lagging servers with complicated code etc.
And I have a decent server.
But I don't think this is a big/complicated code, just wasn't sure.
Re: OnPlayerUpdate Can I use this code? -
Babul - 20.02.2012
calling the timer at each frame will cause lag/high CPU usage. move the cracked code to OnPlayerStateChange or OnPlayerKeyStateChange - pay attention to the SetTimer, it seems it will get called too often.
the actual miniscript in OnPlayerUpdate() wont cause lag, its really small.