Drive-By System
#1

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
Reply
#2

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

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.
Reply
#4

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 ?
Reply
#5

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

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.
Reply
#7

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;
      }
Reply
#8

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;      
}
Reply
#9

Now pawno is crashing
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)