The online racing simulator
IS_PLC Question
(11 posts, started )
IS_PLC Question
hi, im asking a question how IS_PLC functions?

because i'm creating a race insim in my server using .net C# LFS_External modified source by DarkTimes and added PLC Packet
i tried to create a string for allowed cars list for ex


<?php 
vars Conn 
Connection[GetConnIDX(PLC.UCID)];
if (
Conn.CarsList.contains("XRG"))
{
    
PLC.Cars 2;
}
?>

but seems it doesn't work
any help?

<?php 
vars Conn 
Connection[GetConnIDX(PLC.UCID)];

//Reset their cars first. They have none
PLC.Cars 0;

//Start giving them cars
if (Conn.CarsList.contains("XFG")) PLC.Cars |= 1;
if (
Conn.CarsList.contains("XRG")) PLC.Cars |= 2;
if (
Conn.CarsList.contains("FBM")) PLC.Cars |= 0x80000;
?>

This should work.
Hello I'm goofing around lfs_external and PLC player cars packet


[StructLayout(LayoutKind.Sequential)]
public struct IS_PLC
{

public byte Size;
public Enums.Packets Type;
public byte ReqI;
public byte Zero;
public byte UCID;
public byte Sp1;
public byte Sp2;
public byte Sp3;

[COLOR="Red"] public uint Cars;[/COLOR]

}

And I don't know what to put on "unsigned Cars" to bind it to the carflags

public static byte[] ISP_PLC(byte UniqueID, LFS_External.InSim.Flags.CarFlags Flags)
{
LFS_External.Packets.IS_PLC sourceStruct = new LFS_External.Packets.IS_PLC();
sourceStruct.Size = 12;
sourceStruct.Type = Enums.Packets.ISP_PLC;
sourceStruct.ReqI = 0;
sourceStruct.Zero = 0;
sourceStruct.UCID = UniqueID;
sourceStruct.Sp1 = 0;
sourceStruct.Sp2 = 0;
sourceStruct.Sp3 = 0;
[COLOR="red"] sourceStruct.Cars = LFS_External.InSim.Flags.CarFlags;[/COLOR]
return Util.PacketToData(sourceStruct);
}

Can someone give me a hand please ?
Quote from DarkKostas :

<?php 
vars Conn 
Connection[GetConnIDX(PLC.UCID)];

//Reset their cars first. They have none
PLC.Cars 0;

//Start giving them cars
if (Conn.CarsList.contains("XFG")) PLC.Cars |= 1;
if (
Conn.CarsList.contains("XRG")) PLC.Cars |= 2;
if (
Conn.CarsList.contains("FBM")) PLC.Cars |= 0x80000;
?>

This should work.

I tryed but i got 2 errors "Error 1 Operator '|=' cannot be applied to operands of type 'InSimDotNet.Packets.CarFlags' and 'int' "

"Error 2 Cannot implicitly convert type 'int' to 'InSimDotNet.Packets.CarFlags'. An explicit conversion exists (are you missing a cast?)
"

<?php 
//Replace string AVAILABLE_CARS with the var that a person owns a car
string AVAILABLE_CARS "XRG+LX4+LX6+RB4+XRT+RAC+FZ5+FXO";
string[] AllCars AVAILABLE_CARS.Split('+');

string CurrentCar "";
bool DrivingNotOwnedCar true;
byte PlayerID GetPlayer(UCID);
if (
PlayerID != 255CurrentCar _players[PlayerID].CName;

CarFlags AvailableCars CarFlags.None;
foreach (var 
ThisCar in AllCars)
{
    if (
ThisCar == CurrentCarDrivingNotOwnedCar false;
    
AvailableCars |= CarToPLC(ThisCar);
}

insim.Send(new IS_PLC UCID UCIDCars AvailableCars });
return 
DrivingNotOwnedCar;
?>

You can use it as a function on NPL to check if he doesn't own the car so you can spectate him.
Quote from DarkKostas :

<?php 
//Replace string AVAILABLE_CARS with the var that a person owns a car
string AVAILABLE_CARS "XRG+LX4+LX6+RB4+XRT+RAC+FZ5+FXO";
string[] AllCars AVAILABLE_CARS.Split('+');

string CurrentCar "";
bool DrivingNotOwnedCar true;
byte PlayerID GetPlayer(UCID);
if (
PlayerID != 255CurrentCar _players[PlayerID].CName;

CarFlags AvailableCars CarFlags.None;
foreach (var 
ThisCar in AllCars)
{
    if (
ThisCar == CurrentCarDrivingNotOwnedCar false;
    
AvailableCars |= CarToPLC(ThisCar);
}

insim.Send(new IS_PLC UCID UCIDCars AvailableCars });
return 
DrivingNotOwnedCar;
?>

You can use it as a function on NPL to check if he doesn't own the car so you can spectate him.

great code, but what funcion execute code of CarToPLC?
Oops forgot to add it.

<?php 
        CarFlags CarToPLC
(string CarName)
        {
            switch (
CarName.ToUpper())
            {
                case 
"XRG": return CarFlags.XRG;
                case 
"LX4": return CarFlags.LX4;
                case 
"LX6": return CarFlags.LX6;
                case 
"RB4": return CarFlags.RB4;
                case 
"FXO": return CarFlags.FXO;
                case 
"XRT": return CarFlags.XRT;
                case 
"RAC": return CarFlags.RAC;
                case 
"FZ5": return CarFlags.FZ5;
            }
            return 
CarFlags.None;
        }
?>

I am running this code on InSim.NET by the way.
Quote from DarkKostas :Oops forgot to add it.

<?php 
        CarFlags CarToPLC
(string CarName)
        {
            switch (
CarName.ToUpper())
            {
                case 
"XRG": return CarFlags.XRG;
                case 
"LX4": return CarFlags.LX4;
                case 
"LX6": return CarFlags.LX6;
                case 
"RB4": return CarFlags.RB4;
                case 
"FXO": return CarFlags.FXO;
                case 
"XRT": return CarFlags.XRT;
                case 
"RAC": return CarFlags.RAC;
                case 
"FZ5": return CarFlags.FZ5;
            }
            return 
CarFlags.None;
        }
?>

I am running this code on InSim.NET by the way.

I know, me too. Code work perfect!! Now i want to run the code on LFS External, but i don't know how to run that in External

<?php 
insim
.Send(new IS_PLC UCID UCIDCars AvailableCars });  
?>

(btw thanks for all support )
Yeeey time to play around :P
Thanks DarkKostas

Cup of tea - check
Tv - check
In bed with laptop - check
Remote? ...hmmhm remooote ? aaaaa F#$K ._.
Quote from StickerBomb :I know, me too. Code work perfect!! Now i want to run the code on LFS External, but i don't know how to run that in External

<?php 
insim
.Send(new IS_PLC UCID UCIDCars AvailableCars });  
?>

(btw thanks for all support )

I'd suggest you to start converting your project on InSim.NET as LFS External is now dead and wont be supported. That's what i've done myself in the past.

I can't remember now how to do this in External and I don't think it's possible. You can do a small search by typing "insim." and you will see the available functions. Or else you can contact DarkTimes. I am quite sure he knows more about that.
Quote from DarkKostas :I'd suggest you to start converting your project on InSim.NET as LFS External is now dead and wont be supported. That's what i've done myself in the past.

I can't remember now how to do this in External and I don't think it's possible. You can do a small search by typing "insim." and you will see the available functions. Or else you can contact DarkTimes. I am quite sure he knows more about that.

Ok . Thanks a lot DarkKostas for support.

IS_PLC Question
(11 posts, started )
FGED GREDG RDFGDR GSFDG