how to certain team can enter a car TEAM_MEDIC etc
#1

I want that TEAM_MEDIC can drive Ambulance car and other teams cant
Reply
#2

pawn Код:
new vehicleid = GetPlayerVehicleID(playerid);

  if(newstate == PLAYER_STATE_DRIVER)
  {
    if(GetVehicleModel(vehicleid) == 416)
        {
             if(!GetPlayerTeam .....
             {
SendClientMessage(playerid, 0xFFFFFFFF, "You are not authorized to drive this vehicle");
        RemovePlayerFromVehicle(playerid);
        }
    }
}
    return 1;
}
SORRY THATS WRONG IL EDIT IT
EDITED TRY THT
Reply
#3

Where i add it under ?
Reply
#4

[B]OnPlayerStateChange
Reply
#5

i get 4 errors
Reply
#6

Lol yeah sorry about that
Here this is from my script,
Edit it, It should work i havent tested it yet

pawn Код:
forward IsACopCar(vehicleid);
forward IsAmbulance(vehicleid);

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;
}
public IsACopCar(vehicleid)
{
   if(GetVehicleModel(vehicleid) == 597 || GetVehicleModel(vehicleid) == 598 || GetVehicleModel(vehicleid) == 599)
   {
      return 1;
   }
   else return 0;
}

public IsAmbulance(vehicleid)
{
   if(GetVehicleModel(vehicleid) == 416)
   {
      return 1;
   }
   else return 0;
}
Reply
#7

1 warning
Код:
warning 219: local variable "vehicleid" shadows a variable at a preceding level
Reply
#8

Do you have vehicleid at top of your script?
Reply
#9

I think not

Код:
 new vehicleid;
?

Reply
#10

Search your script for

new vehicleid = GetPlayerVehicleID(playerid);

Do you find it anywhere?
If not then

new vehicleid;

See if you can find that
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)