Raised This Month: $ Target: $400
 0% 

client_cmd() vs. console_cmd()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 03-16-2006 , 19:27  
Reply With Quote #1

Not true. If you look at the CVS you can see that it uses SERVER_COMMAND() when the index is less than 1

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;
}
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;
}
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
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 16:42.


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