stock IsVehicleOccupied(vehicleid) //
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerInVehicle(i,vehicleid)) return 1;
}
return 0;
}
new v_VehicleLock[MAX_VEHICLES]
stock ToggleVehicleLock(vehicle, status) {
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicle, engine, lights, alarm, doors, bonnet, boot, objective);
switch(status) {
case 0: { v_VehicleLock[vehicle] = 0; SetVehicleParamsEx(vehicle, engine, lights, alarm, 0, bonnet, boot, objective); }
case 1: { v_VehicleLock[vehicle] = 1; SetVehicleParamsEx(vehicle, engine, lights, alarm, 1, bonnet, boot, objective); }
}
return true;
}
stock LockAllCars() {
for(new i = 0; i < MAX_VEHICLES; i++) {
if(IsValidVehicle(i)) {
//u can add here like If(CarInfo[i][Job] != 0) {
ToggleVehicleLock(i, 1); //1 to lock, 0 to unlock
}
}
}
and auto unlocks?? I want to auto unlock when no driver.. and to lock when there is driver !
|
stock LockAllCars() {
for(new i = 0; i < MAX_VEHICLES; i++) {
if(IsValidVehicle(i)) {
if(!IsVehicleOccupied(i)) { //if the car is empty
ToggleVehicleLock(i, 1); //1 to lock, 0 to unlock
}
else if(IsVehicleOccupied(i)) { //if there is someone inside the car
ToggleVehicleLock(i, 0); //1 to lock, 0 to unlock
}
}
}
}