Raised This Month: $ Target: $400
 0% 

Shortcut Say Commands [10/8/2011]


Post New Thread Reply   
 
Thread Tools Display Modes
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-08-2011 , 05:18   Re: Shortcut Say Commands [6/11/2011]
Reply With Quote #11

Actually, LANG_PLAYER will work too. To explain more :

AMXX does that basically to get a language :
  • Checking amx_client_languages first and if set to 0, language will be from server_language cvar.
  • Otherwise getting the value from the client's cvar lang.

Here the code of client_print :
PHP Code:
static cell AMX_NATIVE_CALL client_print(AMX *amxcell *params/* 3 param */
{
    
int len 0;
    
char *msg;
    
    if (
params[1] == 0)
    {
        for (
int i 1<= gpGlobals->maxClients; ++i)
        {
            
CPlayer *pPlayer GET_PLAYER_POINTER_I(i);
            
            if (
pPlayer->ingame)
            {
                
g_langMngr.SetDefLang(i);
                
msg format_amxstring(amxparams3len);
                
msg[len++] = '\n';
                
msg[len] = 0;
                
UTIL_ClientPrint(pPlayer->pEdictparams[2], msg);
            }
        }
    } 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);
        
g_langMngr.SetDefLang(index);
        
        
msg format_amxstring(amxparams3len);
        
msg[len++] = '\n';
        
msg[len] = 0;
        
        if (
pPlayer->ingame)
            
UTIL_ClientPrint(pPlayer->pEdictparams[2], msg);        //format_amxstring(amx, params, 3, len));
    
}
    
    return 
len;

Each time, before formatting the string, the current player's id, whatever from the first param or the loop, is saved in a global var. (SetDefLang)

We assume amx_client_languages is set on 1 :
  • When you pass LANG_SERVER, language is retrieved from server_language cvar.
  • When you pass LANG_PLAYER, language is retrieved from lang client's cvar using the player's index saved in the global var.
  • When you pass the player's index, language is retrieved from lang client's cvar using this index.

LANG_PLAYER is meant to be used when you can't pass a player's index. But since the current player's index is always saved before formatting the string, LANG_PLAYER will work even if you send client_print to a specific player, but that's not appropriate to do that.

Hope you understand better.

-------

About your plugin, I don't have much reviewed, but If there is known bug, I would prefer you fix it first. But for sure such plugin is meant to be approved later.
__________________

Last edited by Arkshine; 10-08-2011 at 08:55.
Arkshine is offline
enjoi.
Veteran Member
Join Date: Mar 2011
Old 10-08-2011 , 08:48   Re: Shortcut Say Commands [6/11/2011]
Reply With Quote #12

Cool plugi. Gonna try it out
__________________
Block Maker v6.0 []
Point Slay v3.0 []
Contact [ PM ]
enjoi. is offline
Tirant
Veteran Member
Join Date: Jul 2008
Location: Los Angeles, California
Old 10-08-2011 , 16:04   Re: Shortcut Say Commands [6/11/2011]
Reply With Quote #13

Quote:
Originally Posted by Arkshine View Post
...
Okay, I understand, thanks. I've also updated the source code with those changes.
__________________

PM me if you're interested in buying the Credits addition for Base Builder
Battlefield Rebirth [66% done]
Call of Duty: MW2 [100% done]
Base Builder [100% done]

Last edited by Tirant; 10-08-2011 at 16:14.
Tirant is offline
Sylwester
Veteran Member
Join Date: Oct 2006
Location: Poland
Old 10-08-2011 , 16:40   Re: Shortcut Say Commands [10/8/2011]
Reply With Quote #14

Did you see this plugin? :
http://forums.alliedmods.net/showthr...39#post1160139
__________________
Impossible is Nothing
Sylwester is offline
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 11:04.


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