SA-MP Forums Archive
OnPlayerEnterVehicle - 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)
+--- Thread: OnPlayerEnterVehicle (/showthread.php?tid=383153)



OnPlayerEnterVehicle - thefatshizms - 06.10.2012

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


Re: OnPlayerEnterVehicle - ikbenremco - 06.10.2012

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



Re: OnPlayerEnterVehicle - Lordzy - 06.10.2012

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.


Re: OnPlayerEnterVehicle - thefatshizms - 06.10.2012

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?


Re: OnPlayerEnterVehicle - ikbenremco - 06.10.2012

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

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



Re: OnPlayerEnterVehicle - thefatshizms - 06.10.2012

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


Re: OnPlayerEnterVehicle - Unfriendly - 06.10.2012

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.


Re: OnPlayerEnterVehicle - Faisal_khan - 06.10.2012

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