Author Topic: Forging?  (Read 3018 times)

Try my script again, it works fine for me:
Quote
/forge GoldOre 1
Forging costed you: 50 gold, 5 SilverOre, and you now have 1 GoldOre.

You might not have enough gold...
Try: ClientGroup.getObject(0).gold = 9999;
« Last Edit: June 08, 2008, 08:47:21 PM by exidyne »

Uhhhhh........ When I have 50 gold and 2 copper ore I type /forge silverore 1 and it say's Not enough material(s) need 10 more gold! so I grant 10 more gold and it say's same thing so I type /checkgold say's Gold: so then I type grantgold again but this time 1000 gold and type /checkgold I got it I type /forge silverore 1 and say's it again so I check and it's back to Gold:

I need to know how you're storing the client's gold.
In other words, what's your code for /grantgold and /checkgold?

Code: [Select]
function serverCmdGrantGold(%client,%victim,%amount)
{     
    if(%client.isAdmin||%client.isSuperAdmin)
    %victim = findClientByBL_ID(%victim);
    if(!isobject(%victim)){return;}//dont let them give Gold to non-existant people
    %victim.quantity["Gold"]+=%amount;
messageClient(%victim,'Given %1 by %2',%client.name,%amount);
}

function serverCmdgiveGold(%client,%victim,%amount)
{
   if(%amount<=0||%Amount>%client.quantity["Gold"])
   messageClient(%client,'','Not enough Gold! Gold: %1',%client.quantity["Gold"]);
    return;
    %victim = findClientByBL_ID(%victim);
    if(!isobject(%victim)){return;}//dont let them give Gold to non-existant people
    %victim.quantity["Gold"]+=%amount;
    %client.quantity["Gold"]-=%amount;
    messageClient(%victim,'Given %2 Gold by %1',%client.name,%amount);
}

 function serverCmdCheckGold(%client)
    {
       messageClient(%client,'','Gold Left : %1',%client.quantity["Gold"]);
}

Alright, this code should now work and be compatible with your other code.
« Last Edit: June 08, 2008, 09:11:35 PM by exidyne »


Err I wanted it so that you don't have to pay to forge it. Only use items
« Last Edit: June 08, 2008, 09:07:34 PM by Eonz »

So make each item cost 0 gold in the item prices...

I see.. But wont that affect the /buy script?

Code: [Select]
//Itembuying

$itemPrices["SilverOre"] = 20;
$itemImage["SilverOre"] = nametoid("SilverOreItem");
$itemPrices["CopperOre"] = 5;
$itemImage["CopperOre"] = nametoid("CopperOreItem");
$itemPrices["GoldOre"] = 50;
$itemImage["GoldOre"] = nametoid("GoldOreItem");
$itemPrices["PineWood"] = 5;
$itemImage["PineWood"] = nametoid("PineWoodItem");
$itemPrices["OakWood"] = 10;
$itemImage["OakWood"] = nametoid("OakWoodItem");
$itemPrices["MapleWood"] = 20;
$itemImage["MapleWood"] = nametoid("MapleWoodItem");
$itemPrices["sword"] = 100;
$itemImage["sword"] = nametoid("swordItem");
$itemPrices["bow"] = 150;
$itemImage["bow"] = nametoid("bowItem");
$itemPrices["WarAxe"] = 200;
$itemImage["WarAxe"] = nametoid("WarAxeItem");
$itemPrices["ShortSword"] = 100;
$itemImage["ShortSword"] = nametoid("ShortSwordItem");
$itemPrices["Spear"] = 50;
$itemImage["Spear"] = nametoid("SpearItem");
$itemPrices["PioneerHG"] = 250;
$itemImage["PioneerHG"] = nametoid("PioneerHGItem");
$itemPrices["Longsword"] = 200;
$itemImage["Longsword"] = nametoid("LongswordItem");
$itemPrices["MCrossBow"] = 150;
$itemImage["MCrossBow"] = nametoid("MCrossBowItem");

function serverCmdBuy(%client, %item, %amount_to_buy)
{
if( %amount_to_buy < 1 ) // They have to buy at least 1
return;

%price_of_item = $itemPrices[%item] * %amount_to_buy; // Calculate price

if( %price_of_item > %client.quantity["Gold"]) // If they don't have enough gold:
{
messageClient(%client, '', 'Not enough Gold! Gold Left: %1', %client.quantity["Gold"]);
return;
}

%image = $itemImage[%item];

// Add the amount:
%client.quantity[%item] += %amount_to_buy;

// The rest looks good. Find a free inventory slot, etc:
%k = 0;
%i = -1;
while( %k < 5 )
{
if( !%client.quantityplayer.tool[%k] )
{
%i = %k;
}
%k++;
}

if( %i == -1 )
{
messageClient(%client,'','Not enough inventory space!');
return;
}

%client.player.tool[%i] = %image;
messageClient(%client, 'MsgItemPickup', '', %i, %image);

%client.quantitygold -= %price_of_item;
       
}

« Last Edit: June 08, 2008, 09:14:26 PM by Eonz »

Why would you assume that I know anything about a /buy script? Like I said, you have to give me all the details because I can't read your mind. But it's fixed now .

By the way, now that I see your /buy code, you need to delete all of the item prices in the /buy script so they don't override the existing prices. Then replace:
Code: [Select]
      %price_of_item = $itemPrices[%item] * %amount_to_buy; // Calculate price
with:
Code: [Select]
      %price_of_item = firstWord($itemPrices[%item]) * %amount_to_buy; // Calculate price
« Last Edit: June 08, 2008, 09:25:00 PM by exidyne »

Thank's  work's so far without bug's.