Having another problem... I have been trying, testing and changing my butt off to get this working, but it doesn't seem to be willing to listen to me..
The following is the case:
I define an array in the OnLapperStart:
GlobalVar $a_user_array;
In the OnRaceStart I initialize this array:
FOR ($l=1;l<=4;$l=$l+1)
$a_user_array[$l, "username")="X";
$a_user_array[$l, "finishedpos")=0;
ENDFOR
(The "X" is chosen to show things)
So far so good. I have been entering some 'cmdLFS("/msg ")'s at various spots (OnLap, OnFinish etc.) to show what's in the array, and I actually see those "X"s and zeroes in those messages.
Even at the start of the OnResult, where I actually start to use the array.
Anyway, here's were the happening of strange things starts. What do I want to do? Well, in the OnResult I'd like to add the player in question to the array. So I lookup the first available spot in the array and put in the user-data. For testing purposes I entered a "Y" in the first spot, so the lookup should be forced to determine the second spot as the first one available. For the outcome of the array-filling this one doesn't really matter, things also go wrong without this action.
Here's the code I'm using:
$x = 0;
$a_user_array[1,"username"] = "Y";
cmdLFS("/msg A " . $a_user_array[1, "username"]);
cmdLFS("/msg A " . $a_user_array[1, "finishedpos"]);
cmdLFS("/msg A " . $a_user_array[2, "username"]);
cmdLFS("/msg A " . $a_user_array[2, "finishedpos"]);
cmdLFS("/msg A " . $a_user_array[3, "username"]);
cmdLFS("/msg A " . $a_user_array[3, "finishedpos"]);
$for_ready = 0;
FOR ($l=1;$l<=4;$l=$l+1)
IF ($for_ready == 0)
THEN
IF ($a_user_array[$l, "username"] == "X")
THEN
cmdLFS("/msg Forloop " . $a_user_array[$l, "username"]);
cmdLFS("/msg Forloop " . $a_user_array[$l, "finishedpos"]);
cmdLFS("/msg Forindex " . $l);
$x = $l;
$for_ready = 1;
ENDIF
ENDIF
ENDFOR
$a_user_array[$x, "username"] = $userName;
$a_user_array[$x, "finishedpos"] = GetCurrentPlayerVar("FinishedPos");
cmdLFS("/msg B " . $a_user_array[1, "username"]);
cmdLFS("/msg B " . $a_user_array[1, "finishedpos"]);
cmdLFS("/msg B " . $a_user_array[2, "username"]);
cmdLFS("/msg B " . $a_user_array[2, "finishedpos"]);
cmdLFS("/msg B " . $a_user_array[3, "username"]);
cmdLFS("/msg B " . $a_user_array[3, "finishedpos"]);
When I execute this code, I get the following results on screen:
A Y
A 0
A X
A 0
A X
A 0
Forloop X
Forloop 0
Forindex 2
Nothing wrong there yet, but then the mayhem starts:
B
B
B yamasuba.nl
B 1
B
B
To cut things short, the adding to the array of the player at hand seems to have caused the rest of the array being blanked out. And that I don't understand... Might I have come across some mystical bug, or am I doing something terribly wrong myself??