View Single Post
  #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.weapon: player.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.weaponname) in 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