The online racing simulator
Searching in All forums
(51 results)
learjet45
S2 licensed
I love you even more. <3

And with that you've inspired me to work on connecting python and a MySQL database as I know absolutely nothing about SQLite with PHP, but I have enough crappy PHP code that used MySQL databases that I might be able to do something with it.
Last edited by learjet45, .
learjet45
S2 licensed
DarkTimes I love you! Thanks for the update!
learjet45
S2 licensed
Any plans to update Pyinsim for the new insim packets?
learjet45
S2 licensed
Quote from DarkTimes :Sounds like a scope issue, is there a variable named time somewhere? It sounds like you're redefining the variable time to be an int.

Like this:

import time

# Redefine time to be an int
time = 10

# AttributeError: 'int' object has no attribute 'time'
print time.time()


I can't seem to find the problem. Can I PM you the code to see if you can find the issue?
learjet45
S2 licensed
I have no freaking idea what is casuing this, but it's bothering me, and hopefully you can help

I don't know what I did or didn't do to cause this. But here's the thing:
I have all my imports at the beginning of my cruise.py file. Including import time for a lottery system. Problem is, when I try to use it, unless I have import time in the chunk of code for the cmd_lottery, I get an error that crashes the insim.
AttributeError: 'int' object has no attribute 'time'

It's bothering me. Any ideas why this would happen DarkTimes?
learjet45
S2 licensed
Firstttt!

No seriously, I've been on the LTC server waiting for like 30 minutes. Can't wait!
learjet45
S2 licensed
I think there should be moderator approval for new topics to be posted in this board... Some of these are pretty pointless. If you can't find one of the many available cruise server options already available without asking someone to do it for you, you shouldn't be running a server.
learjet45
S2 licensed
You're amazing. <3 Thank you very much!
learjet45
S2 licensed
Here is what happens:
I type !save
I get the "The users have been saved" message
Can keep driving, insim works fine.
But:
If I restart insim (whether closing Python shell and starting insim again, or just hitting F5 to restart insim), I get an error, always relating to user vars:

Exception in thread Thread-1:
Traceback (most recent call last):
File "C:\Python27\lib\threading.py", line 530, in __bootstrap_inner
self.run()
File "C:\Python27\lib\threading.py", line 734, in run
self.function(*self.args, **self.kwargs)
File "C:\Users\Jonathan\Desktop\Pyinsim New\examples\cruise.py", line 157, in heartbeat
draw_osd(insim, ncn)
File "C:\Users\Jonathan\Desktop\Pyinsim New\examples\cruise.py", line 110, in draw_osd
Text='^2Cash: $%d ^7| Total Distance: %.2f Km' % (ncn.vars.cash, ncn.vars.dist))
AttributeError: 'IS_NCN' object has no attribute 'cash'

Tried a second time, ended up being similar, but instead of being with the OSD, it was with adding money. Still, it always comes down to the user vars.
Note: This does not happen if I then disconnect before restarting insim. This issue will not happen in that case, but I'm trying to make it so people don't have to reconnect to have their stats saved while I'm working with the script.

My user file after using !save and restarting insim:
http://mr.learjet45.us/uploads/learjet45
User file after someone disconnects and has vars saved that way rather than with !save
http://mr.learjet45.us/uploads/fatcatpaddy
learjet45
S2 licensed
I can't seem to get any !save commands to work. I end up getting errors with variables after using it and restarting insim. This has happened with every !save I've tried.
learjet45
S2 licensed
Quote from tbofram :i guess he didnt get his cruise server running in the end. by the look of (he is on my server)

My guess would actually be that he goes to various different cruise servers to "borrow" their ideas for his own, or at least attempts to. I don't see this guy ever really running his own cruise server.
learjet45
S2 licensed
Came up with a simple suggestion for the cruise insim. I've made life easier by modifying the def init:

def init(insim):
insim.sendm('/canreset no')
insim.sendm('/cruise yes')
insim.sendm('/laps 0')
print '%s is running!' % PROG_NAME
print '%s is the current directory!' % CURRENT_DIR

That way, the server is always configured properly for a cruise server

Also, could you make a simple !save command for me? I've tried making one based off of the "def closed(insim)" you've included in the script, but I can't seem to get it to work properly. I haven't tested recently, but IIRC, I was getting errors with loading variables, so I'm thinking the files didnt save properly.
learjet45
S2 licensed
I feel stupid.
I actually ended up using the add_distance for my !location. I set the car.X, car.Y, and car.Z as variables and then just sent a message with the variables. Man that was stupid. I could've sworn I tried that already...
learjet45
S2 licensed
Holy triple post Batman!
Thanks for the !location help! That will make life a bit easier :P
I was thinking it was the PType, but then I saw that it wasn't always the same so I wasn't sure.
And thanks for the updated script. I'll work on updating the thing later :P I've done quite a bit of coding (gone from about 250 lines of code in the example you wrote to over 1000), and I can't just copy any paste :P Thanks for all the help!
learjet45
S2 licensed
Ah alright. Any ideas on !location?

Oh, and yet another thing. I can't seem to find anything to distinguish AI from regular players with InsimSniffer, and I'm trying to code in AI detection so people can't use AI.
learjet45
S2 licensed
Haha. I completely forgot to mention that :P

Just show x, y, and z coords. Heck I'd even be happy with just x and y. But I cant seem to get anything working.

Edit: Another weird error, and it doesn't always seem to happen. I've had it happen on two separate occasions now. I'm using
insim.sendm('/msg message')

to send a message, but it's being a bit annoying. It's an !onduty command for the cop system I'm working on. Theres both !onduty and !onduty [username]. I can use !onduty for myself fine, and also !onduty user1, but it seems as though when I try it with a different user (eg !onduty user2), lfs server tells me:

IS_MSX - for commands use IS_MST

This also happened at one point with the bonus system I was working on, but I decided to just ignore it then because it for the most part worked fine.
Last edited by learjet45, .
learjet45
S2 licensed
I feel like I'm being a nussiance

Thanks for the help with that. Working like a charm now. New problem though

I can't get a !location command to work to save my life. I've tried everything I can think of, no dice.
learjet45
S2 licensed
Not exactly :P
Here is what I've used for quite a bit of the stuff I've done :P

def get_ncn_by_uname(uname):
ncn = filter(lambda n: n.UName == uname, connections.values())
if ncn:
return ncn[0]
return None

Edit: and one more thing. I'm working on my issue with pitting and what not. However, I cannot seem to figure out how to get the connection info for the player who pitted. I need to define ncn so I can change the ncn.vars.pitting value, but I'm not sure how to go about doing that with the PLP packet.
learjet45
S2 licensed
One (well two related) last question(s) for now :P

How might I go about changing codes so the color doensn't matter? Also, what would I have to do so the wonderful get_ncn_by_uname isn't case sensetive? eg !give learjet45 1000 as well as !give Learjet45 1000 working. I'm thinking something along the lines of storing usernames as lowercase in the connections list/library thing, then use .lower() on the argument string from commands that use it? Or is there a better way to go about doing things?
learjet45
S2 licensed
Thanks mate. I'll have a go at it.
learjet45
S2 licensed
Thanks mate. Works like a charm

One more question. I've added an !tow, and this is also a problem while pitting. I can't quite think of how to fix it, but when you use the !tow (/pitlane) or pit, because the location jumps from where you were on track to the pits, the distance shoots up quite a bit (I've had it go up over a kilometer and a half on WE1R). How can I fix it so when a user users !tow or pits/specs, the distance won't shoot up?
learjet45
S2 licensed
Been messing with the cruise script some more (done quite a bit actually) and I've come to something I can't quite solve.
I'm working on some admin commands (!kick, !ban and such) along with reasons. I'm trying to get it to display the reason to the user. codes work as !kick user [reason is the rest of the args]
reason = args[1:]
insim.sendm('^3| ^1Spectated: ^7%s' % reason, other_ncn.UCID)
insim.sendm('/spec %s' % args[0])

(using the wonderful get_ncn_by_uname you made for me). Problem is, the reason formatting is weird.
| Spectated: ['this', 'is', 'a', 'test']

Is what I see. I just want it to say "this is a test"

Any ideas?
learjet45
S2 licensed
What language?
learjet45
S2 licensed
Quote from Dygear :To the OP, can't you just get this information from the pth or smx files?

It's been over three years since Krammeh posted the topic. I'm pretty sure he has figured out what he needs by now
learjet45
S2 licensed
What exactly was the point of posting something that doesn't make sense and bumping a topic 2 and a half years after the last post?
FGED GREDG RDFGDR GSFDG