In car & skin != ...
#1

Hello. I have three requests.


If player is in a taxi, and is not skin 102
then player get ejected from the taxi.

If player is in a plane, and is not skin 110
then player get ejected from the plane.

If player is in a cop-car, and is not skin 282 || 281
then player get ejected from the cop-car.
Reply
#2

You need:

GetPlayerSkin
GetPlayerVehicleID
GetVehicleModel
RemovePlayerFromVehicle

And why not lock vehicles doors?
Reply
#3

Quote:
Originally Posted by 0rb
You need:

GetPlayerSkin
GetPlayerVehicleID
GetVehicleModel
RemovePlayerFromVehicle

And why not lock vehicles doors?
An example please?
Reply
#4

Top of script
pawn Код:
new skin;
OnPlayerEnterVehicle
pawn Код:
skin = GetPlayerSkin(playerid);
if(skin != PUTYOUROWNSKINNUMBERHERE && vehicleid == THEVEHICLEIDGOESHERE)
{
//eject them
}
Get the gist?
Reply
#5

Taken From Outbreaks old post.

Quote:
Originally Posted by Outbreak
This should help you, I've made it so no player can enter as driver or passenger, if you want to change that just remove the "|| newstate == PLAYER_STATE_PASSENGER" part.

pawn Код:
new plvehid;
    plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
    new skin = GetPlayerSkin(playerid);
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(plvehid == 597)
        {
            if( (skin == 287) || (skin == 163) || (skin == 282) || (skin == 255) || (skin == 165))
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "== You can use this vehicle to do your job.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "== You are not a cop.");
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
Place it under public OnPlayerStateChange(playerid,newstate,oldstate)

If you place it under OnPlayerEnterVehicle it will only be called when the player pressed ENTER, at that time they aren't yet in the vehicle, so they can't be ejected from it.

http://forum.sa-mp.com/index.php?topic=92053.0

And here it is modified with Andre's IsAirVehicle IsCopCar function:

pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
    new plvehid;
    plvehid = GetVehicleModel(GetPlayerVehicleID(playerid));
    new skin = GetPlayerSkin(playerid);
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if(plvehid == 420)
        {
            if(skin == 102)
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "== You can use this vehicle to do your job.");
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "== You are not a Taxi Driver - Ejected");
                RemovePlayerFromVehicle(playerid);
            }
        }
        if(IsAirVehicle(plvehid))
        {
            if(skin == 110)
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "== You can use this Plane");
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "== You cannot use this plane - Ejected");
                RemovePlayerFromVehicle(playerid);
            }
        }
        if(IsCopCar(plvehid))
        {
            if( (skin == 282) || (skin == 281))
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "== You Can use this Cop Car");
            }
            else
            {
                SendClientMessage(playerid, COLOR_LIGHTBLUE, "== You cannot use this Cop Car - Ejected");
                RemovePlayerFromVehicle(playerid);
            }
        }
    }
    return 1;
}

stock IsAirVehicle(plvehid)
{
  new AirVeh[] = { 592, 577, 511, 512, 593, 520, 553, 476, 519, 460, 513, 548, 425, 417, 487, 488, 497, 563, 447, 469 };
  for(new i = 0; i < sizeof(AirVeh); i++)
  {
    if(GetVehicleModel(plvehid) == AirVeh[i]) return 1;
  }
  return 0;
}

stock IsCopCar(plvehid)
{
  new Operative[] = { 523, 427, 490, 528, 596, 597, 598, 599 };
  for(new i = 0; i < sizeof(Operative); i++)
  {
    if(GetVehicleModel(plvehid) == Operative[i]) return 1;
  }
  return 0;
}
Untested. And i would strongly advise you to SEARCH next time, it'll save you so much time and you'll learn something rather than begging.
Reply
#6

Quote:
Originally Posted by Weirdosport
Top of script
pawn Код:
new skin;
OnPlayerEnterVehicle
pawn Код:
skin = GetPlayerSkin(playerid);
if(skin = PUTYOUROWNSKINNUMBERHERE && vehicleid == THEVEHICLEIDGOESHERE)
{
//eject them
}
Get the gist?
Yeah but where i put?
Reply
#7

in OnPlayerEnterVehicle
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)