Multidimensional array getting erased

One step closer to the asylum.

I have this statement declaring the multi dimensional array:
image

This multi dimensional array gets its value updated at the OnBegin() event:


With the print function extracted right from the verse documentation (which was wrong if I may point it, Columns looked for the index = length)
Up to this point, it all works as intented, printing in the log my ((0, 0),(0, 0)) matrix
I’m trying to keep track which players killed which players, so what I came up with was a 2D array, which the Column Index would represent the corresponding player Index , and it would store in its Rows the number of kills to each player.
Ex: When Player1 kills Player0 the matrix should change to:
{ 0, 1 },
{ 0, 0 }

I’m trying to change the matrix at some point, but it seems the matrix its getting deleted at some point (maybe after finishing the OnBegin() task?)
The next time I try to access one of its elements (To call the PrintAllinMatrix() function, I get no log (now erased else statements with prints, so I’d know its failing to call the .Length of the matrix)

I have never ever encountered this type of issue with any language I’ve coded in.

The next part may be a little irrelevant, but I’ll add it because maybe there is a more robust/failproof way of doing things.

I intended to use another PlayerArray which is set its value to GetPlaySpace().GetPlayers() on the OnBegin() function, to store all player references and access the players through its Index (and not having to call the GetPlayers() function everytime and look for the player. I expected players leaving the match would change the Index at with the GetPlayers() function stores the player in the array, messing with my other Matrix.
This array would also clear suddenly, making its elements unaccesible.
For now I am calling the GetPlayers() function, and trying to clear a bit of development before addressing the possible bugs it would cause.

Why does your Start method take an agent ? Are you generating this array for every agents but writing on the same variable ?

Also why not use players as indexes instead of using ints ? I don’t see how you’ll manage Joining/Leaving correctly with this

Oh sorry for not beeing clear.
The Start method is called on the TriggeredEvent of a trigger I have subscribed on the OnBegin. The trigger is only pressed by one character so the variable should get its value assigned only once.
Players as indexes of a int filled matrix? is that possible? How would the declaration of the variable be?

I’m not sure what you’re trying to do here, but a [player][]player map could work

# The index being the killer and the array of players being the victims
var PlayerElims : [player][]player = map{}
1 Like

I did it, I’ve been trying this 5 days and can’t get results.
I have a method in which I get the two involved players, the killer and the killed player.
First I update the PlayerElims map, so that PlayerElims[Player1] += array{Player2}
That works fine and I’ve checked the length everytime this happens.

Now, when this happens, there is no way I can access Player2Kills := PlayerElimns[Player2], which would return the array of players killed by Player2, which i KNOW for a fact is not empty. This statement will always fail. If i just access PlayerElims[Player1], it succeeds (both ways).

That made me think maybe the Player2 reference is not valid, but I’ve implemented a GetUsername function so I could check this and both player usernames are popping in the log:
image

This WILL work:

This will FAIL everytime:

I do not understand why this is happening, I have checked that both arrays that are the value for the key of everyplayer are not empty.
I have checked that both player references are valid.
I just can’t seem to access whatever player the player2 variable holds.

I’ve tried updating to verse 1.0 as a last resort, but of course would not change anything.

Well in this example it is actually empty, you’ve set the value for Player1 not Player2