The online racing simulator
Searching in All forums
(317 results)
Crady
S3 licensed
ok, ok... it only seems to work on my testing place at home with 2 Servers...

Now I found another prolem:

The "real" servers are hosted at 500Servers. I am talking about 4 Server where always 2 Server have the same IP - just different ports...

If I now start the Program it only connects to 2 Server (to one for each IP) instead of all 4..

my hosts are configured like that:

hosts = {'192.168.2.104': 29999, '192.168.2.104': 2998, '127.0.0.1':2997, '127.0.0.1': 29996}

Any Idea? Perhaps I create a 2 Dictionaries? and then loop over 2 Dictionaries?
Crady
S3 licensed
Yes, thats it!

Now it works... Thank you!
Crady
S3 licensed
Ok... I tryed it and got some Problems...

I in only can send the a Message if I am loggend in as Admin and if ther is the command : insim.Run() or in ,y example socket.Run()

But this command stops the program from connecting to the next server... Here is my try so far:

# Ask for Input
Command = str(raw_input('Command?: '))
Adminpass = str(raw_input('Admin Pass?: '))

# Loop over the hosts dictionary.
for host, port in hosts.iteritems():

# Create new InSim object.
insim = Pyinsim.InSim()

# Connect to this server.
insim.Connect(host, port)

# Add connected InSim object to our sockets list.
sockets.append(insim)


# Loop over the sockets
for socket in sockets:
if socket.Connected == True:
print 'connected'
socket.SendP(Pyinsim.Packet(Pyinsim.ISP_ISI, Admin=Adminpass,
IName='^3XXX', ReqI=1))
SendMessage(Command)

socket.Run()

Crady
S3 licensed
Hmm... wrong OS booted now... I can take a closer look on it this afternoon - after the DTM finale

Well exactly it should be a way in which an Admin is able to change a setting to every of his Servers once without connecting to all of them...

e.g. You have 5 server and want to change all of them to have 30 minutes quali. Then you have to connect to all 5 and have to type /qual=30 ... Or you have a guy you don´t want on your Servers, you need to visit all of your Servers and type /ban xyz xdays ... etc...

In this case I just want to create small app doing this at once... If I get this to work I would like to create a GUI... I am not sure if I should create a windows GUI or buttons in LFS...
Crady
S3 licensed
Hi...

After reading a bit in the Pyton book I bought I must say that I seem to be able to do some simple scripts...

But I want to create some insim apps... And this still is my problem:

To configure an amount of Servers I want to create an app wihich asks me "Which Admin Commad?" for Security it also should ask for the Admin Pass.

Then it should connect to to all IPs / Ports entered in a List, execute the commad, end exit insim...

But my problem is how to close the insim after the command and how to open another after this?

Or is it possible to connect to more than one Server at once?

This is my try with the use of your template:

#
# Copyright 2008 Alex McBride.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the Lesser General Public License (LGPL) as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import Pyinsim
import sys


# Init globals
insim = Pyinsim.InSim(Pyinsim.INSIM_TCP)
connections = {}
players = {}
Server = ['192.168.2.104', '127.0.0.1']
Port = [29999, 29998]
# Helper functions.
def SendMessage(msg):
"""Send message to LFS."""
if len(msg) > 64:
insim.SendP(Pyinsim.Packet(Pyinsim.ISP_MSX, Msg=msg))
else:
insim.SendP(Pyinsim.Packet(Pyinsim.ISP_MST, Msg=msg))


def SendMessageConn(msg, ucid=0, plid=0):
"""Send message to a specific connection or player."""
insim.SendP(Pyinsim.Packet(Pyinsim.ISP_MTC, Msg=msg, UCID=ucid, PLID=plid))


#def RequestPlayersConns():
# """Request all players and connections to be sent."""
# insim.SendP(Pyinsim.Packet(Pyinsim.ISP_TINY, ReqI=1, SubT=TINY_NCN))
# insim.SendP(Pyinsim.Packet(Pyinsim.ISP_TINY, ReqI=1, SubT=TINY_NPL))


