[Release] Heli Script

Would you have the helicam user trigger client/server events to broadcast to other clients (only other clients) that the helicam is in use, and then update when that user exits helicam?

What makes me nervous/paranoid is some unexpected event that prevents the variable getting reset properly, resulting in everyone getting locked out of the helicam. If say the pilot crashes the heli during helicam use then your helicam cleanup section should still run and a helicam_in_use variable could be reset no problem, I assume. But what if instead a pilot’s FiveM client crashes during helicam use?

Actually I wonder if a ‘HelicamInUse’ decorator might be better. It would avoid some potential issues simply because it would be a property of one particular heli entity. Not to mention ease of use of these decorators makes them so tempting. :grin:

Sorry in advance if this is a stupid question. I am not a code guy. I am a streamer that wants to RP a news chopper.
Is it possible that a similar mod will work on the Frogger helicopter?

Yes, you only need to change a few lines of code. I can send you those lines later today if you want.

@Vespura, that would be be very much appreciated! Thanks for the help!

1 Like

@Pitchit alright here you go.

heli_client.lua

Directly below this line:

local polmav_hash = GetHashKey("polmav")

Add one of the following lines for each type of helicopter that you want the helicam to work on:

local maverick_hash = GetHashKey("maverick") -- Maverick
local buzzard_hash = GetHashKey("buzzard") -- Buzzard
local buzzard2_hash = GetHashKey("buzzard2") -- Buzzard2 (without guns)
local valkyrie_hash = GetHashKey("valkyrie") -- Valkyrie
local frogger_hash = GetHashKey("frogger") -- Frogger
local frogger2_hash = GetHashKey("frogger2") -- Frogger2 (Trevor's Version)

Next, replace this function:

function IsPlayerInPolmav()
	local lPed = GetPlayerPed(-1)
	local vehicle = GetVehiclePedIsIn(lPed)
	return IsVehicleModel(vehicle, polmav_hash)
end

With this:

function IsPlayerInPolmav()
	local lPed = GetPlayerPed(-1)
	local vehicle = GetVehiclePedIsIn(lPed)
    local IsPolmav = IsVehicleModel(vehicle, polmav_hash)
    local IsMaverick = IsVehicleModel(vehicle, maverick_hash)
    local IsBuzzard = IsVehicleModel(vehicle, buzzard_hash)
    local IsBuzzard2 = IsVehicleModel(vehicle, buzzard2_hash)
    local IsValkyrie = IsVehicleModel(vehicle, valkyrie_hash)
    local IsFrogger = IsVehicleModel(vehicle, frogger_hash)
    local IsFrogger2 = IsVehicleModel(vehicle, frogger2_hash)
    local isCorrect = false
    if( IsPolmav or IsMaverick or IsBuzzard or IsBuzzard2 or IsValkyrie or IsFrogger or IsFrogger2) then
        isCorrect = true
    end
	return isCorrect
end

Note that you can simply add/remove any of the “or IsXxxxx” parts in the last “if statement” to enable/disable that specific helicopter. I’ve not tested this with the latest version of the script but with a previous version this worked fine even on helicopters that don’t have a spotlight. But maybe in the new version this could cause issues if you allow helicopters that don’t have spotlights. (Not sure)…

Hope this helps. If you have any questions just reply or send me a PM.

EDIT: Btw this most likely isn’t the most perfect way to do it but since I’ve already changed my own code for this exact situation I just copied/pasted my code over here. If anyone wants to improve it, be my guest.

4 Likes

Thank you good sir, it’s nice to see this kind of support around here!

2 Likes

This works great, thank you!

Is there a way to get the speed of cars kinda like the DoJ server? If not cool if so great! Just get back to me but it would really be a killer if you could or tell me how to do it i have a little experience in the coding world.

If you are using the modified version a few posts up then you should be getting the speed of cars by default, when you use the helicam and zoom in on an individual car. If you then press SPACE you can lock on the car and continue to get its speed while in helicam and even after you exit helicam.

If you are not seeing the speed, then maybe you hit Q by accident, which toggles the vehicle display mode between speed+model+license / model+license / no display.

1 Like

I have a problem, how do I change the control id to something and how do I find out what control id is what key

https://wiki.fivem.net/wiki/Controls
Keys are set on top of the clientside lua file.

the light seems to sync great when not in camera, which is fine, especially for single person operation of the heli but I noticed the light hot key on the controller is R1/RB. I’m going to change it but I wonder why you made it the same as the tail rotor control. It just turns on and off all the time because of it.

1 Like

Script was made with only keyboard and mouse controls in mind. On controller they probably overlap which is what’s causing your issue. Luckily you can easily change it :slightly_smiling_face:

2 Likes

Hey, would it be possible to add more than just the polmav helicopter? So multiple helicopters would have these functions like rappel, spotlight and helicam?

Thanks :slight_smile:

1 Like

read there :

Thanks, will this work with multiple helis or is this just to change from the polmav to another?

@MaxxMaxx It’s already right there…

Aha :stuck_out_tongue: Will it work for spotlight and rapell too?

Read here:


Not sure. Although I don’t see why it wouldn’t work.

1 Like