I've been trying to make a crafting system for my Escapists server, and made something that didn't work. I am, however, pretty sure it doesn't work due to some errors I made (NOT sytax errors) while working on it.
What it is supposed to do: Type /craftItem <itemName> <TwoOrThreeSlotNumbers>, and then it will check to see if the items in <TwoOrThreeSlotNumbers> are the required item for <ItemName>.
What it Does: Absolutely nothing.
Here's the code:function serverCmdCraftItem (%client, %item, %item1, %item2, %item3)
{
%player = %client.player;
%item = %item@"Item";
for(%i = 1; %i < 3; %i++)
{
%slot[%i] = %item[%i];
%item[%i] = %client.player.tool[%item[%i]];
%item[%i] = %item[%i]@"Item"; //Make it so instead of showing up as "ToiletPaper" it'll show up "ToiletPaperItem";
}
%craftReq = %item.craftingRequrements;
%craftINT = %item.craftingIntRequirement;
%craftReq = strReplace(%craftReq, ",", ""); //remove commas from Crafting Requirement string.
%craftItem[0] = getWord(%craftReq, 0);
%craftItem[1] = getWord(%craftReq, 1);
%craftItem[2] = getWord(%craftReq, 2);
if(%craftItem[2] $= "")
{
%item3 = "";
}
if(%item1 $= %craftItem[0] && %item2 $= %craftItem[1] && %item3 $= "")
{
echo(%client.name@" - Crafting success!");
%currSlot = %slot[0];
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
%currSlot = %slot[1];
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
for(%i = 0; %i < %player.getDatablock().maxTools; %i++)
{
%tool = %player.tool[%i];
if(%tool == 0)
{
%player.tool[%i] = %item;
%player.weaponCount++;
messageClient(%client,'MsgItemPickup','',%i,%item);
break;
}
}
}
if(%item1 $= %craftItem[0] && %item2 $= %craftItem[1] && %item3 !$= "" && %item3 $= %craftItem[2])
{
echo(%client.name@" - Crafting success!");
%currSlot = %slot[0];
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
%currSlot = %slot[1];
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
%currSlot = %slot[2];
%obj.tool[%currSlot] = 0;
%obj.weaponCount--;
messageClient(%obj.client,'MsgItemPickup','',%currSlot,0);
serverCmdUnUseTool(%obj.client);
for(%i = 0; %i < %player.getDatablock().maxTools; %i++)
{
%tool = %player.tool[%i];
if(%tool == 0)
{
%player.tool[%i] = %iitem;
%player.weaponCount++;
messageClient(%client,'MsgItemPickup','',%i,%item);
break;
}
}
}
}
Also, here's the code for an item to be crafted:datablock ItemData (PaperMacheItem : EBItem)
{
uiName = "Paper Mache";
colorShiftColor = "1 1 1 1";
isContraband = true;
craftingRequirements = "ToiletPaper, SuperGlue";
};
Thanks for helping me, it would really made my Escapists server go up faster!