Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Custom Inventory (https://forums.graalonline.com/forums/showthread.php?t=68711)

xXziroXx 09-13-2006 06:03 PM

Custom Inventory
 
Custom Inventory
v1.0


This inventory works pretty much as the default Graal inventory does. It displays NPCs that doesnt start with "-", and by doubleclicking on a weapon you select it. 'Sub-Folders' will be implemented in the next version, if requested.


Theres only ONE thing that doesnt work properly in it, selected a weapon. For some reason, it doesnt always selected the proper weapon.

Example:

Player doubleclicks on the weapon "Staff/Boots" and it gets equipped properly.
Player then tries to doubleclick the weapon "Tailor", and that too works.
Finally, player tries to equip the weapon "Skateboard", but "Tailor" gets equiped instead!

Id be so-so happy if someone would be able to solve that bug, I havent been able too.


But other then that, its all good to go!



Installing

When adding the NPC, it can be named pretty much anything you want BUT it HAVE to start with a "-"! If it doesnt, it wont work properly.

PHP Code:

function onActionServerSide()
{
  if (
params[0] == "playerweaps") {
    for (
0player.weapons.size(); ++) temp.imgs.add(findWeaponNPC(player.weapons[i]).image);
    
triggerClient("gui"name"openinv"player.weaponstemp.imgs);
  }
}

//#CLIENTSIDE
function onCreated()
{
  
enablefeatures(allfeatures 4);
  
this.gName "Inventory_";
  (
this.gName "Window0").destroy();
  
setTimer(.05);
}

function 
onTimeOut()
{
  
this.plWeapon player.weapon.name;
  
showText(2006100"System""b""Selected Weapon:" SPC this.plWeapon SPC "[" selectedweapon "]");
  
changeImgVis(2004);
  
  
setTimer(.05);
}

function 
onKeyPressed(keynrkeyname)
{
  if (
keyname == "q") {
    if ((
this.gName "Window0").visible == falsetriggerServer("gui"name"playerweaps");
    else (
this.gName "Window0").destroy();
  }
}

function 
onActionClientSide("",weaps,imgs)
{
  if (
params[0] == "openinv"OpenInventory(weapsimgs);
}

function 
OpenInventory(invWeaponsinvImages)
{
  if ((
this.gName "Window0").visible == false) {
    new 
GuiWindowCtrl(this.gName "Window0") {
      
width 196height 177;
      
screenwidth/width/2screenheight/height/2;
    
      
canMinimize false;
      
canMaximize false;
      
canResize false;
      
canMove false;
      
destroyOnHide true;
      
      
xmod NULL;
      
ymod NULL;
      
rowcount NULL;
      
      
invItems NULL;
      
// Removes old buttons
      
for (0invItems.size(); ++) (this.gName "Button" i).destroy();
    
      
// Checks for items to display in inventory
      
for (0invWeapons.size(); ++) {
        if (!
invWeapons[i].starts("-")) invItems.add({invWeapons[i], invImages[i]});
      }
      
      
// Displays the items
      
new GuiScrollCtrl(this.gName "Scroll0") {
        
width 187height 150;
        
523;
        
        
hScrollBar "alwaysOff";
        
vScrollBar "dynamic";
      
        for (
0invItems.size(); ++) {
          
temp.var = 5;
          if (
temp.var.length() == && 0) {
            
xmod NULL;
            
ymod += 36;
            
rowcount ++;
          }
        
          new 
GuiBitmapButtonCtrl(this.gName "Button" i) {
            
width 32height 32;
            
xmodymod;
          
            
this.itemname invItems[i][0];
            
this.itemimage invItems[i][1];
          
            
normalbitmap this.itemimage;
            
mouseoverbitmap this.itemimage;
            
pressedbitmap this.itemimage;
          
            
thiso.catchevent(this"onMouseDown""onSlotPressed");
            
thiso.catchevent(this"onMouseEnter""onMouseOverSlot");
            
thiso.catchevent(this"onMouseLeave""onMouseExitSlot");
          }
          
xmod += 32 4;
        }
      }
    }
    (
this.gName "Window0").makefirstresponder("false");
  } else (
this.gName "Window0").destroy();
}

function 
onSlotPressed(objkeymodifiermousescreenxmousescreenyclickcount)
{
  if (
clickcount == 2) {
    
player.chat "Selected Weapon:" SPC obj.itemname;
    
selectedweapon player.weapons.index(findWeapon(obj.itemname));
    (
this.gName "Window0").destroy();
  } else if (
clickcount == 1) (this.gName "Window0").text obj.itemname;
}

function 
onMouseOverSlot(obj) (this.gName "Window0").text obj.itemname;
function 
onMouseExitSlot(obj) (this.gName "Window0").text ""


Enjoy!

GULTHEX 04-20-2009 08:59 PM

error: unexpected symbol "" at line 35: function onActionClientSide("",weaps,imgs)

okay i tried making it
("",weaps,imgs)

so i think the problem is that actionclientside isint a real function

Chompy 04-20-2009 09:10 PM

PHP Code:


function onActionClientSide()
{
  if (
params[0] == "openinv"OpenInventory(params[1], params[2]);


Try that instead :]

Inverness 04-20-2009 09:27 PM

Quote:

Originally Posted by GULTHEX (Post 1485497)
error: unexpected symbol "" at line 35: function onActionClientSide("",weaps,imgs)

okay i tried making it
("",weaps,imgs)

so i think the problem is that actionclientside isint a real function

I think the problem is in the error message. :noob:

Clearly just do:
PHP Code:

function onActionClientSide(unused,weaps,imgs)
{
  if (
params[0] == "openinv"OpenInventory(weapsimgs);


Chompy, I'm astonished that you're avoiding the problem rather than fixing it. The problem is clearly in the error message.

Chompy 04-20-2009 09:37 PM

Quote:

Originally Posted by Inverness (Post 1485504)
I think the problem is in the error message. :noob:

Clearly just do:
PHP Code:

function onActionClientSide(unused,weaps,imgs)
{
  if (
params[0] == "openinv"OpenInventory(weapsimgs);


Chompy, I'm astonished that you're avoiding the problem rather than fixing it. The problem is clearly in the error message.

Fixing it by adding a placeholder? :p I'd say you either stick with using the params[] array or use predefined parameters instead. (Instead of a mix, as it can become confusing when working with larger codes)

Inverness 04-20-2009 09:43 PM

Quote:

Originally Posted by Chompy (Post 1485514)
Fixing it by adding a placeholder? :p I'd say you either stick with using the params[] array or use predefined parameters instead. (Instead of a mix, as it can become confusing when working with larger codes)

I would use predefined parameters too, but I'm simply fixing what caused the error message, not redoing the script for him.

xXziroXx 04-20-2009 11:03 PM

Oh my god, did I make this piece of junk? :noob:

Damix2 04-21-2009 03:02 AM

Quote:

Originally Posted by xXziroXx (Post 1485545)
Oh my god, did I make this piece of junk? :noob:

Reminds me of that bash.org quote

<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

:D

GULTHEX 04-22-2009 03:45 AM

but when i add iether one of those i get

Script: Function enablefeatures not found at line 12 in script of -inv
<b>Script: Function Inventory_Window0.destroy not found at line 14 in script of -inv

just trying to help the people that dont know what to do

Twinny 04-22-2009 04:00 AM

Quote:

Originally Posted by GULTHEX (Post 1485947)
but when i add iether one of those i get

Script: Function enablefeatures not found at line 12 in script of -inv
<b>Script: Function Inventory_Window0.destroy not found at line 14 in script of -inv

just trying to help the people that dont know what to do

haha running back to the forums probably isn't the right thing to do as such ^^

cbk1994 04-22-2009 04:48 AM

Quote:

Originally Posted by GULTHEX (Post 1485947)
but when i add iether one of those i get

Script: Function enablefeatures not found at line 12 in script of -inv
<b>Script: Function Inventory_Window0.destroy not found at line 14 in script of -inv

just trying to help the people that dont know what to do

You messed up the clientside somehow.

Add //#CLIENTSIDE to the top after the serverside stuff if it's missing. Also check that it's capitalized and doesn't have a space or something after it.

Deas_Voice 04-22-2009 04:03 PM

Quote:

Originally Posted by xXziroXx (Post 1485545)
Oh my god, did I make this piece of junk? :noob:

Quote:

Originally Posted by Damix2 (Post 1485613)
Reminds me of that bash.org quote

<@Logan> I spent a minute looking at my own code by accident.
<@Logan> I was thinking "What the hell is this guy doing?"

:D


sig'd :D

jkldogg 02-27-2010 01:58 AM

will someone please send me the whole script in forum pm? this is extremely useful and its not working for me

got it

xXziroXx 02-27-2010 03:30 AM

Quote:

Originally Posted by jkldogg (Post 1559211)
will someone please send me the whole script in forum pm?

What? :oo:

12171217 02-27-2010 05:44 AM

Vega United's lookin' good!


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

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