The addItem event foolishly uses the %client variable as the last parameter on the event when being delcared like this: Player::addItem(%player, %image, %client). This causes anyone who wants to use it outside of the event to have to do %player.addItem(wrenchItem, %player.client);
This is how I go about adding items to players:
for(%i = 0; %i < %this.getDatablock().maxTools; %i++)
{
%tool = %this.tool[%i];
if(%tool == 0)
{
%this.tool[%i] = %item;
%this.weaponCount++;
messageClient(%cl, 'MsgItemPickup', '', %i, %item);
break;
}
}
If you don't understand what that's doing I'll explain. It does a for loop for the amount of slots the player's playerType data has and looks for a slot that doesn't have an item in it (%tool being 0). If it finds one, it sets the tool to be that item data and uses messageClient so the client knows it has the item.
%this being the player object.