When the situation fits to use console_cmd am I right in saying it is a little more efficient to use apposed to client_cmd?
PHP Code:
static cell AMX_NATIVE_CALL console_cmd(AMX *amx, cell *params) /* 2 param */
{
int index = params[1];
g_langMngr.SetDefLang(index);
int len;
char* cmd = format_amxstring(amx, params, 2, len);
cmd[len++] = '\n';
cmd[len] = 0;
if (index < 1 || index > gpGlobals->maxClients)
{
SERVER_COMMAND(cmd);
} else {
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->bot && pPlayer->initialized)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
}
return len;
}
PHP Code:
static cell AMX_NATIVE_CALL client_cmd(AMX *amx, cell *params) /* 2 param */
{
int len;
char* cmd = format_amxstring(amx, params, 2, len);
cmd[len++] = '\n';
cmd[len] = 0;
if (params[1] == 0)
{
for (int i = 1; i <= gpGlobals->maxClients; ++i)
{
CPlayer* pPlayer = GET_PLAYER_POINTER_I(i);
if (!pPlayer->bot && pPlayer->initialized /*&& pPlayer->ingame*/)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
}
} else {
int index = params[1];
if (index < 1 || index > gpGlobals->maxClients)
{
LogError(amx, AMX_ERR_NATIVE, "Invalid player id %d", index);
return 0;
}
CPlayer* pPlayer = GET_PLAYER_POINTER_I(index);
if (!pPlayer->bot && pPlayer->initialized /*&& pPlayer->ingame*/)
CLIENT_COMMAND(pPlayer->pEdict, "%s", cmd);
}
return len;
}