Advertisement
Combreal

master-server.lua

May 24th, 2014
576
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.67 KB | None | 0 0
  1. --New Master Server
  2. --Changes to the new lobby that the server broadcasts to. Also allows you to change the version.
  3.  
  4. default_version = "01.00.10.0621"
  5. version_address = nil
  6. Game = nil
  7.  
  8. function GetRequiredVersion()
  9.     return 200
  10. end
  11.  
  12. function OnScriptLoad(processId, game, persistent)
  13.     if not persistent then
  14.         hprintf("You probably want to load this script persistently when the server starts.")
  15.         hprintf("ie. put it into scripts/persistent and don't load from your init file.")
  16.     end
  17.     local addr1 = nil
  18.     local addr2 = nil
  19.     Game = game
  20.     if (game == "PC") then
  21.         addr1 = 0x5c34b4
  22.         addr2 = 0x5c3a08
  23.         version_address = 0x5df840
  24.     else
  25.         addr1 = 0x54d384
  26.         addr2 = 0x54d720
  27.         version_address = 0x564b34
  28.     end
  29.        
  30.     -- phasor's writestring functions are ridiculously bugged (lol)
  31.     writestring(addr1, "s1.master.hosthpc.com")
  32.     writestring(addr2, "s1.ms01.hosthpc.com")
  33.     writestring(version_address, default_version)
  34. end
  35.  
  36. function OnServerCommand(admin, command)
  37.     t = tokenizecmdstring(command)
  38.     count = #t
  39.     if (count == 0) then return nil end
  40.     if t[1] == "sv_version" then
  41.         local processed = false
  42.         if (count == 2) then
  43.             v = t[2]
  44.             if (v == "1.10" or v == "110" or v == "10") then                           
  45.                 writestring(version_address, "01.00.10.0621")
  46.                 processed = true
  47.                 respond("Broadcasting on version " .. readstring(version_address))
  48.             end
  49.         else
  50.             respond("current version: " .. readstring(version_address))
  51.             respond("valid versions: 110")
  52.         end    
  53.         return not processed
  54.     end
  55. end
  56.  
  57. function writestring(addr, str)
  58.     local l = 0
  59.     for i = 1, #str do
  60.         local c = string.byte(str, i)
  61.         writebyte(addr + i - 1, c)
  62.         l = l + 1
  63.     end
  64.     writebyte(addr + l, 0)
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement