11MSK = {}
2- MSK .Timeouts = {}
2+
3+ local Timeouts = {}
4+ local callbackRequest = {}
35
46if Config .Framework :match (' esx' ) then
57 ESX = exports [" es_extended" ]:getSharedObject ()
68elseif Config .Framework :match (' qbcore' ) then
79 QBCore = exports [' qb-core' ]:GetCoreObject ()
810end
911
10- local callbackRequest = {}
1112local Letters = {}
1213for i = 48 , 57 do table.insert (Letters , string.char (i )) end
1314for i = 65 , 90 do table.insert (Letters , string.char (i )) end
1415for i = 97 , 122 do table.insert (Letters , string.char (i )) end
1516
16- MSK .Round = function (num , decimal )
17- return tonumber (string.format (" %." .. (decimal or 0 ) .. " f" , num ))
18- end
19-
20- MSK .Trim = function (str )
21- return (string.gsub (str , " %s+" , " " ))
22- end
23-
2417MSK .GetRandomLetter = function (length )
2518 Wait (0 )
2619 if length > 0 then
@@ -30,14 +23,12 @@ MSK.GetRandomLetter = function(length)
3023 end
3124end
3225
33- MSK .HasItem = function (item )
34- if not Config .Framework :match (' esx' ) or Config .Framework :match (' qbcore' ) then
35- logging (' error' , (' Function %s can not used without Framework!' ):format (' MSK.HasItem' ))
36- return
37- end
26+ MSK .Round = function (num , decimal )
27+ return tonumber (string.format (" %." .. (decimal or 0 ) .. " f" , num ))
28+ end
3829
39- local hasItem = MSK . TriggerCallback ( ' msk_core:hasItem ' , item )
40- return hasItem
30+ MSK . Trim = function ( str )
31+ return ( string.gsub ( str , " %s+ " , " " ))
4132end
4233
4334MSK .Notification = function (text )
@@ -76,25 +67,6 @@ MSK.Draw3DText = function(coords, text, size, font)
7667 ClearDrawOrigin ()
7768end
7869
79- MSK .Table_Contains = function (table , value )
80- if type (value ) == ' table' then
81- for k , v in pairs (table ) do
82- for k2 , v2 in pairs (value ) do
83- if v == v2 then
84- return true
85- end
86- end
87- end
88- else
89- for k , v in pairs (table ) do
90- if v == value then
91- return true
92- end
93- end
94- end
95- return false
96- end
97-
9870MSK .TriggerCallback = function (name , ...)
9971 local requestId = GenerateRequestKey (callbackRequest )
10072 local response
@@ -113,12 +85,41 @@ MSK.TriggerCallback = function(name, ...)
11385end
11486
11587MSK .AddTimeout = function (ms , cb )
116- table.insert (MSK . Timeouts , {time = GetGameTimer () + ms , cb = cb })
117- return # MSK . Timeouts
88+ table.insert (Timeouts , {time = GetGameTimer () + ms , cb = cb })
89+ return # Timeouts
11890end
11991
12092MSK .DelTimeout = function (i )
121- MSK .Timeouts [i ] = nil
93+ Timeouts [i ] = nil
94+ end
95+
96+ MSK .HasItem = function (item )
97+ if not Config .Framework :match (' esx' ) or Config .Framework :match (' qbcore' ) then
98+ logging (' error' , (' Function %s can not used without Framework!' ):format (' MSK.HasItem' ))
99+ return
100+ end
101+
102+ local hasItem = MSK .TriggerCallback (' msk_core:hasItem' , item )
103+ return hasItem
104+ end
105+
106+ MSK .Table_Contains = function (table , value )
107+ if type (value ) == ' table' then
108+ for k , v in pairs (table ) do
109+ for k2 , v2 in pairs (value ) do
110+ if v == v2 then
111+ return true
112+ end
113+ end
114+ end
115+ else
116+ for k , v in pairs (table ) do
117+ if v == value then
118+ return true
119+ end
120+ end
121+ end
122+ return false
122123end
123124
124125MSK .logging = function (script , code , ...)
@@ -161,14 +162,14 @@ CreateThread(function()
161162 while true do
162163 local sleep = 200
163164
164- if # MSK . Timeouts > 0 then
165+ if # Timeouts > 0 then
165166 local currTime = GetGameTimer ()
166167 sleep = 0
167168
168- for i = 1 , # MSK . Timeouts , 1 do
169- if currTime >= MSK . Timeouts [i ].time then
170- MSK . Timeouts [i ].cb ()
171- MSK . Timeouts [i ] = nil
169+ for i = 1 , # Timeouts , 1 do
170+ if currTime >= Timeouts [i ].time then
171+ Timeouts [i ].cb ()
172+ Timeouts [i ] = nil
172173 end
173174 end
174175 end
0 commit comments