Raised This Month: $32 Target: $400
 8% 

Country Filter 2nd Edition


Post New Thread Reply   
 
Thread Tools Display Modes
SoltekGamerz
Junior Member
Join Date: Aug 2016
Old 11-03-2016 , 22:41   Re: Country Filter 2nd Edition
Reply With Quote #91

This is a test version

kick by banip

PHP Code:
#include <sourcemod>
#include <geoip>

new Handle:cf_mode INVALID_HANDLE;
new 
bool:g_mode false;

new 
Handle:cf_alphacode INVALID_HANDLE;
new 
bool:g_alphacode false;

new 
Handle:cf_chatusecode INVALID_HANDLE;
new 
bool:g_chatusecode false;

new 
Handle:cf_countries INVALID_HANDLE;

new 
Handle:cf_adminimmunity INVALID_HANDLE;
new 
bool:g_adminimmunity false;

new 
Handle:cf_allowlan INVALID_HANDLE;
new 
bool:g_allowlan false;

new 
Handle:cf_allowunidentified INVALID_HANDLE;
new 
bool:g_allowunidentified false;

new 
Handle:cf_chatannouncements INVALID_HANDLE;
new 
g_chatannouncements;

public 
Plugin:myinfo =
{
    
name "Country Filter 2nd Edition",
    
author "Bacardi",
    
description "Allow or reject certain countries connect to your server.",
    
version "2.0.4",
    
url "http://www.sourcemod.net/"
}

