-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwosa_api_server.lua
More file actions
93 lines (72 loc) · 2.54 KB
/
wosa_api_server.lua
File metadata and controls
93 lines (72 loc) · 2.54 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
--------------------------------
--- WOSA API - OFFICIAL FILE ---
--------------------------------
--------------------------
--- API CONFIG PRIVATE ---
--------------------------
-- @ARRAY API REGISTER
Wosa = nil
-- @LOCAL API REGISTER
local WOSA_API = {}
-- @ARRAY API CONFIG [SHOULD NOT BE TOUCHED]
WOSA_API.CONFIG = {
API_SYNC_VERSION = 2.0,
API_SYNC_RESOURCE = GetCurrentResourceName(),
}
------------------------------
--- API (FROM WOSA) EVENTS ---
------------------------------
TriggerEvent('WOSA:USER_DATA:LIBRARY:SERVER:GET_DATA_v2', function(data) Wosa = data end)
--------------------------------
--- API (MAIN EVENTS) EVENTS ---
--------------------------------
-- @ON RESOURCE START
AddEventHandler('onResourceStart', function(resource)
if resource == WOSA_API.CONFIG.API_SYNC_RESOURCE then
local send_data = {resource = WOSA_API.CONFIG.API_SYNC_RESOURCE, version = WOSA_API.CONFIG.API_SYNC_VERSION}
TriggerEvent('WOSA:API_SYNC:DATA_WRITE', source, 'add_resource', send_data)
end
end)
-- @ON RESOURCE STOP
AddEventHandler('onResourceStop', function(resource)
if resource == WOSA_API.CONFIG.API_SYNC_RESOURCE then
local send_data = {resource = WOSA_API.CONFIG.API_SYNC_RESOURCE, version = WOSA_API.CONFIG.API_SYNC_VERSION}
TriggerEvent('WOSA:API_SYNC:DATA_WRITE', source, 'rem_resource', send_data)
end
end)
-------------------
--- TRANSLATION ---
-------------------
t = function(key, data1, data2, data3, data4, data5, data6)
if data1 == nil then
return Wosa.Translate.Get()[WOSA_API.CONFIG.API_SYNC_RESOURCE][Wosa.Translate.Language()][key] or Wosa.Translate.Get()[WOSA_API.CONFIG.API_SYNC_RESOURCE]['en'][key] or key
else
if Wosa.Translate.Get()[WOSA_API.CONFIG.API_SYNC_RESOURCE][Wosa.Translate.Language()][key] == nil and Wosa.Translate.Get()[WOSA_API.CONFIG.API_SYNC_RESOURCE]['en'][key] == nil then
return key
else
local cache = Wosa.Translate.Get()[WOSA_API.CONFIG.API_SYNC_RESOURCE][Wosa.Translate.Language()][key] or Wosa.Translate.Get()[WOSA_API.CONFIG.API_SYNC_RESOURCE]['en'][key]
if data1 ~= nil then
cache = cache:gsub('#data1', data1)
end
if data2 ~= nil then
cache = cache:gsub('#data2', data2)
end
if data3 ~= nil then
cache = cache:gsub('#data3', data3)
end
if data4 ~= nil then
cache = cache:gsub('#data4', data4)
end
if data5 ~= nil then
cache = cache:gsub('#data5', data5)
end
if data5 ~= nil then
cache = cache:gsub('#data5', data5)
end
if data6 ~= nil then
cache = cache:gsub('#data6', data6)
end
return cache
end
end
end