Advertisement
Guest User

GCPHONE -client/client.lua

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