Deleting item from inventory

Author Topic: Deleting item from inventory  (Read 1081 times)

Anyone know how to delete an item from inventory after it's been used?

I got it so you can't use it anymore, but for some weird reason it remains in your inventory, if you scroll to it nothing happens and you can't drop it. It's just like a ghost, it will even get over-written if you pick up a new item, what's up with that?

Figured it out by looking at other scripts, turns out all you have to do is insert this when you want the item gone
Code: [Select]
%currSlot = %obj.currTool;
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
%obj.unMountImage(%slot);
« Last Edit: December 03, 2012, 02:59:44 PM by Lando The Climber² »

You may wanna remove "%obj.hasSTD=0;"

You may wanna remove "%obj.hasSTD=0;"
Oh yeah :cookieMonster: That was what using the item would do, removed.


That drops the item, he wants it gone.

That drops the item, he wants it gone.
now he only wants it gone....

function Player::removeItem(%this,%item,%bool,%cl) {
   if(isObject(%this)) {
      if(%item>0) {
         for(%i=0;%i<5;%i++) {
            %tool=%this.tool[%i].getID();
            if(%tool==%item.getID()) {
               %this.tool[%i]=0;
               messageClient(%cl,'MsgItemPickup','',%i,0);
               if(%this.currTool==%i) {
                  %this.updateArm(0);
                  %this.unMountImage(0);
               }
               if(!%bool)
                  break;
            }
         }
      }
   }
}


does this help?
it removes a specific item from the players inventory


This looks kinda messy...
Code: [Select]
function Player::removeItem(%this,%item)
{
   if(!isObject(%this) || !isObject(%item.getID()))
      return;
   for(%i=0;%i<5;%i++)
   {
      %tool=%this.tool[%i].getID();
      if(%tool==%item.getID())
      {
         %this.tool[%i]=0;
         messageClient(%this.client,'MsgItemPickup','',%i,0);
         if(%this.currTool==%i)
         {
            %this.updateArm(0);
            %this.unMountImage(0);
         }
      }
   }
}

Prettier?