Emistry icon

[RO] Fabre Punch Event - SQL - Point Rate

Emistry | PRO | 03/05/17 01:53:08 AM UTC | 0 ⭐ | 805 👁️ | Never ⏰ | []
text |

6.46 KB

|

None

|

0 👍

/

0 👎

// https://rathena.org/board/topic/109762-fabre-punch-event/
 /*
CREATE TABLE IF NOT EXISTS `e_fabre_punch_rank` (
  `cid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
  `name` NVARCHAR(30) NOT NULL DEFAULT '',
  `point` INT(11) SIGNED NOT NULL DEFAULT '0',
  `rank` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
  PRIMARY KEY (`cid`)
) ENGINE=MyISAM;
*/
 prontera,129,204,5	script	Fabre Punch Event	4_M_MOC_SOLDIER,{
	doevent "fabre_punch_main::OnTalk";
}
 pvp_n_1-2,100,100,5	script	Fabre Punch Ranking	4_M_MOC_SOLDIER,{
	doevent "fabre_punch_main::OnViewRank";
}
 pvp_n_1-2,0,0,0,0	monster	1 Point	1007,60,0,60000,"fabre_punch_main::OnKill_1"
pvp_n_1-2,0,0,0,0	monster	10 Points	1007,30,0,60000,"fabre_punch_main::OnKill_2"
pvp_n_1-2,0,0,0,0	monster	-20 Points	1007,50,0,60000,"fabre_punch_main::OnKill_3"
pvp_n_1-2,0,0,0,0	monster	Super Points	1007,10,0,60000,"fabre_punch_main::OnKill_4"
 -	script	fabre_punch_main	-1,{
 	OnInit:
		.map$ = "pvp_n_1-2";
 		.npc_name$ = strnpcinfo(3);
		setmapflag .map$, mf_noskill;
		setmapflag .map$, mf_nodrop;
		setmapflag .map$, mf_nomobloot;
		setmapflag .map$, mf_nomvploot;
		setmapflag .map$, mf_nosave;
		setmapflag .map$, mf_noteleport;
		setmapflag .map$, mf_nowarpto;
		setmapflag .map$, mf_nobranch;
 		mapwarp .map$, "prontera",155,181;
		end;
 	OnViewRank:
		switch ( select( 
			"My Current Score",
			"Top List Puncher",
			"Nevermind"
		)) {
			case 1:
				query_sql( "SELECT `point` FROM `e_fabre_punch_rank` WHERE `cid` = "+getcharid(0)+" LIMIT 1",.@current_score );
				mes "My Current Score: " + .@current_score;
				break;
			case 2:
				query_sql( "SELECT `name`,`point` FROM `e_fabre_punch_rank` ORDER BY `point` DESC LIMIT 10",.@name$,.@point );
				.@size = getarraysize( .@name$ );
				mes "Ranking";
				for ( .@i = 0; .@i < .@size; .@i++ ) {
					mes .@name$[.@i] +" - "+.@point[.@i]+" Point";
				}
				break;
			default:
				break;
		}
		close;
 	OnTalk:
		.@cid = getcharid(0);
		.@is_gm = ( getgmlevel() > 0 );
 		switch ( select( 
			"Join Event",
			"Get Reward",
			( .@is_gm && !.status ) ? "[GM] Start Event" : "",
			( .@is_gm && .status == 1 ) ? "[GM] Stop Event" : "",
			"Nevermind"
		)) {
			case 1:
				getinventorylist;
				if ( @inventorylist_count > 0 ) {
					mes "Please remove all your inventory items.";
				}
				else if ( checkcart() ) {
					mes "Please remove your cart as well.";
				}
				else {
					switch ( .status ) {
						case 1:
						case 2:
							warp .map$,0,0;
							break;
						case 3:
							mes "Event ending, try again next time.";
							break;
						default: 
							mes "Event isn't running, try again next time.";
							break;
					}
				}
				break;
			case 2:
				query_sql( "SELECT `rank` FROM `e_fabre_punch_rank` WHERE `cid` = "+.@cid+" LIMIT 1",.@rank );
				switch ( .@rank ) {
					case 1: // top 1
						query_sql( "UPDATE `e_fabre_punch_rank` SET `rank` = 0 WHERE `cid` = "+.@cid+" LIMIT 1" );
						// rewards
						getitem 512,1;
						getitem 512,2;
						getitem 512,3;
						mes "You gained rewards";
						break;
					case 2: // top 2
						query_sql( "UPDATE `e_fabre_punch_rank` SET `rank` = 0 WHERE `cid` = "+.@cid+" LIMIT 1" );
						// rewards
						getitem 512,1;
						getitem 512,2;
						getitem 512,3;
						mes "You gained rewards";
						break;
					case 3: // top 3
						query_sql( "UPDATE `e_fabre_punch_rank` SET `rank` = 0 WHERE `cid` = "+.@cid+" LIMIT 1" );
						// rewards
						getitem 512,1;
						getitem 512,2;
						getitem 512,3;
						mes "You gained rewards";
						break;
					default:
						mes "No reward.";
						break;
				}
				break;
			case 3:
				mes "Event will be starting soon.";
				close2;
				donpcevent .npc_name$+"::OnStart";
				end;
			case 4:
				mes "Event will be ended soon.";
				close2;
				donpcevent .npc_name$+"::OnEnd";
				end;
			default:
				break;
		}
		close;
 	OnMinute30:
	OnStart:
		if ( !.status ) {
			.status = 1;
			query_sql( "TRUNCATE `e_fabre_punch_rank`" );
			for ( .@i = 1; .@i > 0 && .status == 1; .@i-- ) {
				announce "<Fabre Punch Event> Start in "+.@i+" minute(s).",bc_all;
				sleep 6000;
			}
			announce "<Fabre Punch Event> Started.",bc_all;
 			for ( .@i = 5; .@i > 0 && .status == 1; .@i-- ) {
				mapannounce .map$,"<Fabre Punch Event> Start in "+.@i+" second(s).",bc_all;
				sleep 1000;
			}
 			.point_rate = 1;
			if ( .status == 1 ) {
				.status = 2;
				for ( .@minute = 15; .@minute > 0; .@minute -= 5 ) {
					mapannounce .map$,"<Fabre Punch Event> Time Left "+.@minute+" Minute(s).",bc_all;
					if ( .@minute <= 5 ) {
						.point_rate = 3; // 3x point
					}
					else if ( .@minute <= 10 ) {
						.point_rate = 2;  // 2x point
					}
					sleep ( 5 * 6000 );
				}
				query_sql( "SELECT `cid`,`name`,`point` FROM `e_fabre_punch_rank` WHERE `point` > 0 ORDER BY `point` DESC LIMIT 3",.@cid,.@name$,.@point );
				.@size = getarraysize( .@cid );
				for ( .@i = 0; .@i < .@size; .@i++ ) {
					query_sql( "UPDATE `e_fabre_punch_rank` SET `rank` = "+( .@i + 1 )+" WHERE `cid` = "+.@cid[.@i]+" LIMIT 1" );
					mapannounce .map$,"<Fabre Punch Event> Winner "+( .@i + 1 )+" - '"+.@name$[.@i]+"' with "+.@point[.@i]+" Points.",bc_all;
				}
 				mapannounce .map$,"<Fabre Punch Event> Ended. Total "+.@size+" winners.",bc_all;
				.status = 0;
 				sleep 5000;
				mapwarp .map$, "prontera",155,181;
			}
		}
		end;
 	OnEnd:
		if ( .status == 2 )
			awake .npc_name$;
		end;
 	OnKill_1:
		callsub( L_Point,( .point_rate * 1 ) ); // Fabre = 1 Point
		end;
 	OnKill_2:
		callsub( L_Point,( .point_rate * 10 ) ); // Fabre = 10 Point
		end;
 	OnKill_3:
		callsub( L_Point,( .point_rate * -20 ) ); // Fabre = -20 Point
		end;
 	OnKill_4:
		callsub( L_Point, rand( 1,100 ), bc_map ); // Fabre = random 1~100 Point
		end;
 	L_Point:
		if ( .status == 2 ) {
			.@value = getarg( 0,0 );
			.@announce = getarg( 1,bc_self );
 			query_sql( "INSERT INTO `e_fabre_punch_rank` (`cid`, `name`, `point`) VALUES ( "+getcharid(0)+", '"+escape_sql( strcharinfo(0) )+"', "+.@value+" ) ON DUPLICATE KEY UPDATE `point` = `point` + "+.@value );
			dispbottom "<Fabre Punch Event> Gained " + .@value + " Point.";
			if ( .@announce )
				announce "Super Fabre has been killed by [ " + strcharinfo(0) + " ] for " + .@value + " Point(s) !",.@announce;
		}
		else if ( .status == 0 ) {
			dispbottom "Event not yet start, please wait.";
		}
		return;
}

Comments

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

    0 B

    |

    👍

    /

    👎