Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Gui Problems (https://forums.graalonline.com/forums/showthread.php?t=134257269)

sssssssssss 12-12-2009 07:02 AM

Gui Problems
 
Im having issues getting data from a dbnpc and putting it in gui, again. Im not sure why, but in this situation, all the values in the array in the dbnpc are showing up in the main window text on the gui. It should be splitting it up. Worked for a while, until I added some stuff in.

PHP Code:

function onCreated()
{
  
this.db findnpc("NpcChat");
}
function 
onActionServerSide(){
  if (
params[0] == "getText"){
    
triggerClient("weapon"this.name"getText"this.db.info);
  }

}
//#CLIENTSIDE
function onActionClientSide(){
  if (
params[0] == "getText"){
    
temp.setup params[1];
    
NpcChat_Window1.setText(temp.setup[0]);
    
NpcChat_Text1.setText(temp.setup[1]);
    
//temp.list = "";
    //temp.data = {params[1][2], params[1][3], params[1][4], params[1][5]};
    //for (temp.line: temp.data) {
    //  temp.list @= temp.line @ "\n";
    //}
    
NPC_Chat_ItemList.addrow(temp.setup[2]);
    
NPC_Chat_ItemList.addrow(temp.setup[3]);
    
NPC_Chat_ItemList.addrow(temp.setup[4]);
    
NPC_Chat_ItemList.addrow(temp.setup[5]);
    
temp.img temp.setup[6];
    
NpcChat_Image1.image temp.img;
  }

}
public function 
OpenWindowdata ){
  if (
NpcChat_Text1 != NULLNpcChat_Window1.destroy();
  
triggerServer("weapon"this.name"getText");
  new 
GuiWindowCtrl("NpcChat_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "211,231";
    
useOwnProfile true
    
profile.bitmap "guiarm_window.png"
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Loading...";
    
309;
    
88;

    new 
GuiTextCtrl("NpcChat_Text1") {
      
profile GuiBlueTextProfile;
      
height 20;
      
text "";
      
width 42;
      
76;
    }
    new 
GuiScrollCtrl("NpcChat_MultiLine1_Scroll") {
      
profile GuiBlueScrollProfile;
      
useOwnProfile true
      
profile.bitmap "guiarm_scroll.png"
      
height 75;
      
hscrollbar "dynamic";
      
vscrollbar "dynamic";
      
width 176;
      
19;
      
143;

      new 
GuiMLTextCtrl("NpcChat_MultiLine1") {
        
profile GuiBlueMLTextProfile;
        
height 32;
        
horizsizing "width";
        
text "Loading...";
        
width 151;
      }
      new 
GuiMLTextCtrl("NpcChat_MultiLine2") {
        
profile GuiBlueMLTextProfile;
        
height 66;
        
horizsizing "width";
        
text "Loading...";
        
width 151;
      }
      new 
GuiMLTextCtrl("NpcChat_MultiLine3") {
        
profile GuiBlueMLTextProfile;
        
height 32;
        
horizsizing "width";
        
text "Loading...";
        
width 151;
      }
      new 
GuiMLTextCtrl("NpcChat_MultiLine4") {
        
profile GuiBlueMLTextProfile;
        
height 32;
        
horizsizing "width";
        
text "Loading...";
        
width 151;
      }
    }
    new 
GuiScrollCtrl"Npc_Chat_Scroll" ) {
      
this.width 250;
      
this.height 330;
      
      
this.19;
      
this.143;
      
      
this.hScrollBar "alwaysOff";
      
this.vScrollBar "dynamic";
      
      new 
GuiTextListCtrl"Npc_Chat_ItemList" ) {
        
this.width 250;
        
this.height 330;
      }
    }
    new 
GuiShowImgCtrl("NpcChat_Image1") { 
      
9
      
partx 0;
      
party 60;
      
partw 50;
      
parth 36;
      
width 150
      
height 150
      
image "block.png"
    } 
  }


and in the dbnpc NpcChat as a flag:
PHP Code:

info"Ramerd","You like girls?","YOURE ***!","I'm ***","","NO WAY!""head22.png"

Like i said, the
PHP Code:

NpcChat_Window1.setText(temp.setup[0]); 

is showing up the entire array, and shouldnt be as far as I can see. None of the other texts or lines are getting any values at all.

fowlplay4 12-12-2009 07:14 AM

Show the code where you initialize the info array, it should look something like this:

PHP Code:

function onCreated() {
  
this.info = {
    
"Ramerd",
    
"You like girls?",
    
"YOURE ***!",
    
"I'm ***",
    
"",
    
"NO WAY!"
    
"head22.png"
  
};


Also you don't need to specify "weapon" in triggerclient either.

PHP Code:

function onCreated() {
  
player.triggerClient(this.name"getText"this.db.info);


Works fine too :)

sssssssssss 12-12-2009 07:24 AM

I just typed it in the dbnpc flag for now, nothing initializes it yet.

fowlplay4 12-12-2009 07:28 AM

Quote:

Originally Posted by sssssssssss (Post 1543861)
I just typed it in the dbnpc flag for now, nothing initializes it yet.

That's probably the source of your problem then :P Just use the code I supplied you then, it's usually a better idea to let scripts change values and variables especially when dealing with arrays.

Switch 12-12-2009 09:26 PM

Quotes in a DBNPC's flag makes it think it's part of a sub-array.


All times are GMT +2. The time now is 08:42 PM.

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