Hi, I'm still fairly new to coding, I'm having problems installing a smaug banking code written by Minas Ravenblood, on the latest version of smaugfuss..
Help would be highly appreciated..
Cygwin errors at are:
bank.c: In function `do_deposit':
bank.c:126: error: structure has no member named `balance'
bank.c:129: warning: too many arguments for format
bank.c: In function `do_withdraw':
bank.c:177: error: structure has no member named `balance'
bank.c:181: error: structure has no member named `balance'
bank.c:195: error: structure has no member named `balance'
bank.c: In function `do_balance':
bank.c:223: error: structure has no member named `balance'
I've been looking at the given lines for some time now but cant seem to figure out what I did wrong..
I'm hoping anyone can help me out here before I turn grey and pull out all my hair :/
Thanks in advance
-Addrodoc-
A message directed to Mr Gammon: I've lost my old password and screwed up a few times at both requesting my old password and making a new account..
I'm not sure if one is allowed to have a second account, if it's a problem then please delete my old account and i'll stick to this one in the future.
thanks
Post us the offending code and we can help more, just giving error messages leads to little more than guesswork I'm afraid.
bank.c:126: error: structure has no member named `balance'
ch->gold -= amount;
ch->pcdata->balance += amount; <-- line 126
set_char_color( AT_PLAIN, ch );
ch_printf( ch, "You deposit %d gold.\n\r", amount );
snprintf( buf, MAX_STRING_LENGTH, "$n deposits %d gold.\n\r", amount );
act( AT_PLAIN, buf, ch, NULL, NULL, TO_ROOM );
save_char_obj( ch );
return;
}
bank.c:177: error: structure has no member named `balance'
bank.c:181: error: structure has no member named `balance'
if ( !str_cmp( arg1, "all" ) )
amount = ch->pcdata->balance; <-- line 177
else
amount = atoi( arg1 );
if( amount > ch->pcdata->balance ) <--- line 181
{
a few more all pointing out to pcdata->balance..
------------------------------------------------------------
I followed these instructions:
1. To install this code:
Copy bank.c and bank.h to your src directory. Add bank.c, bank.h
and bank.o to the appropriate sections in your Makefile.
2. In mud.h, find the pc_data structure, and add the following to it:
int balance;
Find the following:
#define LEVEL_HIGOD LEVEL_GOD
and after it add: #include "bank.h"
find the ACT flags for mobiles, and define
ACT_BANKER using an available slot.
3. In save.c, function fwrite_char, find the following line:
fprintf( fp, "Favor %d\n", ch->pcdata->favor );
Add the following line below it:
fprintf( fp, "Balance %d\n", ch->pcdata->balance );
Locate function load_char_obj, find the following line:
ch->pcdata->wizinvis = 0;
Add the following line below it:
ch->pcdata->balance = 0;
Locate function fread_char, find the following line:
KEY( "Bamfin", ch->pcdata->bamfin, fread_string_nohash( fp ) );
Add the following line above it:
KEY( "Balance", ch->pcdata->balance, fread_number( fp ) );
4. In build.c, find the act_flags for mobs, and add "banker" in the
spot corresponding to the new ACT_BANKER flag you defined in mud.h.
5. Make the appropriate additions to tables.c for
do_balance, do_withdraw, and do_deposit.
6. Add the text from bank.help to your help.are file.
7. Make clean, then recompile.
8. Create commands for balance, deposit, and withdraw.
9. Set the banker flag on a mob of your choice.
Looks like you didn't add the balance field to the pc_data structure. You should do that, and then 'make clean' then 'make'.
I've added the line 'int balance;' to the part 'struct char_data' in mud.h (it's the only part I can find that looks like pc data structure.. Also, running a find on pc_data structure doesnt seem to work)
It seems I'm having a hard time locating the pc data structure in mud.h.. can someone point out where and what to look for?
thanks
Search for this comment: Data which only PC's have.
Hunting for pc_data would have led you there as well, probably just needed to bounce down a bit farther is all :)
Yes, if the instructions say add it to pc_data and you add it to char_data, the snippet certainly won't work. :-)
The exact phrase you want to search for is "pc_data" as Samson said. Perhaps "struct pc_data" will work as well. Or use the comment that Whiteknight suggested.
I got it to compile without errors, thanks everyone.
However, when I log on the mud and give a mob a banker flag, it doesn't recognise my mob as a banker.
I've tried to give the act flag a different place and number, but after a compile it is still giving me the message 'You're not in a bank!'.
I'm not ready to give up yet, and knowing myself I probably wont stop untill I go K.O from a lack of sleep.. so help is appreciated :)
if you are giving the flag to a mob thats already loaded youll need to destroy the existing mobs and load new ones before the flag goes into effect usually. You probly could use set to add the flag to the existing mobs but it tends to be more headache than its worth to try.
I got it to work, thanks everyone. I would not have been able to do this without the help of you guys. I've learned a lot over the last few days and am encouraged to keep building. Thanks! I'm hoping one day I will be able to give some knowledge back to the community... Untill then, I'll be around here reading and perhaps posting questions once new bugs and errors pop up. :P
Once again, THANKS x100!