AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [HELP] use geoip to display city (https://forums.alliedmods.net/showthread.php?t=276267)

arvEL. 12-18-2015 12:38

[HELP] use geoip to display city
 
hi guys, i have this codes:

PHP Code:

#include <amxmodx>
#include <geoip>
#include <colorchat>
 
public plugin_init()
{
register_plugin("Join Country","1.0","<VeCo>")
}

public 
client_putinserver(id)
{
static 
sz_name[32]
get_user_name(id,sz_name,charsmax(sz_name))
 
static 
sz_ip[16],sz_country[20]
get_user_ip(id,sz_ip,charsmax(sz_ip),1)
geoip_country(sz_ip,sz_country,charsmax(sz_country))
ColorChat(0,GREY,"^1Player^4 %s^1 from^3 %s^1 has joined the game!",sz_name,sz_country)


here just display the country, i want it to display country and city
example:

Player [name] from [country / city] has joined the game!

wickedd 12-18-2015 13:44

Re: [HELP] use geoip to display city
 
geoip_city()

arvEL. 12-18-2015 14:11

Re: [HELP] use geoip to display city
 
Quote:

Originally Posted by wickedd (Post 2373693)
geoip_city()

when i add it the sv it crashed

addons_zz 12-18-2015 14:33

Re: [HELP] use geoip to display city
 
Quote:

Originally Posted by arvEL. (Post 2373703)
when i add it the sv it crashed

It is not crashing mime. What you are using? (meta list, geoip version, version)

Code:

meta list
Currently loaded plugins:
      description      stat pend  file              vers      src  load  unlod
 [ 1] AMX Mod X        RUN  -    amxmodx_mm.dll    v1.8.2    ini  Start ANY
 [ 2] POD-Bot mm      RUN  -    podbot_mm.dll    vV3B22    ini  Chlvl ANY
 [ 3] MySQL            RUN  -    mysql_amxx.dll    v1.8.2    pl1  ANY  ANY
 [ 4] SQLite          RUN  -    sqlite_amxx.dll  v1.8.2    pl1  ANY  ANY
 [ 5] CStrike          RUN  -    cstrike_amxx.dll  v1.8.2    pl1  ANY  ANY
 [ 6] CSX              RUN  -    csx_amxx.dll      v1.8.2    pl1  ANY  ANY
 [ 7] GeoIP            RUN  -    geoip_amxx.dll    v1.2.0-m  pl1  ANY  ANY
 [ 8] Fun              RUN  -    fun_amxx.dll      v1.8.2    pl1  ANY  ANY
 [ 9] Engine          RUN  -    engine_amxx.dll  v1.8.2    pl1  ANY  ANY
 [10] FakeMeta        RUN  -    fakemeta_amxx.dl  v1.8.2    pl1  ANY  ANY
 [11] Ham Sandwich    RUN  -    hamsandwich_amxx  v1.8.2    pl1  ANY  ANY
 [12] Orpheu          RUN  -    orpheu_amxx.dll  v2.6.3    pl1  ANY  ANY
12 plugins, 12 running

geoip version
  Database metadata
    Node count:    3179282
    Record size:  28 bits
    IP version:    IPv6
    Binary format: 2.0
    Build epoch:  1436355742 (2015-07-08 11:42:22 UTC)
    Type:          GeoLite2-City
    Languages:    de en es fr ja pt-BR ru zh-CN
    Description:
      en:  GeoLite2 City database

version
Protocol version 48
Exe version 1.0.0.3 (czero)
Exe build: 13:13:29 Aug 29 2013 (6153)

Code:
#include <amxmodx> #include <geoip> #include <colorchat>   public plugin_init() {     register_plugin("Join Country","1.0","<VeCo>") } public client_putinserver(id) {     static sz_name[32]     get_user_name(id,sz_name,charsmax(sz_name))     static sz_ip[32],     sz_city[32],     sz_country[32]     get_user_ip(id,sz_ip,charsmax(sz_ip),1)     geoip_country(sz_ip,sz_country,charsmax(sz_country))     geoip_city(sz_ip,sz_city,charsmax(sz_city))     ColorChat(0,GREY,"^1Player^4 %s^1 from^3 %s/%s^1 has joined the game!",sz_name,sz_country, sz_city) }

arvEL. 12-18-2015 15:24

Re: [HELP] use geoip to display city
 
Quote:

Originally Posted by addons_zz (Post 2373712)
It is not crashing mime. What you are using? (meta list, geoip version, version)

Code:

meta list
Currently loaded plugins:
      description      stat pend  file              vers      src  load  unlod
 [ 1] AMX Mod X        RUN  -    amxmodx_mm.dll    v1.8.2    ini  Start ANY
 [ 2] POD-Bot mm      RUN  -    podbot_mm.dll    vV3B22    ini  Chlvl ANY
 [ 3] MySQL            RUN  -    mysql_amxx.dll    v1.8.2    pl1  ANY  ANY
 [ 4] SQLite          RUN  -    sqlite_amxx.dll  v1.8.2    pl1  ANY  ANY
 [ 5] CStrike          RUN  -    cstrike_amxx.dll  v1.8.2    pl1  ANY  ANY
 [ 6] CSX              RUN  -    csx_amxx.dll      v1.8.2    pl1  ANY  ANY
 [ 7] GeoIP            RUN  -    geoip_amxx.dll    v1.2.0-m  pl1  ANY  ANY
 [ 8] Fun              RUN  -    fun_amxx.dll      v1.8.2    pl1  ANY  ANY
 [ 9] Engine          RUN  -    engine_amxx.dll  v1.8.2    pl1  ANY  ANY
 [10] FakeMeta        RUN  -    fakemeta_amxx.dl  v1.8.2    pl1  ANY  ANY
 [11] Ham Sandwich    RUN  -    hamsandwich_amxx  v1.8.2    pl1  ANY  ANY
 [12] Orpheu          RUN  -    orpheu_amxx.dll  v2.6.3    pl1  ANY  ANY
12 plugins, 12 running

geoip version
  Database metadata
    Node count:    3179282
    Record size:  28 bits
    IP version:    IPv6
    Binary format: 2.0
    Build epoch:  1436355742 (2015-07-08 11:42:22 UTC)
    Type:          GeoLite2-City
    Languages:    de en es fr ja pt-BR ru zh-CN
    Description:
      en:  GeoLite2 City database

version
Protocol version 48
Exe version 1.0.0.3 (czero)
Exe build: 13:13:29 Aug 29 2013 (6153)

Code:
#include <amxmodx> #include <geoip> #include <colorchat> public plugin_init() { &nbsp;&nbsp;&nbsp;&nbsp;register_plugin("Join Country","1.0","<VeCo>") } public client_putinserver(id) { &nbsp;&nbsp;&nbsp;&nbsp;static sz_name[32] &nbsp;&nbsp;&nbsp;&nbsp;get_user_name(id,sz_name,charsmax(sz_name)) &nbsp;&nbsp;&nbsp;&nbsp;static sz_ip[32], &nbsp;&nbsp;&nbsp;&nbsp;sz_city[32], &nbsp;&nbsp;&nbsp;&nbsp;sz_country[32] &nbsp;&nbsp;&nbsp;&nbsp;get_user_ip(id,sz_ip,charsmax(sz_ip),1) &nbsp;&nbsp;&nbsp;&nbsp;geoip_country(sz_ip,sz_country,charsmax(sz_country)) &nbsp;&nbsp;&nbsp;&nbsp;geoip_city(sz_ip,sz_city,charsmax(sz_city)) &nbsp;&nbsp;&nbsp;&nbsp;ColorChat(0,GREY,"^1Player^4 %s^1 from^3 %s/%s^1 has joined the game!",sz_name,sz_country, sz_city) }

i added it, but not work!!
not display country or city :/

addons_zz 12-18-2015 19:47

Re: [HELP] use geoip to display city
 
Quote:

Originally Posted by arvEL. (Post 2373730)
i added it, but not work!!
not display country or city :/

I do not have time to test it, but if geoip_city(...) is not working, open a issue at Issues with AMX Mod X

Hence, start reading that sub-forum rules: FORUM RULES: Read before you post

But observe:
Quote:

Originally Posted by https://www.amxmodx.org/api/geoip/geoip_city
Return

The result length on successful lookup, 0 otherwise.

Checks its return length size, then use that city as Unknown. This is because, do not exists every words cities at that data base by an IP.

Learn first intent the code and next to give some empty lines and spacing.

Code:
#include <amxmodx> #include <geoip> #include <colorchat>   public plugin_init() {     register_plugin( "Join Country", "1.0", "<VeCo>" ) } public client_putinserver( id ) {     static sz_name[32]     get_user_name( id, sz_name, charsmax( sz_name ) )     static sz_ip[32],     sz_city[32],     sz_country[32]     get_user_ip( id, sz_ip, charsmax( sz_ip ), 1 )     geoip_country( sz_ip, sz_country, charsmax( sz_country ) )         if( !geoip_city( sz_ip, sz_city, charsmax( sz_city ) ) )     {         copy( sz_city, charsmax( sz_city ), "Unknown" )     }     ColorChat( 0, GREY, "^1Player^4 %s^1 from^3 %s/%s^1 has joined the game!", sz_name, sz_country, sz_city ) }

However, GHW Connect Messages is a plugin that is working for me at that server specs I showed earlier.

Update:

Quote:

Originally Posted by arvEL. (Post 2373730)
i added it, but not work!!
not display country or city :/

Quote:

Originally Posted by addons_zz (Post 2373712)
It is not crashing mime. What you are using? (meta list, geoip version, version)

Quote:

If you have access to your game server's console, type the following in the server console:
  • status
  • meta list
  • geoip version
  • version
If you don't have access the your game server's console, join your server and type the
following in your game console:
  • status
  • rcon_password your_rcon_password
  • rcon meta list
  • rcon geoip version
  • rcon version
  1. Paste here everything from the status command *except* the player list.
  2. Paste here the entire result from the meta list, geoip version and version commands.


abdobiskra 12-19-2015 02:46

Re: [HELP] use geoip to display city
 
1 Attachment(s)
Code:
#include <amxmodx> #include <geoip> #include <geoipse> #include <colorchat>   public plugin_init() { register_plugin("Join Country","1.0","<VeCo>") } public client_putinserver(id) {   new szIP[32], szCountry[46], szCity[46], szName[32]; get_user_name(id, szName, 31); get_user_ip( id, szIP, 31, 1 ); geoip_country( szIP, szCountry ); geoip_city( szIP, szCity ); ColorChat(0,GREY,"^1Player^4 [%s]^1 from^3 [%s/%s]^1 has joined the game!", szName, szCountry, szCity) }

http://geolite.maxmind.com/download/...iteCity.dat.gz

arvEL. 12-19-2015 04:26

Re: [HELP] use geoip to display city
 
Quote:

Originally Posted by abdobiskra (Post 2373881)
Code:
#include <amxmodx> #include <geoip> #include <geoipse> #include <colorchat> public plugin_init() { register_plugin("Join Country","1.0","<VeCo>") } public client_putinserver(id) { new szIP[32], szCountry[46], szCity[46], szName[32]; get_user_name(id, szName, 31); get_user_ip( id, szIP, 31, 1 ); geoip_country( szIP, szCountry ); geoip_city( szIP, szCity ); ColorChat(0,GREY,"^1Player^4 [%s]^1 from^3 [%s/%s]^1 has joined the game!", szName, szCountry, szCity) }


http://geolite.maxmind.com/download/...iteCity.dat.gz

sorry i tested it not work.

arvEL. 12-19-2015 04:27

Re: [HELP] use geoip to display city
 
Quote:

Originally Posted by addons_zz (Post 2373823)
I do not have time to test it, but if geoip_city(...) is not working, open a issue at Issues with AMX Mod X

Hence, start reading that sub-forum rules: FORUM RULES: Read before you post

But observe:


Checks its return length size, then use that city as Unknown. This is because, do not exists every words cities at that data base by an IP.

Learn first intent the code and next to give some empty lines and spacing.

Code:
#include <amxmodx> #include <geoip> #include <colorchat> public plugin_init() { register_plugin( "Join Country", "1.0", "<VeCo>" ) } public client_putinserver( id ) { static sz_name[32] get_user_name( id, sz_name, charsmax( sz_name ) ) static sz_ip[32], sz_city[32], sz_country[32] get_user_ip( id, sz_ip, charsmax( sz_ip ), 1 ) geoip_country( sz_ip, sz_country, charsmax( sz_country ) ) if( !geoip_city( sz_ip, sz_city, charsmax( sz_city ) ) ) { copy( sz_city, charsmax( sz_city ), "Unknown" ) } ColorChat( 0, GREY, "^1Player^4 %s^1 from^3 %s/%s^1 has joined the game!", sz_name, sz_country, sz_city ) }


However, GHW Connect Messages is a plugin that is working for me at that server specs I showed earlier.

Update:

i tired from test plugins :/ no one work and GHW_Connect_Message
this display just country no city

abdobiskra 12-19-2015 08:04

Re: [HELP] use geoip to display city
 
PHP Code:

#define VERSION    "1.1"

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

#define SHOW_COLOR        1
#define SHOW_CONNECT        2
#define SHOW_DISCONNECT        4
#define PLAY_SOUND_CONNECT    8
#define PLAY_SOUND_DISCONNECT    16

new display_type_pcvar

new name[33][32]
new 
authid[33][32]
new 
country[33][46]
new 
city[33][46]
new 
ip[33][32]

new 
connect_soundfile[64]
new 
disconnect_soundfile[64]

new 
saytext_msgid

public plugin_init()
{
    
register_plugin("GHW Connect Messages",VERSION,"GHW_Chronic")
    
display_type_pcvar register_cvar("cm_flags","31")
    
register_cvar("cm_connect_string","[AMXX] %name (%steamid) has connected (%country/%city).")
    
register_cvar("cm_disconnect_string","[AMXX] %name (%steamid) has disconnected (%country/%city).")

    
saytext_msgid get_user_msgid("SayText")
}

public 
plugin_precache()
{
    
register_cvar("cm_connect_sound","buttons/bell1.wav")
    
register_cvar("cm_disconnect_sound","fvox/blip.wav")

    
get_cvar_string("cm_connect_sound",connect_soundfile,63)
    
get_cvar_string("cm_disconnect_sound",disconnect_soundfile,63)

    
precache_sound(connect_soundfile)
    
precache_sound(disconnect_soundfile)
}

public 
client_putinserver(id)
{
    if(!
is_user_bot(id))
    {
        
get_client_info(id)

        new 
display_type get_pcvar_num(display_type_pcvar)
        if(
display_type SHOW_CONNECT)
        {
            new 
string[200]
            
get_cvar_string("cm_connect_string",string,199)
            
format(string,199,"^x01%s",string)

            if(
display_type SHOW_COLOR)
            {
                new 
holder[46]

                
format(holder,45,"^x04%s^x01",name[id])
                
replace(string,199,"%name",holder)

                
format(holder,45,"^x04%s^x01",authid[id])
                
replace(string,199,"%steamid",holder)

                
format(holder,45,"^x04%s^x01",country[id])
                
replace(string,199,"%country",holder)

                
format(holder,45,"^x04%s^x01",ip[id])
                
replace(string,199,"%ip",holder)
                
                
format(holder,45,"^x04%s^x01",city[id])
                
replace(string,199,"%city",holder)
            }
            else
            {
                
replace(string,199,"%name",name[id])
                
replace(string,199,"%steamid",authid[id])
                
replace(string,199,"%country",country[id])
                
replace(string,199,"%city",city[id])
                
replace(string,199,"%ip",ip[id])
            }

            new 
numplayers[32], player
            get_players
(players,num,"ch")
            for(new 
i=0;i<num;i++)
            {
                
player players[i]

                
message_begin(MSG_ONE,saytext_msgid,{0,0,0},player)
                
write_byte(player)
                
write_string(string)
                
message_end()

                if(
display_type PLAY_SOUND_CONNECT)
                {
                    new 
stringlen strlen(connect_soundfile)
                    if(
connect_soundfile[stringlen 1]=='v' && connect_soundfile[stringlen 2]=='a' && connect_soundfile[stringlen 3]=='w'//wav
                    
{
                        
client_cmd(player,"spk ^"sound/%s^"",connect_soundfile)
                    }
                    if(
connect_soundfile[stringlen 1]=='3' && connect_soundfile[stringlen 2]=='p' && connect_soundfile[stringlen 3]=='m'//wav
                    
{
                        
client_cmd(player,"mp3 play ^"sound/%s^"",connect_soundfile)
                    }
                }
            }
        }
    }
}

public 
get_client_info(id)
{
    
get_user_name(id,name[id],31)
    
get_user_authid(id,authid[id],31)

    
get_user_ip(id,ip[id],31)
    
geoip_country(ip[id],country[id])
    
geoip_city(ip[id],city[id])
    
    if(
equal(country[id],"error") || equal(city[id],"error"))
    {
        if(
contain(ip[id],"192.168.")==|| equal(ip[id],"127.0.0.1") || contain(ip[id],"10.")==||  contain(ip[id],"172.")==0)
        {
            
country[id] = "LAN"
            
city[id] = "LAN"
        
}
        if(
equal(ip[id],"loopback"))
        {
            
country[id] = "ListenServer User"
        
}
        else
        {
            
country[id] = "Unknown Country"
            
city[id] = "Unknown Country"
        
}
    }
}

public 
client_infochanged(id)
{
    if(!
is_user_bot(id))
    {
        
get_user_info(id,"name",name[id],31)
    }
}

public 
client_disconnect(id)
{
    if(!
is_user_bot(id))
    {
        new 
display_type get_pcvar_num(display_type_pcvar)
        if(
display_type SHOW_DISCONNECT)
        {
            new 
string[200]
            
get_cvar_string("cm_disconnect_string",string,199)
            
format(string,199,"^x01%s",string)

            if(
display_type SHOW_COLOR)
            {
                new 
holder[46]

                
format(holder,45,"^x04%s^x01",name[id])
                
replace(string,199,"%name",holder)

                
format(holder,45,"^x04%s^x01",authid[id])
                
replace(string,199,"%steamid",holder)

                
format(holder,45,"^x04%s^x01",country[id])
                
replace(string,199,"%country",holder)

                
format(holder,45,"^x04%s^x01",ip[id])
                
replace(string,199,"%ip",holder)
                
                
format(holder,45,"^x04%s^x01",city[id])
                
replace(string,199,"%city",holder)
            }
            else
            {
                
replace(string,199,"%name",name[id])
                
replace(string,199,"%steamid",authid[id])
                
replace(string,199,"%country",country[id])
                
replace(string,199,"%city",city[id])
                
replace(string,199,"%ip",ip[id])
            }

            new 
numplayers[32], player
            get_players
(players,num,"ch")
            for(new 
i=0;i<num;i++)
            {
                
player players[i]

                
message_begin(MSG_ONE,saytext_msgid,{0,0,0},player)
                
write_byte(player)
                
write_string(string)
                
message_end()

                new 
stringlen strlen(disconnect_soundfile)
                if(
disconnect_soundfile[stringlen 1]=='v' && disconnect_soundfile[stringlen 2]=='a' && disconnect_soundfile[stringlen 3]=='w'//wav
                
{
                    
client_cmd(player,"spk ^"sound/%s^"",disconnect_soundfile)
                }
                if(
disconnect_soundfile[stringlen 1]=='3' && disconnect_soundfile[stringlen 2]=='p' && disconnect_soundfile[stringlen 3]=='m'//wav
                
{
                    
client_cmd(player,"mp3 play ^"sound/%s^"",disconnect_soundfile)
                }
            }
        }
    }




All times are GMT -4. The time now is 18:12.

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