[IMPORTANT] OnPlayerDisconnect!
#1

Hello. I have noticed strange bug in this callback.

Mostly when player disconnects, it shows this:

Код:
Player name: // It is null!
Player IP: 255.255.255.255 // It is invalid!
Parameters "playerid" and "reason" return very strange values.
What is this? Can you fix it?

Thanks.
Reply
#2

You're trying to get a disconnected players name and ip
Reply
#3

Quote:
Originally Posted by dice7
You're trying to get a disconnected players name and ip
Yes, but sometimes it works. And I think, in prev. versions it worked OK. strange
Reply
#4

It's not a bug, OnPlayerDisconnect just doesn't have enough time to store data. You cannot fix it but you can bypass it. Here's a example.

pawn Код:
new
   IP[16],
   name[MAX_PLAYER_NAME],
   format[128];

public OnPlayerConnect(playerid) {
  GetPlayerIP(playerid, IP, 16); GetPlayerName(playerid, name, MAX_PLAYER_NAME);
  return 1;
}

public OnPlayerDisconnect(playerid) {
  format(format, 128, "%s's left IP was: %s", name, IP);
  SendClientMessageToAll(COLOR_WHATEVER, format);
  return 1;
}
It will show their name and IP with no problems, like what you said, sometimes it works sometimes it doesn't but this is the best way to make sure it shows the IP and name all the time.
Reply
#5

The name part works for me..
Reply
#6

Guys. I am not stupid. I was only reporting this. But thanks anyway.
Reply
#7

It should still tell us name and ip of disconnecting player like it can tell us location, health, armour, etc.
Reply
#8

Quote:
Originally Posted by $€ЯĢ
It should still tell us name and ip of disconnecting player like it can tell us location, health, armour, etc.
But sometimes both playerid and reason are invalid numbers... This is the problem.
Reply
#9

The only problem I had with this was, when you /q the moment you connect, the reason will be kicked/banned
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)