[Release] Pin System

D

Deleted member 471572

Guest
I am releasing my Pin System FULLY working v.55 for you guys.
Take from this one and how it's functioning and work on it from there.

Be Sure first of all to add this to your SQL.

Code:
ALTER TABLE `accounts` ADD COLUMN `pin` int(4) NOT NULL default '0';
NOTE: This runs off akakori's Account Gender / Selection fix.

HUGE Credit to akakori, he's helped me with this through the beggining, and unfortunately right before he left, we didn't get a chance to fix up the bugs, so I've taken the script looked over it and re-scripted some areas like the boolean which was the biggest issue.

I've left all credits to him in the patch file.

This script is Modified by me. And it should work 100% no error, previously it used to give 66 errors now its none.
Also as I've told Kori I didn't bother using this on my server, since this was his and he left, I felt like I was using it ie *leeched* so instead of making him work it out, I've done it myself. Also it wasn't compatible with the current SVN, now it is.

It is also now compatible with the newest revision 988.

I won't provide any help (I know that's a dick move), but, it's all straight forward, if you're getting errors you don't know how to patch and/or follow instructions.

Okay, with that being said let's get started.

In MapleClient.java

Find:

PHP:
private int status = 0;
Add below it:

PHP:
private String pin;
Find:

PHP:
private boolean autoCreate = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.morethanone", "false"));
Add below it:

PHP:
private boolean  pinActivate = Boolean.parseBoolean(props.getProperty("net.sf.odinms.world.pinactivate", "false"));
Find:

PHP:
.prepareStatement("SELECT id,password,salt,tempban,banned,gm,macs,greason,gender FROM accounts WHERE name = ?");
Replace it with:

PHP:
.prepareStatement("SELECT id,password,salt,tempban,banned,gm,macs,greason,gender,pin FROM accounts WHERE name = ?");
Find:

PHP:
tempban = getTempBanCalendar(rs);
Add bellow it:

PHP:
                                gender = rs.getInt("gender");
                                if (gender != 0 || gender != 1) {
                                    setStatus(1);
                                }
                                else {
                                    if (rs.getString("pin") == null) {
                                        setStatus(2);
                                    }
                                    else 
                                       pin = rs.getString("pin");
                                }
Find:

PHP:
        public void setStatus(int status) {
            this.status = status;
        }
Add bellow it:

PHP:
        public int getPin() {
            return Integer.parseInt(this.pin);
        }
        
        public void setPin(int pin) {
            this.pin = String.valueOf(pin);
        }
Now open notepad and make a new Java file. Name it RegisterPinHandler.java.
Add all of this in it.

PHP:
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.sf.odinms.net.login.handler;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import net.sf.odinms.client.MapleClient;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;
import net.sf.odinms.database.DatabaseConnection;
import net.sf.odinms.tools.MaplePacketCreator;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
 *
 * @author akakori
 */
public class RegisterPinHandler extends AbstractMaplePacketHandler {
    private static final Logger log = LoggerFactory.getLogger(MapleClient.class);
    @Override
        public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
            if(c.status() != 2)
                //hacking
                return;
            if (slea.readByte() == 0x00) {
                if (c.getPin() == -1) {
                    c.setStatus(2);
            }
                int pin = Integer.parseInt(slea.readMapleAsciiString());
                Connection con = DatabaseConnection.getConnection();
        PreparedStatement ps;
                try {
                    ps = con.prepareStatement("update accounts set pin = ? where id = ?");
                    ps.setInt(1, pin);
                    ps.setInt(2, c.getAccID());
                    ps.executeUpdate();
                    ps.close();
                    //c.setStatus(2);
        } catch (SQLException e) {
            log.error("ERROR", e);
        }
                c.getSession().write(MaplePacketCreator.getPinAssgined());
            }
        }
}
Put it in your net.sf.odinms.net.login.handler folder.

In your PacketProcessor.java

Find:

PHP:
import net.sf.odinms.net.channel.handler.ReportHandler;
Add this bellow it:

PHP:
import net.sf.odinms.net.login.handler.RegisterPinHandler;
import net.sf.odinms.net.login.handler.SetGenderHandler;
Find:

PHP:
registerHandler(RecvPacketOpcode.SET_GENDER, new SetGenderHandler());
Add this bellow it:

PHP:
registerHandler(RecvPacketOpcode.REGISTER_PIN, new RegisterPinHandler());
Now open your SendPacketOpcode.java.

Find:

PHP:
GENDER_SET,
Add bellow:

PHP:
PIN_ASSIGNED,
Now in your RecvPacketOpcode.java.

Find:

PHP:
SET_GENDER,
Add bellow it:

PHP:
REGISTER_PIN,
Now open MaplePacketCreator.java.

Find:

PHP:
/**
      * Gets a successful authentication and PIN Request packet.
Add ABOVE It with a space in between the both add:

PHP:
        public static MaplePacket getPinAssgined() {
            MaplePacketLittleEndianWriter mplew = new MaplePacketLittleEndianWriter();
            mplew.writeShort(SendPacketOpcode.PIN_ASSIGNED.getValue());
            mplew.write(0);
            return mplew.getPacket();
        }
Now open AfterLoginHandler.java.

Find:

PHP:
// Official requests the pin here - but pins suck so we just accept
Add bellow it:

PHP:
                    if(c.getPinActivate())
                    c.getSession().write(MaplePacketCreator.requestPin());
                    else
Find:

PHP:
if (pin.equals("1234")) {
Replace it with:

PHP:
if (Integer.parseInt(pin) == c.getPin()) {
Now open up your SetGenderHandler.java Which you created for Kori's Gender Selection.

Find:

PHP:
@author Compaq_Owner
Replace it with:

PHP:
@author akakori

Now open recvops.properties.

Find:

PHP:
SET_GENDER = CHAR_SELECT 1
Add bellow it:

PHP:
REGISTER_PIN = 0x05
Open up sendops.properties.

Find:

PHP:
GENDER_SET = PIN_OPERATION 1
Add bellow:

PHP:
PIN_ASSIGNED = 0x11
Lastly. Go to your world.properties.

Find:

PHP:
net.sf.odinms.channel.events=lolcastle,3rdjob,ZakumPQ,KerningPQ
Add bellow it:

PHP:
# activate log with pins
net.sf.odinms.world.pinactivate = false
# activate in-game account creation
Well I've attached a TXT Version of it. The .patch file can be found here:



.txt File is attached.
 

Attachments

Last edited by a moderator:
Very nice. :). Great to see this new release right after I format my computer :D.
 
Nice release ~

I made the file pin.sql (sql file) and im about to execute to odinms..
first .. what do i do with the .txt u provided? sorry im newbie S:
 
Nothing, this auto registers a pin. Checks function to looped pin.
If none, assigns one.
 
PIN's sucks =( They're just disturbing.. Who wants to hack a private server account anyway?

Good job and nice release though, can't say anything else about that =)
 
PIN's sucks =( They're just disturbing.. Who wants to hack a private server account anyway?

Good job and nice release though, can't say anything else about that =)

o.O

 
Back