The online racing simulator
hi the_angry_angel,
first off nice app
i was wondering if i could maybe get a little help, im no way a programer but i would like to learn, what i want to do is use you app like in the other thread to allow only ppl with a good time at a certain track to be able to race, is there a way to add names without having to manualy add them, i mean like set up an app to quiery LFSW for the usernames with a best time at EX: BL1 with time of 1.15min or less to only be able to join and race?

ill give some info on why i want to do this 1 is that i want to run some small races on a team server, just like 15-25 laps most of the time but i dont want the server filled with ppl who cant race the config fast enough to keep up, therfore i find if they have the times to match they should know the track atleast.

would you be able to help out or anyone else maybe?
thanks racemania
LFSW querying is on my massive list of "things to do" at the moment - once that's implemented it's pretty straight forward to actually acheive I'll get off my arse and pop it up the list a bit if you would like? It's actually something I've been interested in finishing for quite some time..
how i can write some information to file? Useful for some statistic.

if it not externalize do please function - read; write; append; delete;
There are a number of file and general I/O functions built into Lua itself, which you can file under the lua manual/documentation here;
http://www.lua.org/manual/5.1/
thanks. Great tools
Can I try edit api.lua for additional function luaLFSapi:lap, luaLFSapi:spx and so on?

in api.lua
function luaLFSapi:lap(imsg)
print("Parsing LAP")
local n, psize, pty, reqi, plid, pltime, petime, plapsdone, pflags, spare, penalty, numstops, spare2 = bunpack(imsg, "bbbbLLhhbbbb")
return { plid = plid, ucid = ucid, ltime = pltime, etime = petime, lapsdone = plapsdone, flags = pflags, penalty = penalty, numstops = numstops }
end

in test.lua
function testing()
local t = luaLFSapi:lap(imsg)
laptime = t.ltime
print("laptime="..laptime)
end
evt_bind(ISP_LAP, testing)

in console only Parsing LAP . help me
Yes, please feel free. It'd be nice if you could pass them back to me so that I can add them to the main release (you will be added to the notice, etc. files)?

For reference you should really use luaLFS:lap in the testing function, as that is actually created and should have a number of member variables with data set, which might be unaccessible with luaLFSapi:lap used instead
Quote from the_angry_angel :LFSW querying is on my massive list of "things to do" at the moment - once that's implemented it's pretty straight forward to actually acheive I'll get off my arse and pop it up the list a bit if you would like? It's actually something I've been interested in finishing for quite some time..

hi that would be a great to have in the app for one it would make it easier then typing it all in.

just got a question when i add names how do i seperate between each user for example you have
:racers ={ "notme", },

should i add
:racers ={ "notme", }racemania,

then each name after it?

and what are some of the commands that can be used i remember reading a post that said some commands but i cant find the topic anymore ?

thanks racemania
ahh yeah thats the thread i was looking for lol

thanks for the help keep up the great work mate
how i may use IS_LAP data and all other?
i found my mistake. Need function testing(imsg)
in api.lua wrong some data. I correct this.

function luaLFSapi:npl(imsg)
print("Parsing NPL")
local n, psize, pty, reqi, plid, ucid, ptype, pflags, pnameU, plate, vehiclenameU, skinnameU, tyres, hmass, htres, spare, passengers, spare2, spare3, playernum, spare4, spare5 = bunpack(imsg, "bbbbbbhA24A8A4A16A4bbbbibbbb")
print("NPL parsed")
local n, pname = bunpack(pnameU, "z")
local n, cname = bunpack(vehiclenameU, "z")
local n, sname = bunpack(skinnameU, "z")
return { plid = plid, ucid = ucid, ptype = ptype, flags = pflags, pname = pname, plate = plate, cname = cname, sname = sname, tyres = tyres, h_mass = hmass, h_tres = htres, passengers = passengers, nump = playernum }
end
I do my first test script. In LAN we too may set gandicaps

function ver_gand(imsg)
local t = luaLFS:npl(imsg)
local car = "BF1"
local h_tres = 18
local h_mass = 53
if ((t.cname == car) and ((t.h_tres ~= h_tres) or (t.h_mass ~= h_mass))) then
luaLFS:mst("/spec "..t.pname)
luaLFS:mtc(t.ucid, 0, "^C^1------------------------------------")
luaLFS:mtc(t.ucid, 0, "^C^Wrong data in setup!!!")
luaLFS:mtc(t.ucid, 0, "^C^3Correct:")
luaLFS:mtc(t.ucid, 0, "^C^2Restriction - ^618%")
luaLFS:mtc(t.ucid, 0, "^C^2Added Mass - ^653kg")
end
end

