The online racing simulator
Ah ok, I use my version a lot and it works well but it's true that I never used the autocross objects (so probably not good for me either)
Hell yeah! That's what i need Smile
Need a hand with the pyinsim library, I am just playing around with insim to check live chat of servers, something simple, I know that I need to use "ISP_MSO" packet to get that.
I have this small snippet just for printing in console the chat, but I receive always the error "struct.error: unpack requires a buffer of 12 bytes", sometimes is "buffer of 4 bytes" or "buffer of 2 bytes", whenever a message is on LFS (for user/insim/or lfs itself)

This is my code snippet:

import pyinsim


def req_conns(insim):
insim.send(pyinsim.ISP_TINY, ReqI=1, SubT=pyinsim.TINY_NCN)
insim.send(pyinsim.ISP_TINY, ReqI=1, SubT=pyinsim.TINY_NPL)


def textChat(insim, mso):
print(mso.Msg)


insim = pyinsim.insim('127.0.0.1', 29999, Flags=pyinsim.ISP_MCI | pyinsim.ISP_NPL |
pyinsim.ISF_LOCAL | pyinsim.ISP_MSO, Interval=100, IName=b'Testing')

insim.bind(pyinsim.ISP_MSO, textChat)

req_conns(insim)

pyinsim.run()

This is the whole error printed on console:

Traceback (most recent call last):
File "C:\Program Files (x86)\Python39-32\lib\asyncore.py", line 83, in read
obj.handle_read_event()
File "C:\Program Files (x86)\Python39-32\lib\asyncore.py", line 420, in handle_read_event
self.handle_read()
File "c:\Users\User\Desktop\PyInsim\pyinsim\core.py", line 354, in handle_read
self._dispatch_to._handle_tcp_read()
File "c:\Users\User\Desktop\PyInsim\pyinsim\core.py", line 561, in _handle_tcp_read
self._handle_insim_packet(data)
File "c:\Users\User\Desktop\PyInsim\pyinsim\core.py", line 598, in _handle_insim_packet
packet = _PACKET_MAP[ptype]().unpack(data)
File "c:\Users\User\Desktop\PyInsim\pyinsim\insim.py", line 681, in unpack
self.Msg = struct.unpack('%dsx' % int(self.Size - 9), data[8:])[0]
struct.error: unpack requires a buffer of 12 bytes

I am doing wrong the call of the ISP_MSO? Or is something wrong with the pyinsim library? Using py3 to run it
Sorry juanann, I have fix it some week ago but haven't commit... (done now)
so you can download again or just change :
in insim.py file :
in class IS_MSO(object):

replace :
#self.Msg = struct.unpack('%dsx' % int(self.Size - 9), data[8:])
by :
self.Msg = data[8:].split(b'\x00')[0]
Quote from KingOfIce :Sorry juanann, I have fix it some week ago but haven't commit... (done now)
so you can download again or just change :
in insim.py file :
in class IS_MSO(object):

replace :
#self.Msg = struct.unpack('%dsx' % int(self.Size - 9), data[8:])
by :
self.Msg = data[8:].split(b'\x00')[0]

Thanks! that did it SmileThumbs up

Python - pyinsim - Python InSim library
(158 posts, started )
FGED GREDG RDFGDR GSFDG