Graal Forums  

Go Back   Graal Forums > Development Forums > Tech Support
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #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
  #2  
Old 07-25-2006, 06:18 AM
Giltwist2k1 Giltwist2k1 is offline
Registered User
Giltwist2k1's Avatar
Join Date: Jun 2002
Posts: 13
Giltwist2k1 is on a distinguished road
Send a message via ICQ to Giltwist2k1 Send a message via AIM to Giltwist2k1 Send a message via Yahoo to Giltwist2k1
Angry

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.
Reply With Quote
  #3  
Old 08-22-2006, 09:31 PM
Admins Admins is offline
Graal Administration
Join Date: Jan 2000
Location: Admins
Posts: 11,693
Admins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud ofAdmins has much to be proud of
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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 10:42 AM.


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