public 
OnPluginStart()
{
    
LoadTranslations("country_filter_2nd_edition.phrases");

    
cf_mode CreateConVar("cf_mode""0""0 = Allow all expect cf_countries\n1 = Allow only cf_countries"FCVAR_NONEtrue0.0true1.0);
    
g_mode GetConVarBool(cf_mode);
    
HookConVarChange(cf_modeConVarChanged);

    
cf_alphacode CreateConVar("cf_alphacode""2""Choose what code type use in cf_countries\n2 = ISO 3166-1 alpha-2 codes (GB JP US)\n3 = ISO 3166-1 alpha-3 codes (GBR JPN USA)\nhttp://en.wikipedia.org/wiki/ISO_3166-1#Current_codes"FCVAR_NONEtrue2.0true3.0);
    
g_alphacode GetConVarInt(cf_alphacode) == truefalse;
    
HookConVarChange(cf_alphacodeConVarChanged);

    
cf_countries CreateConVar("cf_countries""""List countries\nexample alpha 2 codes: \"GB JP US\"\nexample alpha 3 codes: \"GBR JPN USA\""FCVAR_NONE);

    
cf_chatusecode CreateConVar("cf_chatusecode""0""Print country name in chat using, 0 = Country name, 1 = Country code"FCVAR_NONEtrue0.0true1.0);
    
g_chatusecode GetConVarBool(cf_chatusecode);
    
HookConVarChange(cf_chatusecodeConVarChanged);

    
cf_adminimmunity CreateConVar("cf_adminimmunity""0""Admin immunity, 0 = Disabled, 1 = Enabled"FCVAR_NONEtrue0.0true1.0);
    
g_adminimmunity GetConVarBool(cf_adminimmunity);
    
HookConVarChange(cf_adminimmunityConVarChanged);

    
cf_allowlan CreateConVar("cf_allowlan""0""Allow players connect from LAN, 0 = Disabled, 1 = Enabled\nIP 10.x.x.x\nIP 127.x.x.x\nIP 169.254.x.x\nIP 192.168.x.x\nIP 172.16.x.x - 172.31.x.x"FCVAR_NONEtrue0.0true1.0);
    
g_allowlan GetConVarBool(cf_allowlan);
    
HookConVarChange(cf_allowlanConVarChanged);

    
cf_allowunidentified CreateConVar("cf_allowunidentified""0""Allow players connect from unidentified country, 0 = Disabled, 1 = Enabled"FCVAR_NONEtrue0.0true1.0);
    
g_allowunidentified GetConVarBool(cf_allowunidentified);
    
HookConVarChange(cf_allowunidentifiedConVarChanged);

    
cf_chatannouncements CreateConVar("cf_chatannouncements""1""Print chat announcements to all players\nUsage 1+2 = 3 (Print allowed and rejected country connections)\n0 = Off\n1 = Allowed connections\n2 = Rejected connections\n4 = Allowed LAN connections\n8 = Rejected LAN connections"FCVAR_NONEtrue0.0true15.0);
    
g_chatannouncements GetConVarInt(cf_chatannouncements);
    
HookConVarChange(cf_chatannouncementsConVarChanged);
    
// 0 off
    // 1 allow country
    // 2 denied country
    // 4 allow lan
    // 8 denied lan

    
AutoExecConfig(true"country_filter_2nd_edition");
}

public 
ConVarChanged(Handle:convar, const String:oldValue[], const String:newValue[])
{
    if(
convar == cf_mode)
    {
        
g_mode StringToInt(newValue) == true:false;
    }

    if(
convar == cf_alphacode)
    {
        
g_alphacode StringToInt(newValue) == true:false;
    }

    if(
convar == cf_chatusecode)
    {
        
g_chatusecode StringToInt(newValue) == true:false;
    }

    if(
convar == cf_adminimmunity)
    {
        
g_adminimmunity StringToInt(newValue) == true:false;
    }

    if(
convar == cf_allowlan)
    {
        
g_allowlan StringToInt(newValue) == true:false;
    }

    if(
convar == cf_allowunidentified)
    {
        
g_allowunidentified StringToInt(newValue) == true:false;
    }

    if(
convar == cf_chatannouncements)
    {
        
g_chatannouncements StringToInt(newValue);
    }
}

public 
OnClientConnected(client)
{
    if(!
g_adminimmunity && !IsFakeClient(client))
    {
        
CheckConnection(client);
    }
}

public 
OnClientPostAdminCheck(client)
{
    if(
g_adminimmunity && !IsFakeClient(client) && !CheckCommandAccess(client"cf_immunity"ADMFLAG_RESERVATION))
    {
        
CheckConnection(client);
    }
}

CheckConnection(client)
{
    
decl String:IP[16];
    
IP[0] = '\0';
    
GetClientIP(clientIPsizeof(IP));

    if(
StrEqual(IP"loopback"))    // Player is listenserver
    
{
        return;
    }

    
decl String:CODE[4];
    
CODE[0] = '\0';

    if(
g_alphacode GeoipCode2(IPCODE):GeoipCode3(IPCODE))
    {
        
// Country found from GeoIP.dat

        
decl String:str[257], String:expcodes[64][4];
        
str[0] = '\0';
        
GetConVarString(cf_countriesstrsizeof(str));    // Get list cf_countries

        
new bool:reject g_mode true:false;    // Default if country not found from cf_countries

        
if(str[0] != '\0')    // cf_countries should contain something
        
{
            new 
total ExplodeString(str" "expcodes644);    // Separate cf_countries codes
    
            
for(new 0totali++)    // Loop amount of cf_countries codes
            
{
                if(
StrEqual(CODEexpcodes[i]))    // Player country match from cf_countries list
                
{
                    
reject g_mode false:true;    // Will we reject this country ? Depend cf_mode.
                    
break;
                }
            }
        }

        
decl String:countryname[45];
        
countryname[0] = '\0';
        
GeoipCountry(IPcountrynamesizeof(countryname));

        switch(
reject)
        {
            case 
true:    // Reject
            
{
                if(
g_chatannouncements 2)
                {
                    
PrintToChatAll("%t""Country not allowed join chat"clientg_chatusecode CODE:countryname);
                }
                
BanClient(client0BANFLAG_AUTO BANFLAG_NOKICK"%t""Country not allowed join kick"countryname);
            }
            case 
false:    // Pass
            
{
                if(
g_chatannouncements 1)
                {
                    
PrintToChatAll("%t""Country allowed join chat"clientg_chatusecode CODE:countryname);
                }
            }
        }
    }
    else
    {
        
// Country not found from GeoIP.dat
        // Failed identify player country (Reason for this could be old GeoIP.dat file or one of LAN IP addresses)

        
new bool:islan false;
        
decl String:expip[4][2];
        
ExplodeString(IP"."expip24);
        new 
ip1st StringToInt(expip[0]), ip2nd StringToInt(expip[1]);

        if(
ip1st == 10 || ip1st == 127)    // 10.x.x.x | 127.x.x.x
        
{
            
islan true;
        }
        else if(
ip1st == 192 && ip2nd == 168 || ip1st == 169 && ip2nd == 254)    // 192.168.x.x | 169.254.x.x
        
{
            
islan true;
        }
        else if(
ip1st == 172 && ip2nd >= 16 && ip2nd <= 31)    // 172.16.x.x - 172.31.x.x
        
{
            
islan true;
        }

        switch(
islan)
        {
            case 
true:
            {
                if(!
g_allowlan)
                {
                    if(
g_chatannouncements 8)
                    {
                        
PrintToChatAll("%t""LAN not allowed join chat"clientIP);
                    }
                    
BanClient(client0BANFLAG_AUTO BANFLAG_NOKICK"%t""LAN not allowed join kick"IP);
                }
                else
                {
                    if(
g_chatannouncements 4)
                    {
                        
PrintToChatAll("%t""LAN allowed join chat"clientIP);
                    }
                }
            }
            case 
false:
            {
                if(!
g_allowunidentified)
                {
                    if(
g_chatannouncements 2)
                    {
                        
PrintToChatAll("%t""Unidentified not allowed join chat"client);
                    }
                    
BanClient(client0BANFLAG_AUTO BANFLAG_NOKICK,  "%t""Unidentified not allowed join kick");
                }
                else
                {
                    if(
g_chatannouncements 1)
                    {
                        
PrintToChatAll("%t""Unidentified allowed join chat"client);
                    }
                }
            }
        }
    }

SoltekGamerz is offline
szogun
Senior Member
Join Date: Apr 2016
Old 11-27-2016 , 03:52   Re: Country Filter 2nd Edition
Reply With Quote #92

....

Last edited by szogun; 05-11-2017 at 06:09. Reason: delet
szogun is offline
szogun
Senior Member
Join Date: Apr 2016
Old 05-11-2017 , 06:07   Re: Country Filter 2nd Edition
Reply With Quote #93

And if you can block only two separate countries so that the rest of the players were free to enter
szogun is offline
geoxd1
Junior Member
Join Date: Aug 2017
Location: Poland
Old 08-31-2017 , 04:49   Re: Country Filter 2nd Edition
Reply With Quote #94

Is There Way To Auto Mute When These Countrys join in server, Russia, Belarus, Ukraine and Poland i have huge problem with them they scream allways or don't respect rule english only in voice chat.

Last edited by geoxd1; 08-31-2017 at 04:49.
geoxd1 is offline
romeo7
Senior Member
Join Date: Mar 2017
Old 09-01-2017 , 16:55   Re: Country Filter 2nd Edition
Reply With Quote #95

Quote:
Originally Posted by geoxd1 View Post
Is There Way To Auto Mute When These Countrys join in server, Russia, Belarus, Ukraine and Poland i have huge problem with them they scream allways or don't respect rule english only in voice chat.
use mute edition.
https://forums.alliedmods.net/showpo...5&postcount=58
cvar:
cf_mode "0"
cf_countries "RU BY UA PL"
cf_muteorban "0"

Last edited by romeo7; 09-01-2017 at 17:03.
romeo7 is offline
geoxd1
Junior Member
Join Date: Aug 2017
Location: Poland
Old 09-06-2017 , 13:46   Re: Country Filter 2nd Edition
Reply With Quote #96

Quote:
Originally Posted by romeo7 View Post
use mute edition.
https://forums.alliedmods.net/showpo...5&postcount=58
cvar:
cf_mode "0"
cf_countries "RU BY UA PL"
cf_muteorban "0"
Thanks Dude
geoxd1 is offline
r3v
Senior Member
Join Date: Feb 2016
Location: Lithuania, Vilnius
Old 07-06-2018 , 16:26   Re: Country Filter 2nd Edition
Reply With Quote #97

Can someone confirm mute version is broken? It's not working on CS:S. Original (kick) version working perfectly. GeoIP.dat is updated, no error logs.

PHP Code:
// This file was auto-generated by SourceMod (v1.8.0.6048)
// ConVars for plugin "country_filter_2nd_edition.smx"


// Admin immunity, 0 = Disabled, 1 = Enabled
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_adminimmunity "1"

// Allow players connect from LAN, 0 = Disabled, 1 = Enabled
// IP 10.x.x.x
// IP 127.x.x.x
// IP 169.254.x.x
// IP 192.168.x.x
// IP 172.16.x.x - 172.31.x.x
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_allowlan "1"

// Allow players connect from unidentified country, 0 = Disabled, 1 = Enabled
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_allowunidentified "0"

// Choose what code type use in cf_countries
// 2 = ISO 3166-1 alpha-2 codes (GB JP US)
// 3 = ISO 3166-1 alpha-3 codes (GBR JPN USA)
// http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
// -
// Default: "2"
// Minimum: "2.000000"
// Maximum: "3.000000"
cf_alphacode "2"

// Print chat announcements to all players
// Usage 1+2 = 3 (Print allowed and rejected country connections)
// 0 = Off
// 1 = Allowed connections
// 2 = Rejected connections
// 4 = Allowed LAN connections
// 8 = Rejected LAN connections
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "15.000000"
cf_chatannouncements "0"

// Print country name in chat using, 0 = Country name, 1 = Country code
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_chatusecode "0"

// List countries
// example alpha 2 codes: "GB JP US"
// example alpha 3 codes: "GBR JPN USA"
// -
// Default: "RU BY UA PL"
cf_countries "BG IL KG PT RO SK UZ RU BY UA PL TR CZ FR HU AL TH HU JO MD RS HU LV EE"

// 0 = Allow all expect cf_countries
// 1 = Allow only cf_countries
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_mode "0"

cf_muteorban 0 

Last edited by r3v; 07-06-2018 at 16:28.
r3v is offline
romeo7
Senior Member
Join Date: Mar 2017
Old 07-06-2018 , 17:28   Re: Country Filter 2nd Edition
Reply With Quote #98

Quote:
Originally Posted by r3v View Post
Can someone confirm mute version is broken? It's not working on CS:S. Original (kick) version working perfectly. GeoIP.dat is updated, no error logs.

PHP Code:
// This file was auto-generated by SourceMod (v1.8.0.6048)
// ConVars for plugin "country_filter_2nd_edition.smx"


// Admin immunity, 0 = Disabled, 1 = Enabled
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_adminimmunity "1"

// Allow players connect from LAN, 0 = Disabled, 1 = Enabled
// IP 10.x.x.x
// IP 127.x.x.x
// IP 169.254.x.x
// IP 192.168.x.x
// IP 172.16.x.x - 172.31.x.x
// -
// Default: "1"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_allowlan "1"

// Allow players connect from unidentified country, 0 = Disabled, 1 = Enabled
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_allowunidentified "0"

// Choose what code type use in cf_countries
// 2 = ISO 3166-1 alpha-2 codes (GB JP US)
// 3 = ISO 3166-1 alpha-3 codes (GBR JPN USA)
// http://en.wikipedia.org/wiki/ISO_3166-1#Current_codes
// -
// Default: "2"
// Minimum: "2.000000"
// Maximum: "3.000000"
cf_alphacode "2"

// Print chat announcements to all players
// Usage 1+2 = 3 (Print allowed and rejected country connections)
// 0 = Off
// 1 = Allowed connections
// 2 = Rejected connections
// 4 = Allowed LAN connections
// 8 = Rejected LAN connections
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "15.000000"
cf_chatannouncements "0"

// Print country name in chat using, 0 = Country name, 1 = Country code
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_chatusecode "0"

// List countries
// example alpha 2 codes: "GB JP US"
// example alpha 3 codes: "GBR JPN USA"
// -
// Default: "RU BY UA PL"
cf_countries "BG IL KG PT RO SK UZ RU BY UA PL TR CZ FR HU AL TH HU JO MD RS HU LV EE"

// 0 = Allow all expect cf_countries
// 1 = Allow only cf_countries
// -
// Default: "0"
// Minimum: "0.000000"
// Maximum: "1.000000"
cf_mode "0"

cf_muteorban 0 
use THIS its best for me.
romeo7 is offline
Sarin
Senior Member
Join Date: Nov 2014
Location: Sydney, Australia
Old 12-27-2018 , 17:52   Re: Country Filter 2nd Edition
Reply With Quote #99

Fantastic plugin. Top show mate!!!!
Sarin is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 12-28-2018 , 09:03   Re: Country Filter 2nd Edition
Reply With Quote #100

Quote:
GeoLite Legacy Downloadable Databases

Updated versions of the GeoLite Legacy databases are now only available to redistribution license customers,
although anyone can continue to download the March 2018 GeoLite Legacy builds. Starting January 2, 2019, the last build will be removed from our website. GeoLite Legacy database users will need to switch to the GeoLite2 or commercial GeoIP databases and update their integrations by January 2, 2019.
For more information, please visit our Support Center.
Note: After careful consideration, taking into account customer feedback, we have decided against removing latitude and longitude coordinates from the GeoLite2 databases. We are in the process of reviewing coordinates used in all of our GeoLite2 and GeoIP databases to ensure there is no risk of misuse.
* GeoLite2 databases are free IP geolocation databases comparable to, but less accurate than, MaxMind’s GeoIP2 databases. Please remember to use the accuracy radius if displaying coordinates on a map.
https://github.com/alliedmodders/sourcemod/issues/913
https://github.com/alliedmodders/sourcemod/pull/914





Here zip pack (final ?).
GeoIP.dat.gz- 27.3.2018
Code:
 [GEOIP] GeoIP database info: GEO-106FREE 20180327 Build 1 Copyright (c) 2018 MaxMind Inc All Rights Reserved
Attached Files
File Type: gz GeoIP.dat.gz (694.8 KB, 525 views)

Last edited by Bacardi; 12-28-2018 at 09:09.
Bacardi is offline
Reply


Thread Tools
Display Modes

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 19:51.


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