OHHH i see now why you did that. But still, if i remember correctly "if(-1)" returns true.
anyways, your problem was the
%player.tool[%i] = %obj.dataBlock.getID();
You used tool[%i] not tool[%freeslot]. Why it doesnt add is because %i is equal to maxTools so technically, it is the slot right after the last inventory slot.
so this would be the correct code. changed a little bit for efficency.
if(%obj.getClassName() $= "Item")
{
for(%i = 0; %i < %player.getDatablock().maxTools; %i++)
{
if(!%player.tool[%i])
{
%freeSlot = %i;
}
if(%player.tool[%i] == %obj.dataBlock.getID())
{
//Already has item, abort abort
return;
}
}
if(%freeSlot)
{
%player.tool[%freeSlot] = %obj.dataBlock.getID();
%player.weaponCount++;
messageClient(%player.client, 'MsgItemPickup', '' , %i, %obj.dataBlock.getID());
}
%obj.delete();
return;
}