Advertisement
Guest User

Untitled

a guest
May 25th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.37 KB | None | 0 0
  1. local Keys = {
  2. ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  3. ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  4. ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  5. ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  6. ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  7. ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  8. ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  9. ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  10. ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  11. }
  12.  
  13. --====================================================================================
  14. -- #Author: Jonathan D @ Gannon
  15. --====================================================================================
  16.  
  17. -- Configuration
  18. local KeyToucheCloseEvent = {
  19. { code = 172, event = 'ArrowUp' },
  20. { code = 173, event = 'ArrowDown' },
  21. { code = 174, event = 'ArrowLeft' },
  22. { code = 175, event = 'ArrowRight' },
  23. { code = 176, event = 'Enter' },
  24. { code = 177, event = 'Backspace' },
  25. }
  26. local KeyOpenClose = 288 -- F1
  27. local KeyTakeCall = 38 -- E
  28. local menuIsOpen = false
  29. local contacts = {}
  30. local messages = {}
  31. local myPhoneNumber = ''
  32. local isDead = false
  33. local USE_RTC = false
  34. local useMouse = false
  35. local ignoreFocus = false
  36. local takePhoto = false
  37. local hasFocus = false
  38.  
  39. local PhoneInCall = {}
  40. local currentPlaySound = false
  41. local soundDistanceMax = 8.0
  42.  
  43.  
  44. --====================================================================================
  45. -- Check si le joueurs poséde un téléphone
  46. -- Callback true or false
  47. --====================================================================================
  48. function hasPhone (cb)
  49. cb(true)
  50. end
  51. --====================================================================================
  52. -- Que faire si le joueurs veut ouvrir sont téléphone n'est qu'il en a pas ?
  53. --====================================================================================
  54. function ShowNoPhoneWarning ()
  55. end
  56.  
  57. --[[
  58. Ouverture du téphone lié a un item
  59. Un solution ESC basé sur la solution donnée par HalCroves
  60. https://forum.fivem.net/t/tutorial-for-gcphone-with-call-and-job-message-other/177904
  61. --]]
  62. --[[
  63. ESX = nil
  64. Citizen.CreateThread(function()
  65. while ESX == nil do
  66. TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  67. Citizen.Wait(0)
  68. end
  69. end)
  70.  
  71. function hasPhone (cb)
  72. if (ESX == nil) then return cb(0) end
  73. ESX.TriggerServerCallback('gcphone:getItemAmount', function(qtty)
  74. cb(qtty > 0)
  75. end, 'phone')
  76. end
  77. function ShowNoPhoneWarning ()
  78. if (ESX == nil) then return end
  79. ESX.ShowNotification("No tienes ~r~Telefono~s~")
  80. end
  81. --]]
  82.  
  83.  
  84. --====================================================================================
  85. --
  86. --====================================================================================
  87. Citizen.CreateThread(function()
  88. while true do
  89. Citizen.Wait(0)
  90. if takePhoto ~= true then
  91. if IsControlJustPressed(1, KeyOpenClose) then
  92. hasPhone(function (hasPhone)
  93. if hasPhone == true then
  94. TooglePhone()
  95. else
  96. ShowNoPhoneWarning()
  97. end
  98. end)
  99. end
  100. if menuIsOpen == true then
  101. for _, value in ipairs(KeyToucheCloseEvent) do
  102. if IsControlJustPressed(1, value.code) then
  103. SendNUIMessage({keyUp = value.event})
  104. end
  105. end
  106. if useMouse == true and hasFocus == ignoreFocus then
  107. local nuiFocus = not hasFocus
  108. SetNuiFocus(nuiFocus, nuiFocus)
  109. hasFocus = nuiFocus
  110. elseif useMouse == false and hasFocus == true then
  111. SetNuiFocus(false, false)
  112. hasFocus = false
  113. end
  114. else
  115. if hasFocus == true then
  116. SetNuiFocus(false, false)
  117. hasFocus = false
  118. end
  119. end
  120. end
  121. end
  122. end)
  123.  
  124.  
  125.  
  126. --====================================================================================
  127. -- Active ou Deactive une application (appName => config.json)
  128. --====================================================================================
  129. RegisterNetEvent('gcPhone:setEnableApp')
  130. AddEventHandler('gcPhone:setEnableApp', function(appName, enable)
  131. SendNUIMessage({event = 'setEnableApp', appName = appName, enable = enable })
  132. end)
  133.  
  134. --====================================================================================
  135. -- Gestion des appels fixe
  136. --====================================================================================
  137. function startFixeCall (fixeNumber)
  138. local number = ''
  139. DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "", "", "", "", "", 10)
  140. while (UpdateOnscreenKeyboard() == 0) do
  141. DisableAllControlActions(0);
  142. Wait(0);
  143. end
  144. if (GetOnscreenKeyboardResult()) then
  145. number = GetOnscreenKeyboardResult()
  146. end
  147. if number ~= '' then
  148. TriggerEvent('gcphone:autoCall', number, {
  149. useNumber = fixeNumber
  150. })
  151. PhonePlayCall(true)
  152. end
  153. end
  154.  
  155. function TakeAppel (infoCall)
  156. TriggerEvent('gcphone:autoAcceptCall', infoCall)
  157. end
  158.  
  159. RegisterNetEvent("gcPhone:notifyFixePhoneChange")
  160. AddEventHandler("gcPhone:notifyFixePhoneChange", function(_PhoneInCall)
  161. PhoneInCall = _PhoneInCall
  162. end)
  163.  
  164. --[[
  165. Affiche les imformations quant le joueurs est proche d'un fixe
  166. --]]
  167. function showFixePhoneHelper (coords)
  168. for number, data in pairs(FixePhone) do
  169. local dist = GetDistanceBetweenCoords(
  170. data.coords.x, data.coords.y, data.coords.z,
  171. coords.x, coords.y, coords.z, 1)
  172. if dist <= 2.0 then
  173. SetTextComponentFormat("STRING")
  174. AddTextComponentString("~g~" .. data.name .. ' ~o~' .. number .. '~n~~INPUT_PICKUP~~w~ Utilizar')
  175. DisplayHelpTextFromStringLabel(0, 0, 0, -1)
  176. if IsControlJustPressed(1, KeyTakeCall) then
  177. startFixeCall(number)
  178. end
  179. break
  180. end
  181. end
  182. end
  183.  
  184.  
  185. Citizen.CreateThread(function ()
  186. local mod = 0
  187. while true do
  188. local playerPed = PlayerPedId()
  189. local coords = GetEntityCoords(playerPed)
  190. local inRangeToActivePhone = false
  191. local inRangedist = 0
  192. for i, _ in pairs(PhoneInCall) do
  193. local dist = GetDistanceBetweenCoords(
  194. PhoneInCall[i].coords.x, PhoneInCall[i].coords.y, PhoneInCall[i].coords.z,
  195. coords.x, coords.y, coords.z, 1)
  196. if (dist <= soundDistanceMax) then
  197. DrawMarker(1, PhoneInCall[i].coords.x, PhoneInCall[i].coords.y, PhoneInCall[i].coords.z,
  198. 0,0,0, 0,0,0, 0.1,0.1,0.1, 0,255,0,255, 0,0,0,0,0,0,0)
  199. inRangeToActivePhone = true
  200. inRangedist = dist
  201. if (dist <= 1.5) then
  202. SetTextComponentFormat("STRING")
  203. AddTextComponentString("~INPUT_PICKUP~ Descolgar")
  204. DisplayHelpTextFromStringLabel(0, 0, 1, -1)
  205. if IsControlJustPressed(1, KeyTakeCall) then
  206. PhonePlayCall(true)
  207. TakeAppel(PhoneInCall[i])
  208. PhoneInCall = {}
  209. StopSoundJS('ring2.ogg')
  210. end
  211. end
  212. break
  213. end
  214. end
  215. if inRangeToActivePhone == false then
  216. showFixePhoneHelper(coords)
  217. end
  218. if inRangeToActivePhone == true and currentPlaySound == false then
  219. PlaySoundJS('ring2.ogg', 0.2 + (inRangedist - soundDistanceMax) / -soundDistanceMax * 0.8 )
  220. currentPlaySound = true
  221. elseif inRangeToActivePhone == true then
  222. mod = mod + 1
  223. if (mod == 15) then
  224. mod = 0
  225. SetSoundVolumeJS('ring2.ogg', 0.2 + (inRangedist - soundDistanceMax) / -soundDistanceMax * 0.8 )
  226. end
  227. elseif inRangeToActivePhone == false and currentPlaySound == true then
  228. currentPlaySound = false
  229. StopSoundJS('ring2.ogg')
  230. end
  231. Citizen.Wait(0)
  232. end
  233. end)
  234.  
  235.  
  236. function PlaySoundJS (sound, volume)
  237. SendNUIMessage({ event = 'playSound', sound = sound, volume = volume })
  238. end
  239.  
  240. function SetSoundVolumeJS (sound, volume)
  241. SendNUIMessage({ event = 'setSoundVolume', sound = sound, volume = volume})
  242. end
  243.  
  244. function StopSoundJS (sound)
  245. SendNUIMessage({ event = 'stopSound', sound = sound})
  246. end
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259. RegisterNetEvent("gcPhone:forceOpenPhone")
  260. AddEventHandler("gcPhone:forceOpenPhone", function(_myPhoneNumber)
  261. if menuIsOpen == false then
  262. TooglePhone()
  263. end
  264. end)
  265.  
  266. --====================================================================================
  267. -- Events
  268. --====================================================================================
  269. RegisterNetEvent("gcPhone:myPhoneNumber")
  270. AddEventHandler("gcPhone:myPhoneNumber", function(_myPhoneNumber)
  271. myPhoneNumber = _myPhoneNumber
  272. SendNUIMessage({event = 'updateMyPhoneNumber', myPhoneNumber = myPhoneNumber})
  273. end)
  274.  
  275. RegisterNetEvent("gcPhone:contactList")
  276. AddEventHandler("gcPhone:contactList", function(_contacts)
  277. SendNUIMessage({event = 'updateContacts', contacts = _contacts})
  278. contacts = _contacts
  279. end)
  280.  
  281. RegisterNetEvent("gcPhone:allMessage")
  282. AddEventHandler("gcPhone:allMessage", function(allmessages)
  283. SendNUIMessage({event = 'updateMessages', messages = allmessages})
  284. messages = allmessages
  285. end)
  286.  
  287. RegisterNetEvent("gcPhone:getBourse")
  288. AddEventHandler("gcPhone:getBourse", function(bourse)
  289. SendNUIMessage({event = 'updateBourse', bourse = bourse})
  290. end)
  291.  
  292. RegisterNetEvent("gcPhone:receiveMessage")
  293. AddEventHandler("gcPhone:receiveMessage", function(message)
  294. -- SendNUIMessage({event = 'updateMessages', messages = messages})
  295. SendNUIMessage({event = 'newMessage', message = message})
  296. table.insert(messages, message)
  297. if message.owner == 0 then
  298. local text = '~o~Nuevo mensaje'
  299. if ShowNumberNotification == true then
  300. text = '~o~Nuevo mensaje de ~y~'.. message.transmitter
  301. for _,contact in pairs(contacts) do
  302. if contact.number == message.transmitter then
  303. text = '~o~Nuevo mensaje de ~g~'.. contact.display
  304. break
  305. end
  306. end
  307. end
  308. SetNotificationTextEntry("STRING")
  309. AddTextComponentString(text)
  310. DrawNotification(false, false)
  311. PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
  312. Citizen.Wait(300)
  313. PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
  314. Citizen.Wait(300)
  315. PlaySound(-1, "Menu_Accept", "Phone_SoundSet_Default", 0, 0, 1)
  316. end
  317. end)
  318.  
  319. --====================================================================================
  320. -- Function client | Contacts
  321. --====================================================================================
  322. function addContact(display, num)
  323. TriggerServerEvent('gcPhone:addContact', display, num)
  324. end
  325.  
  326. function deleteContact(num)
  327. TriggerServerEvent('gcPhone:deleteContact', num)
  328. end
  329. --====================================================================================
  330. -- Function client | Messages
  331. --====================================================================================
  332. function sendMessage(num, message)
  333. TriggerServerEvent('gcPhone:sendMessage', num, message)
  334. end
  335.  
  336. function deleteMessage(msgId)
  337. TriggerServerEvent('gcPhone:deleteMessage', msgId)
  338. for k, v in ipairs(messages) do
  339. if v.id == msgId then
  340. table.remove(messages, k)
  341. SendNUIMessage({event = 'updateMessages', messages = messages})
  342. return
  343. end
  344. end
  345. end
  346.  
  347. function deleteMessageContact(num)
  348. TriggerServerEvent('gcPhone:deleteMessageNumber', num)
  349. end
  350.  
  351. function deleteAllMessage()
  352. TriggerServerEvent('gcPhone:deleteAllMessage')
  353. end
  354.  
  355. function setReadMessageNumber(num)
  356. TriggerServerEvent('gcPhone:setReadMessageNumber', num)
  357. for k, v in ipairs(messages) do
  358. if v.transmitter == num then
  359. v.isRead = 1
  360. end
  361. end
  362. end
  363.  
  364. function requestAllMessages()
  365. TriggerServerEvent('gcPhone:requestAllMessages')
  366. end
  367.  
  368. function requestAllContact()
  369. TriggerServerEvent('gcPhone:requestAllContact')
  370. end
  371.  
  372.  
  373.  
  374. --====================================================================================
  375. -- Function client | Appels
  376. --====================================================================================
  377. local aminCall = false
  378. local inCall = false
  379.  
  380. RegisterNetEvent("gcPhone:waitingCall")
  381. AddEventHandler("gcPhone:waitingCall", function(infoCall, initiator)
  382. SendNUIMessage({event = 'waitingCall', infoCall = infoCall, initiator = initiator})
  383. if initiator == true then
  384. PhonePlayCall()
  385. if menuIsOpen == false then
  386. TooglePhone()
  387. end
  388. end
  389. end)
  390.  
  391. RegisterNetEvent("gcPhone:acceptCall")
  392. AddEventHandler("gcPhone:acceptCall", function(infoCall, initiator)
  393. if inCall == false and USE_RTC == false then
  394. inCall = true
  395. NetworkSetVoiceChannel(infoCall.id + 1)
  396. NetworkSetTalkerProximity(0.0)
  397. end
  398. if menuIsOpen == false then
  399. TooglePhone()
  400. end
  401. PhonePlayCall()
  402. SendNUIMessage({event = 'acceptCall', infoCall = infoCall, initiator = initiator})
  403. end)
  404.  
  405. RegisterNetEvent("gcPhone:rejectCall")
  406. AddEventHandler("gcPhone:rejectCall", function(infoCall)
  407. if inCall == true then
  408. inCall = false
  409. Citizen.InvokeNative(0xE036A705F989E049)
  410. NetworkSetTalkerProximity(2.5)
  411. end
  412. PhonePlayText()
  413. SendNUIMessage({event = 'rejectCall', infoCall = infoCall})
  414. end)
  415.  
  416.  
  417. RegisterNetEvent("gcPhone:historiqueCall")
  418. AddEventHandler("gcPhone:historiqueCall", function(historique)
  419. SendNUIMessage({event = 'historiqueCall', historique = historique})
  420. end)
  421.  
  422.  
  423. function startCall (phone_number, rtcOffer, extraData)
  424. TriggerServerEvent('gcPhone:startCall', phone_number, rtcOffer, extraData)
  425. end
  426.  
  427. function acceptCall (infoCall, rtcAnswer)
  428. TriggerServerEvent('gcPhone:acceptCall', infoCall, rtcAnswer)
  429. end
  430.  
  431. function rejectCall(infoCall)
  432. TriggerServerEvent('gcPhone:rejectCall', infoCall)
  433. end
  434.  
  435. function ignoreCall(infoCall)
  436. TriggerServerEvent('gcPhone:ignoreCall', infoCall)
  437. end
  438.  
  439. function requestHistoriqueCall()
  440. TriggerServerEvent('gcPhone:getHistoriqueCall')
  441. end
  442.  
  443. function appelsDeleteHistorique (num)
  444. TriggerServerEvent('gcPhone:appelsDeleteHistorique', num)
  445. end
  446.  
  447. function appelsDeleteAllHistorique ()
  448. TriggerServerEvent('gcPhone:appelsDeleteAllHistorique')
  449. end
  450.  
  451.  
  452. --====================================================================================
  453. -- Event NUI - Appels
  454. --====================================================================================
  455.  
  456. RegisterNUICallback('startCall', function (data, cb)
  457. startCall(data.numero, data.rtcOffer, data.extraData)
  458. cb()
  459. end)
  460.  
  461. RegisterNUICallback('acceptCall', function (data, cb)
  462. acceptCall(data.infoCall, data.rtcAnswer)
  463. cb()
  464. end)
  465. RegisterNUICallback('rejectCall', function (data, cb)
  466. rejectCall(data.infoCall)
  467. cb()
  468. end)
  469.  
  470. RegisterNUICallback('ignoreCall', function (data, cb)
  471. ignoreCall(data.infoCall)
  472. cb()
  473. end)
  474.  
  475. RegisterNUICallback('notififyUseRTC', function (use, cb)
  476. USE_RTC = use
  477. if USE_RTC == true and inCall == true then
  478. inCall = false
  479. Citizen.InvokeNative(0xE036A705F989E049)
  480. NetworkSetTalkerProximity(2.5)
  481. end
  482. cb()
  483. end)
  484.  
  485.  
  486. RegisterNUICallback('onCandidates', function (data, cb)
  487. TriggerServerEvent('gcPhone:candidates', data.id, data.candidates)
  488. cb()
  489. end)
  490.  
  491. RegisterNetEvent("gcPhone:candidates")
  492. AddEventHandler("gcPhone:candidates", function(candidates)
  493. SendNUIMessage({event = 'candidatesAvailable', candidates = candidates})
  494. end)
  495.  
  496.  
  497.  
  498. RegisterNetEvent('gcphone:autoCall')
  499. AddEventHandler('gcphone:autoCall', function(number, extraData)
  500. if number ~= nil then
  501. SendNUIMessage({ event = "autoStartCall", number = number, extraData = extraData})
  502. end
  503. end)
  504.  
  505. RegisterNetEvent('gcphone:autoCallNumber')
  506. AddEventHandler('gcphone:autoCallNumber', function(data)
  507. TriggerEvent('gcphone:autoCall', data.number)
  508. end)
  509.  
  510. RegisterNetEvent('gcphone:autoAcceptCall')
  511. AddEventHandler('gcphone:autoAcceptCall', function(infoCall)
  512. SendNUIMessage({ event = "autoAcceptCall", infoCall = infoCall})
  513. end)
  514.  
  515.  
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.  
  537.  
  538.  
  539.  
  540.  
  541.  
  542.  
  543.  
  544.  
  545.  
  546.  
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553.  
  554.  
  555.  
  556.  
  557.  
  558.  
  559.  
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575. --====================================================================================
  576. -- Gestion des evenements NUI
  577. --====================================================================================
  578. RegisterNUICallback('log', function(data, cb)
  579. print(data)
  580. cb()
  581. end)
  582. RegisterNUICallback('focus', function(data, cb)
  583. cb()
  584. end)
  585. RegisterNUICallback('blur', function(data, cb)
  586. cb()
  587. end)
  588. RegisterNUICallback('reponseText', function(data, cb)
  589. local limit = data.limit or 255
  590. local text = data.text or ''
  591.  
  592. DisplayOnscreenKeyboard(1, "FMMC_MPM_NA", "", text, "", "", "", limit)
  593. while (UpdateOnscreenKeyboard() == 0) do
  594. DisableAllControlActions(0);
  595. Wait(0);
  596. end
  597. if (GetOnscreenKeyboardResult()) then
  598. text = GetOnscreenKeyboardResult()
  599. end
  600. cb(json.encode({text = text}))
  601. end)
  602. --====================================================================================
  603. -- Event - Messages
  604. --====================================================================================
  605. RegisterNUICallback('getMessages', function(data, cb)
  606. cb(json.encode(messages))
  607. end)
  608. RegisterNUICallback('sendMessage', function(data, cb)
  609. if data.message == '%pos%' then
  610. local myPos = GetEntityCoords(PlayerPedId())
  611. data.message = 'GPS: ' .. myPos.x .. ', ' .. myPos.y
  612. end
  613. TriggerServerEvent('gcPhone:sendMessage', data.phoneNumber, data.message)
  614. end)
  615. RegisterNUICallback('deleteMessage', function(data, cb)
  616. deleteMessage(data.id)
  617. cb()
  618. end)
  619. RegisterNUICallback('deleteMessageNumber', function (data, cb)
  620. deleteMessageContact(data.number)
  621. cb()
  622. end)
  623. RegisterNUICallback('deleteAllMessage', function (data, cb)
  624. deleteAllMessage()
  625. cb()
  626. end)
  627. RegisterNUICallback('setReadMessageNumber', function (data, cb)
  628. setReadMessageNumber(data.number)
  629. cb()
  630. end)
  631. --====================================================================================
  632. -- Event - Contacts
  633. --====================================================================================
  634. RegisterNUICallback('addContact', function(data, cb)
  635. TriggerServerEvent('gcPhone:addContact', data.display, data.phoneNumber)
  636. end)
  637. RegisterNUICallback('updateContact', function(data, cb)
  638. TriggerServerEvent('gcPhone:updateContact', data.id, data.display, data.phoneNumber)
  639. end)
  640. RegisterNUICallback('deleteContact', function(data, cb)
  641. TriggerServerEvent('gcPhone:deleteContact', data.id)
  642. end)
  643. RegisterNUICallback('getContacts', function(data, cb)
  644. cb(json.encode(contacts))
  645. end)
  646. RegisterNUICallback('setGPS', function(data, cb)
  647. SetNewWaypoint(tonumber(data.x), tonumber(data.y))
  648. cb()
  649. end)
  650.  
  651. -- Add security for event (leuit#0100)
  652. RegisterNUICallback('callEvent', function(data, cb)
  653. local eventName = data.eventName or ''
  654. if string.match(eventName, 'gcphone') then
  655. if data.data ~= nil then
  656. TriggerEvent(data.eventName, data.data)
  657. else
  658. TriggerEvent(data.eventName)
  659. end
  660. else
  661. print('Event not allowed')
  662. end
  663. cb()
  664. end)
  665. RegisterNUICallback('useMouse', function(um, cb)
  666. useMouse = um
  667. end)
  668. RegisterNUICallback('deleteALL', function(data, cb)
  669. TriggerServerEvent('gcPhone:deleteALL')
  670. cb()
  671. end)
  672.  
  673.  
  674.  
  675. function TooglePhone()
  676. menuIsOpen = not menuIsOpen
  677. SendNUIMessage({show = menuIsOpen})
  678. if menuIsOpen == true then
  679. PhonePlayIn()
  680. else
  681. PhonePlayOut()
  682. end
  683. end
  684. RegisterNUICallback('faketakePhoto', function(data, cb)
  685. menuIsOpen = false
  686. SendNUIMessage({show = false})
  687. cb()
  688. TriggerEvent('camera:open')
  689. end)
  690.  
  691. RegisterNUICallback('closePhone', function(data, cb)
  692. menuIsOpen = false
  693. SendNUIMessage({show = false})
  694. PhonePlayOut()
  695. cb()
  696. end)
  697.  
  698.  
  699.  
  700.  
  701. ----------------------------------
  702. ---------- GESTION APPEL ---------
  703. ----------------------------------
  704. RegisterNUICallback('appelsDeleteHistorique', function (data, cb)
  705. appelsDeleteHistorique(data.numero)
  706. cb()
  707. end)
  708. RegisterNUICallback('appelsDeleteAllHistorique', function (data, cb)
  709. appelsDeleteAllHistorique(data.infoCall)
  710. cb()
  711. end)
  712.  
  713.  
  714. ----------------------------------
  715. ---------- GESTION VIA WEBRTC ----
  716. ----------------------------------
  717. AddEventHandler('onClientResourceStart', function(res)
  718. DoScreenFadeIn(300)
  719. if res == "gcphone" then
  720. TriggerServerEvent('gcPhone:allUpdate')
  721. end
  722. end)
  723.  
  724.  
  725. RegisterNUICallback('setIgnoreFocus', function (data, cb)
  726. ignoreFocus = data.ignoreFocus
  727. cb()
  728. end)
  729.  
  730.  
  731.  
  732.  
  733.  
  734.  
  735.  
  736.  
  737.  
  738.  
  739.  
  740.  
  741.  
  742.  
  743.  
  744. RegisterNUICallback('takePhoto', function(data, cb)
  745. CreateMobilePhone(1)
  746. CellCamActivate(true, true)
  747. takePhoto = true
  748. Citizen.Wait(0)
  749. if hasFocus == true then
  750. SetNuiFocus(false, false)
  751. hasFocus = false
  752. end
  753. while takePhoto do
  754. Citizen.Wait(0)
  755.  
  756. if IsControlJustPressed(1, 27) then -- Toogle Mode
  757. frontCam = not frontCam
  758. CellFrontCamActivate(frontCam)
  759. elseif IsControlJustPressed(1, 177) then -- CANCEL
  760. DestroyMobilePhone()
  761. CellCamActivate(false, false)
  762. cb(json.encode({ url = nil }))
  763. takePhoto = false
  764. break
  765. elseif IsControlJustPressed(1, 176) then -- TAKE.. PIC
  766. exports['screenshot-basic']:requestScreenshotUpload(data.url, data.field, function(data)
  767. local resp = json.decode(data)
  768. DestroyMobilePhone()
  769. CellCamActivate(false, false)
  770. cb(json.encode({ url = resp.files[1].url }))
  771. end)
  772. takePhoto = false
  773. end
  774. HideHudComponentThisFrame(7)
  775. HideHudComponentThisFrame(8)
  776. HideHudComponentThisFrame(9)
  777. HideHudComponentThisFrame(6)
  778. HideHudComponentThisFrame(19)
  779. HideHudAndRadarThisFrame()
  780. end
  781. Citizen.Wait(1000)
  782. PhonePlayAnim('text', false, true)
  783. end)
  784.  
  785. ---------------------------------------------------------------
  786. ------ PATH TO NO BUGS WITH ANOTHER SCRIPTS BEING STUCKS ------
  787. ---------------------------------------------------------------
  788. Citizen.CreateThread(
  789. function()
  790. while true do
  791. Citizen.Wait(1)
  792. if menuIsOpen then
  793. local playerPed = PlayerPedId()
  794. DisableControlAction(0, Keys["R"], true) -- Reload
  795. DisableControlAction(0, Keys["SPACE"], true) -- Jump
  796. DisableControlAction(0, Keys["Q"], true) -- Cover
  797. DisableControlAction(0, Keys["TAB"], true) -- Select Weapon
  798. DisableControlAction(0, Keys["F"], true) -- Also 'enter'?
  799.  
  800. DisableControlAction(0, Keys["F1"], true) -- Disable phone
  801. DisableControlAction(0, Keys["F2"], true) -- Inventory
  802. DisableControlAction(0, Keys["F3"], true) -- Animations
  803. DisableControlAction(0, Keys["F6"], true) -- Job
  804.  
  805. DisableControlAction(0, Keys["V"], true) -- Disable changing view
  806. DisableControlAction(2, Keys["B"], true) -- Disable going stealth
  807. DisableControlAction(0, Keys["X"], true) -- Disable clearing animation
  808. DisableControlAction(2, Keys["P"], true) -- Disable pause screen
  809. DisableControlAction(2, Keys["LEFTCTRL"], true) -- Disable going stealth
  810. end
  811. end
  812. end
  813. )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement