Raised This Month: $ Target: $400
 0% 

Server Console


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Emil
Junior Member
Join Date: May 2010
Location: Skövde, Sweden
Old 05-22-2010 , 16:19   Server Console
Reply With Quote #1

Q1: How can i get the server console commands?

I get the client commands via
Code:
void ClientCommand( edict_t *pEntity )
.

Q2: Does EdictIndex change from Client Connect -> Client Disconnect?
Emil is offline
Send a message via Skype™ to Emil
API
Veteran Member
Join Date: May 2006
Old 05-22-2010 , 16:45   Re: Server Console
Reply With Quote #2

A1: If you are using MM:S, which I assume you are, you can use the factory to get the IVEngineServer instance. Check the header for a list of functions.

A2: A client's index will remain constant during their session (map change is a new session). Index's are reused, and range from 1 to MAXCLIENTS (max is 64). User ID's are much different. They are not reused (unless the server is restarted). User IDs are an excellent way to verify a client's validness. For example:
Timer(5.0, Function, UserID);

In Function, you can use:
Code:
int index = g_pEngine->IndexOfUserId(UserID);
if(index<=0)
{
  // client must have left
}
Good luck.
__________________
API is offline
Send a message via AIM to API
Emil
Junior Member
Join Date: May 2010
Location: Skövde, Sweden
Old 07-29-2010 , 16:19   Re: Server Console
Reply With Quote #3

With this i get the server issued commands, but not the ones from the console.
for instance i get "changelevel cs_assault" when the server starts.
But if i write "changelevel cs_assault" in the server console i dont get that but the first exec in the config :/


Code:
SH_DECL_HOOK1_void(IVEngineServer, ServerCommand, SH_NOATTRIB, 0, const char *);

bool SupportersPlugin::Load(PluginId id, ISmmAPI *ismm, char *error, size_t maxlen, bool late)
{
GET_V_IFACE_CURRENT(GetEngineFactory, m_Engine, IVEngineServer, INTERFACEVERSION_VENGINESERVER);
SH_ADD_HOOK_MEMFUNC(IVEngineServer, ServerCommand, m_Engine, this, &SupportersPlugin::ServerCommand, false);
} bool SupportersPlugin::Unload(char *error, size_t maxlen) {
SH_REMOVE_HOOK_MEMFUNC(IVEngineServer, ServerCommand, m_Engine, this, &SupportersPlugin::ServerCommand, false);
} void SupportersPlugin::ServerCommand(const char* cmdStr) {
//Do something with cmdStr
}

Last edited by Emil; 07-29-2010 at 16:29.
Emil is offline
Send a message via Skype™ to Emil
Chrisber
AlliedModders Donor
Join Date: Jul 2007
Location: localhost
Old 07-29-2010 , 17:49   Re: Server Console
Reply With Quote #4

Try to find the ConCommand instance of the command and hook the Dispatch function.

Code:
ConCommand *pCmd = gCvar->FindCommand("changelevel");
//hook pCmd->Dispatch
Chris
Chrisber 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 06:12.


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