Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Delete flag from DB? (https://forums.graalonline.com/forums/showthread.php?t=134258662)

DeCeaseD 04-07-2010 02:28 AM

Okay, so i've unfortunately ran into another problem.. Don't make fun of me. :cry: Okay so.. This probably isn't the best approach to making an "Item System", but here goes:

I've made 2 Databases for storing flags. 1st, is the BackpackStorage DB, which is the place where the items that the player has is stored, which backpack they are in, and how much of that item they have. Example: DeCeaseD_backpack_1="gun_Mp5,3".

2nd, is the ItemDatabase, which stores the stats for each of those items, like for instance: gun_Mp5="Actual Name", "Icon Image", "Gun Img", "Gun Dmg", etc.

Now.. for the "inventory". When the player opens up one of their bags, it's triggering to the server sending the players.account, along with which backpack is being opened, it than in turn looks to the DB, retrieves the items, than sends it to the client for storing. Once the items are stored, it than goes back to the server, and get's the stats for those items.. Now here's where my problem comes in. Everything works fine with the sending/retrieving of flags, but the problem is that, it's only retrieving/sending ONE of the items that I have in my backpack when it should be retrieving/sending two or more. I'll post the script, and can anyone tell me where I went wrong??


PHP Code:

function onActionServersidecmdd1d2d3d4d5 )
{
  if ( 
cmd == "InitializeSlot" ) {
  
    
clientr.backpack_slots 1;
    
clientr.backpack_size1 "Small";
    
player.chat "Recieved 1 "clientr.backpack_size1 @" backpack!";
  }
  if ( 
cmd == "RemoveSlot") {
  
    
clientr.backpack_slots NULL;
    
clientr.backpack_size1 NULL;
  }
  if ( 
cmd == "BackpackCheck" ) {
  
    
temp.npc findNPC("BackpackStorage");
    
temp.pl d1;
    
temp.backpack d2;
    
npc.(d1 @"_backpack_"backpack).add({"gun_Test"2});
  }
  if ( 
cmd == "ItemRefresh" ) {
  
    
temp.npc findNPC("BackpackStorage");
    
temp.pl d1;
    
temp.backpack d2;
    
temp.items npc.RetrieveItemsplbackpack );
    
temp.itemCount items.size();
    
triggerClient(this.name"ReturnItems"itemsitemCount);
    
//player.chat = "Item: "@ items[itemCount-1][0] @" Quantity: "@ items[itemCount-1][1] @" Item Count: "@ itemCount;
  
}
  if ( 
cmd == "GetItemStats" ) {
  
    
temp.npc findNPC("ItemDatabase");
    
temp.items npc.ReturnItemStatsd1 );
    
triggerClient(this.name"ReturnItemStats"items);
    
//player.chat = items;
  
}
}

//#CLIENTSIDE
function onCreated() {
  if ( 
clientr.backpack_slots <= ) {
  
    
triggerServer("gui"this.name"InitializeSlot");
  }
  
onTimeout();
}

function 
onActionClientsidecmdd1d2d3d4d5)
{
  if ( 
cmd == "ReturnItems" ) {
  
    
this.items d1;
    
this.itemCount d2;
    for ( 
temp.0temp.this.itemCounttemp.v++ ) {
    
      
triggerServer("gui"this.name"GetItemStats"d1[@ v][0]);
    }
  }
  if ( 
cmd == "ReturnItemStats" ) {
  
    
this.itemStats d1;
    
//player.chat = this.itemStats;
  
}
}

function 
onTimeout()
{
  
displayBackPacks(); 
  
//Contain OpenBackpack();
  //OpenBackpack will check for pack# and retrieve items
  //Contain DisplayItems();
  //DisplayItems will show items, and DisplayOptions()
  //Contain DisplayOptions();
  //DisplayOptions will display options for item usage.
  
setTimer(0.05);
}

