@@ -22,10 +22,10 @@ MSK.GetRandomLetter = function(length)
22
22
end
23
23
end
24
24
25
- MSK .RegisterCommand = function (name , group , cb , console , suggestion )
25
+ MSK .RegisterCommand = function (name , group , cb , console , framework , suggestion )
26
26
if type (name ) == ' table' then
27
27
for k , v in ipairs (name ) do
28
- MSK .RegisterCommand (v , group , cb , console , suggestion )
28
+ MSK .RegisterCommand (v , group , cb , console , framework , suggestion )
29
29
end
30
30
return
31
31
end
@@ -86,14 +86,14 @@ MSK.RegisterCommand = function(name, group, cb, console, suggestion)
86
86
MSK .Notification (source , error )
87
87
end
88
88
else
89
- if Config .Framework :match (' standalone' ) then
90
- cb (source , args , rawCommand )
91
- elseif Config .Framework :match (' esx' ) then
89
+ if Config .Framework :match (' esx' ) and framework then
92
90
local xPlayer = ESX .GetPlayerFromId (source )
93
91
cb (xPlayer , args , rawCommand )
94
- elseif Config .Framework :match (' qbcore' ) then
92
+ elseif Config .Framework :match (' qbcore' ) and framework then
95
93
local Player = QBCore .Functions .GetPlayer (source )
96
94
cb (Player , args , rawCommand )
95
+ elseif Config .Framework :match (' standalone' ) or not framework then
96
+ cb (source , args , rawCommand )
97
97
end
98
98
end
99
99
end
@@ -128,6 +128,7 @@ MSK.Table_Contains = function(table, value)
128
128
end
129
129
end
130
130
end
131
+ return false
131
132
end
132
133
133
134
MSK .AddWebhook = function (webhook , botColor , botName , botAvatar , title , description , fields , footer , time )
@@ -174,6 +175,38 @@ MSK.logging = function(script, code, ...)
174
175
end
175
176
end
176
177
178
+ MSK .HasItem = function (xPlayer , item )
179
+ if not xPlayer then logging (' error' , ' Player on Function MSK.HasItem does not exist!' ) return end
180
+ if not Config .Framework :match (' esx' ) or Config .Framework :match (' qbcore' ) then
181
+ logging (' error' , (' Function %s can not used without Framework!' ):format (' ^3MSK.HasItem^0' ))
182
+ return
183
+ end
184
+ local hasItem
185
+
186
+ if Config .Framework :match (' esx' ) then
187
+ hasItem = xPlayer .getInventoryItem (item )
188
+ elseif Config .Framework :match (' qbcore' ) then
189
+ hasItem = xPlayer .Functions .GetItemByName (item )
190
+ else
191
+ logging (' error' , ' Framework on Function MSK.HasItem is not configured!' )
192
+ end
193
+
194
+ return hasItem
195
+ end
196
+
197
+ MSK .RegisterCallback (' msk_core:hasItem' , function (source , cb , item )
198
+ local src = source
199
+ local xPlayer
200
+
201
+ if Config .Framework :match (' esx' ) then
202
+ xPlayer = ESX .GetPlayerFromId (src )
203
+ elseif Config .Framework :match (' qbcore' ) then
204
+ xPlayer = QBCore .Functions .GetPlayer (src )
205
+ end
206
+
207
+ cb (MSK .HasItem (xPlayer , item ))
208
+ end )
209
+
177
210
RegisterNetEvent (' msk_core:triggerCallback' )
178
211
AddEventHandler (' msk_core:triggerCallback' , function (name , requestId , ...)
179
212
local src = source
0 commit comments