The online racing simulator
Searching in All forums
(535 results)
misiek08
S3 licensed
Yeah I can use google but I was asking for example. I'm very busy so learning now from websites isn't best for me. Better is to see a code and analyze it. Faster and easier - for me.
InSim with Mysql (Spark library on mono)
misiek08
S3 licensed
Can anyone make for me an example code to select column bl1_xfg from database zgloszenia server 123.456.789.123, user: test and pass asdqwe123qweasd. I'm using Spark library on Command Line Application runnig by mono on Debian Lenny.
misiek08
S3 licensed
Only 2010 is good working with this library.

EDIT:
DarkTimes was faster...
misiek08
S3 licensed
Show us how are you making this box'es now. Show your code for box'es.
misiek08
S3 licensed
Now you have time to do it
misiek08
S3 licensed
I did multi-bind's and unbinds in PHP. Here it's only other code syntax but everything looks identical but it's your lib and my suggestion are unbinds. Thanks!

Binding some event on MSO packet is good performance idea.
misiek08
S3 licensed
Ok. So I will write the reason. I'am going to make an big application for rolling start, F1 style times comparsion on screen, live tracker, takeover chatcher, point system. Enabling all callback (sometimes 6 on every packet) could kill InSim server so I'm going to make MSO handler for enabling modules of the InSim system. Unbinds should be here for the same reason. Disabling some functionality.
misiek08
S3 licensed
Can I bind and unbind packet events in other packet event. My english is bad so an example:

static void PlayerLeft(IS_PLL pll)
{
// Remove player.
_players.Remove(pll.PLID);
insim.Bind<IS_REO>(AFuncOfREO);
}

And any unbind function?

EDIT: Can I set multibinds?
misiek08
S3 licensed
Thank you, sir. I'm making warm-up lap system with staying at primary position and virtual lights by InSim. Is anything like this done by someone?
misiek08
S3 licensed
Best solution will be to run an InSim with Mysql data, 50ms interval from another machine (not from server hosting) and catch all events and make some math, database and files operations.
misiek08
S3 licensed
using System;
using System.Collections.Generic;
using Spark;
using Spark.Helpers;
using Spark.Packets;

namespace Spark.Example4
{
/// <summary>
/// Example 4: Helpers. Connects to InSim, requests all players to be sent, the prints out
/// the time of each player that completes a lap.
/// </summary>
class Program
{
// We store the players in a dictionary with the PLID as the key.
static InSim insim;
static Dictionary<int, IS_NPL> _players = new Dictionary<int, IS_NPL>();
static Dictionary<int, IS_NCN> _conns = new Dictionary<int, IS_NCN>();

static void Main()
{
// Create new InSim object.
using (insim = new InSim())
{
// Bind handlers.
insim.Bind<IS_NCN>(NewConn);
insim.Bind<IS_CNL>(ConnLeft);
insim.Bind<IS_NPL>(NewPlayer);
insim.Bind<IS_PLL>(PlayerLeft);
insim.Bind<IS_MCI>(MultiCarInfo);

// Establish the InSim connection.
insim.Connect("62.75.188.55", 32002);

// Initialize InSim.
insim.Send(new IS_ISI { IName = "^3MP 2010 DEMO", Admin="janosik123", Prefix = '@', Flags = InSimFlags.ISF_MCI, Interval = 1000});

// Request connections.
insim.Send(new IS_TINY { SubT = TinyType.TINY_NCN, ReqI = 255});

// Request players.
insim.Send(new IS_TINY { SubT = TinyType.TINY_NPL, ReqI = 255});

//insim.Bind<IS_MCI>(MultiCarInfo);

// Prevent program from exiting.
insim.Run();
}
}

static void NewConn(IS_NCN ncn)
{
if(_conns.ContainsKey(ncn.UCID)){
_conns[ncn.UCID] = ncn;
}
else{
_conns.Add(ncn.UCID, ncn);
}
Console.WriteLine("New connection: {0} ({1}) #{2}", ncn.PName, ncn.UName, ncn.UCID);
}

static void ConnLeft(IS_CNL cnl)
{
Console.WriteLine("Connection left: {0} ({1}) #{2} Reason: {3}", getConn(cnl.UCID).PName, getConn(cnl.UCID).UName, cnl.UCID, cnl.Reason);
_conns.Remove(cnl.UCID);
}

static void NewPlayer(IS_NPL npl)
{
if (_players.ContainsKey(npl.PLID))
{
// Leaving pits, just update NPL object.
_players[npl.PLID] = npl;
}
else
{
// Add new player.
_players.Add(npl.PLID, npl);
}
Console.WriteLine("New player: {0} (#{1})", npl.PName, npl.UCID);
}

static void PlayerLeft(IS_PLL pll)
{
// Remove player.
_players.Remove(pll.PLID);
}

static void MessageOut(IS_MSO mso)
{
if(mso.Msg == "something"){

}
}

static IS_NPL getPlayer(byte PLID){
Int32 szukaj = Convert.ToInt32(PLID);
return _players[szukaj];
}

static IS_NCN getConn(byte UCID)
{
Int32 szukaj = Convert.ToInt32(UCID);
return _conns[szukaj];
}

static void spectatePlayer(byte PLID) {
Console.WriteLine("Speeding: {0}", getConn(getPlayer(PLID).UCID).UName);
if (getConn(getPlayer(PLID).UCID).UName == "misiek08")
{
insim.Send(new IS_MST { Msg = ("/spec " + getConn(getPlayer(PLID).UCID).UName) });
}
}

static void MultiCarInfo(IS_MCI mci)
{
// Loop through each car on track.
foreach (var car in mci.CompCars)
{
IS_NPL npl;
npl = getPlayer(car.PLID);
// Convert LFS speed into Mph.
var kph = MathHelper.SpeedToKph(car.Speed);
// Print nicely formatted string to console.
Console.WriteLine("Speed: {0} {1:F2}", npl.PName, kph);
if(kph > 100){
spectatePlayer(car.PLID);
}

}
}
}
}

If on server is someone it won't work. It can't find index is _players Array or _conns. I think, MCI is executed faster than NCN and NPL events.
misiek08
S3 licensed
There is outgauge example. Number 5 or 6.
misiek08
S3 licensed
I know but the 2nd library (External?) is used in Form applications so I thought that .NET External library can't be used in console and Spark looks like it be working on the command line.
misiek08
S3 licensed
Sorry but one more question. Will work Spark library in the command line. I have to read screen content via Perl daemon or SSH2 in PHP or output everything from InSim to debug file and read this file by above written technologies.
misiek08
S3 licensed
So mono, Mysql, .NET and it is succes! We will gonna see it. Now i'm going to make 4 server tracker in PHP - easier than everything else.
misiek08
S3 licensed
Wait!
Sorry for double but edits aren't visible as new posts.

What will be better: Python vs Sparky lib.

I saw an Python example and it looks so easy. MySQL in Python isn't hard too.
misiek08
S3 licensed
C++ is hard to code. I need very simply language. Sparky lib is very easy like for me. PHP it's kiddy. Thanks for replies. I think, I'm gonna check .NET Sparky library, I'm gonna to check performance.
misiek08
S3 licensed
But comparing PHP and Spark? Spark will be 100times better? :P

What with connection to MySQL in all languages above?
misiek08
S3 licensed
Spark Library (http://www.lfsforum.net/showthread.php?t=68564) will be good? It's .net but Airio it's .NET too and it's working by mono very well. I can't check performance now because I don't have time to make new InSim if it will be not good.
misiek08
S3 licensed
Perl and Python are out of race because I don't know them so much. I know perl but only to make a daemon for game/hosting panel. I will try it in C++.
misiek08
S3 licensed
There is one database. Now it's MySQL and it's working ok. I have 25 connected servers, 4 (or 5) with MCI packets and 2 with NPL packets. 1s interval (1000ms). I'm running on PHP and it's working fast but sometimes lags on 6-7 server (which have MCI/NLP packets ofc). I need something faster because the PHP InSim's are taking too much RAM and too much CPU (CPU isn't problem but RAM consumption is terrible). 1 instance of my PHP InSim System = 1 server so I have 25 "daemons" in PHP running all the time. Maybe after some optimizing, this will take less RAM but I don't have time for rewriting PHP InSim System or making a new one.
misiek08
S3 licensed
You can do it by:
> 150
> 300
beacuse every text to the max state will be shown. Better make a function with
> 5000 print(asdasd); return
> 4000 print(asdasd); return

> = if
misiek08
S3 licensed
No. Without MCI and NLP packets on every server because I don't wonna copy InSim Relay. I only need joining server(NCN) and NPL and maybe LAP and SPX packets in the future. For PB's and WR's.

EDIT:
Ok. 700kB/s ~ 5.6Mb/s. It's not much like for downloading. I have 3Ghz processor and 1,5GB of RAM. Transfer? 5Tb per month. I can get 10Mb connection without transfer limit and it could work but like I wrote above, I don't need MCI and NPL packets on every server. Maybe some servers...
Last edited by misiek08, .
misiek08
S3 licensed
I know it's very, very old topic but maybe anyone have source of it (or executable). I need it quickly for a race. Source needed to change design and text's (if needed)
LFS Multi server InSim
misiek08
S3 licensed
Hi!
I'm going to make a big system for server in my country (Poland). It would be informing players about event's and allow to schedule notes. What language will be best for this if I'm using Debian Lenny on my server. For me, easiest is PHP but I don't know how much CPU and RAM can it take. I think, we'll use this InSim on 100-150 servers.

EDIT:
C++ ? C ? Phyton (please, not)? Delphi (not for sockets and server communication and linux)? Perl (I think it's would be not good too)?
Last edited by misiek08, .
FGED GREDG RDFGDR GSFDG