Raised This Month: $ Target: $400
 0% 

[HELP] use geoip to display city


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 12-19-2015 , 08:56   Re: [HELP] use geoip to display city
Reply With Quote #1

Quote:
Originally Posted by abdobiskra View Post
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)
                }
            }
        }
    }

sorry not work
__________________
arvEL. is offline
Send a message via Skype™ to arvEL.
abdobiskra
Veteran Member
Join Date: Jul 2014
Location: Algeria
Old 12-19-2015 , 09:32   Re: [HELP] use geoip to display city
Reply With Quote #2

Well in this case it must be accompanied us a picture about the problem after experimentation?
__________________
abdobiskra is offline
Send a message via Skype™ to abdobiskra
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 12-19-2015 , 10:20   Re: [HELP] use geoip to display city
Reply With Quote #3

Quote:
Originally Posted by abdobiskra View Post
Well in this case it must be accompanied us a picture about the problem after experimentation?
This guy is playing with us, I already asked him twice for this below and he keep ignoring:

Quote:
Originally Posted by addons_zz View Post
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.
And moreover:

Quote:
Originally Posted by addons_zz View Post
do not exists every words cities at that data base by an IP. (LAN, for example)

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
However, thanks for your GHW Connect Messages code.

Last edited by addons_zz; 12-21-2015 at 16:48. Reason: spelling fixes
addons_zz is offline
simanovich
AlliedModders Donor
Join Date: Jun 2012
Location: Israel
Old 12-20-2015 , 09:55   Re: [HELP] use geoip to display city
Reply With Quote #4

The original GeoIP Module doesn't have cities database.

Use this Module:
https://forums.alliedmods.net/showthread.php?t=95665
__________________
simanovich is offline
arvEL.
Senior Member
Join Date: Dec 2014
Location: Iraq
Old 12-21-2015 , 16:32   Re: [HELP] use geoip to display city
Reply With Quote #5

Quote:
Originally Posted by simanovich View Post
The original GeoIP Module doesn't have cities database.

Use this Module:
https://forums.alliedmods.net/showthread.php?t=95665
give me the download direct link
and example about get city
__________________
arvEL. is offline
Send a message via Skype™ to arvEL.
wickedd
Veteran Member
Join Date: Nov 2009
Old 12-21-2015 , 16:44   Re: [HELP] use geoip to display city
Reply With Quote #6

Quote:
Originally Posted by arvEL. View Post
give me the download direct link
and example about get city
He gave you the link and there's a example of how to use it in this thread.
__________________
Just buy the fucking game!!!!
I hate No-Steamers and lazy ass people.
wickedd is offline
addons_zz
Veteran Member
Join Date: Aug 2015
Location: Dreams, zz
Old 12-21-2015 , 16:48   Re: [HELP] use geoip to display city
Reply With Quote #7

Quote:
Originally Posted by wickedd View Post
He gave you the link and there's a example of how to use it in this thread.
Quote:
Originally Posted by addons_zz View Post
This guy is playing with us
addons_zz 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 18:12.


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