03.08.2014, 14:05
Here's a short example that I just created:
This will print the seats that each player inside your vehicle is in. I must give credit to Jeff somewhat for a few parts of this code as he taught me a few things quite a while back.
cnt - The number of players inside your vehicle.
Seat[#][0] - The id of the #'th player inside your vehicle.
Seat[#][1] - The seat id of the #'th player inside your vehicle.
pawn Код:
new veh = GetPlayerVehicleID(playerid), cnt = 0, Seat[10][2], i;
for(i = 0; i < MAX_PLAYERS; i++) //Start a loop through all players. (Foreach is the recommended approach)
{
if(!IsPlayerConnected(i)) continue; //This skips ids that aren't connected. Remove if using Foreach
if(!IsPlayerInVehicle(i, veh)) continue; //This skips ids that are not inside your vehicle.
new vseat = GetPlayerVehicleSeat(i); //Get the player's vehicle seat ID
Seat[cnt][0] = i; //Save the playerid to the first element.
Seat[cnt][1] = (-1 < vseat < sizeof(Seat)) ? (vseat) : (cnt + 1); //Save the player's seat to the second element
++cnt; //Add '1' to the seat count.
}
for(i = 0; i < cnt; i++) printf("ID %d is in Seat ID %d", Seat[i][0], Seat[i][1]);
cnt - The number of players inside your vehicle.
Seat[#][0] - The id of the #'th player inside your vehicle.
Seat[#][1] - The seat id of the #'th player inside your vehicle.