SA-MP Forums Archive
How to find out which playerid is driving a vehicle - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to find out which playerid is driving a vehicle (/showthread.php?tid=126329)



How to find out which playerid is driving a vehicle - adsy - 07.02.2010

I am just trying to figure out a script whereby i need to find out who is driving the vehicle to be able to send them a message when someoen enters their vehicle.

Is this at all possible?

I'll lay out the plan.

Guy gets in car to drive it

Another guy gets in

First guy receives message saying theres someone in your vehicle
(the above line is where im stuck)
First guy gets choice to kick them out or lock them in (or ignore)

Second guy receives lock confirmation and charge or gets booted (or ignored)

second guy has to pay up to release doors unless driver unlocks


Re: How to find out which playerid is driving a vehicle - XeoN_13 - 07.02.2010

Im not sure how to doit but i can guess it uses IsPlayerInVeh , or something like this


Re: How to find out which playerid is driving a vehicle - adsy - 07.02.2010

may as well start to build it

Код:
check = GetPlayerVehicleID(playerid);
if(IsPlayerInVehicle(playerid, check))
{
new state = GetPlayerState(idofplayerdriving);

 if(state = PLAYER_STATE_DRIVER)
 {
 
 }

}



Re: How to find out which playerid is driving a vehicle - adsy - 07.02.2010

i did a search and found this:

Код:
for(new i=0; i<MAX_PLAYERS; i++)
{
if(GetPlayerState(i) == PLAYER_STATE_DRIVER && GetPlayerState(playerid) != PLAYER_STATE_DRIVER && GetVehicleModel(GetPlayerVehicleID(playerid)) == 420)
{
//STUFF
}
}
modified now


Re: How to find out which playerid is driving a vehicle - Coicatak - 07.02.2010

pawn Код:
stock GetVehicleDriver(vehicle) //the function
{
  for(new i=0; i<MAX_PLAYERS, IsPlayerConnected(i); i++) //check for every connected players
  {
    if(GetPlayerVehicleID(i) == vehicle && GetPlayerState(i) == PLAYER_STATE_DRIVER) return i; //if the player chechek drives the car it returns his ID
  }
  return INVALID_PLAYER_ID; //else it returns INVALID_PLAYER_ID
}