Combreal icon

master-server.lua

Combreal | PRO | 05/24/14 03:39:07 PM UTC | 0 ⭐ | 1304 👁️ | Never ⏰ | []
Lua |

1.67 KB

|

None

|

0 👍

/

0 👎

--New Master Server
--Changes to the new lobby that the server broadcasts to. Also allows you to change the version.
 
default_version = "01.00.10.0621"
version_address = nil
Game = nil
 
function GetRequiredVersion()
    return 200
end
 
function OnScriptLoad(processId, game, persistent)
    if not persistent then
        hprintf("You probably want to load this script persistently when the server starts.")
        hprintf("ie. put it into scripts/persistent and don't load from your init file.")
    end
    local addr1 = nil
    local addr2 = nil
    Game = game
    if (game == "PC") then
        addr1 = 0x5c34b4
        addr2 = 0x5c3a08
        version_address = 0x5df840
    else
        addr1 = 0x54d384
        addr2 = 0x54d720
        version_address = 0x564b34
    end
        
    -- phasor's writestring functions are ridiculously bugged (lol)
    writestring(addr1, "s1.master.hosthpc.com")
    writestring(addr2, "s1.ms01.hosthpc.com")
    writestring(version_address, default_version)
end
 
function OnServerCommand(admin, command)
    t = tokenizecmdstring(command)
    count = #t
    if (count == 0) then return nil end
    if t[1] == "sv_version" then
        local processed = false
        if (count == 2) then
            v = t[2]
            if (v == "1.10" or v == "110" or v == "10") then                            
                writestring(version_address, "01.00.10.0621")
                processed = true
                respond("Broadcasting on version " .. readstring(version_address))
            end
        else
            respond("current version: " .. readstring(version_address)) 
            respond("valid versions: 110")
        end     
        return not processed
    end
end
 
function writestring(addr, str)
    local l = 0
    for i = 1, #str do
        local c = string.byte(str, i)
        writebyte(addr + i - 1, c)
        l = l + 1
    end
    writebyte(addr + l, 0)
end

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