GTA 5 - Police helicopters are allies

Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Ultra Üye
Katılım
26 Eyl 2022
Mesajlar
1,512
Çözümler
3
Tepki puanı
292
Ödüller
3
Yaş
29
3 HİZMET YILI
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:
Süper Üye
Katılım
19 Haz 2021
Mesajlar
937
Çözümler
1
Tepki puanı
158
Ödüller
4
Yaş
28
4 HİZMET YILI
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)
instead of just doing with police helicopter i have done changing all police vehicle and tried it and after few crashes all police turn out my ally ez
 
Onaylı Üye
Katılım
4 Mar 2023
Mesajlar
93
Tepki puanı
14
Ödüller
1
3 HİZMET YILI
Hahaha, it's interesting. Can you create a code next time to prevent the police from catching me
 
Onaylı Üye
Katılım
15 May 2022
Mesajlar
60
Tepki puanı
3
Ödüller
2
Yaş
27
4 HİZMET YILI
Gta 5 Is A Good Game But Starting Picture Astagfirullah Ramadan
Post automatically merged:

Happy Ramadan
 
Son düzenleme:
Uzman Üye
Katılım
20 Eki 2020
Mesajlar
276
Tepki puanı
22
Ödüller
4
Yaş
25
5 HİZMET YILI
well this is interesting
 
Seçkin Üye
Katılım
3 Haz 2017
Mesajlar
404
Tepki puanı
39
Ödüller
8
9 HİZMET YILI
this will be meta when u fight greiffers XD
 
Onaylı Üye
Katılım
18 Eki 2020
Mesajlar
53
Tepki puanı
2
Ödüller
6
Yaş
34
5 HİZMET YILI
awesome, really want to learn programming too but it's too complicated for me :(
 
Durum
Üzgünüz bu konu cevaplar için kapatılmıştır...
Üst