mirror of
https://github.com/mangosfour/server.git
synced 2025-12-28 13:37:13 +00:00
[Rel21] Stage 2 of updates for Rel21 Build System
This commit is contained in:
parent
fdefc0869a
commit
0bffcd62ad
79 changed files with 26890 additions and 0 deletions
88
src/modules/Eluna/extensions/ObjectVariables.ext
Normal file
88
src/modules/Eluna/extensions/ObjectVariables.ext
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
--
|
||||
-- Copyright (C) 2010 - 2015 Eluna Lua Engine <http://emudevs.com/>
|
||||
-- This program is free software licensed under GPL version 3
|
||||
-- Please see the included DOCS/LICENSE.md for more information
|
||||
--
|
||||
|
||||
-- filename.ext files are loaded before normal .lua files
|
||||
|
||||
local variableStores = {
|
||||
Map = {},
|
||||
Player = {},
|
||||
Creature = {},
|
||||
GameObject = {},
|
||||
}
|
||||
|
||||
local function DestroyData(event, obj)
|
||||
if (event == 18) then
|
||||
local mapid = obj:GetMapId()
|
||||
local instid = obj:GetInstanceId()
|
||||
if (variableStores.Map[mapid]) then
|
||||
variableStores.Map[mapid][instid] = nil
|
||||
end
|
||||
else
|
||||
variableStores[obj:GetObjectType()][obj:GetGUIDLow()] = nil
|
||||
end
|
||||
end
|
||||
|
||||
local function GetData(self, field)
|
||||
local Type = self:GetObjectType()
|
||||
local varStore = variableStores[Type]
|
||||
local id
|
||||
if (Type == "Map") then
|
||||
local mapid = self:GetMapId()
|
||||
varStore = varStore[mapid]
|
||||
if (not varStore) then
|
||||
return nil
|
||||
end
|
||||
id = self:GetInstanceId()
|
||||
else
|
||||
id = self:GetGUIDLow()
|
||||
end
|
||||
|
||||
if (not varStore[id]) then
|
||||
return nil
|
||||
end
|
||||
|
||||
if (field == nil) then
|
||||
return varStore[id]
|
||||
else
|
||||
return varStore[id][field]
|
||||
end
|
||||
end
|
||||
|
||||
local function SetData(self, field, val)
|
||||
assert(field ~= nil, "field was nil", 2)
|
||||
|
||||
local Type = self:GetObjectType()
|
||||
local varStore = variableStores[Type]
|
||||
local id
|
||||
if (Type == "Map") then
|
||||
local mapid = self:GetMapId()
|
||||
|
||||
if (not varStore[mapid]) then
|
||||
varStore[mapid] = {}
|
||||
end
|
||||
varStore = varStore[mapid]
|
||||
|
||||
id = self:GetInstanceId()
|
||||
else
|
||||
id = self:GetGUIDLow()
|
||||
end
|
||||
|
||||
if (not varStore[id]) then
|
||||
varStore[id] = {}
|
||||
end
|
||||
|
||||
varStore[id][field] = val
|
||||
end
|
||||
|
||||
for k,v in pairs(variableStores) do
|
||||
_G[k].GetData = GetData
|
||||
_G[k].SetData = SetData
|
||||
end
|
||||
|
||||
RegisterPlayerEvent(4, DestroyData)
|
||||
RegisterServerEvent(31, DestroyData)
|
||||
RegisterServerEvent(32, DestroyData)
|
||||
RegisterServerEvent(18, DestroyData)
|
||||
Loading…
Add table
Add a link
Reference in a new issue