Advertisement
Emistry

[RO] Promo Code Event

Jan 30th, 2016
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.73 KB | None | 0 0
  1. /*
  2.     CREATE TABLE IF NOT EXISTS `event_promo_code` (
  3.         `id` SMALLINT(6) UNSIGNED NOT NULL AUTO_INCREMENT,
  4.         `nameid` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '512',
  5.         `amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '1',
  6.         `min_amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '1',
  7.         `max_amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '1',
  8.         `total` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '1',
  9.         PRIMARY KEY (`id`)
  10.     ) ENGINE=MyISAM;
  11. */ 
  12.    
  13. -   script  Sample#npc  FAKE_NPC,{
  14.  
  15.     OnInit:
  16.         .minute = 30;
  17.         .command$ = "claim";
  18.         bindatcmd .command$,strnpcinfo(3)+"::OnAtcommand";
  19.        
  20.         setarray .announce$,   
  21.             "This is promo code event.",
  22.             "A promo code will be announced. ",
  23.             "All you have to do is type the @"+.command$+" with the code given to claim the rewards",
  24.             "First come first serve basis.",
  25.             "Good luck, and event start now.";
  26.         .announce_size = getarraysize( .announce$ );
  27.         .npcname$ = strnpcinfo(0);
  28.         end;
  29.        
  30.     OnAtcommand:
  31.         if ( .status == 0 ) {
  32.             dispbottom "Event isnt activated.";
  33.         }
  34.         else if ( .status == 1 ) {
  35.             dispbottom "Event will begin shortly. Get ready.";
  36.         }
  37.         else if ( .status == 2 ) {
  38.             .@aid = getcharid(3);
  39.            
  40.             if ( !.@atcmd_numparameters || .@atcmd_parameters$[0] != .code$ ) {
  41.                 mes "Please type: "+.@atcmd_command$+" '"+.code$+"'";
  42.             }
  43.             else if ( .total <= 0 ) {
  44.                 mes "You're too late. All reward has been claimed.";
  45.             }
  46.             else if ( compare( .player_check$,"#"+.@aid+"#" ) ) {
  47.                 mes "You already claimed the reward for this rounds.";
  48.             }
  49.             else {
  50.                 mes "You gained "+.amount+"x "+getitemname( .nameid );
  51.                 .total--;
  52.                 .player_check$ = .player_check$ + .@aid + "#";
  53.                 getitem .nameid,.amount;
  54.                 if ( .total <= 0 )
  55.                     donpcevent .npcname$+"::OnEventEnd";
  56.             }
  57.             close;
  58.         }
  59.         end;
  60.        
  61.     OnMinute00: // start every hours
  62.     OnEventStart:
  63.         if ( !.status ) {
  64.             .status = 1;
  65.             .minute_left = .minute;
  66.             .player_check$ = "#";
  67.             for ( .@i = 0; .@i < .announce_size; .@i++ ) {
  68.                 announce "<PROMO CODE EVENT> "+.announce$[.@i],bc_all;
  69.                 sleep 5000;
  70.             }
  71.             query_sql( "SELECT `nameid`,`amount`,`min_amount`,`max_amount` FROM `event_promo_code`",.nameid,.amount,.min_amount,.max_amount,.total );
  72.             .status = 2;
  73.             .code$ = ""+rand( 1000000,MAX_ZENY );
  74.             initnpctimer;
  75.             announce "<PROMO CODE EVENT> Time Left : "+.minute_left+" minute(s) , use @"+.command$+" to claim the reward now.",bc_all;
  76.         }
  77.         end;
  78.        
  79.     OnTimer60000:
  80.         .minute_left--;
  81.         announce "<PROMO CODE EVENT> Time Left : "+.minute_left+" minute(s) , use @"+.command$+" to claim the reward now.",bc_all;
  82.         setnpctimer 0,.npcname$;
  83.         if ( .minute_left >= 0 ) end;
  84.        
  85.     OnEventEnd:
  86.         stopnpctimer;
  87.         .status = 0;
  88.         announce "<PROMO CODE EVENT> Event ended, try again next time.",bc_all;
  89.         end;
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement