2 questions -
fissekarl - 28.05.2011
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?
Re: 2 questions -
Ash. - 28.05.2011
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?
Re: 2 questions -
fissekarl - 28.05.2011
1st: so no solution for this? Must be?
2st. Nope just a cmd.
Re: 2 questions -
Osviux - 28.05.2011
Try chaning IP to GetPlayerIp(playerid,)
Re: 2 questions -
fissekarl - 28.05.2011
The first question is possible ive seen it before
Re: 2 questions -
Fj0rtizFredde - 28.05.2011
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
Re: 2 questions -
fissekarl - 28.05.2011
Like this
pawn Код:
GetPVarString(playerid,"PlayerIP",IP,sizeof(IP));
That would work?
I'll test it later, but what about my second question?
Re: 2 questions -
fissekarl - 29.05.2011
bump
Re: 2 questions -
blewert - 29.05.2011
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.
Re: 2 questions -
fissekarl - 29.05.2011
I'll test it later & pm you how it goes.
What about the second question?