-- Tet new Wizard's LoadTags function --
-- Declare a global table for global use across the script.
local global_tag_id_table
local global_tag_name_table
function GetRequiredVersion() return 200 end
function OnScriptLoad(process, game, persistent)
if game == "PC" then
map_name = readstring(0x698F21)
map_pointer = 0x63525c
else
map_name = readstring(0x61D151)
map_pointer = 0x5B927C
end
end
function OnNewGame(map)
LoadTags()
end
function OnServerChat(player, type, message)
local response = nil
if player then
if string.lower(message) == "shee" then
local response = false
tagId = tag("vehi", "vehicles\\banshee\\banshee_mp")
privatesay(player, tagId, false)
return response
end
end
return response
end
function LoadTags()
local map_base = readdword(map_pointer)
local tag_table_base = readdword(map_base) -- Confirmed. (0x40440028)
local tag_table_count = readdword(map_base + 0xC) -- Confirmed. Number of tags in the tag table.
local tag_table_size = 0x20 -- Confirmed.
-- For efficiency within Lua
local reverse = string.reverse
for i=0,(tag_table_count - 1) do
local tag_class = reverse(readstring(tag_table_base + (tag_table_size * i), 4))
local tag_id = readdword(tag_table_base + 0xC + (tag_table_size * i))
local tag_name_address = readdword(tag_table_base + 0x10 + tag_table_size * i)
local tag_name = readstring(tag_name_address)
global_tag_id_table[tag_class] = global_tag_id_table[tag_class] or {}
global_tag_id_table[tag_class][tag_name] = tag_id
global_tag_name_table[tag_id] = {}
global_tag_name_table[tag_id].tag_name = tag_name
global_tag_name_table[tag_id].tag_class = tag_class
end
end
function tag(type_or_id, tagname)
if not tagname then
return global_tag_name_table[type_or_id].tag_class, global_tag_name_table[type_or_id].tag_name
end
return type(global_tag_id_table[type_or_id]) == "table" and global_tag_id_table[type_or_id][tagname]
end
Comments
0 B
|👍
/👎