I've tried calling the addItem event from a script and in the console, but I haven't found a way to give a tool to a client. I looked at another topic, and tried using this:
function GameConnection::forceEquip(%this,%slot,%item)
{
%player = %this.player;
if(!isObject(%player))
{
return;
}
if(!isObject(%item))
{
%item = 0;
}
%oldTool = %player.tool[%slot];
%player.tool[%slot] = %item;
messageClient(%this,'MsgItemPickup','',%slot,%item);
if(!isObject(%oldTool))
{
%player.weaponCount ++;
}
}
function utdmAddWeapon(%client, %itemData)
{
%max = %client.player.getDatablock().maxTools;
for(%i=0;%i<%max;%i++)
{
if(!%client.player.slot[%i])
{
%client.forceEquip(%client, %i, %itemData.getId());
break;
}
}
}
Sorry about the uneven indentation. I copied this from my phone.
%itemData is the ItemData datablock.. Example: GunItem or gc_rpg7Item.
So can somebody please help me make it work?
I suspect that %client.forceEquip
should not have a %client as the first argument.