fork(12) download
  1. --
  2. --Local variables : Please do not touch theses variables
  3. --
  4.  
  5. if(config.useCopWhitelist == true) then
  6. isCop = false
  7. else
  8. isCop = true
  9. end
  10. local isInService = false
  11. local rank = "unknown"
  12. local checkpoints = {}
  13. local policeHeli = nil
  14. local handCuffed = false
  15. local isAlreadyDead = false
  16. -- jail addon
  17. local isHandCuffed = false -- Don't touch!
  18. -- Jail addon end
  19. local allServiceCops = {}
  20. local blipsCops = {}
  21. local drag = false
  22. local officerDrag = -1
  23.  
  24. anyMenuOpen = {
  25. menuName = "",
  26. isActive = false
  27. }
  28.  
  29. --It isn't recommanded to use this array directly, please just use it in order to retrieve quickly the key code your are searching
  30. --[[
  31. local Keys = {
  32. ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  33. ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  34. ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  35. ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  36. ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  37. ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  38. ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  39. ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  40. ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  41. }]]
  42.  
  43. local clockInStation = {
  44. {x=850.156677246094, y=-1283.92004394531, z=28.0047378540039}, -- La Mesa
  45. {x=457.956909179688, y=-992.72314453125, z=30.6895866394043}, -- Mission Row
  46. {x=1856.91320800781, y=3689.50073242188, z=34.2670783996582}, -- Sandy Shore
  47. {x=-450.063201904297, y=6016.5751953125, z=31.7163734436035} -- Paleto Bay
  48. }
  49.  
  50. local garageStation = {
  51. {x=-470.85266113281, y=6022.9296875, z=31.340530395508}, -- La Mesa
  52. {x=1873.3372802734, y=3687.3508300781, z=33.616954803467}, -- Mission Row
  53. {x=452.115966796875, y=-1018.10681152344, z=28.4786586761475}, -- Sandy Shore
  54. {x=855.24249267578, y=-1279.9300537109, z=26.513223648071 } -- Paleto Bay
  55. }
  56.  
  57. local heliStation = {
  58. {x=449.113966796875, y=-981.084966796875, z=43.691966796875} -- Mission Row
  59. }
  60.  
  61. local armoryStation = {
  62. {x=452.119966796875, y=-980.061966796875, z=30.690966796875} -- Mission Row
  63. }
  64.  
  65. --
  66. --Events handlers
  67. --
  68.  
  69. if(config.useCopWhitelist == true) then
  70. AddEventHandler("playerSpawned", function()
  71. TriggerServerEvent("police:checkIsCop")
  72. end)
  73. end
  74.  
  75. if(config.useCopWhitelist == true) then
  76. RegisterNetEvent('police:receiveIsCop')
  77. AddEventHandler('police:receiveIsCop', function(result)
  78. if(result == "unknown") then
  79. if(config.useCopWhitelist == true) then
  80. isCop = false
  81. end
  82. else
  83. isCop = true
  84. rank = result
  85. end
  86. end)
  87. end
  88.  
  89. if(config.useCopWhitelist == true) then
  90. RegisterNetEvent('police:nowCop')
  91. AddEventHandler('police:nowCop', function()
  92. isCop = true
  93. end)
  94. end
  95.  
  96. if(config.useCopWhitelist == true) then
  97. RegisterNetEvent('police:noLongerCop')
  98. AddEventHandler('police:noLongerCop', function()
  99. if(config.useCopWhitelist == true) then
  100. isCop = false
  101. end
  102. isInService = false
  103.  
  104. if(config.enableOutfits == true) then
  105. RemoveAllPedWeapons(GetPlayerPed(-1))
  106. TriggerServerEvent("skin_customization:SpawnPlayer")
  107. else
  108. local model = GetHashKey("a_m_y_mexthug_01")
  109.  
  110. RequestModel(model)
  111. while not HasModelLoaded(model) do
  112. RequestModel(model)
  113. Citizen.Wait(0)
  114. end
  115.  
  116. SetPlayerModel(PlayerId(), model)
  117. SetModelAsNoLongerNeeded(model)
  118. RemoveAllPedWeapons(GetPlayerPed(-1))
  119. end
  120.  
  121. if(policeHeli ~= nil) then
  122. SetEntityAsMissionEntity(policeHeli, true, true)
  123. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(policeHeli))
  124. policeHeli = nil
  125. end
  126.  
  127. ServiceOff()
  128. end)
  129. end
  130.  
  131. -- jail addon
  132. RegisterNetEvent('jail:teleportPlayer')
  133. AddEventHandler('jail:teleportPlayer', function(amount)
  134. if(isHandCuffed == true) then
  135. SetEntityCoords(GetPlayerPed(-1), tonumber(config.jail.pos_x), tonumber(config.jail.pos_y), tonumber(config.jail.pos_z))
  136.  
  137. TriggerEvent('chatMessage', txt[config.lang]["title_notification"], {0,0,0}, txt[config.lang]["jail_arrest_notification_part_1"] .. amount .. txt[config.lang]["jail_arrest_notification_part_2"])
  138.  
  139. Citizen.CreateThread(function()
  140. while (amount > 0) do
  141. Citizen.Wait(1000)
  142. amount = amount - 1
  143. end
  144.  
  145. -- Remove Weapons
  146. RemoveAllPedWeapons(GetPlayerPed(-1))
  147. TriggerEvent('chatMessage', txt[config.lang]["title_notification"], {0,0,0}, txt[config.lang]["jail_weapons_removed"])
  148.  
  149. -- Arrest
  150. TriggerEvent('police:getArrested', t)
  151. end)
  152. else
  153. TriggerEvent('chatMessage', source, txt[config.lang]["title_notification"], {0,0,0}, txt[config.lang]["jail_not_cuffed"])
  154. end
  155. end)
  156. -- jail addon end
  157.  
  158. RegisterNetEvent('police:getArrested')
  159. AddEventHandler('police:getArrested', function()
  160. handCuffed = not handCuffed
  161. if(handCuffed) then
  162. TriggerEvent("police:notify", "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["now_cuffed"])
  163. isHandCuffed = true -- jail addon
  164. else
  165. TriggerEvent("police:notify", "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["now_uncuffed"])
  166. isHandCuffed = false -- jail addon
  167. drag = false
  168. end
  169. end)
  170.  
  171. --Inspired from emergency for request system (by Jyben : https://f...content-available-to-author-only...m.net/t/release-job-save-people-be-a-hero-paramedic-emergency-coma-ko/19773)
  172. local lockAskingFine = false
  173. RegisterNetEvent('police:payFines')
  174. AddEventHandler('police:payFines', function(amount, sender)
  175. Citizen.CreateThread(function()
  176.  
  177. if(lockAskingFine ~= true) then
  178. lockAskingFine = true
  179. local notifReceivedAt = GetGameTimer()
  180. Notification(txt[config.lang]["info_fine_request_before_amount"]..amount..txt[config.lang]["info_fine_request_after_amount"])
  181. while(true) do
  182. Wait(0)
  183.  
  184. if (GetTimeDifference(GetGameTimer(), notifReceivedAt) > 15000) then
  185. TriggerServerEvent('police:finesETA', sender, 2)
  186. Notification(txt[config.lang]["request_fine_expired"])
  187. lockAskingFine = false
  188. break
  189. end
  190.  
  191. if IsControlPressed(1, 246) then
  192. if(config.useModifiedBanking == true) then
  193. TriggerServerEvent('bank:withdrawAmende', amount)
  194. else
  195. TriggerServerEvent('bank:withdraw', amount)
  196. end
  197. Notification(txt[config.lang]["pay_fine_success_before_amount"]..amount..txt[config.lang]["pay_fine_success_after_amount"])
  198. TriggerServerEvent('police:finesETA', sender, 0)
  199. lockAskingFine = false
  200. break
  201. end
  202.  
  203. if IsControlPressed(1, 45) then
  204. TriggerServerEvent('police:finesETA', sender, 3)
  205. lockAskingFine = false
  206. break
  207. end
  208. end
  209. else
  210. TriggerServerEvent('police:finesETA', sender, 1)
  211. end
  212. end)
  213. end)
  214.  
  215. -- Copy/paste from fs_freeroam (by FiveM-Script : https://f...content-available-to-author-only...m.net/t/alpha-fs-freeroam-0-1-4-fivem-scripts/14097)
  216. RegisterNetEvent("police:notify")
  217. AddEventHandler("police:notify", function(icon, type, sender, title, text)
  218. Citizen.CreateThread(function()
  219. Wait(1)
  220. SetNotificationTextEntry("STRING");
  221. AddTextComponentString(text);
  222. SetNotificationMessage(icon, icon, true, type, sender, title, text);
  223. DrawNotification(false, true);
  224. end)
  225. end)
  226.  
  227. if(config.useVDKInventory == true) then
  228. RegisterNetEvent('police:dropIllegalItem')
  229. AddEventHandler('police:dropIllegalItem', function(id)
  230. TriggerEvent("player:looseItem", tonumber(id), exports.vdk_inventory:getQuantity(id))
  231. end)
  232. end
  233.  
  234. --Piece of code given by Thefoxeur54
  235. RegisterNetEvent('police:unseatme')
  236. AddEventHandler('police:unseatme', function(t)
  237. local ped = GetPlayerPed(t)
  238. ClearPedTasksImmediately(ped)
  239. plyPos = GetEntityCoords(GetPlayerPed(-1), true)
  240. local xnew = plyPos.x+2
  241. local ynew = plyPos.y+2
  242.  
  243. SetEntityCoords(GetPlayerPed(-1), xnew, ynew, plyPos.z)
  244. end)
  245.  
  246. RegisterNetEvent('police:toggleDrag')
  247. AddEventHandler('police:toggleDrag', function(t)
  248. if(handCuffed) then
  249. drag = not drag
  250. officerDrag = t
  251. end
  252. end)
  253.  
  254. RegisterNetEvent('police:forcedEnteringVeh')
  255. AddEventHandler('police:forcedEnteringVeh', function(veh)
  256. if(handCuffed) then
  257. local pos = GetEntityCoords(GetPlayerPed(-1))
  258. local entityWorld = GetOffsetFromEntityInWorldCoords(GetPlayerPed(-1), 0.0, 20.0, 0.0)
  259.  
  260. local rayHandle = CastRayPointToPoint(pos.x, pos.y, pos.z, entityWorld.x, entityWorld.y, entityWorld.z, 10, GetPlayerPed(-1), 0)
  261. local _, _, _, _, vehicleHandle = GetRaycastResult(rayHandle)
  262.  
  263. if vehicleHandle ~= nil then
  264. SetPedIntoVehicle(GetPlayerPed(-1), vehicleHandle, 1)
  265. end
  266. end
  267. end)
  268.  
  269. RegisterNetEvent('police:removeWeapons')
  270. AddEventHandler('police:removeWeapons', function()
  271. RemoveAllPedWeapons(GetPlayerPed(-1), true)
  272. end)
  273.  
  274. if(config.enableOtherCopsBlips == true) then
  275. RegisterNetEvent('police:resultAllCopsInService')
  276. AddEventHandler('police:resultAllCopsInService', function(array)
  277. allServiceCops = array
  278. enableCopBlips()
  279. end)
  280. end
  281.  
  282. if(config.useModifiedEmergency == true) then
  283. RegisterNetEvent('es_em:cl_ResPlayer')
  284. AddEventHandler('es_em:cl_ResPlayer', function()
  285. if(isCop and isInService) then
  286. ServiceOff()
  287. end
  288.  
  289. if(handCuffed == true) then
  290. handCuffed = false
  291. end
  292. end)
  293. end
  294.  
  295. --
  296. --Functions
  297. --
  298.  
  299. function Notification(msg)
  300. SetNotificationTextEntry("STRING")
  301. AddTextComponentString(msg)
  302. DrawNotification(0,1)
  303. end
  304.  
  305. function drawNotification(text)
  306. SetNotificationTextEntry("STRING")
  307. AddTextComponentString(text)
  308. DrawNotification(false, false)
  309. end
  310.  
  311. --From Player Blips and Above Head Display (by Scammer : https://f...content-available-to-author-only...m.net/t/release-scammers-script-collection-09-03-17/3313)
  312. function enableCopBlips()
  313.  
  314. for k, existingBlip in pairs(blipsCops) do
  315. RemoveBlip(existingBlip)
  316. end
  317. blipsCops = {}
  318.  
  319. local localIdCops = {}
  320. for id = 0, 64 do
  321. if(NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= GetPlayerPed(-1)) then
  322. for i,c in pairs(allServiceCops) do
  323. if(i == GetPlayerServerId(id)) then
  324. localIdCops[id] = c
  325. break
  326. end
  327. end
  328. end
  329. end
  330.  
  331. for id, c in pairs(localIdCops) do
  332. local ped = GetPlayerPed(id)
  333. local blip = GetBlipFromEntity(ped)
  334.  
  335. if not DoesBlipExist( blip ) then
  336.  
  337. blip = AddBlipForEntity( ped )
  338. SetBlipSprite( blip, 1 )
  339. Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true )
  340. HideNumberOnBlip( blip )
  341. SetBlipNameToPlayerName( blip, id )
  342.  
  343. SetBlipScale( blip, 0.85 )
  344. SetBlipAlpha( blip, 255 )
  345.  
  346. table.insert(blipsCops, blip)
  347. else
  348.  
  349. blipSprite = GetBlipSprite( blip )
  350.  
  351. HideNumberOnBlip( blip )
  352. if blipSprite ~= 1 then
  353. SetBlipSprite( blip, 1 )
  354. Citizen.InvokeNative( 0x5FBCA48327B914DF, blip, true )
  355. end
  356.  
  357. SetBlipNameToPlayerName( blip, id )
  358. SetBlipScale( blip, 0.85 )
  359. SetBlipAlpha( blip, 255 )
  360.  
  361. table.insert(blipsCops, blip)
  362. end
  363. end
  364. end
  365.  
  366. function GetPlayers()
  367. local players = {}
  368.  
  369. for i = 0, 31 do
  370. if NetworkIsPlayerActive(i) then
  371. table.insert(players, i)
  372. end
  373. end
  374.  
  375. return players
  376. end
  377.  
  378. function GetClosestPlayer()
  379. local players = GetPlayers()
  380. local closestDistance = -1
  381. local closestPlayer = -1
  382. local ply = GetPlayerPed(-1)
  383. local plyCoords = GetEntityCoords(ply, 0)
  384.  
  385. for index,value in ipairs(players) do
  386. local target = GetPlayerPed(value)
  387. if(target ~= ply) then
  388. local targetCoords = GetEntityCoords(GetPlayerPed(value), 0)
  389. local distance = Vdist(targetCoords["x"], targetCoords["y"], targetCoords["z"], plyCoords["x"], plyCoords["y"], plyCoords["z"])
  390. if(closestDistance == -1 or closestDistance > distance) then
  391. closestPlayer = value
  392. closestDistance = distance
  393. end
  394. end
  395. end
  396.  
  397. return closestPlayer, closestDistance
  398. end
  399.  
  400. function drawTxt(text,font,centre,x,y,scale,r,g,b,a)
  401. SetTextFont(font)
  402. SetTextProportional(0)
  403. SetTextScale(scale, scale)
  404. SetTextColour(r, g, b, a)
  405. SetTextDropShadow(0, 0, 0, 0,255)
  406. SetTextEdge(1, 0, 0, 0, 255)
  407. SetTextDropShadow()
  408. SetTextOutline()
  409. SetTextCentre(centre)
  410. SetTextEntry("STRING")
  411. AddTextComponentString(text)
  412. DrawText(x , y)
  413. end
  414.  
  415. function isNearTakeService()
  416. local distance = 10000
  417. local pos = {}
  418. for i = 1, #clockInStation do
  419. local coords = GetEntityCoords(GetPlayerPed(-1), 0)
  420. local currentDistance = Vdist(clockInStation[i].x, clockInStation[i].y, clockInStation[i].z, coords.x, coords.y, coords.z)
  421. if(currentDistance < distance) then
  422. distance = currentDistance
  423. pos = clockInStation[i]
  424. end
  425. end
  426.  
  427. if anyMenuOpen.menuName == "cloackroom" and anyMenuOpen.isActive and distance > 3 then
  428. CloseMenu()
  429. end
  430. if(distance < 30) then
  431. DrawMarker(1, pos.x, pos.y, pos.z-1, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 0, 155, 255, 200, 0, 0, 2, 0, 0, 0, 0)
  432. end
  433. if(distance < 2) then
  434. return true
  435. end
  436. end
  437.  
  438. function isNearStationGarage()
  439. local distance = 10000
  440. local pos = {}
  441. for i = 1, #garageStation do
  442. local coords = GetEntityCoords(GetPlayerPed(-1), 0)
  443. local currentDistance = Vdist(garageStation[i].x, garageStation[i].y, garageStation[i].z, coords.x, coords.y, coords.z)
  444. if(currentDistance < distance) then
  445. distance = currentDistance
  446. pos = garageStation[i]
  447. end
  448. end
  449.  
  450. if anyMenuOpen.menuName == "garage" and anyMenuOpen.isActive and distance > 5 then
  451. CloseMenu()
  452. end
  453. if(distance < 30) then
  454. DrawMarker(1, pos.x, pos.y, pos.z-1, 0, 0, 0, 0, 0, 0, 2.0, 2.0, 1.0, 0, 155, 255, 200, 0, 0, 2, 0, 0, 0, 0)
  455. end
  456. if(distance < 2) then
  457. return true
  458. end
  459. end
  460.  
  461. function isNearHelicopterStation()
  462. local distance = 10000
  463. local pos = {}
  464. for i = 1, #heliStation do
  465. local coords = GetEntityCoords(GetPlayerPed(-1), 0)
  466. local currentDistance = Vdist(heliStation[i].x, heliStation[i].y, heliStation[i].z, coords.x, coords.y, coords.z)
  467. if(currentDistance < distance) then
  468. distance = currentDistance
  469. pos = heliStation[i]
  470. end
  471. end
  472.  
  473. if(distance < 30) then
  474. DrawMarker(1, pos.x, pos.y, pos.z-1, 0, 0, 0, 0, 0, 0, 2.5, 2.5, 1.0, 0, 155, 255, 200, 0, 0, 2, 0, 0, 0, 0)
  475. end
  476. if(distance < 2) then
  477. return true
  478. end
  479. end
  480.  
  481. function isNearArmory()
  482. local distance = 10000
  483. local pos = {}
  484. for i = 1, #armoryStation do
  485. local coords = GetEntityCoords(GetPlayerPed(-1), 0)
  486. local currentDistance = Vdist(armoryStation[i].x, armoryStation[i].y, armoryStation[i].z, coords.x, coords.y, coords.z)
  487. if(currentDistance < distance) then
  488. distance = currentDistance
  489. pos = armoryStation[i]
  490. end
  491. end
  492.  
  493. if (anyMenuOpen.menuName == "armory" or anyMenuOpen.menuName == "armory-weapon_list") and anyMenuOpen.isActive and distance > 2 then
  494. CloseMenu()
  495. end
  496. if(distance < 30) then
  497. DrawMarker(1, pos.x, pos.y, pos.z-1, 0, 0, 0, 0, 0, 0, 1.0, 1.0, 1.0, 0, 155, 255, 200, 0, 0, 2, 0, 0, 0, 0)
  498. end
  499. if(distance < 2) then
  500. return true
  501. end
  502. end
  503.  
  504. function ServiceOn()
  505. isInService = true
  506. if(config.useJobSystem == true) then
  507. TriggerServerEvent("jobssystem:jobs", config.job.officer_on_duty_job_id)
  508. end
  509. TriggerServerEvent("police:takeService")
  510. end
  511.  
  512. function ServiceOff()
  513. isInService = false
  514. if(config.useJobSystem == true) then
  515. TriggerServerEvent("jobssystem:jobs", config.job.officer_not_on_duty_job_id)
  516. end
  517. TriggerServerEvent("police:breakService")
  518.  
  519. if(config.enableOtherCopsBlips == true) then
  520. allServiceCops = {}
  521.  
  522. for k, existingBlip in pairs(blipsCops) do
  523. RemoveBlip(existingBlip)
  524. end
  525. blipsCops = {}
  526. end
  527. end
  528.  
  529. function DisplayHelpText(str)
  530. SetTextComponentFormat("STRING")
  531. AddTextComponentString(str)
  532. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  533. end
  534.  
  535. function CloseMenu()
  536. SendNUIMessage({
  537. action = "close"
  538. })
  539.  
  540. anyMenuOpen.menuName = ""
  541. anyMenuOpen.isActive = false
  542. end
  543.  
  544. RegisterNUICallback('sendAction', function(data, cb)
  545. _G[data.action]()
  546. cb('ok')
  547. end)
  548.  
  549. --
  550. --Threads
  551. --
  552.  
  553. local alreadyDead = false
  554.  
  555. Citizen.CreateThread(function()
  556.  
  557. --Embedded NeverWanted script // Non loop part
  558. if(config.enableNeverWanted == true) then
  559. SetPoliceIgnorePlayer(PlayerId(), true)
  560. SetDispatchCopsForPlayer(PlayerId(), false)
  561. Citizen.InvokeNative(0xDC0F817884CDD856, 1, false)
  562. Citizen.InvokeNative(0xDC0F817884CDD856, 2, false)
  563. Citizen.InvokeNative(0xDC0F817884CDD856, 3, false)
  564. Citizen.InvokeNative(0xDC0F817884CDD856, 5, false)
  565. Citizen.InvokeNative(0xDC0F817884CDD856, 8, false)
  566. Citizen.InvokeNative(0xDC0F817884CDD856, 9, false)
  567. Citizen.InvokeNative(0xDC0F817884CDD856, 10, false)
  568. Citizen.InvokeNative(0xDC0F817884CDD856, 11, false)
  569. end
  570.  
  571. for _, item in pairs(clockInStation) do
  572. item.blip = AddBlipForCoord(item.x, item.y, item.z)
  573. SetBlipSprite(item.blip, 60)
  574. SetBlipAsShortRange(item.blip, true)
  575. BeginTextCommandSetBlipName("STRING")
  576. AddTextComponentString(txt[config.lang]["police_station"])
  577. EndTextCommandSetBlipName(item.blip)
  578. end
  579.  
  580. while true do
  581. Citizen.Wait(10)
  582.  
  583. DisablePlayerVehicleRewards(PlayerId())
  584.  
  585. --Embedded NeverWanted script // Loop part
  586. if(config.enableNeverWanted == true) then
  587. SetPlayerWantedLevel(PlayerId(), 0, false)
  588. SetPlayerWantedLevelNow(PlayerId(), false)
  589. ClearAreaOfCops()
  590. end
  591.  
  592. if(anyMenuOpen.isActive) then
  593. DisableControlAction(1, 21)
  594. DisableControlAction(1, 140)
  595. DisableControlAction(1, 141)
  596. DisableControlAction(1, 142)
  597. SetDisableAmbientMeleeMove(GetPlayerPed(-1), true)
  598. if (IsControlJustPressed(1,172)) then
  599. SendNUIMessage({
  600. action = "keyup"
  601. })
  602. elseif (IsControlJustPressed(1,173)) then
  603. SendNUIMessage({
  604. action = "keydown"
  605. })
  606. elseif (IsControlJustPressed(1,176)) then
  607. SendNUIMessage({
  608. action = "keyenter"
  609. })
  610. elseif (IsControlJustPressed(1,177)) then
  611. if(anyMenuOpen.menuName == "policemenu" or anyMenuOpen.menuName == "armory" or anyMenuOpen.menuName == "cloackroom" or anyMenuOpen.menuName == "garage") then
  612. CloseMenu()
  613. elseif(anyMenuOpen.menuName == "armory-weapon_list") then
  614. BackArmory()
  615. else
  616. BackMenuPolice()
  617. end
  618. end
  619. else
  620. EnableControlAction(1, 21)
  621. EnableControlAction(1, 140)
  622. EnableControlAction(1, 141)
  623. EnableControlAction(1, 142)
  624. end
  625.  
  626. --Control death events
  627. if(config.useModifiedEmergency == false) then
  628. if(IsPlayerDead(PlayerId())) then
  629. if(alreadyDead == false) then
  630. if(isInService) then
  631. ServiceOff()
  632. end
  633. handCuffed = false
  634. drag = false
  635. alreadyDead = true
  636. end
  637. else
  638. alreadyDead = false
  639. end
  640. end
  641.  
  642. if (handCuffed == true) then
  643. RequestAnimDict('mp_arresting')
  644.  
  645. while not HasAnimDictLoaded('mp_arresting') do
  646. Citizen.Wait(0)
  647. end
  648.  
  649. local myPed = PlayerPedId(-1)
  650. local animation = 'idle'
  651. local flags = 16
  652.  
  653. while(IsPedBeingStunned(myPed, 0)) do
  654. ClearPedTasksImmediately(myPed)
  655. end
  656. TaskPlayAnim(myPed, 'mp_arresting', animation, 8.0, -8, -1, flags, 0, 0, 0, 0)
  657. end
  658.  
  659. --Piece of code from Drag command (by Frazzle, Valk, Michael_Sanelli, NYKILLA1127 : https://f...content-available-to-author-only...m.net/t/release-drag-command/22174)
  660. if drag then
  661. local ped = GetPlayerPed(GetPlayerFromServerId(officerDrag))
  662. local myped = GetPlayerPed(-1)
  663. AttachEntityToEntity(myped, ped, 4103, 11816, 0.48, 0.00, 0.0, 0.0, 0.0, 0.0, false, false, false, false, 2, true)
  664. else
  665. DetachEntity(GetPlayerPed(-1), true, false)
  666. end
  667.  
  668. if(isCop) then
  669. if(isNearTakeService()) then
  670.  
  671. DisplayHelpText(txt[config.lang]["help_text_open_cloackroom"],0,1,0.5,0.8,0.6,255,255,255,255) -- ~g~E~s~
  672. if IsControlJustPressed(1,51) then
  673. OpenCloackroom()
  674. end
  675. end
  676.  
  677. if(isInService) then
  678.  
  679. --Open Garage menu
  680. if(isNearStationGarage()) then
  681. if(policevehicle ~= nil) then
  682. DisplayHelpText(txt[config.lang]["help_text_put_car_into_garage"],0,1,0.5,0.8,0.6,255,255,255,255)
  683. else
  684. DisplayHelpText(txt[config.lang]["help_text_get_car_out_garage"],0,1,0.5,0.8,0.6,255,255,255,255)
  685. end
  686.  
  687. if IsControlJustPressed(1,51) then
  688. if(policevehicle ~= nil) then
  689. --Destroy police vehicle
  690. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(policevehicle))
  691. policevehicle = nil
  692. else
  693. OpenGarage()
  694. end
  695. end
  696. end
  697.  
  698. --Open Garage menu
  699. if(isNearArmory()) then
  700.  
  701. DisplayHelpText(txt[config.lang]["help_text_open_armory"],0,1,0.5,0.8,0.6,255,255,255,255)
  702.  
  703. if IsControlJustPressed(1,51) then
  704. OpenArmory()
  705. end
  706. end
  707.  
  708. --Open/Close Menu police
  709. if (IsControlJustPressed(1,166)) then
  710. TogglePoliceMenu()
  711. end
  712.  
  713. --Control helicopter spawning
  714. if isNearHelicopterStation() then
  715. if(policeHeli ~= nil) then
  716. DisplayHelpText(txt[config.lang]["help_text_put_heli_into_garage"],0,1,0.5,0.8,0.6,255,255,255,255)
  717. else
  718. DisplayHelpText(txt[config.lang]["help_text_get_heli_out_garage"],0,1,0.5,0.8,0.6,255,255,255,255)
  719. end
  720.  
  721. if IsControlJustPressed(1,51) then
  722. if(policeHeli ~= nil) then
  723. Citizen.InvokeNative(0xEA386986E786A54F, Citizen.PointerValueIntInitialized(policeHeli))
  724. policeHeli = nil
  725. else
  726. local heli = GetHashKey("polmav")
  727. local ply = GetPlayerPed(-1)
  728. local plyCoords = GetEntityCoords(ply, 0)
  729.  
  730. RequestModel(heli)
  731. while not HasModelLoaded(heli) do
  732. Citizen.Wait(0)
  733. end
  734.  
  735. policeHeli = CreateVehicle(heli, plyCoords["x"], plyCoords["y"], plyCoords["z"], 90.0, true, false)
  736. SetVehicleHasBeenOwnedByPlayer(policevehicle,true)
  737. local netid = NetworkGetNetworkIdFromEntity(policeHeli)
  738. SetNetworkIdCanMigrate(netid, true)
  739. NetworkRegisterEntityAsNetworked(VehToNet(policeHeli))
  740. SetVehicleLivery(policeHeli, 0)
  741. TaskWarpPedIntoVehicle(ply, policeHeli, -1)
  742. SetEntityAsMissionEntity(policeHeli, true, true)
  743. end
  744. end
  745. end
  746. end
  747. end
  748. end
  749. end)
Runtime error #stdin #stdout #stderr 0s 15008KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
lua5.3: prog.lua:5: attempt to index a nil value (global 'config')
stack traceback:
	prog.lua:5: in main chunk
	[C]: in ?