OnIncomingConnection Bug
#1

OnIncomingConnection is a new callback (added in 0.3z R2-2) Which is called when a player attemp to join the server.

It will return 3 parameters :
  • playerid (Integer) = That player ID Wants to connect
  • ip_address (String) = Player's IP (length = 15)
  • port (Int) player's port
I Have tested this function, but it has a bug. In this callback , Player's name doesn't returned.

I Have tested it with this way:

pawn Код:
stock PlayerName(playerid)
{
    new
        playerName[MAX_PLAYER_NAME+1];
   
    GetPlayerName(playerid, playerName, sizeof(playerName));
    return playerName;
}
pawn Код:
public OnIncomingConnection(playerid, ip_address[], port)
{
    printf("Incoming connection for player ID %i - (Name : %s) [IP/port: %s:%i]", playerid, PlayerName(playerid), ip_address, port);
    return 1;
}
That isn't because of PlayerName(playerid), Because the result with GetPlayerName is same.

Player Name under this callback is NULL.
Reply
#2

This isn't a bug. This callback is called when an IP address attempts a connection to the server so that means the player is not even connected to the server and it's mainly used to block the connection, not for printing name out; use OnPlayerConnect instead.
Reply
#3

Quote:
Originally Posted by iZN
Посмотреть сообщение
This isn't a bug. This callback is called when an IP address attempts a connection to the server so that means the player is not even connected to the server and it's mainly used to block the connection, not for printing name out; use OnPlayerConnect instead.
So why it returns the pID? If pID returned player Name must be returned too! not player name will be null.
Reply
#4

Quote:
Originally Posted by iFarbod
Посмотреть сообщение
So why it returns the pID? If pID returned player Name must be returned too! not player name will be null.
player id is allocated by server, not by client. Server has allocated their ID before they have really connected.
As of this time, client has not sent their name.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)