PDA

View Full Version : Cant catch commands...


devicenull
12-04-2004, 23:19
class myadmin : public IServerPluginCallbacks, public IGameEventListener {
public:
myadmin();
~myadmin();
virtual bool Load( CreateInterfaceFn interfaceFactory, CreateInterfaceFn gameServerFactory );
virtual PLUGIN_RESULT ClientCommand( edict_t *pEntity );
virtual void ClientPutInServer( edict_t *pEntity, char const *playername );
alevels lookUpAccess(char const *playerID);
private:

};

PLUGIN_RESULT myadmin::ClientCommand(edict_t *pEntity)
{
const char *pcmd = eng->Cmd_Argv(0);

Msg("myadmin::ClientCommand() got command %s\n",pcmd);


if ( !pEntity || pEntity->IsFree() )
{
return PLUGIN_CONTINUE;
}

if ( FStrEq( pcmd, "n_listadmins" ) )
{
if (g_accUsed == 0) {
eng->ClientPrintf(pEntity,"No admins loaded");
}
for (int i=0;i<g_accUsed;i++) {
char temp[512];
sprintf(temp,"%s /t %s",acc[i].steamid,acc[i].access);
eng->ClientPrintf(pEntity,temp);
}
return PLUGIN_STOP;
}
return PLUGIN_CONTINUE;
}

I have that stuff. But it wont catch an of the commands, I don't even get a myadmin::ClientCommand() got command %s\n

BAILOPAN
12-04-2004, 23:21
I think Alfred mentioned in hlcoders that this was not working right.

I could be wrong.

You might have to use the CON_COMMAND() interface to do it or register a cvar as a client variable... he talked about it.

devicenull
12-04-2004, 23:22
Ah, ok.
I'll try that.

The weird thing is, I see the event firing in the base empty plugin. I can't get it to fire in mine though :/

PM
12-04-2004, 23:24
Probably because the arg isn't passed (at all?) correctly into the function?

:gyar:

devicenull
12-04-2004, 23:52
Nm. Stupid mistake, forgot:

EXPOSE_SINGLE_INTERFACE_GLOBALVAR(myadmin, IServerPluginCallbacks, INTERFACEVERSION_ISERVERPLUGINCALLBACKS, g_Admin);

BeetleFart
12-05-2004, 02:02
Nm. Stupid mistake, forgot:

EXPOSE_SINGLE_INTERFACE_GLOBALVAR(myadmin, IServerPluginCallbacks, INTERFACEVERSION_ISERVERPLUGINCALLBACKS, g_Admin);

whats the definition for g_Admin?

BAILOPAN
12-05-2004, 02:18
g_Admin would be his global instantiation of myadmin

BeetleFart
12-05-2004, 02:21
g_Admin would be his global instantiation of myadmin

Yeah so I figured, for now I just used the g_EmtpyServerPlugin thats already defined...
Ill have to comeup with an admin class to test it out.
Thanks

devicenull
12-05-2004, 11:23
g_Admin would be his global instantiation of myadmin

Yeah so I figured, for now I just used the g_EmtpyServerPlugin thats already defined...
Ill have to comeup with an admin class to test it out.
Thanks

If your just modifying the empty plugin, you don't need to add that line, I just made a new class because it was easier then replacing cemptyserverplugin everywhere, imo

Geesu
12-05-2004, 11:26
Yea I started to create my own project and couldn't get it to work so I used the empty plugin and renamed everything.

Device did you have to add all the header files that were in the emptyplugin to your new project?

devicenull
12-05-2004, 11:27
Its still in the project that was there, so yes, they are all still there.


Wow, I just realized I posted this to the wrong forum :P