The online racing simulator
Searching in All forums
(51 results)
learjet45
S2 licensed
Edit: disregard that stuff.



still hasn't solved the "Unknown command" problem.
Last edited by learjet45, .
learjet45
S2 licensed

I'm getting an error with the cruise example you so graciously updated
Traceback (most recent call last):
File "C:\Python27\lib\asyncore.py", line 79, in read
obj.handle_read_event()
File "C:\Python27\lib\asyncore.py", line 435, in handle_read_event
self.handle_read()
File "C:\Python27\lib\site-packages\pyinsim\core.py", line 255, in handle_read
self._dispatch_to._handle_tcp(self._recv_buff[:size])
File "C:\Python27\lib\site-packages\pyinsim\core.py", line 462, in _handle_tcp
[callback(self, packet) for callback in bound]
File "C:/Users/Jonathan/Desktop/Pyinsim New/examples/default cruise.py", line 189, in message_out
insim.sendm('^3| ^7Unknown command', ncn.UCID)
UnboundLocalError: local variable 'ncn' referenced before assignment
Server exiting as no hosts connected

Any time I try to use an ! code, that's what Python tells me. That's from the just the converted script, no modifications.


EDIT: I've moved
ncn = connections[mso.UCID]

from
if cmd in CMD_LOOKUP:

to after
args = mso.Msg[mso.TextStart:].split()

and now I'm just getting unknown command every time, no matter if the code exists or not.
Last edited by learjet45, .
learjet45
S2 licensed
DarkTimes, I love you! <3 Thank you so much!

Edit: Getting an error when trying to run it. Python is saying that __file__ isnt defined in the line:
CURRENT_DIR = os.path.dirname(__file__)

I googled a little bit, and then ended up changing it to os.__file__, but that isn't what I wanted :P It works, but its a half-a**ed repair job :P
Last edited by learjet45, .
learjet45
S2 licensed
AFAIK, the closest thing to a mod that is allowable is an insim system on a server. You are not allowed to edit the cars, tracks, etc. I do believe that texture mods are allowed for tracks. And custom skins are obviously allowed. But modding cars is not.
learjet45
S2 licensed
It would be amazing if you could port your cruise example from 1.6.4 to 2.0 pretty please I made a half-a**ed attempt at doing so, and it has failed miserably so far.

Edit: Through my various edits, commenting things out, and whatever else I could think of to try to get the code to work, the issue seems to keep on returning to the player management part of the code.
Last edited by learjet45, .
learjet45
S2 licensed
I'm more curious as to why you are a demo user, yet have access to licensed content.


And I'm with Degats on the cheating. It's a driving aid that you otherwise wouldn't have. If this is something you can't do, learn how to, use the mouse, or get a wheel. It was obviously removed for a reason
learjet45
S2 licensed
Quote from DarkTimes :It's not that there are too many cruise servers, it's that there are too many people asking for cruise servers. I think part of this is down to the fact that no one has ever created a nice, user-friendly cruise server, that people can download and deploy. Really, where is the Lapper or AIRIO of cruise servers?

At the moment if people want a cruise server they have to download and compile a buggy Visual Studio solution, learn how to program and spend hours tweaking the code, even just to add there own server name.

I've said this for the last few years, but you guys need to get together and create a full user-friendly configurable cruise server that "normal" people can download, the way that the Lapper guys have done. A real program with configuration and help files, that someone who isn't a programmer can actually understand.

If you do this, not only will you reduce about 99% of the spam on the programmer forum, you'll become heroes. Hell you could probably even charge money for it!

If I could actually code well, I would do something like this :P However, my coding skills fail. I think Python would be good for this though Very easy to learn language.
learjet45
S2 licensed
I'd just like to say:
I love you! Downloading to try it out
learjet45
S2 licensed
Perhaps it might help to say what type of script you need help with?
learjet45
S2 licensed
http://www.lfsforum.net/search.php?searchid=4002384

Quote from bunder9999 :it's probably just LSC's insim with a bunch of string changes.

And you're probably right.
learjet45
S2 licensed
You can host a server yourself using the Live For Speed Dedicated Server files.

However I highly doubt you will find anyone who will just rent a live for speed server for you. Even if the LFS Server files are free, hosting them is not. People make businesses out of running game servers, and free servers are no exception.
learjet45
S2 licensed
:/
I also asked DarkTimes via PM if he was alright with me changing it just to be sure. Otherwise I wouldn't have done it if he said no.
learjet45
S2 licensed
Quote from DarkTimes :I must say this is one of the better programmer requests I've seen on this forum, so I really hope you find someone to work on this with you. You could have maybe mentioned a little more about the platform and language you expect the programmer to work in, but aside from that you have earned the coveted DarkTimes seal of approval.




