The online racing simulator
LFSLapper Adding ISP_JRR (Join Request Reply) InsimPacket
Hi everyone,

Today i started with implementing a new Insimpacket for LFSLapper.
The Packet i try to implement is the JRR (Join Request Reply) insimpacket.

With this packet you can allow or refuse a join request from a player ( Player is allowed or not allowed tojoin the race). Also with this packet you can Spawn the players car to a differend location or you can reset theire car without repairing the damage.

The following Command/Function that you might use after releasing the first testversion of LFSLapper, should look like this.


<?php 
CASE "!jrr":
            
$X_Axis 0;  #X axis SpawnPoint
$Y_Axis 0;  #Y axis SpawnPoint
$Z_Axis 0;  #Z axis SpawnPoint
$Flags 128;  #Move car (128) else (0)
$Heading 0;  #Heading of the players car at Spawnpoint
$UCID 0;   #Connection's unique id (0 = host)
$PLID getcurrentplayervar("PLID");  #Player's unique id
$JRRAction 5;  #Type of action.
            
joinrequest($X_Axis $Y_Axis $Z_Axis $Flags ,$Heading $UCID $PLID ,$JRRAction); #Send Data to LFS

BREAK;
?>

After alot of struggling with getting data from LFS , i managed to get move my car to differend location.
I hope that the rest of the test goes well without to many errors.

UPDATE: Released testversion: 7.0.4.2 (see post 10 for changelog)




Have a nice day

Bass-Driver([DanTaco])
Update:

It doesnt go well and i might need help from a another programmer.

Let me explain.

It doesnt spawn my car to the right position, after sending the position where i want to get spawned.
I send my position to LFS with the following script:


<?php 
$X_Axis 
1;      #X axis SpawnPoint 
$Y_Axis 1;      #Y axis SpawnPoint
$Z_Axis 0;      #Z axis SpawnPoint
$Flags 128;      #Move car (128) else (0)
$Heading 30;  #Heading of the players car at Spawnpoint
$UCID 0;       #Connection's unique id (0 = host)
$PLID getcurrentplayervar("PLID");  #Player's unique id
$JRRAction 5;  #Type of action. Reset without repair
            
joinrequest($X_Axis $Y_Axis $Z_Axis $Flags ,$Heading $UCID $PLID ,$JRRAction); #Send Data to LFS
?>

This function will be executed in the sourcecode of LFSLapper

<?php 
public void joinrequest(GLScript.unionVal valArrayList args)
{
//short X, short Y, byte Zbyte, byte Flags, byte Heading, byte UCID, byte PLID, byte JRRAction
byte[] jrr myEncoder.JRR(short.Parse(args[0].ToString()), short.Parse(args[1].ToString()), byte.Parse(args[2].ToString()), byte.Parse(args[3].ToString()), byte.Parse(args[4].ToString()), byte.Parse(args[5].ToString()), byte.Parse(args[6].ToString()), byte.Parse(args[7].ToString()));
insimConnection.Send(jrrjrr.Length);
}
?>

This code send the data to the JRR packet:


