03.09.2009, 15:50
Try to use optimising code. Here is Simple Weapon Anticheat:
Код:
#include <a_samp> new Text: BanMessage; new BannedWeapons [ 999 ]; new MAX_BANNED_WEAPONS = 0; new Spawned [ MAX_PLAYERS ]; //============================================================================== public OnFilterScriptInit ( ) { BanWeapon (38); // Minigun BanWeapon (35); //RGP BanWeapon (36); // RL BanWeapon (39); // Flamethrower SetTimer ("BannedWeaponCheck",1000 ,true); return 1; } //============================================================================== forward BannedWeaponCheck (); public BannedWeaponCheck () { for (new playerid = 0; playerid < MAX_PLAYERS; playerid++) { for ( new weaponid = 0; weaponid < MAX_BANNED_WEAPONS; weaponid++) { if (GetPlayerWeapon (playerid) == BannedWeapons [weaponid] && Spawned [playerid] == 1 ) { ResetPlayerWeapons (playerid); Kick (playerid); } } } } //============================================================================== public OnPlayerDisconnect (playerid , reason) { Spawned [playerid] = 0; return 1; } //============================================================================== public OnPlayerConnect (playerid) { Spawned [playerid] = 0; return 1; } //============================================================================== public OnPlayerSpawn (playerid) { Spawned [playerid] = 1; return 1; } //============================================================================== public OnPlayerDeath (playerid , killerid , reason) { Spawned [playerid] = 0; return 1; } //============================================================================== stock BanWeapon (weaponid) { BannedWeapons [MAX_BANNED_WEAPONS] = weaponid; MAX_BANNED_WEAPONS = MAX_BANNED_WEAPONS += 1; return MAX_BANNED_WEAPONS - 1; } //============================================================================== stock BanWithMessage ( playerid ) { TextDrawShowForPlayer ( playerid , BanMessage ); TogglePlayerControllable ( playerid , 0 ); GameTextForPlayer ( playerid , " " , 100000000000000 , 1 ); Kick ( playerid ); new string [ 256 ] , weaponname [ 256 ] , weaponid; weaponid = GetPlayerWeapon ( playerid ); GetWeaponName ( weaponid , weaponname , 256 ); }