Author Topic: Adding items to a player  (Read 366 times)

Ok, so this worked before, but now it's not working at all. I'm creating server commands and they are supposed to add items to a player.
function serverCmdBuyPrimary(%client,%class,%tier)
{
Code: [Select]
switch$(%class) {
case "Assault": //=======================================================[ CLASS 1: ASSAULT ]
if(%tier == 1)
{
%client.player.addItem("Classic A. Rifle");
messageClient(%client,'',"Purchased Class A. Rifle for FREE");
}
else if(%tier == 2 && %client.score >= 500)
{
%client.score -= 500;
%client.player.addItem("Assault Rifle");
messageClient(%client,'',"Purchased Assault Rifle for 500 score");
}
else if(%tier == 3 && %client.score >= 1000)
{
client.score -= 1000;
%client.player.addItem("Modern A. Rifle");
messageClient(%client,'',"Purchased Modern A. Rifle for 1000 score");
}
else
{
messageClient(%client,'',"That tier is invalid!");
}
so the message-sending works, but when it adds an item, it's not working. please help

Damn, alchy!
'dem prices!!

Damn, alchy!
'dem prices!!
wow he's right those are some crazy prices

i guess you're rewarding well for kills.



i'm guessing you had Event_AddItem on before or something, addItem isn't a default method.

From Event_AddItem (by Destiny)
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;
      }
   }
}

You should probably just enable Event_AddItem or something though if this is a private mod.


edit:
Also, I noticed your final else is stating that the tier is invalid, but that may possibly cause a logical error since that can also happen if they don't have enough money for the selected tier. Not really breaking anything, just a logical error.
« Last Edit: October 04, 2012, 07:20:54 PM by otto-san »