Here is my CNL code.
<?php
// A client left the server.
private void CNL_ClientLeavesHost(Packets.IS_CNL CNL)
{
try
{
clsConnection Conn = Connections[GetConnIdx(CNL.UCID)];
clsConnection Conn2 = Connections[GetConnIdx(Connections[CNL.UCID].Chasee)];
MsgAll("^6»^7 " + Conn.PlayerName + " ^7(" + Conn.Username + ") disconnected.");
#region ' Robbery Goes to PITS '
if (Conn.UniqueID == RobberUCID && RobInChase == 1)
{
Conn.RobTimerActiv = 0;
MsgAll("^6»^7 " + Conn.PlayerName + " ^7was fined ^1$" + RobCash);
MsgAll("^6»^7 REASON: Escaping from the police!");
Conn.Cash -= RobCash;
RobTimers = 0;
BankTimer.Enabled = false;
BankTimer.Stop();
RobInChase = 0;
IsRobbable = false;
RobberUCID = -1;
}
#endregion
#region ' Specting whilst suspect being Chased '
if (Conn.Chasee != -1)
{
MsgAll("^6»^7 " + Conn.PlayerName + "^7 lost " + Conn2.PlayerName + "^7!");
if (Conn.IsCadet == 1)
{
MsgAll("^6»^7 " + Conn.PlayerName + " was fined ^1$300");
MsgAll("^6»^7 Reason: Losing the chase on Track!");
Conn.Cash -= 300;
}
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 19, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 20, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 20, Conn2.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 21, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 22, Conn.UniqueID);
#region ' Check UCID '
foreach (clsConnection C in Connections)
{
if (C.Chasee == Conn.UniqueID)
{
C.Chasee = -1;
C.ChaseePlayerName = "";
C.ChaseeUsername = "";
C.Busted = 0;
C.ChaseCondition = 0;
C.CTimer = 0;
C.InChaseOrNot = 0;
}
if (C.Username == Conn.JoinedBackupUsername)
{
C.BackupCallerUsername = "";
}
if (C.Username == Conn.BackupCallerUsername)
{
C.JoinedBackupUsername = "";
}
}
#endregion
Conn2.IsBeingChased = 0;
Conn.InChaseOrNot = 0;
Conn.ChaseePlayerName = "";
Conn.ChaseeUsername = "";
Conn.Chasee = -1;
Conn.ChaseCondition = 0;
Conn.JoinChase = 0;
Conn.CTimer = 0;
SirenShutsOff();
}
#endregion
#region ' Suspect Spected whilst being Chased '
if (Conn.IsBeingChased == 1)
{
MsgAll("^6»^7 " + Conn.PlayerName + " ^7was fined ^1$700");
MsgAll("^6»^7 Reason: Leaving as Suspect whilsts Being chased!");
Conn.Cash -= 700;
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 20, Conn.UniqueID);
foreach (clsConnection C in Connections)
{
if (C.Chasee == Conn.UniqueID)
{
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 19, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 20, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 21, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 22, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 23, C.UniqueID);
C.Chasee = -1;
C.ChaseeUsername = "";
C.ChaseePlayerName = "";
C.ChaseCondition = 0;
C.InChaseOrNot = 0;
C.JoinChase = 0;
C.CTimer = 0;
}
}
Conn.IsBeingChased = 0;
SirenShutsOff();
}
#endregion
#region ' Busted Ran Away '
if (Conn.BustedRanAway == 1)
{
foreach (clsConnection C in Connections)
{
if (C.Username == Conn.OfficerUsername)
{
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 39, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 40, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 41, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 42, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 43, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 44, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 45, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 46, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 47, C.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 48, C.UniqueID);
C.OpenBustedBox = 0;
C.BustedUsername = "";
if (C.Chasee != -1)
{
if (C.Chasee == Conn.UniqueID)
{
Conn.Chasee = -1;
Conn.ChaseCondition = 0;
}
}
}
}
if (Conn.AcceptFines == 1)
{
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 39, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 40, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 41, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 42, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 43, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 44, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 45, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 46, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 47, Conn.UniqueID);
InSim.Send_BFN_DeleteButton(Enums.BtnFunc.BFN_DEL_BTN, 48, Conn.UniqueID);
Conn.AcceptFines = 0;
}
MsgAll("^6»^7 " + Conn.PlayerName + " ^7runs away but fined ^1$1800");
Conn.OfficerUsername = "";
Conn.Cash -= 1800;
Conn.BustedRanAway = 0;
}
#endregion
#region ' Account Reset Issue '
if (AccountReset == false)
{
foreach (clsConnection C in Connections)
{
if (C.FailCon == 0)
{
FileInfo.UpdateUserLeave(C);
}
}
}
if (AccountReset == true)
{
AccountReset = false;
}
#endregion
RemoveFromConnectionsList(CNL.UCID); // Update Connections[] list
}
catch { }
}
?>