Limit drive by allowed weapons, why does this not work?
#1

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
    {
        SetPlayerArmedWeapon(playerid, 0);
    }
   
    if(newstate == PLAYER_STATE_PASSENGER)
    {
        new gun = GetPlayerWeapon(playerid);
        if (gun != 22 || gun != 26 || gun != 28 || gun != 29 || gun != 30 || gun != 31 || gun != 32)
        {
            SetPlayerArmedWeapon(playerid, 0);
        }
        else
        {
        SetPlayerArmedWeapon(playerid, gun);
        }
    }
Driver isn't allowed to drive by, passenger can only drive-by with 9mm, tec9, uzi, MP5, AK47 or M4.

Why does this not work?
If I enter as a passenger with for example a 9mm or uzi, it still takes it away
Reply
#2

Replace all || to && ;p
Reply
#3

Thanks
Reply
#4

You can replace
pawn Код:
gun != 28 || gun != 29 || gun != 30 || gun != 31 || gun != 32
to

pawn Код:
!(28 <= gun <= 32)
Reply
#5

pawn Код:
stock GetPlayerGun(playerid){
    switch(GetPlayerWeapon(playerid)){
        case 22,26,28,29,30,31,32: return true;
    }return false;
}

if(newstate == PLAYER_STATE_DRIVER){
    SetPlayerArmedWeapon(playerid, 0);
}
if(newstate == PLAYER_STATE_PASSENGER){
    if(GetPlayerGun(playerid)){
        SetPlayerArmedWeapon(playerid, 0);
    {else{
        SetPlayerArmedWeapon(playerid, GetPlayerGun(playerid));
    }
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)