AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Country Welcome (https://forums.alliedmods.net/showthread.php?t=12265)

[WbOF]LuZiFeR 04-10-2005 09:56

Country Welcome
 
I have taken the country-kicker from EKS to make my first trials in scripting. (Hope, that this is no problem :) )

Now i have change some things to use the Kicker as a Welcome-Plugin. The players or admins on the server see, who connects from which country....

Code:

/* Country Welcome

About:
This plugin shows, from which country a player is connecting
It is possible to configurate countrys that are not shown,
and who will became the message (Admins or all Players)

Modules required: geoip

Credits:
EKS for the plugin country_kicker, because the basic-code is from him :)

Setting up plugin:
sv_message
 1 Players
 2 Admins

sv_country_name use commas to seperate country names
like:
sv_country_name "NOR,DEN,DEU"

Changelog
0.9 ( 02.04.2005 ) first try
*/

#include <amxmodx>
#include <geoip>

#define MAX_COUNTRYS 15

new g_Mode
new g_CC[MAX_COUNTRYS+1][4]
new g_Countries
new CountyList[128]

public plugin_init()
{
        register_plugin("Country Welcome","0.9.0","LuZi")
        register_cvar("sv_country_name","DEU")
        register_cvar("sv_message","1")
}

public plugin_cfg()
{
        g_Mode = get_cvar_num("sv_message")
       
        new CvarInfo[MAX_COUNTRYS*3+MAX_COUNTRYS+2]
        get_cvar_string("sv_country_name",CvarInfo,MAX_COUNTRYS*3+MAX_COUNTRYS+2)
       
        g_Countries = ExplodeString( g_CC, MAX_COUNTRYS, 3, CvarInfo, ',' )
       
        for(new i=0;i<=g_Countries;i++)
                format(CountyList,127,"%s %s",CountyList,g_CC[i])
}
stock ExplodeString( p_szOutput[][], p_nMax, p_nSize, p_szInput[], p_szDelimiter )
{
    new nIdx = 0, l = strlen(p_szInput)
    new nLen = (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput, p_szDelimiter ))
    while( (nLen < l) && (++nIdx < p_nMax) )
        nLen += (1 + copyc( p_szOutput[nIdx], p_nSize, p_szInput[nLen], p_szDelimiter ))
    return nIdx
}
stock IsConInArray(Con[4])
{
        for(new i=0;i<=g_Countries;i++)
        {
                if(equal(Con,g_CC[i]))
                        return 1
        }
        return 0
}
stock IsLocalIp(IP[32])
{
        new tIP[32]
       
        copy(tIP,3,IP)
        if(equal(tIP,"10.") || equal(tIP,"127"))
                return 1
        copy(tIP,7,IP)
        if(equal(tIP,"192.168"))
                return 1

        return 0
}
public client_connect(id)
{
        new userip[32]
        new CC[4]
        get_user_ip(id,userip,31,1)

        geoip_code3(userip,CC)
        if(strlen(userip) == 0)
        {
                get_user_ip(id,userip,31,1)               
                if(!IsLocalIp(userip))
                        log_amx("%s made a error when passed though geoip",userip)
                return PLUGIN_HANDLED
        }

        if(g_Mode == 1 && !IsConInArray(CC))
        {
                new Name[32]
                get_user_name(id,Name,31)
                server_cmd("say Wir begruessen %s aus %s !",Name,CC)
        }               
       
        else if(g_Mode == 2 && !IsConInArray(CC))
        {
                new Name[32]
                get_user_name(id,Name,31)
                server_cmd("amx_chat Es verbindet sich %s aus %s !",Name,CC)
        }
        return PLUGIN_HANDLED
}

Now i have 2 questions:

Are the if-statements working in this way ? (Maybe no one connects from another country then germany until now.. )

Is it possible to show the whole countryname (Germany instead of DEU) ? I don't know the function of geoip in details...

Sorry about my english :) And maybe it is a noob-question, but somewhere i must begin with this.... :)

regards LuZi

[WbOF]LuZiFeR 04-10-2005 11:41

Now i know, that the if-functions working correctly... :)

Is there someone, who knows, why the geoip-modul shows USA for all players that are connecting from AOL (regardless which country) ?

[WbOF]LuZiFeR 04-11-2005 09:42

No suggestions ? O.K.... :)

It looks like, that the geoip only brings 3 digit country-codes, so i must solve this with a if-statement and a table with fullnames....

And AOL is using US-IPs regardless from which country a player connects, so i must handle it like a error in geoip....

Edit: Ohh... There's a function geoip_country.... :D


All times are GMT -4. The time now is 10:00.

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