Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 05-17-2011, 01:17 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Talking 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
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!



Last edited by Astram; 05-17-2011 at 01:17 AM.. Reason: Taking out findplayer
Reply With Quote
  #2  
Old 05-17-2011, 02:06 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
Show us some screenshots?
__________________
Quote:
Originally Posted by Crono View Post
No look at it, Stefan is totally trolling Thor. Calling Classic a "playerworld" (something it's not supposed to be) is the ultimate subtle insult to a true fan.

It's genius.
Reply With Quote
  #3  
Old 05-17-2011, 02:45 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
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.
__________________
Reply With Quote
  #4  
Old 05-17-2011, 02:49 AM
Astram Astram is offline
Era iPhone PR
Astram's Avatar
Join Date: Aug 2010
Posts: 324
Astram can only hope to improve
Send a message via AIM to Astram
Quote:
Originally Posted by cbk1994 View Post
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
?_?
__________________
-Toad
The worlds biggest Toad fan...
Era iPhone FTW!


Reply With Quote
  #5  
Old 05-17-2011, 02:52 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 Astram View Post
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.
__________________
Reply With Quote
  #6  
Old 05-17-2011, 03:08 AM
Tricxta Tricxta is offline
The Muffin Man
Tricxta's Avatar
Join Date: Oct 2010
Location: Australia
Posts: 563
Tricxta is a jewel in the roughTricxta is a jewel in the rough
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?
__________________
Quote:
Originally Posted by Crono View Post
No look at it, Stefan is totally trolling Thor. Calling Classic a "playerworld" (something it's not supposed to be) is the ultimate subtle insult to a true fan.

It's genius.
Reply With Quote
  #7  
Old 05-17-2011, 04:57 AM
WhiteDragon WhiteDragon is offline
Banned
Join Date: Feb 2007
Posts: 1,002
WhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to beholdWhiteDragon is a splendid one to behold
Quote:
Originally Posted by cbk1994 View Post
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 . 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.
Reply With Quote
  #8  
Old 05-17-2011, 05:04 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 WhiteDragon View Post
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.
__________________
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 12:32 PM.


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