/* CREATE TABLE IF NOT EXISTS `event_promo_code` ( `id` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT, `nameid` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '512', `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '1', `min_amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '1', `max_amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '1', `total` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '1', PRIMARY KEY (`id`) ) ENGINE=MyISAM; */ - script Sample#npc FAKE_NPC,{ OnInit: .minute = 30; .command$ = "claim"; bindatcmd .command$,strnpcinfo(3)+"::OnAtcommand"; setarray .announce$, "This is promo code event.", "A promo code will be announced. ", "All you have to do is type the @"+.command$+" with the code given to claim the rewards", "First come first serve basis.", "Good luck, and event start now."; .announce_size = getarraysize( .announce$ ); .npcname$ = strnpcinfo(0); end; OnAtcommand: if ( .status == 0 ) { dispbottom "Event isnt activated."; } else if ( .status == 1 ) { dispbottom "Event will begin shortly. Get ready."; } else if ( .status == 2 ) { .@aid = getcharid(3); if ( !.@atcmd_numparameters || .@atcmd_parameters$[0] != .code$ ) { mes "Please type: "+.@atcmd_command$+" '"+.code$+"'"; } else if ( .total <= 0 ) { mes "You're too late. All reward has been claimed."; } else if ( compare( .player_check$,"#"+.@aid+"#" ) ) { mes "You already claimed the reward for this rounds."; } else { mes "You gained "+.amount+"x "+getitemname( .nameid ); .total--; .player_check$ = .player_check$ + .@aid + "#"; getitem .nameid,.amount; if ( .total <= 0 ) donpcevent .npcname$+"::OnEventEnd"; } close; } end; OnMinute00: // start every hours OnEventStart: if ( !.status ) { .status = 1; .minute_left = .minute; .player_check$ = "#"; for ( .@i = 0; .@i < .announce_size; .@i++ ) { announce " "+.announce$[.@i],bc_all; sleep 5000; } query_sql( "SELECT `nameid`,`amount`,`min_amount`,`max_amount` FROM `event_promo_code`",.nameid,.amount,.min_amount,.max_amount,.total ); .status = 2; .code$ = ""+rand( 1000000,MAX_ZENY ); initnpctimer; announce " Time Left : "+.minute_left+" minute(s) , use @"+.command$+" to claim the reward now.",bc_all; } end; OnTimer60000: .minute_left--; announce " Time Left : "+.minute_left+" minute(s) , use @"+.command$+" to claim the reward now.",bc_all; setnpctimer 0,.npcname$; if ( .minute_left >= 0 ) end; OnEventEnd: stopnpctimer; .status = 0; announce " Event ended, try again next time.",bc_all; end; }