How to check for vehicle passengers -
Jochemd - 31.08.2010
Hello,
Is it possible to check for vehicle passengers?
Regards, Jochem
Re: How to check for vehicle passengers -
Peter_Corneile - 31.08.2010
Check what ? Like if theres anyone in the vehicle as passenger or not ?
Re: How to check for vehicle passengers -
Jochemd - 31.08.2010
Yes, that
Re: How to check for vehicle passengers -
Jochemd - 31.08.2010
But I want this: the driver types /park. Then the vehicle gets linked to an interior and warped. The drivers interior gets set to the interior to. But how can I set the passengers interior?
Re: How to check for vehicle passengers -
Paladin - 31.08.2010
Hope this gives you an idea
Код:
for(new i = 0; i < MAX_PLAYERS; i++) // Scans from 1-Max player slots
{
if(IsPlayerConnected(i)) // Checks for all connected IDs
{
if(GetPlayerVehicleID(i) == GetPlayerVehicleID(playerid) && i != playerid) // Makes sure the connected IDs are in the car and is not the person that typed /park
{
SetPlayerInterior(i, [INTERIOR]); // Sets interior of the player found in the vehicle
}
}
}
It's untested, but I think it should work
Re: How to check for vehicle passengers -
Jochemd - 31.08.2010
Of course, that must work
Re: How to check for vehicle passengers -
Mauzen - 31.08.2010
With the native functions it is not possible.
But you could do something like this: (not tested)
pawn Код:
GetVehiclePassengers(vehicleid, &passengers[4])
{
for(new i = 0; i < 4; i ++)
passengers[i] = -1;
for(new i = 0; i < MAX_PLAYERS; i ++)
if(GetPlayerVehicleID(i) == vehicleid)
passengers[GetPlayerVehicleSeat(i)] = i;
}
it should fill an array with the players on the seat 0-3 of vehicleid. If a seat is unoccupied, it returns -1 for the seat id.
EDIT: Paladin was faster, his code should fit perfectly to your needs
Re: How to check for vehicle passengers -
Jochemd - 31.08.2010
@ Mauzen: How can I use that with interior? Does it need to be stored away into a variable?
Re: How to check for vehicle passengers -
Mauzen - 31.08.2010
You would have to create an array, send it to the function, and then set the interior for all players in the array. So its more hard to use than Paladins code, but can be used for lots of other stuff, too.
Re: How to check for vehicle passengers -
Jochemd - 31.08.2010
Indeed, I will add it into my gm