Jump to content
xerxesbreak

Need help with sql query

Recommended Posts

I'm using this script of Liltroll but I've been having some  trouble with the sql 

////////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------//
//                          PROMOTIONAL CODES                         //
//                     AUTHOR: LIL TROLL//COLDFIRE                    //
//--------------------------------------------------------------------//
//                          RATHENA SCRIPT                            //
//--------------------------------------------------------------------//
//                          Version 1.2.3                             //
//--------------------------------------------------------------------//
//    FEATURES: (Modified Promotional Code by sir Patskie)            //
//   								       				//
// #1 5`Degree of Abuse-Protection(+ItemBound = 6)		       	//
//    - IP,ACCOUNT,COUNTLIMIT,DOUBLECHECK,MIX			       	//
// #2 Code can be deleted/detected by gm.			       		//
// #3 Friendly User Interface.					      		//
// #4 Very easy to configure.					      			//
// #5 Code auto delete at certain variable setup(limit pool).	     //
// #6 GM can view codes when claiming.				       		//
// #7 GM can set limitation of usage of the codes.		       	//
// #8 Automatically delete any codes that set to desirable 	       	//
//    pool limit by gm claimed by players.			      		//
// #9 GM can set random code with random item! :D		      		//
// #10 GM toggle (when claiming the code, restriction) included.		//
//--------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
/*
DROP TABLE IF EXISTS `reward_codes`;
DROP TABLE IF EXISTS `reward_logs`;
CREATE TABLE IF NOT EXISTS `reward_codes` (
	`promo` VARCHAR(26) NOT NULL DEFAULT '',
	`nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
	`item_name` VARCHAR(50) NOT NULL DEFAULT '',
	`amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
	`time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
	`limit` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`pool` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	PRIMARY KEY (`promo`)
) ENGINE = MYISAM;
CREATE TABLE IF NOT EXISTS `reward_logs` (
	`account_id` int(11) unsigned NOT NULL default '0',
	`last_ip` VARCHAR( 100 ) NOT NULL,
	`code` VARCHAR( 26 ) NOT NULL,
	`redeem_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
	`claim` INT( 10 ) NOT NULL,
	PRIMARY KEY (`code`)
) ENGINE = MYISAM;
*/
-	script	LilTrollPCodes	-1,{
OnInit:
	//initnpctimer;	// I USED THIS FOR TESTING PURPOSES	WITH ONTIMER
	bindatcmd "claim",strnpcinfo(3)+"::OnClaim";	
	bindatcmd "code",strnpcinfo(3)+"::OnEditCode";
	setarray .promoprize[0],501,502,503,504,505,506,507,508,509,510;   	// SET ITEM ID HERE FOR REWARDS
	setarray .prizeamount[0],1,2,3,4,5,6,7,8,9,10;         // AMOUNT OF REWARDS
	setarray .claimlimit[0],1,2,3,4,5,6,7,8,9,10;		// CLAIM LIMITATION
	setarray .length,5,15; // <MIN>,<MAX> LENGTH CHECK	// 5 Recommended Minimum due to not recognizing 1234 from garbage deletion.
	setarray .gm,0,								// 1 Enable, 0 Disable GM Restriction in Claiming Promo Codes.
		 	  99;								// GM claims doesnt affect claim limit pool.
	query_sql "CREATE TABLE IF NOT EXISTS `reward_codes` (`promo` VARCHAR(26) NOT NULL DEFAULT '',`nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',`item_name` VARCHAR(50) NOT NULL DEFAULT '',`amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',`time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',`limit` INT(10) UNSIGNED NOT NULL DEFAULT '0',`pool` INT(10) UNSIGNED NOT NULL DEFAULT '0',PRIMARY KEY (`promo`)) ENGINE = MYISAM";
	query_sql "CREATE TABLE IF NOT EXISTS `reward_logs` (`account_id` int(11) unsigned NOT NULL default '0',`last_ip` BINARY( 9 ) NOT NULL,`code` VARCHAR( 26 ) NOT NULL,`redeem_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',`claim` INT( 10 ) NOT NULL,PRIMARY KEY (`code`)) ENGINE = MYISAM";
	end;											// 15 maximum characters supported in random code generation.
//OnTimer20000:			// I USED THIS FOR TESTING PURPOSES WITH INITNPCTIMER
OnMinute0000: // Refreshes every 1 Hour. Automatically delete 0 pool count promos. // Change this if you want.
	// ****************************************************** BIRBE WIRE ***************************************************	
	set [email protected],query_sql("SELECT `promo`,`pool` FROM `reward_codes` ORDER BY pool ASC LIMIT 50",[email protected]$,[email protected]);
	for(set [email protected],1; [email protected] <= [email protected]; set [email protected],[email protected]++) {
	query_sql "DELETE FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$[0]) + "' AND `pool` = '0'";   // Number 1 row will be deleted.
	query_sql "DELETE FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$[[email protected]]) + "' AND `pool` = '0'"; // Numbers from 2-10 rows will be deleted.
	}
	debugmes "Promotional Codes garbage are deleted.";
	// ****************************************************** BIRBE WIRE ***************************************************	
	//initnpctimer;	// I USED THIS FOR TESTING PURPOSES WITH ONTIMER
end;
	// ****************************************************** BIRBE WIRE ***************************************************
OnDay0101: OnDay0102: OnDay0103: OnDay0104: OnDay0105: OnDay0106:	// Clean sql garbage every 1st day of the month.
OnDay0107: OnDay0108: OnDay0109: OnDay0110: OnDay0111: OnDay0112:
	set [email protected],query_sql("SELECT `codes`,`redeem_time` FROM `reward_logs` ORDER BY pool ASC LIMIT 25",[email protected]$);
	for(set [email protected],1; [email protected] <= [email protected]; set [email protected],[email protected]++) {
	query_sql "DELETE FROM `reward_logs` WHERE `codes` = '" + escape_sql([email protected]$[0]) + "'";  // Number 1 row will be deleted.
	query_sql "DELETE FROM `reward_logs` WHERE `codes` = '" + escape_sql([email protected]$[[email protected]]) + ""; // Numbers from 2-25 rows will be deleted.
	}
	debugmes "reward_logs garbage has been deleted.";
end;  	
	// ****************************************************** BIRBE WIRE ***************************************************
OnClaim:	// ONCLAIM COMMAND STARTS
	if ( getgmlevel() < 99 ) { 
	mes "^00007fNew Exodus Ragnarok Online^000000"; 							// INPUT YOUR SERVERNAME
	mes "Promotional Code Rewards"; 								// YOU CAN CHANGE ALL MES DIALOGUES
	mes "Input the correct [ ^ff0000Code^000000 ]"; 
	}
	if ( getgmlevel() == 99 ) {									// CHECK GM LEVEL
									// QUERY SQL SELECT "DONT CHANGE"
	set [email protected], query_sql("SELECT `promo`,`pool` FROM `reward_codes` ORDER BY time_created DESC LIMIT 20",[email protected]$,[email protected]);
									// QUERY SQL SELECT "DONT CHANGE"
	mes "^00007fPROMOTIONAL REWARDS^000000";
	mes "^ff0000GM MENU:^000000";
	mes "^005500Codes:Claim Limit^000000";
	// FOR STATEMENT DONT CHANGE IF YOU DONT KNOW WHAT YOU ARE DOING.
	for(set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1)
	// FOR STATEMENT DONT CHANGE IF YOU DONT KNOW WHAT YOU ARE DOING.
	mes ""[email protected]$[[email protected]]+" : "[email protected][[email protected]]+"";
	}
	input [email protected]$;
	set [email protected]$,strtoupper([email protected]$);						// CLAIM INPUT CODE
	if ( getstrlen( [email protected]$ ) < .length[0] || getstrlen( [email protected]$ ) > .length[1] ) {			// CHECK LENGHT OF THE CODE
		announce "Incorrect input. Code is not less than " +.length[0]+ " and must be greater than " +.length[1]+ ".",bc_self;
		end;// ----------------------------------------------------------------------
	}	// END CHECK LENGHT
	close2;		// CLOSE2 COMMAND SCRIPTS WOULD CONTINUE								// QUERY SQL SELECT "DONT CHANGE"
	query_sql "SELECT `promo`,`nameid`, `amount`,`limit`,`pool` FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$) + "'", [email protected]$, [email protected], [email protected],[email protected],[email protected];
	query_sql "SELECT `account_id`,`last_ip`,`code`,`claim` FROM `reward_logs` WHERE `code` = '" + escape_sql([email protected]$) + "'",[email protected],[email protected]$,[email protected]$,[email protected];							// QUERY SQL SELECT "DONT CHANGE"			
	if(.gm[0] == 1) {
		if ( getgmlevel() == .gm[1] ) {
			getitem [email protected], [email protected];		// GM CAN CLAIM REWARDS WITHOUT RESTRICTION
			end;						
		}	// END IF GM CONDTION	
	}
	if ( [email protected] ) { 					// CHECK IF CODE IS INVALID
		announce "Invalid code.",bc_self; 		
		end; 
	}	// END CHECK INVALID CODE					
						// DONT CHANGE! THIS IS THE 5th DEGREE of ABUSE PROTECTION, COMBO-MIX LOL! ------------------------------------------
	if ( getcharip(strcharinfo(0)) == [email protected]$ && [email protected]$ == [email protected]$ && [email protected] == 0 && getcharid(3) == [email protected] && [email protected] >= 1 ) { // Double Check MIX
						// ------------------------------------------------------------------------------------------------------------------
	announce "Code claim limit reach. Also either you already got this promo or other player in different IP might used code.",bc_self;
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
	end;
	}	// END OF 5th DEGREE ABUSE PROTECTION
			// DONT CHANGE! THIS IS THE 4th DEGREE of ABUSE PROTECTION, THE COMBO XD
	if ( [email protected]$ == [email protected]$ && [email protected] == 0 && getcharid(3) == [email protected] && [email protected] >= 1 ) {
			// ----------------------------------------------------------------------
	announce "Code claim limit reach. And you already got this promo.",bc_self;
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
	end;
	}	// END OF 4th DEGREE ABUSE PROTECTION
	//DONT CHANGE! THIS IS THE 3th DEGREE of ABUSE PROTECTION, POOL LIMIT
	if ( [email protected]$ == [email protected]$ && [email protected] == 0 ) { 
	// ==========================================================================
		if([email protected]$ == [email protected]$ && [email protected] == 1 ) {
			announce "Code "[email protected]$+" claim limit reached. "[email protected]+" player already redeemed the code.",bc_self; 
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
			end; 
		}
		if([email protected]$ == [email protected]$ && [email protected] >= 1 ) {
			announce "Code "[email protected]$+" claim limit reached. "[email protected]+" players already redeemed the codes.",bc_self; 
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
			end; 
		}
	}	// END OF 3th DEGREE OF ABUSE PROTECTION		
	//DONT CHANGE! THIS IS THE 2nd DEGREE of ABUSE PROTECTION, ACOUNT BASE LIMIT
	if([email protected]$ == [email protected]$ && getcharid(3) == [email protected] && [email protected] >= 1) { 	
	// ----------------------------------------------------------------------
	announce "Your Account already claimed "[email protected]$+" code.",bc_self; 
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
	end; 				
	}	// END OF 2nd DEGREE OF ABUSE PROTECTION
	//DONT CHANGE! THIS IS THE 2nd DEGREE of ABUSE PROTECTION, IP BASE LIMIT
	if ([email protected]$ == [email protected]$ && getcharip(strcharinfo(0)) == [email protected]$ && [email protected] >= 1 ) { 
	// ----------------------------------------------------------------------
	announce "IP that you used already claimed "[email protected]$+" code.",bc_self; 
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
	end; 
	} 	// END OF 1st DEGREE OF ABUSE PROTECTION
	getitem [email protected], [email protected];	// CODE SUCCESSFULLY REDEEMED! AFTER 5th DEGREE OF CHECKING!
	announce "Promotional code : "[email protected]$+" successfully redeemed!",bc_self;
						//  NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
// ****************************************** BIRBE WIRE *************************************************
	// SQL QUERY SERIES, PLEASE DONT CHANGE ANYTHING BELOW IF YOU DONT KNOW WHAT YOU ARE DOING!
	// CLAIM COUNT	
	if(query_sql("SELECT `claim` FROM `reward_logs` WHERE `code` = '" + escape_sql([email protected]$) + "'",[email protected])) { 
		set [email protected],1;
		query_sql("UPDATE `reward_logs` SET `claim` = '"+1+"' WHERE `code` = '" + escape_sql([email protected]$) + "'"); 
	}   
	else {
		query_sql("INSERT INTO `reward_logs` (`account_id`,`last_ip`,`code`,`redeem_time`,`claim`) VALUES ('"+getcharid(3)+"','"+getcharip(strcharinfo(0))+"','"+escape_sql([email protected]$)+"',NOW(),'"+1+"')"); 
	}
	// POOL COUNT
	if(query_sql("SELECT `pool` FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$) + "'",[email protected])){ 
	set [email protected],[email protected];
	query_sql("UPDATE `reward_codes` SET `pool` = '"[email protected]+"' WHERE `promo` = '" + escape_sql([email protected]$) + "'"); 
	} 
	else { 
		if([email protected] == 0) { 
			end; 
		}
		if([email protected] >= 1) { 
			query_sql "INSERT INTO `reward_codes` VALUES `pool` =  '"[email protected]+"'"; 
			end;
		}
	}
	// SQL QUERY SERIES, PLEASE DONT CHANGE ANYTHING ABOVE IF YOU DONT KNOW WHAT YOU ARE DOING!	
// ****************************************** BIRBE WIRE *************************************************
end;	// END OF ONCLAIM COMMAND

OnEditCode:	// ONEDITCODE STARTS
	MainMenu:
		goto EditCode;
	EditCode:
		if ( getgmlevel() < 99 ) end;		// CHECK GM LEVEL
		mes "[   ^ff0000Promotional-Code Generator^000000   ]";	// YOU CAN CHANGE MES DIALOGUES HERE
		mes "    ^ff5500Select from the options below:^000000";
		mes "===================================";
		// SQL QUERY DO NOT CHANGE =========================
		set [email protected], query_sql("SELECT `promo`,`pool` FROM `reward_codes` ORDER BY time_created DESC LIMIT 20",[email protected]$,[email protected]);
		// =================================================
		mes "^005500Available Codes:^000000";
		// FOR STATEMENT DONT CHANGE IF YOU DONT KNOW ANYTHING
		for(set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1)
		mes ""[email protected]$[[email protected]]+" : "[email protected][[email protected]]+"";
		// ===================================================
		next;
		menu "^55007f[ Create Codes ]^000000",Setup,"^005500[ View Codes ]^000000",View,"^6a6a4f[ Delete Codes ]^000000",Delete;
		close;
	Setup:
		next;
		menu "[ Create Manualy ]",Bling,"[ Random Code ]",Bleng,"[ All Random ]",Blung,"[ Main Menu ]",EditCode;  
		Bling:
			goto Promo;
			Promo:
				goto step1;
				step1:
				mes "[ ^ff0000Promotional Code Generator^000000 ]";
				mes "^ff5500Input the desired code.^000000.";
				input [email protected]$;
				set [email protected]$,strtoupper([email protected]$);
				if ( getstrlen( [email protected]$ ) < .length[0] || getstrlen( [email protected]$ ) > .length[1] ) {
					announce "The code length must not be less than " +.length[0]+ " and must not be greater than " +.length[1]+ ".",bc_self;
					next;
					menu "[ Re-Enter ]",step1,"[ Cancel ]",Done;
					close;
				}
				query_sql "SELECT `promo` FROM `reward_codes` WHERE `promo` = '"+ escape_sql([email protected]$) + "'",[email protected]$;
				if ([email protected]$ == [email protected]$) { 
					mes "The Code : [^ff0000"[email protected]$+"^000000] is already existing."; 
					next;
					menu "[ Re-Enter ]",step1,"[ Cancel ]",Done;
					close;
				}
				goto step2;
				step2:
				mes "You have entered [ ^FF0000"[email protected]$+"^000000 ].";
				mes "Set the ^005500Promotional Item^000000.";
				input [email protected];
				if ( [email protected] || getitemname([email protected]) == "null" ) {
					announce "Sorry, that is an invalid item id.",bc_self;
					next;
					menu "[ Re-Enter ]",step2,"[ Cancel ]",Done;
					close;
				}
				goto step3;
				step3:
				set [email protected]$, getitemname([email protected]);
				mes "Item ^FF0000"[email protected]+"^000000 is ^FF0000"[email protected]$+"^000000.";
				mes "Now, set the ^00007fAmount^000000.";
				input [email protected];
				if ( [email protected] ) {
					announce "Sorry, that is an invalid amount number.",bc_self;
					next;
					menu "[ Re-Enter ]",step3,"[ Cancel ]",Done;
					close;
				}
				if ([email protected] > 1 ) {
					mes ""[email protected]+" pieces of reward.";
				}
				else {
					mes ""[email protected]+" piece of reward.";
				}
				next;
				menu "[ Proceed ]",Proceed,"[ Done ]",Done;
				close;
					Proceed:
						goto LilTroll;
						LilTroll:
							mes "[ ^ff0000Promotional Code Generator^000000 ]";
							mes "Check the promo below:";
							mes "Code: ^ff0000"[email protected]$+"^000000 : ^005500"[email protected]+"^000000";
							mes "^55007f"+getitemname([email protected])+"^000000) : ^00007f"[email protected]+"^000000 ";
							mes "Set claim limitation.";
							input [email protected];
							if([email protected] == 0){
								announce "You must set atleast 1 limitation.",bc_self;  
								close;
							}
							set [email protected],[email protected];
							mes "Code-Pool usage ends at "[email protected]+"."; 
							mes "Create your Promo Code now?";
							next;
							if ( select("Generate:Stop") - 1 ) close;
							// QUERY SQL, PLEASE DONT CHANGE ANYTHING IF YOU DONT KNOW THIS ====================================================================================================================================================================================================
							query_sql ("INSERT INTO `reward_codes` (`promo`,`nameid`,`item_name`,`amount`,`time_created`,`limit`,`pool`) VALUES ( '" + escape_sql([email protected]$) + "', '" + [email protected] + "', '" + escape_sql([email protected]$) + "', '" + [email protected] + "', NOW() ,'"[email protected]+"','"[email protected]+"' )");
							//  ==================================================================================================================================================================================================== ===========================================================
							announce "Done creating "[email protected]$+"!",bc_self;        
							next;
							menu "[ Create Another Code ]",Setup,"[ Done ]",Done;
							close;
		Bleng:
			goto RandCode;
			RandCode:
			// ******************** IF YOU TOUCH BELOW THIS! TESLA COIL WILL ELECTRIFY AND TOAST YOU! RESULTING INSTANT DEATH! *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
			setarray [email protected]$[0],"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0";
			set [email protected],.promoprize[rand(getarraysize(.promoprize))];
			set [email protected],.prizeamount[rand(getarraysize(.prizeamount))];
			set [email protected],.claimlimit[rand(getarraysize(.claimlimit))];
			if(.length[1]==15) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==14) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==13) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==12) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==11) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==10) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==9) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==8) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==7) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==6) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==5) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";	
			// ********************  IF YOU TOUCH ABOVE THIS! TESLA COIL WILL ELECTRIFY AND TOAST YOU! RESULTING INSTANT DEATH! *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
			mes "[ ^ff0000Promotional Code Generator^000000 ]";
			mes "Random Generator:";
			mes "Code : "[email protected]$+" ";
			next;
			menu "[ Re-Generate ]",RandCode,"[ Proceed ]",RandProceed,"[ Return ]",Setup;
			close;
				RandProceed:
				goto RandomProceed;
				RandomProceed:
					query_sql "SELECT `promo` FROM `reward_codes` WHERE `promo` = '"+ escape_sql([email protected]$) + "'",[email protected]$;
					if ([email protected]$ == [email protected]$) { 
						mes "The Code : [^ff0000"[email protected]$+"^000000] is already existing."; 
						next;
						menu "[ Re-Generate ]",RandCode,"[ Cancel ]",Done;
						close;
					}
				goto RandProceed1;
				RandProceed1:
				mes "Randon code is : ";
				mes "[ ^FF0000"[email protected]$+"^000000 ].";
				mes "Set the ^005500Promotional Item^000000.";
				input [email protected];
				if ( [email protected] || getitemname([email protected]) == "null" ) {
					announce "Sorry, that is an invalid item id.",bc_self;
					next;
					menu "[ Re-Enter ]",RandProceed1,"[ Cancel ]",Done;
					close;
				}
				goto RandProceed2;
				RandProceed2:
				set [email protected]$, getitemname([email protected]);
				mes "Item ^FF0000"[email protected]+"^000000 is ^FF0000"[email protected]$+"^000000.";
				mes "Now, set the ^00007fAmount^000000.";
				input [email protected];
				if ( [email protected] ) {
					announce "Sorry, that is an invalid amount number.",bc_self;
					next;
					menu "[ Re-Enter ]",RandProceed2,"[ Cancel ]",Done;
					close;
				}
				if ([email protected] > 1 ) {
					mes ""[email protected]+" pieces of reward.";
				}
				else {
					mes ""[email protected]+" piece of reward.";
				}
				next;
				menu "[ Proceed ]",RandFinalize,"[ Done ]",Done;
				close;
					RandFinalize:
						goto LilTrollol;
						LilTrollol:
							mes "[ ^ff0000Promotional Code Generator^000000 ]";
							mes "Check the promo below:";
							mes "Code: ^ff0000"[email protected]$+"^000000 : ^005500"[email protected]+"^000000";
							mes "^55007f"+getitemname([email protected])+"^000000) : ^00007f"[email protected]+"^000000 ";
							mes "Set claim limitation.";
							input [email protected];
							if([email protected] == 0){
								announce "You must set atleast 1 limitation.",bc_self;  
								close;
							}
							set [email protected],[email protected];
							mes "Code-Pool usage ends at "[email protected]+"."; 
							mes "Create your Promo Code now?";
							next;
							if ( select("Generate:Stop") - 1 ) close;
							// QUERY SQL, PLEASE DONT CHANGE ANYTHING IF YOU DONT KNOW THIS ====================================================================================================================================================================================================
							query_sql ("INSERT INTO `reward_codes` (`promo`,`nameid`,`item_name`,`amount`,`time_created`,`limit`,`pool`) VALUES ( '" + escape_sql([email protected]$) + "', '" + [email protected] + "', '" + escape_sql([email protected]$) + "', '" + [email protected] + "', NOW() ,'"[email protected]+"','"[email protected]+"' )");
							//  ==================================================================================================================================================================================================== ===========================================================
							announce "Done creating code!",bc_self;        
							next;
							menu "[ Create Another Code ]",Setup,"[ Done ]",Done;
							close;
		Blung:
			goto String;
			String:
			// ******************** IF YOU TOUCH BELOW THIS! TESLA COIL WILL ELECTRIFY AND TOAST YOU! RESULTING INSTANT DEATH! *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
			setarray [email protected]$[0],"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0";
			set [email protected],.promoprize[rand(getarraysize(.promoprize))];
			set [email protected],.prizeamount[rand(getarraysize(.prizeamount))];
			set [email protected],.claimlimit[rand(getarraysize(.claimlimit))];
			if(.length[1]==15) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==14) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==13) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==12) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==11) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==10) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==9) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==8) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==7) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==6) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==5) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";	
			// ********************  IF YOU TOUCH ABOVE THIS! TESLA COIL WILL ELECTRIFY AND TOAST YOU! RESULTING INSTANT DEATH! *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
			mes "[ ^ff0000Promotional Code Generator^000000 ]";
			mes "Random Generator:";
			mes "Code : "[email protected]$+" ";
			mes "Item : "+getitemname([email protected])+" ";
			mes "Item ID : "[email protected]+"";
			set [email protected]$,getitemname([email protected]);
			mes "Amount : "[email protected]+" ";
			mes "Limit : "[email protected]+" ";
			next;
			menu "[ Re-Generate Codes ]",string,"[ Confirm ]",confirm,"[ Cancel ]",done;
			close;
				Done:
					close;
				Confirm:
					// QUERY SQL DONT CHANGE ANYTHING HERE ====================================================================================================================================================================================================================
					query_sql ("INSERT INTO `reward_codes` (`promo`,`nameid`,`item_name`,`amount`,`time_created`,`limit`,`pool`) VALUES ( '" + escape_sql([email protected]$) + "', '" + [email protected] + "', '" + escape_sql([email protected]$) + "', '" + [email protected] + "', NOW() ,'"[email protected]+"','"[email protected]+"' )");
					// ========================================================================================================================================================================================================================================================
					announce "Promotional Code : "[email protected]$+" has been created.",bc_self;
					next;
					menu "[ Create Another Code ]",Setup,"[ Done ]",Done;
					close;
		View:
		goto	Existing;
			Existing:
				// QUERY SQL DONT CHANGE ANYTHING HERE =========================================================================================================================
				set [email protected], query_sql("SELECT `promo`, `item_name`, `amount`, `pool` FROM `reward_codes` ORDER BY time_created DESC LIMIT 20", [email protected]$, [email protected]$, [email protected], [email protected]);    
				// QUERY SQL DONT CHANGE ANYTHING HERE =========================================================================================================================
				if ( [email protected] ) {
				announce "No exisiting codes.",bc_self;
				close;
				}
				mes "[ ^ff0000Promotional Code Generator^000000 ]";
				mes "===================================";
				mes "=======  EXISITING  CODES  =======";
				mes "===================================";
				mes "Code:ID:Item:Amount:Limit";
				// FORE STATEMENT DONT CHANGE ANY OF HERE =================================
				for(set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1)
				mes "["[email protected]$[[email protected]]+"]:["[email protected]$[[email protected]]+"]["[email protected][[email protected]]+"]["[email protected]+"]";
				// ========================================================================
				mes "===================================";
				next;
				menu "[ Main Menu ]",EditCode,"[ Done ]",Done;
				close;
			Delete:
			goto Deletenow;
				Deletenow:
					// QUERY SQL DONT CHANGE ANYTHING HERE ===========================================================================================
					set [email protected], query_sql("SELECT `promo`,`time_created` FROM `reward_codes` ORDER BY time_created ASC LIMIT 10", [email protected]$,[email protected]$);
					// ===============================================================================================================================
					mes "[ ^ff0000Promotional Code Generator^000000 ]";
					mes "===================================";
					mes "=======  EXISITING  CODES  =======";
					mes "===================================";
					// FORE STATEMENT DONT CHANGE ANY OF HERE ===
					for(set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1){
					mes ""[email protected]$[[email protected]]+" : "[email protected]$+""; }
					// ==========================================
					mes "===================================";
					input [email protected]$;
					next;
					mes "[ ^ff0000Promotional Code Generator^000000 ]";
					mes "Would you like to delete the code?";
					mes ""[email protected]$+"";
					next;
					if ( select("[ Confirm ]:[ Cancel ]") - 1 ) close;
					// QUERY SQL DONT CHANGE ANYTHING HERE ===========================================================================================
					query_sql "SELECT `promo` FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$) + "'",[email protected]_exists$;  
					if([email protected]$ == [email protected]_exists$ ) {
					announce "Promotional Code : ["[email protected]$+"] has been deleted.",bc_self;
					query_sql "DELETE FROM `ragnarok`.`reward_codes` WHERE `promo` = '" + escape_sql([email protected]$) + "'"; 
					query_sql "DELETE FROM `ragnarok`.`reward_logs` WHERE `code` = '" + escape_sql([email protected]$) + "'";
					// QUERY SQL DONT CHANGE ANYTHING HERE ===========================================================================================
					next;
					menu "[ Main Menu ]",Proceed,"[ Done ]",Done;
					close;
					}
					else {
						announce "Promotional code not found.",bc_self;
						next;
						menu "[ Main Menu ]",MainMenu,"[ Done ]",Done;
						close;
					}
