How can I prevent passanger drive-by with no driver?
#1

Does anyone know how I can prevent players from sitting in a vehicle as a passanger when there is no driver?
Reply
#2

You need anti G-Bug
Reply
#3

@better version is kar post's.
Reply
#4

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    if(ispassenger)
    {
        if(GetVehicleDriverCount(vehicleid) == 0)
        {
            ClearAnimations(playerid);
            return 0;
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_PASSENGER)
    {
        new vehicleid = GetPlayerVehicleID(playerid);
        if(GetVehicleDriverCount(vehicleid) == 0)
        {
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}

stock GetVehicleDriverCount(vehicleid) {

    if ((vehicleid <= 0) || (vehicleid == INVALID_VEHICLE_ID) || (vehicleid > MAX_VEHICLES)) return INVALID_PLAYER_ID;
    new totaldrivers = 0, i ;
    for (i = 0; i < MAX_PLAYERS; i++)
    {
        if (IsPlayerConnected(i) == 0) continue;
        if (GetPlayerState(i) != PLAYER_STATE_DRIVER) continue; // not a driver of any vehicle?
        if (GetPlayerVehicleID(i) == vehicleid) // found a connected driver in this car.
        {
            totaldrivers++;
        }
    }
    return totaldrivers; // return how many there are.
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)