You don't need the GeoIP module since you're using 1.8.3, it's already include. However, you still need
GeoLite2 City.
Download the binary and install it in addons/amxmodx/data folder.
Here you go
PHP Code:
#include <amxmodx>
#include <geoip>
new szIP[ MAX_PLAYERS + 1 ][ 16 ], szStates[ MAX_PLAYERS + 1 ][ 15 ], s_kick
new Trie:s_load
new States[][] =
{
"Texas",
"Mississippi" // Add the states here
}
public plugin_init()
{
register_plugin( "States Kicker", "0.1", "csykosoma" )
s_kick = register_cvar( "states_kick", "1" ) /* 1 = Kick the states on the list. 2 = Allow only the states from the list*/
s_load = TrieCreate( )
for( new i = 0; i < sizeof( States ); i++ )
{
TrieSetCell( s_load, States[ i ], 1 )
}
}
public client_authorized( id )
{
get_user_ip( id, szIP[ id ], charsmax( szIP[] ), 1 )
geoip_region_name( szIP[ id ], szStates[ id ], charsmax( szStates[] ) )
switch( get_pcvar_num( s_kick ) )
{
case 1:
{
if( TrieKeyExists( s_load, szStates[ id ] ) )
{
server_cmd( "kick #%i ^"Your State Is Not Allowed^"", get_user_userid( id ) )
}
}
case 2:
{
if( !TrieKeyExists( s_load, szStates[ id ] ) )
{
server_cmd( "kick #%i ^"Your States Is Not Allowed^"", get_user_userid( id ) )
}
}
}
}
public plugin_end( )
{
TrieDestroy( s_load )
}
__________________