//Check if player currently has item equipped in layer 2 var tempObj = tChar.FindItemLayer(2);
//If he has, unequip it if( tempObj !=null) tempObj.container= tChar.pack; else { //If there is no item equipped in layer 2, create one and equip it on character var itemMade = CreateDFNItem( tChar.socket, tChar,"0x13e4",1,"ITEM",true); if( itemMade ) { itemMade.container= tChar; itemMade.layer=2; } else tChar.SysMessage("Failed to create item."); }
I suppose a Wiki-type thing would be the most ideal - though we tried that before, hosted on sourceforge. Only a few people contributed, and eventually the wiki was overrun by spammers. It is no longer operational.
Hey Xuri, your above code is awesome, I modified it slightly to actually make a self equipping item. thx!
This was something I was trying to figure out too.
function onUseUnChecked(objPlayer,objItem)
{
//Check if player currently has item equipped in layer 10
var tempObj = objPlayer.FindItemLayer( 10 );
//If he has, unequip it
if( tempObj != null )
tempObj.container = objPlayer.pack;
else
{
//If there is no item equipped in layer 10, equip me on character
var itemMade = objItem // Xuri's create line --> CreateDFNItem( objPlayer.socket, objPlayer, objItem.id, 1, "ITEM", true );
if( itemMade )
{
itemMade.container = objPlayer;
itemMade.layer = 10;
}
else
objPlayer.SysMessage( "Failed to hook item." );
}
}