forked from AlterGamingNetwork/mellotrainer
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcl_utils.lua
139 lines (114 loc) · 2.87 KB
/
cl_utils.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
--[[--------------------------------------------------------------------------
*
* Mello Trainer
* (C) Michael Goodwin 2017
* http://github.com/thestonedturtle/mellotrainer/releases
*
* This menu used the Scorpion Trainer as a framework to build off of.
* https://github.com/pongo1231/ScorpionTrainer
* (C) Emre Cürgül 2017
*
* A lot of useful functionality has been converted from the lambda menu.
* https://lambda.menu
* (C) Oui 2017
*
* Additional Contributors:
* WolfKnight (https://forum.fivem.net/u/WolfKnight)
*
---------------------------------------------------------------------------]]
function _LoadAnimDict( dict )
while ( not HasAnimDictLoaded( dict ) ) do
RequestAnimDict( dict )
Citizen.Wait( 5 )
end
end
function _LoadClipSet( set )
while ( not HasClipSetLoaded( set ) ) do
RequestClipSet( set )
Citizen.Wait( 5 )
end
end
function _LoadModel( mdl )
while ( not HasModelLoaded( mdl ) ) do
RequestModel( mdl )
Citizen.Wait( 5 )
end
end
-- Used to show notifications on the screen.
function drawNotification(text)
SetNotificationTextEntry("STRING")
AddTextComponentString(text)
DrawNotification(false, false)
end
-- String splits by the separator.
function stringsplit(inputstr, sep)
if sep == nil then
sep = "%s"
end
local t={} ; i=1
for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
t[i] = str
i = i + 1
end
return t
end
-- Sort a table by values.
function sortByValue(custTable)
local Keys = {}
for k,_ in pairs(custTable) do
Keys[#Keys+1] = _
end
table.sort(Keys)
local newObj = {}
for k,v in ipairs(Keys) do
for key,value in pairs(custTable) do
if value == v then
newObj[key] = value
break
end
end
end
return newObj
end
-- Get Table Length
function getTableLength(T)
local count = 0
for _ in pairs(T) do
count = count + 1
end
return count
end
-- Get value for state toggles
function GetToggleState(variableName)
local value = _G[variableName]
if(value)then
return "ON"
else
return "OFF"
end
end
function requestInput(exampleText, maxLength)
DisplayOnscreenKeyboard(1, "FMMC_KEY_TIP8", "", exampleText, "", "", "", maxLength + 1)
blockinput = true
while UpdateOnscreenKeyboard() ~= 1 and UpdateOnscreenKeyboard() ~= 2 do
Citizen.Wait( 0 )
end
local result = GetOnscreenKeyboardResult()
UnblockMenuInput()
if result ~= "" and result ~= exampleText then
return result
else
return false
end
end
function UnblockMenuInput()
Citizen.CreateThread( function()
Citizen.Wait( 150 )
blockinput = false
end )
end
function tableSet(mytable)
local set = {}
for _,l in ipairs(mytable) do set[l] = true end
return set
end