ADMIN ONLY VEH HELP
#1

im making:
Код:
Vehicle ID: 490
Vehicle Name: FBI Rancher
Category: Public Service
Modifications: None


an admin only vehicle and heres the code i made but it doest work, any help?

pawn Код:
if(vehicleid == 490)
    {
      if(Level[playerid] == 1 && IsLoggedIn[playerid] == 1)
      {
        SendClientMessage(playerid,COLOR_PINK,"*** [ADMIN VEHICLE] You Are In An Admin Only Vehicle.");

        }
        else
        {
          GameTextForPlayer(playerid,"~r~Ejected",3000,5);
          SendClientMessage(playerid,COLOR_SPRINGGREEN,"Only Admins Can Use This Vehicle.");
          RemovePlayerFromVehicle(playerid);
        }
    }
EDIT: Its in OnPlayerEnterVehicle
Reply
#2

Its the vehicle ID not the Model ID.

(Maybe) do:

pawn Код:
new carmodel;
carmodel = GetPlayerModel(vehicleid);
if(carmodel == 490)
Not entirely sure though - something along those lines
Reply
#3

hey, this should work, i tested it on my own game mode just now.

but please note, it needs to go under
pawn Код:
public OnPlayerStateChange(playerid,newstate,oldstate)
I'll explain why after..

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

    if(oldstate == PLAYER_STATE_ONFOOT)
    {
    if(plvehid == 490)
        {
        if(Level[playerid] == 1 && IsLoggedIn[playerid] == 1)
        {
            SendClientMessage(playerid,COLOR_PINK,"*** [ADMIN VEHICLE] You Are In An Admin Only Vehicle.");
            }
        else
            {
            GameTextForPlayer(playerid,"~r~Ejected",3000,5);
        SendClientMessage(playerid,COLOR_SPRINGGREEN,"Only Admins Can Use This Vehicle.");
        RemovePlayerFromVehicle(playerid);
            }
        }
    }
Ok, the reason it wont work with OnPlayerEnterVehicle is because that function is called ONLY when the player presses to enter the vehicle.

So OnPlayerEnterVehicle is called as the player is actually getting into the vehicle, NOT while they're inside it.

So when they're getting into it, they aren't actually inside te vehicle, so they cant be ejected, even though the message might display.

OnPlayerStateChange is called when the player finishes getting into the vehicle, because their state has officially changed from on foot, to driver or passenger.


The only thing i found that i couldn't get working is the GameTextForPlayer, when they enter as a driver it doesnt show, but the other message does, and they're ejected. So that part works.

When the player enters as a passenger the EJECTED message works.

If you want to change it so that it can accept passengers, then just change
pawn Код:
if(oldstate == PLAYER_STATE_ONFOOT)
to

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)