90dfcd0feb
+ Added AI-Vehiclelock. + Set it to 50% chance.
19 lines
531 B
Lua
19 lines
531 B
Lua
AddEventHandler('entityCreated', function(entity)
|
|
-- not valid anymore?
|
|
if not DoesEntityExist(entity) then return end
|
|
|
|
-- rest of core remains the same
|
|
local entityType = GetEntityType(entity)
|
|
|
|
-- not a vehicle? bail out
|
|
if entityType ~= 2 then return end
|
|
|
|
-- only for 'random' population cars
|
|
if GetEntityPopulationType(entity) > 5 then return end
|
|
|
|
-- if >0.5 (50% chance of locking), bail out
|
|
if math.random() > 0.5 then return end
|
|
|
|
-- lock!
|
|
SetVehicleDoorsLocked(entity, 2)
|
|
end) |