evt_bind (ISP_NPL, ver_gand)
Quote from A.Fedorov :I do my first test script. In LAN we too may set gandicaps

function ver_gand(imsg)
local t = luaLFS:npl(imsg)
local car = "BF1"
local h_tres = 18
local h_mass = 53
if ((t.cname == car) and ((t.h_tres ~= h_tres) or (t.h_mass ~= h_mass))) then
luaLFS:mst("/spec "..t.pname)
luaLFS:mtc(t.ucid, 0, "^C^1------------------------------------")
luaLFS:mtc(t.ucid, 0, "^C^Wrong data in setup!!!")
luaLFS:mtc(t.ucid, 0, "^C^3Correct:")
luaLFS:mtc(t.ucid, 0, "^C^2Restriction - ^618%")
luaLFS:mtc(t.ucid, 0, "^C^2Added Mass - ^653kg")
end
end

evt_bind (ISP_NPL, ver_gand)

great work,
so if i read this correctly you can add car mass and restriction?
if so idd be happy to do some testing with you.
Quote from racemania :so if i read this correctly you can add car mass and restriction?

IMHO, if player takes BF1 and he/she doesn't set the restriction exactly to 18% and "added mass" to 53 kg, then the player is forced to spectate.

I think, that this is perfect example of the LUALfs, really easy to use . I hope, that I get some time to test the latest version.
Quote from Kada_CZ :IMHO, if player takes BF1 and he/she doesn't set the restriction exactly to 18% and "added mass" to 53 kg, then the player is forced to spectate.

I read it as the same.

Quote from Kada_CZ : I think, that this is perfect example of the LUALfs, really easy to use . I hope, that I get some time to test the latest version.

I'm sure it'll be a very interesting experience - I had a lot of regressions and cock ups / bugs slip in when I was reving and backporting stuff to 0.6-0.7 Should be releasing a fixed and finished api version next time.
i suggest in api use name data from insim documentation to not mix up

example

struct IS_CPR // Conn Player Rename
{
byte Size; // 36
byte Type; // ISP_CPR
byte ReqI; // 0
byte UCID; // unique id of the connection

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

function luaLFSapi:cpr(imsg)
local n, psize, pty, reqi, ucid, pnameU, plate = bunpack(imsg, "bbbb24A8A")
local n, pname = bunpack(pnameU, "z")
return { ucid = ucid, pname = pname, plate = plate }
end


I try to do this in future.
hi guys, got a question

would there be a way to get LUAlfs to pick up a file from lfslapper or if not could LUAlfs record top lap times, EG: i want to run a comp, but i want the drivers top be able to drive faster then the time for each track in the comps, so when they can drive the track at required times they are then enterd into the file for the race.

i know it sounds hard or may be confusing, basicly any driver that joins the comp must pass a qualify of a lap time first and then they can enter the race. if you get what i mean.

also how could i use ISP_LAP, // 24 - info : lap time to record times sorry as said in a previous post im not even close to a programer and i wouldnt have a clue what to do other then what i read so everything you write i belive lol.

anyways any help i could get or anywhere i can find more info will be great.
thanks racemania


EDIT: ok now i can see it wouldnt work within LUAlfs because how could someone join the race if there name isnt on the list so ill have to still stick to lapper till i can figure out how to save usernames and send them to LUAlfs, ill get there soon enough i spose.
Quote from racemania :EDIT: ok now i can see it wouldnt work within LUAlfs because how could someone join the race if there name isnt on the list so ill have to still stick to lapper till i can figure out how to save usernames and send them to LUAlfs, ill get there soon enough i spose.

The server api example is very much a work in progress. All that needs to be done to fix the connection issue is to send an IS_TINY to request all the current connections and all the current racers when it first connects to the server.
2the_angry_angel
how i can get IS_SPX data when I get IS_LAP? I want write result lap with split data into file.
It will depend on what SubT you set.
may you give me example how get splits time when laps done (IS_LAP event)?

I want create file and append data like this

20061025 16:43:10,repeat,BL1,repeat,XFG,6,2:10.540,0:34.850,1:35.580
Quote from A.Fedorov :may you give me example how get splits time when laps done (IS_LAP event)?

You can't get the SPx info from the laps packet, so what you have to do is record what lap the player is on, and then listen for and record the SPX as they come through, when you receive a lap increment your lap value for that player and add the new split values for the next lap.

Hope that makes sense, I'm afraid it's not a trivial thing to do and I've not got a moment to pop an actual example together right now.
can i know what event started my function?

i want start one function with event NPL,RST,SPX and LAP.

if (event = ISP_RST) then
...
...
end
if (event = ISP_LAP) then
...
...
end

FGED GREDG RDFGDR GSFDG