Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 08-06-2011, 09:17 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Quote:
Originally Posted by xXziroXx View Post
Uh, why?
You'd have to rig something together using a trigger system or attributes. For the fairly new scripter that task could be overwhelming and/or adds un-needed complexity right now.

Whereas if you store it twice, once on the server-side and once on the client-side. You have access to it on the client-side right away without sending it through your server-to-client data routing system.

Then when his shop is working the way he wants, he can always go in after and setup a way to sync the shop data to the client.
__________________
Quote:
Reply With Quote
  #2  
Old 08-08-2011, 10:12 PM
Adddeeee Adddeeee is offline
Registered User
Join Date: Aug 2011
Posts: 30
Adddeeee is on a distinguished road
This is what we've got so far!

Although I'm interested in re-doing the shop with DB NPC's instead of putting all the item information in the shop class. Do you think that would be more efficient or is this a good solution? Don't really know how to set it all up using DB NPC's yet though.

PHP Code:
function onActionBuyItem(cmdselected)

  if(
cmd == "Buy")
  {
    for(
temp.itemthis.listofitems)
    {
      if(
temp.item[0] == selected)
      {
        if(
player.rupees temp.item[3])
        {
          
player.chat "Not enough rupees!";
        }
        else
        {
          
player.chat "Bought " temp.item[1] @ "!";
          
player.rupees player.rupees temp.item[3];
          
this.money this.money temp.item[3];
          
this.chat this.money;
          
player.addweapon(temp.item[2]);
        }
      }
    }
  }
}

function 
onCreated()
{
  
this.setShape(13232); 
  
this.listofitems = {{"Shop_Item_Fireball""Fireball""split_fireball"30}, 
                      {
"Shop_Item_Sword""Sword""split_sword"20},
                      {
"Shop_Item_Bow""Bow""split_bow"10}
                     };
}

//#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;
    
    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 32;
      
height 32;
      
      
this.imageselected "split_fireball_selected.png";
      
this.imagenotselected "split_fireball.png";
      
this.image this.imageselected;
      
thiso.catchevent(this.name"onMouseDown""onItemSelected");
    }
    
    new 
GuiShowImgCtrl("Shop_Item_Sword"
    {
      
Shop_Item_Fireball.Shop_Item_Fireball.width 20;
      
20;
      
width 32;
      
height 32;
      
      
this.imageselected "split_sword_selected.png";
      
this.imagenotselected "split_sword.png";
      
this.image this.imagenotselected;
      
thiso.catchevent(this.name"onMouseDown""onItemSelected");
    }
    
    new 
GuiShowImgCtrl("Shop_Item_Bow"
    {
      
Shop_Item_Sword.Shop_Item_Sword.width 20;
      
20;
      
width 32;
      
height 32;
      
      
this.imageselected "split_bow_selected.png";
      
this.imagenotselected "split_bow.png";
      
this.image this.imagenotselected;
      
thiso.catchevent(this.name"onMouseDown""onItemSelected");
    }
  }
  
Shop_Window.show();
  
this.listofitems = {Shop_Item_FireballShop_Item_SwordShop_Item_Bow};
  
this.itemselected this.listofitems[0].name;
}

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""Buy"this.itemselected);
  
Shop_Window.makefirstresponder(true);
}

function 
onItemSelected(selected
{
  for(
tempi 0temp.this.listofitems.size();temp.++) 
  {
    
temp.item this.listofitems[i];
    
temp.item.image = (temp.item == selected temp.item.imageselected temp.item.imagenotselected);
  }
  
  
this.itemselected selected.name;

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 01:55 AM.


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