end;	// ENDS ONEDITCODES 
} // ENDS LILTROLLPCODES

It only records 1 account id in the reward_logs table I've tried everything I can but I still can't fix it. I hope someone can help me. Thank you!

Edited by xerxesbreak

Share this post


Link to post
Share on other sites
2 hours ago, xerxesbreak said:

I'm using this script of Liltroll but I've been having some  trouble with the sql 

////////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------//
//                          PROMOTIONAL CODES                         //
//                     AUTHOR: LIL TROLL//COLDFIRE                    //
//--------------------------------------------------------------------//
//                          RATHENA SCRIPT                            //
//--------------------------------------------------------------------//
//                          Version 1.2.3                             //
//--------------------------------------------------------------------//
//    FEATURES: (Modified Promotional Code by sir Patskie)            //
//   								       				//
// #1 5`Degree of Abuse-Protection(+ItemBound = 6)		       	//
//    - IP,ACCOUNT,COUNTLIMIT,DOUBLECHECK,MIX			       	//
// #2 Code can be deleted/detected by gm.			       		//
// #3 Friendly User Interface.					      		//
// #4 Very easy to configure.					      			//
// #5 Code auto delete at certain variable setup(limit pool).	     //
// #6 GM can view codes when claiming.				       		//
// #7 GM can set limitation of usage of the codes.		       	//
// #8 Automatically delete any codes that set to desirable 	       	//
//    pool limit by gm claimed by players.			      		//
// #9 GM can set random code with random item! :D		      		//
// #10 GM toggle (when claiming the code, restriction) included.		//
//--------------------------------------------------------------------//
////////////////////////////////////////////////////////////////////////
/*
DROP TABLE IF EXISTS `reward_codes`;
DROP TABLE IF EXISTS `reward_logs`;
CREATE TABLE IF NOT EXISTS `reward_codes` (
	`promo` VARCHAR(26) NOT NULL DEFAULT '',
	`nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
	`item_name` VARCHAR(50) NOT NULL DEFAULT '',
	`amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',
	`time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
	`limit` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	`pool` INT(10) UNSIGNED NOT NULL DEFAULT '0',
	PRIMARY KEY (`promo`)
) ENGINE = MYISAM;
CREATE TABLE IF NOT EXISTS `reward_logs` (
	`account_id` int(11) unsigned NOT NULL default '0',
	`last_ip` VARCHAR( 100 ) NOT NULL,
	`code` VARCHAR( 26 ) NOT NULL,
	`redeem_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
	`claim` INT( 10 ) NOT NULL,
	PRIMARY KEY (`code`)
) ENGINE = MYISAM;
*/
-	script	LilTrollPCodes	-1,{
OnInit:
	//initnpctimer;	// I USED THIS FOR TESTING PURPOSES	WITH ONTIMER
	bindatcmd "claim",strnpcinfo(3)+"::OnClaim";	
	bindatcmd "code",strnpcinfo(3)+"::OnEditCode";
	setarray .promoprize[0],501,502,503,504,505,506,507,508,509,510;   	// SET ITEM ID HERE FOR REWARDS
	setarray .prizeamount[0],1,2,3,4,5,6,7,8,9,10;         // AMOUNT OF REWARDS
	setarray .claimlimit[0],1,2,3,4,5,6,7,8,9,10;		// CLAIM LIMITATION
	setarray .length,5,15; // <MIN>,<MAX> LENGTH CHECK	// 5 Recommended Minimum due to not recognizing 1234 from garbage deletion.
	setarray .gm,0,								// 1 Enable, 0 Disable GM Restriction in Claiming Promo Codes.
		 	  99;								// GM claims doesnt affect claim limit pool.
	query_sql "CREATE TABLE IF NOT EXISTS `reward_codes` (`promo` VARCHAR(26) NOT NULL DEFAULT '',`nameid` INT(11) UNSIGNED NOT NULL DEFAULT '0',`item_name` VARCHAR(50) NOT NULL DEFAULT '',`amount` SMALLINT(6) UNSIGNED NOT NULL DEFAULT '0',`time_created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',`limit` INT(10) UNSIGNED NOT NULL DEFAULT '0',`pool` INT(10) UNSIGNED NOT NULL DEFAULT '0',PRIMARY KEY (`promo`)) ENGINE = MYISAM";
	query_sql "CREATE TABLE IF NOT EXISTS `reward_logs` (`account_id` int(11) unsigned NOT NULL default '0',`last_ip` BINARY( 9 ) NOT NULL,`code` VARCHAR( 26 ) NOT NULL,`redeem_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',`claim` INT( 10 ) NOT NULL,PRIMARY KEY (`code`)) ENGINE = MYISAM";
	end;											// 15 maximum characters supported in random code generation.
//OnTimer20000:			// I USED THIS FOR TESTING PURPOSES WITH INITNPCTIMER
OnMinute0000: // Refreshes every 1 Hour. Automatically delete 0 pool count promos. // Change this if you want.
	// ****************************************************** BIRBE WIRE ***************************************************	
	set [email protected],query_sql("SELECT `promo`,`pool` FROM `reward_codes` ORDER BY pool ASC LIMIT 50",[email protected]$,[email protected]);
	for(set [email protected],1; [email protected] <= [email protected]; set [email protected],[email protected]++) {
	query_sql "DELETE FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$[0]) + "' AND `pool` = '0'";   // Number 1 row will be deleted.
	query_sql "DELETE FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$[[email protected]]) + "' AND `pool` = '0'"; // Numbers from 2-10 rows will be deleted.
	}
	debugmes "Promotional Codes garbage are deleted.";
	// ****************************************************** BIRBE WIRE ***************************************************	
	//initnpctimer;	// I USED THIS FOR TESTING PURPOSES WITH ONTIMER
end;
	// ****************************************************** BIRBE WIRE ***************************************************
OnDay0101: OnDay0102: OnDay0103: OnDay0104: OnDay0105: OnDay0106:	// Clean sql garbage every 1st day of the month.
OnDay0107: OnDay0108: OnDay0109: OnDay0110: OnDay0111: OnDay0112:
	set [email protected],query_sql("SELECT `codes`,`redeem_time` FROM `reward_logs` ORDER BY pool ASC LIMIT 25",[email protected]$);
	for(set [email protected],1; [email protected] <= [email protected]; set [email protected],[email protected]++) {
	query_sql "DELETE FROM `reward_logs` WHERE `codes` = '" + escape_sql([email protected]$[0]) + "'";  // Number 1 row will be deleted.
	query_sql "DELETE FROM `reward_logs` WHERE `codes` = '" + escape_sql([email protected]$[[email protected]]) + ""; // Numbers from 2-25 rows will be deleted.
	}
	debugmes "reward_logs garbage has been deleted.";
end;  	
	// ****************************************************** BIRBE WIRE ***************************************************
OnClaim:	// ONCLAIM COMMAND STARTS
	if ( getgmlevel() < 99 ) { 
	mes "^00007fNew Exodus Ragnarok Online^000000"; 							// INPUT YOUR SERVERNAME
	mes "Promotional Code Rewards"; 								// YOU CAN CHANGE ALL MES DIALOGUES
	mes "Input the correct [ ^ff0000Code^000000 ]"; 
	}
	if ( getgmlevel() == 99 ) {									// CHECK GM LEVEL
									// QUERY SQL SELECT "DONT CHANGE"
	set [email protected], query_sql("SELECT `promo`,`pool` FROM `reward_codes` ORDER BY time_created DESC LIMIT 20",[email protected]$,[email protected]);
									// QUERY SQL SELECT "DONT CHANGE"
	mes "^00007fPROMOTIONAL REWARDS^000000";
	mes "^ff0000GM MENU:^000000";
	mes "^005500Codes:Claim Limit^000000";
	// FOR STATEMENT DONT CHANGE IF YOU DONT KNOW WHAT YOU ARE DOING.
	for(set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1)
	// FOR STATEMENT DONT CHANGE IF YOU DONT KNOW WHAT YOU ARE DOING.
	mes ""[email protected]$[[email protected]]+" : "[email protected][[email protected]]+"";
	}
	input [email protected]$;
	set [email protected]$,strtoupper([email protected]$);						// CLAIM INPUT CODE
	if ( getstrlen( [email protected]$ ) < .length[0] || getstrlen( [email protected]$ ) > .length[1] ) {			// CHECK LENGHT OF THE CODE
		announce "Incorrect input. Code is not less than " +.length[0]+ " and must be greater than " +.length[1]+ ".",bc_self;
		end;// ----------------------------------------------------------------------
	}	// END CHECK LENGHT
	close2;		// CLOSE2 COMMAND SCRIPTS WOULD CONTINUE								// QUERY SQL SELECT "DONT CHANGE"
	query_sql "SELECT `promo`,`nameid`, `amount`,`limit`,`pool` FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$) + "'", [email protected]$, [email protected], [email protected],[email protected],[email protected];
	query_sql "SELECT `account_id`,`last_ip`,`code`,`claim` FROM `reward_logs` WHERE `code` = '" + escape_sql([email protected]$) + "'",[email protected],[email protected]$,[email protected]$,[email protected];							// QUERY SQL SELECT "DONT CHANGE"			
	if(.gm[0] == 1) {
		if ( getgmlevel() == .gm[1] ) {
			getitem [email protected], [email protected];		// GM CAN CLAIM REWARDS WITHOUT RESTRICTION
			end;						
		}	// END IF GM CONDTION	
	}
	if ( [email protected] ) { 					// CHECK IF CODE IS INVALID
		announce "Invalid code.",bc_self; 		
		end; 
	}	// END CHECK INVALID CODE					
						// DONT CHANGE! THIS IS THE 5th DEGREE of ABUSE PROTECTION, COMBO-MIX LOL! ------------------------------------------
	if ( getcharip(strcharinfo(0)) == [email protected]$ && [email protected]$ == [email protected]$ && [email protected] == 0 && getcharid(3) == [email protected] && [email protected] >= 1 ) { // Double Check MIX
						// ------------------------------------------------------------------------------------------------------------------
	announce "Code claim limit reach. Also either you already got this promo or other player in different IP might used code.",bc_self;
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
	end;
	}	// END OF 5th DEGREE ABUSE PROTECTION
			// DONT CHANGE! THIS IS THE 4th DEGREE of ABUSE PROTECTION, THE COMBO XD
	if ( [email protected]$ == [email protected]$ && [email protected] == 0 && getcharid(3) == [email protected] && [email protected] >= 1 ) {
			// ----------------------------------------------------------------------
	announce "Code claim limit reach. And you already got this promo.",bc_self;
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
	end;
	}	// END OF 4th DEGREE ABUSE PROTECTION
	//DONT CHANGE! THIS IS THE 3th DEGREE of ABUSE PROTECTION, POOL LIMIT
	if ( [email protected]$ == [email protected]$ && [email protected] == 0 ) { 
	// ==========================================================================
		if([email protected]$ == [email protected]$ && [email protected] == 1 ) {
			announce "Code "[email protected]$+" claim limit reached. "[email protected]+" player already redeemed the code.",bc_self; 
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
			end; 
		}
		if([email protected]$ == [email protected]$ && [email protected] >= 1 ) {
			announce "Code "[email protected]$+" claim limit reached. "[email protected]+" players already redeemed the codes.",bc_self; 
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
			end; 
		}
	}	// END OF 3th DEGREE OF ABUSE PROTECTION		
	//DONT CHANGE! THIS IS THE 2nd DEGREE of ABUSE PROTECTION, ACOUNT BASE LIMIT
	if([email protected]$ == [email protected]$ && getcharid(3) == [email protected] && [email protected] >= 1) { 	
	// ----------------------------------------------------------------------
	announce "Your Account already claimed "[email protected]$+" code.",bc_self; 
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
	end; 				
	}	// END OF 2nd DEGREE OF ABUSE PROTECTION
	//DONT CHANGE! THIS IS THE 2nd DEGREE of ABUSE PROTECTION, IP BASE LIMIT
	if ([email protected]$ == [email protected]$ && getcharip(strcharinfo(0)) == [email protected]$ && [email protected] >= 1 ) { 
	// ----------------------------------------------------------------------
	announce "IP that you used already claimed "[email protected]$+" code.",bc_self; 
						// NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
	end; 
	} 	// END OF 1st DEGREE OF ABUSE PROTECTION
	getitem [email protected], [email protected];	// CODE SUCCESSFULLY REDEEMED! AFTER 5th DEGREE OF CHECKING!
	announce "Promotional code : "[email protected]$+" successfully redeemed!",bc_self;
						//  NOTE: YOU CAN CHANGE ABOVE ANNOUNCE DIALOGUE.
// ****************************************** BIRBE WIRE *************************************************
	// SQL QUERY SERIES, PLEASE DONT CHANGE ANYTHING BELOW IF YOU DONT KNOW WHAT YOU ARE DOING!
	// CLAIM COUNT	
	if(query_sql("SELECT `claim` FROM `reward_logs` WHERE `code` = '" + escape_sql([email protected]$) + "'",[email protected])) { 
		set [email protected],1;
		query_sql("UPDATE `reward_logs` SET `claim` = '"+1+"' WHERE `code` = '" + escape_sql([email protected]$) + "'"); 
	}   
	else {
		query_sql("INSERT INTO `reward_logs` (`account_id`,`last_ip`,`code`,`redeem_time`,`claim`) VALUES ('"+getcharid(3)+"','"+getcharip(strcharinfo(0))+"','"+escape_sql([email protected]$)+"',NOW(),'"+1+"')"); 
	}
	// POOL COUNT
	if(query_sql("SELECT `pool` FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$) + "'",[email protected])){ 
	set [email protected],[email protected];
	query_sql("UPDATE `reward_codes` SET `pool` = '"[email protected]+"' WHERE `promo` = '" + escape_sql([email protected]$) + "'"); 
	} 
	else { 
		if([email protected] == 0) { 
			end; 
		}
		if([email protected] >= 1) { 
			query_sql "INSERT INTO `reward_codes` VALUES `pool` =  '"[email protected]+"'"; 
			end;
		}
	}
	// SQL QUERY SERIES, PLEASE DONT CHANGE ANYTHING ABOVE IF YOU DONT KNOW WHAT YOU ARE DOING!	
// ****************************************** BIRBE WIRE *************************************************
end;	// END OF ONCLAIM COMMAND

OnEditCode:	// ONEDITCODE STARTS
	MainMenu:
		goto EditCode;
	EditCode:
		if ( getgmlevel() < 99 ) end;		// CHECK GM LEVEL
		mes "[   ^ff0000Promotional-Code Generator^000000   ]";	// YOU CAN CHANGE MES DIALOGUES HERE
		mes "    ^ff5500Select from the options below:^000000";
		mes "===================================";
		// SQL QUERY DO NOT CHANGE =========================
		set [email protected], query_sql("SELECT `promo`,`pool` FROM `reward_codes` ORDER BY time_created DESC LIMIT 20",[email protected]$,[email protected]);
		// =================================================
		mes "^005500Available Codes:^000000";
		// FOR STATEMENT DONT CHANGE IF YOU DONT KNOW ANYTHING
		for(set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1)
		mes ""[email protected]$[[email protected]]+" : "[email protected][[email protected]]+"";
		// ===================================================
		next;
		menu "^55007f[ Create Codes ]^000000",Setup,"^005500[ View Codes ]^000000",View,"^6a6a4f[ Delete Codes ]^000000",Delete;
		close;
	Setup:
		next;
		menu "[ Create Manualy ]",Bling,"[ Random Code ]",Bleng,"[ All Random ]",Blung,"[ Main Menu ]",EditCode;  
		Bling:
			goto Promo;
			Promo:
				goto step1;
				step1:
				mes "[ ^ff0000Promotional Code Generator^000000 ]";
				mes "^ff5500Input the desired code.^000000.";
				input [email protected]$;
				set [email protected]$,strtoupper([email protected]$);
				if ( getstrlen( [email protected]$ ) < .length[0] || getstrlen( [email protected]$ ) > .length[1] ) {
					announce "The code length must not be less than " +.length[0]+ " and must not be greater than " +.length[1]+ ".",bc_self;
					next;
					menu "[ Re-Enter ]",step1,"[ Cancel ]",Done;
					close;
				}
				query_sql "SELECT `promo` FROM `reward_codes` WHERE `promo` = '"+ escape_sql([email protected]$) + "'",[email protected]$;
				if ([email protected]$ == [email protected]$) { 
					mes "The Code : [^ff0000"[email protected]$+"^000000] is already existing."; 
					next;
					menu "[ Re-Enter ]",step1,"[ Cancel ]",Done;
					close;
				}
				goto step2;
				step2:
				mes "You have entered [ ^FF0000"[email protected]$+"^000000 ].";
				mes "Set the ^005500Promotional Item^000000.";
				input [email protected];
				if ( [email protected] || getitemname([email protected]) == "null" ) {
					announce "Sorry, that is an invalid item id.",bc_self;
					next;
					menu "[ Re-Enter ]",step2,"[ Cancel ]",Done;
					close;
				}
				goto step3;
				step3:
				set [email protected]$, getitemname([email protected]);
				mes "Item ^FF0000"[email protected]+"^000000 is ^FF0000"[email protected]$+"^000000.";
				mes "Now, set the ^00007fAmount^000000.";
				input [email protected];
				if ( [email protected] ) {
					announce "Sorry, that is an invalid amount number.",bc_self;
					next;
					menu "[ Re-Enter ]",step3,"[ Cancel ]",Done;
					close;
				}
				if ([email protected] > 1 ) {
					mes ""[email protected]+" pieces of reward.";
				}
				else {
					mes ""[email protected]+" piece of reward.";
				}
				next;
				menu "[ Proceed ]",Proceed,"[ Done ]",Done;
				close;
					Proceed:
						goto LilTroll;
						LilTroll:
							mes "[ ^ff0000Promotional Code Generator^000000 ]";
							mes "Check the promo below:";
							mes "Code: ^ff0000"[email protected]$+"^000000 : ^005500"[email protected]+"^000000";
							mes "^55007f"+getitemname([email protected])+"^000000) : ^00007f"[email protected]+"^000000 ";
							mes "Set claim limitation.";
							input [email protected];
							if([email protected] == 0){
								announce "You must set atleast 1 limitation.",bc_self;  
								close;
							}
							set [email protected],[email protected];
							mes "Code-Pool usage ends at "[email protected]+"."; 
							mes "Create your Promo Code now?";
							next;
							if ( select("Generate:Stop") - 1 ) close;
							// QUERY SQL, PLEASE DONT CHANGE ANYTHING IF YOU DONT KNOW THIS ====================================================================================================================================================================================================
							query_sql ("INSERT INTO `reward_codes` (`promo`,`nameid`,`item_name`,`amount`,`time_created`,`limit`,`pool`) VALUES ( '" + escape_sql([email protected]$) + "', '" + [email protected] + "', '" + escape_sql([email protected]$) + "', '" + [email protected] + "', NOW() ,'"[email protected]+"','"[email protected]+"' )");
							//  ==================================================================================================================================================================================================== ===========================================================
							announce "Done creating "[email protected]$+"!",bc_self;        
							next;
							menu "[ Create Another Code ]",Setup,"[ Done ]",Done;
							close;
		Bleng:
			goto RandCode;
			RandCode:
			// ******************** IF YOU TOUCH BELOW THIS! TESLA COIL WILL ELECTRIFY AND TOAST YOU! RESULTING INSTANT DEATH! *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
			setarray [email protected]$[0],"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0";
			set [email protected],.promoprize[rand(getarraysize(.promoprize))];
			set [email protected],.prizeamount[rand(getarraysize(.prizeamount))];
			set [email protected],.claimlimit[rand(getarraysize(.claimlimit))];
			if(.length[1]==15) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==14) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==13) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==12) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==11) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==10) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==9) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==8) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==7) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==6) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==5) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";	
			// ********************  IF YOU TOUCH ABOVE THIS! TESLA COIL WILL ELECTRIFY AND TOAST YOU! RESULTING INSTANT DEATH! *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
			mes "[ ^ff0000Promotional Code Generator^000000 ]";
			mes "Random Generator:";
			mes "Code : "[email protected]$+" ";
			next;
			menu "[ Re-Generate ]",RandCode,"[ Proceed ]",RandProceed,"[ Return ]",Setup;
			close;
				RandProceed:
				goto RandomProceed;
				RandomProceed:
					query_sql "SELECT `promo` FROM `reward_codes` WHERE `promo` = '"+ escape_sql([email protected]$) + "'",[email protected]$;
					if ([email protected]$ == [email protected]$) { 
						mes "The Code : [^ff0000"[email protected]$+"^000000] is already existing."; 
						next;
						menu "[ Re-Generate ]",RandCode,"[ Cancel ]",Done;
						close;
					}
				goto RandProceed1;
				RandProceed1:
				mes "Randon code is : ";
				mes "[ ^FF0000"[email protected]$+"^000000 ].";
				mes "Set the ^005500Promotional Item^000000.";
				input [email protected];
				if ( [email protected] || getitemname([email protected]) == "null" ) {
					announce "Sorry, that is an invalid item id.",bc_self;
					next;
					menu "[ Re-Enter ]",RandProceed1,"[ Cancel ]",Done;
					close;
				}
				goto RandProceed2;
				RandProceed2:
				set [email protected]$, getitemname([email protected]);
				mes "Item ^FF0000"[email protected]+"^000000 is ^FF0000"[email protected]$+"^000000.";
				mes "Now, set the ^00007fAmount^000000.";
				input [email protected];
				if ( [email protected] ) {
					announce "Sorry, that is an invalid amount number.",bc_self;
					next;
					menu "[ Re-Enter ]",RandProceed2,"[ Cancel ]",Done;
					close;
				}
				if ([email protected] > 1 ) {
					mes ""[email protected]+" pieces of reward.";
				}
				else {
					mes ""[email protected]+" piece of reward.";
				}
				next;
				menu "[ Proceed ]",RandFinalize,"[ Done ]",Done;
				close;
					RandFinalize:
						goto LilTrollol;
						LilTrollol:
							mes "[ ^ff0000Promotional Code Generator^000000 ]";
							mes "Check the promo below:";
							mes "Code: ^ff0000"[email protected]$+"^000000 : ^005500"[email protected]+"^000000";
							mes "^55007f"+getitemname([email protected])+"^000000) : ^00007f"[email protected]+"^000000 ";
							mes "Set claim limitation.";
							input [email protected];
							if([email protected] == 0){
								announce "You must set atleast 1 limitation.",bc_self;  
								close;
							}
							set [email protected],[email protected];
							mes "Code-Pool usage ends at "[email protected]+"."; 
							mes "Create your Promo Code now?";
							next;
							if ( select("Generate:Stop") - 1 ) close;
							// QUERY SQL, PLEASE DONT CHANGE ANYTHING IF YOU DONT KNOW THIS ====================================================================================================================================================================================================
							query_sql ("INSERT INTO `reward_codes` (`promo`,`nameid`,`item_name`,`amount`,`time_created`,`limit`,`pool`) VALUES ( '" + escape_sql([email protected]$) + "', '" + [email protected] + "', '" + escape_sql([email protected]$) + "', '" + [email protected] + "', NOW() ,'"[email protected]+"','"[email protected]+"' )");
							//  ==================================================================================================================================================================================================== ===========================================================
							announce "Done creating code!",bc_self;        
							next;
							menu "[ Create Another Code ]",Setup,"[ Done ]",Done;
							close;
		Blung:
			goto String;
			String:
			// ******************** IF YOU TOUCH BELOW THIS! TESLA COIL WILL ELECTRIFY AND TOAST YOU! RESULTING INSTANT DEATH! *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
			setarray [email protected]$[0],"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","1","2","3","4","5","6","7","8","9","0";
			set [email protected],.promoprize[rand(getarraysize(.promoprize))];
			set [email protected],.prizeamount[rand(getarraysize(.prizeamount))];
			set [email protected],.claimlimit[rand(getarraysize(.claimlimit))];
			if(.length[1]==15) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==14) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==13) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==12) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==11) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==10) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==9) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==8) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==7) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==6) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";
			if(.length[1]==5) set [email protected]$,""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+""[email protected]$[rand(0,61)]+"";	
			// ********************  IF YOU TOUCH ABOVE THIS! TESLA COIL WILL ELECTRIFY AND TOAST YOU! RESULTING INSTANT DEATH! *********************************************************************************************************************************************************************************************************************************************************************************************************************************************************
			mes "[ ^ff0000Promotional Code Generator^000000 ]";
			mes "Random Generator:";
			mes "Code : "[email protected]$+" ";
			mes "Item : "+getitemname([email protected])+" ";
			mes "Item ID : "[email protected]+"";
			set [email protected]$,getitemname([email protected]);
			mes "Amount : "[email protected]+" ";
			mes "Limit : "[email protected]+" ";
			next;
			menu "[ Re-Generate Codes ]",string,"[ Confirm ]",confirm,"[ Cancel ]",done;
			close;
				Done:
					close;
				Confirm:
					// QUERY SQL DONT CHANGE ANYTHING HERE ====================================================================================================================================================================================================================
					query_sql ("INSERT INTO `reward_codes` (`promo`,`nameid`,`item_name`,`amount`,`time_created`,`limit`,`pool`) VALUES ( '" + escape_sql([email protected]$) + "', '" + [email protected] + "', '" + escape_sql([email protected]$) + "', '" + [email protected] + "', NOW() ,'"[email protected]+"','"[email protected]+"' )");
					// ========================================================================================================================================================================================================================================================
					announce "Promotional Code : "[email protected]$+" has been created.",bc_self;
					next;
					menu "[ Create Another Code ]",Setup,"[ Done ]",Done;
					close;
		View:
		goto	Existing;
			Existing:
				// QUERY SQL DONT CHANGE ANYTHING HERE =========================================================================================================================
				set [email protected], query_sql("SELECT `promo`, `item_name`, `amount`, `pool` FROM `reward_codes` ORDER BY time_created DESC LIMIT 20", [email protected]$, [email protected]$, [email protected], [email protected]);    
				// QUERY SQL DONT CHANGE ANYTHING HERE =========================================================================================================================
				if ( [email protected] ) {
				announce "No exisiting codes.",bc_self;
				close;
				}
				mes "[ ^ff0000Promotional Code Generator^000000 ]";
				mes "===================================";
				mes "=======  EXISITING  CODES  =======";
				mes "===================================";
				mes "Code:ID:Item:Amount:Limit";
				// FORE STATEMENT DONT CHANGE ANY OF HERE =================================
				for(set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1)
				mes "["[email protected]$[[email protected]]+"]:["[email protected]$[[email protected]]+"]["[email protected][[email protected]]+"]["[email protected]+"]";
				// ========================================================================
				mes "===================================";
				next;
				menu "[ Main Menu ]",EditCode,"[ Done ]",Done;
				close;
			Delete:
			goto Deletenow;
				Deletenow:
					// QUERY SQL DONT CHANGE ANYTHING HERE ===========================================================================================
					set [email protected], query_sql("SELECT `promo`,`time_created` FROM `reward_codes` ORDER BY time_created ASC LIMIT 10", [email protected]$,[email protected]$);
					// ===============================================================================================================================
					mes "[ ^ff0000Promotional Code Generator^000000 ]";
					mes "===================================";
					mes "=======  EXISITING  CODES  =======";
					mes "===================================";
					// FORE STATEMENT DONT CHANGE ANY OF HERE ===
					for(set [email protected],0; [email protected] < [email protected]; set [email protected],[email protected]+1){
					mes ""[email protected]$[[email protected]]+" : "[email protected]$+""; }
					// ==========================================
					mes "===================================";
					input [email protected]$;
					next;
					mes "[ ^ff0000Promotional Code Generator^000000 ]";
					mes "Would you like to delete the code?";
					mes ""[email protected]$+"";
					next;
					if ( select("[ Confirm ]:[ Cancel ]") - 1 ) close;
					// QUERY SQL DONT CHANGE ANYTHING HERE ===========================================================================================
					query_sql "SELECT `promo` FROM `reward_codes` WHERE `promo` = '" + escape_sql([email protected]$) + "'",[email protected]_exists$;  
					if([email protected]$ == [email protected]_exists$ ) {
					announce "Promotional Code : ["[email protected]$+"] has been deleted.",bc_self;
					query_sql "DELETE FROM `ragnarok`.`reward_codes` WHERE `promo` = '" + escape_sql([email protected]$) + "'"; 
					query_sql "DELETE FROM `ragnarok`.`reward_logs` WHERE `code` = '" + escape_sql([email protected]$) + "'";
					// QUERY SQL DONT CHANGE ANYTHING HERE ===========================================================================================
					next;
					menu "[ Main Menu ]",Proceed,"[ Done ]",Done;
					close;
					}
					else {
						announce "Promotional code not found.",bc_self;
						next;
						menu "[ Main Menu ]",MainMenu,"[ Done ]",Done;
						close;
					}
end;	// ENDS ONEDITCODES 
} // ENDS LILTROLLPCODES

It only records 1 account id in the reward_logs table I've tried everything I can but I still can't fix it. I hope someone can help me. Thank you!

Try to check my Script Collection . I modified Liltroll and i use Coupon as the title of the NPC

Share this post


Link to post
Share on other sites
Quote

Try to check my Script Collection . I modified Liltroll and i use Coupon as the title of the NPC

Hi! I checked your script-collection in github and there were no coupon there. sorry but can I ask if there is another script collection I'm missing?

Share this post


Link to post
Share on other sites
On 1/12/2021 at 10:30 PM, Poring King said:

Ahh Thank you!, I'll try it right now and reply again later if it works for me. thank you again! sorry for the trouble.

It's working too but is it possible to make it 1x per IP?

also apparently when you try to create another code there's no chance for the account to claim a different code

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.