13.07.2018, 19:31
Under OnPlayerKeyStateChange
Code above will check to see the player press the H key, then check to see if they're in a vehicle and not in the drivers seat.
It will then check the weapon the player has (in-hand) and if it comes up with any ID's you check for, it'll respond with the code you entered.
In my code, if the weapon they're using isn't allowed, it sends them a message and places them back in the passenger seat (if I didn't put them back in the passenger seat, it would still allow them to drive-by, so I'd recommended also using ApplyAnimation to put them back in the passenger seat)
PHP код:
if ((newkeys & 2) && !(oldkeys & 2)) //key 2 is what we have to use to check if the key pressed was H.
{
if(IsPlayerInAnyVehicle(playerid) && GetPlayerVehicleSeat(playerid) != 0)
{
switch(GetPlayerWeapon(playerid))
{
case 31: {SendClientMessage(playerid, -1, "You can't drive-by with this weapon."); ApplyAnimation(playerid, "PED", "CAR_sitp", 4.1, 0, 0, 0, 0, 0, 0); return 1;}
case /*weapon id you don't want to be able to driveby with, i.e. m4*/: {SendClientMessage(playerid, -1, "You can't drive-by with this weapon."); ApplyAnimation(playerid, "PED", "CAR_sitp", 4.1, 0, 0, 0, 0, 0, 0); return 1;}
}
}
}
It will then check the weapon the player has (in-hand) and if it comes up with any ID's you check for, it'll respond with the code you entered.
In my code, if the weapon they're using isn't allowed, it sends them a message and places them back in the passenger seat (if I didn't put them back in the passenger seat, it would still allow them to drive-by, so I'd recommended also using ApplyAnimation to put them back in the passenger seat)

