-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.lua
60 lines (56 loc) · 1.96 KB
/
init.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
ChaosMod = {}
ChaosMod.Modules = {}
ChaosMod.ModuleList = {}
ChaosMod.Modules.__index = ChaosMod.Modules
function GetModuleClass(ID)
return ChaosMod.Modules[ID]
end
function ChaosMod.Modules.new(Identifier, Name, Description, ClientFunction, ServerFunction)
local newModule = {}
setmetatable(newModule, ChaosMod.Modules)
newModule.ID = Identifier
newModule.Name = Name
newModule.Description = Description
newModule.ClientFunction = ClientFunction
newModule.ServerFunction = ServerFunction
if IsDuplicityVersion() then
newModule.Event = string.format("ChaosMod:%s:%s:Start", newModule.ID, randomString(10))
else
TriggerServerEvent("ChaosMod:RequstEventName", newModule.ID)
end
DebugPrint(string.format("%s has been loaded.", newModule.ID))
ChaosMod.Modules[Identifier] = newModule
ChaosMod.ModuleList[#ChaosMod.ModuleList+1] = Identifier
return newModule
end
function ChaosMod.Modules:Start()
DebugPrint(string.format("%s has been triggered.", self.ID))
TriggerClientEvent('chat:addMessage', -1, {args = {"^5[^1ChaosMod^5]", string.format("%s - %s", self.Name, self.Description)}})
if self.ClientFunction then
TriggerClientEvent(self.Event, -1)
end
if self.ServerFunction then
self.ServerFunction()
end
end
if IsDuplicityVersion() then
function ChaosMod.Modules:GetEventName()
return self.Event
end
RegisterNetEvent("ChaosMod:RequstEventName")
AddEventHandler("ChaosMod:RequstEventName", function(Identifier)
TriggerClientEvent("ChaosMod:RecieveEventName", source, Identifier, GetModuleClass(Identifier):GetEventName())
end)
else
function ChaosMod.Modules:UpdateEventID(Event)
self.Event = Event
if self.ClientFunction then
RegisterNetEvent(self.Event)
AddEventHandler(self.Event, self.ClientFunction)
end
end
RegisterNetEvent("ChaosMod:RecieveEventName")
AddEventHandler("ChaosMod:RecieveEventName", function(Identifier, EventName)
GetModuleClass(Identifier):UpdateEventID(EventName)
end)
end