Advertisement
Guest User

Untitled

a guest
Jan 10th, 2018
528
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.16 KB | None | 0 0
  1. --[[------------------------------------------------------------------------
  2.  
  3. ActionMenu
  4. Created by WolfKnight
  5. Additional help from lowheartrate, TheStonedTurtle, and Briglair.
  6.  
  7. ------------------------------------------------------------------------]]--
  8.  
  9. -- Define the variable used to open/close the menu
  10. local menuEnabled = false
  11. --[[------------------------------------------------------------------------
  12. ActionMenu Toggle
  13. Calling this function will open or close the ActionMenu.
  14. ------------------------------------------------------------------------]]--
  15. function ToggleActionMenu()
  16. -- Make the menuEnabled variable not itself
  17. -- e.g. not true = false, not false = true
  18. menuEnabled = not menuEnabled
  19.  
  20. if ( menuEnabled ) then
  21. -- Focuses on the NUI, the second parameter toggles the
  22. -- onscreen mouse cursor.
  23. SetNuiFocus( true, true )
  24.  
  25. -- Sends a message to the JavaScript side, telling it to
  26. -- open the menu.
  27. SendNUIMessage({
  28. showmenu = true
  29. })
  30. else
  31. -- Bring the focus back to the game
  32. SetNuiFocus( false )
  33.  
  34. -- Sends a message to the JavaScript side, telling it to
  35. -- close the menu.
  36. SendNUIMessage({
  37. hidemenu = true
  38. })
  39. end
  40. end
  41.  
  42. --[[------------------------------------------------------------------------
  43. ActionMenu HTML Callbacks
  44. This will be called every single time the JavaScript side uses the
  45. sendData function. The name of the data-action is passed as the parameter
  46. variable data.
  47. ------------------------------------------------------------------------]]--
  48. RegisterNUICallback( "ButtonClick", function( data, cb )
  49. if ( data == "handsup" ) then
  50. handsUp()
  51.  
  52. elseif ( data == "button1" ) then
  53. TriggerEvent( 'Engine' )
  54.  
  55. elseif ( data == "trunk" ) then
  56. TriggerEvent( 'trunk' )
  57.  
  58. elseif ( data == "TrunkClose" ) then
  59. TriggerEvent( 'TrunkClose' )
  60.  
  61. elseif ( data == "cuff" ) then
  62. TriggerEvent( 'HandCuff' )
  63.  
  64. elseif ( data == "Drag" ) then
  65. TriggerEvent( 'Drag' )
  66.  
  67. elseif ( data == "carbine" ) then
  68. TriggerEvent( 'carbine' )
  69.  
  70. elseif ( data == "cop" ) then
  71. TriggerEvent( 'Emotes' )
  72.  
  73. elseif ( data == "drink" ) then
  74. TriggerEvent( 'Emotes' )
  75.  
  76. elseif ( data == "smoke" ) then
  77. TriggerEvent( 'Emotes' )
  78.  
  79. elseif ( data == "Film" ) then
  80. TriggerEvent( 'Emotes' )
  81.  
  82. elseif ( data == "lean" ) then
  83. TriggerEvent( 'Emotes' )
  84.  
  85. elseif ( data == "camera" ) then
  86. TriggerEvent( 'Emotes' )
  87.  
  88. elseif ( data == "mobile" ) then
  89. TriggerEvent( 'Emotes' )
  90.  
  91. elseif ( data == "handsup" ) then
  92. TriggerEvent( 'handsup' )
  93.  
  94. elseif ( data == "handsup_knees" ) then
  95. TriggerEvent( 'KneelHU' )
  96.  
  97. elseif ( data == "exit" ) then
  98. -- We toggle the ActionMenu and return here, otherwise the function
  99. -- call below would be executed too, which would just open the menu again
  100. ToggleActionMenu()
  101. return
  102. end
  103.  
  104. -- This will only be called if any button other than the exit button is pressed
  105. ToggleActionMenu()
  106. end )
  107.  
  108.  
  109. --[[------------------------------------------------------------------------
  110. ActionMenu Control and Input Blocking
  111. This is the main while loop that opens the ActionMenu on keypress. It
  112. uses the input blocking found in the ES Banking resource, credits to
  113. the authors.
  114. ------------------------------------------------------------------------]]--
  115. Citizen.CreateThread( function()
  116. -- This is just in case the resources restarted whilst the NUI is focused.
  117. SetNuiFocus( false )
  118.  
  119. while true do
  120. -- Control ID 20 is the 'Z' key by default
  121. -- Use https://wiki.fivem.net/wiki/Controls to find a different key
  122. if ( IsControlJustPressed( 1, 244 ) ) then
  123. ToggleActionMenu()
  124. end
  125.  
  126. if ( menuEnabled ) then
  127. local ped = GetPlayerPed( -1 )
  128.  
  129. DisableControlAction( 0, 1, true ) -- LookLeftRight
  130. DisableControlAction( 0, 2, true ) -- LookUpDown
  131. DisableControlAction( 0, 24, true ) -- Attack
  132. DisablePlayerFiring( ped, true ) -- Disable weapon firing
  133. DisableControlAction( 0, 142, true ) -- MeleeAttackAlternate
  134. DisableControlAction( 0, 106, true ) -- VehicleMouseControlOverride
  135. end
  136.  
  137. Citizen.Wait( 0 )
  138. end
  139. end )
  140.  
  141. function chatPrint( msg )
  142. TriggerEvent( 'chatMessage', "ActionMenu", { 255, 255, 255 }, msg )
  143. end
  144.  
  145. --Engine
  146.  
  147. --Trunk start
  148.  
  149. RegisterNetEvent("Trunk")
  150. AddEventHandler("Trunk", function()
  151. local Veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
  152. SetVehicleDoorOpen(Veh, 5, false, false)
  153. end)
  154.  
  155. RegisterNetEvent("TrunkClose")
  156. AddEventHandler("TrunkClose", function()
  157. local Veh = GetVehiclePedIsUsing(GetPlayerPed(-1))
  158. SetVehicleDoorShut(Veh, 5, false)
  159. end)
  160.  
  161. --Trunk End
  162.  
  163.  
  164. --HandCuff start
  165. RegisterNetEvent("Handcuff")
  166. AddEventHandler("Handcuff", function()
  167. local lPed = GetPlayerPed(-1)
  168. if DoesEntityExist(lPed) then
  169. if IsEntityPlayingAnim(lPed, "mp_arresting", "idle", 3) then
  170. --DetachEntity(handcuffconfig.handcuffs, 0, 0)
  171. --DeleteEntity(handcuffconfig.handcuffs)
  172. --handcuffconfig.handcuffs = nil
  173. ClearPedSecondaryTask(lPed)
  174. SetEnableHandcuffs(lPed, false)
  175. SetCurrentPedWeapon(lPed, GetHashKey("WEAPON_UNARMED"), true)
  176. else
  177. RequestAnimDict("mp_arresting")
  178. while not HasAnimDictLoaded("mp_arresting") do
  179. Citizen.Wait(100)
  180. end
  181.  
  182. --RequestModel(GetHashKey(handcuffconfig.model))
  183. --while not HasModelLoaded(GetHashKey(handcuffconfig.model)) do
  184. -- Citizen.Wait(100)
  185. --end
  186.  
  187. --local plyCoords = GetEntityCoords(GetPlayerPed(PlayerId()), false)
  188. --handcuffconfig.handcuffs = CreateObject(GetHashKey(handcuffconfig.model), plyCoords.x, plyCoords.y, plyCoords.z, 1, 1, 1)
  189.  
  190. --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)
  191.  
  192. TaskPlayAnim(lPed, "mp_arresting", "idle", 8.0, -8, -1, 49, 0, 0, 0, 0)
  193. SetEnableHandcuffs(lPed, true)
  194. SetCurrentPedWeapon(lPed, GetHashKey("WEAPON_UNARMED"), true)
  195. end
  196. end
  197. end)
  198.  
  199. --Drag
  200.  
  201. local drag = false
  202.  
  203. function DragPlayer()
  204. local t, distance = GetClosestPlayer()
  205. if(distance ~= -1 and distance < 3) then
  206. TriggerServerEvent("police:dragRequest", GetPlayerServerId(t))
  207. 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"])
  208. else
  209. TriggerEvent('chatMessage', txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["no_player_near_ped"])
  210. end
  211. end
  212.  
  213. --Drag end
  214.  
  215. -- carbine toggle
  216. function carbine()
  217. local ped = GetPlayerPed(-1)
  218. if HasPedGotWeapon(ped, "Weapon_Carbinerifle", false) then
  219. RemoveWeaponFromPed(ped, "Weapon_Carbinerifle")
  220. else
  221. GiveWeaponToPed(ped, "Weapon_Carbinerifle", 200, false, true)
  222. end
  223. end
  224. -- carbine end
  225.  
  226. --Emote start
  227. RegisterNetEvent('Emotes');
  228. RegisterNetEvent('Emotes');
  229.  
  230. -- Emotes, feel free to modify or edit or whatevah!
  231. local emotes = {}
  232. emotes['cop'] = {name = 'cop', anim = 'WORLD_HUMAN_COP_IDLES'}
  233. emotes['drink'] = {name = 'drink', anim = 'WORLD_HUMAN_DRINKING'}
  234. emotes['smoke'] = {name = 'smoke', anim = 'WORLD_HUMAN_SMOKING'}
  235. emotes['film'] = {name = 'film', anim = 'WORLD_HUMAN_MOBILE_FILM_SHOCKING'}
  236. emotes['lean'] = {name = 'lean', anim = 'WORLD_HUMAN_LEANING'}
  237. emotes['camera'] = {name = 'camera', anim = 'WORLD_HUMAN_PAPARAZZI'}
  238. emotes['mobile'] = {name = 'mobile', anim = 'WORLD_HUMAN_STAND_MOBILE'}
  239.  
  240. playing_emote = false;
  241.  
  242. local Keys = { ["W"] = 32, ["A"] = 34, ["S"] = 8, ["D"] = 9 }
  243.  
  244. AddEventHandler('Emotes', function(name)
  245. if emotes[name] then
  246. ped = GetPlayerPed(-1);
  247. if ped then
  248. if playing_emote == false then
  249. if emotes[name].name == "sitchair" then
  250. pos = GetEntityCoords(ped);
  251. head = GetEntityHeading(ped);
  252. TaskStartScenarioAtPosition(ped, emotes[name].anim, pos['x'], pos['y'], pos['z'] - 1, head, 0, 0, false);
  253. else
  254. TaskStartScenarioInPlace(ped, emotes[name].anim, 0, true);
  255. end
  256. playing_emote = true;
  257.  
  258. end
  259. end
  260. end
  261. end)
  262.  
  263. AddEventHandler('Emotes', function()
  264. TriggerEvent('emotes', "^2Emotes", {255, 0, 0}, " (Example: /emote sit)");
  265. local emoteslist = ""
  266. for k in pairs(emotes) do
  267. emoteslist = k .. " ".. emoteslist
  268. end
  269. TriggerEvent('emotes', "", {255, 0, 0}, emoteslist);
  270. end)
  271.  
  272. TriggerEvent('es:addCommand', 'emotes', function(source, args, user)
  273. TriggerClientEvent('Emotes', source, args[2]);
  274. end)
  275.  
  276. TriggerEvent('es:addCommand', 'emote', function(source, args, user)
  277. TriggerClientEvent('Emotes', source, args[2]);
  278. end)
  279. --emote end
  280.  
  281.  
  282. Citizen.CreateThread(function()
  283. while true do
  284. Citizen.Wait(0)
  285. if playing_emote == true then
  286. if IsControlPressed(1, Keys["W"]) or IsControlPressed(1, Keys["A"]) or IsControlPressed(1, Keys["S"]) or IsControlPressed(1, Keys["D"]) then
  287. ClearPedTasks(ped);
  288. playing_emote = false;
  289. end
  290. end
  291. end
  292. end)
  293. --Emote end
  294.  
  295.  
  296. --handsup start--
  297.  
  298. local handsup = false
  299.  
  300. function handsUp()
  301. local dict = "missminuteman_1ig_2"
  302.  
  303. RequestAnimDict(dict)
  304. while not HasAnimDictLoaded(dict) do
  305. Citizen.Wait(0)
  306. end
  307. if not handsup then
  308. TaskPlayAnim(GetPlayerPed(-1), dict, "handsup_enter", 8.0, 8.0, -1, 50, 0, false, false, false)
  309. handsup = true
  310. else
  311. handsup = false
  312. ClearPedTasks(GetPlayerPed(-1))
  313. end
  314. end
  315.  
  316. --handsup end--
  317.  
  318. --KneelHU Start
  319.  
  320. function loadAnimDict( dict )
  321. while ( not HasAnimDictLoaded( dict ) ) do
  322. RequestAnimDict( dict )
  323. Citizen.Wait( 5 )
  324. end
  325. end
  326.  
  327. RegisterNetEvent( 'KneelHU' )
  328. AddEventHandler( 'KneelHU', function()
  329. local player = GetPlayerPed( -1 )
  330. if ( DoesEntityExist( player ) and not IsEntityDead( player )) then
  331. loadAnimDict( "random@arrests" )
  332. loadAnimDict( "random@arrests@busted" )
  333. if ( IsEntityPlayingAnim( player, "random@arrests@busted", "idle_a", 3 ) ) then
  334. TaskPlayAnim( player, "random@arrests@busted", "exit", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
  335. Wait (3000)
  336. TaskPlayAnim( player, "random@arrests", "kneeling_arrest_get_up", 8.0, 1.0, -1, 128, 0, 0, 0, 0 )
  337. else
  338. TaskPlayAnim( player, "random@arrests", "idle_2_hands_up", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
  339. Wait (4000)
  340. TaskPlayAnim( player, "random@arrests", "kneeling_arrest_idle", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
  341. Wait (500)
  342. TaskPlayAnim( player, "random@arrests@busted", "enter", 8.0, 1.0, -1, 2, 0, 0, 0, 0 )
  343. Wait (1000)
  344. TaskPlayAnim( player, "random@arrests@busted", "idle_a", 8.0, 1.0, -1, 9, 0, 0, 0, 0 )
  345. end
  346. end
  347. end )
  348.  
  349. Citizen.CreateThread(function()
  350. while true do
  351. Citizen.Wait(0)
  352. if IsEntityPlayingAnim(GetPlayerPed(PlayerId()), "random@arrests@busted", "idle_a", 3) then
  353. DisableControlAction(1, 140, true)
  354. DisableControlAction(1, 141, true)
  355. DisableControlAction(1, 142, true)
  356. DisableControlAction(0,21,true)
  357. end
  358. end
  359. end)
  360.  
  361. --KneelHU End
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement