SA-MP Forums Archive
Auto Lock - 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: Auto Lock (/showthread.php?tid=610004)



Auto Lock - Ugaustin - 18.06.2016

hi, does anyone know how can I lock car automaticly without me typing anything .. for job?? and for taxi with params.


PHP код:
stock IsVehicleOccupied(vehicleid)  // 
{
    for(new 
i=0;i<MAX_PLAYERS;i++)
    {
        if(
IsPlayerInVehicle(i,vehicleid)) return 1;
    }
    return 
0;




Re: Auto Lock - TwinkiDaBoss - 18.06.2016

You can simply do something like

PHP код:
new v_VehicleLock[MAX_VEHICLES]
stock ToggleVehicleLock(vehiclestatus) {
    new 
enginelightsalarmdoorsbonnetbootobjective;
    
GetVehicleParamsEx(vehicleenginelightsalarmdoorsbonnetbootobjective);
    switch(
status) {
        case 
0: { v_VehicleLock[vehicle] = 0SetVehicleParamsEx(vehicleenginelightsalarm0bonnetbootobjective); }
        case 
1: { v_VehicleLock[vehicle] = 1SetVehicleParamsEx(vehicleenginelightsalarm1bonnetbootobjective); }
    }
    return 
true;
}
stock LockAllCars() {
    for(new 
0MAX_VEHICLESi++) {
        if(
IsValidVehicle(i)) {
            
//u can add here like If(CarInfo[i][Job] != 0) {
             
ToggleVehicleLock(i1); //1 to lock, 0 to unlock
        
}
    }




Re: Auto Lock - Ugaustin - 18.06.2016

and auto unlocks?? I want to auto unlock when no driver.. and to lock when there is driver !


Re: Auto Lock - TwinkiDaBoss - 18.06.2016

Quote:
Originally Posted by Ugaustin
Посмотреть сообщение
and auto unlocks?? I want to auto unlock when no driver.. and to lock when there is driver !
PHP код:
stock LockAllCars() {
    for(new 
0MAX_VEHICLESi++) {
        if(
IsValidVehicle(i)) {
            if(!
IsVehicleOccupied(i)) { //if the car is empty
                
ToggleVehicleLock(i1); //1 to lock, 0 to unlock
            
}
            else if(
IsVehicleOccupied(i)) { //if there is someone inside the car
                
ToggleVehicleLock(i0); //1 to lock, 0 to unlock
            
}
        }
    }




Re: Auto Lock - Ugaustin - 18.06.2016

and if there a way only for driver??like taxi??