Advertisement
Combreal

WizardnewLoadTag.lua

Jan 8th, 2015
731
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.96 KB | None | 0 0
  1. -- Tet new Wizard's LoadTags function --
  2.  
  3.  
  4. -- Declare a global table for global use across the script.
  5. local global_tag_id_table
  6. local global_tag_name_table
  7.  
  8. function GetRequiredVersion() return 200 end
  9.  
  10. function OnScriptLoad(process, game, persistent)
  11.     if game == "PC" then
  12.         map_name = readstring(0x698F21)
  13.         map_pointer = 0x63525c
  14.     else
  15.         map_name = readstring(0x61D151)
  16.         map_pointer = 0x5B927C
  17.     end
  18. end
  19.  
  20. function OnNewGame(map)
  21.     LoadTags()
  22. end
  23.  
  24. function OnServerChat(player, type, message)
  25.     local response = nil
  26.     if player then
  27.         if string.lower(message) == "shee" then
  28.             local response = false
  29.             tagId = tag("vehi", "vehicles\\banshee\\banshee_mp")
  30.             privatesay(player, tagId, false)
  31.             return response
  32.         end
  33.     end
  34.     return response
  35. end
  36.  
  37.  function LoadTags()
  38.  
  39.     local map_base = readdword(map_pointer)
  40.     local tag_table_base = readdword(map_base) -- Confirmed. (0x40440028)
  41.     local tag_table_count = readdword(map_base + 0xC) -- Confirmed. Number of tags in the tag table.
  42.     local tag_table_size = 0x20 -- Confirmed.
  43.  
  44.     -- For efficiency within Lua
  45.     local reverse = string.reverse
  46.  
  47.     for i=0,(tag_table_count - 1) do
  48.         local tag_class = reverse(readstring(tag_table_base + (tag_table_size * i), 4))
  49.         local tag_id = readdword(tag_table_base + 0xC + (tag_table_size * i))
  50.         local tag_name_address = readdword(tag_table_base + 0x10 + tag_table_size * i)
  51.         local tag_name = readstring(tag_name_address)
  52.         global_tag_id_table[tag_class] = global_tag_id_table[tag_class] or {}
  53.         global_tag_id_table[tag_class][tag_name] = tag_id
  54.         global_tag_name_table[tag_id] = {}
  55.         global_tag_name_table[tag_id].tag_name = tag_name
  56.         global_tag_name_table[tag_id].tag_class = tag_class
  57.     end
  58. end
  59.  
  60.  function tag(type_or_id, tagname)
  61.     if not tagname then
  62.         return global_tag_name_table[type_or_id].tag_class, global_tag_name_table[type_or_id].tag_name
  63.     end
  64.     return type(global_tag_id_table[type_or_id]) == "table" and global_tag_id_table[type_or_id][tagname]
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement