Posts by h0tw1r3

A new update is now available, introducing a lot of new content!
Latest hotfix: 0.7.5.2 (2024-09-10)

    Very good news! Thank you, thank you. I was just starting to work on my server mod manager again. Looks like I'll put that on hold :)


    About how long before the change will be available (weeks, months)?
    Will it be possible to put out a developer preview?

    Here you can have a little look at what I've written.
    It's not finished yet. But you can also edit like .


    Administration.lua is not standalone - there is no way to run the code for debugging or testing.


    So many commands are missing: sscanf, SendPlayerMessage, LogString, GetMaxPlayers, getCharacterById, IsPlayerConnected, character:*, SendPlayerMessage, PlayAnimation... the list goes on and on.


    Did this come from another game engine? If so, it's really not useful at all. ;(

    Lots of fixes and updates today. Main show stopper from me running this on my main server is the lack of privilege support. Will be working on that in the next day or two.


    Below is an example Message of the day module.

    • Automatically displays the latest message on login
    • Message display every hour to connected players
    • Adds /motd command with three actions (broadcast, list, set)
    • Adds motd help information to the /help command (framework built-in)


    [lua]
    -- Copyright (c) 2014, Jeffrey Clark. This file is licensed under the
    -- Affero General Public License version 3 or later. See the COPYRIGHT file.


    modMotd = {
    new = function()
    self = ModBase.new()
    self.name = "Message of the day"
    self.author = "h0tw1r3"
    self.version = 0.1


    -- Module initilization
    db:queryupdate("CREATE TABLE IF NOT EXISTS `motd` (`ID` INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, `time` INTEGER, `message` VARCHAR);");


    -- Internal methods
    self.broadcastMotd = function(self)
    server:brodcastTextMessage(self:prettyMotd())
    end


    self.prettyMotd = function(self, motd)
    if not motd then motd = self:getMotd() end
    return string.format("[#FFA500]** %s -- %s", motd.message, os.date("%x %X", motd.time))
    end


    self.getMotd = function(self)
    -- TODO: cache result
    local motd = { time = 0, message = "No message of the day" }
    result = db:query("SELECT * FROM motd ORDER BY time DESC LIMIT 1;")
    if result:next() then
    motd.time = result:getInt("time")
    motd.message = result:getString("message")
    end
    result:close()


    return motd
    end


    -- Client commands and help list
    self.commands['motd'] = {
    callback = function(event, command, action, message)
    if not action then
    event.player:sendTextMessage(self:prettyMotd())
    elseif action == "broadcast" then
    self:broadcastMotd()
    elseif action == "list" then
    -- TODO
    ModManager:sendPlayerCommandHelp(event.player, command, "list not implemented yet")
    elseif action == "set" and message then
    db:queryupdate("INSERT INTO motd (time, message) VALUES (strftime('%s', 'now'), '" .. message .. "')")
    event.player:sendTextMessage("motd set")
    else
    ModManager:sendPlayerCommandHelp(event.player, command, "Invalid command usage, see /help " .. command)
    end
    return true
    end,
    help = {
    "set <message>",
    "broadcast => send motd to all players",
    "list => show last 5 messages",
    " => show motd",
    }
    }


    -- Global timers
    self.timers['Broadcast'] = {
    -- Broadcast motd every 60 minutes, forever
    frequency = 3600,
    count = -1,
    callback = function() self:broadcastMotd() end
    }


    -- Event hooks
    self.events['PlayerSpawn'] = {
    callback = function(event)
    event.player:sendTextMessage(self:prettyMotd())
    end,
    }


    return self
    end
    }
    [/lua]

    @Hroudtwolf
    can you edit it i have downloaded a lua editor but i dont know what im doing wrong if you edit it i can see my fault


    /soapbox Taking credit for something you didn't write is really not the best way to get help from people who know what they are doing. 90% of what you claim to have written was taken from my h0tstuff script, except you removed my name, the AGPL license and even the author note for the explode function. Just wow... Not Cool.

    I'm slowly rewriting my h0tstuff script into something more manageable / extendable. Figured I would share my progress. I'm not running this on my server yet.


    Right now it is basic plugin framework and a couple example modules; Welcome Message and Motd.
    Suggestions appreciated.


    https://github.com/Clarkmania/rising-world-h0tmod


    Supports run-time hooking of events, commands, and timers. Will be adding an admin module next for enabling and disabling modules on the fly.

    I understand that just before onEnable (lua) is invoked, enabled is set to true (java) which prevents addEvent (lua) from being called again. No problem there.


    The events are added before the onEvent lua function is even invoked. It happens at mod:attach(ModManager). I could break out IntelliJ and debug the java, but I figured I would ask first.


    Removing ModManager:list() had no effect.

    This is the original "bug" report, but as it turns out I was calling addEvent with an nil function.


    While playing around with writing a "modmanager" to clean-up my nasty script, I ran into a bit-wall.


    I am implementing a manager object which other objects (mods) can attach to.
    The manager automatically calls addEvent for any event functions in the mod(s) object when it is attached.


    When I run the server, enable is flipped before addEvent's are called *and* before onEnable is called.


    Code
    [LUA]Script "h0tmod" loaded. Author: h0tw1r3 Team: ClarkMania
    [LUA][h0tmod] 01/02/15 19:35:09.096: ModManager: init mod manager (does nothing yet)
    [LUA][h0tmod] 01/02/15 19:35:09.099: Test: attach begin
    [LUA][h0tmod] 01/02/15 19:35:09.099: Test: register begin
    [LUA][h0tmod] addEvent is only allowed before "onEnable" is called.
    [LUA][h0tmod] 01/02/15 19:35:09.1: ModManager: hook failed: InventoryToChest
    [LUA][h0tmod] 01/02/15 19:35:09.101: Test: register end
    [LUA][h0tmod] 01/02/15 19:35:09.102: Test: attach end
    [LUA][h0tmod] 01/02/15 19:35:09.102: onEnable begin
    [LUA][h0tmod] 01/02/15 19:35:09.103: onEnable end


    Script as tested.


    Not sure why, but I think java LuaScript.enabled is set before lua onEnable is actually invoked.


    I've added print statements everywhere. Code seems to be processed in the correct order.


    Does LuaScript "this.script.call()" return immediately after parsing or something? I'm baffled. 8|

    The ban command works fine when running a LAN only server, but not for wan. Error is caught when trying to insert the record into the Banlist table.
    Basically the MacAddress it's trying to resolve doesn't exist for internet connections.

    Ban support was difficult to fully test by myself as I only have one copy of the RW.
    Please report any bugs on Github.

    Pushed to Github:

    • Player ban support
      Works around problem with built-in ban currently being broken (kicks but does not ban)
    • Support banning players even when they are offline
      Ban will be applied the next log in attempt. So, if they are banned for 5 minutes, the 5 minutes will start the next time they connect.
    • Close all resultsets (table locks?)
    • Change the SELECT queries behind server:findPlayerByName and server:getPlayerInformationFromDB to case insensitive (COLLATE NOCASE).
      I'm assuming player names are case-insensitive for unique purposes anyway (ie. h0tw1r3 == H0TW1R3).
      Would make player lookup from scripts much easier for the admin/user.
    • Add getOnlinePlayers to Server.
      Although this can obviously be done in lua itself, it would be convenient to do things like broadcasting messages to specific groups.

    Pushed to github:

    • /setmotd <message>
      Displays a message every hour to all connected players
    • /setwelcome <message>
      Displays a message on first spawn (player connect)
    • Date/time prefix added to most messages/chat
    • Hide /help for admin commands from non-admins

    Changed:

    • Country flags (geoip)
    • Replaced locked column to an icon after the server name
    • Last server status indicated by an Up / Down label before the IP
    • Changed out of date server (version) indicated by red row, to highlighting the version number instead.

    Going out of town today. Don't expect I'll have a chance to make more changes until next week.


    Looking good so far. :)


    Maybe you could implement a basic 'voting' system? Just an up/down to see how it'd go.


    Good idea. How about a +1 or Like?