Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[------------------------------------------------------------------------
- ActionMenu
- Created by WolfKnight
- Additional help from lowheartrate, TheStonedTurtle, and Briglair.
- ------------------------------------------------------------------------]]--
- -- Define the variable used to open/close the menu
- local menuEnabled = false
- --[[------------------------------------------------------------------------
- ActionMenu Toggle
- Calling this function will open or close the ActionMenu.
- ------------------------------------------------------------------------]]--
- function ToggleActionMenu()
- -- Make the menuEnabled variable not itself
- -- e.g. not true = false, not false = true
- menuEnabled = not menuEnabled
- if ( menuEnabled ) then
- -- Focuses on the NUI, the second parameter toggles the
- -- onscreen mouse cursor.
- SetNuiFocus( true, true )
- -- Sends a message to the JavaScript side, telling it to
- -- open the menu.
- SendNUIMessage({
- showmenu = true
- })
- else
- -- Bring the focus back to the game
- SetNuiFocus( false )
- -- Sends a message to the JavaScript side, telling it to
- -- close the menu.
- SendNUIMessage({
- hidemenu = true
- })
- end
- end
- --[[------------------------------------------------------------------------
- ActionMenu HTML Callbacks
- This will be called every single time the JavaScript side uses the
- sendData function. The name of the data-action is passed as the parameter
- variable data.
- ------------------------------------------------------------------------]]--
- RegisterNUICallback( "ButtonClick", function( data, cb )
- if ( data == "handsup" ) then
- handsUp()
- elseif ( data == "button1" ) then
- TriggerEvent( 'Engine' )
- elseif ( data == "trunk" ) then
- TriggerEvent( 'trunk' )
- elseif ( data == "TrunkClose" ) then
- TriggerEvent( 'TrunkClose' )
- elseif ( data == "cuff" ) then
- TriggerEvent( 'HandCuff' )
- elseif ( data == "Drag" ) then
- TriggerEvent( 'Drag' )
- elseif ( data == "carbine" ) then
- TriggerEvent( 'carbine' )
- elseif ( data == "cop" ) then
- TriggerEvent( 'Emotes' )
- elseif ( data == "drink" ) then
- TriggerEvent( 'Emotes' )
- elseif ( data == "smoke" ) then
- TriggerEvent( 'Emotes' )
- elseif ( data == "Film" ) then
- TriggerEvent( 'Emotes' )
- elseif ( data == "lean" ) then
- TriggerEvent( 'Emotes' )
- elseif ( data == "camera" ) then
- TriggerEvent( 'Emotes' )
- elseif ( data == "mobile" ) then
- TriggerEvent( 'Emotes' )
- elseif ( data == "handsup" ) then
- TriggerEvent( 'handsup' )
- elseif ( data == "handsup_knees" ) then
- TriggerEvent( 'KneelHU' )
- 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
- -- This will only be called if any button other than the exit button is pressed
- ToggleActionMenu()
- end )
- --[[------------------------------------------------------------------------
- ActionMenu Control and Input Blocking
- This is the main while loop that opens the ActionMenu on keypress. It
- uses the input blocking found in the ES Banking resource, credits to
- the authors.
- ------------------------------------------------------------------------]]--
- Citizen.CreateThread( function()
- -- This is just in case the resources restarted whilst the NUI is focused.
- SetNuiFocus( false )
- while true do
- -- Control ID 20 is the 'Z' key by default
- -- Use https://wiki.fivem.net/wiki/Controls to find a different key
- if ( IsControlJustPressed( 1, 244 ) ) then
- ToggleActionMenu()
- end
- if ( menuEnabled ) then
- local ped = GetPlayerPed( -1 )
- DisableControlAction( 0, 1, true ) -- LookLeftRight
- DisableControlAction( 0, 2, true ) -- LookUpDown
- DisableControlAction( 0, 24, true ) -- Attack
- DisablePlayerFiring( ped, true ) -- Disable weapon firing
- DisableControlAction( 0, 142, true ) -- MeleeAttackAlternate
- DisableControlAction( 0, 106, true ) -- VehicleMouseControlOverride
- end
- Citizen.Wait( 0 )
- end
- end )
- function chatPrint( msg )
- TriggerEvent( 'chatMessage', "ActionMenu", { 255, 255, 255 }, msg )
- end
- --Engine
- --Trunk start
- RegisterNetEvent("Trunk")
- AddEventHandler("Trunk", function()
- local Veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
- SetVehicleDoorOpen(Veh, 5, false, false)
- end)
- RegisterNetEvent("TrunkClose")
- AddEventHandler("TrunkClose", function()
- local Veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
- SetVehicleDoorShut(Veh, 5, false)
- end)
- --Trunk End
- --HandCuff start
- RegisterNetEvent("Handcuff")
- AddEventHandler("Handcuff", function()
- local lPed = GetPlayerPed(-1)
- if DoesEntityExist(lPed) then
- if IsEntityPlayingAnim(lPed, "mp_arresting", "idle", 3) then
- --DetachEntity(handcuffconfig.handcuffs, 0, 0)
- --DeleteEntity(handcuffconfig.handcuffs)
- --handcuffconfig.handcuffs = nil
- ClearPedSecondaryTask(lPed)
- SetEnableHandcuffs(lPed, false)
- SetCurrentPedWeapon(lPed, GetHashKey("WEAPON_UNARMED"), true)
- else
- RequestAnimDict("mp_arresting")
- while not HasAnimDictLoaded("mp_arresting") do
- Citizen.Wait(100)
- end
- --RequestModel(GetHashKey(handcuffconfig.model))
- --while not HasModelLoaded(GetHashKey(handcuffconfig.model)) do
- -- Citizen.Wait(100)
- --end
- --local plyCoords = GetEntityCoords(GetPlayerPed(PlayerId()), false)
- --handcuffconfig.handcuffs = CreateObject(GetHashKey(handcuffconfig.model), plyCoords.x, plyCoords.y, plyCoords.z, 1, 1, 1)
- --AttachEntityToEntity(handcuffconfig.handcuffs, GetPlayerPed(PlayerId()), GetPedBoneIndex(GetPlayerPed(PlayerId()), 60309), 0.0, 0.05, 0.0, 0.0, 0.0, 80.0, 1, 0, 0, 0, 0, 1)
- TaskPlayAnim(lPed, "mp_arresting", "idle", 8.0, -8, -1, 49, 0, 0, 0, 0)
- SetEnableHandcuffs(lPed, true)
- SetCurrentPedWeapon(lPed, GetHashKey("WEAPON_UNARMED"), true)
- end
- end
- end)
- --Drag
- local drag = false
- function DragPlayer()
- local t, distance = GetClosestPlayer()
- if(distance ~= -1 and distance < 3) then
- TriggerServerEvent("police:dragRequest", GetPlayerServerId(t))
- TriggerEvent("police:notify", "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["drag_sender_notification_part_1"] .. GetPlayerName(serverTargetPlayer) .. txt[config.lang]["drag_sender_notification_part_2"])
- else
- TriggerEvent('chatMessage', txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["no_player_near_ped"])
- end
- end
- --Drag end
- -- carbine toggle
- function carbine()
- local ped = GetPlayerPed(-1)
- if HasPedGotWeapon(ped, "Weapon_Carbinerifle", false) then
- RemoveWeaponFromPed(ped, "Weapon_Carbinerifle")
- else
- GiveWeaponToPed(ped, "Weapon_Carbinerifle", 200, false, true)
- end
- end
- -- carbine end
- --Emote start
- RegisterNetEvent('Emotes');
- RegisterNetEvent('Emotes');
- -- Emotes, feel free to modify or edit or whatevah!
- local emotes = {}
- emotes['cop'] = {name = 'cop', anim = 'WORLD_HUMAN_COP_IDLES'}
- emotes['drink'] = {name = 'drink', anim = 'WORLD_HUMAN_DRINKING'}
- emotes['smoke'] = {name = 'smoke', anim = 'WORLD_HUMAN_SMOKING'}
- emotes['film'] = {name = 'film', anim = 'WORLD_HUMAN_MOBILE_FILM_SHOCKING'}
- emotes['lean'] = {name = 'lean', anim = 'WORLD_HUMAN_LEANING'}
- emotes['camera'] = {name = 'camera', anim = 'WORLD_HUMAN_PAPARAZZI'}
- emotes['mobile'] = {name = 'mobile', anim = 'WORLD_HUMAN_STAND_MOBILE'}
- playing_emote = false;
- local Keys = { ["W"] = 32, ["A"] = 34, ["S"] = 8, ["D"] = 9 }
- AddEventHandler('Emotes', function(name)
- if emotes[name] then
- ped = GetPlayerPed(-1);
- if ped then
- if playing_emote == false then
- if emotes[name].name == "sitchair" then
- pos = GetEntityCoords(ped);
- head = GetEntityHeading(ped);
- TaskStartScenarioAtPosition(ped, emotes[name].anim, pos['x'], pos['y'], pos['z'] - 1, head, 0, 0, false);
- else
- TaskStartScenarioInPlace(ped, emotes[name].anim, 0, true);
- end
- playing_emote = true;
- end
- end
- end
- end)
- AddEventHandler('Emotes', function()
- TriggerEvent('emotes', "^2Emotes", {255, 0, 0}, " (Example: /emote sit)");
- local emoteslist = ""
- for k in pairs(emotes) do
- emoteslist = k .. " ".. emoteslist
- end
- TriggerEvent('emotes', "", {255, 0, 0}, emoteslist);
- end)
- TriggerEvent('es:addCommand', 'emotes', function(source, args, user)
- TriggerClientEvent('Emotes', source, args[2]);
- end)
- TriggerEvent('es:addCommand', 'emote', function(source, args, user)
- TriggerClientEvent('Emotes', source, args[2]);
- end)
- --emote end
- Citizen.CreateThread(function()
- while true do
- Citizen.Wait(0)
- if playing_emote == true then
- if IsControlPressed(1, Keys["W"]) or IsControlPressed(1, Keys["A"]) or IsControlPressed(1, Keys["S"]) or IsControlPressed(1, Keys["D"]) then
- ClearPedTasks(ped);
- playing_emote = false;
- end
- end
- end
- end)
- --Emote end
- --handsup start--
- local handsup = false
- function handsUp()
- local dict = "missminuteman_1ig_2"
- RequestAnimDict(dict)
- while not HasAnimDictLoaded(dict) do
- Citizen.Wait(0)
- end
- if not handsup then
- TaskPlayAnim(GetPlayerPed(-1), dict, "handsup_enter", 8.0, 8.0, -1, 50, 0, false, false, false)
- handsup = true
- else
- handsup = false
- ClearPedTasks(GetPlayerPed(-1))
- end
- end
- --handsup end--
- --KneelHU Start
- function loadAnimDict( dict )
- while ( not HasAnimDictLoaded( dict ) ) do
- RequestAnimDict( dict )
- Citizen.Wait( 5 )
- end
- end
- RegisterNetEvent( '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)
- --KneelHU End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement