[FilterScript] Extreme Simple/Efficient Anti-Driveby
#1

Alright I've been checking through some Anti-Driveby scripts and most(of what I've seen) use stuff like OnPlayerEnterVehicle or storing guns in big Variables. Now I've come up with the most Memory friendly and easiest solution and I'm sure your gonna like it.

Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
	{
		new Weapons[13];
		new Ammo[13];
		for(new slot = 0; slot != 13; slot++)
		{
			new wep, ammo;
			GetPlayerWeaponData(playerid, slot, wep, ammo);
			if(slot != 4)
			{
				GetPlayerWeaponData(playerid, slot, Weapons[slot], Ammo[slot]);
			}
		}
		ResetPlayerWeaponsEx(playerid);
		for(new slot = 0; slot != 13; slot++)
		{
			GivePlayerWeapon(playerid, Weapons[slot], Ammo[slot]);
		}
	}
	return 1;
}
That's all! You don't actualy have to wait for the person to get out of their car. You can simply take it and instantly give it back. The player will then receive his gun back as soon as he is fully out of the vehicle.
(I'm not sure if this works in versions before 0.3b)

If you have a function called "RemovePlayerWeapon(playerid, weaponid)", you can make this script even shorter.
This is how it looks in my server:
Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
	if(newstate == PLAYER_STATE_DRIVER)
	{
	    new gun,ammo;
	    GetPlayerWeaponData(playerid, 4, gun, ammo);
	    RemovePlayerWeapon(playerid, gun);
	    GivePlayerWeapon(playerid, gun, 35578);//I use infinite ammo in my server
	}
	return 1;
}
Life can be that simple
Reply


Messages In This Thread
Extreme Simple/Efficient Anti-Driveby - by Germanator - 30.09.2010, 03:37
Re: Extreme Simple/Efficient Anti-Driveby - by MisterTickle - 30.09.2010, 03:44
Re: Extreme Simple/Efficient Anti-Driveby - by MisterTickle - 06.10.2010, 12:53
Re: Extreme Simple/Efficient Anti-Driveby - by Germanator - 19.12.2010, 03:06
Re: Extreme Simple/Efficient Anti-Driveby - by Scenario - 19.12.2010, 03:08
Re: Extreme Simple/Efficient Anti-Driveby - by Germanator - 19.12.2010, 03:13
Re: Extreme Simple/Efficient Anti-Driveby - by X35B - 19.12.2010, 03:33
Re: Extreme Simple/Efficient Anti-Driveby - by Scenario - 19.12.2010, 03:35
Re: Extreme Simple/Efficient Anti-Driveby - by X35B - 19.12.2010, 03:36
Re: Extreme Simple/Efficient Anti-Driveby - by Lorenc_ - 19.12.2010, 05:10

Forum Jump:


Users browsing this thread: 3 Guest(s)