Detect holding weapon as passenger?
#1

I've been searching since a lot of days, how I could detect the weapon of someone when the user enter a car.
Example: If the user has an M16 and try to shoot as passenger, it would kick him out from the car.

I thought about using GetPlayerWeapon(playerid); but I thought it wouldn't work because I'm trying to detect if the user is shooting as passenger.

I'd be very grateful to the person that will help me.
Thanks
Reply
#2

I don't think it's possible to detect shooting.
Reply
#3

Quote:
Originally Posted by Mean
Посмотреть сообщение
I don't think it's possible to detect shooting.
Well detect if the key used to take the weapon out of the car window is pressed then...
Reply
#4

Quote:
Originally Posted by M.A
Посмотреть сообщение
Well detect if the key used to take the weapon out of the car window is pressed then...
Yeah, but that's not accurate.
Reply
#5

This is a guess I just thought of, but it might work:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetPlayerWeapon(playerid) != 0 || GetPlayerWeapon(playerid) != 1)
    {
        SetPlayerArmedWeapon(playerid,0);
    }
    return 1;
}
It gets the player's weapons if they are either unarmed or brassknuckles they will have no problem if they arent holding them then it will change them to not holding a gun inside the car. You would have to play around with it to see if its working because I didnt test it.

Also to get the state of the player try using these:

pawn Код:
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)

if (GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
Reply
#6

Quote:
Originally Posted by Tommy_Mandaz
Посмотреть сообщение
This is a guess I just thought of, but it might work:

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(GetPlayerWeapon(playerid) != 0 || GetPlayerWeapon(playerid) != 1)
    {
        SetPlayerArmedWeapon(playerid,0);
    }
    return 1;
}
It gets the player's weapons if they are either unarmed or brassknuckles they will have no problem if they arent holding them then it will change them to not holding a gun inside the car. You would have to play around with it to see if its working because I didnt test it.

Also to get the state of the player try using these:

pawn Код:
if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER)

if (GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
Thanks mate.
Well, I still want the player to be a passenger, just not to be able to shoot out of the car...
I'll try to see what I can do.
Reply
#7

Yeah so you would probably do this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        if(GetPlayerWeapon(playerid) != 0 || GetPlayerWeapon(playerid) != 1)
        {
            SetPlayerArmedWeapon(playerid,0);
        }
    }
    return 1;
}
Reply
#8

Quote:
Originally Posted by Tommy_Mandaz
Посмотреть сообщение
Yeah so you would probably do this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if (GetPlayerState(playerid) == PLAYER_STATE_DRIVER || GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
    {
        if(GetPlayerWeapon(playerid) != 0 || GetPlayerWeapon(playerid) != 1)
        {
            SetPlayerArmedWeapon(playerid,0);
        }
    }
    return 1;
}
Wow, I didn't thought about disarm the player as passenger!
Thanks buddy!
Reply
#9

No problem
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)