The online racing simulator
Holding connected player's information
(6 posts, started )
Holding connected player's information
Hi all,
What is the best way to hold information of multiple players connected to a server with InSim?

  • username
  • nickname
  • plid
  • ucid
  • car

I'm using C# with InSimDotNet :-) Any help is much appreciated
#2 - Racon
There are two lists, really: connections (LFS accounts connected to your server) and players (cars on track, essentially). The UCID is unique to the connection (0 is the LFS host), and the PLID is unique to the joined car. Your connections won't have a PLID from when they first join the server to when they first join the track, and can end up with multiple PLIDS if they're running AI cars.

You can combine the lists if you make it so that the connection list can handle both multiple players and also no player at all, else you need to have the two lists separate, and have some kind of lookup between them to figure out the UCID when you're given a PLID and vice versa.

I use the two list approach... but my framework doesn't handle multiple AIs correctly, so there's some technical debt to pay there if I ever want to open it up to that.

Other caveats to watch for: the PLID can change when a player spectates and rejoins; one connection can have multiple players (AI cars are on the controlling players UCID, but each have their own PLID); and you can also transfer a car to another connection with the takeover procedure - the car keeps the PLID, but now it's 'owned' by the new connection.
Ah okay, that makes sense now.
Do you know how I would go about storing these lists in C#?
#4 - Racon
Sorry, I know nothing of C# or InSimDotNet - I'm all PHP.
Ah, okay. No worries bud - thanks for explaining about the PLID/UCIDs Smile
Okay, so I've used LsGO InSim as a guide and I've nearly got it - however when I go to add the data, the output in the list is instead:

Connection list:

The code I am using is:

clsConnection NewConn = new clsConnection();

NewConn.UniqueID = NCN.UCID;
NewConn.Username = NCN.UName;
NewConn.PlayerName = NCN.PName;
NewConn.IsAdmin = NCN.Admin;


Hope someone can help me! Big grin

Holding connected player's information
(6 posts, started )