gah...Currency problem

Posted by Ithildin on Tue 01 Jun 2004 05:04 AM — 6 posts, 21,195 views.

USA #0
i just spent my whole day putting in a currency snippet. right now, it's working, but everything but the gold is going to inventory. the snippet is for gold silver copper. i also put in platinum. i changed the system to look like this:

10 gold = 1 plat
10 silver = 1 gold
10 copper = 1 silver

whenever i give a mob 20 copper, i'll kill it, get the 20 copper, it won't go to score, but it'll go to my inventory. also, whenever i give the mob platinum, it comes back as copper when i get it from corpse. so if a mob has 20 plat on him, when i kill it i get 20 copper back and it's in my inventory as 20 copper. copper in my score doesn't change.

i'll post some code later, just wondered if anyone had this happen to them as well.

i have no idea, what's goin on. i'm looking through all my steps again. but it's so tedious and late at night. i'll try to put some code up soon.
USA #1
ok, for the most part, i have it working. but the platinum is still converting to copper. so i'm gonna look some more on that. i guessed i messed up somewhere in that tonage of code. heh.


i had just forgot to put the copper as type copper etc.
USA #2
here might be my problem:


/*
 * make some coinage
 * G/S/C support -Druid
 * type:
 * 0 = gold
 * 1 = silver
 * 2 = copper
 * 3 = platinum
 */
OBJ_DATA *create_money( int amount, int type )
{
    char buf[MAX_STRING_LENGTH];
    OBJ_DATA *obj;

    if ( amount <= 0 )
    {
	bug( "Create_money: zero or negative money %d.", amount );
	amount = 1;
    }
    
    if( type>4 || type<0)
    {
    	bug("Create_money: wrong type: %d!",type);
    	type=2;
    }

	if (type ==0)
	{
    	if ( amount == 1 )
    	{
		obj = create_object( get_obj_index( OBJ_VNUM_GOLD_ONE ), 0 );
		return obj;
    	}
    	else
    	{
		obj = create_object( get_obj_index( OBJ_VNUM_GOLD_SOME ), 0 );	
		sprintf( buf, obj->short_descr, amount );
		STRFREE( obj->short_descr );
		obj->short_descr = STRALLOC( buf );
		obj->value[0]	 = amount;
		return obj;
    	}
	}
	
	if (type ==1)
	{
    	if ( amount == 1 )
    	{
		obj = create_object( get_obj_index( OBJ_VNUM_SILVER_ONE ), 0 );
		return obj;
    	}
    	else
    	{
		obj = create_object( get_obj_index( OBJ_VNUM_SILVER_SOME ), 0 );	
		sprintf( buf, obj->short_descr, amount );
		STRFREE( obj->short_descr );
		obj->short_descr = STRALLOC( buf );
		obj->value[0]	 = amount;
		return obj;
    	}
	}
	
	if (type == 2)
	{
    	if ( amount == 1 )
   	 {
		obj = create_object( get_obj_index( OBJ_VNUM_COPPER_ONE ), 0 );
		return obj;
    	}
    	else
    	{
		obj = create_object( get_obj_index( OBJ_VNUM_COPPER_SOME ), 0 );	
		sprintf( buf, obj->short_descr, amount );
		STRFREE( obj->short_descr );
		obj->short_descr = STRALLOC( buf );
		obj->value[0]	 = amount;
		return obj;
    	}
	}
	if (type == 3)
	{
    	if ( amount == 1 )
   	 {
		obj = create_object( get_obj_index( OBJ_VNUM_PLATINUM_ONE ), 0 );
		return obj;
    	}
    	else
    	{
		obj = create_object( get_obj_index( OBJ_VNUM_PLATINUM_SOME ), 0 );	
		sprintf( buf, obj->short_descr, amount );
		STRFREE( obj->short_descr );
		obj->short_descr = STRALLOC( buf );
		obj->value[0]	 = amount;
		return obj;
    	}
	}
	obj = create_object( get_obj_index(  OBJ_VNUM_COPPER_ONE ), 0 ); <-----this might be?
	return obj;    
}



i'll go tinker with it
Canada #3
I think we had this exact problem with that same snippet a few months back, search in the forums, I'm sure we figured it out before.
USA #4
i have already searched the forums. the message that toy had awhile back was for a command for his bankers. which i'll implement that final code once i get this taken care of.

the only problem is, that platinum is converting to copper and i can't seem to find it anywhere.
USA #5
i found it...gah. this took too long..heh.

now on to putting in toy's code. ;)