SA-MP Forums Archive
Detect holding weapon as passenger? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Detect holding weapon as passenger? (/showthread.php?tid=247577)



Detect holding weapon as passenger? - M.A - 09.04.2011

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


Re: Detect holding weapon as passenger? - Mean - 09.04.2011

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


Re: Detect holding weapon as passenger? - M.A - 09.04.2011

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


Re: Detect holding weapon as passenger? - Mean - 10.04.2011

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.


Re: Detect holding weapon as passenger? - Tommy_Mandaz - 10.04.2011

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)



Re: Detect holding weapon as passenger? - M.A - 10.04.2011

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.


Re: Detect holding weapon as passenger? - Tommy_Mandaz - 10.04.2011

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



Re: Detect holding weapon as passenger? - M.A - 10.04.2011

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!


Re: Detect holding weapon as passenger? - Tommy_Mandaz - 10.04.2011

No problem