02.04.2010, 11:57
When a player disconnects,, sometimes, instead of saying that guys name says another's...
If i disconnect to others appears that someone else disconnected.
Here is the code i have at OnPlayerDisconnect.
Here's the GetPlayerNameEx if needed:
Help would be very appreciated.
If i disconnect to others appears that someone else disconnected.
Here is the code i have at OnPlayerDisconnect.
pawn Код:
public OnPlayerDisconnect(playerid,reason)
{
new string[128];
for(new i = 0; i <= MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
switch(reason)
{
case 0: format(string, sizeof(string), "~w~%s ~b~has ~y~joined ~b~the server~w~ (~r~TIME-OUT~W~)",GetPlayerNameEx(i));
case 1: format(string, sizeof(string), "~w~%s ~b~has ~y~joined ~b~the server~w~ (~r~LEAVING~W~)",GetPlayerNameEx(i));
case 2: format(string, sizeof(string), "~w~%s ~b~has ~y~joined ~b~the server~w~ (~r~KICK~w~/~r~BAN~W~)",GetPlayerNameEx(i));
}
TextDrawSetString(Connect,string);
TextDrawShowForAll(Text:Connect);
SetTimer("SendConnectMessageStop",6000,0);
}
}
return 1;
}
pawn Код:
GetPlayerNameEx(playerid)
{
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid,PlayerName,MAX_PLAYER_NAME);
for(new i=0; i <strlen(PlayerName); i++)
{
if(PlayerName[i]==']'){PlayerName[i]=')';}
if(PlayerName[i]=='['){PlayerName[i]='(';}
if(PlayerName[i]=='*'){PlayerName[i]=']';}
}
return PlayerName;
}