weird problem with player country or player ip
#1

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
Reply
#2

Код:
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
Reply
#3

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);
Reply
#4

Thanks hope it works
Reply
#5

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


Forum Jump:


Users browsing this thread: 1 Guest(s)