alberta,121,44,2	script	Donor Rewards Redeemer	4_M_3RDPRIN1,{
	// ----------------- NPC Settings -----------------
	// --- SET THESE BEFORE LOADING THE SCRIPT! ---
	
	// Server Name
	set .serverName$,"2004 ClassicRO";
	set .npcName$,"[Donor Rewards Redeemer]";
	set .@voucher,0;
	set .@rok,0;
	set .@voucherb,0;
	set .@obb,0;
	set .@oca,0;

	query_sql("SELECT `balance` FROM cp_donations WHERE `account_id` = '"+getcharid(3)+"'",.@balance);
		mes .npcName$;
		if (.@balance < 1) { mes "^FF0000You have no Paypal Credit available to claim.^000000"; close; }
		mes "^0000ffYou have:^000000 ";
		mes " Paypal Credits: ^FF0000"+F_InsertComma(.@balance)+"^000000";
		mes "^0000ffYou will receive:^000000";
		set .@voucher,.@balance/1000;
		mes "Cash Voucher:^FF0000 "+.@voucher+"^000000 pcs.";
		/*
		mes "^0000ffBonus:^000000";

		if (.@voucher >= 10 && .@voucher < 17 ) {
			set .@voucherb,2;
			set .@obb,0;
			set .@oca,0;
		}
		if (.@voucher >= 17 && .@voucher < 26 ) {
			set .@voucherb,4;
			set .@obb,0;
			set .@oca,0;
		}
		if (.@voucher >= 26 &&  .@voucher < 34 ) {
			set .@voucherb,6;
			set .@obb,0;
			set .@oca,0;

		}
		if (.@voucher >= 34 &&  .@voucher < 43 ) {
			set .@voucherb,8;
			set .@obb,0;
			set .@oca,0;


		}
		if (.@voucher >= 43 &&  .@voucher < 95 ) {
			set .@voucherb,10;
			set .@obb,0;
			set .@oca,0;


		}
		if (.@voucher >= 95 ){
			set .@voucherb,30;
			set .@obb,0;
			set .@oca,0;
		}
		if (.@voucherb) mes "   + Cash Voucher:^FF0000 "+.@voucherb+"^000000 pcs.";
		if (.@obb) mes "     + Old Blue Box:^FF0000 "+.@obb+"^000000 pcs.";
		if (.@oca) mes "+ Old Card Album:^FF0000 "+.@oca+"^000000 pcs.";

		*/
		mes "^FF0000Proceed with the conversion?^000000";
		next;
		switch(select("No","Yes"))
		{
			case 1: 	
				close;
			case 2: 
				// Process Voucher
				getitem 7179,.@voucher; logmes "CREDIT: -"+.@voucher*1000+" CREDIT TO VOUCHER";
				query_sql "UPDATE cp_donations set `balance` = `balance` - "+ (.@voucher*1000) +" where `account_id` = '"+getcharid(3)+"'";

				// Process Bonus
				//if (.@voucherb) getitem 7179,.@voucherb; logmes "BONUS: - Received "+.@voucherb+" Cash Voucher";
				//if (.@obb) { getitem 603,.@obb; logmes "BONUS: - Received "+.@obb+" Bonus Old Blue Box"; }
				//if (.@oca) { getitem 616,.@oca; logmes "BONUS: - Received "+.@oca+" Bonus Old Card Album"; }
				mes "Thank you for using this service.";	
			default:
				close;

		}
	
		close;
}

