Quote:
Originally Posted by [DOG]irinel1996
Someone suggested this for SA-MP 0.3x, so I tried to make it:
pawn Код:
stock GetVehiclePlayerInSeat(vehicleid, seatid) { if (!GetVehicleModel(vehicleid)) return INVALID_VEHICLE_ID; new total = GetMaxPlayers() ; for (new x; x < total; x++) { if (IsPlayerConnected(x)) { if (IsPlayerInAnyVehicle(x) && GetPlayerVehicleSeat(x) == seatid) { return x; //Thanks ****** for making me notice this. (player id 0 issue) break; } } } return INVALID_PLAYER_ID; //Thanks Slice }
Returns:
x -> player's id who is seated on the seatid.
INVALID_VEHICLE_ID -> the vehicle doesn't exist.
INVALID_PLAYER_ID -> the seatid is empty.
PD: I didn't test it, but I guess it should work.
Best regards!
EDIT: Tested.
|
That's going to give a warning. You can't have the break keyword under the return keyword, so you'll have to remove the
break;