OnPlayerEnterVehicle
#1

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    for(new i = 0; i < MAX_PLAYERS;i++) {
        if(GetPlayerState(i) == PLAYER_STATE_PASSENGER) {
            new driver;
            driver = GetPlayerState(i);
            if(driver == PLAYER_STATE_DRIVER && IsPlayerInVehicle(i, vehicleid) && IsPlayerConnected(i)) {
                GivePlayerMoney(driver, 12);
                GivePlayerMoney(playerid, -12);
            }
        }
    }
    return 1;
}
Nothing happens..the driver doesnt get money and the passenger doesnt get -12 taken
Reply
#2

Put it undder
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate) {
Reply
#3

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
  if(GetPlayerState(playerid) == PLAYER_STATE_PASSENGER)
  {
   GivePlayerMoney(playerid,-12);
  }
  else if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
  {
   GivePlayerMoney(playerid,12);
  }
  return 1;
}
NOT TESTED. But you dont need to loop.
Reply
#4

I'm trying to do this for a taxi kind of thing so it will give the money to the driver so did i do it correct on finding the driver from the car he was entering?
Reply
#5

Youcan also add.
pawn Код:
stock IsATaxi(vehicleid) {
    switch(GetVehicleModel(vehicleid)) {
        case 420, 438, 437: return 1;  
    }
    return 0;
}

pawn Код:
if(IsATaxi(GetPlayerVehicleID(playerid))) {
Reply
#6

Lordz wouldn't that just give me the money if i entered as a passenger or driver? i want it so if there is already a driver in the car and you enter as a passenger your money will go down and the drivers will go up
Reply
#7

What I would do is set it up so that a player does a command.
Like /fare.

And it checks what seat they're in, and if they're a taxi driver.

If they're driving, and they're a taxi driver, it gives them 12 bucks and takes 12 from the passenger.
You could also set up a timer that loops until the person gets out.

Wouldn't be that difficult, I'm sure you could do it.
Reply
#8

Tried adding it under
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    return 1;
}
?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)