View Single Post
  #10  
Old 08-06-2011, 04:57 PM
Adddeeee Adddeeee is offline
Registered User
Join Date: Aug 2011
Posts: 30
Adddeeee is on a distinguished road
Hi!

This is what we've got so far. We have now updated the script so that our trigger action triggers onActionBuyItem.

Although, we have a variable called this.itemselected, which will store information regarding the currently selected item.

this.itemselected contains one of the two available gui controls: Shop_Item_Fireball or Shop_Item_Sword.

The gui looks just fine when running the script. We can click on the different items and the currently selected item changes.

Although, when we trigger the server via triggeraction, the gui control which is stored in this.itemselected disappears. We've noticed that this happens when we use this.itemselected as a parameter for triggeraction. If we use a string, for example "higuys" as parameter to the triggeraction everything works just fine.

I get a feeling that we're not ready to build a shop system!

PHP Code:
function onActionBuyItem(item)
{
  
player.chat item;  
}

function 
onCreated() 
{
  
this.setShape(13232);
}

//#CLIENTSIDE
function onPlayerTouchsMe()
{
  new 
GuiBitmapBorderCtrl("Shop_Window"
  {
    
this.profile GuiBitmapBorderProfile;
    
this.width screenwidth 2;
    
this.height screenheight 2;
    
this.screenwidth this.width 2;
    
this.screenheight this.height 2;
    
this.canmove false;
    
this.canresize false;
    
this.makefirstresponder(true);
    
    new 
GuiButtonCtrl("Shop_Button")
    {
      
width 100;
      
height 40;
      
Shop_Window.width this.width 2;    
      
Shop_Window.height this.height 10;
      
text "Buy";
    }
        
    new 
GuiShowImgCtrl("Shop_Item_Fireball"
    {
      
20;
      
20;
      
width 60;
      
height 60;
      
      
this.imageselected "split_fireball_selected.png";
      
this.imagenotselected "split_fireball.png";
      
this.image this.imageselected;
      
      
this.price 20;
    }
    
    new 
GuiShowImgCtrl("Shop_Item_Sword"
    {
      
Shop_Item_FireBall.Shop_Item_Fireball.width 20;
      
20;
      
width 60;
      
height 60;
      
      
this.imageselected "split_sword_selected.png";
      
this.imagenotselected "split_sword.png";
      
this.image this.imagenotselected;
      
      
this.price 30;
    }
  }
  
Shop_Window.show();
  
this.listofitems = {Shop_Item_FireballShop_Item_Sword};
  
this.itemselected this.listofitems[0];
}

function 
onMouseDown()
{
  if(!((
mousescreenx in |Shop_Window.xShop_Window.Shop_Window.width|)
      &&(
mousescreeny in |Shop_Window.yShop_Window.Shop_Window.height|)))
  {
    
Shop_Window.hide();
  }
}

function 
Shop_Button.onMouseDown()
{
  
triggeraction(this.0.5this.0.5"BuyItem"this.itemselected);
  
}

function 
Shop_Item_Fireball.onMouseDown()
{
  
temp.this.listofitems.size();
  
  for(
0temp.s++)
  {
    
this.listofitems[i].image this.listofitems[i].imagenotselected;   
    if(
this.listofitems[i] == Shop_Item_Fireball)
      
this.itemselected this.listofitems[i];
  } 
  
Shop_Item_Fireball.image Shop_Item_Fireball.imageselected;
}

function 
Shop_Item_Sword.onMouseDown()
{
  
temp.this.listofitems.size();
  
  for(
0this.listofitems.size(); ++)
  {
    
this.listofitems[i].image this.listofitems[i].imagenotselected;   
    if(
this.listofitems[i] == Shop_Item_Sword)
      
this.itemselected this.listofitems[i];
  }
  
Shop_Item_Sword.image Shop_Item_Sword.imageselected;

Reply With Quote