AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   player country (geoip) (https://forums.alliedmods.net/showthread.php?t=312815)

CrazY. 12-16-2018 18:00

player country (geoip)
 
Hello, I'm trying to get player's country with geoip but it's not working, it's always returning 0. Besides, I'm using amxx 1.9.0 (latest)

Code:
public client_putinserver(this) {     if (is_user_bot(this))         return;     if (is_user_hltv(this))         return;     new szName[32], szCountry[32], szIp[32];     get_user_name(this, szName, charsmax(szName));     get_user_ip(this, szIp, charsmax(szIp), 1);     if (geoip_country_ex(szIp, szCountry, charsmax(szCountry)) == 0)         copy(szCountry, charsmax(szCountry), "N/A");     client_print(0, print_chat, "Player %s has connected (%s).", szName, szCountry); }

SomewhereLost 12-16-2018 20:06

Re: player country (geoip)
 
Try this

PHP Code:

public client_putinserver(this)
{
    if (
is_user_bot(this))
        return;

    if (
is_user_hltv(this))
        return;

new 
szName[32], szCountry[46], szIp[17];
   
    
get_user_name(thisszNamecharsmax(szName));
    
get_user_ip(thisszIpcharsmax(szIp));
    
geoip_country(szIpszCountrycharsmax(szCountry));
   
    if(!
strlen(szCountry)) szCountry "N/A";
    
    
client_print(0print_chat"Player %s has connected (%s)."szNameszCountry);



CrazY. 12-17-2018 07:47

Re: player country (geoip)
 
geoip_country it's deprecated in amxx 1.9.0.

Natsheh 12-17-2018 09:28

Re: player country (geoip)
 
Show meta list.

And server operating system.

klippy 12-17-2018 10:26

Re: player country (geoip)
 
https://wiki.alliedmods.net/AMX_Mod_...se_Notes#GeoIP

CrazY. 12-19-2018 17:59

Re: player country (geoip)
 
Apparently it is working now.

LondoN 12-20-2018 05:11

Re: player country (geoip)
 
public client_putinserver ( Player )
{
if ( is_user_bot ( Player ) || is_user_hltv ( Player ) )
return;

new Name [ 32 ], Country [ 32 ], IP [ 16 ];
get_user_name ( id, Name, charsmax ( Name ) );
get_user_ip ( id, IP, charsmax ( IP ), 1 );
geoip_country ( IP, Country, charsmax ( Country ) );

client_print ( 0, print_chat, "Player %s joined from %s", !strlen ( Country ) ? "N/A" : Country );
}

cam simplify the strlen.

eat1k 12-22-2018 14:57

Re: player country (geoip)
 
P.S. You may to not use get_user_name() when you have "%n" (AMXX >= 1.8.3).
Code:
client_print_color(0, print_team_default, "^1Name: ^4%n", id);

CrazY. 12-22-2018 15:15

Re: player country (geoip)
 
If I didn't misunderstand, this will output player name. Cool, I didn't know, thank you.


All times are GMT -4. The time now is 07:30.

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