-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathsv_main.lua
More file actions
77 lines (57 loc) · 1.98 KB
/
sv_main.lua
File metadata and controls
77 lines (57 loc) · 1.98 KB
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
---------------------------
-- made by parow with <3 --
---------------------------
function GetBlipData()
local a = LoadResourceFile("BlipsBuilder", "data/blipData.json")
return a and json.decode(a) or {}
end
RegisterServerEvent('bc:addBlip')
AddEventHandler('bc:addBlip', function (data)
BlipData = GetBlipData()
print(dump(data))
table.insert(BlipData,data)
SaveResourceFile("BlipsBuilder", "data/blipData.json", json.encode(BlipData))
TriggerClientEvent("bc:SyncBlips",-1, GetBlipData())
end)
RegisterServerEvent('bc:editBlip')
AddEventHandler('bc:editBlip', function (i,data)
print(i)
print(dump(data))
BlipData = GetBlipData()
BlipData[i] = data
SaveResourceFile("BlipsBuilder", "data/blipData.json", json.encode(BlipData))
TriggerClientEvent("bc:SyncBlips",-1, GetBlipData())
end)
RegisterServerEvent('bc:deleteBlip')
AddEventHandler('bc:deleteBlip', function (i)
BlipData = GetBlipData()
table.remove(BlipData,i)
SaveResourceFile("BlipsBuilder", "data/blipData.json", json.encode(BlipData))
TriggerClientEvent("bc:SyncBlips",-1, GetBlipData())
end)
RegisterServerEvent('bc:requestSync')
AddEventHandler('bc:requestSync', function ()
BlipData = GetBlipData()
TriggerClientEvent("bc:SyncBlips",source,BlipData)
end)
function dump(o)
if type(o) == 'table' then
local s = '{ '
for k,v in pairs(o) do
if type(k) ~= 'number' then k = '"'..k..'"' end
s = s .. '['..k..'] = ' .. dump(v) .. ','
end
return s .. '} '
else
return tostring(o)
end
end
local count = 0
for _,v in pairs(GetBlipData()) do count = count + 1 end
print("[BlipsBuilder] Successfully loaded: " .. count .. " blip(s).")
TriggerEvent('es:addGroupCommand', 'blipsbuilder', 'admin', function(source)
TriggerClientEvent('bc:OpenMenu', source)
end, function(source, _, _)
local _source = source
TriggerClientEvent('chatMessage', _source, "SYSTEM", {255, 0, 0}, 'Insufficient permissions!')
end, {help = ''})