ehovda321
Junior Member
Posts: 38
Threads: 22
Joined: Dec 2011
Reputation:
0
RemoveItem("tinderbox") not working!
Here is my script -
Spoiler below!
void OnStart()
{
SetEntityPlayerInteractCallback("buy_a", "buy_a", false);
SetEntityPlayerInteractCallback("sell_a", "sell_a", false);
}
void buy_a(string &in asEntity)
{
if(GetGlobalVarInt("buy_a") == 0) // < --- STOCK \\
{
SetGlobalVarInt("buy_a", 0);
SetMessage("store", "out", 3);
}
if(GetGlobalVarInt("balance") < 3) // < --- BALANCE \\
{
SetMessage("store", "cannotafford", 3);
}
if(GetGlobalVarInt("buy_a") > 0) // < --- STOCK \\
{
if(GetGlobalVarInt("balance") > 2) // < --- BALANCE \\
{
t_count++;
GiveItemFromFile("tinderbox_"+(t_count), "tinderbox.ent");
PlayGuiSound("cash_register.ogg", 1);
AddGlobalVarInt("balance", -3);
AddGlobalVarInt("buy_a", -1);
AddGlobalVarInt("tinderbox_total", 1);
SetMessage("store", "bought_a", 2.5);
checkamount_buy();
checkbalance();
}
}
}
void sell_a(string &in asEntity) // < -- Player SELLS ONE TINDERBOX \\
{
if(GetGlobalVarInt("tinderbox_total") == 0)
{
SetMessage("store", "notenough", 3);
}
if(GetGlobalVarInt("tinderbox_total") > 0) // < --- YOUR AMOUNT \\
{
for(int z = 1; z < 251; z++)
{
RemoveItem("tinderbox_"+(z - 1));
}
for(int y = 0; y < GetGlobalVarInt("tinderbox_total"); y++)
{
RemoveItem("tinderbox");
}
t_count++;
GiveItemFromFile("tinderbox_"+(t_count), "tinderbox.ent");
PlayGuiSound("cash_register.ogg", 1);
AddGlobalVarInt("balance", 2);
AddGlobalVarInt("buy_a", 1);
AddGlobalVarInt("tinderbox_total", -1);
SetMessage("store", "sold_a", 2.5);
checkamount_sell();
checkbalance();
}
}
What's the problem? When I click the button for "sell_a", it will double the amount!?
(This post was last modified: 03-29-2013, 01:50 AM by ehovda321 .)
03-29-2013, 01:50 AM