I've actually been messing around with DarkTimes' cruise script he wrote for Pyinsim. It has a couple neat features I added. I can send it to you if you want (as long as you don't give it to anyone). It's for pyinsim. I haven't finished the license system yet, but it's coming along. Let me know. msn is [email protected]
learjet45
S2 licensed
Quote from DarkTimes :I misspelled the word 'metres'.

Try:

def cmd_location(ncn, args):
if ncn.vars.on_track:
# Get XYZ and convert to meters
last_pos = ncn.vars.last_pos
x = pyinsim.metres(last_pos[0])
y = pyinsim.metres(last_pos[1])
z = pyinsim.metres(last_pos[2])

# Send message
insim.sendm('^3| Location: %d %d %d' % (x, y, z), ncn.UCID)
else:
insim.sendm('^3| You are not on track', ncn.UCID)


Will try, thanks! Totally missed that myself :P
learjet45
S2 licensed
Tried it, doesn't seem to work.

>>> Traceback (most recent call last):
File "C:\Python264\lib\site-packages\pyinsim\pyinsim.py", line 2570, in __recvThread
[self.__recv(sock) for sock in socks]
File "C:\Python264\lib\site-packages\pyinsim\pyinsim.py", line 2591, in __recv
[self.__onPacketData(pdata) for pdata in self.__buffer]
File "C:\Python264\lib\site-packages\pyinsim\pyinsim.py", line 2608, in __onPacketData
if isp: self.event(ptype, packet)
File "C:\Python264\lib\site-packages\pyinsim\pyinsim.py", line 2475, in event
[callback(self, *args) for callback in self.__callbacks[evt]]
File "C:\Users\Jonathan\Pyinsim 164 beta\examples\cruise.py", line 407, in message_out
CMD_LOOKUP[cmd0](ncn, cmd[1])
File "C:\Users\Jonathan\Pyinsim 164 beta\examples\cruise.py", line 174, in cmd_location
x = pyinsim.meters(last_pos[0])
AttributeError: 'module' object has no attribute 'meters'

learjet45
S2 licensed
Thanks DarkTimes!
Edit:
Can I get some help with an !location or !position code

I have tried to make a code to print out the users coordinates (doesnt have to be a certain user, just the user who types it), but can't seem to get it.

Thanks!
Last edited by learjet45, .
learjet45
S2 licensed
I've picked up my cruise script project again thanks to DarkTimes's base script with 1.6.4 beta, and I'm loving it.
I've been doing some changes and additions, and so far so good. Except one thing.
I've tried making an !give code to send other users money. It's not very advanced and I know it will let you send money to yourself. but what I need to get done first is it actually giving money. Here is what I have:

#Change cash level
def cmd_give(ncn, args):
if args:
for arg in args:
ncn = arg.split(':')[-0]
amt = arg.split(':')[-1]
#insim.sendm('^3| ^7You are trying to send %s $%s' % (user, amt))
ncn.vars.cash += amt
insim.sendm('cash changed')

The commented out line was for testing. I was trying to get it to say you are sending whatever user a certain amount. However that failed. It would print out 2 messages, saying "You are trying to send user $user" and "You are trying to send 1 $1".
Even though I figured I would have issues, I tried to keep going. Basically, I got as far as that. Any ideas? Here is what python shell tells me:

>>> Traceback (most recent call last):
File "C:\Python264\lib\site-packages\pyinsim\pyinsim.py", line 2570, in __recvThread
[self.__recv(sock) for sock in socks]
File "C:\Python264\lib\site-packages\pyinsim\pyinsim.py", line 2591, in __recv
[self.__onPacketData(pdata) for pdata in self.__buffer]
File "C:\Python264\lib\site-packages\pyinsim\pyinsim.py", line 2608, in __onPacketData
if isp: self.event(ptype, packet)
File "C:\Python264\lib\site-packages\pyinsim\pyinsim.py", line 2475, in event
[callback(self, *args) for callback in self.__callbacks[evt]]
File "C:\Users\Jonathan\Pyinsim 164 beta\examples\cruise.py", line 267, in message_out
CMD_LOOKUP[cmd0](ncn, cmd[1])
File "C:\Users\Jonathan\Pyinsim 164 beta\examples\cruise.py", line 231, in cmd_give
ncn.vars.cash += amt
AttributeError: 'str' object has no attribute 'vars'

learjet45
S2 licensed
Quote from tmehlinger :Warning, I'm planting the seed for a free software argument...

Since it appears that you're new to Python/InSim programming, you might as well just post your code. I doubt you or your friend are doing anything really revolutionary with InSim that warrants keeping the code secret. Furthermore, if/when you're making mistakes, it's extremely likely that we've made the same mistakes ourselves and we'll be able to advise you better.

By the same token, it's a nice gesture to share your code since you're using someone else's freely given code in the same application.

I'm not totally new to Python, and neither is my friend.
he just doesn't like his codes floating around in the open without his consent.
I have no problem sending you the code. If you PM me I'll send you a link. I'm just not used to Insim programming. I have some basic experience with Python. I'm no major coder or anything, but it's not like I have never written a single line of code in my life.
learjet45
S2 licensed
Well alrighty then.
New idea time. I'll see how this new idea goes and see what I can do.
Last edited by learjet45, . Reason : typo and updated
learjet45
S2 licensed
Quote from DarkTimes :Does a message come up within LFS before it closes? It could be that you are not sending the ISI initialisation packet, alternatively it could be that the game admin password you've supplied is incorrect.

Another cause could be that you've neglected to include a call to InSim.run() in your program, which prevents your program from exiting while the connection is still active. If you look at the example code I posted you can see run() being used.

cut

A Python program will exit as soon as it reaches the end of the main program thread, regardless of any background threads which may be running (like the ones in pyinsim listening for packets). When this happens Python will release all the resources used by your program, causing the socket connection with LFS to be closed. Calling run() prevents this by telling your program to wait until all the background threads have completed before continuing.

I've got the initialization packet, the run(), and the correct admin password

The end of my code:
try:
insim.connect('192.168.1.104', 29999)
insim.send(pyinsim.ISP_ISI, Admin='Not For You to Know', IName='^3pyinsim')
insim.send(pyinsim.ISP_TINY, ReqI=1, SubT=pyinsim.TINY_NPL)
insim.run()
except pyinsim.socket.error, err:
print 'InSim Error:', err[1]

And right before that:
insim = pyinsim.InSim()
insim.bind(pyinsim.ISP_NCN, connectionJoined)

Quote from tmehlinger :Also make sure you're binding EVT_ERROR.


def insim_error(insim, error):
print 'InSim error: ', error

insim.bind(pyinsim.EVT_ERROR, insim_error)

If you are running insim.run() as DarkTimes mentioned above, it could very well be that your code is bombing out somewhere and failing silently because the error happens on a child thread (it won't get caught on the main thread where you're doing all your work). This has happened to me.

Alright. I'll try it and see if it helps.

I also had a few return true/return false from the original code from my friend, and I removed those as morpha recommended. Code still works fine. But I still get the
InSim Guest Closed: pyinsim

in live for speed dedi server as soon as I connect. I literally watched the server via teamviewer as I connected, and as soon as I connect right after the Learjet45 connected (learjet45) line, the insim closes the connection to pyinsim or whatever.
I'll try that EVT_ERROR bind and see if that helps.

Edit: That did the trick! Thanks tme! Here is what I get:
InSim error: connectionJoined() takes exactly 4 arguments (2 given)

From python IDLE GUI.
If someone wants the code to look at, again feel free to PM me. I don't want it floating around for anyone to get hold of. My friend and I have tried to keeps our codes as private as possible, especially when it is developed specifically for our servers (in which case, the original code he gave me was made specifically for our clan's server).
Last edited by learjet45, .
learjet45
S2 licensed
Alright. I need some help now.
LFS closes the connection to insim as soon as the I connect. PM me for the file, I don't want it out in the open and neither does my friend who wrote the original code this is based on.
learjet45
S2 licensed
I still gotta hear back from my friend who gave me the code.
In the mean time, I'll try it. Thanks!
learjet45
S2 licensed
Well from what I have of my basic test code (connects to the MySQL database, searches for my username, and sends back info if it is found, next part varies depending on if it is found), and so far so good. I got rid of all my errors with the code and it will run just fine. But for some reason I have to use 192.168.1.104 for my IP for insim instead of localhost, I get the error that insim couldnt connect if I use localhost.
Anyways, I don't know what's up, but as soon as I join my server, insim shuts off basically.
It happens with the sample codes too. As soon as the event happens once (ex a racer speeds over 80 km/h in example 4 i believe), insim closes the connection and doesn't run anymore. How do I keep insim alive so it doesn't shut off?
learjet45
S2 licensed
Quote from morpha :Yes, but pyinsim itself is not a tracker like LFSLapper or AIRIO, which means while it is able to request and receive the information you seek, it does not do so on its own nor does it store it anywhere if you request it.

Perhaps you could post the code you have so we can help you port it to pyinsim?

BTW there is a MySQL module for python 2.6, MySQLdb (windows distros).

Thanks, and I'll see what I can do on my own first. Plus I need permission first to be able to post the code.

Quote from DarkTimes :Yes, feel free to post the code and we can help you port it. In terms of InSim, the username (license name) is sent in the IS_NCN packet when a player joins the host.

This code for example prints out the license name of each player who joins a host.

import pyinsim

def connectionJoined(insim, ncn):
print 'Username', ncn.UName, 'joined host'

insim = pyinsim.insimConnect('localhost', 29999, IName='^3pyinsim')
insim.bind(pyinsim.ISP_NCN, connectionJoined)
insim.run()


Thanks for the sample code! That will help me a lot! And again, I'll wait and see what I can do on my own first before I post the code.
FGED GREDG RDFGDR GSFDG