Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

PvP Kill Count

Joined
Jan 6, 2010
Messages
744
Reaction score
1,051
I'm working on a new pwAdmin feature to count the pvp kills and death using the world2.log file

would be nice if someone who has a decent amount of pvp kills on his server can share this file (mine has only 1 pvp kill xD)

if you don't want to share this file (for security resons) it would be nice if you can post the lines containing the following pattern:

Code:
... 用户[COLOR="Blue"]48[/COLOR]被[COLOR="Blue"]33[/COLOR]杀死,类别([COLOR="Blue"]258[/COLOR]) ...

also the category number seems interesting, i've got 258 for a kill in the main world...
 
Last edited:
Black Magic Development
Loyal Member
Joined
Apr 29, 2010
Messages
2,170
Reaction score
600
I'm working on a new pwAdmin feature to count the pvp kills and death using the world2.log file

would be nice if someone who has a decent amount of pvp kills on his server can share this file (mine has only 1 pvp kill xD)

if you don't want to share this file (for security resons) it would be nice if you can post the lines containing the following pattern:

Code:
... 用户[COLOR="Blue"]48[/COLOR]被[COLOR="Blue"]33[/COLOR]杀死,类别([COLOR="Blue"]258[/COLOR]) ...

also the category number seems interesting, i've got 258 for a kill in the main world...

Code:
[COLOR="Blue"]48[/COLOR] killed by [COLOR="Blue"]33[/COLOR] users, category ([COLOR="Blue"]258[/COLOR]) ...

So Im assuming that is userid, number of deaths, odd category id?
 
Nerd-IO
Loyal Member
Joined
Feb 13, 2009
Messages
3,303
Reaction score
651
'formatlog' file for more detail on PK/kill and so on... rbb138 already made a script for that on the forum. :mellow:
 
[B]aSH
Loyal Member
Joined
Apr 2, 2009
Messages
1,138
Reaction score
371
I do this:

Shell file to get the Logs.
Code:
cd /server/logs/
grep -e ':type=2:' world2.formatlog >> kills.formatlog
chmod 777 kills.formatlog
sed -i 's/ /,/g' kills.formatlog
sed -i 's/=/,/g' kills.formatlog
sed -i 's/:/,/g' kills.formatlog
sed -i 's/,,,/,/g' kills.formatlog
sed -i 's/,,/,/g' kills.formatlog
mysqlimport -u root --local --force --columns=date,hour,minute,@x,@x,@x,@x,@x,@x,@x,corpseid,@x,@x,@x,killerid --fields-terminated-by=, dbo kills.formatlog
rm kills.formatlog

Php Script will Update a different table named pkrank
PHP:
<body bgcolor="#161616">
<font color=white>
<?
$username="root";
$password="";
$database="dbo";

mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT killerid, corpseid, hour, date, COUNT(killerid) AS ckills FROM kills GROUP BY killerid, corpseid, hour, date HAVING ( COUNT(killerid) > 0 )";
$result=mysql_query($query);

$num=mysql_num_rows($result);

$i=0;
while ($i < $num) {
$PlayerName=mysql_result($result,$i,"killerid");
$One = 1;

$SearchifexistQuery = Mysql_Query("SELECT * FROM pkrank WHERE userid = '$PlayerName'");
$SearchifexistNum = Mysql_Num_Rows($SearchifexistQuery);
IF ($SearchifexistNum == 1 OR $SearchifexistNum > 1) {
	$SearchifexistFetch = Mysql_Fetch_Array($SearchifexistQuery);
	$CharacterKills = $SearchifexistFetch['kills'];
	$NewCharacterKills = $CharacterKills + $One;
	Mysql_Query("UPDATE pkrank SET kills = '$NewCharacterKills' WHERE userid = '$PlayerName'");
}
ELSE {
	Mysql_Query("INSERT INTO pkrank (userid, name, class, level, kills) VALUES ('$PlayerName', 'Needs Updating', 'Needs Updating', '1', '$One')");
}
$i++;
}
echo "Successfully Updated Tables!<br>";
Mysql_Query("DELETE FROM kills");
Mysql_Query("UPDATE administration SET status = NOW() WHERE type = 'PKUPDATE'");
?>

Next script will call java servlet
PHP:
<?
$DBHost = "127.0.0.1"; // localhost or your IP
$DBUser = "root"; // Database user
$DBPassword = ""; // Database password
$DBName = "dbo"; // Database name