<?php 
public byte[] JRR(short Xshort Ybyte Zbytebyte Flagsbyte Headingbyte UCIDbyte PLIDbyte JRRAction//Join Request Reply - send one of these back to LFS in response to a join request
        
{
            
byte[] packet = new byte[16];
            
packet[0] = 16;
            
packet[1] = (byte)TypePack.ISP_JRR;
            
packet[2] = 0;                  
            
packet[3] = PLID;               //Player's unique id (if zero, use UCID) // ZERO when this is a reply to a join request - SET to move a car
            
packet[4] = UCID;               //Connection's unique id (0 = host) // set when this is a reply to a join request - ignored when moving a car
            
packet[5] = JRRAction;          //JRR Action
            
packet[6] = 0;                  //Spare
            
packet[7] = 0;                  //Spare

            //Convert Short X into 2 bytes
            
packet[8] = (byte)(>> 8);
            
packet[9] = (byte)(255);
            
//Convert Short Y into 2 bytes
            
packet[10] = (byte)(>> 8);
            
packet[11] = (byte)(255);

            
packet[12] = Zbyte;             //Z Pos
            
packet[13] = Flags;             //Flags
            
packet[14] = 0;                 //Index
            
packet[15] = Heading;           //Heading

            //DebugMessages to see data for each packet (Console)

            
for (int i 016i++)
            {
                
Console.WriteLine("Packet: "" = " +  packet[i]);
            }
            return 
packet// send packet to lfs
        
}
?>

LFSLapper send this packet to LFS

In the console it looks like this:

https://www.lfs.net/attachment/145870

And when i get spawned, i type a command to see my current position

https://www.lfs.net/attachment/145873


Things i did to attempt fixing it:

-X/Y axis divide by 16 ( didnt work)
-Other bit-converters (Short > 2 Bytes) ( Didnt work)

So i hope someone can help me.
Attached images
Packetinfo.jpg
Packetinfo1.jpg
..
I know i'm a bit to late with adding the JRR packet.
Its just because the head developers: Gai-Luron and Krayy stop theire development of LFSLapper. So i thought to update the LFSLapper library with adding new insimpacket(as a noob programmer). I've managed to add 4 new insimpackets with succes and now i'm trying to add the JRR packet.

I red those posts yesterday , i'v used the search option on this forum and searched for "JRR". But non of those posts could help me.

So that why to asked for help.
Anyway,Thank you to give me those links. Could be handy for the future.
..
Sending a 1 for X-axis or Y-Axis = 16 ingame. So 2 is 32 etc.

So i thought to change the code with dividing the sending X/Y axis values by 16, gives me the next result.


<?php 
//Convert Short X into 2 bytes
packet[8] = (byte)((>> 8)/16); //Divide by 16
packet[9] = (byte)((255)/16); //Divide by 16
//Convert Short Y into 2 bytes
packet[10] = (byte)((>> 8)/16); //Divide by 16
packet[11] = (byte)((255)/16); //Divide by 16
?>

Sending 0 to 15 for X/Y axis displays 0 for X/Y ingame. But sending 16 displays 16 ingame ( which is good right), but sending 17 - 31 Displays still 16 ingame.


Input X/Y Axis >> Output

0-15 >> 0
16 >> 16
17-31 >> 16
32 >> 32
33-47 >> 32
48 >> 48
etc

The heading packet (packet[15]) seems to work fine.

I have a question about the ZByte Packet (Packet[12]). When i send ZByte = 4 i should spawn in the air?( i know, i will fall down to the track). Because the Height of the spawnplace is 2. But i get spawned on the track. Does it work this way or is this also wrong?
..
Well i'v fixed it yaay

I did the Short to 2 Bytes conversion wrong.

Was

<?php 
//Convert Short X into 2 bytes
packet[8] = (byte)(>> 8); //Shift by 8 bits
packet[9] = (byte)(255);
//Convert Short Y into 2 bytes
packet[10] = (byte)(>> 8); //Shift by 8 bits
packet[11] = (byte)(255);
?>

is now

<?php 
//Convert Short X into 2 bytes
packet[8] = (byte)((16) & 255);
packet[9] = (byte)((16) >> 8); //Shift by 8 bits
//Convert Short Y into 2 bytes
packet[10] = (byte)((16) & 255); 
packet[11] = (byte)((16) >> 8); //Shift by 8 bits
?>

Infosource: http://stackoverflow.com/quest ... t-between-short-and-bytes

So when i want to X= -95 and Y= 157 , i multiply it with 16 and tada it works.

Now that works, lets play further with this packet.

@Cargame:Thank you for helping
..
Update:

Here is the first testversion that includes the JRR insimpacket:


The commands+Info can you find in the LFSLapper.lpr file.
For now i only want to test the reset function of this JRR packet.


<?php 
#########################################################
        #JRR Command Info:
        #########################################################
        
        #########################################################
        #########RESET YOUR CAR (with or without repair)#########
        #########################################################
        
        
Set $Flags 128;
        
Set $UCID 0;
        
$PLID getcurrentplayervar("PLID");  #PLayer's unique ID
        
or
        
$PLID players id here;  #PLayer's unique ID
        
To see your PLID type !plicid
        
        
If you want to reset your car on your current position:
        
            
$X_Axis getcurrentplayervar("X");      #X axis SpawnPoint
            
$Y_Axis getcurrentplayervar("Y");        #Y axis SpawnPoint
            
$Z_Axis getcurrentplayervar("Z");        #Z axis SpawnPoint
        
ELSE
        
            
$X_Axis 0;      Fill in the X coordinate
            $Y_Axis 
0;      Fill in the Y coordinate
            $Z_Axis 
0;      Fill in the Z coordinate
            You can drive to a location 
and type !zone to see the coordinates of that location
            
        $JRRAction 
4; = Reset with repair
        $JRRAction 
5; = Reset without repair
        
###################################################
        
*/
        CASE 
"!jrr":
            
privmsg("Test JoinRequest");
            
$X_Axis getcurrentplayervar("X");      #X axis SpawnPoint
            
$Y_Axis getcurrentplayervar("Y");      #Y axis SpawnPoint
            
$Z_Axis getcurrentplayervar("Z");      #Z axis SpawnPoint
            
$Flags 128;      #Move/Reset car (128) else (0)
            
$Heading 0;  #Heading of the players car at Spawnpoint
            
$UCID 0;       #Connection's unique id (0 = host)
            
$PLID getcurrentplayervar("PLID");  #Player's unique id
            
$JRRAction 4;
                
            
joinrequest($X_Axis $Y_Axis $Z_Axis $Flags ,$Heading $UCID $PLID ,$JRRAction); #Send Data to LFS
        
BREAK;
        CASE 
"!plicid":
          
privmsg("Your UCID: ".getcurrentplayervar("UCID"));
          
privmsg("Your PLID: ".getcurrentplayervar("PLID"));
        BREAK;
        
###################################################
?>

Other Fixes/Changes in this version:


+-------------------------------+
|Changes from 7.0.4.1 to 7.0.4.2|
+-------------------------------+
1. New Function: joinrequest(); JRR Insimpacket

2. Changed:

Characterlenght increased to 120 chars instead of 67 for the following functions:
Privmsg();
GlobalMsg();

3. Fixes:
#########
Fixed Typo's & Changing Pitworks in sourcefile Insim4.cs ( Thanks to Iceman121 for reporting the typo's and idea's)

-Mechanicals Damages >> Mechanical Damage
-Body Dammage >> Minor Damage
Major Damage

-Refuel >> Refuelling
-Wheels & Transmissions >> Wheels
#########
Sourcecode bugfix: in GLScript.cs ( Thanks to Yisc[NL] for reporting the bug)
Link of report: https://www.lfs.net/forum/post/1906238#post1906238
#########
Sourcecode bugfix (CSC) (CarState Packet) implemented in version 7.0.4.1
LFSLapper crashed after getting player without a username (HOST)
#########
Minor bugfixes in LFSLapper.lpr ( Thanks to Yisc[NL] for reporting the bug)
Link of report: https://www.lfs.net/forum/post/1906123#post1906123

As I can turn off these messages?
Quote from cargame.nl :Smile

(strange language though, thats why I dont like C# .. makes no sense to me Tongue )

Nothing here with C#, just binary math. Same in every language.
I have the following error

6/21/2017 9:01:49 AM -> Syntax error in cfg file ".\default\SISTEMAS.lpr" at line #456
You can't change the dimension of an array... use unSet( $X_Axis ); before


Can it be something I deleted from LFSLapper.lpr?
No, the error means you are mishandling an array Smile
Quote from Yisc[NL] :No, the error means you are mishandling an array Smile

The code is the same as the one published by Bass-Driver


<?php 
CASE "!jrr":
            
privmsg("Test JoinRequest");
            
$X_Axis getcurrentplayervar("X");      #X axis SpawnPoint
            
$Y_Axis getcurrentplayervar("Y");      #Y axis SpawnPoint
            
$Z_Axis getcurrentplayervar("Z");      #Z axis SpawnPoint
            
$Flags 128;      #Move/Reset car (128) else (0)
            
$Heading 0;  #Heading of the players car at Spawnpoint
            
$UCID 0;       #Connection's unique id (0 = host)
            
$PLID getcurrentplayervar("PLID");  #Player's unique id
            
$JRRAction 4;
                
            
joinrequest($X_Axis $Y_Axis $Z_Axis $Flags ,$Heading $UCID $PLID ,$JRRAction); #Send Data to LFS
        
BREAK;
        CASE 
"!plicid":
          
privmsg("Your UCID: ".getcurrentplayervar("UCID"));
          
privmsg("Your PLID: ".getcurrentplayervar("PLID"));
        BREAK;
?>

-
(donatas.s) DELETED by donatas.s

FGED GREDG RDFGDR GSFDG