[Help] Script Java PVP Rank
Hey guys, I found some scripts here in ragezone for pvp rank, all is working fine, but the java script, that I think that update the character's name in database isn't functioning.
I can make a rank pvp with the player's ID, but i want to know if someone can tell me how to get the character's name using the ID's.
The script that i found is here:
PHP 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 = "suportegm";
String db_database = "pw";
%>
<%
//
// 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 rank 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 rank 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!");
}
%>
I hope someone can help me and thanks in advance!:thumbup1:
If you don't want to tell me what to do, just give me an idea how to do that...
Sorry for my bad english, I'm brazilian