void do_buyhome( CHAR_DATA *ch, char *argument )
{
ROOM_INDEX_DATA *room;
char *origarg = argument;
AREA_DATA *pArea;
char arg[MAX_INPUT_LENGTH];
if ( !ch->in_room )
return;
if ( IS_NPC(ch) || !ch->pcdata )
return;
if ( ch->plr_home != NULL )
{
send_to_char( "&RYou already have a home!\n\r&w", ch);
return;
}
room = ch->in_room;
for ( pArea = first_bsort; pArea; pArea = pArea->next_sort )
{
if ( room->area == pArea )
{
send_to_char( "&RThis area isn't installed yet!\n\r&w", ch);
return;
}
}
smash_tilde( argument );
argument = one_argument( argument, arg );
if ( arg[0] == '\0' )
{
send_to_char( "Usage: Buyhome <options>\n\r", ch );
send_to_char( "Options: purchase, sell, description, name\n\r", ch );
return;
}
// Allows a Player to buy a one room home
if (!str_prefix(arg,"purchase"))
{
if ( IS_SET( room->room_flags, ROOM_PLR_HOME))
{
if ( ch->PlayerHomeVnum == ch->in_room->vnum)
{
send_to_char( "Doh!!! You already own this home!!" , ch);
return;
}
send_to_char(" Umm you can't buy someone's home out from underneith them !!!", ch);
return;
}
if ( !IS_SET( room->room_flags , ROOM_EMPTY_HOME ) )
{
send_to_char( "&RThis room isn't for sale!\n\r&w", ch);
return;
}
if ( ch->gold < 100000 )
{
send_to_char( "&RThis room costs 100000 credits you don't have enough!\n\r&w", ch);
return;
}
send_to_char( "&RYou have just purchased a home in the world of Techno-Magicka.\n\r", ch);
send_to_char( "&RPlease see helpfile \"buyhome\" for the details on how to modify it.\n\r", ch);
ch->gold -= 100000;
REMOVE_BIT( room->room_flags , ROOM_EMPTY_HOME );
SET_BIT( room->room_flags , ROOM_PLR_HOME );
fold_area( room->area, room->area->filename, FALSE );
ch->plr_home = room;
ch->PlayerHomeVnum = ch->in_room->vnum;
do_save( ch , "" );
return;
}
// Allows a player to sell a home they own
else if (!str_prefix(arg, "sell"))
{
if ( ch->PlayerHomeVnum == '\0' )
{
send_to_char( "&RYou do not own a home!\n\r&w", ch);
return;
}
if ( IS_SET( room->room_flags , ROOM_EMPTY_HOME ) )
{
send_to_char( "&RThis room can't be sold it's for sale!\n\r&w", ch);
return;
}
if ( IS_SET( room->room_flags, ROOM_PLR_HOME) && (ch->PlayerHomeVnum != ch->in_room->vnum))
{
send_to_char( "&RThis is not your home you can not sell this", ch );
return;
}
send_to_char("You've now sold your home and 100000 credits have been deposited into your account!\n\r", ch);
ch->gold += 100000;
REMOVE_BIT( room->room_flags , ROOM_PLR_HOME );
SET_BIT( room->room_flags , ROOM_EMPTY_HOME );
fold_area( room->area, room->area->filename, FALSE );
ch->plr_home = '\0';
ch->PlayerHomeVnum = '\0';
do_save( ch , "" );
return;
}
here's part of it
|