added helper a core translation helper to the translator

regadmincmd is now officially done and tested, as are overrides
printtoplayers now prints to the server on id==0 as a convenience
fixed a crash bug in the admin system
fixed up console.inc a bit

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40526
This commit is contained in:
David Anderson
2007-02-17 19:03:18 +00:00
parent 3be7988cd1
commit ae5dfd0966
8 changed files with 124 additions and 27 deletions
+21 -11
View File
@@ -436,21 +436,25 @@ static cell_t sm_PrintToServer(IPluginContext *pCtx, const cell_t *params)
static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
{
int index = params[1];
if ((index < 1) || (index > g_Players.GetMaxClients()))
if ((index < 0) || (index > g_Players.GetMaxClients()))
{
return pCtx->ThrowNativeError("Invalid client index %d", index);
}
CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
if (!pPlayer->IsInGame())
CPlayer *pPlayer = NULL;
if (index != 0)
{
return pCtx->ThrowNativeError("Client %d is not in game", index);
}
/* Silent fail on bots, engine will crash */
if (pPlayer->IsFakeClient())
{
return 0;
pPlayer = g_Players.GetPlayerByIndex(index);
if (!pPlayer->IsInGame())
{
return pCtx->ThrowNativeError("Client %d is not in game", index);
}
/* Silent fail on bots, engine will crash */
if (pPlayer->IsFakeClient())
{
return 0;
}
}
char buffer[1024];
@@ -463,7 +467,12 @@ static cell_t sm_PrintToConsole(IPluginContext *pCtx, const cell_t *params)
buffer[res++] = '\n';
buffer[res] = '\0';
engine->ClientPrintf(pPlayer->GetEdict(), buffer);
if (index != 0)
{
engine->ClientPrintf(pPlayer->GetEdict(), buffer);
} else {
META_CONPRINT(buffer);
}
return 1;
}
@@ -495,5 +504,6 @@ REGISTER_NATIVES(consoleNatives)
{"GetCmdArg", sm_GetCmdArg},
{"PrintToServer", sm_PrintToServer},
{"PrintToConsole", sm_PrintToConsole},
{"RegAdminCmd", sm_RegAdminCmd},
{NULL, NULL}
};