SA-MP Forums Archive
weird problem with player country or player ip - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: weird problem with player country or player ip (/showthread.php?tid=651050)



weird problem with player country or player ip - wallen - 12.03.2018

PHP код:
CMD:whois(playeridparams[])
{
    if(
connected[playerid] == true) return GameTextForPlayer(playerid"~r~Spawn First"50005);
    if(
pInfo[playerid][Admin] < 3) return SendClientMessage(playerid, -1"{C3C3C3}(INFO) You don't have the priviliges to use this command.");
    {
            new 
str[500], targetip[90], str2[144];
            if(
sscanf(params"u"target)) return SendClientMessage(playerid, -1"{c3c3c3}(INFO) /whois [id]");
            if(
target == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1"{c3c3c3}(INFO) Player offline.");
            
GetPlayerIp(targetip16);
            
GetPlayerCountry(targetstr2sizeof(str2));
            
format(strsizeof(str), "{ff0000}%s's ip is '%s' connected from '%s'"PlayerName[target], ip[target], str2[target]);
               
SendClientMessage(playerid, -1str);
    }
    return 
1;

When i do that command to myself it shows ip and country with no issues, but when i type /whois 1 or any other id, it removes 2/3 letters from country name, like, "Kingdoom" instead of United Kingdoom, and ip's are like ".123.2312.3" instead of 12.3.2314.4 you know. Using whitetiger's geo location


Re: weird problem with player country or player ip - Sew_Sumi - 12.03.2018

Код:
str2[target]
That isn't right.

str2 isn't an array based on a player, it's a string. That'll be why you've got messed outputs. You are ID 0, so it will show all the string, but if they are ID 15, the string will show from character 15 onwards. (I only learnt of this last week)


If I have ExampleName[10] and I have a player called FudgeCake, if I do something like ExampleName[5] I'll either end up with output of eCake, or Cake... Hopefully Cake.

source: http://forum.sa-mp.com/showpost.php?...06&postcount=2


Re: weird problem with player country or player ip - RedFusion - 12.03.2018

I found an error in your code

Change from this
pawn Код:
format(str, sizeof(str), "{ff0000}%s's ip is '%s' connected from '%s'", PlayerName[target], ip[target], str2[target]);
to this
pawn Код:
format(str, sizeof(str), "{ff0000}%s's ip is '%s' connected from '%s'", PlayerName[target], ip, str2);



Re: weird problem with player country or player ip - wallen - 12.03.2018

Thanks hope it works


Re: weird problem with player country or player ip - Sew_Sumi - 12.03.2018

I sure hope you read what I mentioned. It could help you in the future, especially with how that technique works.