Emistry icon

[RO] Wishlist NPC - Monthly Reward

Emistry | PRO | 11/27/16 06:26:20 PM UTC | 0 ⭐ | 672 👁️ | Never ⏰ | []
text |

3.53 KB

|

None

|

0 👍

/

0 👎

// https://rathena.org/board/topic/107975-r-wishlist-npc/
 /*
CREATE TABLE IF NOT EXISTS `e_wishlist` (
  `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
  `aid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `nameid` INT(11) NOT NULL DEFAULT '0',
  `amount` INT(11) NOT NULL DEFAULT '0',
  `status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`id`)
) ENGINE=MyISAM; 
*/
 prontera,155,181,5	script	WishList NPC	4_F_MAID,{
	doevent "wishlist_main::OnTalk";
}
  -	script	wishlist_main	-1,{
 	OnTalk:
		.@aid = getcharid(3);
 		mes "What item you wish to get in this month?";
		mes "Tell me what its and you might be the lucky one to obtain it by end of this month.";
		next;
		switch ( select( 
			"Add New Wishlist",
			"Claim Pending Wishlist",
			"My Wishlist History"
		)) {
			case 1:
				query_sql( "SELECT `id`,`nameid`,`amount` FROM `e_wishlist` WHERE `aid` = "+.@aid+" AND `status` = 0", .@id );
				.@size = getarraysize( .@id );
				if ( .@size >= .max_entry ) {
					mes "You have already created "+.@size+" wishlist this month. Try again next month.";
				}
				else {
					mes "Enter Item ID";
					input .@nameid;
					if ( getitemname( .@nameid ) != "null" ) {
						mes "Enter Amount";
						input .@amount,0,.item_max_amount;
						if ( .@amount > 0 ) {
							next;
							if ( select( "Confirm","Cancel" ) == 1 ) {
								mes "Wishlist Added.";
								query_sql( "INSERT INTO `e_wishlist` ( `aid`,`nameid`,`amount` ) VALUES ( "+getcharid(3)+", "+.@nameid+", "+.@amount+" )" );
							}
						}
					}
				}
				break;
			case 2:
				mes "Item List:";
				query_sql( "SELECT `id`,`nameid`,`amount` FROM `e_wishlist` WHERE `aid` = "+.@aid+" AND `status` = 2", .@id, .@nameid, .@amount );
				.@size = getarraysize( .@id );
				for ( .@i = 0; .@i < .@size; .@i++ )
					.@menu$ = .@menu$ + getitemname( .@nameid[.@i] ) +" - "+.@amount[.@i]+" each" + ":";
				.@i = select( .@menu$ ) - 1;
 				mes "You gained "+getitemname( .@nameid[.@i] )+" - "+.@amount[.@i]+" each";
				query_sql( "UPDATE `e_wishlist` SET `status` = 3 WHERE `id` = "+.@id[.@i]+" LIMIT 1" );
				getitem .@nameid[.@i],.@amount[.@i];
				break;
			case 3:
				mes "Recent Entry:";
				query_sql( "SELECT `id`,`nameid`,`amount`,`status` FROM `e_wishlist` WHERE `aid` = "+.@aid+" LIMIT 100", .@id, .@nameid, .@amount, .@status );
				.@size = getarraysize( .@id );
				for ( .@i = 0; .@i < .@size; .@i++ ) {
					switch ( .@status[.@i] ) {
						case 1: .@status$ = "Expired"; break;
						case 2: .@status$ = "Unclaimed"; break;
						case 3: .@status$ = "Claimed"; break;
						default: .@status$ = "Pending"; break;
					}
					mes "["+( .@i+1 )+".] "+.@amount[.@i]+"x "+getitemname( .@nameid[.@i] )+" ("+.@status$+")";
 					if ( .@i && .@i % 7 == 0 ) {
						next;
						if ( select ( "Next Page","Cancel" ) == 2 ) 
							close;
					}
				}
			default: break;
		}
		close;
 	OnInit:
		.max_entry = 1;
		.item_max_amount = 30000;
		end;
 	OnDay0101:
	OnDay0201:
	OnDay0301:
	OnDay0401:
	OnDay0501:
	OnDay0601:
	OnDay0701:
	OnDay0801:
	OnDay0901:
	OnDay1001:
	OnDay1101:
	OnDay1201:
		query_sql( "SELECT `id`,`aid` FROM `e_wishlist` WHERE `status` = 0 ORDER BY RAND() LIMIT 1",.@id,.@aid );
		query_sql( "UPDATE `e_wishlist` SET `status` = 2 WHERE `id` = "+.@id+" LIMIT 1" );
		query_sql( "UPDATE `e_wishlist` SET `status` = 1 WHERE `status` = 0" );
		if ( .@aid ) {
			if ( attachrid( .@aid ) ) {
				message strcharinfo(0),"You gained an item from the WishList NPC.";
			}
		}
		end;
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