The online racing simulator
Insim Question
(7 posts, started )
Insim Question
I've seen that insim applications are able place handicaps such as intake restriction and weight, but is it possible to limit tire choice? For instance I don't want Road Super tires to be used but other types are ok.

Thank you for any help
In AirAttack Rally, there is such system. As i remember, i wanted to use normal tyres on rally cross. It didnt let me as i remember.
Yes, you could limit the tyre compound that a player uses. Check the compound in the NPL packet and spectate them if they have the wrong type.

struct IS_NPL // New PLayer joining race (if PLID already exists, then leaving pits)
{
byte Size; // 76
byte Type; // ISP_NPL
byte ReqI; // 0 unless this is a reply to an TINY_NPL request
byte PLID; // player's newly assigned unique id

byte UCID; // connection's unique id
byte PType; // bit 0 : female / bit 1 : AI / bit 2 : remote
word Flags; // player flags

char PName[24]; // nickname
char Plate[8]; // number plate - NO ZERO AT END!

char CName[4]; // car name
char SName[16]; // skin name - MAX_CAR_TEX_NAME
[B]byte Tyres[4]; // compounds[/B]

byte H_Mass; // added mass (kg)
byte H_TRes; // intake restriction
byte Model; // driver model
byte Pass; // passengers byte

int Spare;

byte Sp0;
byte NumP; // number in race (same when leaving pits, 1 more if new)
byte Sp2;
byte Sp3;
};

// Tyre compounds (4 byte order : rear L, rear R, front L, front R)

enum
{
TYRE_R1, // 0
TYRE_R2, // 1
TYRE_R3, // 2
TYRE_R4, // 3
TYRE_ROAD_SUPER, // 4
TYRE_ROAD_NORMAL, // 5
TYRE_HYBRID, // 6
TYRE_KNOBBLY, // 7
TYRE_NUM
};

Here is a Python script that does it.

"""Compounds: script to prevent player with ROAD_SUPER tyres from joining a host."""

import pyinsim

def playerJoined(insim, npl):
tyres = (npl['Tyres1'], npl['Tyres2'], npl['Tyres3'], npl['Tyres4'])
if pyinsim.TYRE_ROAD_SUPER in tyres:
insim.send(pyinsim.ISP_MST, Msg='/spec %(PName)s' % npl)
insim.send(pyinsim.ISP_MST, Msg='%(PName)s ^3spectated as using road-super' % npl)

insim = pyinsim.InSim()
insim.bind(pyinsim.ISP_NPL, playerJoined)

try:
insim.connect('localhost', 29999)
insim.send(pyinsim.ISP_ISI, Admin='pass', IName='Compounds')
insim.run()
except pyinsim.socket.error, err:
print 'InSim Error:', err[1]

Quote from DarkTimes :Here is a Python script that does it.

"""Compounds: script to prevent player with ROAD_SUPER tyres from joining a host."""

import pyinsim

def playerJoined(insim, npl):
tyres = (npl['Tyres1'], npl['Tyres2'], npl['Tyres3'], npl['Tyres4'])
if pyinsim.TYRE_ROAD_SUPER in tyres:
insim.send(pyinsim.ISP_MST, Msg='/spec %(PName)s' % npl)
insim.send(pyinsim.ISP_MST, Msg='%(PName)s ^3spectated as using road-super' % npl)

insim = pyinsim.InSim()
insim.bind(pyinsim.ISP_NPL, playerJoined)

try:
insim.connect('localhost', 29999)
insim.send(pyinsim.ISP_ISI, Admin='pass', IName='Compounds')
insim.run()
except pyinsim.socket.error, err:
print 'InSim Error:', err[1]


Looks a little confusing :/

But from what I see here, I can guess it looks up the pyinsim library that you made, defines the 4 tyres on the new player's car from the npl packet and looks to see if any of the tyres match the Road_Super compound. If a player does match the situation it kicks them with a message with the players name that says spectated for using Road_super tyres.

The next section looks like it defines the insim variable from something from your pyinsim library and then I get a little lost after that.

Looks like I have some reading up to do. I didn't even know about Python until today, luckily it looks like it's a free program so i'll be downloading and looking at what I can do with it this week.

This is great if I can combine this with forcing an intake restriction as well for multiple cars

Thank you for the help DarkTimes
Sorry, I understand it might not make much sense if you don't know Python. I've added comments to try to explain each step.

"""Compounds: script to prevent player with ROAD_SUPER tyres from joining a host."""

# Import the pyinsim library.
import pyinsim

# Function which is called when an IS_NPL packet is received.
def playerJoined(insim, npl):
# Create a list of the tyre types the player is using.
tyres = (npl['Tyres1'], npl['Tyres2'], npl['Tyres3'], npl['Tyres4'])
# Check if ROAD_SUPER exists in the list.
if pyinsim.TYRE_ROAD_SUPER in tyres:
# Send a message to spectate the player.
insim.send(pyinsim.ISP_MST, Msg='/spec %(PName)s' % npl)
# Send a message to say that the player was spectated.
insim.send(pyinsim.ISP_MST, Msg='%(PName)s ^3spectated as using road-super' % npl)

# Create an InSim object, which handles the InSim connection with LFS.
insim = pyinsim.InSim()

# Bind the playerJoined event handler, so pyinsim knows to call that function when an IS_NPL packet is received.
insim.bind(pyinsim.ISP_NPL, playerJoined)

try:
# Connect to LFS on this IP and port. localhost means LFS is on the same computer as the Python script.
insim.connect('localhost', 29999)

# Initailise InSim by sending the IS_ISI packet.
insim.send(pyinsim.ISP_ISI, Admin='pass', IName='Compounds')

# This stops the program from exiting while waiting for new packets to arrive.
insim.run()
except pyinsim.socket.error, err:
# Catch any errors which occur when connecting (EG LFS is not running etc..)
print 'InSim Error:', err[1]

Thank you, I could understand what you were doing with that "if" check before but didn't know what the rest was about. Thanks for the help again.

Insim Question
(7 posts, started )
FGED GREDG RDFGDR GSFDG