Vehicle Restrictions Not working.
#1

How would I restrict a hunter vehicle? Here is my code
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(vehicleid != 425 )
        {
        new Float:slx, Float:sly, Float:slz;
        GetPlayerPos(playerid, slx, sly, slz);
        RemovePlayerFromVehicle(playerid);
        SetPlayerPos(playerid, slx, sly, slz+1.5);
        PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
        SendClientMessage(playerid, COLOR_GREEN, "Your not allowed to enter this vehicle");
        return 1;
        }
        return 1;
}
I Will +Rep who ever helps me
Reply
#2

All vehicles on the server have an ID which is between 0 and 2000. "vehicleid" is not the model number, but you can use the "vehicleid" variable to determine the model number by using the GetVehicleModel function.

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
        if(GetVehicleModel(vehicleid) == 425)
        {
        new Float:slx, Float:sly, Float:slz;
        GetPlayerPos(playerid, slx, sly, slz);
        RemovePlayerFromVehicle(playerid);
        SetPlayerPos(playerid, slx, sly, slz+1.5);
        PlayerPlaySound(playerid, 1130, slx, sly, slz+1.3);
        SendClientMessage(playerid, COLOR_GREEN, "Your not allowed to enter this vehicle");
        return 1;
        }
        return 1;
}
You should also look up logical operators, your use of it made no sense before. '!=' is used to check if something is unequal to the value you're comparing it against.

You might also want to add a validity check - i.e. if the person is an admin, they should still be able to enter, or whatever. At this rate, nobody can enter the vehicle.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)