AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   client print_console (https://forums.alliedmods.net/showthread.php?t=144283)

J4CK 12-01-2010 14:00

client print_console
 
I want when player join my server, all players can see in console:

[user connect] Name from Country

why dont works ?
PHP Code:


#include <amxmodx>
#include <amxmisc>
#include <geoip>

public client_putinserver(id) {

        static 
putin_name[32]
        
get_user_name(id,putin_name,32)

        static 
ip[17],country[46]
        
get_user_ip(id,ip,16,1)
    
        
geoip_country(ip,country,45)
        
        if(
equal(country,"error"))
            
client_print(0print_console"[user connect] %s from [%s]",putin_name"unknown")
        else
            
client_print(0print_console"[user connect] %s from [%s]",putin_name,country)



Emp` 12-01-2010 15:09

Re: client print_console
 
You might have to loop through all the players and send it individually.

I know that with console_print, sending 0 sends it to the server console.

I don't know if client_print with print_console and using 0 as the id, if it actually sends it to all players or just the console.

Since it doesn't seem to be working, you might want to just loop through all players.

Exolent[jNr] 12-01-2010 16:53

Re: client print_console
 
client_print() will use 0 for all players regardless of where it is printed.

Code:

static cell AMX_NATIVE_CALL client_print(AMX *amx, cell *params) /* 3 param */
{
        int len = 0;
        char *msg;
       
        // if id = 0
        if (params[1] == 0)
        {
                // print to all players

                for (int i = 1; i <= gpGlobals->maxClients; ++i)
                {
                        CPlayer *pPlayer = GET_PLAYER_POINTER_I(i);
                       
                        if (pPlayer->ingame)
                        {
                                g_langMngr.SetDefLang(i);
                                msg = format_amxstring(amx, params, 3, len);
                                msg[len++] = '\n';
                                msg[len] = 0;
                                UTIL_ClientPrint(pPlayer->pEdict, params[2], msg);
                        }
                }
        } else {// id is not 0
                // print to id

                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);
                g_langMngr.SetDefLang(index);
               
                msg = format_amxstring(amx, params, 3, len);
                msg[len++] = '\n';
                msg[len] = 0;
               
                if (pPlayer->ingame)
                        UTIL_ClientPrint(pPlayer->pEdict, params[2], msg);                //format_amxstring(amx, params, 3, len));
        }
       
        return len;
}



All times are GMT -4. The time now is 11:16.

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