Advertisement
Guest User

Untitled

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