SA-MP Forums Archive
Limit drive by allowed weapons, why does this not work? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Limit drive by allowed weapons, why does this not work? (/showthread.php?tid=495790)



Limit drive by allowed weapons, why does this not work? - AnthonyTimmers - 18.02.2014

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


Re: Limit drive by allowed weapons, why does this not work? - Jefff - 18.02.2014

Replace all || to && ;p


Re: Limit drive by allowed weapons, why does this not work? - AnthonyTimmers - 18.02.2014

Thanks


Re: Limit drive by allowed weapons, why does this not work? - Jefff - 18.02.2014

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

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



Respuesta: Limit drive by allowed weapons, why does this not work? - OTACON - 18.02.2014

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));
    }
}