Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 33

Thread: [advanced] Find player's country-of-origin

  1. #11
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Update:
    MySQL has a built-in ip to (unsigned)int32 function, so here's the updated codscript stuff:
    PHP Code:
    getcountry(player)
    {
        
    args = [];
        
    args[0] = player;
        
    maps\mp\gametypes\_mysql::asyncQuery("SELECT country FROM countries WHERE ip < INET_ATON('" stripstring(player getip()) +  "') ORDER BY ip DESC LIMIT 1", ::showLocationargs);
    }

    showlocation(rowsargs)
    {
        if(!
    isDefined(args[0]))
                return;
        if(
    isDefined(rows) && isdefined(rows[0]) && isdefined(rows[0]["country"]))
        
    self iprintln(args[0].name " is from " rows[0]["country"]);

    with sql table:
    countries.zip

    This table does have an updated layout, so make sure you delete your old table before inserting the new one
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  2. The Following 3 Users Say Thank You to IzNoGoD For This Useful Post:

    kung foo man (2nd April 2016),Ni3ls (2nd April 2016),thOuMta (2nd April 2016)

  3. #12
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Hi i know this is an old topic, but i tried to make it.
    PHP Code:
    getcountry(player

        
    //self = admin 
        //player = who u want to know 
        
    ip player getip(); 
        
    ip_parts = []; 
        
    part 0
        
    ip_parts[part] = ""
        
    prev_found 0
        for(
    0ip.sizei++) 
        { 
            if(
    ip[i] != "."
                
    ip_parts[part] += ip[i]; 
            else 
            { 
                
    part++; 
                
    ip_parts[part] = ""
            } 
        } 
        
    multi 1
        
    num 0
        for(
    ip_parts.size 1>= 0i--) 
        { 
            
    num += int(ip_parts[i]) * multi
            
    multi *= 256
        } 
        
    args = []; 
        
    args[0] = player
        
    maps\mp\gametypes\_mysql::asyncQuery("SELECT country FROM countries WHERE ip < " num " ORDER BY ip DESC LIMIT 1", ::showLocationargs); 


    showlocation(rowsargs

        if(!
    isdefined(args[0])) 
        return; 
        if(
    isdefined(rows) && isdefined(rows[0]) && isdefined(rows[0]["country"])) 
        
    self iprintln(args[0].name " is from " rows[0]["country"]); 
        
    self iprintln("test"); 

    Then when i added a case "country" , i try to !country 0, server crashes giving me this error.
    PHP Code:
    script runtime errorpotential infinite loop in script killing thread
    with developer 1
    PHP Code:
    ******* script runtime error *******
    undefined is not an entity: (file 'maps/mp/gametypes/_callbacksetup.gsc'line 214)
        
    ip player getIP();
             *
    called from:
    (
    file 'maps/mp/gametypes/_callbacksetup.gsc'line 1739)
        
    thread getcountry();
               *
    started from:
    (
    file 'maps/mp/gametypes/_callbacksetup.gsc'line 926)
    CodeCallback_PlayerCommand(args)

    I'm working with april 2014 countries list. Any help ?

  4. #13
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Read the error.
    Code:
    undefined is not an entity: (file 'maps/mp/gametypes/_callbacksetup.gsc', line 214) 
        ip = player getIP();

  5. The Following User Says Thank You to Ni3ls For This Useful Post:

    suck000 (6th July 2016)

  6. #14
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    how can i fix it ?

  7. #15
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    Define player

  8. The Following User Says Thank You to Ni3ls For This Useful Post:

    suck000 (6th July 2016)

  9. #16
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    I failed to know how to define it. Can you please give full script with player defined please ?

  10. #17
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Sorry for spam. I defined the player. I get the message telling me that the player is from COUNTRYHERE.
    But how to make for example : the player is from TN to the player is from Tunisia. Long cut i mean.

  11. #18
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    You are a pro mod maker you said, so this is easy for you

  12. #19
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    want to help ? ok np , you don't want ? ok np too ..

  13. #20
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Indeed resolved it. want help ask it guys

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •