/*
CREATE TABLE IF NOT EXISTS `ir_main` (
`id` bigint(20) unsigned NOT NULL auto_increment,
`account_id` int(11) unsigned NOT NULL,
`item_id` int(11) unsigned NOT NULL,
`amount` int(11) unsigned NOT NULL,
`refine` tinyint(3) unsigned NOT NULL default '0',
`card0` smallint(5) unsigned NOT NULL default '0',
`card1` smallint(5) unsigned NOT NULL default '0',
`card2` smallint(5) unsigned NOT NULL default '0',
`card3` smallint(5) unsigned NOT NULL default '0',
`ticket_id` int(11) unsigned NOT NULL default '0',
`claim` tinyint(2) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
*/
prontera,169,181,5 script Item Redeem 1_M_SIGNART,{
mes "[ Item Redeem ]";
mes "Select Option";
.@menu$ = "Redeem Items:Cancel";
if (getgmlevel()>=99)
.@menu$ = .@menu$+":Add Items";
switch(select(.@menu$)){
case 3:
if (getgmlevel() < 99)
close;
while(1){
next;
mes "[ Item Redeem ]";
mes "Are you Sure you want to add items?";
if (select("Add Items:Cancel") == 2)
close;
next;
mes "[ Item Redeem ]";
mes "Enter Ticket ID";
mes "0 if no TicketID";
input .@ticket_id;
next;
mes "[ Item Redeem ]";
mes "Enter AccountID";
input .@acc_id;
next;
mes "[ Item Redeem ]";
mes "How Many Items you want to put?";
input .@count;
for (.@i = 0; .@i < .@count; .@i++){
next;
mes "[ Item Redeem ]";
mes "["+ (.@i+1) +"/"+ .@count +"] Enter ItemID";
input .@item_id[.@i];
.@type = getiteminfo(.@item_id[.@i],2);
if (.@type == 4 || .@type == 5){
for (.@j=0; .@j < 4; .@j++){
next;
mes "[ Item Redeem ]";
mes "["+ (.@j+1) +"/4] Enter CardID";
mes "0 if no card on this slot.";
input .@card;
setd(".@cards_"+.@i+"_"+.@j,.@card);
}
next;
mes "[ Item Redeem ]";
mes "Enter Refine Amount.";
input .@refine[.@i];
}
next;
mes "[ Item Redeem ]";
mes "["+ (.@i+1) +"/"+ .@count +"] Enter Amount";
input .@amount[.@i];
next;
mes "[ Item Redeem ]";
mes "Review the Item:";
mes .@amount[.@i]+"x "+ getitemname(.@item_id[.@i]);
mes "Refine: "+ .@refine[.@i];
mes "Cards: ";
for (.@j = 0; .@j < 4; .@j++)
mes (.@j+1)+" Slot: "+ getitemname(getd(".@cards_"+.@i+"_"+.@j));
if (select("Item Info is Correct: Info is not correct, edit this item...") == 2){
//Remove Data which are not necessary, like cards and refines.
.@refine[.@i] = 0;
for (.@j=0; .@j < 4; .@j++)
setd(".@cards_"+.@i+"_"+.@j,0);
.@i--;
}
next;
mes "[ Item Redeem ]";
mes "Item Added...";
}
next;
mes "Are you Sure to add all these items?";
mes "Clicking No, will remove all the items, and you would have to redo..";
for (.@i = 0; .@i < .@count; .@i++){
mes .@amount[.@i]+"x "+ getitemname(.@item_id[.@i]);
}
if (select("Yes, Add:No") == 2)
continue;
for (.@i = 0; .@i < .@count; .@i++){
query_sql "INSERT INTO `ir_main` (`account_id`,`item_id`,`amount`,`refine`,`card0`,`card1`,`card2`,`card3`,`ticket_id`) VALUES ("+.@acc_id+","+.@item_id[.@i]+","+.@amount[.@i]+","+.@refine[.@i]+","+ getd(".@cards_"+.@i+"_0") +","+ getd(".@cards_"+.@i+"_1") +","+ getd(".@cards_"+.@i+"_2") +","+ getd(".@cards_"+.@i+"_3") +","+ .@ticket_id +")";
}
}
case 2:
close;
case 1:
next;
mes "[ Item Redeem ]";
mes "Are you sure you want to claim the items?";
select("Yes, Claim the Items");
next;
mes "[ Item Redeem ]";
query_sql "SELECT `id`,`item_id`,`amount`,`refine`,`card0`,`card1`,`card2`,`card3` FROM `ir_main` WHERE `claim`=0 AND `account_id`="+ getcharid(3),.@id,.@item_id,.@amount,.@refine,.@card0,.@card1,.@card2,.@card3;
.@count = getarraysize(.@id);
if (.@count == 0){
mes "You don't have any items to redeem..";
close;
}
mes "Are you Sure you want to redeem these items?";
mes "Items List: ";
for (.@i = 0; .@i < .@count; .@i++) {
mes (.@i+1)+".) "+ .@amount[.@i]+"x "+ getitemname(.@item_id[.@i]);
if (.@refine[.@i])
mes "Refine: "+ .@refine[.@i];
if (.@card0[.@i] || .@card1[.@i] || .@card2[.@i] || .@card3[.@i])
mes "Cards: ";
for (.@j = 0; .@j < 4; .@j++)
if (getd(".@card"+.@j+"["+.@i+"]"))
mes (.@j+1)+" Slot: "+ getitemname(getd(".@card"+.@j+"["+.@i+"]"));
}
if (select("Yes, Redeem:No, Don't Redeem Now...") == 2){
next;
mes "[ Item Redeem ]";
mes "Okay, Come back soon to redeem it...";
close;
}
next;
mes "[ Item Redeem ]";
for (.@i = 0; .@i < .@count; .@i++) {
if (checkweight(.@item_id[.@i],.@amount[.@i])){
query_sql "UPDATE `ir_main` SET `claim`="+getcharid(3)+" WHERE `id`="+.@id[.@i];
getitem2 .@item_id[.@i],.@amount[.@i],1,.@refine[.@i],0,.@card0[.@i],.@card1[.@i],.@card2[.@i],.@card3[.@i];
} else {
mes "You are OverWeight....";
mes "Please Empty some weight, to get more items...";
close;
}
}
mes "All Items have been redeemed...";
close;
}
end;
OnInit:
query_sql "CREATE TABLE IF NOT EXISTS `ir_main` ( `id` bigint(20) unsigned NOT NULL auto_increment, `account_id` int(11) unsigned NOT NULL, `item_id` int(11) unsigned NOT NULL, `amount` int(11) unsigned NOT NULL, `refine` tinyint(3) unsigned NOT NULL default '0', `card0` smallint(5) unsigned NOT NULL default '0', `card1` smallint(5) unsigned NOT NULL default '0', `card2` smallint(5) unsigned NOT NULL default '0', `card3` smallint(5) unsigned NOT NULL default '0', `ticket_id` int(11) unsigned NOT NULL default '0', `claim` tinyint(2) NOT NULL DEFAULT '0', PRIMARY KEY (`id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1";
end;
}