Got most of what i want working.
What i am doing is letting people toss worthess stuff in trash can for recycling and getting a 2 dollar reward for it. It works fine but the check i have to see what the value of the item is, is not checking and letting me toss it anyway. here is my code, if someone has some pointers on why it isn't working i would appreciate it.#include <lib.h>
inherit LIB_STORAGE;
void create() {
::create();
SetKeyName("trashcan");
SetId(({"trashcan","can","dustbin","trash","rubbish"}));
SetAdjectives(({"metal","small","blue","recycling","trash","garbage","dust"}));
SetShort("a recycling bin");
SetLong("This is a blue trash can, marked with "+
"the letters \"/dev/null\".");
SetMass(274);
SetBaseCost("dollars",50);
SetMaxCarry(999999);
}
id (str) { return str=="trashcan" || str == "can"; }
init()
{
::init();
add_action("toss","waste");
add_action("toss","toss");
}
toss (str)
{
object ob;
string item;
int i,reward;
if (!str)
return write ("Usage: 'toss <what>'.\n");
str = lower_case (str);
if (!(ob = present(str,this_player())))
{
if(!sscanf(str,"%s in trashcan",item) || !(ob=present(item,this_player())))
if(!sscanf(str,"%s in the trashcan",item) ||
!(ob=present(item,this_player())))
{
write ("You don't have that.\n");
return 1;
}
}
if (ob->SetValue() > 10)
return write ("That item is too valuable to toss.\n");
if (ob->drop())
return write("That item cannot be tossed.\n");
if (living(ob))
{
tell_object(ob, this_player()->GetName() + " tossed you away!\n");
write("Naughty boy!\n");
}
ob = deep_inventory(ob) + ({ ob });
for(i=0; i < sizeof(ob); ++i)
destruct(ob[i]);
write ("The trashcan starts grinding the " + str + ".\n");
say (this_player()->GetName() + " tosses " + str + " in the trashcan.\n");
call_out ("reward", 2, this_player());
return 1;
}
reward (who)
{
tell_object(who, "You get 2 dollars from the trashcan for showing tidyness.\n");
say(who->GetName() + " gets 2 dollars from the trashcan for showing tidyness.\n",who);
who->AddCurrency("dollars",2);
}