Anti bike passenger DB godmode not working
#1

pawn Код:
new LastWep[MAX_PLAYERS];
public HalfSecondVariables()
{
    foreach(new playerid:Player)
    {
        if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER && IsABike(GetPlayerVehicleID(playerid)))
        {
            new PlayerFound;
            foreach(new i:Player)
            {
                if(GetPlayerVehicleID(playerid) == GetPlayerVehicleID(i) && GetPlayerState(i) == PLAYER_STATE_DRIVER)
                {
                    PlayerFound = 1;
                }
            }
            if(!PlayerFound && !!GetPlayerWeapon(playerid))
            {
                LastWep[playerid] = GetPlayerWeapon(playerid);
                SetPlayerArmedWeapon(playerid,0);
            }
            else if(PlayerFound && !GetPlayerWeapon(playerid) && !!LastWep[playerid])
            {
                SetPlayerArmedWeapon(playerid,LastWep[playerid]);
            }
        }
    }
    return 1;
}
It works fine besides returning the gun after the driver enters the bike again.
Reply
#2

What you exactly want ? and use OnPlayerStateChange for that
Reply
#3

I want it to set the players equipped weapon to fists when they try to shoot with 'drive by' on the back of an empty bike, then set it back once a player is on the bike again. This will not give the weapon back to the player on the back of the bike.
Reply
#4

Why not use:
pawn Код:
public OnPlayerStateChange(playerid, oldstate, newstate)
{
  if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    GivePlayerWeapon(playerid, 0, 1);
  return 1;
}
I haven't tested it, but see no reason why it shouldn't work.
Reply
#5

Because that doesn't give back the weapon like it was before it was taken.
Reply
#6

pawn Код:
new LastWep[MAX_PLAYERS];

public OnPlayerStateChange(playerid, oldstate, newstate)
{
    if(newstate == PLAYER_STATE_ONFOOT)
    {
        if(LastWeap[playerid])
            SetPlayerArmedWeapon(playerid,LastWep[playerid]);

        LastWep[playerid] = 0;
    }
    else if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(IsABike(GetPlayerVehicleID(playerid)))
        {
            LastWep[playerid] = GetPlayerWeapon(playerid);
            SetPlayerArmedWeapon(playerid,0);
        }
    }
    return 1;
}
Reply
#7

This just takes the weapon away no matter what, even if their is someone in the driver seat of the bike and at no time does it give it back.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)