Try something like this:
$Buying_StoreItem["Bow"] = "BowImage/t100";
function serverCmdBuy(%client, %item)
{
if(!$Buying_StoreItem[%item])
{
messageClient(%client,'',"\c6Please enter a valid item name! Replace all spaces with \"_\"!");
return false;
}
%price = getField($Buying_StoreItem[%item], 1);
%player = %client.player;
if (%client.gold < %price)
{
messageClient(%client,'',"\c6You don't have enough gold!");
return false;
}
if (%player.getDatablock().maxTools <= %player.weaponCount)
{
messageClient(%client,'',"\c6You don't have the space for that item!");
return false;
}
%client.gold-=%price;
messageClient(%client,'',"\c6You purchased a\c3"@%item@"\c6for\c3" SPC %price SPC "\c6!");
for (%i = 0; %i < %player.getDatablock().maxTools; %i++)
{
%tool = %player.tool[%i];
if(%tool == 0)
{
%player.tool[%i] = getField($Buying_StoreItem[%item], 0);
%player.weaponCount++;
messageClient(%client,'MsgItemPickup','',%i, %image);
break;
}
}
return true;
}
Note - I havent actually tested this, so there may be minor typos. But its shorter (less else if else), and the data for each store item is in 1 global instead of several.