SA-MP Forums Archive
Vehicle Restrictions Not working. - 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)
+--- Thread: Vehicle Restrictions Not working. (/showthread.php?tid=349527)



Vehicle Restrictions Not working. - Infinity90 - 09.06.2012

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


Re: Vehicle Restrictions Not working. - Calgon - 09.06.2012

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.