View Single Post
  #1  
Old 07-18-2006, 09:15 AM
Dach Dach is offline
call me Chad, it's cooler
Dach's Avatar
Join Date: Aug 2002
Posts: 1,899
Dach is on a distinguished road
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 
__________________
Scripting Documents:Old Script Documentation-Movement Tutorial
Reply With Quote