SA-MP Forums Archive
taxi service - 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: taxi service (/showthread.php?tid=67773)



taxi service - CJ101 - 04.03.2009

ok, i want to take $100 of the passanger, and give it to the driver, when the passanger exits the vehicle. help, cause i have no idea where to start.


Re: taxi service - Daren_Jacobson - 04.03.2009

start in OnPlayerExitVehicle


Re: taxi service - NigNog1 - 04.03.2009

Quote:
Originally Posted by Daren_Jacobson
start in OnPlayerExitVehicle
What does entering a vehicle have to do with taking some money away? Plus OnPlayerStateChange is a little more accurate.



Anyway, first of all you will need a function to get the driver ID of a vehicle:

Код:
stock GetVehicleDriver ( iVehicleID )
{
  for ( new iDriverID; iDriverID < GetMaxPlayers ( ); iDriverID ++ ) 
  {
    if ( GetPlayerState ( iDriverID ) == PLAYER_STATE_DRIVER )
    {
      if ( GetPlayerVehicleID ( iDriverID ) == iVehicleID)
        return iDriverID;
    }
  }
  return INVALID_PLAYER_ID;
}
Now, wherever you want to take the money away, just check get the driver ID using this function, give the driver the money, and take if off the passenger.

E.g:

Код:
if ( IsPlayerInAnyVehicle ( iPassengerID )
{
  new iDriverID = GetVehicleDriver ( GetPlayerVehicleID ( iPassengerID ));
  if ( iDriverID != INVALID_PLAYER_ID )
  {
    GivePlayerMoney ( iDriverID, 100);
   GivePlayerMoney ( iPassengerID, -100);
  }
}