That works perfect thank you.
is there a way to trigger a lua script so like i can toggle my engine like i would by typing /engine
using the engine script or no?
I have it here is the function https://pastebin.com/T4GTXMUE
edit: also credit to [Release] Engine ON/OFF Toggle
Do you really have to paste the resource into the actionmenu config? Iām pretty sure as long as you still start the resources like engine/hands up you can just tell the menu to TriggerEvent( āEngineā ) and it will still work.
Also thank you @WolfKnight179 and everyone who worked on this menu itās so nice and easy to use.
Is this working or is it broken? I am reading 50/50 on the comments, and unsure if it is worth a try.
It works and is super easy to use, I think Iāve tried to help you before you can PM me if you need help again.
You donāt need to put the event in the resource but in doing so, you are cutting down the Count of the total resources you are actually using. It doesnāt really make sense to have a resource separated from the resource that is actually using said resource unless itās some type of framework or I guess personal preference. Meaning, why create a resource called handsUp or engineOnOff and then call that resource from a separate resource being this menu when you can tie it all together in One resource, when the menu resource is using all these other āseparateā resources. By combining the resources you are making it easier to edit and debug as well as keeping the code tidy and together based on what it actually does/is doing.
If you look at the trainers people release, itās all one resource, not a collection of separate resources calling each other.
However, either way works, one way or another.
It works absolutely fine if you know how to read instructions.
Pretty sure you dont but i just put the function in there at the bottom of cl_action under a comment for each function. I find it a little easier to work with instead of going through different files to edit it. Instead its only 2 files.
the menu wont exit after pressing exit or pressing esc i never messed with the exit part tho
here is the exit code:
cl_action.lua
elseif ( data == "exit" ) then
-- We toggle the ActionMenu and return here, otherwise the function
-- call below would be executed too, which would just open the menu again
ToggleActionMenu()
return
end
end
-- This will only be called if any button other than the exit button is pressed
ToggleActionMenu()
end )
nui.html:
</div>
<!-- Do not remove this or you will not be able to exit the menu -->
<button class="menuoption" data-action="exit">Exit</button>
</div>
</body>
</html>
nvm i fixed it but i cant get kneelhu to work code:
cl_client:
--kneel handsup
function loadAnimDict( dict )
while ( not HasAnimDictLoaded( dict ) ) do
RequestAnimDict( dict )
Citizen.Wait( 5 )
end
end
TriggerEvent( 'KneelHU' )
AddEventHandler( 'KneelHU', function()
local player = GetPlayerPed( -1 )
if ( DoesEntityExist( player ) and not IsEntityDead( player )) then
loadAnimDict( "random@arrests" )
loadAnimDict( "random@arrests@busted" )
if ( IsEntityPlayingAnim( player, "random@arrests@busted", "idle_a", 3 ) ) then
TaskPlayAnim( player, "random@arrests@busted", "exit", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
Wait (3000)
TaskPlayAnim( player, "random@arrests", "kneeling_arrest_get_up", 8.0, 1.0, -1, 128, 0, 0, 0, 0 )
else
TaskPlayAnim( player, "random@arrests", "idle_2_hands_up", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
Wait (4000)
TaskPlayAnim( player, "random@arrests", "kneeling_arrest_idle", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
Wait (500)
TaskPlayAnim( player, "random@arrests@busted", "enter", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
Wait (1000)
TaskPlayAnim( player, "random@arrests@busted", "idle_a", 8.0, 1.0, -1, 9, 0, 0, 0, 0 )
end
end
end )
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsEntityPlayingAnim(GetPlayerPed(PlayerId()), "random@arrests@busted", "idle_a", 3) then
DisableControlAction(1, 140, true)
DisableControlAction(1, 141, true)
DisableControlAction(1, 142, true)
DisableControlAction(0,21,true)
end
end
end)
nui.html:
<button class="menuoption" data-action="handsup_knees">Gets On Knees With Hands Up</button>
</div>
the issue is that i press the button the menu goes away but there is no action any help is appreciated oh and also i fixed my issue with the exit problem
You have to tell the button to trigger the script.
elseif ( data == "handsup_knees" ) then
TriggerEvent( 'KneelHU' )
Exactly what āTrundleTheGreatā said, since you never posted that part of the code we donāt know if you actually did call the event. I also tested your code, seems to work flawlessly. So it must be how you are actually calling the event.
@WolfKnight179 hey can u help me code this menu so i can turn off the engines , roll up windows, hands up, kneel , etc, please dm thank you
so iāve gotten the trunk to open using the open trunk part but it wont close.
here is the code i have so far:
bottom of cl_action.lua:
--trunk
RegisterNetEvent("Trunk")
AddEventHandler("Trunk", function()
local Veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
SetVehicleDoorOpen(Veh, 5, false, false)
end)
RegisterNetEvent("Trunk")
AddEventHandler("Trunk", function()
local Veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
SetVehicleDoorShut(Veh, 5, false)
end)
button code:
elseif ( data == "trunkopen" ) then
TriggerEvent( 'Trunk' )
Works on the menu perfectly! By any chance do you know how to make it so the car still starts whenever you spawn it so I donāt have to go into the menu everytime to turn it on?
I chucked in the code and what TrundleTheGreat posted and it didnāt work. My menu now dosenāt show, but when I remove everything that involves the handsup knees it works again. Any help?
Fixed it! All good, anyone else have scripts they can share?