Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Tech Support (https://forums.graalonline.com/forums/forumdisplay.php?f=7)
-   -   saving multidimensional arrays to the player (https://forums.graalonline.com/forums/showthread.php?t=67422)

Dach 07-18-2006 09:15 AM

saving multidimensional arrays to the player
 
PHP Code:

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 

PHP Code:

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.

PHP Code:

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.


All times are GMT +2. The time now is 04:24 AM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.