-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathfunctions.lua
167 lines (153 loc) · 6.8 KB
/
functions.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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
---------------------------------------------------------------------------------------------------
--------------------------------------- FUNCTIONS -------------------------------------------------
--close menu
local T = Translation.Langs[Config.Lang]
function Closem()
MenuData.CloseAll()
if Inmenu then
Inmenu = false
end
end
function GetPlayers()
TriggerServerEvent("vorp_admin:GetPlayers")
local playersData = {}
RegisterNetEvent("vorp_admin:SendPlayers", function(result)
playersData = result
end)
while next(playersData) == nil do
Wait(10)
end
return playersData
end
function GetPlayersClient(player)
local players = GetActivePlayers()
for i = 1, #players, 1 do
local server = GetPlayerServerId(players[i])
if tonumber(server) == tonumber(player) then
local ped = 0
while ped == 0 do
ped = GetPlayerPed(players[i])
Wait(10)
end
return ped
end
end
end
function Inputs(input, button, placeholder, header, type, errormsg, pattern)
local myInput = {
type = "enableinput", -- Dont Touch
inputType = input,
button = button, -- Button Name
placeholder = placeholder, -- Place holder name
style = "block", -- Dont Touch
attributes = {
inputHeader = header, -- Header
type = type, -- Inpu type text, number,date.etc if number comment out the pattern
pattern = pattern, -- Regular expression validated for only numbers "[0-9]", for letters only [A-Za-z]+ with charecter limit [A-Za-z]{5,20} with chareceter limit and numbers [A-Za-z0-9]{5,}
title = errormsg, -- If input doesnt match show this message
style = "border-radius: 10px; background-color: ; border:none;", -- Style the input
}
}
return myInput
end
---------------------------------------------------------------------------------------------------------------
----------------------------------- MAIN MENU -----------------------------------------------------------------
function OpenMenu()
MenuData.CloseAll()
local elements = {
{ label = T.Menus.MainMenuOptions.administration, value = 'administration', desc = T.Menus.MainMenuOptions.administration_desc },
{ label = T.Menus.MainMenuOptions.booster, value = 'boost', desc = T.Menus.MainMenuOptions.booster_desc },
{ label = T.Menus.MainMenuOptions.database, value = 'database', desc = T.Menus.MainMenuOptions.database_desc },
{ label = T.Menus.MainMenuOptions.teleport, value = 'teleport', desc = T.Menus.MainMenuOptions.teleport_desc },
{ label = T.Menus.MainMenuOptions.devTools, value = 'devtools', desc = T.Menus.MainMenuOptions.devTools_desc },
}
MenuData.Open('default', GetCurrentResourceName(), 'menuapi',
{
title = T.Menus.DefaultsMenusTitle.menuTitle,
subtext = T.Menus.DefaultsMenusTitle.menuSubTitle,
align = Config.AlignMenu,
elements = elements,
},
function(data, menu)
if data.current == "backup" then
_G[data.trigger]()
end
if data.current.value == "administration" then
local AdminAllowed = IsAdminAllowed("vorp.staff.Admin")
if AdminAllowed then
Admin()
end
elseif data.current.value == "boost" then
local AdminAllowed = IsAdminAllowed("vorp.staff.Boosters")
if AdminAllowed then
Boost()
end
elseif data.current.value == "database" then
local AdminAllowed = IsAdminAllowed("vorp.staff.Database")
if AdminAllowed then
DataBase()
end
elseif data.current.value == "teleport" then
local AdminAllowed = IsAdminAllowed("vorp.staff.Teleports")
if AdminAllowed then
Teleport()
end
elseif data.current.value == "devtools" then
local AdminAllowed = IsAdminAllowed("vorp.staff.Devtools")
if AdminAllowed then
OpenDevTools()
end
end
end,
function(data, menu)
menu.close()
end)
end
-- FUNCTIONS
-- CREDITS to the author for the clipboard
function Round(input, decimalPlaces)
return tonumber(string.format("%." .. (decimalPlaces or 0) .. "f", input))
end
function CopyToClipboard(dataType)
local ped = PlayerPedId()
local coords = GetEntityCoords(ped)
local x, y, z = Round(coords.x, 2), Round(coords.y, 2), Round(coords.z, 2)
if dataType == 'v2' then
local copiedText = string.format('{x = %s, y = %s, z = %s}', x, y, z)
SendNUIMessage({ string = copiedText })
TriggerEvent('vorp:TipRight', T.Notify.copied, 3000)
elseif dataType == 'v3' then
local copiedText = string.format('vector3(%s, %s, %s)', x, y, z)
SendNUIMessage({ string = copiedText })
TriggerEvent('vorp:TipRight', T.Notify.copied, 3000)
elseif dataType == 'v4' then
local heading = GetEntityHeading(ped)
local h = Round(heading, 2)
local copiedText = string.format('vector4(%s, %s, %s, %s)', x, y, z, h)
SendNUIMessage({ string = copiedText })
TriggerEvent('vorp:TipRight', T.Notify.copied, 3000)
elseif dataType == 'heading' then
local heading = Round(GetEntityHeading(ped), 2)
SendNUIMessage({ string = heading })
TriggerEvent('vorp:TipRight', T.Notify.copied, 3000)
end
end
-- GET CLOSESTOBJECT
function GetClosestObject(coords)
local ped = PlayerPedId()
local objects = GetGamePool('CObject')
local closestDistance = -1
local closestObject = -1
if not coords then
coords = GetEntityCoords(ped)
end
for i = 1, #objects, 1 do
local objectCoords = GetEntityCoords(objects[i])
local distance = #(objectCoords - coords)
if closestDistance == -1 or closestDistance > distance then
closestObject = objects[i]
closestDistance = distance
end
end
return closestObject, closestDistance
end