Report System Shows Name

Newbie Spellweaver
Joined
Jul 11, 2008
Messages
26
Reaction score
1
This is my way of doing, there are others. This may also seem a bit noob for the 'pro's but eh who cares :D.

This shows
'You reported Your Mum for Hacking'
instead of
'You reported id 21222 for Hacking'

In your Report Handler (net.odinms.sf.channel.handler.):
Find:
public class ReportHandler extends AbstractMaplePacketHandler {

Add After That:
private static String getCharInfoById(int id){
try {
Connection dcon = DatabaseConnection.getConnection();
PreparedStatement ps = dcon.prepareStatement("SELECT * FROM characters where id = ?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if(rs.next())
return rs.getString("name");

} catch(Exception ex) {}
return "error while trying to get name";

}

Replace
sb.append(reportedCharId);

With:
sb.append(getCharInfoById(reportedCharId));

Easy :P
---------------------------------------
Alternatively you could replace the whole thing:
Code:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


package net.sf.odinms.net.channel.handler;

import net.sf.odinms.client.MapleClient;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
import java.sql.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;


//import java.sql.PreparedStatement;
import net.sf.odinms.database.DatabaseConnection;
import net.sf.odinms.net.world.remote.WorldChannelInterface;
import net.sf.odinms.tools.MaplePacketCreator;


/**
 *
 * @author Administrator
 */
public class ReportHandler extends AbstractMaplePacketHandler {
     private static String getCharInfoById(int id){
                        try {
            Connection dcon = DatabaseConnection.getConnection();
            PreparedStatement ps = dcon.prepareStatement("SELECT * FROM characters where id = ?");
            ps.setInt(1, id);
            ResultSet rs = ps.executeQuery();
            if(rs.next())
            return rs.getString("name");
            
            } catch(Exception ex) {}
            return "error while trying to get name";
            
        }
    final static int GMGuildId = 198;
    final String[] reasons = {"Hacking", "Botting", "Scamming", "Fake GM", "Harassment", "Advertising"};
  //  final static String[] Sreason = {"Hacking", "Botting", "Scamming", "Fake GM", "Harassment", "Advertising"};
    	@Override
	public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c)  {
		int reportedCharId = slea.readInt();
                byte reason = slea.readByte();
                String chatlog = "No chatlog";
                short clogLen = slea.readShort();
                if(clogLen > 0)
                    chatlog = slea.readAsciiString(clogLen);
                Logger logger = LoggerFactory.getLogger(this.getClass());
                logger.info(
                        c.getPlayer().getName() + " reported charid " + reportedCharId
                        );
               boolean reported = addReportEntry(c.getPlayer().getId(), reportedCharId, reason, chatlog);
                int cid = reportedCharId;
                StringBuilder sb = new StringBuilder();
                sb.append(c.getPlayer().getName());
                sb.append(" reported character ");
                sb.append(getCharInfoById(cid));
                sb.append(" for ");
                sb.append(reasons[reason]);
                        sb.append(".");
                
                if(reported) c.getSession().write(MaplePacketCreator.reportReply((byte)0));
                else c.getSession().write(MaplePacketCreator.reportReply((byte)4));
                WorldChannelInterface wci = c.getChannelServer().getWorldInterface();
                try{wci.broadcastGMMessage(null, MaplePacketCreator.serverNotice(5 , sb.toString()).getBytes());} catch(Exception ex){}
                //if(GMGuild != null){
               //     GMGuild.broadcast(MaplePacketCreator.serverNotice(5, sb.toString()));
               //     GMGuild.
                    
              //  } else {
              //      c.getSession().write(MaplePacketCreator.serverNotice(5, "Failed to inform GMs. This may take a while to be processed"));
              //  }
                
                
	}
        
        public boolean addReportEntry(int reporterId, int victimId, byte reason, String chatlog) {
            try {
            Connection dcon = DatabaseConnection.getConnection();
           
            PreparedStatement ps;
            
            ps = dcon.prepareStatement("INSERT INTO reports VALUES (NULL, CURRENT_TIMESTAMP, ?, ?, ?, ?, 'UNHANDLED')");
            ps.setInt(1, reporterId);
            ps.setInt(2, victimId);
            ps.setInt(3, reason);
            ps.setString(4, chatlog);
            ps.executeUpdate();
            ps.close();
            } catch (Exception ex){
                //do ****
                return false;
            }
            return true;
            
        }

}
 
Last edited:
Re: [Release] Report System Shows Name

You mean add
Code:
private static String getCharInfoById(int id){
try {
Connection dcon = DatabaseConnection.getConnection();
PreparedStatement ps = dcon.prepareStatement("SELECT * FROM characters where id = ?");
ps.setInt(1, id);
ResultSet rs = ps.executeQuery();
if(rs.next())
return rs.getString("name");

} catch(Exception ex) {}
return "error while trying to get name";

}
under
Code:
public class ReportHandler extends AbstractMaplePacketHandler {
??
 
Re: [Release] Report System Shows Name

no not really, i knew how to do this 0.o its quite easy
 
Re: [Release] Report System Shows Name

1) use proper english, so you atleast sound intelligent
2) alot of ppl know how to do this 0.o
 
Re: [Release] Report System Shows Name

1) use proper english, so you atleast sound intelligent
2) alot of ppl know how to do this 0.o

i mean i expect most of us here know how to fix this already.
btw, does the proper usage of a certain language make a person sound more intelligent?
 
Back