SA-MP Forums Archive
Whats wrong with this - 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: Whats wrong with this (/showthread.php?tid=129492)



Whats wrong with this - Torran - 22.02.2010

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid = GetPlayerVehicleID(playerid);

  if(newstate == PLAYER_STATE_DRIVER)
  {
    if(IsACopCar(vehicleid))
        {
          if(GetPlayerTeam(playerid) == TEAM_POLICE)
          {
            }
        }
        else
        {
          SendClientMessage(playerid, 0xFFFFFFFF, "You are not authorized to drive this vehicle");
            RemovePlayerFromVehicle(playerid);
        }
        if(IsAmbulance(vehicleid))
        {
          if(GetPlayerTeam(playerid) == TEAM_MEDIC)
          {
            }
        }
        else
        {
          SendClientMessage(playerid, 0xFFFFFFFF, "You are not authorized to drive this vehicle");
            RemovePlayerFromVehicle(playerid);
        }
    }
    return 1;
}

If im a cop and try get in ambulance, It dont let me in and kicks me out,
If i try get in cop car as a cop, It lets me,

If i spawn as medic and try get in ambulance, It dosent let me and kicks me out,
If i get in the cop car as a medic it lets me drive off??

Why is this


Re: Whats wrong with this - aircombat - 22.02.2010

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    new vehicleid = GetPlayerVehicleID(playerid);

  if(newstate == PLAYER_STATE_DRIVER)
  {
    if(IsACopCar(vehicleid))
        {
          if(GetPlayerTeam(playerid) == TEAM_POLICE)
          {
            return 1;
          }
          else
          {
          SendClientMessage(playerid, 0xFFFFFFFF, "You are not authorized to drive this vehicle");
          RemovePlayerFromVehicle(playerid);
        }
       }
        if(IsAmbulance(vehicleid))
        {
          if(GetPlayerTeam(playerid) == TEAM_MEDIC)
          {
            return 1;
          }
        else
        {
          SendClientMessage(playerid, 0xFFFFFFFF, "You are not authorized to drive this vehicle");
            RemovePlayerFromVehicle(playerid);
        }
    }
}
    return 1;
}
that should work

________
SUZUKI T SERIES HISTORY


Re: Whats wrong with this - Torran - 22.02.2010

I had a simpler code before but i lost it,
It was a better method than that,
Does anyone know?