Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting > Code Gallery
FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 09-13-2006, 07:03 PM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
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.

Graal Script 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!
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #2  
Old 04-20-2009, 09:59 PM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
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
Reply With Quote
  #3  
Old 04-20-2009, 10:10 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Graal Script Code:

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

Try that instead :]
__________________
Reply With Quote
  #4  
Old 04-20-2009, 10:27 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by GULTHEX View Post
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.

Clearly just do:
Graal Script 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.
__________________
Reply With Quote
  #5  
Old 04-20-2009, 10:37 PM
Chompy Chompy is offline
»\(║_o)/»
Chompy's Avatar
Join Date: Sep 2006
Location: Norway
Posts: 2,815
Chompy is just really niceChompy is just really niceChompy is just really nice
Send a message via MSN to Chompy
Quote:
Originally Posted by Inverness View Post
I think the problem is in the error message.

Clearly just do:
Graal Script 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? 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)
__________________
Reply With Quote
  #6  
Old 04-20-2009, 10:43 PM
Inverness Inverness is offline
Incubator
Inverness's Avatar
Join Date: Aug 2004
Location: Houston, Texas
Posts: 3,613
Inverness is a jewel in the roughInverness is a jewel in the rough
Quote:
Originally Posted by Chompy View Post
Fixing it by adding a placeholder? 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.
__________________
Reply With Quote
  #7  
Old 04-21-2009, 12:03 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Oh my god, did I make this piece of junk?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #8  
Old 04-21-2009, 04:02 AM
Damix2 Damix2 is offline
RED SQUARE CLUB
Join Date: Nov 2003
Location: NY-what's better?
Posts: 3,577
Damix2 will become famous soon enough
Quote:
Originally Posted by xXziroXx View Post
Oh my god, did I make this piece of junk?
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?"

__________________
Reply With Quote
  #9  
Old 04-22-2009, 04:45 AM
GULTHEX GULTHEX is offline
Registered User
Join Date: Jul 2008
Posts: 148
GULTHEX can only hope to improve
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
Reply With Quote
  #10  
Old 04-22-2009, 05:00 AM
Twinny Twinny is offline
My empire of dirt
Twinny's Avatar
Join Date: Mar 2006
Location: Australia
Posts: 2,422
Twinny is just really niceTwinny is just really nice
Send a message via AIM to Twinny
Quote:
Originally Posted by GULTHEX View Post
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
Reply With Quote
  #11  
Old 04-22-2009, 05:48 AM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
Quote:
Originally Posted by GULTHEX View Post
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.
__________________
Reply With Quote
  #12  
Old 04-22-2009, 05:03 PM
Deas_Voice Deas_Voice is offline
Deas
Deas_Voice's Avatar
Join Date: Jun 2007
Location: Sweden
Posts: 2,264
Deas_Voice is a jewel in the roughDeas_Voice is a jewel in the rough
Send a message via AIM to Deas_Voice Send a message via MSN to Deas_Voice Send a message via Yahoo to Deas_Voice
Quote:
Originally Posted by xXziroXx View Post
Oh my god, did I make this piece of junk?
Quote:
Originally Posted by Damix2 View Post
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?"


sig'd
__________________
.
WTF is real life, and where do I Download it?
There is no Real Life, just AFK!
since 2003~
I Support~
ღAeonღ | ღTestbedღ | ღDelteriaღ

if you are going to rep me, don't be an idiot, leave your name!
I got nothing but love for you
Reply With Quote
  #13  
Old 02-27-2010, 01:58 AM
jkldogg jkldogg is offline
J.Rollin (killaz)
jkldogg's Avatar
Join Date: Feb 2010
Location: USA
Posts: 675
jkldogg can only hope to improve
Send a message via AIM to jkldogg Send a message via MSN to jkldogg Send a message via Skype™ to jkldogg
will someone please send me the whole script in forum pm? this is extremely useful and its not working for me

got it
__________________

PSN: jkldogg



The best post ever made on the graal forums.
After playing Graal Online for many years, JKL decides to make a forum account. Isn't life funny?

Last edited by jkldogg; 02-27-2010 at 08:35 AM.. Reason: works
Reply With Quote
  #14  
Old 02-27-2010, 03:30 AM
xXziroXx xXziroXx is offline
Master of Puppets
xXziroXx's Avatar
Join Date: May 2004
Location: Sweden
Posts: 5,288
xXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant futurexXziroXx has a brilliant future
Send a message via AIM to xXziroXx Send a message via MSN to xXziroXx
Quote:
Originally Posted by jkldogg View Post
will someone please send me the whole script in forum pm?
What?
__________________

"A delayed game is eventually good, but a rushed game is forever bad." - Shigeru Miyamoto
Reply With Quote
  #15  
Old 02-27-2010, 05:44 AM
12171217 12171217 is offline
Banned
Join Date: Jan 2009
Posts: 453
12171217 has a spectacular aura about
Vega United's lookin' good!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 11:24 PM.


Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Copyright (C) 1998-2008 Linux cyberjoueurs All Rights Reserved.