Blockland Forums > Modification Help
Setting an item to slot 4.
Daenth:
I'm not all that advanced in scripting and I'm trying to get into it. One problem I have encountered trying to make a little script is that I have no idea how set and item to a specific slot. Could someone give me an example of what the code should look like?
Destiny/Zack0Wack0:
Do you mean to give the player a tool in slot 4?
--- Code: ---%item = hammerItem.getID();//the item you want to give them, change it to yours
%slot = 3;//the index of the slot
%oldTool = %player.tool[%slot];
%player.tool[%slot] = %item;
messageClient(%player.client,'MsgItemPickup','',%slot,%item);
if(%oldTool <= 0)
%player.weaponCount++;
--- End code ---
Daenth:
--- Quote from: Destiny/Zack0Wack0 on April 20, 2011, 09:18:43 PM ---Do you mean to give the player a tool in slot 4?
--- Code: ---%item = hammerItem.getID();//the item you want to give them, change it to yours
%slot = 3;//the index of the slot
%oldTool = %player.tool[%slot];
%player.tool[%slot] = %item;
messageClient(%player.client,'MsgItemPickup','',%slot,%item);
if(%oldTool <= 0)
%player.weaponCount++;
--- End code ---
--- End quote ---
By "give" does it override the current item in the slot?
Greek2me:
Yes, the old item would be replaced with the new one.
Treynolds416:
If you wanted it not to be able to do that, use an if statement
--- Code: ---if(%oldTool <= 0)
//Don't do anything
else
//Zack's Script
--- End code ---