[FUNCTION f_house_transfer]
if !(<ARGO.ISPLAYER>)
    SRC.SYSMESSAGE @,,1 Only players can own a house!
    return 1
endif
REF1=<ARGS>
if (<ARGO>==<SRC>)
    SRC.SYSMESSAGE @,,1 You cannot transfer a house to yourself, silly.
    return 1
elif ((<ARGO.IsOnHouse>) || (<SRC.IsOnHouse>)) || ((<ARGO.DISTANCE <REF1>> > 2) || (<SRC.DISTANCE <REF1>> > 2))
    SRC.SYSMESSAGE @,,1 In order to transfer the house, you and the recipient must both be outside the building and within two paces of the house sign.
    return 1
elif (<ARGO.CHECK_ACCOUNT_TYPEDEF t_multi*> >= <DEF.scp.House_MaxPerAccount>)
    SRC.SYSMESSAGE @,,1 <ARGO.NAME> already have <dDEF.scp.House_MaxPerAccount> houses and can't own another one!
    return 1
elif (<DEF0.scp.House_PlaceWaitPeriod>) && (<ARGO.TAG0.House.PlacementDelay> > <SERV.TIME>)
    SRC.SYSMESSAGE @,,1 That player cannot have a house transferred to them at this time.
    ARGO.SYSMESSAGE @,,1 Number of days you will have to wait till you can have a house transfered to you: <eval (<ARGO.TAG0.House.PlacementDelay>-<SERV.TIME>)/864000>
    return 1
endif
SRC.SYSMESSAGE @,,1 Please wait while the other player verifies the transfer.
SRC.TRYSRC <ARGO> DIALOG d_house_transfer 0,<REF1>
[TYPEDEF t_trade_house_deed]
ON=@Click
MESSAGE House Transfer Contract
MESSAGE House Name: <LINK.NAME>
MESSAGE Owner: <UID.<LINK.MORE2>.NAME>
MESSAGE Location: <LINK.SEXTANTP> //<LINK.REGION.REGION.NAME> (<LINK.P>)
return 1
ON=@ClientToolTip
SRC.ADDCLILOC 1061112,<LINK.NAME>
SRC.ADDCLILOC 1061113,<UID.<LINK.MORE2>.NAME>
SRC.ADDCLILOC 1061114,<STRARG <LINK.SEXTANTP>> <STREAT <LINK.SEXTANTP>>
ON=@Timer
if (<CONT.TYPE>==t_eq_trade_window)
    TIMERF 2,trigger @Timer
else
    UID.<MORE1>.EVENTS=-e_house_transfer
    REMOVE
endif
return 1
ON=@HouseTraded
REF1=<MORE1>        //New Owner
REF2=<LINK.MORE2>    //Old Owner
REF1.EVENTS=-e_house_transfer
REF2.SYSMESSAGE @,,1 You have transferred ownership of the house.
REF1.SYSMESSAGE @,,1 You are now the owner of this house.  The house's co-owner, friend, ban, and access lists have been cleared.  You should double-check the security settings on any doors and teleporters in the house.
LINK.TAG.LastTraded=<serv.rtime.format %d>-<serv.rtime.format %m>-<serv.rtime.format %Y> <strsub 11 0 <serv.rtime>>
LINK.MORE2=<REF1>
LINK.LINK.MORE1=<REF1>
for <eval <REF2.COUNT>-1> 0
    if (<REF2.FINDCONT.<LOCAL._FOR>.LINK>==<LINK.LINK>)
        REF2.FINDCONT.<dLOCAL._FOR>.CONT=<REF1>
    endif
endfor
for 1 3
    ARGS=<LINK.HouseAccessList <LOCAL._FOR>>
    for x <LINK.TAG0.Access.Total.<LOCAL._FOR>>
        if !(<isempty <ARGV[<dLOCAL.X>]>>)
            UID.<ARGV[<dLOCAL.X>]>.NOTICE You got removed from the <DEF.Access_<LOCAL._FOR>> list of the house '<LINK.NAME>' because it was been traded to a new owner on <serv.rtime.format %d>/<serv.rtime.format %m>/<serv.rtime.format %Y> <strsub 11 0 <serv.rtime>>.
        endif
    endfor
endfor
if !(<REF1.ISGM>) && (<DEF0.scp.House_PlaceWaitPeriod>)
    REF1.TAG.House.PlacementDelay=<eval <SERV.TIME>+(<DEF0.scp.House_PlaceWaitPeriod>*864000)+36000>
endif
LINK.CLEARTAGS Access