OnPlayerUpdate optimize question.. - 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 optimize question.. (
/showthread.php?tid=607910)
OnPlayerUpdate optimize question.. -
Ult1mate - 25.05.2016
Hi. Which is more efficient and faster ?
I will use for anti cheats/hacks but player connect the server lag problems.
For Example:
- GetTickCount:
Код:
new count[MAX_PLAYERS];
Код:
public OnPlayerUpdate(playerid)
{
if(GetTickCount() - count[playerid] > 1000){
count[playerid] = GetTickCount();
new Float:animX, Float:animY, Float:animZ;
new anim = GetPlayerAnimationIndex(playerid);
GetPlayerPos(playerid, animX, animY, animZ);
if((anim >= 1538) && (anim <= 1544) || (anim == 1250) || (anim == 1062) && animZ > 5 || animZ > -5){
BanEx(playerid, "Anim Hack");}
return 0;
}
return 1;
}
- Call a public/stock functions:
Код:
public OnPlayerConnect(playerid){
SetTimerEx("Bla", 1000, true, "i", playerid);
return 1;
}
Код:
forward Bla(playerid);
public Bla(playerid){
new Float:animX, Float:animY, Float:animZ;
new anim = GetPlayerAnimationIndex(playerid);
GetPlayerPos(playerid, animX, animY, animZ);
if((anim >= 1538) && (anim <= 1544) || (anim == 1250) || (anim == 1062) && animZ > 5 || animZ > -5){
BanEx(playerid, "Anim Hack");}
return true;
}
Re: OnPlayerUpdate optimize question.. -
luke49 - 25.05.2016
I suggest creating a timer, because it will cause you less lagg on your server.
Re: OnPlayerUpdate optimize question.. -
ilijap - 25.05.2016
Why creating a new timer? Search maybe you have another 1s timer and use global timer no per player