Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 33

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

  1. #21
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    Hmm sry for coming back again but i managed to show the message but for example im num 0 ingame .. when i do !locate 0 everything is cool but when i write !locate 1 to see another player country it shows my Nick instead of his and my country instead of his.. asked à player to connect to the srv before me .. he got 0 id and when i do !locate 0 everything is cool but same problème comes again if i do !locate 1 to see my self i still have iprintlnbold that tells the 0 id player country and name. Any fix please ?

  2. #22
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    Quote Originally Posted by suck000 View Post
    Hmm sry for coming back again but i managed to show the message but for example im num 0 ingame .. when i do !locate 0 everything is cool but when i write !locate 1 to see another player country it shows my Nick instead of his and my country instead of his.. asked à player to connect to the srv before me .. he got 0 id and when i do !locate 0 everything is cool but same problème comes again if i do !locate 1 to see my self i still have iprintlnbold that tells the 0 id player country and name. Any fix please ?
    Yes, inside your code.


    "Hey my car isnt working it wont start can you please fix it?"
    "Do you have your car here?"
    "Nope"
    "What brand+type is your car?"
    "Its a red car"
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

  3. The Following User Says Thank You to IzNoGoD For This Useful Post:

    kung foo man (7th July 2016)

  4. #23
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    PHP Code:
    case "locate":
                    if(!(
    self checkIfAdmin()))
                    return;
                    if (
    isDefined(args[2]) && isint(args[2]))
                    {
                    
    args[2] = int(args[2]);
                    if(!
    checkIfExist(args[2]))
                    {
                    
    self thread tellMessage("Couldn\'t find a player with this number.");
                            return;
                    }
                        
    player getplayerbyid();
                        
    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);  
                    return;
                    }
                    
    thread tellmessage("Usage : !locate playernum");
                    return; 

  5. #24
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    PHP Code:
    showlocation(rowsargs)  
    {
        if(!
    isdefined(args[0]))  
        return;  
        if(
    isdefined(rows) && isdefined(rows[0]) && isdefined(rows[0]["country"]))  
        
    self iprintlnbold(args[0].name "^7 is from ^2" getlongcountry(rows[0]["country"]));  

    Sorry for posting two Times in à row cuz im on phone :P

  6. #25
    Assadministrator IzNoGoD's Avatar
    Join Date
    Aug 2012
    Posts
    1,718
    Thanks
    17
    Thanked 1,068 Times in 674 Posts
    PHP Code:
    player getplayerbyid(); 
    There's your problem.
    "Does not work" is an error report for a bug between keyboard and chair.

    All hail Artie Effem

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

  8. #27
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    84
    Thanks
    69
    Thanked 20 Times in 17 Posts
    Quote Originally Posted by suck000 View Post
    And how can i fix it sir ?
    If you copied my code, at least you could read it. It's not that ugly (hopefully).

    PHP Code:
    getPlayerById(number)
    {
        
    number Int(number);
        
    players getentarray("player""classname");
        for(
    0players.sizei++) 
        {
            if(
    players[igetEntityNumber() == number)
                return 
    players[i];
        }
        return 
    undefined;

    Read it again (if you did it) and spot the part you missed.

  9. The Following User Says Thank You to Whiskas For This Useful Post:

    suck000 (7th July 2016)

  10. #28
    Brigadier General
    Join Date
    Dec 2012
    Posts
    1,012
    Thanks
    440
    Thanked 171 Times in 132 Posts
    If you had developer 1 on it would gave you the error

  11. #29
    Private First Class
    Join Date
    Mar 2016
    Posts
    134
    Thanks
    48
    Thanked 11 Times in 10 Posts
    PHP Code:
    case "locate"
                    if(!(
    self checkIfAdmin())) 
                    return; 
                    if (
    isDefined(args[2]) && isint(args[2])) 
                    { 
                    
    args[2] = int(args[2]); 
                    if(!
    checkIfExist(args[2])) 
                    { 
                    
    self thread tellMessage("Couldn\'t find a player with this number."); 
                            return; 
                    } 
                        
    player getplayerbyid(); 
                        
    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);   
                    return; 
                    } 
                    
    thread tellmessage("Usage : !locate playernum"); 
                    return; 
    PHP Code:
    showlocation(rowsargs)   

        if(!
    isdefined(args[0]))   
        return;   
        if(
    isdefined(rows) && isdefined(rows[0]) && isdefined(rows[0]["country"]))   
        
    self iprintlnbold(args[0].name "^7 is from ^2" getlongcountry(rows[0]["country"]));   

    failed to notice the problem. can you fix the code please ?

    I got the car here and his model

  12. #30
    Private Whiskas's Avatar
    Join Date
    Jan 2015
    Posts
    84
    Thanks
    69
    Thanked 20 Times in 17 Posts
    Quote Originally Posted by suck000 View Post
    PHP Code:
    case "locate"
                    if(!(
    self checkIfAdmin())) 
                    return; 
                    if (
    isDefined(args[2]) && isint(args[2])) 
                    { 
                    
    args[2] = int(args[2]); 
                    if(!
    checkIfExist(args[2])) 
                    { 
                    
    self thread tellMessage("Couldn\'t find a player with this number."); 
                            return; 
                    } 
                        
    player getplayerbyid(); 
                        
    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);   
                    return; 
                    } 
                    
    thread tellmessage("Usage : !locate playernum"); 
                    return; 
    PHP Code:
    showlocation(rowsargs)   

        if(!
    isdefined(args[0]))   
        return;   
        if(
    isdefined(rows) && isdefined(rows[0]) && isdefined(rows[0]["country"]))   
        
    self iprintlnbold(args[0].name "^7 is from ^2" getlongcountry(rows[0]["country"]));   

    failed to notice the problem. can you fix the code please ?

    I got the car here and his model
    Quote Originally Posted by IzNoGoD View Post
    PHP Code:
    player getplayerbyid(); 
    There's your problem.

    Just use CTRL + F player = getplayerbyid(); maybe?

Posting Permissions

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