anti drive by thing
#1

Can you make that when you enter a vehicle as driver your armed weapon changes to fists/hand?
Reply
#2

Will only work if you reset the players weapons, save them, and give them back when he leaves the car.
Reply
#3

Though so. :/
Reply
#4

Okey, I made the code for you. Was easier that I thought.

pawn Код:
new PlayerWeaponDetails[MAX_PLAYERS][13][2];
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER /*|| newstate == PLAYER_STATE_PASSENGER*/) //Just remove the ''/*'' ''*/'' and it works for Passenger too.
    {
        for (new i = 0; i < 13; i++) PlayerWeaponDetails[playerid][i][0]=0, PlayerWeaponDetails[playerid][i][1]=0;
        for (new i = 0; i < 13; i++) GetPlayerWeaponData(playerid, i, PlayerWeaponDetails[playerid][i][0], PlayerWeaponDetails[playerid][i][1]);
        ResetPlayerWeapons(playerid);
    }
    if(oldstate == PLAYER_STATE_DRIVER /*|| newstate == PLAYER_STATE_PASSENGER*/) //Same here.
    {
        if(newstate == PLAYER_STATE_ONFOOT)
        {
            for (new i = 0; i < 13; i++) GivePlayerWeapon(playerid, PlayerWeaponDetails[playerid][i][0], PlayerWeaponDetails[playerid][i][1]);
        }
    }
    return 1;
}
Note: I've tested the code, and the weapon ammo is not always correct. I think that there is a mistake in the function "GetPlayerWeaponData".

Just test the code yourself, and give me your opinion.

Greetz.
Reply
#5

Works awesome, i didnt detect any bugs.
TNX
Reply
#6

Great. Have fun. And Thank you for the feedback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)