View Single Post
  #11  
Old 05-11-2008, 04:27 PM
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 Stryke View Post
PHP Code:
function InvItem_0.onMouseDown() {
  for(
temp.i=0;temp.i<player.weapons.size();temp.i++;)
  {
    if(
player.weapons[temp.i].name == InvItem_0)
    {
      
temp.var == temp.i;
      break;
    }
  }
  
selectedweapon temp.var;

How would I make it so that if you click an item, it will equip it?
This won't work.. Also is it possible to put a function in a for statement because I don't want to make 20 function InvItem_x.onMouseDown's.
PHP Code:
function InvItem_0.onMouseDown() {
  for(
temp.i=0;temp.i<player.weapons.size();temp.i++;)
  {
    if(
player.weapons[temp.i].itemName == InvItem_0)
    {
      
player.selectedweapon temp.i;
      return;
    }
  }

and then in your items

PHP Code:
new GuiShowImgCtrl"InvItem_0" )
{
  
image "x.png";
  
width 32;
  
height 32;
  
10;
  
10;
  
  
this.itemName "Guns/KABOOM!!!111!!";

'name' is reserved by default.
__________________
Reply With Quote