@@ -98,17 +98,10 @@ local function IsRadioOn()
9898 return onRadio
9999end
100100
101- local function DoRadioCheck (PlayerItems )
102- local _hasRadio = false
103-
104- for _ , item in pairs (PlayerItems ) do
105- if item .name == " radio" then
106- _hasRadio = true
107- break ;
108- end
109- end
110-
111- hasRadio = _hasRadio
101+ local function DoRadioCheck ()
102+ QBCore .Functions .TriggerCallback (" qb-radio::server::hasRadio" , function (value )
103+ hasRadio = value
104+ end )
112105end
113106
114107-- Exports
@@ -119,27 +112,26 @@ exports("IsRadioOn", IsRadioOn)
119112-- Handles state right when the player selects their character and location.
120113RegisterNetEvent (' QBCore:Client:OnPlayerLoaded' , function ()
121114 PlayerData = QBCore .Functions .GetPlayerData ()
122- DoRadioCheck (PlayerData . items )
115+ DoRadioCheck ()
123116end )
124117
125118-- Resets state on logout, in case of character change.
126119RegisterNetEvent (' QBCore:Client:OnPlayerUnload' , function ()
127- DoRadioCheck ({})
128120 PlayerData = {}
129121 leaveradio ()
130122end )
131123
132124-- Handles state when PlayerData is changed. We're just looking for inventory updates.
133125RegisterNetEvent (' QBCore:Player:SetPlayerData' , function (val )
134126 PlayerData = val
135- DoRadioCheck (PlayerData . items )
127+ DoRadioCheck ()
136128end )
137129
138130-- Handles state if resource is restarted live.
139131AddEventHandler (' onResourceStart' , function (resource )
140132 if GetCurrentResourceName () == resource then
141133 PlayerData = QBCore .Functions .GetPlayerData ()
142- DoRadioCheck (PlayerData . items )
134+ DoRadioCheck ()
143135 end
144136end )
145137
0 commit comments