Please do not just copy and paste. Go over it, see how it works and learn from it, like all of us are continuously doing =)
The Gumps package can be found in the 097 distro. I haven't found any bugs, so if you find any please do tell.
Bank check's;
Code:
use uo;
include ":Gumps:Include/yesno";
program Check(mobile, check)
if ( !ReserveItem(check) )
SendSysMessage(mobile, "That item is already being used.");
return 0;
endif
if ( check.Container != mobile.Backpack )
SendSysMessage(mobile, "That item must be in your backpack.");
return 0;
endif
var check_amount := CInt(GetObjProperty(check, "CheckAmount"));
if ( !check_amount )
SendSysMessage(mobile, "This is a blank check.");
SetName(check, "Blank Check");
return 0;
else
if ( YesNo(mobile, "Are you sure you want to cash this "+(check_amount)+"gp check now?") )
var result := CreateGoldInContainer(mobile.Backpack, check_amount);
if ( result )
SendSysMessage(mobile, "Your backpack is too full!");
SendSysMessage(mobile, "Any remaining gold will be left on the check.");
SetObjProperty(check, "CheckAmount", result);
SetName(check, "Check for "+(result)+" Gold");
return 0;
elseif ( result == 0 )
SendSysMessage(mobile, "Your check has been cashed.");
SubtractAmount(check, 1);
return 1;
else
SendSysMessage(mobile, "Seriously...");
return 0;
endif
else
SendSysMessage(mobile, "Aborted.");
return 0;
endif
endif
return 0;
endprogram
function CreateGoldInContainer(container, amount)
if ( container )
var current_amount := amount;
var stacks := (amount / 60000);
var recieved;
for ( recieved := 1; recieved <= stacks; recieved += 1 )
if ( CreateItemInContainer(container, 0x0EED, 60000) )
current_amount -= 60000;
else
return (current_amount);
endif
SleepMS(2);
endfor
var left_over_amount := (amount - (stacks * 60000));
if ( !CreateItemInContainer(container, 0x0EED, left_over_amount) )
return (left_over_amount);
else
return 0;
endif
else
return (-1);
endif
endfunction
Withdraw function for bankers;
Code:
function WithdrawGoldFromBank(bank_box, backpack, amount)
var current_amount := amount;
var stacks := (amount / 60000);
var recieved;
for (recieved := 1; recieved <= stacks; recieved := recieved + 1 )
if ( ConsumeSubstance(bank_box, 0x0EED, 60000) )
if ( CreateItemInContainer(backpack, 0x0EED, 60000) )
current_amount -= 60000;
else
return (current_amount);
endif
endif
SleepMS(2);
endfor
var left_over_amount := (amount - (stacks * 60000));
if ( ConsumeSubstance(bank_box, 0x0EED, left_over_amount) )
if ( !CreateItemInContainer(backpack, 0x0EED, left_over_amount) )
return (left_over_amount);
endif
endif
return 0; // Successfully withdrew the gold.
endfunction