@@ -98,17 +98,8 @@ 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+ hasRadio = QBCore .Functions .HasItem (Config .RadioItem , 1 )
112103end
113104
114105-- Exports
@@ -119,27 +110,27 @@ exports("IsRadioOn", IsRadioOn)
119110-- Handles state right when the player selects their character and location.
120111RegisterNetEvent (' QBCore:Client:OnPlayerLoaded' , function ()
121112 PlayerData = QBCore .Functions .GetPlayerData ()
122- DoRadioCheck (PlayerData . items )
113+ DoRadioCheck ()
123114end )
124115
125116-- Resets state on logout, in case of character change.
126117RegisterNetEvent (' QBCore:Client:OnPlayerUnload' , function ()
127- DoRadioCheck ({} )
118+ DoRadioCheck ()
128119 PlayerData = {}
129120 leaveradio ()
130121end )
131122
132123-- Handles state when PlayerData is changed. We're just looking for inventory updates.
133124RegisterNetEvent (' QBCore:Player:SetPlayerData' , function (val )
134125 PlayerData = val
135- DoRadioCheck (PlayerData . items )
126+ DoRadioCheck ()
136127end )
137128
138129-- Handles state if resource is restarted live.
139130AddEventHandler (' onResourceStart' , function (resource )
140131 if GetCurrentResourceName () == resource then
141132 PlayerData = QBCore .Functions .GetPlayerData ()
142- DoRadioCheck (PlayerData . items )
133+ DoRadioCheck ()
143134 end
144135end )
145136
0 commit comments