I am writting a code for clan members to donate questpoints to a clan balance, where the clan leader can view the total balance of the clan, the clan leader then can use those to purchase clan things. What I need help with is, creating a command to save value to a file, and incriment the value in in the file vs the value people donate and I need help in creating a command that can read the file and retrieve the value saved in the file.
Some basic understanding of how to save to a file say a clan file, and how to retrieve information from it would be appreciated, I figure I would have to setup something as a pointer for the command to read from. then use something like fread("BALANCE") or whatever the tagline I want to call, and fwrite etc to write it. But I need a simple layout of how to set this up, it would be GREATLY appreciated.
You can probably find whatever command records the clan info and add it to there.
-Mark Calloway
i apologize for size of this note
heres snippet i wrote for yeh.. might not work, havent tested it but if look at it should see how to add things to clans, this makes so can use 'donate (ammount)' and can see total when do clans ___ there is no way for imms to edit other then going into the clans file but i assume u can add something in setclan or so that will make it so u can have leader buy stuff with clan valor for the clan
starters.. open mud.h
-in clan_data after
int class; /* For guilds */
-add
int vbalance;
-in the declare_do_fun stuff add before do_down add
DECLARE_DO_FUN( do_donate );
-open tables.c
-add
if ( skill == do_donate ) return "do_donate";
-and
if ( !str_cmp( name, "do_donate" )) return do_donate;
-in respective positions
-open clans.c
-after
KEY( "Badge", clan->badge, fread_string( fp ) );
-add
KEY( "BalanceV", clan->vbalance, fread_number( fp ) );
-before
void do_induct( CHAR_DATA *ch, char *argument )
-add
void do_donate( CHAR_DATA *ch, char *argument )
{
char arg[MAX_INPUT_LENGTH];
char buf[MAX_STRING_LENGTH];
int amount = 0;
argument = one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Usage: donate <amount>\n\r", ch);
return;
}
amount = atoi(arg);
if ( amount < 0 )
{
send_to_char( "Let me see... when dwarfs fly.\n\r", ch );
return;
}
if( amount > ch->pcdata->quest_curr)
{
send_to_char("You do not have that much glory", ch);
return;
} else
{
sprintf( buf, "You donate %d valor to the cause!\n\r", amount);
send_to_char( buf, ch );
ch->pcdata->quest_curr -= amount;
ch->pcdata->clan->vbalance += amount;
save_clan( ch->pcdata->clan );
}
return;
}
-in do_clans Before
ch_printf( ch, "\n\rDescription: %s\n\r", clan->description );
-add
ch_printf( ch, "\n\rValor: %d\n\r", clan->vbalance );
theres prob some pharse/spelling errors i always get 1 or 2 of them but.. u get idea, just once get compiled and running start mud and with ur imm do
cedit donate create do_donate
cedit donate level 5
cedit save cmdtable
-and set, any probs email me or post a note
missed one
in clans.c after
fprintf( fp, "Badge %s~\n", clan->badge );
add
fprintf( fp, "BalanceV %s~\n", clan->vbalance );
or else wouldnt save
Thank you for your help... also thank you Chris for writting out an excellent example.
I've been able to take that example and turn it into a fully functional clan donation system. Along with Balance, Total life donations, a deduction command for immortals to remove qps for purchases, a donation_fame board, that displays to members of the clan a list of people who've donated and how much, listed in a top 10 format.
Once again, Thanks Chris.
The Guardian,
Xyrex