How to find out which playerid is driving a vehicle
#1

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
Reply
#2

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

may as well start to build it

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

 if(state = PLAYER_STATE_DRIVER)
 {
 
 }

}
Reply
#4

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
Reply
#5

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
}
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)