// Connect to server and select databse.
$Link = MySQL_Connect($DBHost, $DBUser, $DBPassword) or die ("Can't connect to MySQL");
MySQL_Select_Db($DBName, $Link) or die ("Database ".$DBName." do not exists.");

$handle = fopen("http://localhost:8180/iweb/pkrank.jsp", "r");
	while($line = fgets($handle))
	{
		echo($line);
	}
fclose($handle);
?>

This is the java servlet, this servlet updates the userids, level and class of the top 50 characters.
Code:
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.lang.*"%>
<%@page import="java.util.*"%>
<%@page import="java.text.*"%>
<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
<%@page import="protocol.*"%>
<%@page import="com.goldhuman.auth.*"%>
<%@page import="com.goldhuman.util.*"%>
<%@page import="org.apache.commons.logging.Log"%>
<%@page import="org.apache.commons.logging.LogFactory"%>
<%@page import="java.sql.*"%>

<%
	String db_host = "localhost";
	String db_port = "3306";
	String db_user = "root";
	String db_password = "";
	String db_database = "dbo";
%>

<%
	//
	// Coded by [B]aSH from Vendetta Gaming Network.
	// 

int count = 0;
String cls = null;

try {
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	Connection connection = DriverManager.getConnection("jdbc:mysql://" + db_host + ":" + db_port + "/" + db_database, db_user, db_password);
	Statement statement = connection.createStatement();
	ResultSet rst = statement.executeQuery("SELECT * FROM pkrank ORDER BY kills DESC LIMIT 50");
	RoleBean role = null;
	String tempplayername = null;
	int index = 0;
	while (rst.next())
		{	
			//Prepare Statement
			PreparedStatement UpdateInfo = connection.prepareStatement("UPDATE pkrank SET name=?, class=?, level=? WHERE userid=?");
			int roleid = rst.getInt("userid");
			role = GameDB.get( roleid );
			session.setAttribute( "gamedb_rolebean", role );
			if (null == role){
			}
			else {
				tempplayername = null;
				tempplayername = StringEscapeUtils.escapeHtml(role.base.name.getString());
			
				index = 0;
				index = tempplayername.indexOf("'");
				StringBuffer playername = new StringBuffer(tempplayername);
				if(index > 0){
					playername.replace(index, index + 1, "?");
				}						
			}
			switch(role.base.cls)
			{
				case 0:	cls = "Warrior"; break;
				case 1:	cls = "Mage"; break;
				case 2:	cls = "Monk"; break;
				case 3:	cls = "WereFox"; break;
				case 4:	cls = "WereBeast"; break;
				case 5:	cls = "Genie"; break;
				case 6:	cls = "Archer"; break;
				case 7:	cls = "Priest"; break;
				default:	cls = "Unknown";
			}
			UpdateInfo.setString(1, tempplayername);
			UpdateInfo.setString(2, cls);
			UpdateInfo.setInt(3, role.status.level);
			UpdateInfo.setInt(4, roleid);
			UpdateInfo.executeUpdate();

			count++;
		}
}
catch (Exception e)
{
	out.println("<font color=red>Error Occured But System Added <b>" + count + "</b> Characters.");
}	
%>

<%
if (count > 0) {
out.println("<font color=green><br>Complete Updated: <b>" + count + "</b> Characters.<br><br>");
}
else
{
out.println("<br><font color=red>No Characters available to add!");
}
%>

