Quote:
Originally Posted by Stryke
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;
x = 10;
y = 10;
this.itemName = "Guns/KABOOM!!!111!!";
}
'name' is reserved by default.