def GetConnection(ucid):
"""Get connection from UCID."""
return connections[ucid]


def GetPlayer(plid):
"""Get player from PLID."""
return players[plid]


def GetPlayerFromUcid(ucid):
"""Get player from UCID."""
for player in players.itervalues():
if player['UCID'] == ucid:
return player
return None


# TODO: Add more helper functions.


# Packet received events
def VersionCheck(ver):
"""Check the version."""
if ver['InSimVer'] != Pyinsim.INSIM_VERSION:
print 'Invalid InSim version detected.'
sys.exit(0)


def ConnectionJoined(ncn):
"""Add connection to connections dictionary."""
connections[ncn['UCID']] = ncn


def ConnectionLeft(cnl):
"""Delete connection from connections dictionary."""
del connections[cnl['UCID']]


def ConnectionRenamed(cpr):
"""Rename player in connections and players lists."""
connection = GetConnection(cpr['UCID'])
connection['PName'] = cpr['PName']
player = GetPlayerFromUcid(cpr['UCID'])
player['PName'] = cpr['PName']
player['Plate'] = cpr['Plate']


def PlayerJoined(npl):
"""Add player to players dictionary."""
players[npl['PLID']] = npl


def PlayerLeft(pll):
"""Delete player from players dictionary."""
del players[pll['PLID']]


def TookOverCar(toc):
"""Change UCID for player."""
player = GetPlayer(toc['PLID'])
player['UCID'] = toc['NewUCID']


# TODO: Add more packet event handlers.


# Bind events.
insim.Bind({Pyinsim.ISP_VER: VersionCheck,
Pyinsim.ISP_NCN: ConnectionJoined,
Pyinsim.ISP_CNL: ConnectionLeft,
Pyinsim.ISP_NPL: PlayerJoined,
Pyinsim.ISP_PLL: PlayerLeft,
Pyinsim.ISP_CPR: ConnectionRenamed,
Pyinsim.ISP_TOC: TookOverCar})


# Connection lost.
def ConnectionLost():
print 'InSim connection lost.'
sys.exit(0)

insim.ConnectionLost(ConnectionLost)

# Ask for Input
Command = str(raw_input('Command?: '))
Adminpass = str(raw_input('Admin Pass?: '))


# Connect to InSim.

try:
insim.Connect(Server[0], Port[0])
except Pyinsim.socket.error, (ex):
print 'Connection to InSim failed: %s' % (ex.args[1])
sys.exit(0)
else:
# Initailise InSim and request players/connections.
insim.SendP(Pyinsim.Packet(Pyinsim.ISP_ISI, Admin=Adminpass,
IName='^3Pyinsim', ReqI=1))

# send message
SendMessage(Command)

# Keep program thread alive.
insim.Run()
finally:
insim.Close

Crady
S3 licensed
Quote :Sorry, but I'm quite busy with some other projects at the moment, or I should be busy with them, if I wasn't such a slacker. I will help people using Pyinsim all I can, but I can't work on any outside projects specifically at the moment.

I really can imagine that you are very busy - as I am too...

But I now decided to change and spare my projects and believe me, I bought a Video2Brain DVD for Python beginners and a very big book "Python the complete manual"... I guess after watching the video and reading the 1st 100 pages in this book I will be able to understand it more clearly!

My big problem is the LFS insim... I never spent time in that and to be honestly I do not understand anything in the manual which can be found in the doc folder... But thats why you made this great lib... Now I only need to know what I can get from LFS and how to use it

My far away aim is create a webapplication which makes it via user accounts possible to manage the lapper config more easy than scripting a config file... I mean adding/removing/changing autoactions, adding/removing user rights, editing the swear filter, editing the ban list, synchronizing the ban list for several servers of a team... etc...

Well hard dreams.... but lets see, what the future brings
Crady
S3 licensed
Thank you, DarkTime, great one!

