User ip adress
#1

hey guys.
can someone give me a code for --- onplayerdisconnect ip adress for admins to see

like so when a players leaves, admins will be able to see a persons ip adress.

example: Michael left [123.245.2.32]
Reply
#2

pawn Код:
//ontop of script
forward SendClientMessageToAdmins(color,string[]);

public SendClientMessageToAdmins(color,string[])//sumwhere in script
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if (IsPlayerAdmin(i))
            {
                SendClientMessage(i, color, string);
                printf("%s", string);
            }
        }
    }
    return 1;
}

public OnPlayerDisconnect(playerid,reason);
{
   new ip[128];
   new str[256];
   new name[256];
   GetPlayerName(playerid,name,sizeof(name);
   GetPlayerIP(playerid,ip,sizeof (ip);
   format(str,256,"%s[%s] left the server.",name,ip);
   SendClientMessageToAdmins(yourcolor,str);
   return 1;
}
didn't test it yet tho
tell me if it works^^
Reply
#3

Код:
new ip[128];
   new str[256];
   new name[256];
O.o talk about useless cells.
It should look like this instead:
pawn Код:
new ip[16];
new str[128];
new name[MAX_PLAYER_NAME];
Reply
#4

If you're going to get player's ip at OnPlayerDisconnect callback then it won't work, because there is a bug if you want to get player's ip at OnPlayerDisconnect, it will always show ip 255.255.255.255.
Reply
#5

I'm guessing that doesn't happen all the time? Oh well, I may be wrong, but here's a possible solution:
pawn Код:
//top of script
new PlayerIP[MAX_PLAYERS];

//OnPlayerConnect
ip[16];
PlayerIP[playerid] = GetPlayerIp(playerid, ip, sizeof ip);

//OnPlayerDisconnect
new str[128], name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, MAX_PLAYER_NAME);
for(new i = 0; i<MAX_PLAYERS; i++)
{
  if(IsPlayerAdmin(i))
  {
   format(str, sizeof str, "%s has left the server! (IP: %d)", name, PlayerIP[playerid]);
   SendClientMessage(i, color, str);
  }
}
-- untested
Reply
#6

Quote:
Originally Posted by Swift_
I'm guessing that doesn't happen all the time? Oh well, I may be wrong, but here's a possible solution:
All the time. So the solution is other callback like you did.
Reply
#7

it says that:

symbol already defined: "GetPlayerName"
Line: ip[16]; error 010: invalid function or declaration
line: for(new i = 0; i<MAX_PLAYERS; i++) error 010: invalid function or declaration
Line: if(IsPlayerAdmin(i)) error 010: invalid function or declaration
Reply
#8

Just get the ip when the player connects, store it somewhere, and when they disconnect, show it again.
Reply
#9

I could have sworn I just did that but showed him in code, next time read before posting.
Reply
#10

so what about all these errors?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)