Author Topic: Make item able to be picked up more than once?  (Read 956 times)

I wasn't sure how to exactly word the title but here is what I mean, most items have it to where you can only have one of each but I have a item on my server that I need to edit so I can hold more of it and I can't seem to find which line changes that, can someone please help me?

You want to make it so you can pick an item up more than once? so it doesn't disappear after the first person got it?

I mean be able to put more than one of it in your inventory, like the pill or C4

This code is from the Pill Item, it should point you in the right direction.

Code: [Select]
function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
if(%col.dataBlock $= "PillItem" && %obj.getDamagePercent() < 100 && %col.canPickup)
{
for(%i=0;%i<%this.maxTools;%i++)
{
%item = %obj.tool[%i];
if(%item $= 0 || %item $= "")
{
%freeSlot = 1;
break;
}
}

if(%freeSlot)
{
%obj.pickup(%col);
return;
}
}
Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
}

I'm not a coder so I honestly have no clue what I'm doing but I'm guessing that I'm looking for "freeslot"
Nope, there is no freeslot.
« Last Edit: May 23, 2013, 12:07:21 PM by Alyx Vance »

This code is from the Pill Item, it should point you in the right direction.


function Armor::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f)
{
   if(%col.dataBlock $= "PillItem" && %obj.getDamagePercent() < 100 && %col.canPickup)
   {
      for(%i=0;%i<%this.maxTools;%i++)
      {
         %item = %obj.tool[%i];
         if(%item $= 0 || %item $= "")
         {
            %freeSlot = 1;
            break;
         }
      }

      if(%freeSlot)
      {
         %obj.pickup(%col);
         return;
      }
   }
   Parent::onCollision(%this, %obj, %col, %a, %b, %c, %d, %e, %f);
}

Just rename what is in bold to your item datablock. Then add the piece of script to the bottom of your script.

I'm trying to make Ibans molotov to be picked up more than once but he has the script set up weird so I'm really not sure what I'm doing.
I'm horrible at coding stuff.

Make a download for your .zip

Its on RTB. Ibans Molotov