Graal Forums

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

Astram 05-17-2011 01:17 AM

Inventory Script
 
PHP Code:

//#CLIENTSIDE
function onCreated()
  {
  
setTimer(.005);
  
enablefeaturesallfeatures -);
  }
function 
onKeyPressed(codekeyscancode) {
  if (
key == "q" || key == "Q")
    {
    if (
this.on == false)
      {
      
this.on true;
      
onOpenInv();
      }
    else
      {
      
this.on false;
      
Inventory_Window1.hide();
      }
    }
  }
function 
onOpenInv()
  {
  new 
GuiWindowCtrl("Inventory_Window1") {
    
profile GuiBlueWindowProfile;
    
clientrelative true;
    
clientextent "320,221";

    
canmaximize false;
    
canminimize false;
    
canclose false;
    
canmove true;
    
canresize true;
    
closequery false;
    
destroyonhide false;
    
text "Inventory";
    
509;
    
203;

    new 
GuiScrollCtrl("Inventory_TextList1_Scroll") {
      
profile GuiBlueScrollProfile;
      
height 115;
      
hscrollbar "alwaysOff";
      
vscrollbar "dynamic";
      
width 293;
      
12;
      
8;

      new 
GuiTextListCtrl("Inventory_TextList1") {
        
profile GuiBlueTextListProfile;
        
height 32;
        
horizsizing "width";
        
width 289;
        
clearrows();
        for (
temp.weps 0temp.weps player.weapons.size(); temp.weps ++)
          {
          if (!(
player.weapons[(@temp.weps)].name.starts("-")))
            {
          
addrow(temp.weps,player.weapons[temp.weps].name);
          }
        }
      }
    }
    new 
GuiButtonCtrl("Inventory_Button1") {
      
profile GuiBlueButtonProfile;
      
text "Close";
      
width 320;
      
190;
    }
    new 
GuiButtonCtrl("Inventory_Button2") {
      
profile GuiBlueButtonProfile;
      
text "Equip";
      
width 320;
      
160;
    }
    
Inventory_Window1.show();
  }
}

function 
Inventory_Button1.onAction() {
  
Inventory_Window1.hide();
}

function 
Inventory_Button2.onAction() {
  
Inventory_Window1.hide();
  
temp.wep Inventory_TextList1.getSelectedText();
  
selectedweapon player.weapons.index(findweapon(temp.wep));


If you guys want to beef up your server a bit with a custom inventory feel free to take this! I havent tested it yet but it should run just find.

Even though I have already done these things, I would like to implent a new cleaner version into this item system.

-Admin Item Generator (via GUI with no scripting involved)
-Drop System
-Bag Support (the item bag (Astram/Tools; Toad/Blah))

Enjoy this while you can, while I will be working on another :cool:

Tricxta 05-17-2011 02:06 AM

Show us some screenshots?

cbk1994 05-17-2011 02:45 AM

Please don't release scripts like this into the code gallery. I really do appreciate your effort and that you're trying to help others, but releasing broken model scripts isn't the way to do it.

A couple things to work on:
  • Your styling is very inconsistent. This is the most crucial issue with your script.
  • The minimum clientside timeout is 0.05 seconds, not 0.0005 seconds.
  • You don't need to check for q and Q. String comparison is not case-sensitive.
  • Try to use meaningful object names rather than _Button1.
  • I would recommend using clientWidth and clientHeight instead of clientExtent.
  • Generally use foreach loops when looping through arrays like you did for displaying weapons.

Again, thanks for trying to help :). Let me know if anything I said doesn't make sense.

Astram 05-17-2011 02:49 AM

Quote:

Originally Posted by cbk1994 (Post 1650150)
Please don't release scripts like this into the code gallery. I really do appreciate your effort and that you're trying to help others, but releasing broken model scripts isn't the way to do it.

