20.12.2010, 22:19
Hi all,i maked a simple Speedcheck for cheaters.
If a players goes more than 280 km/h (with car),he will be autobanned,with the planes (310 km/h),same.
But this dont work,here is the code:
OnPlayerStateChange
And the stocks:
What's wrong with it?
If a players goes more than 280 km/h (with car),he will be autobanned,with the planes (310 km/h),same.
But this dont work,here is the code:
OnPlayerStateChange
Код:
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) { new Float:speed; speed = GetPlayerSpeed(playerid, false); if(speed > 280) { new string[100]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(string, 100, "%s was auto-banned for SpeedHack.", name); SendClientMessageToAll(COLOR_RED, string); BanLog(string); Ban(playerid); new str[100]; format(str,sizeof str,"0,4s was auto-banned for SpeedHack", name); IRC_GroupSay(gGroupID, IRC_CHANNEL, str); } if(!IsPlayerInPlane(playerid)) { speed = GetPlayerSpeed(playerid, true); if(speed > 310) { new string[100]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(string, 100, "%s was auto-banned for SpeedHack.", name); SendClientMessageToAll(COLOR_RED, string); Ban(playerid); BanLog(string); new str[100]; format(str,sizeof str,"0,4s was auto-banned for SpeedHack", name); IRC_GroupSay(gGroupID, IRC_CHANNEL, str); } } }
Код:
stock GetPlayerSpeed(playerid,bool:kmh) { new Float:Vx,Float:Vy,Float:Vz,Float:rtn; if(IsPlayerInAnyVehicle(playerid)) GetVehicleVelocity(GetPlayerVehicleID(playerid),Vx,Vy,Vz); else GetPlayerVelocity(playerid,Vx,Vy,Vz); rtn = floatsqroot(floatabs(floatpower(Vx + Vy + Vz,2))); return kmh?floatround(rtn * 100 * 1.61):floatround(rtn * 100); } stock IsPlayerInPlane(playerid) { if(IsPlayerInAnyVehicle(playerid)) { switch(GetVehicleModel(GetPlayerVehicleID(playerid))) { case 593,592,577,563,553,548,520,519,513,512,511, 497,488,487,476,469,460,447,425,417,493,484,453: return 1; default: return 0; } } return 0; }