Author |
Message |
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: 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
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. _________________ (Insert a bunch of dead links here) |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: 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 |
|
Back to top |
|
|
Dr Brain Flip-flopping like a wind surfer
Age:38 Gender: Joined: Dec 01 2002 Posts: 3502 Location: Hyperspace Offline
|
Posted: 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. _________________ Hyperspace Owner
Smong> so long as 99% deaths feel lame it will always be hyperspace to me |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: 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.
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();
}
}
|
Last edited by JoWie on Sun Jan 30, 2011 12:31 pm, edited 3 times in total |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: 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?? |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Tue Jan 18, 2011 10:45 am Post subject: |
|
|
|
|
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 |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: 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.) |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: 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? |
|
Back to top |
|
|
JoWie Server Help Squatter
Gender: Joined: Feb 25 2004 Posts: 215 Offline
|
Posted: 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. |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: 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 :/ |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: Tue Jan 18, 2011 6:21 pm Post subject: |
|
|
|
|
capman
cmd_blah
privcmd_bleh |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: 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. |
|
Back to top |
|
|
Cheese Wow Cheese is so helpful!
Joined: Mar 18 2007 Posts: 1017 Offline
|
Posted: 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 |
|
Back to top |
|
|
Samapico No, these DO NOT look like penises, ok?
Joined: May 08 2003 Posts: 1252 Offline
|
Posted: Sun Jan 30, 2011 2:07 pm Post subject: |
|
|
|
|
With Jowie's wisdom, I got this cmdlist thing to work, see here for attachments |
|
Back to top |
|
|
|