Here are the create SQL statements for the 2 Tables I use
Code:
CREATE TABLE  `dbo`.`kills` (
  `date` varchar(255) NOT NULL,
  `hour` varchar(255) NOT NULL,
  `minute` varchar(255) NOT NULL,
  `corpseid` varchar(255) NOT NULL,
  `killerid` varchar(255) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

CREATE TABLE  `dbo`.`pkrank` (
  `userid` int(10) unsigned NOT NULL,
  `name` varchar(255) NOT NULL,
  `class` varchar(45) NOT NULL,
  `level` varchar(45) NOT NULL,
  `kills` int(10) unsigned NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

Hope this helps anyone and Ronny of course.
 
Joined
Jan 6, 2010
Messages
744
Reaction score
1,051
'formatlog' file for more detail on PK/kill and so on... rbb138 already made a script for that on the forum. :mellow:

aw nice, this file is smaller than world2.log and utf8 that will increase the parsing speed...

grep -e ':type=2:' world2.formatlog

this is the part which i want to verify, can it be confirmed that only type=2** are player kills?
 
[B]aSH
Loyal Member
Joined
Apr 2, 2009
Messages
1,138
Reaction score
371
aw nice, this file is smaller than world2.log and utf8 that will increase the parsing speed...



this is the part which i want to verify, can it be confirmed that only type=2** are player kills?

Yep it does verify mate.
 
Robb
Loyal Member
Joined
Jan 22, 2009
Messages
1,224
Reaction score
466
this is the part which i want to verify, can it be confirmed that only type=2** are player kills?

type = 256 means the person got red name
and type = 2432894639284 (or similar) means death by guard (or possibly monster).

ensuring type = 2 means peple cant farm newbs, as i explained in my thread on ranking scripts ages ago.

also bash, credit where due pls...
"this is the script i use" = "this is the shell script robb gave me"

As a pvp server these ranks are very important for community (which is declining) so im not estatic to give them out but i always give help to those willing to work for it.

You can either use ash's jsp method to directy import lines into mysql or run a wget on the webpage and import that into database in 1 go via scheduled shell script.
 
Last edited:
Newbie Spellweaver
Joined
Apr 8, 2009
Messages
8
Reaction score
12
It seems Chaos13 (or another) said: data "pvp kills" are recorded in the xml character
 
Newbie Spellweaver
Joined
Apr 15, 2011
Messages
19
Reaction score
0
when I of this command
mysqlimport-u root - local - force -
columns = date, hour, minute, @ x, @ x, @ x, @ x, @ x, @ x, @ x, corpseid, @ x, @ x, @ x, killerid - fields-terminated-by =,
dbo kills.formatlog
error of more or less well
root @ localhost password: No
What can it be?
 
Newbie Spellweaver
Joined
Feb 5, 2011
Messages
54
Reaction score
0
grep-e ': type = 2:' world2.formatlog

Finds no result what to do?
 
Banned
Banned
Joined
Apr 13, 2011
Messages
125
Reaction score
28
The PHP script bash did is wrong no offense bro.

i took the liberty to edit it and make it better and more accurate here is the result:

.php
PHP:
<body bgcolor="#161616">
<font color=white>
<?
			$DBHost = "local-host"; // ip
			$DBUser = "my-username";  	     //user
			$DBPassword = "my-pass";  	//pass
			$DBName = "dbo";		//database

			$Link = MySQL_Connect($DBHost, $DBUser, $DBPassword) or die ("Can't connect to MySQL");
			MySQL_Select_Db($DBName, $Link) or die ("Database ".$DBName." do not exists.");

$query="SELECT killerid, COUNT(killerid) AS ckills FROM kills GROUP BY killerid HAVING ( COUNT(killerid) > 0 )";
$result=mysql_query($query);

$querydeaths="SELECT corpseid, COUNT(corpseid) AS cdeaths FROM kills GROUP BY corpseid HAVING ( COUNT(corpseid) > 0 )";
$resultdeaths=mysql_query($querydeaths);

$num=mysql_num_rows($result);

$i=0;
while ($i < $num) {
// get killer-id
$PlayerName=mysql_result($result,$i,"killerid");
//get kills result
$ckills=mysql_result($result,$i,"ckills");
//get deaths result
$cdeaths=mysql_result($resultdeaths,$i,"cdeaths");


$SearchifexistQuery = Mysql_Query("SELECT kills,deaths FROM pkrank WHERE userid = '$PlayerName'");
$SearchifexistNum = Mysql_Num_Rows($SearchifexistQuery);
IF ($SearchifexistNum == 1 OR $SearchifexistNum > 1) {
    $SearchifexistFetch = Mysql_Fetch_Array($SearchifexistQuery);
    $CharacterKills = $SearchifexistFetch['kills'];
    $Characterdeaths = $SearchifexistFetch['deaths'];
    $NewCharacterKills = $CharacterKills + $ckills;
    $NewCharacterdeaths = $Characterdeaths + $cdeaths;
    Mysql_Query("UPDATE pkrank SET kills = '$NewCharacterKills' WHERE userid = '$PlayerName'");
    Mysql_Query("UPDATE pkrank SET deaths = '$NewCharacterdeaths' WHERE userid = '$PlayerName'");
}
ELSE {
    Mysql_Query("INSERT INTO pkrank (userid, name, clasa, level, kills, reputation, deaths, gender) VALUES ('$PlayerName', 'Upcoming...', 'Upcoming...', '1', '1' , '1', '1', 'Upcoming...')");
}
$i++;
}
echo "Successfully Updated Tables!<br>";
//delete table
Mysql_Query("DELETE FROM kills");
//close connection
mysql_close($Link);

?>
.jsp
PHP:
<%@page import="java.sql.*"%>
<%@page import="protocol.*"%>
<%@page import="java.io.*"%>
<%@page import="java.text.*"%>
<%@page import="org.apache.commons.logging.LogFactory"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.goldhuman.Common.Octets"%>
<%@page import="com.goldhuman.IO.Protocol.Rpc.Data.DataVector"%>
<%@page import="org.apache.commons.lang.StringEscapeUtils"%>
<%@ page language="java" import="java.sql.*" errorPage="" %>

<%
	Connection connection = null;
	Class.forName("com.mysql.jdbc.Driver").newInstance();
	connection = DriverManager.getConnection("jdbc:mysql://localhost/dbo","root", "password");
	ResultSet rst = null;
	RoleBean role = null;
	String tempplayername = null;
	int count = 0;
	int level = 0;
	int rep = 0;
	String cls = null;
	String gender = null;
	PreparedStatement UpdateInfo = null;



try {

	Statement statement = connection.createStatement();
	rst = statement.executeQuery("SELECT userid FROM pkrank ORDER BY kills DESC");
	
	int index = 0;
	while (rst.next())
		{	
			//Prepare Statement
			UpdateInfo = connection.prepareStatement("UPDATE pkrank SET name=?, clasa=?, level=?, reputation=?, gender=? WHERE userid=?");
			int roleid = rst.getInt("userid");
			role = GameDB.get( roleid );

			
			if (null == role)
			{



			}
			else 
			{

			try{
				tempplayername = null;
				tempplayername = StringEscapeUtils.escapeHtml(role.base.name.getString());
			
				index = 0;
				index = tempplayername.indexOf("'");
				StringBuffer playername = new StringBuffer(tempplayername);
				if(index > 0)
				{
					playername.replace(index, index + 1, "?");
				}

			switch(role.base.cls)
			{
				case 0:	cls = "Warrior"; break;
				case 1:	cls = "Mage"; break;
				case 2:	cls = "Monk"; break;
				case 3:	cls = "WereFox"; break;
				case 4:	cls = "WereBeast"; break;
				case 5:	cls = "Genie"; break;
				case 6:	cls = "Archer"; break;
				case 7:	cls = "Priest"; break;
				default:	cls = "Unknown";
			}
			
				level = role.status.level;
				rep = role.status.reputation;

			
			gender = (role.base.gender == 0) ? "Male" : "Female";	

         
    }
    catch (Exception e)
    {
        continue;
    }



					
			}




			UpdateInfo.setString(1, tempplayername);
			UpdateInfo.setString(2, cls);
			UpdateInfo.setInt(3, level);
			UpdateInfo.setInt(4, rep);
			UpdateInfo.setString(5, gender);
			UpdateInfo.setInt(6, roleid);
			UpdateInfo.executeUpdate();
			count++;
			
		}
}
catch (Exception e)
{
	out.println("<font color=red>Error Occured But System Added <b>" + count + "</b> Characters.<br>");
	out.println(e);



}	



if (count > 0) {
out.println("<font color=green><br>Complete Updated: <b>" + count + "</b> Characters.<br><br>");
}
else
{
out.println("<br><font color=red>No Characters available to add!");

}
try{
         if(connection!=null){
             connection.close();
         }
         if(rst!=null){
             rst.close();
         }
         
         if(UpdateInfo!=null){
          UpdateInfo.close();
         }
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
%>

tables;
CREATE TABLE IF NOT EXISTS `kills` (
`date` varchar(255) NOT NULL,
`hour` varchar(255) NOT NULL,
`minute` varchar(255) NOT NULL,
`corpseid` int(22) NOT NULL,
`killerid` int(22) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;


CREATE TABLE IF NOT EXISTS `pkrank` (
`userid` int(10) unsigned NOT NULL,
`name` varchar(255) NOT NULL,
`clasa` varchar(45) NOT NULL,
`level` int(11) NOT NULL,
`kills` int(22) unsigned NOT NULL,
`reputation` bigint(11) NOT NULL,
`deaths` int(10) unsigned NOT NULL,
`gender` varchar(255) NOT NULL,
UNIQUE KEY `userid` (`userid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

enjoy:eek:tt1:
 
Last edited:
Robb
Loyal Member
Joined
Jan 22, 2009
Messages
1,224
Reaction score
466
Funny, people that DDOS my server are now using my work on theirs.

The php scripts might be changed but the basic principle and idea is still the same idea i had one year ago lol.

If you really go into it, you can create things like this:
ronny1982 - PvP Kill Count - RaGEZONE Forums
 
Last edited:
Back
Top