22.07.2017, 05:52
This my Code in OnPlayerDC
Код:
public OnPlayerDisconnect(playerid, reason) { // Destroy TD // Player disconnected - is there any "special" reason? if(!isempty(PlayerInfo(playerid, DisconnectReason))) { SendClientMessageFormatted(INVALID_PLAYER_ID, COLOR_SILVER_SAND, "%s(%d) has left the server! "HTML_LYNCH"(%s)", PlayerInfo(playerid, UserName), playerid, PlayerInfo(playerid, DisconnectReason)); DCC_SendChannelMessage(Server[CurrentChannel], sprintf("`PART` %s(%d) has left the server! (%s)",\ ReturnPlayerName(playerid), playerid, PlayerInfo(playerid, DisconnectReason))); } // There's no "special" reason - show SA-MP's default ones else { new disconnecttmp[32]; switch(reason) { case 0: disconnecttmp = "timed out/crashed"; case 1: disconnecttmp = "quit the game"; case 2: disconnecttmp = "kicked/banned"; } SendClientMessageFormatted(INVALID_PLAYER_ID, COLOR_SILVER_SAND, "%s(%d) has left the server! "HTML_LYNCH"(%s)", PlayerInfo(playerid, UserName), playerid, disconnecttmp); DCC_SendChannelMessage(Server[CurrentChannel], sprintf("`PART` %s(%d) has left the server! (%d/"#MAX_PLAYERS")",\ PlayerInfo(playerid, UserName), playerid, (Iter_Count(Player) - 1))); } SendDeathMessage(INVALID_PLAYER_ID, playerid, 201); if(PlayerInfo(playerid, ID) != -1 && PlayerInfo(playerid, LoggedIn)) { // Save player data and then reset it SavePlayerData(playerid, true); ResetPlayerData(playerid); foreach(new player_id : Player) { if(PlayerInfo(player_id, LastPM) == playerid) { // Invalidate last pm sent ID to those who sent a PM to this player PlayerInfo(player_id, LastPM) = INVALID_PLAYER_ID; } } } // Hide all turfs to aplayer on disconnect foreach(new i : Turf) { GangZoneHideForPlayer(playerid, i); } static pCount = 0; foreach(new i : Player) { pCount++; if(PlayerInfo(i, IsPlayerSpectating) && PlayerInfo(i, PlayerSpectating) == playerid) { spectateoff(i); } } if((pCount <= Server[MinimumPlayers]) && Server[PendingUpdate]) { SetTimerEx("RestartServer", 7000, false, ""); GameTextForAll("Automatic Server Restart in~n~7 seconds", 6000, 3); } if(DuelInfo[playerid][InDuel] && DuelInfo[DuelInfo[playerid][Opponent]][InDuel] && DuelInfo[playerid][DuelSlot] == DuelInfo[DuelInfo[playerid][Opponent]][DuelSlot]) { new tmp[500]; switch(reason) { case 0: format(tmp, sizeof(tmp), ""HTML_MONZA"[DUEL] "HTML_SHAKESPEARE"%s"HTML_MADISON" has timed-out during a duel. "HTML_SHAKESPEARE"%s"HTML_MADISON" has won this match!", PlayerInfo(playerid, UserName), ReturnPlayerName(DuelInfo[playerid][Opponent])); case 1: format(tmp, sizeof(tmp), ""HTML_MONZA"[DUEL] "HTML_SHAKESPEARE"%s"HTML_MADISON" has left the server during a duel. "HTML_SHAKESPEARE"%s"HTML_MADISON" has won this match!", PlayerInfo(playerid, UserName), ReturnPlayerName(DuelInfo[playerid][Opponent])); case 2: format(tmp, sizeof(tmp), ""HTML_MONZA"[DUEL] "HTML_SHAKESPEARE"%s"HTML_MADISON" has been kicked out from the server during a duel. "HTML_SHAKESPEARE"%s"HTML_MADISON" has won this match!", PlayerInfo(playerid, UserName), ReturnPlayerName(DuelInfo[playerid][Opponent])); } GivePlayerMoneyEx(DuelInfo[playerid][Opponent], DuelInfo[playerid][Bet]*2); StopDuelEx(DuelInfo[DuelInfo[playerid][Opponent]][DuelSlot], playerid, DuelInfo[playerid][Opponent]); SendClientMessageToAll(-1, tmp); } foreach(new turf_id : Turf) { DestroyDynamicMapIcon(PlayerMapIcon[playerid][turf_id]); } DestroyPlayerProgressBar(playerid, PlayerInfo(playerid, ActorHealth)); TextDraw::DestroyPlayerTD(playerid); TextDraw::Destroy******TextDraws(playerid); TextDraw::DeleteGameTD(playerid); return true; }