The online racing simulator
UniqueId
(13 posts, started )
#1 - Hahni
UniqueId
I have read the InSim.txt serveral times but I dont find a way to know my UniqueId. Sure I can look what connectionnumber I have when I join a server and then I find the the right entry in the NodeLap Info of the IS_NLP packet. But the connectionnumber changes. Is there a easy way to know my UniqueId ?

Edit: Or a way to know my actual connectionnumber
Quote from Hahni :I have read the InSim.txt serveral times but I dont find a way to know my UniqueId. Sure I can look what connectionnumber I have when I join a server and then I find the the right entry in the NodeLap Info of the IS_NLP packet. But the connectionnumber changes. Is there a easy way to know my UniqueId ?

Edit: Or a way to know my actual connectionnumber

AFAIK You get uniqueId, when you join race (leave pits). So you should update it there (using Username as reference?). You get connection number, when user connects to server, but it might change when someone leaves the server, so you need to update it there as well. If the players that left was not taking last slot (highest number), then a player with highest number slot will get his connection number.
#3 - Hahni
Ok, thank you.

I thought the UniqueId stay the same for the time I'm connected to the server. But ok then I have to deal with it
Hmm, to be sure with the UniqueID...
You get one if you join the race and when you leave race you can get a new one?
And a new player who connects, will he gets the first free ID?

for example
ID: 1 Player1
ID: 2 Player2
ID: 3 Player3

Player2 disconnects
Player4 connects will get ID: 2?

But one player in a race will have one ID from begin to end thats right isnt it?

it would be nice if the ID dont change and used id from disconnected players won´t be used before a race restart or before the IDs to give are at the end (255).

But I dont think that will be implemented so late in LFS
The whole player tracking side of insim programming can be a real pig, i'm sure my method isn't the right way and is more a kind of brute force alternative lol... My primary meens of keeping track of players is the nickname, followed by uniqueId as a secondary... I'm tempted to go back and do it again properly as it is a bit of a jury rig :/
Hmm, I began using the name for reference but in a mci or split package I dont get this name so I can use the ID everywhere... (first I wanted to do the same name and then ID but it makes not much sense in my opinion)
#7 - filur
I tie ID and username to nickname and store ID and username under nickname. Sort of cross-referenced i guess, works really well. List simply gets updated whenever there's a packet holding relevant information.
Hmm my post got delete so here the short version...

I will write some things I did and have to do, some thoughts you can resume or edit

I develop a sort of new stats saving tool so I need much information (in split and mci too there without username).
In my guess it makes no difference if I look everytime for name and id or update the ID where it have to be done.

Here the points where the ID or name changes (isnt complete I think)

- New Player (IS_NPL) -> get the ID (?) --> unimportant for me cause I get non-existing IDs from the first information I store (mci, lap, split).

- Rename Player (IS_REN) -> get a new name reference by ID (for me) or with the old name

??? - Player Leave Race (IS_PLL) -> ID changed to 0 (no player in race)?

Are there more points? For sure I will test the last ??? point myself but I wrote it here cause it came in my mind this moment
Hi, I seem to have a problem with tracking my UniqueID:
I spectate, and join the race hence getting a new UniqueID that I read from the IS_NPL packet that contains my uname.


<?php 
$npl
->parse($control); //$control = packet
if($npl->uname != $ply) return NULL//$ply = "notanillusion"
?>

$npl->parse($control):

<?php 
function parse($packet) {
    
$foo unpack("a4id/a24uname/a24pname/a8plate/a32cname/Sflags/ctype/cunique_id/cply_num/ctotal/Sverify_id"$packet);
    foreach(
$foo as $key => $value) {
        
$this->$key $value;
    }
}
?>

And put the UniqueID into a $race object which holds stuff like lap, split, sector times, names etc.

<?php 
$race
->unique_id $npl->unique_id;
?>

Then I wait for SPX and LAP packets, and on arrival parse them and do some operations if it matches my UniqueID.

$spx->parse($control):

<?php 
function parse($packet) {
    
$foo unpack("a4id/c3time/cply_num/cunique_id/Sverify_id"$packet);
    
$foo['time'] = ($foo['time1'] * 60) + $foo['time2'].".".$foo['time3'];
    foreach(
$foo as $key => $value) {
        
$this->$key $value;
    }
}
?>


<?php 
if($spx->unique_id == $race->unique_id) {
//$spx is an instance of the SPX packet object
//$race is an instance of the $race object to which the IS_NPL UniqueID was placed when I joined the race
// do operations
}
?>

My problem is that the UniqueID's in the $race object and the $spx object don't match even though I haven't pitted or spectated again since joining.

Am I reading the IS_NPL or IS_SPX packets incorrectly or what? I must be reading the IS_NPL wrong because I get UniqueID's like 46, 23, 37 etc, while all the UniqueID's from IS_SPX and IS_LAP packets are in the order of 0-2x.
I tested it and I got 1,2,3 but I joined with me (Host) and got 1.
in Race I have 0.
Maybe you could do it in a other way (but you do something wrong, I cannot find it...), adding a new ID if you get the first information you need and dont find this id.
I use this script in MP on S2 servers. I've attached the code for it, and also a log of what it outputs when I join a race and drive to the first split. In the log, the last is_spx output is me reaching split 1. Maybe you could have a quick look and see if I'm making some nooby mistake again?

I still can't see why IS_NPL says my UniqueID is 11, and IS_SPX says it's 6. Curiously my PlyNum _is_ 6 and IS_SPX says it's 0. That must mean I'm parsing the IS_SPX packet incorrectly

*edit: attached another log, it's completely random, lol
Attached files
track_log.txt - 2 KB - 166 views
tracker.zip - 3.4 KB - 143 views
track_log2.txt - 1.4 KB - 138 views
I think your unpack string format is a little off. Type, unique ID, ply num, etc are all bytes that range from 0-256 but in your unpack statement you have a lowercase c, which says its a "signed char". In Java a char is 2 bytes that ranges from 0-65536. If php is the same you will have to use their byte equivalent. If a php char is only one byte, then you will have to use a capital C or "unsigned char". Remember, unsigned means it includes negatives and half the range (-127 to 128) is in the negative area whereas unsigned means its all positive and the full range (0-256). Hope that helps
I know what you mean.. but, it doesn't matter whether I use 'c' or 'C' in this case as far as I can tell. The attached log is from using the following unpack(). My split packet is one of the two last ones, doesn't really matter which because neither has a matching UID

is_npl:

<?php 
unpack
("a4id/a24uname/a24pname/a8plate/a32cname/Sflags/Ctype/Cunique_id/Cply_num/Ctotal/Sverify_id"$packet);
?>

is_spx:

<?php 
unpack
("a4id/C3time/Cply_num/Cunique_id/Sverify_id"$packet);
?>

Beats me

*edit: After following the logs for a while, I can say the UniqueID in the IS_LAP and IS_SPX packets is consistent, only the IS_NPL one is different. Still can't see how I'd be reading the IS_NPL packet wrong.
Attached files
track_log_C.txt - 1.2 KB - 148 views

UniqueId
(13 posts, started )
FGED GREDG RDFGDR GSFDG