Preventing player bug abuse
#1

The point of this piece of code is to find if a player is on the back of a bike without anyone on the front and if they have a gun then set the player armed weapon to fists. Then if someone gets on the bike while the disarmed player is on the back, it will give the weapon back that they had equipped before. This is all to prevent them from abusing the GTA SA bug of not losing health while in drive by mode alone on the back of a bike.

The problem with it is it just takes the weapon even if their is someone on the front, and it doesn't give it back at any point.
pawn Code:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    new LastWep[MAX_PLAYERS];
    if(newstate == PLAYER_STATE_PASSENGER && IsABike(GetPlayerVehicleID(playerid)))
    {
        new PlayerFound;
        foreach(new i:Player)
        {
            if(GetPlayerVehicleID(playerid) == GetPlayerVehicleID(i) && newstate == PLAYER_STATE_DRIVER)
            {
                PlayerFound = 1;
            }
        }
        if(!PlayerFound && !!GetPlayerWeapon(playerid))
        {
            LastWep[playerid] = GetPlayerWeapon(playerid);
            SetPlayerArmedWeapon(playerid,0);
        }
        else if(PlayerFound && !GetPlayerWeapon(playerid) && !!LastWep[playerid])
        {
            RemovePlayerFromVehicle(playerid);
            SetPlayerArmedWeapon(playerid,LastWep[playerid]);
            PutPlayerInVehicle(playerid,GetPlayerVehicleID(playerid),1);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)