PDA

View Full Version : saving multidimensional arrays to the player


Dach
07-18-2006, 09:15 AM
function onCreated() {
with (findplayer("Dach")) {
template={2,0,10,4,18,"body.png","head0.png","sword1.png","shield1.png"};
player.outfits = new[5];
for (i=0;i<5;i++){
player.outfits[i] = i;
}
}
}
//#CLIENTSIDE


function onCreated() {
with (findplayer("Dach")) {
template={2,0,10,4,18,"body.png","head0.png","sword1.png","shield1.png"};
client.outfits = new[5][9];
for (i=0;i<5;i++)
for (j=0;j<9;j++)
client.outfits[i][j] = template[i];
}
}
//#CLIENTSIDE

Both of the above algorithms using client. clientr. or player. prefixes will store only '0' to the array (storing in single and two dimensional, respectively). This is reading from the player attributes, if you echo them they will look okay. Using the client. prefix from clientside does the same. However, the next algorithm will work just fine with the prefixes. It does not seem to affect anything else, just prefixes associated with the player object.


function onCreated() {
with (findplayer("Dach")) {
template={2,0,10,4,18,"body.png","head0.png","sword1.png","shield1.png"};
client.outfits = null;
for (i=0;i<5;i++)
client.outfits.add(template);
}
}
//#CLIENTSIDE

Giltwist2k1
07-25-2006, 06:18 AM
I'm bumping this because, honestly, it was my script that spawned this report. Multidimensional arrays are supposed to be one of the big improvements in GS2, and I'd like to see them actually work.

Admins
08-22-2006, 09:31 PM
It is not recommended to directly manipulate player. or clientr. arrays though because they would be sent each time you modify an array member. Best way is to build a temporary array and then assign it to he player. or clientr. var.
I guess the problem in the above script is that assigning the empty array to the variable might not work correctly, will try to check that when i have time.