Thijs-boy
13th January 2012, 19:09
Here I am again.
First if someone connects to the host, he sees the GUI of the InSim.
But now he cannot see the GUI or anything, the InSim is seeing him as 'host' Also InSim can't see his username. He isn't added to the connections list and also got kicked (by catch)
Continue next post
Thijs-boy
13th January 2012, 19:10
privatevoid AddToConnectionsList(Packets.IS_NCN NCN)
{
bool InList = false;
// Check of connection is already in the list
foreach (clsConnection Conn in Connections)
{
if (Conn.UniqueID == NCN.UCID)
{
InList = true;
continue;
}
}
// If not, add it
if (!InList)
{
try
{
// Assign values of new connnnection.
clsConnection NewConn = newclsConnection();
NewConn.UniqueID = NCN.UCID;
NewConn.Username = NCN.UName;
NewConn.PlayerName = NCN.PName;
NewConn.IsAdmin = NCN.Admin;
NewConn.Flags = NCN.Flags;
if (NewConn.Username != "")
{
// Load Player Database
NewConn.Cars = FileInfo.GetUserCars(NCN.UName);
NewConn.Cash = FileInfo.GetUserCash(NCN.UName);
NewConn.BankBalance = FileInfo.GetUserBankBalance(NCN.UName);
NewConn.TotalDistance = FileInfo.GetUserDistance(NCN.UName);
NewConn.Health = FileInfo.GetUserHealth(NCN.UName);
NewConn.JobsDone = FileInfo.GetUserJobDone(NCN.UName);
NewConn.LottoTimer = FileInfo.GetUserLastLotto(NCN.UName);
NewConn.TowTicket = FileInfo.GetUserTicket(NCN.UName);
// Load Cars Distance
NewConn.UF1 = FileInfo.GetUserUF1Distance(NCN.UName);
NewConn.XFG = FileInfo.GetUserXFGDistance(NCN.UName);
NewConn.XRG = FileInfo.GetUserXRGDistance(NCN.UName);
NewConn.LX4 = FileInfo.GetUserLX4Distance(NCN.UName);
NewConn.LX6 = FileInfo.GetUserLX6Distance(NCN.UName);
NewConn.RB4 = FileInfo.GetUserRB4Distance(NCN.UName);
NewConn.FXO = FileInfo.GetUserFXODistance(NCN.UName);
NewConn.XRT = FileInfo.GetUserXRTDistance(NCN.UName);
NewConn.RAC = FileInfo.GetUserRACDistance(NCN.UName);
NewConn.FZ5 = FileInfo.GetUserFZ5Distance(NCN.UName);
NewConn.UFR = FileInfo.GetUserUFRDistance(NCN.UName);
NewConn.XFR = FileInfo.GetUserXFRDistance(NCN.UName);
NewConn.FXR = FileInfo.GetUserFXRDistance(NCN.UName);
NewConn.XRR = FileInfo.GetUserXRRDistance(NCN.UName);
NewConn.FZR = FileInfo.GetUserFZRDistance(NCN.UName);
NewConn.MRT = FileInfo.GetUserMRTDistance(NCN.UName);
// Load Authorization Level
NewConn.CanBeOfficer = FileInfo.GetUserOfficer(NCN.UName);
NewConn.CanBeTow = FileInfo.GetUserTowTruck(NCN.UName);
NewConn.IsMember = FileInfo.GetUserMember(NCN.UName);
NewConn.CanBeCadet = FileInfo.GetUserCadet(NCN.UName);
NewConn.CanBeMafia = FileInfo.GetUserMafia(NCN.UName);
// Load Player Settings
NewConn.KMHtoMPH = FileInfo.GetSpeedometer(NCN.UName);
NewConn.MilesOrKilometers = FileInfo.GetOdometer(NCN.UName);
NewConn.DistanceToTodays = FileInfo.GetDistView(NCN.UName);
NewConn.HideGUIorNOT = FileInfo.GetDisplayView(NCN.UName);
NewConn.OndutyBox = FileInfo.GetOfficerBox(NCN.UName);
// Load Player Items
NewConn.Item1 = FileInfo.GetUserItem1(NCN.UName);
NewConn.Item2 = FileInfo.GetUserItem2(NCN.UName);
NewConn.Item3 = FileInfo.GetUserItem3(NCN.UName);
NewConn.Item4 = FileInfo.GetUserItem4(NCN.UName);
// Load SuperAdmin Info
NewConn.DetectAdmin = FileInfo.GetUserAdmin(NCN.UName);
NewConn.MessageID = 1;
}
else// To Hoster
{
NewConn.FailCon = 1;
// Load Player Database
NewConn.Cars = "UF1";
NewConn.Cash = 1000;
NewConn.BankBalance = 0;
NewConn.TotalDistance = 0;
NewConn.Health = 100;
NewConn.JobsDone = 0;
NewConn.LottoTimer = 0;
NewConn.TowTicket = 0;
// Load Authorization Level
NewConn.CanBeOfficer = 0;
NewConn.CanBeTow = 0;
NewConn.IsMember = 0;
NewConn.CanBeCadet = 0;
NewConn.CanBeMafia = 0;
// Load Player Settings
NewConn.KMHtoMPH = 0;
NewConn.MilesOrKilometers = 0;
NewConn.DistanceToTodays = 0;
NewConn.HideGUIorNOT = 3;
// Load Player Items
NewConn.Item1 = 0;
NewConn.Item2 = 0;
NewConn.Item3 = 0;
NewConn.Item4 = 0;
}
// Load Bits
NewConn.IsAFK = 0;
NewConn.AFKTimer = 900;
NewConn.CheckAFKTimer = 15;
NewConn.CheckIsAFK = 1;
NewConn.BankBonusTimer = 3600;
NewConn.BonusDone = 0;
NewConn.DistanceSincePit = 0;
NewConn.TripMeter = 0;
// TowTruck Bits
NewConn.IsTowTruck = 0;
NewConn.Towee = -1;
NewConn.IsBeingTowed = 0;
NewConn.TowRequest = 0;
NewConn.TowRUsername = "";
NewConn.AcceptTowRUser = "";
NewConn.TowSiren = 0;
NewConn.TowStart = 0;
// Officer bits
NewConn.IsOfficer = 0;
NewConn.IsCadet = 0;
NewConn.Chasee = -1;
NewConn.IsBeingChased = 0;
NewConn.TrapSpeed = 0;
NewConn.TrapX = 0;
NewConn.TrapY = 0;
NewConn.ChaseePlayerName = "";
NewConn.ChaseeUsername = "";
NewConn.InChaseOrNot = 0;
NewConn.Busted = 0;
// Busted Box
NewConn.BustedUsername = "";
NewConn.OfficerUsername = "";
NewConn.OpenBustedBox = 0;
NewConn.AcceptFines = 0;
NewConn.BustedRanAway = 0;
NewConn.AllowFine = 0;
NewConn.PayFineSet = 0;
// Check In House, Establishments
NewConn.InHouse1 = 0;
NewConn.InHouse2 = 0;
NewConn.InHouse3 = 0;
NewConn.InHouse4 = 0;
NewConn.InHouse5 = 0;
NewConn.InSchool = 0;
NewConn.InShop = 0;
NewConn.InBank = 0;
NewConn.InBank2 = 0;
NewConn.InDisco = 0;
NewConn.InMarket = 0;
NewConn.InGarage = 0;
Connections.Add(NewConn);
}
catch
{
clsConnection NewConn = newclsConnection();
NewConn.PlayerName = NCN.PName;
NewConn.Username = NCN.UName;
NewConn.FailCon = 1;
Connections.Remove(NewConn);
InSim.Send_MST_Message("/kick " + NewConn.Username);
}
}
}
#endregion
// A new client joined the server.
privatevoid NCN_ClientJoinsHost(Packets.IS_NCN NCN)
{
try
{
FileInfo.NewUser(NCN.UName);
AddToConnectionsList(NCN); // Update Connections[] list (don't remove this line!)
#region ' New Cruiser '
if (Connections[GetConnIdx(NCN.UCID)].TotalDistance == -1)
{
MsgAll("^6»^7 " + Connections[GetConnIdx(NCN.UCID)].PlayerName + "^7 is our new cruiser!");
MsgAll("^6»^7 Please welcome him/her to the community!");
InSim.Send_MTC_MessageToConnection("^6»^6 Please Start In ^2UF1/XFG!", NCN.UCID, 0);
InSim.Send_MTC_MessageToConnection("^6»^6 Please Start In ^2UF1/XFG!", NCN.UCID, 0);
Connections[GetConnIdx(NCN.UCID)].TotalDistance += 1;
}
#endregion
#region ' Welcome DFT '
InSim.Send_MTC_MessageToConnection("^6»^7 Welcome, " + NCN.PName, NCN.UCID, 0);
InSim.Send_MTC_MessageToConnection("^6»^6 " + Website, NCN.UCID, 0);
#endregion
#region ' Identify Admin '
if (NCN.Admin == 1)
{
if (Connections[GetConnIdx(NCN.UCID)].DetectAdmin == 1)
{
MsgAll("^6»^7 " + NCN.PName + " ^7is now logged in as Admin!");
}
else if (NCN.UName == "")
{
NCN.Admin = 0;
}
else
{
MsgAll("^6»^7 " + NCN.PName + " ^7is not an admin!");
InSim.Send_MST_Message("/kick " + NCN.UName);
}
}
#endregion
#region ' DFT Member Check '
if (NCN.PName.Contains("^1DFT ^4"))
{
if (Connections[GetConnIdx(NCN.UCID)].IsMember == 0 && Connections[GetConnIdx(NCN.UCID)].DetectAdmin == 0)
{
MsgAll("^6»^7 " + NCN.PName + " ^7is not a DFT Official!");
InSim.Send_MTC_MessageToConnection("^6»^7 Please remove the tag and comeback again!", NCN.UCID, 0);
InSim.Send_MST_Message("/kick " + NCN.UName);
}
}
#endregion
Connections[GetConnIdx(NCN.UCID)].Spectators = 0;
}
catch { }
}
My second problem is the RemoveFromConnectionsList. This was playing since I got the InSim, and I tried many things. Like copying it from other InSims, still doesn't work. When someone disconnect, he is still in connectionlist (before the 1st bug)
// Methods for automatically update Players[] and Connection[] lists
privatevoid RemoveFromConnectionsList(byte ucid)
{
// Copy of item to remove
clsConnection RemoveItem = newclsConnection();
// Check what item the connection had
foreach (clsConnection Conn in Connections)
{
if (ucid == Conn.UniqueID)
{
// Copy item (Can't delete it here)
RemoveItem = Conn;
continue;
}
}
// Remove item
Connections.Remove(RemoveItem);
}
// A client left the server.
privatevoid CNL_ClientLeavesHost(Packets.IS_CNL CNL)
{
try
{
clsConnection Conn = Connections[GetConnIdx(CNL.UCID)];
clsConnection Conn2 = Connections[GetConnIdx(Connections[CNL.UCID].Chasee)];
if (CNL.Reason == Enums.CNL_Reason.LEAVR_DISCO)
{
InSim.Send_MST_Message("/msg " + Connections[GetConnIdx(CNL.UCID)].PlayerName + " ^8disconnected (" + Connections[GetConnIdx(CNL.UCID)].Username + ")");
}
elseif (CNL.Reason == Enums.CNL_Reason.LEAVR_KICKED)
{
InSim.Send_MST_Message("/msg " + Connections[GetConnIdx(CNL.UCID)].PlayerName + " ^8was kicked (" + Connections[GetConnIdx(CNL.UCID)].Username + ")");
}
elseif (CNL.Reason == Enums.CNL_Reason.LEAVR_BANNED)
{
InSim.Send_MST_Message("/msg " + Connections[GetConnIdx(CNL.UCID)].PlayerName + " ^8was banned (" + Connections[GetConnIdx(CNL.UCID)].Username + ")");
}
elseif (CNL.Reason == Enums.CNL_Reason.LEAVR_LOSTCONN)
{
InSim.Send_MST_Message("/msg Lost connection to " + Connections[GetConnIdx(CNL.UCID)].PlayerName + " ^8(" + Connections[GetConnIdx(CNL.UCID)].Username + ")");
}
elseif (CNL.Reason == Enums.CNL_Reason.LEAVR_TIMEOUT)
{
InSim.Send_MST_Message("/msg " + Connections[GetConnIdx(CNL.UCID)].PlayerName + " ^8timed out (" + Connections[GetConnIdx(CNL.UCID)].Username + ")");
}
#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 { }
}
I am using the LSGO InSim.
Written in C++ & Using Microsoft Visual C# 2010 Express
Credits to Skywatcher & Povo
Thank you
PoVo
18th January 2012, 07:00
I think it's something with saving and loading the player accounts.
Try to run the insim program as administrator in Windows. (Right click on .exe -> Run as Administrator)
Thijs-boy
19th January 2012, 05:34
Well, it's possible, I added the Odo for cars.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.