Author Topic: Discard a Player Item  (Read 896 times)

How would I go about making a servercmd to discard an item?  (Not drop)  

It'd just remove their currently selected item or item in hand when used.  Thanks guys.

You should try to experiment with the trace(bool) and %obj.dump() functions instead of coming to coding help every time you encounter a problem.

You should try to experiment with the trace(bool) and %obj.dump() functions instead of coming to coding help every time you encounter a problem.

I've tried making this cmd a few times, so now I am using part of the remove item event.  Here's what I have so far:

Code: [Select]
function ServerCmdDiscardItem(%player, %item, %bool, %client)
{
if(%item > 0)
{
for(%i=0;%i<5;%i++)
{
%tool = %player.tool[%i];
if(%tool > 0)
%toolID = %tool.getID();
if(%toolID $= %item)
{
if(isObject(%player))
{
%player.tool[%i] = 0;

}
if(!%bool)
break;
}
}
}
}

In a server command, the first argument will always be the client.

How do you target a held selected item?  Meaning the item your inventory scroller is on.
« Last Edit: November 20, 2009, 09:24:21 PM by Tezuni »


you might consider using
      for(%i=0;%i<%client.player.getDatablock().maxTools;%i++)
      {
instead of this, in case you want to change the player's max tools sometime
      for(%i=0;%i<5;%i++)
      {

I've tried this:  (It's not working)

Code: [Select]
function servercmdDropTool(%client, %slot)
{
      messageClient(%client, 'MsgItemPickup', '', %slot, 0);
      %client.player.tool[%slot] = 0;
      %client.player.weaponCount--;
      serverCmdUnUseTool(%client);
parent::serverCmddropTool(%client, %slot);
}

*Yes it is packaged in my code I copied it from*

Question
Why are you remaking a default function?

Because the save item event is abuseable on my rp.  People can drop their items (for others to pick up) then Self Delete and reload everything.  I tried making a server cmd to discard the item, now im just making it use ctrl+w or the default item drop key bind.