2 questions
#1

Hi.

First, when someone disconnects it always says 255.255.255.255

pawn Код:
public OnPlayerDisconnect(playerid, reason)
{
    new IP[16], string[128];
    GetPlayerIp(playerid, IP, sizeof(IP));
    for (new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerAdmin(i))
        {
            switch(reason)
            {
                case 0: format(string, sizeof(string), "%s. IP: %s. has left the server (Timed out)", PlayerName(playerid), IP);
                case 1: format(string, sizeof(string), "%s. IP: %s. has left the server (Quit)", PlayerName(playerid), IP);
                case 2: format(string, sizeof(string), "%s. IP: %s. has left the server (Kicked)", PlayerName(playerid), IP);
            }
            SendClientMessage(i, Grey, string);
        }
    }
    return 1;
}
And the second , how to show several Ids in 1 line

like lets say I do somekind of a list it will always show like this

"Namehere(idhere)"

and then make a line right under but I would like to do it like this

"namehere(idhere), "namehere2(idhere2)"

and then at the last there will be no comma?
Reply
#2

1st: When someone disconnects, you cannot retrieve the IP address, it was discussed in the "Bug Reports" section a while back.

2nd: Just format a string, with the data you choose, like so:

pawn Код:
format(string, sizeof(string), "%s(%i), %s(%i), %s(%i)", str, int, str, int, str, int);
(Not a live example and will not work.)

Or did you mean in a dialog?
Reply
#3

1st: so no solution for this? Must be?

2st. Nope just a cmd.
Reply
#4

Try chaning IP to GetPlayerIp(playerid,)
Reply
#5

The first question is possible ive seen it before
Reply
#6

You could use a PVar and save the IP when the player connects
pawn Код:
//OnPlayerConnect:
new PlayerIP[16];
GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
SetPVarString(playerid,"playersIP",PlayerIP);
Then you get the PVarString in OnPlayerDisconnect
Reply
#7

Like this

pawn Код:
GetPVarString(playerid,"PlayerIP",IP,sizeof(IP));
That would work?
I'll test it later, but what about my second question?
Reply
#8

bump
Reply
#9

Honestly, I've never really used PVars, but I gave it a go. I tested this script and it should work:

Put this in OnPlayerConnect:

pawn Код:
new szIP[ 16 ];

//Get the players IP and assign it to szIP
GetPlayerIp( playerid, szIP, sizeof szIP );
   
//Set the PVar to the value of szIP for later use.
SetPVarString( playerid, "p_szIP", szIP );
And put this in OnPlayerDisconnect:

pawn Код:
new szStr [ 128 ],
    szIP  [ 16  ];

//Get the PVar and assign the value to the local variable, szIP.
GetPVarString( playerid, "p_szIP", szIP, sizeof szIP );

for (new i = 0; i < MAX_PLAYERS; i++)
{
    //Loop de loop
    if( IsPlayerAdmin(i) )
    {
        //They're an admin

        switch( reason )
        {
            //Timeout
            case 0:
                format(szStr, sizeof(szStr), "%s. IP: %s. has left the server (Timed out)", PlayerName(playerid), szIP);
       
            //Quit
            case 1:
                format(szStr, sizeof(szStr), "%s. IP: %s. has left the server (Quit)", PlayerName(playerid), szIP);
       
            //Kicked
            case 2:
                format(szStr, sizeof(szStr), "%s. IP: %s. has left the server (Kicked)", PlayerName(playerid), szIP);
        }

        //Send the message
        SendClientMessage(i, Grey, szStr);
    }
}
.. or click here for what they should look like.
Reply
#10

I'll test it later & pm you how it goes.

What about the second question?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)