I will test your rewritten Code this afternoon and will report! But yet I got some worries in mind: What will happen if the racer at Pole spinns out although he obtained speedlimit? Do all other drivers go to spec then because they "overtake" ?? Well although it is just a "Demo Code" I would like to stay and improve on it... - I would say that spec could be changed with a drive through penalty and the formation lap Funktions itself should be switchable to on/off via a command which only can be applied by an Amdin...

Secondary I have a suggestion to python / Pyinsim itself:

What do you think about developing a good insim application together in this forum to 1st create a usefull app, 2nd to show the possibilities of Python and 3rd help ppl learning Python (espeically Pyinsim)...
Last edited by Crady, .
Crady
S3 licensed
DarkTimes!


Thank you!!!!!!


Ok... I took me some few time today and tried to understand python and your lib a bit...

Well I think I already failed at the start

Ok... As I told you in the PM I sent you I am also intersted in hanling a rolling start and... tataaaaaaaa... you already coded something like that!

But the Problem I have is that any speeding of 1mph causes a spec.

So I tried to change your code a bit. I wanted that a personal rcm appears to the driver who speeded (I dunno how to code buttons yet), then the timer should run, rcm should be cleared by rcc and then if the car still is faster than the limit a spec should follow...

This is my try:

elif ToKph(car["Speed"]) > SPEED_LIMIT:
# Player broke the speed-limit, spec them.
SendMessage("/rcm " + GET_SLOWER)
SendMessage("/rcm_ply " + players[car["PLID"]][0]["PName"])
BlockingTimer(MSG_TIMEOUT)
SendMessage("/rcc_ply " + players[car["PLID"]][0]["PName"])
players[car["Speed"]] = 0
if ToKph(car["Speed"]) > SPEED_LIMIT:
SendMessage("/spec " + players[car["PLID"]][0]["PName"])
SendMessage(SPEEDING_MSG)

But I realized 2 big problems with it:
1.) rcm_ply does not work with Nickname and changing "PName" to "UName" gives me an error...
2.) I become sent to spec anyway even if I slow down under the limit...

I seems to me that the 1st speed I got the message for speeding for is stored somehow and at the "if" it still is over the limit...

So I tryed to set the Speed to 0 manually which seems not to work too...

An other problem I noticed is that there seems to be an endles loop after speeding... because I am not able to join the race later - I always become to spec again as soon as I join...

Any clue?

If I (or we) manage to get this to work my next step will be to create a command like "!rollingstarton" and "!rollingstartoff" to be able to choose wether there will be a rolling start or not. The over-next step should be using a config file and then creating a exe...
Crady
S3 licensed
Really usefull ur app!

The blue flag seems to work really great but the "you are causing a yellow flag" is a bit annoying but on the onther hand usefull for guys crouching around the track to remind them to speed up...

But I got one error message:

After exiting LFS this evening I saw this log:


Welcome to FlagMessages V1
Sucessfully connected to InSim...
LFS Version: S2 0.5Z
InSim Version: 4
Unhandled exception in thread started by
Traceback (most recent call last):
File "Pyinsim.pyc", line 1166, in __ReceiveThread
File "Pyinsim.pyc", line 1187, in __RaisePacketEvent
File "FlagMessages.py", line 176, in PlayerLeft
File "FlagMessages.py", line 77, in GetPlayer
KeyError: 37

I dunno when it happen cause the app window was under the lfs screen...

And here some other (hopefully) short wishes:

- Could you make it possible to choose in cinfig.ini which of the three flags I want to use? Or is it already by making a "#" in front of the msg line?
- It also would be nice to have 2 diferent yellow text: "Yellow: Drive carefully", "You are causing a yellow flag! Be careful!"
- is it possible to turn on a button by a command (for not showing it all the time) wihich causes a personal "Black flag! Your are disqualified! Go to pit now!" to the driver a actually watch when clicking it?
Crady
S3 licensed
BIG FAT THAKS!!!!!!

Seems to work great at a short test!

But I found one problem:

