Server Help

ASSS Questions - Generic event handler?

Samapico - Mon Jan 17, 2011 10:35 pm
Post subject: Generic event handler?
Did anyone ever make some kind of module that handles the sequence of an event being hosted? I'm talking about something generic... Most events require x to y players, a fixed number of teams, etc. And the whole 'player x lagged out, wait y time, get substitute, cancel game if everyone leaves' part.
I'll need something like this for an event I have, and probably many more after, so I'd do something that can be used in almost any case, using a set of rules and whatnot. If someone else already did it, or if someone started such a module, I'd like to know tongue.gif
Also, if you have suggestions for the approach to accomplish this, you're welcome.




Also, completely unrelated bonus question:
Initrd.gz wrote:
You could modify cmdman to have a function that gets the list of commands, but perhaps it could be a security breach (not to mention a pain to use on existing servers), and use their helptext.
^ This was posted almost 2 years ago here, no one really replied to it... but would this be possible? Is it done already? Did someone do it somewhere? Listing commands like on a bot would be nice to have.
Cheese - Tue Jan 18, 2011 1:48 am
Post subject:
http://forums.minegoboom.com/viewtopic.php?p=79745#79745
Samapico - Tue Jan 18, 2011 7:49 am
Post subject:
I gave that exact link in my post.... "it doesn't look like it's possible" doesn't answer my question much. ?commands are registered, and has to be a way to get the list of them, even if it involves adding a new interface function to cmdman
Dr Brain - Tue Jan 18, 2011 8:29 am
Post subject:
D1st0rt made this: https://bitbucket.org/d1st0rt/asss_hostedgame

I'm not very familiar with it, so I'm not sure if it'll do what you need.
JoWie - Tue Jan 18, 2011 10:03 am
Post subject:
Samapico wrote:
I gave that exact link in my post.... "it doesn't look like it's possible" doesn't answer my question much. ?commands are registered, and has to be a way to get the list of them, even if it involves adding a new interface function to cmdman


It's possible to do this without modifying cmdman / asss core.

Code: Show/Hide

static Icmdman *cmd;

static void (*AddCommandOriginal)(const char *cmdname, CommandFunc func, Arena *arena, helptext_t ht);
static void (*RemoveCommandOriginal)(const char *cmdname, CommandFunc func, Arena *arena);

static void AddCommandInt(const char *cmdname, CommandFunc func, Arena *arena, helptext_t ht)
{
        // ...
        AddCommandOriginal(cmdname, func, arena, ht);
}
       
static void RemoveCommandInt(const char *cmdname, CommandFunc func, Arena *arena)
{
        // ...
        RemoveCommandOriginal(cmdnam, func, arena);
}

static void ReleaseInterfaces()
{
        mm->ReleaseInterface(cmd);
}

EXPORT int MM_cmdlist(int action, Imodman *mm_, Arena *arena)
{
        if (action == MM_LOAD)
        {
                mm = mm_;
                cmd = mm->GetInterface(I_CMDMAN, ALLARENAS);
               
                if (!cmd)
                {
                        ReleaseInterfaces();
                        return MM_FAIL;
                }
               
                AddCommandOriginal = cmd->AddCommand;
                RemoveCommandOriginal = cmd->RemoveCommand;
                cmd->AddCommand = AddCommandInt;
                cmd->RemoveCommand = RemoveCommandInt;
        }
        else if (action == MM_UNLOAD)
        {
                if (cmd->AddCommand != AddCommandInt || cmd->RemoveCommand != RemoveCommandInt)
                        return MM_FAIL;
       
                cmd->AddCommand = AddCommandOriginal;
                cmd->RemoveCommand = RemoveCommandOriginal;

                ReleaseInterfaces();
        }
}

Samapico - Tue Jan 18, 2011 10:44 am
Post subject:
If I understand what you're doing there, you'd need to add:
cmd->AddCommand = AddCommandOriginal;
cmd->RemoveCommand = RemoveCommandOriginal;

just before releasing the cmd interface

?

Also, you'd need to load that thing right after cmdman... but then, you wouldn't be able to use this to list the core commands? Unless it's another module that adds commands to communicate with the core module??
Samapico - Tue Jan 18, 2011 10:45 am
Post subject:
Dr Brain wrote:
D1st0rt made this: https://bitbucket.org/d1st0rt/asss_hostedgame

I'm not very familiar with it, so I'm not sure if it'll do what you need.

Ahh... I think that's what I was looking for.... Pretty sure I had heard of something like this before. I'll see what it can do, thanks icon_smile.gif
JoWie - Tue Jan 18, 2011 3:29 pm
Post subject:
Samapico wrote:
If I understand what you're doing there, you'd need to add:
cmd->AddCommand = AddCommandOriginal;
cmd->RemoveCommand = RemoveCommandOriginal;

just before releasing the cmd interface

?

Also, you'd need to load that thing right after cmdman... but then, you wouldn't be able to use this to list the core commands? Unless it's another module that adds commands to communicate with the core module??


I accidently forgot those.

You need to load it right after cmdman (later is fine to, but you would miss out on commands). You would get every command that exists even the core ones. (cmdman does not register any command of its own.)
Samapico - Tue Jan 18, 2011 4:22 pm
Post subject:
Can 2 modules add the same command?

If this cmdlist module was to add a ?man or ?help command, so that if someone types ?man or ?help with no arguments, a list of commands is shown, would it mess up the "original" man/help command? Or would both modules receive the function call?
JoWie - Tue Jan 18, 2011 5:14 pm
Post subject:
If a command is added multiple times, cmdman fires all of the functions (even if the same command, function pair is added multiple times).

You could register a command in MM_POSTLOAD for ?man or ?help and simply add one line if no arguments are used that gives the arena message "Type ?cmdlist for a list of commands"


Oh and if you use that code snippit, remember that you would need to use mutex locks.
Samapico - Tue Jan 18, 2011 5:35 pm
Post subject:
And is there a way to know if a player has access to a particular command? I'm guessing that's handled by another module :/
Cheese - Tue Jan 18, 2011 6:21 pm
Post subject:
capman

cmd_blah
privcmd_bleh
Samapico - Tue Jan 18, 2011 6:37 pm
Post subject:
oooh, CAPability? Was wondering what the hell 'cap' was for... cool.

There will be a nice cmdlist module soon...

"soon" being relative.
Cheese - Tue Jan 18, 2011 10:13 pm
Post subject:
its been on my to do list, but i havnt gotten around to it

but its very important you check they have permisson to use the command before you tell them that it exists
Samapico - Sun Jan 30, 2011 2:07 pm
Post subject:
With Jowie's wisdom, I got this cmdlist thing to work, see here for attachments
All times are -5 GMT
View topic
Powered by phpBB 2.0 .0.11 © 2001 phpBB Group