public OnPlayerUpdate(playerid)
{
SetPlayerTeam(playerid,gTeam[playerid]);
AntiMoneyCheat(playerid);
pupdates[playerid]++;
if(pupdates[playerid] > UPDATE_COUNT && running == 1){
pupdates[playerid]=0;
new check;
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && IsVehicleValid(GetPlayerVehicleID(playerid))){
new Float:vx,Float:vy,Float:vz;
GetVehicleVelocity(GetPlayerVehicleID(playerid),vx,vy,vz);
if(vx==0.0 && vy==0.0 && vz < -0.0032 && vz > -0.022){
if(IsPlayerInWater(playerid)==0){
check=1;
}
else
{
check=3;
}
}
}
else
{
if(GetPlayerState(playerid)==PLAYER_STATE_ONFOOT && GetPlayerSurfingVehicleID(playerid)==INVALID_VEHICLE_ID){
new Float:vx,Float:vy,Float:vz,Float:px,Float:py,Float:pz;
GetPlayerVelocity(playerid,vx,vy,vz);
pupdates[playerid]=0;
new keys,ud,lr;
GetPlayerKeys(playerid,keys,ud,lr);
if (keys & KEY_SPRINT)
{
if(-0.022 < vz < -0.0040 && -0.235 < vx < 0.235 && -0.235 < vy < 0.235)
{
if(!IsPlayerInRangeOfPoint(playerid,2.0,GetPVarFloat(playerid,"oposx"),GetPVarFloat(playerid,"oposy"),GetPVarFloat(playerid,"oposz")) || -0.5>(GetPVarFloat(playerid,"oposz")-pz)>-0.1 || 0.075>(GetPVarFloat(playerid,"oposz")-pz)>-0.075)
{
if(IsPlayerInWater(playerid)==0)
{
check=2;
if(airbreakcount[playerid] > (POSSIBLE_AIRBREAK_COUNT_ONFOOT-2))
{
SetPlayerVelocity(playerid,0.3,0.3,0.3);
}
}
else
{
check=3;
}
}
SetPVarFloat(playerid,"oposx",px);
SetPVarFloat(playerid,"oposy",py);
SetPVarFloat(playerid,"oposz",pz);
}
}
else
{
if(-0.022 < vz < -0.0040 && -0.121 < vx < 0.121 && -0.121 < vy < 0.121)
{
if(!IsPlayerInRangeOfPoint(playerid,2.0,GetPVarFloat(playerid,"oposx"),GetPVarFloat(playerid,"oposy"),GetPVarFloat(playerid,"oposz")) || -0.5>(GetPVarFloat(playerid,"oposz")-pz)>-0.1 || 0.075>(GetPVarFloat(playerid,"oposz")-pz)>-0.075)
{
if(IsPlayerInWater(playerid)==0)
{
check=2;
if(airbreakcount[playerid] > (POSSIBLE_AIRBREAK_COUNT_ONFOOT-2))
{
SetPlayerVelocity(playerid,0.3,0.3,0.3);
}
}
else
{
check=3;
}
}
SetPVarFloat(playerid,"oposx",px);
SetPVarFloat(playerid,"oposy",py);
SetPVarFloat(playerid,"oposz",pz);
}
}
}
}
if(check > 0)
{
if(check < 3)
{
new POSSIBLE_AIRBREAK_COUNT;
switch(check)
{
case 1: POSSIBLE_AIRBREAK_COUNT=POSSIBLE_AIRBREAK_COUNT_CAR;
case 2: POSSIBLE_AIRBREAK_COUNT=POSSIBLE_AIRBREAK_COUNT_ONFOOT;
}
airbreakcount[playerid]++;
if(airbreakcount[playerid] > POSSIBLE_AIRBREAK_COUNT)
{
airbreakcount[playerid]=0;
new string[60], name[24];
GetPlayerName(playerid,name,sizeof(name));
format(string,sizeof(string),"* %s was been banned (Reason:airbreak)",name);
SendClientMessageToAll(color,string);
SaveToFile("BanLog",string); Ban(playerid);
}
}
}
else
{
airbreakcount[playerid]=0;
}
}
return 1;
}
|
Do you realize that all that piece of code gets executed about 32 times each second?
|
|
Do you realize that all that piece of code gets executed about 32 times each second?
|
|
Well it's not my script. I even didn't looked on it. BTW it should be optimized?
So as i see this is not good script. Any other anti airbreak script here? |
|
Well it's not my script. I even didn't looked on it. BTW it should be optimized?
|
|
ZamaXor, run some tests with these macros in OnPlayerUpdate:
http://forum.sa-mp.com/showthread.ph...706#post877706 |
|
Just keep it running for quite some time, get a few players on.
After a few hours of activity, search for warnings in the server log. |
OnPlayerUpdate was executed in 3 ms.