Hello
i have this code:
this code checks if the player has a car. but i don't know how to add CarFlags to each other !!
what i mean is, if you are, for example, counting the number of connections who have fbm, you can use an integer or a byte and add one to the counter :
but in the case of Enum (CarFlags), you can't use something like this (+=).
I had this code, but it's too long:
I want the code to check what cars does the player own, and then send a IS_PLC packet with those cars.
Thank you
i have this code:
foreach(string Car in Cars)
{
if (Conn.Cars.Contains(Car))
{
foreach (string CF in Enum.GetNames(typeof(CarFlags)))
{
if (Car == CF)
{
// I want this code here
}
}
}
}
this code checks if the player has a car. but i don't know how to add CarFlags to each other !!
what i mean is, if you are, for example, counting the number of connections who have fbm, you can use an integer or a byte and add one to the counter :
foreach(clsConnection C in Connections)
{
if (Conn.Cars.Contains("FBM"))
{
counter += 1;
}
}
but in the case of Enum (CarFlags), you can't use something like this (+=).
I had this code, but it's too long:
#region ' Set Allowed Cars '
IS_PLC PLC = new IS_PLC();
if (Conn.Cars.Contains("XFG") && !Conn.Cars.Contains("XRG") && !Conn.Cars.Contains("FBM"))
{
PLC.Cars = CarFlags.XFG;
}
else if (!Conn.Cars.Contains("XFG") && Conn.Cars.Contains("XRG") && !Conn.Cars.Contains("FBM"))
{
PLC.Cars = CarFlags.XRG;
}
else if (!Conn.Cars.Contains("XFG") && !Conn.Cars.Contains("XRG") && Conn.Cars.Contains("FBM"))
{
PLC.Cars = CarFlags.FBM;
}
else if (Conn.Cars.Contains("XFG") && Conn.Cars.Contains("XRG") && !Conn.Cars.Contains("FBM"))
{
PLC.Cars = CarFlags.XFG | CarFlags.XRG;
}
else if (Conn.Cars.Contains("XFG") && !Conn.Cars.Contains("XRG") && Conn.Cars.Contains("FBM"))
{
PLC.Cars = CarFlags.XFG | CarFlags.FBM;
}
else if (!Conn.Cars.Contains("XFG") && Conn.Cars.Contains("XRG") && Conn.Cars.Contains("FBM"))
{
PLC.Cars = CarFlags.XRG | CarFlags.FBM;
}
else if (Conn.Cars.Contains("XFG") && Conn.Cars.Contains("XRG") && Conn.Cars.Contains("FBM"))
{
PLC.Cars = CarFlags.XFG | CarFlags.XRG | CarFlags.FBM;
}
else if (!Conn.Cars.Contains("XFG") && !Conn.Cars.Contains("XRG") && !Conn.Cars.Contains("FBM"))
{
PLC.Cars = CarFlags.None;
}
PLC.UCID = Conn.UniqueID;
Insim.Send(PLC);
#endregion
I want the code to check what cars does the player own, and then send a IS_PLC packet with those cars.
Thank you