function 
displayBackPacks()
{
  
temp.mXY = {mousescreenxmousescreeny};
  for ( 
temp.0temp.clientr.backpack_slotstemp.i++ ) {
  
    
temp.sizeCheck clientr.(@ "backpack_size" i+1);
    
temp.displayXY = { screenwidth 300 + (58 i), screenheight 50 };
    
with findImg200 ) ) {
    
      
image "necro_gui_iconbox.gif";
      
mode 1;
      
layer 4;
      
red green blue 1;
      
displayXY[0];
      
displayXY[1];
    }
    if ( 
sizeCheck != nil ) {
      
with findImg205 ) ) {
    
        
mode 1;
        
layer 5;
        
red green blue 1;
        
displayXY[0] - 3;
        
displayXY[1] - 5;
      }
    }
    if ( 
mXY[0in |displayXY[0], displayXY[0] + 34| &&
         
mXY[1in |displayXY[1], displayXY[1] + 34| ) {
      
      
this.overBackpack =  i+1;
      
findImg(200 i).alpha .9;
      
findImg(205 i).alpha .9;
      if ( 
leftmousebutton ) {
        if ( !
this.lmb ) {
          
this.lmb true;
          
this.selectedBackpack i+1;
          
play("necro_click2.wav");
          if ( 
this.overBackpack == this.selectedBackpack ) {
            if ( 
this.openBackpack != this.selectedBackpack ) {
            
              
findImg(205 i).image "necro_gui_backpack1_2.gif";
              
openBackpack();
            } else
            if ( 
this.openBackpack == this.selectedBackpack ) {
            
              
findImg(205 i).image "necro_gui_backpack1_1.gif";
              
this.openBackpack NULL;
              
this.selectedBackpack NULL;
              
this.itemsRefreshed false;
            }
          }
        }
      } else { 
this.lmb false; }
    } else {
      if ( 
this.selectedBackpack != i+|| this.selectedBackpack == NULL || this.overBackpack == NULL ) {
            
        
findImg(205 i).image "necro_gui_backpack1_1.gif";
        
findImg(200 i).alpha .45;
        
findImg(205 i).alpha .45;
      }
    }
  }
  if ( 
this.openBackpack != NULL openBackpack();
  if ( 
this.openBackpack == NULL this.itemsRefreshed false;
}

function 
openBackpack()
{
  
this.openBackpack this.selectedBackpack;
  if ( 
player.account == "DeCeaseD") {
    if ( !
this.itemsRefreshed ) {
    
      
this.itemsRefreshed true;
      
triggerServer("gui"this.name"ItemRefresh"player.accountthis.openBackpack);
      
//triggerServer("gui", this.name, "BackpackCheck", player.account, this.openBackpack);   
    

  }
  
displayItems();
}

function 
displayItems()
{
  for ( 
temp.0temp.this.itemCount-1temp.v++ ) {
  
    
temp.pItems this.itemStats;
    
player.chat "Items: "pItems;
  }



DeCeaseD 04-07-2010 09:01 PM

Sorry for the double post, but could someone PLEASE help me with this? I've seriously been sitting here trying to debug the script for a good hour or so and I've still gotten no luck with it. I'm getting really aggrivated! :cry:

Switch 04-07-2010 09:23 PM

What's the function that returns what you have?

DeCeaseD 04-07-2010 09:26 PM

Quote:

Originally Posted by Switch (Post 1567699)
What's the function that returns what you have?

For returning the items, I have this in the BackpackDB:

PHP Code:

public function RetrieveItemsplbackpack )
{
  return 
this.(pl @"_backpack_"backpack);


And for returning the stats of those items, I have this in the ItemDB:

PHP Code:

public function ReturnItemStatsitemitemCount 
{
  for ( 
temp.0temp.itemCounttemp.v++; ) {
  
    return 
this.(@ item)[temp.v];
    echo(
"Debug: "this.(@ item)[temp.v]);
  }



Switch 04-07-2010 09:31 PM

return will end a function, therefore it only returns the first item stat. you need to send the item stats all at once.

Also, how are the flags working on the retrieving of items?


All times are GMT +2. The time now is 11:36 AM.

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