// NPC Settings - SET THESE BEFORE LOADING THE SCRIPT! set $servername$,"Joy-Ro"; set $npcname$,"[Item Redeemer]"; // NPC Name to display during chat. Default: "[Item Redeemer]" set $redeemtable$,"cp_redeemlog"; // Default: "cp_redeemlog" set $showcredits,1; // Display Credits to FluxCP Creators? 0 = Disable. 1 = Enable. Default: 1 // End NPC Settings. // Server Settings // DON'T CHANGE THIS UNLESS YOU KNOW WHAT YOU'RE DOING AND HAVE MADE THE APPROPRIATE SOURCE MODS! set $maxinventorysize,100; // Max amount of unique items able to be held in inventory. set $maxquantity,30000; // Max amount of an item able to be held in inventory. // End Server Settings. // Begin NPC mes $npcname$; if (Sex) mes "Well hello there good sir!"; else mes "Well hello there young madam!"; mes "How may I be of assistance to you on this fine day?"; next; switch(select("I wish to redeem items:Who might you be?:I am merely perusing the area")) { case 1: mes $npcname$; deletearray @inventorylist_id; deletearray @inventorylist_amount; set @inventorylist_count,0; getinventorylist; if (@inventorylist_count < $maxinventorysize) { query_sql "SELECT `id`, `nameid`, `quantity` FROM `"+escape_sql($redeemtable$)+"` WHERE `account_id` = '"+escape_sql(getcharid(3))+"' AND `redeemed` = '0' LIMIT 128",.@id,.@nameid,.@quantity; mes "Items Pending Redemption: "+getarraysize(.@id); if (getarraysize(.@id) > 0) { for( set .@loop, 0; .@loop < getarraysize(.@id); set .@loop,.@loop+1) { deletearray @inventorylist_id; deletearray @inventorylist_amount; set @inventorylist_count,0; getinventorylist; if (@inventorylist_count < $maxinventorysize) { for( set .@loop_inner,0; .@loop_inner < @inventorylist_count; set .@loop_inner,.@loop_inner+1) { deletearray @inventorylist_id; deletearray @inventorylist_amount; set @inventorylist_count,0; getinventorylist; if (@inventorylist_id[.@loop_inner] == .@nameid[.@loop]) { if (@inventorylist_amount[.@loop_inner]+.@quantity[.@loop] > $maxquantity) { mes "I'm terribly sorry, but you cannot hold more than "+$maxquantity+" of "+getitemname(.@nameid[.@loop])+" at a time!"; mes "Please come back when you carry less of this item."; close; } else if (checkweight(.@nameid[.@loop],.@quantity[.@loop]) == 0) { mes "I'm terribly sorry, but you are carrying too much to accept your rewards."; mes "Please come again with less weight."; close; } } } query_sql "UPDATE `"+escape_sql($redeemtable$)+"` SET `char_id` = '"+escape_sql(getcharid(0))+"', `redeemed` = '1', `redemption_date` = NOW() WHERE `id` = '"+escape_sql(.@id[.@loop])+"'"; getitem .@nameid[.@loop],.@quantity[.@loop]; getitem Old_Violet_Box, .@quantity[.@loop]; mes .@quantity[.@loop]+"x "+getitemname(.@nameid[.@loop]); } else { mes "I'm terribly sorry, but you cannot hold more than "+$maxinventorysize+" items in your inventory."; mes "Please come again with less items."; close; } } if (Sex) mes "Thank you for your patronage fine sir."; else mes "Thank you for your patronage ma'am."; mes "Please enjoy your stay on our server, "+$servername$+"."; close; } else { mes "My records indicate that there are no rewards awaiting to be redeemed."; mes "My deepest apologies for the misunderstanding."; close; } } else { mes "I'm terribly sorry, but you cannot hold more than "+$maxinventorysize+" items in your inventory."; mes "Please come again with less items."; close; } close; case 2: mes $npcname$; mes "I am here to allow for the redemption of rewards for donations to our server, "+$servername$; mes "Donations may be made to the server via the control panel."; close; case 3: mes $npcname$; mes "Very well then."; mes "Good day to you."; close; }}