Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ SMAUG
➜ SMAUG coding
➜ Writting to a file, then retrieving the value.....
Writting to a file, then retrieving the value.....
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Xyrex
(12 posts) Bio
|
Date
| Tue 02 Jul 2002 12:02 AM (UTC) |
Message
| 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. | Top |
|
Posted by
| Neves
USA (78 posts) Bio
|
Date
| Reply #1 on Tue 02 Jul 2002 04:58 AM (UTC) |
Message
| You can probably find whatever command records the clan info and add it to there.
-Mark Calloway | Top |
|
Posted by
| Chris L
USA (57 posts) Bio
|
Date
| Reply #2 on Wed 03 Jul 2002 06:03 PM (UTC) |
Message
| 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 | Top |
|
Posted by
| Chris L
USA (57 posts) Bio
|
Date
| Reply #3 on Thu 04 Jul 2002 03:44 AM (UTC) |
Message
| 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 | Top |
|
Posted by
| Xyrex
(12 posts) Bio
|
Date
| Reply #4 on Thu 04 Jul 2002 05:05 PM (UTC) |
Message
| 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 | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
17,883 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top