Ultra Üye
I'm new to LUA programming, and I hope this code helps. It should make the police helicopters behave like allies and help the player instead of pursuing you.
Lua:
-- Define the hash value for the police helicopter
local POLICE_HELI_HASH = 0x1517D4D9
-- Define the interval in milliseconds at which the code should run
local UPDATE_INTERVAL_MS = 1000
-- Define a function to check if a vehicle is a police helicopter
local function is_police_helicopter(vehicle)
return entity.get_entity_model_hash(vehicle) == POLICE_HELI_HASH
end
-- Define the main function that will run continuously while the feature is enabled
menu.add_feature("Police Helicopter Allies", "toggle", 0, function(feature)
while feature.on do
-- Check if the player is being pursued by police helicopters
local player_wanted_level = player.get_player_wanted_level(player.player_id())
local police_helicopters = {}
if player_wanted_level > 2 then
local vehicles = vehicle.get_all_vehicles()
for _, vehicle in ipairs(vehicles) do
if is_police_helicopter(vehicle) then
table.insert(police_helicopters, vehicle)
end
end
end
-- Command the police helicopters to protect the player and attack their enemies
local player_ped = player.get_player_ped(player.player_id())
local enemies = ped.get_all_peds()
for _, helicopter in ipairs(police_helicopters) do
vehicle.set_heli_blades_speed(helicopter, 100)
vehicle.set_vehicle_engine_on(helicopter, true, true)
vehicle.set_heli_turret_mode(helicopter, 1)
for _, enemy in ipairs(enemies) do
local enemy_ped = enemy
local enemy_driver = vehicle.get_ped_in_vehicle_seat(entity.get_entity_attached_to(enemy_ped), -1)
if enemy_ped ~= player_ped and enemy_driver ~= player_ped then
vehicle.set_vehicle_shoot_at_target(helicopter, enemy_ped, true)
end
end
end
-- Wait for the specified interval before running the code again
system.yield(UPDATE_INTERVAL_MS)
end
end)
Son düzenleme: