Do I do "if" or Do "else if"
#2

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 );

}
Reply


Messages In This Thread
Do I do "if" or Do "else if" - by Eazy_Efolife - 03.09.2009, 15:37
Re: Do I do "if" or Do "else if" - by Butilka - 03.09.2009, 15:50
Re: Do I do "if" or Do "else if" - by Eazy_Efolife - 03.09.2009, 15:51
Re: Do I do "if" or Do "else if" - by Correlli - 03.09.2009, 15:55
Re: Do I do "if" or Do "else if" - by Eazy_Efolife - 03.09.2009, 16:00
Re: Do I do "if" or Do "else if" - by Andom - 03.09.2009, 16:00
Re: Do I do "if" or Do "else if" - by Correlli - 03.09.2009, 16:08
Re: Do I do "if" or Do "else if" - by Eazy_Efolife - 03.09.2009, 16:14
Re: Do I do "if" or Do "else if" - by coole210 - 03.09.2009, 18:11

Forum Jump:


Users browsing this thread: 1 Guest(s)