pfnAddServerCommand
Okay, so i have been diggin into this piece of junk ;) I have this code, and it does not work in CS 1.5 listen server or dedicated server. I issue the command:
rbcm rb_addbot which should add a bot ;) ps. do not mind the CVAR_REGISTER function.... ;) Code:
// SERVER Command: RealBot |
Re: pfnAddServerCommand
Do NOT use your own (hooked) versions of pfnCmd_Argv and pfnCmd_Argc, instead use the CMD_ARGV and CMD_ARGC macros to the direct engine functions... also notice that if your sv_bot CVAR is called "rbcm", registering a rbcm server command may not work...
Other than that what you have here should work :) |
Re: pfnAddServerCommand
I built a general purpose server/client command registration and dispatch system for the mean bot/admin mod, there's a few hundred lines of code which is too much to post in here, but here's some bits which show how I get agruments for custom server and client commands. Each command that is executed, is passed an array of strings "vtxArgList" (in my case using the standard C++ string class, not the C style strings). The nice part about this system is ALL my custom commands use the exact same argument header and dispatch function. In otherwords, I only register one standard dispatch function associated with each command name. When a server command is executed, it calls the dispatch function, the dispatch function then looks up the command in an array of registered commands (which include security settings and other nice things). When a match is found, it gets the arguments and passes it to the custom command function as a standard array of strings. From there, the custom command function simply does whatever it is supposed to do using as its arguments the array of strings. It's VERY simple to use, but was a bit complicated to figure out at first. I've been using it for so long now I've almost forgottem how it works!
Anyway here's the code that gets the arguments, hope you can read the non standard naming convention I've been using :) Code:
int finGetCmdLineArgCount( void ) |
Re: pfnAddServerCommand
Code:
const char *pcmd = Cmd_Argv(1); Hope this helps P.S. 0th argument is the command name, like rbcm In your case it'll be: (lets pretend abcde is his name, and 1 is his team) rbcm rb_addbot abcde 1 Code:
*pcmd = "rb_addbot"; |
Re: pfnAddServerCommand
nonono, if you're using your own registered server command, DON'T use your own Cmd_Argv(), Cmd_Argc() and Cmd_Args(). Use the MACROS which call the direct engine functions, CMD_ARGV(), CMD_ARGC() and CMD_ARGS(). If you don't, your code will work, but NOT if a bot is issuing a Client Command at the same time. You will have unpredictable results if this happens, and it will.
|
Re: pfnAddServerCommand
Fierce recon is correct about the pcmd you want being the first argument and not the 0th.
If using your own CMD_ARG.. functions they will work ok as long as you dont use metamod since they call the engine function anyway. If using metamod though you need to call the engine cmd_args functions as your versions of cmd_arg under metamod will probably just do nothing as they RETURN_META. |
All times are GMT +2. The time now is 11:53. |
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.