1- local QBCore = exports [' qb-core' ]:GetCoreObject ()
1+ local QBCore = exports [' qb-core' ]:GetCoreObject ({ ' Functions' })
2+ local sharedVehicles = exports [' qb-core' ]:GetShared (' Vehicles' )
23local PlayerJob = {}
34local patt = ' [?!@#]'
45local frontCam = false
6+ local phoneProp = 0
7+ local phoneModel = ` prop_npc_phone_02`
58PhoneData = {
69 MetaData = {},
710 isOpen = false ,
@@ -28,6 +31,63 @@ PhoneData = {
2831
2932-- Functions
3033
34+ local function LoadAnimation (dict )
35+ RequestAnimDict (dict )
36+ while not HasAnimDictLoaded (dict ) do
37+ Wait (1 )
38+ end
39+ end
40+
41+ local function CheckAnimLoop ()
42+ CreateThread (function ()
43+ while PhoneData .AnimationData .lib ~= nil and PhoneData .AnimationData .anim ~= nil do
44+ local ped = PlayerPedId ()
45+ if not IsEntityPlayingAnim (ped , PhoneData .AnimationData .lib , PhoneData .AnimationData .anim , 3 ) then
46+ LoadAnimation (PhoneData .AnimationData .lib )
47+ TaskPlayAnim (ped , PhoneData .AnimationData .lib , PhoneData .AnimationData .anim , 3.0 , 3.0 , - 1 , 50 , 0 , false , false , false )
48+ end
49+ Wait (500 )
50+ end
51+ end )
52+ end
53+
54+ function newPhoneProp ()
55+ deletePhone ()
56+ RequestModel (phoneModel )
57+ while not HasModelLoaded (phoneModel ) do
58+ Wait (1 )
59+ end
60+ phoneProp = CreateObject (phoneModel , 1.0 , 1.0 , 1.0 , 1 , 1 , 0 )
61+
62+ local bone = GetPedBoneIndex (PlayerPedId (), 28422 )
63+ if phoneModel == ` prop_cs_phone_01` then
64+ AttachEntityToEntity (phoneProp , PlayerPedId (), bone , 0.0 , 0.0 , 0.0 , 50.0 , 320.0 , 50.0 , 1 , 1 , 0 , 0 , 2 , 1 )
65+ else
66+ AttachEntityToEntity (phoneProp , PlayerPedId (), bone , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 0.0 , 1 , 1 , 0 , 0 , 2 , 1 )
67+ end
68+ end
69+
70+ function deletePhone ()
71+ if phoneProp ~= 0 then
72+ DeleteObject (phoneProp )
73+ phoneProp = 0
74+ end
75+ end
76+
77+ function DoPhoneAnimation (anim )
78+ local ped = PlayerPedId ()
79+ local AnimationLib = ' cellphone@'
80+ local AnimationStatus = anim
81+ if IsPedInAnyVehicle (ped , false ) then
82+ AnimationLib = ' anim@cellphone@in_car@ps'
83+ end
84+ LoadAnimation (AnimationLib )
85+ TaskPlayAnim (ped , AnimationLib , AnimationStatus , 3.0 , 3.0 , - 1 , 50 , 0 , false , false , false )
86+ PhoneData .AnimationData .lib = AnimationLib
87+ PhoneData .AnimationData .anim = AnimationStatus
88+ CheckAnimLoop ()
89+ end
90+
3191function string :split (delimiter )
3292 local result = {}
3393 local from = 1
@@ -978,8 +1038,8 @@ RegisterNUICallback('FetchVehicleScan', function(_, cb)
9781038 QBCore .Functions .TriggerCallback (' qb-phone:server:ScanPlate' , function (result )
9791039 QBCore .Functions .TriggerCallback (' police:IsPlateFlagged' , function (flagged )
9801040 result .isFlagged = flagged
981- if QBCore . Shared . Vehicles [vehname ] ~= nil then
982- result .label = QBCore . Shared . Vehicles [vehname ][' name' ]
1041+ if sharedVehicles [vehname ] ~= nil then
1042+ result .label = sharedVehicles [vehname ][' name' ]
9831043 else
9841044 result .label = ' Unknown brand..'
9851045 end
@@ -1480,14 +1540,26 @@ RegisterNetEvent('QBCore:Client:OnPlayerUnload', function()
14801540 }
14811541end )
14821542
1483- RegisterNetEvent (' QBCore:Client:OnJobUpdate' , function (JobInfo )
1484- SendNUIMessage ({
1485- action = ' UpdateApplications' ,
1486- JobData = JobInfo ,
1487- applications = Config .PhoneApplications
1488- })
1543+ RegisterNetEvent (' QBCore:Client:OnPlayerUpdated' , function (key , val )
1544+ if key == ' job' then
1545+ local JobInfo = val
1546+ SendNUIMessage ({
1547+ action = ' UpdateApplications' ,
1548+ JobData = JobInfo ,
1549+ applications = Config .PhoneApplications
1550+ })
14891551
1490- PlayerJob = JobInfo
1552+ PlayerJob = JobInfo
1553+ elseif key == ' all' then
1554+ local JobInfo = val .job
1555+ SendNUIMessage ({
1556+ action = ' UpdateApplications' ,
1557+ JobData = JobInfo ,
1558+ applications = Config .PhoneApplications
1559+ })
1560+
1561+ PlayerJob = JobInfo
1562+ end
14911563end )
14921564
14931565-- Events
0 commit comments