Graal Forums  

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

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 03-31-2011, 06:06 PM
PhilSmith PhilSmith is offline
Workin' on It
PhilSmith's Avatar
Join Date: Mar 2011
Location: Chicago
Posts: 38
PhilSmith is on a distinguished road
Weapon Names Problem

I've been trying to make a custom inventory and while doing so I have come across a slight problem. I want to make the inventory hide the typical "-" and "*" weapons, however my check is not working. It seems as though the weapons that are named with these starting characters, are actually not (in the mind of my script).

PHP Code:
for(i=0;i<player.weapon.size();i++){
    if(!
player.weapon[i].name.starts("-")){
      new 
GuiBitmapButtonCtrl("PhilSmith_Weapon_"@i){
        
profile=PhilSmith_HUDButtons;
        
PhilSmith_Inventory.x+(i*40);
        
PhilSmith_Inventory.y+15;
        
normalbitmap temp.imgs[i];
        
mouseoverbitmap temp.imgs[i];
        
pressedbitmap temp.imgs[i];
        
width 32;
        
height=32;
        
text=player.weapon[i].name;
      }
    }
  } 
Thanks for taking the time to look this over to help me.
__________________
Nothing to say...
Reply With Quote
  #2  
Old 03-31-2011, 06:25 PM
xAndrewx xAndrewx is offline
Registered User
xAndrewx's Avatar
Join Date: Sep 2004
Posts: 5,260
xAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud ofxAndrewx has much to be proud of
PHP Code:
for(i=0;i<player.weapons.size();i++){
    if(
player.weapons[i].name.starts("-")) continue;
    if(
player.weapons[i].name.pos("/")) continue;
    new 
GuiBitmapButtonCtrl("PhilSmith_Weapon_"@i){
      
profile=PhilSmith_HUDButtons;
      
PhilSmith_Inventory.x+(i*40);
      
PhilSmith_Inventory.y+15;
      
normalbitmap temp.imgs[i];
      
mouseoverbitmap temp.imgs[i];
      
pressedbitmap temp.imgs[i];
      
width 32;
      
height=32;
      
text=player.weapons[i].name;
    }
  } 
Use player.weapon[S] not player.weapon

gj on coding though
__________________
Reply With Quote
  #3  
Old 03-31-2011, 08:16 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
Well let's throw some more detail your way...

player.weapons - holds a list of weapon objects that you currently have:

PHP Code:
for (temp.weaponplayer.weapons) {
  echo(
temp.weapon.name);

You can check if a player has a certain weapon like this:

PHP Code:
// Setup: Weapon name to check for
temp.weaponname "-System";

// Method using findweapon
temp.weapon findweapon(temp.weaponname);
if (
temp.weapon in player.weapons) {
  echo(
"Player has " temp.weaponname);
}

// Directly referring to the weapon object
if ((@temp.weaponnamein player.weapons) {
  echo(
"Player has " temp.weaponname);

You can even access functions and variables in other weapons:

PHP Code:
findweapon("-System").someAwesomeFunction();
echo((@
"-System").answer)); // echos "3" 
Weapon: -System

PHP Code:
public function someAwesomeFunction() {
  echo(
"awesomeness detected.");
}

this.answer "3"
The methods are basically the same, except the findweapon way is little more clear (imo) to other people reading the script.
__________________
Quote:
Reply With Quote
  #4  
Old 04-01-2011, 02:02 AM
PhilSmith PhilSmith is offline
Workin' on It
PhilSmith's Avatar
Join Date: Mar 2011
Location: Chicago
Posts: 38
PhilSmith is on a distinguished road
Thanks guys. Snk your always a big help . Thanks fowlplay for going out of your way to teach Especially teaching more than I asked for. It gives me more knowledge, and more possible way to do something like this
__________________
Nothing to say...
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:14 AM.


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