Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //===== Table: ===============================================
- /*
- CREATE TABLE IF NOT EXISTS `event_woe_rank` (
- `id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
- `aid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
- `cid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
- `gid` INT(11) UNSIGNED NOT NULL DEFAULT '0',
- `char_name` VARCHAR(30) NOT NULL DEFAULT '',
- `guild_name` VARCHAR(30) NOT NULL DEFAULT '',
- `map` VARCHAR(30) NOT NULL DEFAULT '',
- `woe_type` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
- `status` TINYINT(3) UNSIGNED NOT NULL DEFAULT '1',
- `todate` INT(11) UNSIGNED NOT NULL DEFAULT '0',
- PRIMARY KEY (`id`)
- ) ENGINE=MyISAM;
- */
- //============================================================
- - script WoE_Kill_Counter FAKE_NPC,{
- OnInit:
- // Ranking Limit
- .Display_Limit = 10;
- // List of Castle
- setarray .woe_1$, "aldeg_cas", "gefg_cas", "payg_cas", "prtg_cas";
- setarray .woe_2$, "arug_cas", "schg_cas";
- for (.@i = 0; .@i < 2; .@i++) {
- .@size = getarraysize(getd(".woe_"+(.@i + 1)+"$"));
- if (.@size > 0) {
- for (.@x = 0; .@x < .@size; .@x++) {
- for (.@c = 1; .@c <= 5; .@c++)
- setd(".map_"+getd(".woe_"+(.@i+1)+"$["+.@x+"]")+"0"+.@c+"_agit", (.@i+1));
- }
- }
- }
- bindatcmd("woerank",strnpcinfo(NPC_NAME_UNIQUE)+"::OnAtCommand",0,99);
- OnHour00:
- .todate = atoi(gettimestr("%Y%m%d", 10));
- end;
- OnPCKillEvent:
- if (.woe_running) {
- .@aid = getcharid(3);
- .@cid = getcharid(0);
- .@killedrid = killedrid;
- .@map$ = strcharinfo(3);
- .@gid = getcharid(2);
- .@woe_type = getd(".map_"+.@map$+"_agit");
- if (.@killedrid != .@aid && .@gid > 0 && .@woe_type) {
- .@char_name$ = strcharinfo(0);
- .@guild_name$ = strcharinfo(2);
- .@sql$ = "INSERT INTO `event_woe_rank` (`aid`,`cid`,`gid`,`char_name`,`guild_name`,`map`,`woe_type`,`todate`) VALUES ("+.@aid+","+.@cid+","+.@gid+",'"+escape_sql(.@char_name$)+"','"+escape_sql(.@guild_name$)+"','"+escape_sql(.@map$)+"',"+.@woe_type+","+.todate+")";
- query_sql(.@sql$);
- }
- }
- end;
- OnAgitStart2:
- .@woe_type++;
- OnAgitStart:
- .@woe_type++;
- query_sql("UPDATE `event_woe_rank` SET `status` = 2 WHERE `status` = 1 AND `woe_type` = "+.@woe_type);
- OnAgitEnd:
- OnAgitEnd2:
- .woe_running = (agitcheck() || agitcheck2());
- end;
- OnAtCommand:
- .@todate = atoi(.@atcmd_parameters$[1]);
- .@aid = -1;
- .@cid = -1;
- .@gid = -1;
- if (compare(.@atcmd_parameters$[0], "me")) {
- .@type = 1;
- .@cid = getcharid(0);
- }
- else if (compare(.@atcmd_parameters$[0], "player")) {
- .@type = 1;
- }
- else if (compare(.@atcmd_parameters$[0], "guild")) {
- .@type = 2;
- } else {
- dispbottom "Usage: "+.@atcmd_command$+" <me|player|guild> <date>";
- dispbottom "Example: "+.@atcmd_command$+" me";
- dispbottom "Example: "+.@atcmd_command$+" player";
- dispbottom "Example: "+.@atcmd_command$+" player 20181109";
- dispbottom "Example: "+.@atcmd_command$+" guild";
- dispbottom "Example: "+.@atcmd_command$+" guild 20181109";
- end;
- }
- callsub(L_Rank, .@type, .@aid, .@cid, .@gid, .@woe_type, .@todate);
- end;
- L_Rank:
- .@type = getarg(0, 0);
- .@aid = getarg(1, 0);
- .@cid = getarg(2, 0);
- .@gid = getarg(3, 0);
- .@woe_type = getarg(4, 0);
- .@todate = getarg(5, 0);
- .@sql$ = "SELECT tbl.`char_name`,tbl.`guild_name`,COUNT(tbl.`id`) AS `kill` "
- + "FROM `event_woe_rank` tbl "
- + "WHERE ("
- + "`status` = 1"
- + " AND ("+.@aid+" = -1 OR ("+.@aid+" > 0 AND `aid` = "+.@aid+"))"
- + " AND ("+.@cid+" = -1 OR ("+.@cid+" > 0 AND `cid` = "+.@cid+"))"
- + " AND ("+.@gid+" = -1 OR ("+.@gid+" > 0 AND `gid` = "+.@gid+"))"
- + " AND ("+.@woe_type+" <= 0 OR ("+.@woe_type+" > 0 AND `woe_type` = "+.@woe_type+"))"
- + " AND ("+.@todate+" <= 0 OR ("+.@todate+" > 0 AND `todate` = "+.@todate+"))"
- + ") "
- + "GROUP BY "+(.@type == 2 ? "`gid`" : "`cid`")+" "
- + "ORDER BY `kill` DESC "
- + "LIMIT "+.Display_Limit;
- .@size = query_sql(.@sql$, .@name$, .@guild_name$, .@killcount);
- dispbottom sprintf("Top WoE %s Kills %s", .@type == 2 ? "Guild" : "Player", .@todate > 0 ? "(Date "+.@todate+")" : "" );
- dispbottom "----------------------------";
- if (.@size) {
- for (.@i = 0; .@i < .@size; .@i++) {
- dispbottom sprintf("%2d - %-24s - %5d", (.@i+1), (.@type == 2 ? .@guild_name$[.@i] : .@name$[.@i]), .@killcount[.@i]);
- }
- } else {
- dispbottom "No record found.";
- }
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement