Raised This Month: $ Target: $400
 0% 

client_cmd vs console_cmd


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
vamppa
Senior Member
Join Date: Apr 2010
Location: The Netherlands
Old 05-26-2014 , 07:40   client_cmd vs console_cmd
Reply With Quote #1

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 *amxcell *params/* 2 param */
{
    
int index params[1];
    
g_langMngr.SetDefLang(index);
    
int len;
    
charcmd format_amxstring(amxparams2len);
    
    
cmd[len++] = '\n';
    
cmd[len] = 0;

    if (
index || index gpGlobals->maxClients)
    {
        
SERVER_COMMAND(cmd);
    } else {
        
CPlayerpPlayer 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 *amxcell *params/* 2 param */
{
    
int len;
    
charcmd format_amxstring(amxparams2len);
    
cmd[len++] = '\n';
    
cmd[len] = 0;

    if (
params[1] == 0)
    {
        for (
int i 1<= gpGlobals->maxClients; ++i)
        {
            
CPlayerpPlayer 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 || index gpGlobals->maxClients)
        {
            
LogError(amxAMX_ERR_NATIVE"Invalid player id %d"index);
            return 
0;
        }
        
        
CPlayerpPlayer GET_PLAYER_POINTER_I(index);
        
        if (!
pPlayer->bot && pPlayer->initialized /*&& pPlayer->ingame*/)
            
CLIENT_COMMAND(pPlayer->pEdict"%s"cmd);
    }
    
    return 
len;

vamppa is offline
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 05-26-2014 , 09:52   Re: client_cmd vs console_cmd
Reply With Quote #2

The only difference between them is that console_cmd sends it to the server if Index is 0, where client_cmd sends it to all connected users
__________________
ProjectYami Laboratories

I do not browse the forums regularly anymore. If you need me for anything (asking questions or anything else), then PM me (be descriptive in your PM, message containing only a link to a thread will be ignored).
YamiKaitou is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 05-26-2014 , 14:34   Re: client_cmd vs console_cmd
Reply With Quote #3

Also, IIRC, commands registered with register_clcmd() will not be hooked if they are used in the server's console. So, you use register_clcmd() when you have things that require that it come from a client's actual game (things like menus and other things that are actually displayed on the HUD.
__________________
fysiks is offline
Reply


Thread Tools
Display Modes

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 09:40.


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