how to add drive by , help me?
#5

Under OnPlayerKeyStateChange

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.1000000); 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.1000000); return 1;}
        }
    }

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


Messages In This Thread
how to add drive by , help me? - by linhpro200294 - 13.07.2018, 07:54
Re: how to add drive by , help me? - by linhpro200294 - 13.07.2018, 08:18
Re: how to add drive by , help me? - by linhpro200294 - 13.07.2018, 10:56
Re: how to add drive by , help me? - by linhpro200294 - 13.07.2018, 11:03
Re: how to add drive by , help me? - by ItsRobinson - 13.07.2018, 19:31

Forum Jump:


Users browsing this thread: 1 Guest(s)