Restrict drive-by? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Restrict drive-by? (
/showthread.php?tid=308139)
Restrict drive-by? -
Arrows73 - 02.01.2012
Hi,
Is it possible to restrict drive-bys (not the passenger but the driver ones)?
Thanks in advance!
Re: Restrict drive-by? -
Basssiiie - 02.01.2012
Check with OnPlayerKeyStateChange if the player is shooting while in a vehicle and while he's the driver of the vehicle. Make sure to except some vehicles like the Rhino, Rustler, Hunter ect.
Re: Restrict drive-by? -
silvan - 02.01.2012
how about change the weapon slot? back to fist pounch when they enter a vehicle as driver
Re: Restrict drive-by? -
Sinner - 02.01.2012
You can reset the weapons of the player if he's a driver, and set the weapons back when he gets out of the vehicle.
Example (GivePlayerWeapons(playerid) is a custom function you would need to write):
pawn Код:
new bool:RestrictedDriveBy[MAX_PLAYERS]; // On topof script
public OnPlayerEnterVehicle(playerid, vehicleid) {
// Check if the player is the driver
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER) {
ResetPlayerWeapons(playerid); // Reset his weapons
RestrictedDriveBy[playerid] = true;
}
}
public OnPlayerExitVehicle(playerid, vehicleid) {
if(RestrictedDriveBy[playerid] == true) {
GivePlayerWeapons(playerid); // Give him back his weapons (custom)
RestrictedDriveBy[playerid] = false;
}
}
Re: Restrict drive-by? -
silvan - 02.01.2012
No need to reset... that is a alot of useless code....
All you need is this
pawn Код:
SetPlayerArmedWeapon(playerid,0);
Put it under the OnPlayerStateChange
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(newstate == PLAYER_STATE_DRIVER)
{
SetPlayerArmedWeapon(playerid,0);
return 1;
}
return 1;
}
This set the player holding fists when they enter a vehicle. I'm sure it works well
AW: Restrict drive-by? -
Arrows73 - 03.01.2012
@Sinner: That would take a long time, saving all that stuff in an enum etc.
@silvan: Thx! Didn't think about that
That should work