Switcho Posted December 23, 2018 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 7 Reputation: 0 Joined: 12/07/11 Last Seen: June 22, 2019 Share Posted December 23, 2018 Hi , I use this pvp ranking : //===== rAthena Script ======================================= //= PvP log //===== By: ================================================== //= Vietlubu //===== Description: ========================================= //= Simple SQL PvP log //= Notes: //= - Create table `pvplog` when start script. //= - Add new record when has OnPCKillEvent //= - Remove NCP PvP Ranking if you don't want to use. //===== Compatible With: ===================================== //= rAthena Project //===== Changelogs: ========================================== //= 1.0 First version. //============================================================ prontera,155,181,5 script PvP Ranking 430,{ .@limitRanking = 3; .@limitEnemies = 3; mes "[PvP Ranking]"; //menu "Ranking of month", L_RankMonth, "Ranking of week", L_RankWeek, "Ranking of day", L_RankDay; select "Ranking of month", "Ranking of week", "Ranking of day", "My enemies"; if (@menu < 4) { // Ranking switch(@menu) { case 1: .@ranking$ = "MONTH"; .@message$ = "Ranking of month"; break; case 2: .@ranking$ = "WEEK"; .@message$ = "Ranking of week"; break; case 3: .@ranking$ = "DAY"; .@message$ = "Ranking of day"; break; } query_sql("SELECT `char`.`name`, COUNT(`char`.`name`) AS count_kill FROM `pvplog` INNER JOIN `char` ON `char`.`char_id` = `pvplog`.`killer_id` WHERE " + .@ranking$ + "(`pvplog`.`pvp_date`) = " + .@ranking$ + "(CURRENT_DATE()) GROUP BY `char`.`name` ORDER BY count_kill DESC LIMIT " + .@limitRanking, .@name$, .@count_kill); mes .@message$; for( @i = 0; @i < getarraysize(.@name$); @i++ ) { mes "Top " + (@i+1) + ": ^2ecc71" + .@name$[@i] + "^000000 kills times: ^e74c3c" + .@count_kill[@i] + "^000000"; } } else if (@menu == 4) { query_sql("SELECT `char`.`name`, COUNT(`char`.`name`) AS count_kill FROM `pvplog` INNER JOIN `char` ON `char`.`char_id` = `pvplog`.`killer_id` WHERE `pvplog`.`victim_id` = " + getcharid(0) + " GROUP BY `char`.`name` ORDER BY count_kill DESC LIMIT " + .@limitEnemies, .@name$, .@count_kill); mes "Top your enemies:"; for( @i = 0; @i < getarraysize(.@name$); @i++ ) { mes "Top 1: ^e74c3c" + .@name$[0] + "^000000 kill you ^2ecc71" + .@count_kill[0] + "^000000 times" + "^000000"; } } close; L_RankMonth: mes "Ranking of month"; close; L_RankWeek: mes "Ranking of week"; close; L_RankDay: mes "Ranking of day"; close; end; } - script pvplog -1,{ OnInit: query_sql("CREATE TABLE IF NOT EXISTS `pvplog` (`pvp_id` mediumint(9) unsigned NOT NULL auto_increment, `pvp_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `killer_id` int(11) NOT NULL default '0', `victim_id` int(11) NOT NULL default '0', `map` varchar(11) NOT NULL default '', PRIMARY KEY (`pvp_id`)) ENGINE=MyISAM AUTO_INCREMENT=1;"); end; OnPCKillEvent: query_sql("INSERT INTO `pvplog` (`killer_id`, `victim_id`, `map`) VALUES ('" + getcharid(0) + "', (SELECT `char_id` FROM `char` WHERE `name` = '" + rid2name(killedrid) + "'), '" + strcharinfo(3) + "');"); end; } The script works perfectly , but he show only the kill. : I want to add the number of death like this : Top 1 : Test1 Nombre de kills/Deaths : 19/14 Top 2 : Test2 Nombres de kills/Deaths :14/19 but I do not know how to do it Thx Quote Link to comment Share on other sites More sharing options...
0 n0tttt Posted December 23, 2018 Group: Members Topic Count: 4 Topics Per Day: 0.00 Content Count: 303 Reputation: 118 Joined: 12/10/16 Last Seen: April 5 Share Posted December 23, 2018 Don't know if works. //===== rAthena Script ======================================= //= PvP log //===== By: ================================================== //= Vietlubu //===== Description: ========================================= //= Simple SQL PvP log //= Notes: //= - Create table `pvplog` when start script. //= - Add new record when has OnPCKillEvent //= - Remove NCP PvP Ranking if you don't want to use. //===== Compatible With: ===================================== //= rAthena Project //===== Changelogs: ========================================== //= 1.0 First version. //============================================================ prontera,155,181,5 script PvP Ranking 430,{ .@limitRanking = 3; .@limitEnemies = 3; mes "[PvP Ranking]"; //menu "Ranking of month", L_RankMonth, "Ranking of week", L_RankWeek, "Ranking of day", L_RankDay; select "Ranking of month", "Ranking of week", "Ranking of day", "My enemies"; if (@menu < 4) { // Ranking switch(@menu) { case 1: .@ranking$ = "MONTH"; .@message$ = "Ranking of month"; break; case 2: .@ranking$ = "WEEK"; .@message$ = "Ranking of week"; break; case 3: .@ranking$ = "DAY"; .@message$ = "Ranking of day"; break; } query_sql("SELECT `char`.`id``char`.`name`, COUNT(`char`.`name`) AS count_kill FROM `pvplog` INNER JOIN `char` ON `char`.`char_id` = `pvplog`.`killer_id` WHERE " + .@ranking$ + "(`pvplog`.`pvp_date`) = " + .@ranking$ + "(CURRENT_DATE()) GROUP BY `char`.`name` ORDER BY count_kill DESC LIMIT " + .@limitRanking, .@id, .@name$, .@count_kill); mes .@message$; for( .@size = getarraysize(.@name$); .@i < .@size; .@i++ ) { query_sql("SELECT COUNT(`pvplog`.`victim_id`) FROM `pvplog` WHERE `pvplog`.`victim_id` = '"+.@id[.@i]+" AND " + .@ranking$ + "(`pvplog`.`pvp_date`) = " + .@ranking$ + "(CURRENT_DATE())", .@count_death); mes "Top " + (.@i+1) + ": ^2ecc71" + .@name$[.@i] + "^000000 kills times: ^e74c3c" + .@count_kill[.@i]/"+.@count_death+" + "^000000"; } } else if (@menu == 4) { query_sql("SELECT `char`.`name`, COUNT(`char`.`name`) AS count_kill FROM `pvplog` INNER JOIN `char` ON `char`.`char_id` = `pvplog`.`killer_id` WHERE `pvplog`.`victim_id` = " + getcharid(0) + " GROUP BY `char`.`name` ORDER BY count_kill DESC LIMIT " + .@limitEnemies, .@name$, .@count_kill); mes "Top your enemies:"; for( .@size = getarraysize(.@name$); .@i < .@size; .@i++ ) { mes "Top "+(.@i+1)+": ^e74c3c" + .@name$[.@i] + "^000000 kill you ^2ecc71" + .@count_kill[.@i] + "^000000 times" + "^000000"; } } close; L_RankMonth: mes "Ranking of month"; close; L_RankWeek: mes "Ranking of week"; close; L_RankDay: mes "Ranking of day"; close; end; } - script pvplog -1,{ OnInit: query_sql("CREATE TABLE IF NOT EXISTS `pvplog` (`pvp_id` mediumint(9) unsigned NOT NULL auto_increment, `pvp_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `killer_id` int(11) NOT NULL default '0', `victim_id` int(11) NOT NULL default '0', `map` varchar(11) NOT NULL default '', PRIMARY KEY (`pvp_id`)) ENGINE=MyISAM AUTO_INCREMENT=1;"); end; OnPCKillEvent: query_sql("INSERT INTO `pvplog` (`killer_id`, `victim_id`, `map`) VALUES ('" + getcharid(0) + "', (SELECT `char_id` FROM `char` WHERE `name` = '" + rid2name(killedrid) + "'), '" + strcharinfo(3) + "');"); end; } Quote Link to comment Share on other sites More sharing options...
0 Switcho Posted December 23, 2018 Group: Members Topic Count: 3 Topics Per Day: 0.00 Content Count: 7 Reputation: 0 Joined: 12/07/11 Last Seen: June 22, 2019 Author Share Posted December 23, 2018 Thx for the reply but he doesn't work Quote Link to comment Share on other sites More sharing options...
0 AnnieRuru Posted January 5, 2019 Group: Members Topic Count: 18 Topics Per Day: 0.00 Content Count: 2044 Reputation: 682 Joined: 10/09/12 Last Seen: December 20, 2020 Share Posted January 5, 2019 (edited) wow ... this kind of table logs every single kills I wonder will this kind of table can cause lag to the server ? because `the killer_id` field is not indexed" perhaps index that field just to be safe explain pvplog; alter table pvplog add key killer_id (killer_id); and here's the script for it, @Switcho //===== rAthena Script ======================================= //= PvP log //===== By: ================================================== //= Vietlubu //===== Description: ========================================= //= Simple SQL PvP log //= Notes: //= - Create table `pvplog` when start script. //= - Add new record when has OnPCKillEvent //= - Remove NCP PvP Ranking if you don't want to use. //===== Compatible With: ===================================== //= rAthena Project //===== Changelogs: ========================================== //= 1.0 First version. //============================================================ prontera,155,181,5 script PvP Ranking 430,{ .@limitRanking = 3; .@limitEnemies = 3; mes "[PvP Ranking]"; //menu "Ranking of month", L_RankMonth, "Ranking of week", L_RankWeek, "Ranking of day", L_RankDay; select "Ranking of month", "Ranking of week", "Ranking of day", "My enemies"; if (@menu < 4) { // Ranking switch(@menu) { case 1: .@ranking$ = "MONTH"; .@message$ = "Ranking of month"; break; case 2: .@ranking$ = "WEEK"; .@message$ = "Ranking of week"; break; case 3: .@ranking$ = "DAY"; .@message$ = "Ranking of day"; break; } query_sql("SELECT `pvplog`.`killer_id` AS CID, `char`.`name`, COUNT(`pvplog`.`killer_id`) AS count_kill, (SELECT COUNT(`pvplog`.`victim_id`) from pvplog where victim_id = CID) FROM `pvplog` INNER JOIN `char` ON `char`.`char_id` = `pvplog`.`killer_id` WHERE " + .@ranking$ + "(`pvplog`.`pvp_date`) = " + .@ranking$ + "(CURRENT_DATE()) GROUP BY `char`.`name` ORDER BY count_kill DESC LIMIT " + .@limitRanking, .@cid, .@name$, .@count_kill, .@count_death); mes .@message$; for( @i = 0; @i < getarraysize(.@name$); @i++ ) { mes "Top " + (@i+1) + ": ^2ecc71" + .@name$[@i] + "^000000 kill/death: ^e74c3c" + .@count_kill[@i] + "/"+ .@count_death[@i] + "^000000"; } } else if (@menu == 4) { query_sql("SELECT `char`.`name`, COUNT(`char`.`name`) AS count_kill FROM `pvplog` INNER JOIN `char` ON `char`.`char_id` = `pvplog`.`killer_id` WHERE `pvplog`.`victim_id` = " + getcharid(0) + " GROUP BY `char`.`name` ORDER BY count_kill DESC LIMIT " + .@limitEnemies, .@name$, .@count_kill); mes "Top your enemies:"; for( @i = 0; @i < getarraysize(.@name$); @i++ ) { mes "Top 1: ^e74c3c" + .@name$[0] + "^000000 kill you ^2ecc71" + .@count_kill[0] + "^000000 times" + "^000000"; } } close; L_RankMonth: mes "Ranking of month"; close; L_RankWeek: mes "Ranking of week"; close; L_RankDay: mes "Ranking of day"; close; end; } - script pvplog -1,{ OnInit: query_sql("CREATE TABLE IF NOT EXISTS `pvplog` (`pvp_id` mediumint(9) unsigned NOT NULL auto_increment, `pvp_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `killer_id` int(11) NOT NULL default '0', `victim_id` int(11) NOT NULL default '0', `map` varchar(11) NOT NULL default '', PRIMARY KEY (`pvp_id`)) ENGINE=MyISAM AUTO_INCREMENT=1;"); end; OnPCKillEvent: query_sql("INSERT INTO `pvplog` (`killer_id`, `victim_id`, `map`) VALUES ('" + getcharid(0) + "', (SELECT `char_id` FROM `char` WHERE `name` = '" + rid2name(killedrid) + "'), '" + strcharinfo(3) + "');"); end; } Edited January 5, 2019 by AnnieRuru Quote Link to comment Share on other sites More sharing options...
Question
Switcho
Hi ,
I use this pvp ranking :
//===== rAthena Script ======================================= //= PvP log //===== By: ================================================== //= Vietlubu //===== Description: ========================================= //= Simple SQL PvP log //= Notes: //= - Create table `pvplog` when start script. //= - Add new record when has OnPCKillEvent //= - Remove NCP PvP Ranking if you don't want to use. //===== Compatible With: ===================================== //= rAthena Project //===== Changelogs: ========================================== //= 1.0 First version. //============================================================ prontera,155,181,5 script PvP Ranking 430,{ .@limitRanking = 3; .@limitEnemies = 3; mes "[PvP Ranking]"; //menu "Ranking of month", L_RankMonth, "Ranking of week", L_RankWeek, "Ranking of day", L_RankDay; select "Ranking of month", "Ranking of week", "Ranking of day", "My enemies"; if (@menu < 4) { // Ranking switch(@menu) { case 1: .@ranking$ = "MONTH"; .@message$ = "Ranking of month"; break; case 2: .@ranking$ = "WEEK"; .@message$ = "Ranking of week"; break; case 3: .@ranking$ = "DAY"; .@message$ = "Ranking of day"; break; } query_sql("SELECT `char`.`name`, COUNT(`char`.`name`) AS count_kill FROM `pvplog` INNER JOIN `char` ON `char`.`char_id` = `pvplog`.`killer_id` WHERE " + .@ranking$ + "(`pvplog`.`pvp_date`) = " + .@ranking$ + "(CURRENT_DATE()) GROUP BY `char`.`name` ORDER BY count_kill DESC LIMIT " + .@limitRanking, .@name$, .@count_kill); mes .@message$; for( @i = 0; @i < getarraysize(.@name$); @i++ ) { mes "Top " + (@i+1) + ": ^2ecc71" + .@name$[@i] + "^000000 kills times: ^e74c3c" + .@count_kill[@i] + "^000000"; } } else if (@menu == 4) { query_sql("SELECT `char`.`name`, COUNT(`char`.`name`) AS count_kill FROM `pvplog` INNER JOIN `char` ON `char`.`char_id` = `pvplog`.`killer_id` WHERE `pvplog`.`victim_id` = " + getcharid(0) + " GROUP BY `char`.`name` ORDER BY count_kill DESC LIMIT " + .@limitEnemies, .@name$, .@count_kill); mes "Top your enemies:"; for( @i = 0; @i < getarraysize(.@name$); @i++ ) { mes "Top 1: ^e74c3c" + .@name$[0] + "^000000 kill you ^2ecc71" + .@count_kill[0] + "^000000 times" + "^000000"; } } close; L_RankMonth: mes "Ranking of month"; close; L_RankWeek: mes "Ranking of week"; close; L_RankDay: mes "Ranking of day"; close; end; } - script pvplog -1,{ OnInit: query_sql("CREATE TABLE IF NOT EXISTS `pvplog` (`pvp_id` mediumint(9) unsigned NOT NULL auto_increment, `pvp_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, `killer_id` int(11) NOT NULL default '0', `victim_id` int(11) NOT NULL default '0', `map` varchar(11) NOT NULL default '', PRIMARY KEY (`pvp_id`)) ENGINE=MyISAM AUTO_INCREMENT=1;"); end; OnPCKillEvent: query_sql("INSERT INTO `pvplog` (`killer_id`, `victim_id`, `map`) VALUES ('" + getcharid(0) + "', (SELECT `char_id` FROM `char` WHERE `name` = '" + rid2name(killedrid) + "'), '" + strcharinfo(3) + "');"); end; }
The script works perfectly , but he show only the kill. :
I want to add the number of death like this :
Top 1 : Test1 Nombre de kills/Deaths : 19/14
Top 2 : Test2 Nombres de kills/Deaths :14/19
but I do not know how to do it
Thx
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.