Author Topic: Add item to player  (Read 957 times)

All I want to know is how to add an item, tool, or weapon to a player. For some reason I'm actually
having a difficult time figuring this out, maybe it's harder than it sounds?

download Event_addItem from an rtb archive and look into its code for the quickest results.

I'll post a version of mine in the morning.


This is the function used for Event_addItem
Code: [Select]
function Player::addItem(%player,%image,%client)
{
   for(%i = 0; %i < %player.getDatablock().maxTools; %i++)
   {
      %tool = %player.tool[%i];
      if(%tool == 0)
      {
         %player.tool[%i] = %image;
         %player.weaponCount++;
         messageClient(%client,'MsgItemPickup','',%i,%image);
         break;
      }
   }
}
Using this, I did this in the console:
Player::addItem(findClientByName("BigNaeyt").player, "GunItem", findClientByName("BigNaeyt"));

This causes the item to appear in my tools, but for some reason I can't scroll over it. Ideas?
« Last Edit: January 03, 2016, 05:02:25 PM by Radíowave »

Use GunItem.getId() instead, datablocks names aren't sent to the client so it can't find the object "GunItem" in MsgItemPickup

or nameToID("GunItem")