SA-MP Forums Archive
[SOLVED]Detect a player in car ? - 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: [SOLVED]Detect a player in car ? (/showthread.php?tid=73601)



[SOLVED]Detect a player in car ? - Zeromanster - 16.04.2009

I made a command on my server that when the player types it in, it puts him in a RC vehicle.

Now the problem is, that if someone already is in that vehicle others can still type in that command and 2 (or more) players would end up together in that RC vehicle as drivers (and thats not fun )

Is there a way to detect is that RC vehicle free ?

So if it's free, it would normally put player in the vehicle, and if it's not it would display a message like "The RC vehicle is being used, try again later."

Thanks for your answers


Re: Detect a player in car ? - Donny_k - 16.04.2009

pawn Код:
//top
new
  theRC;

//in creation
  theRC = CreateVehicle( .......................

//in your command
  bool: allowed = true;
  for ( new i; i < MAX_PLAYERS; i ++ )
  {
    if ( GetPlayerVehicleID( i ) == theRC )
    {
      allowed = false;
      break;
    }
  }
  if ( allowed ) PutPlayerInVehicle( ..........
  else SendClientMessage( ............., "that vehicle is taken, blah blah.........."



Re: Detect a player in car ? - Zeromanster - 16.04.2009

Thanks Donny, it works