Restrict drive-by?
#1

Hi,
Is it possible to restrict drive-bys (not the passenger but the driver ones)?

Thanks in advance!
Reply
#2

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.
Reply
#3

how about change the weapon slot? back to fist pounch when they enter a vehicle as driver
Reply
#4

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;
    }
}
Reply
#5

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
Reply
#6

@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
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)