30.09.2010, 03:37
(
Последний раз редактировалось Germanator; 30.09.2010 в 03:56.
)
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.
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:
Life can be that simple
Код:
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; }
(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; }