SA-MP Forums Archive
Locking other Factions out of vehicles - 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: Locking other Factions out of vehicles (/showthread.php?tid=635433)



Locking other Factions out of vehicles - cloudysky - 06.06.2017

Hello,

Could you possibly help me with my vehicles? In the script files all the vehicles are set to Faction 1, so unless you are Faction 1 it shouldn't be letting you drive, which is the case for some of the vehicles but not all of the vehicles, a couple of them can be driven by anyone dispite being set to Faction 1 only.

pawn Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    new Vehiclefile[100], i;
    new engine, lights, alarm, doors, bonnet, boot, objective;
    format(Vehiclefile, sizeof(Vehiclefile), "vehicles/Vehicle_%d.ini", vehicleid);
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    if(fexist(Vehiclefile))
    {
        Vehicles[i][VFaction] = dini_Int(Vehiclefile, "Faction");
        if(PlayerInfo[playerid][FactionApartof] == Vehicles[i][VFaction] || Vehicles[i][VFaction] == 0 )
        {
            SetVehicleParamsEx(vehicleid, 1, lights, alarm, doors, bonnet, boot, 0);
        }
        else
        {
            SendClientMessage(i, COLOUR_CYAN, "You do not have the keys to this vehicle!" );
            SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, 0);
        }
    }
Thanks


Re: Locking other Factions out of vehicles - MiiSha - 07.06.2017

Maybe those who you can drive are not saved into the ini file.