taxi service
#1

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

start in OnPlayerExitVehicle
Reply
#3

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


Forum Jump:


Users browsing this thread: 2 Guest(s)