Raised This Month: $51 Target: $400
 12% 

[ Solved ]switch string


Post New Thread Reply   
 
Thread Tools Display Modes
Freezo Begin
BANNED
Join Date: Mar 2014
Location: Morocco
Old 01-09-2015 , 18:47   Re: [ Solved ]switch string
Reply With Quote #11

yes i know ( ' using a enum with trie like this one ' )

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

enum _:Country
{
    
Country_Sweden,
    
Country_Estonia,
    
Country_Germany
};

new const 
g_country_name[Country][] =
{
    
"Sweden",
    
"Estonia",
    
"Germany"
};

new 
Trie:g_countries;

public 
plugin_init()
{
    
g_countries TrieCreate();
    
    for(new 
0Countryi++)
    {
        
TrieSetCell(g_countriesg_country_name[i], i);
    }
}

public 
plugin_end()
{
    
TrieDestroy(g_countries);
}

check_country(id)
{
    new 
ip[32], country[46];
    
get_user_ip(idipcharsmax(ip), 1);
    
geoip_country(ipcountrycharsmax(country));
    
    new 
country_id;
    if(
TrieGetCell(g_countriescountrycountry_id))
    {
        
// "country" is "Sweden" "Estonia" or "Germany"
        
        
switch(country_id)
        {
            case 
Country_Sweden:
            {
                
// "country" is "Sweden"
            
}
            case 
Country_Estonia:
            {
                
// "country" is "Estonia"
            
}
            case 
Country_Germany:
            {
                
// "country" is "Germany"
            
}
        }
    }
    else
    {
        
// "country" is any other string
    
}

Freezo Begin 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 03:11.


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