SA-MP Forums Archive
CMD not returning IP address to user. - 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: CMD not returning IP address to user. (/showthread.php?tid=406578)



CMD not returning IP address to user. - EAsT-OAK_510 - 10.01.2013

Okay, so I attempted to create a command which admins could use to check an offline user's last logged IP address to my server. But instead of returning the offline person's IP address it returns the IP address of the user who uses the command.

pawn Код:
CMD:oipcheck(playerid, params[])
{
    new playerb[32], playerbb, file[32], IP[16], string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "s", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /oipcheck [playerid]");
    format(file, sizeof(file), "users/%s.ini", playerb);
    if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_GREY, "Player name not found.");
    format(PlayerInfo[playerid][pIP], 16, "%s", dini_Get(file, "IP"));
    GetPlayerIp(playerid, IP, sizeof(IP));
    format(string, sizeof(string), "Name: %s | IP: %s", playerbb, RPIP(playerbb));
    playerb[24] = playerbb;
    SendClientMessage(playerid, COLOR_ORANGE, string);
    return 1;
}



Re: CMD not returning IP address to user. - Fabio11 - 10.01.2013

Here
pawn Код:
GetPlayerIp(playerid, IP, sizeof(IP));
You get the IP of the user who uses the command. The rest in on you.


Re: CMD not returning IP address to user. - Shetch - 10.01.2013

Код:
GetPlayerIp(playerid, IP, sizeof(IP));
In this line you are just getting your own IP adress..?
I don't think you even need this line of code.

Код:
CMD:oipcheck(playerid, params[])
{
    new playerb[32], playerbb, file[32], IP[16], string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "s", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /oipcheck [playerid]");
    format(file, sizeof(file), "users/%s.ini", playerb);
    if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_GREY, "Player name not found.");
    format(PlayerInfo[playerid][pIP], 16, "%s", dini_Get(file, "IP"));
    format(string, sizeof(string), "Name: %s | IP: %s", playerbb, PlayerInfo[playerid][pIP]);
    playerb[24] = playerbb;
    SendClientMessage(playerid, COLOR_ORANGE, string);
    return 1;
}



Re: CMD not returning IP address to user. - EAsT-OAK_510 - 10.01.2013

Quote:
Originally Posted by Shetch
Посмотреть сообщение
Код:
GetPlayerIp(playerid, IP, sizeof(IP));
In this line you are just getting your own IP adress..?
I don't think you even need this line of code.

Код:
CMD:oipcheck(playerid, params[])
{
    new playerb[32], playerbb, file[32], IP[16], string[128];
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command.");
    if(sscanf(params, "s", playerb)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /oipcheck [playerid]");
    format(file, sizeof(file), "users/%s.ini", playerb);
    if(!dini_Exists(file)) return SendClientMessage(playerid, COLOR_GREY, "Player name not found.");
    format(PlayerInfo[playerid][pIP], 16, "%s", dini_Get(file, "IP"));
    format(string, sizeof(string), "Name: %s | IP: %s", playerbb, PlayerInfo[playerid][pIP]);
    playerb[24] = playerbb;
    SendClientMessage(playerid, COLOR_ORANGE, string);
    return 1;
}
Remember, I want to check an offline user's IP address. So the command has to read it from the user's file.


Re: CMD not returning IP address to user. - Shetch - 10.01.2013

Exaxtly, that's what I did.
It reads from the dini file and saves the Ip adress to PlayerInfo[playerid][pIP].

Afterwards it just prints it out.


Re: CMD not returning IP address to user. - EAsT-OAK_510 - 10.01.2013

Quote:
Originally Posted by Shetch
Посмотреть сообщение
Exaxtly, that's what I did.
It reads from the dini file and saves the Ip adress to PlayerInfo[playerid][pIP].

Afterwards it just prints it out.
Oh I misread it, my bad. Thanks.


Re: CMD not returning IP address to user. - Shetch - 10.01.2013

Tell me if it works.