A couple things to work on:
  • Your styling is very inconsistent. This is the most crucial issue with your script.
  • The minimum clientside timeout is 0.05 seconds, not 0.0005 seconds.
  • You don't need to check for q and Q. String comparison is not case-sensitive.
  • Try to use meaningful object names rather than _Button1.
  • I would recommend using clientWidth and clientHeight instead of clientExtent.
  • Generally use foreach loops when looping through arrays like you did for displaying weapons.

Again, thanks for trying to help :). Let me know if anything I said doesn't make sense.

I used the RC Graal Gui Editor. Because I needed to set it up quick. xD I was in a hurry. I put the script through the Java beatuifier soooo... Also, the timer works perfectly. Thanks, I just got mixed up with the clientWidth. So it would be like.
PHP Code:

clientWidth clientHeight 10

?_?

cbk1994 05-17-2011 02:52 AM

Quote:

Originally Posted by Astram (Post 1650153)
I used the RC Graal Gui Editor. Because I needed to set it up quick. xD I was in a hurry. I put the script through the Java beatuifier soooo... Also, the timer works perfectly. Thanks, I just got mixed up with the clientWidth. So it would be like.
PHP Code:

clientWidth clientHeight 10

?_?

If you're doing it in a hurry, it's probably not Code Gallery material.

I don't know what beautifier you used, but it didn't work very well. You should be indenting and styling as you script anyway.

The timer may work perfectly, but that doesn't mean it's correct. The smallest timeout possible is 0.05 seconds—there's no reason to make it look like you're using a smaller one.

clientWidth and clientHeight are just the width and height of the element (excluding the border width/height). Set them like ordinary variables.

Tricxta 05-17-2011 03:08 AM

I do like how astram has posted this, to me it demonstrates that gs2 is alot more powerful then gs1 when scanning for player attributes so basically efficiency wise.... Thanks astram for trying to help although I do tend to agree with chris's point about not being code gallery worthy. Your still in your learning days, yes?

WhiteDragon 05-17-2011 04:57 AM

Quote:

Originally Posted by cbk1994 (Post 1650154)
Code Gallery material

I feel like I'm about to be off-topic in epic proportions here. I hope no one minds. In this light:

I don't think it's good to be too stingy about what qualifies for a "Code Gallery" script. If someone makes a script to their best effort and releases it, I think it's fine to post it here. If it isn't up to scruff, someone will hopefully give a breakdown of why, the script will be updated. Both the original scripter and future observers will learn something from the critique.

My reasoning for this is that a discussion board will easily devolve into situation where an in-group is deciding on what is good or bad and leading the discussion entirely. In-groups are not always right (in fact, often wrong), and they create some weird sensation of a faux hierarchy which you need to climb to be respected, when you are actually just meeting fairly arbitrary restrictions.

I believe it is best to instead always be critical, and give in-depth explanations of decisions. This way, there is less arbitrary and more precise. Precise is easy to follow, and precise is not easy to bull.

This post is definitely not aimed at Chris. He's usually the one giving the in-depth explanations himself :p. It's rather just a preemptive strike against anything ugly happening in the section. Hopefully most agree.



Though. I do value the fact there should be a place to release very polished scripts, ready-to-roll scripts. I don't think a forum is a good place for that. Something like a package system with voting might be appropriate. Maybe this is something Graal can get in the near future.

cbk1994 05-17-2011 05:04 AM

Quote:

Originally Posted by WhiteDragon (Post 1650182)
post

My idea of the Code Gallery is that it's more of a repository of good code that others can learn from, not so much just an assortment of ready-to-use scripts (although certainly many can be very useful).

I don't see any reason the same level of help can't be given outside of the Code Gallery. Perhaps less-established scripters could post a script they plan on releasing, get critique, make changes, and then post the polished version in the gallery.

I agree with you, though—I don't mean to make it seem like new scripters shouldn't be allowed to post code in here, or that you have to be a member of some in-group, I'm just trying to keep the code gallery clean of flawed scripts so others trying to learn aren't confused by them. Sorry if it came out wrong.


All times are GMT +2. The time now is 07:27 PM.

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