-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsv_utility.lua
48 lines (38 loc) · 1.16 KB
/
sv_utility.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
local pairs = pairs
local print = print
local tostring = tostring
local sub = string.sub
local len = string.len
local gsub = string.gsub
local gmatch = string.gmatch
local insert = table.insert
local _GetPlayerIdentifiers = GetPlayerIdentifiers
cachedIdentifiers = {}
function Log(message)
print("^1DiscordAPI ^7| " .. tostring(message))
end
function GetIdentifiersTable(player)
if cachedIdentifiers[player] then return cachedIdentifiers[player] end
local data = {}
for _, v in pairs(_GetPlayerIdentifiers(player))do
if sub(v, 1, len("license:")) == "license:" then
data.license = v
elseif sub(v, 1, len("discord:")) == "discord:" then
data.discord = gsub(v, "discord:", "")
end
end
cachedIdentifiers[player] = data
return data
end
AddEventHandler("playerDropped", function()
if not cachedIdentifiers[source] then return end
cachedIdentifiers[source] = nil
end)
function SplitString(input, separator)
if separator == nil then separator = "%s" end
local split = {}
for str in gmatch(input, "([^" .. separator .. "]+)") do
insert(split, str)
end
return split
end