If a yellow flag is shown because of me (me slow at straight to provokate a blue flag) I also get shown a yellow flag... So I can use this one as "Caution! You are to slow! Speed up!"
Last edited by Crady, .
Crady
S3 licensed
Wow! Altough your promises are small I stay excited
Crady
S3 licensed
Nice, but as I requested I only need a insim app that enables me to send an automatically personal rcm to racer having a blue flag. A cool value addon to this would be to be able sending private or public rcm to racers via klick with own or saved text...

I Do not want so many buttons etc. showing up to every racer because I do not know which addon they are using atm. Perhaps forcing them to see buttons your app creates could cause overlaying their own buttons they use with relax e.g. ...
Request: Flag detection to send racers personal rcm or personal message
Crady
S3 licensed
Hi!

I am looking for an insim app which alows me to send a racer who has a blue or yellow flag a personal message via rcm_ply ...

Often racer turn off the falg notification or chat and do not recognice that they become lapped...

As far as I know this does not work with lapper atm...
Crady
S3 licensed
Wow!

sounding great! I do not know, what is possible at the moment, which data you get from LFS, but there are more currently included in your great program (split times, g-meter etc. ...)

Though I can imagine it is a hard time of work I would to suggest you create 2 different sim-views:
1.) Like this you already created - just filled with more data with a new plugin
2.) Soucy´s request: Current position, Position of all racers, their Splits and times, gap, pitted (yes/no)... etc...

Although we are nearly neighbours I cannot help you because I am not able to code... I only have ideas...


EDIT:

if it then is possible to connect both sim-views to one server....
Crady
S3 licensed
Hi...

I really would like to test this program... could you please send me a link to download it somewhere??
Crady
S3 licensed
Hi!

I really would like to throw an eye on it! But the download links are giving a timeout

Could you please fix it or give me a mirror?
Crady
S3 licensed
No, this one only shows information about your own car like speed, rpm, gear etc...

The interesting infos like Gap, Splits, standings etc. are not supported in LFS yet or are not integrated...
Crady
S3 licensed
Sounding very well!

But I have a question:

Do I have to run this program on my machine at home or is it possible to directly start it on the server (like the lapper) and activate it by a special command?

Is it possible to run your program together with lapper or will there be a confilct with the insim ports?

And a improvement option I alo have / or better would like to have:

The program should be able to give penalties if someone overtakes under safety car or full course yellow...

Is this possible?
Crady
S3 licensed
Hi...

I just want to know how the standings are?

I would like to use such a program too...
My first Video I made about 3 month ago...
Crady
S3 licensed
Well here is it...

Not the best but for the first one I made not that bad I think:

http://de.youtube.com/watch?v=Fo0sCq4B64o
Crady
S3 licensed
Ok, thank you for the clarification!
Is it possible to set a dedicated host with custom advertisement?
Crady
S3 licensed
Hi!

Of course it is possible to customize the car skins - and everyone can see your skin if you upload it to LFSworld.

You also can exchange the advertisement at the tracks. Is it possible to upload my own custom advertisement to inform visiters of my host about a comming event etc. ?
Crady
S3 licensed
Hmmm...

That means I should get more grip the more my tires are used - only of course I do not overheat them...

Or at least I should not loose grip until my tires blow because of using all the wear - when I do not overheat them...

My problem is that I only have experience in short races about 5-10 laps and am limited in time to test it out and will have a 60 lap race at weekend...

Thank you!
Tire consumption effecting grip???
Crady
S3 licensed
Hello!

Does the tire consumption effect the grip my tires can provide?

I mean does the time I loose while tire change balance the time I can drive faster with new tires? (When the tires are changed at one pit stop they are about 60% I think)...
Crady
S3 licensed
hmm...

ok.. the Headset I plug in in front USB connectors - may be they have too low power... I will test it on the MoBo Connector...

But the USB Soundcard I connected at the MoBo USB Slot... same scratchy result on PitSpotter Output...

The Sound Quality litening to MP3s for my ears is GREAT (using a Mac - Windows PC only for LFS )
FGED GREDG RDFGDR GSFDG