SA-MP Forums Archive
Drive-By System - 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: Drive-By System (/showthread.php?tid=495960)



Drive-By System - Drago987 - 19.02.2014

Hello,i've made a Drive By System with this codes
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER)
      {
            new weapons[13][2];
            for (new i = 0; i < 13; i++)
            {
                GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
            }
            SetPlayerArmedWeapon(playerid, 0);
            if(newstate == PLAYER_STATE_ONFOOT && PLAYER_STATE_PASSENGER)
            {
                     for( new i; i < 13; i++)
                     {
                           SetPlayerArmedWeapon(playerid, 31) && SetPlayerArmedWeapon(playerid, 29) && SetPlayerArmedWeapon(playerid, 28) && SetPlayerArmedWeapon(playerid, 32);
                     }
             }
             return 1;
    }
which supposed to make the passenger only be able to hold a specific weapons (Tec9,M4,UZI and MP5) only but when a player enter a vehicle as a passenger he can hold any weapon he want Not the specific weapons only.
Can someone help me with it please ?
++ REP


Re: Drive-By System - xo - 19.02.2014

Replace
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
with
pawn Код:
if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER)



Re: Drive-By System - Bingo - 19.02.2014

Try to set ONE only, For example
Код:
SetPlayerArmedWeapon(playerid, 29)
If still players can hold any weapon, Then see in filterscripts there might be something.


Re: Drive-By System - Drago987 - 19.02.2014

Quote:
Originally Posted by XO
Посмотреть сообщение
Replace
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
with
pawn Код:
if(newstate == PLAYER_STATE_PASSENGER || newstate == PLAYER_STATE_DRIVER)
that made the player cant use the weapons as a passenger

Quote:
Originally Posted by [vTc]Patroool
Посмотреть сообщение
Try to set ONE only, For example
Код:
SetPlayerArmedWeapon(playerid, 29)
If still players can hold any weapon, Then see in filterscripts there might be something.
i've made it One weapon but players still can hold any weapon.I'm using this code in the GM but i cant find any problem with it
Any Other ideas ?


Re: Drive-By System - Bingo - 19.02.2014

Okay listen, Keep the weapon ONE only. And change here all 13 to 1. Compile and try


Re: Drive-By System - xo - 19.02.2014

My bad i read it wrong, try
pawn Код:
if(newstate==PLAYER_STATE_PASSENGER)
                    {
                    new gun,tmpaa;
                    GetPlayerWeaponData(playerid,4,gun,tmpaa);
                    #pragma unused tmpaa
                    if(gun != 28 || gun != 29 || gun != 32 || gun != 31) SetPlayerArmedWeapon(playerid,0);
                    else SetPlayerArmedWeapon(playerid,gun);
                }
Will keep uzi ,, etc else it will disarm him.


Re: Drive-By System - Drago987 - 19.02.2014

Quote:
Originally Posted by XO
Посмотреть сообщение
My bad i read it wrong, try
pawn Код:
if(newstate==PLAYER_STATE_PASSENGER)
                    {
                    new gun,tmpaa;
                    GetPlayerWeaponData(playerid,4,gun,tmpaa);
                    #pragma unused tmpaa
                    if(gun != 28 || gun != 29 || gun != 32 || gun != 31) SetPlayerArmedWeapon(playerid,0);
                    else SetPlayerArmedWeapon(playerid,gun);
                }
Will keep uzi ,, etc else it will disarm him.
it still make the player able to use any weapon. Here is the whole Code ,i may did something wrong
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
      {
            new weapons[13][2];
            for (new i = 0; i < 13; i++)
            {
                GetPlayerWeaponData(playerid, i, weapons[i][0], weapons[i][1]);
            }
            SetPlayerArmedWeapon(playerid, 0);
            if(newstate==PLAYER_STATE_PASSENGER)
                    {
                    new gun,tmpaa;
                    GetPlayerWeaponData(playerid,4,gun,tmpaa);
                    #pragma unused tmpaa
                    if(gun != 28 || gun != 29 || gun != 32 || gun != 31) SetPlayerArmedWeapon(playerid,0);
                    else SetPlayerArmedWeapon(playerid,gun);
                }
                return 1;
      }



Re: Drive-By System - xo - 19.02.2014

Dude use this remove all what you doing

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
            if(newstate==PLAYER_STATE_PASSENGER)
                {
                    new gun,tmpaa;
                    GetPlayerWeaponData(playerid,4,gun,tmpaa);
                    #pragma unused tmpaa
                    if(gun != 28 || gun != 29 || gun != 32 || gun != 31) SetPlayerArmedWeapon(playerid,0);
                    else SetPlayerArmedWeapon(playerid,gun);
                }
                return 1;      
}



Re: Drive-By System - Drago987 - 19.02.2014

Now pawno is crashing


Re: Drive-By System - Scenario - 19.02.2014

Don't do it under OnPlayerStateChange. Try this:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    switch(ispassenger)
    {
        case 1:
        {
            new
                curWeapon = GetPlayerWeapon(playerid);
           
            if(curWeapon != 28 || curWeapon != 29 || curWeapon != 32 || curWeapon != 31) SetPlayerArmedWeapon(playerid, 0);
        }
        default: SetPlayerArmedWeapon(playerid, 0);
    }      
    return 1;
}