[Include] Extended functions on Vehicles / Seats
#4

pawn Код:
stock Float:GetEveryoneHP(vehicle)
{
    if(IsValidVehicle(vehicleid) == 0) return -1;
    new Float:hP = 0.0; //This should be "0.0" instead of "-1.0"
    for(new p = 0; p < MAX_PLAYERS; p++)
    {
        if(IsPlayerConnected(p) != 1 || IsPlayerInAnyVehicle(p) != 1) continue;
        if(GetPlayerVehicleID(p) != vehicleid) continue;
        if(GetPlayerState(p) != PLAYER_STATE_DRIVER) continue;
        new Float:pHP;
        GetPlayerHealth(p, pHP);
        hP = (hP + pHP); //If hP is equal to "-1.0" it will deduct "1.0" from the first instance.
    }
    return hP;
}
EDIT:

pawn Код:
stock GetVehiclePassenger(vehicleid)
{
    if(IsValidVehicle(vehicleid) == 0) return -1;
    for(new p = 0; p < MAX_PLAYERS; p++)
    {
        if(IsPlayerConnected(p) != 1 || IsPlayerInAnyVehicle(p) != 1) continue;
        if(GetPlayerVehicleID(p) != vehicleid) continue;
        if(GetPlayerVehicleSeat(p) != 1) continue;
        return p;
    }
    return -1;
}
I think it will just return the id of the very first passenger in a car/bus. What if all the seats are occupied by passengers ?
Reply


Messages In This Thread
Extended functions on Vehicles / Seats - by d3ll - 03.08.2014, 16:56
Re: Extended functions on Vehicles / Seats - by Dignity - 03.08.2014, 17:01
Re: Extended functions on Vehicles / Seats - by iFarbod - 03.08.2014, 17:03
Re: Extended functions on Vehicles / Seats - by codectile - 04.08.2014, 05:25

Forum Jump:


Users browsing this thread: 1 Guest(s)