Raised This Month: $32 Target: $400
 8% 

Trying to catch ServerCommand


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 02-10-2005 , 10:54   Trying to catch ServerCommand
Reply With Quote #1

OK I uncommented this link in my moduleconfig.h:
Code:
#define FN_ServerCommand            ServerCommand

ANd this is my code:
Code:
void ServerCommand(char *crap) {     const char *szCmd = CMD_ARGV(0);     SERVER_PRINT(szCmd);     if ( strcmp(szCmd, "debugit") == 0 )     {         char msg[512];         int pos = 0;         // Loop through all the races         for(int i = 0; i < 20; i++)         {             IRace *race = manager.GetRace(i);             if ( race != NULL )             {                 pos += sprintf(msg + pos, "Race: %s found at %i\n", race->racename, i);             }             else             {                 pos += sprintf(msg + pos, "Null race at %i\n", i);             }         }         SERVER_PRINT(msg);     }     RETURN_META(MRES_IGNORED); }

But when I type ANY command I can't catch anything, even if I try SERVER_PRINT(crap). When I type a command in the server console and hit enter it doesn't print anything. I have done this before so I'm confused as to what I'm doing wrong. Help pls.
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Da Bishop
Senior Member
Join Date: Aug 2004
Location: Chester County PA
Old 02-10-2005 , 17:48  
Reply With Quote #2

ummm perhaps

Code:
CMD_ARGV(0)

be

Code:
CMD_ARGV[0]
just thinking
__________________
Anything that is done can only be done better by urself - since life is a opinion make it the way urs feel its best

~live by it
Da Bishop is offline
Send a message via MSN to Da Bishop
Freecode
Never Fall Asleep
Join Date: Jan 2004
Old 02-10-2005 , 23:19  
Reply With Quote #3

try printing crap since its passed into the function
Code:
void ServerCommand(char *crap)
Freecode is offline
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 02-11-2005 , 04:02  
Reply With Quote #4

As I have told you on IRC, the function you are hooking is the one AMXX invokes when you run the server_cmd native. That is, external DLLs can tell the engine to send some crap to its command parser as a server command - without the need to type it into the console. Note that you would only be able to intercept it when the gamedll calls it - which is pretty unlikely. There is no generic server command hook, like ClientCommand.

AMX/AMXX does this by calling REG_SVR_COMMAND for every registered server command / client command. They register every command to a central hook (plugin_srvcmd in srvcmd.cpp), which does a similar action to the function you have posted.
__________________
hello, i am pm
PM is offline
Geesu
Veteran Member
Join Date: Mar 2004
Location: Cincinnati, OH
Old 02-11-2005 , 08:26   Re: Trying to catch ServerCommand
Reply With Quote #5

Quote:
Originally Posted by Geesu
even if I try SERVER_PRINT(crap)
Come on freecode You wouldn't think I'd try that. Yea thanks for the heads up PM.
__________________
Need war3ft help? DO NOT PM ME... Check the forums
Geesu is offline
Send a message via AIM to Geesu Send a message via MSN to Geesu
Owyn
Veteran Member
Join Date: Nov 2007
Old 09-06-2009 , 07:33   Re: Trying to catch ServerCommand
Reply With Quote #6

so did you guys succeed hooking server commands? ^^ i need it
__________________
☜ Free Mozy ☂backup\҉sync user
Quote:
Американский форум - Задаёшь вопрос, потом тебе отвечают.
Израильский форум - Задаёшь вопрос, потом тебе задают вопрос.
Русский форум - Задаёшь вопрос, потом тебе долго рассказывают, какой ты мудак.
Owyn is offline
Send a message via ICQ to Owyn
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-06-2009 , 14:49   Re: Trying to catch ServerCommand
Reply With Quote #7

Quote:
Originally Posted by PM View Post
As I have told you on IRC, the function you are hooking is the one AMXX invokes when you run the server_cmd native. That is, external DLLs can tell the engine to send some crap to its command parser as a server command - without the need to type it into the console. Note that you would only be able to intercept it when the gamedll calls it - which is pretty unlikely. There is no generic server command hook, like ClientCommand.

AMX/AMXX does this by calling REG_SVR_COMMAND for every registered server command / client command. They register every command to a central hook (plugin_srvcmd in srvcmd.cpp), which does a similar action to the function you have posted.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:18.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode