• Unfortunately, we have experienced significant hard drive damage that requires urgent maintenance and rebuilding. The forum will be a state of read only until we install our new drives and rebuild all the configurations needed. Please follow our Facebook page for updates, we will be back up shortly! (The forum could go offline at any given time due to the nature of the failed drives whilst awaiting the upgrades.) When you see an Incapsula error, you know we are in the process of migration.

[Add-On] Deleting characters without PIC.

Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
Since you can't delete characters without PIC, and PIC is plainly annoying, I quickly made this NPC. Yes, It can be done a lot better but this didn't take long.

NPC Code:
Code:
/*
 * Made by Sparrow of RaGEZONE
 * Purpose: Deletes characters without PIC.
 * Map: Free Market (910000000)
 * NPC Name:
 */

var status = 0;
var selectedchar;
var text = "Are you sure you wish to delete #b#e";
var text2 = "#n#k?\r\n#L8#Yes#l\r\n#L7#No#l";

function start() {
status = -1;
action(1, 0, 0);
}

function action(mode, type, selection) {
if (mode == -1) {
cm.dispose();
}
else if(mode == 0){
cm.dispose();
}
else {
if (mode == 1)
status++;
else
status--;

if (status == 0) {
    cm.sendSimple("Hello " + cm.getPlayer() + ", click on a character to delete it.#b" + cm.getC().loadCharacterList(cm.getC().getWorld()) + "\r\n\r\n#L6#Information#l#k");

    } else if (selection == 1) {
          selectedchar = cm.getPlayer().Character1;
            cm.sendSimple(text + cm.getPlayer().getNameById(selectedchar) + text2);

           } else if (selection == 2) {
             selectedchar = cm.getPlayer().Character2;
             cm.sendSimple(text + cm.getPlayer().getNameById(selectedchar) + text2);

          } else if (selection == 3) {
             selectedchar = cm.getPlayer().Character3;
             cm.sendSimple(text + cm.getPlayer().getNameById(selectedchar) + text2);

          } else if (selection == 4) {
             selectedchar = cm.getPlayer().Character4;
             cm.sendSimple(text + cm.getPlayer().getNameById(selectedchar) + text2);

         } else if (selection == 5) {
             selectedchar = cm.getPlayer().Character5;
             cm.sendSimple(text + cm.getPlayer().getNameById(selectedchar) + text2);

         } else if (selection == 6) {
             cm.sendOk("#eInformation#n\r\nThe purpose of this NPC is to delete your characters, since the only way you can delete your characters is with PIC Enabled.\r\n\r\n#eNotice#n\r\nWhen you select the option to delete your character, there will be a confirmation notice asking you if you are sure.\r\n\r\n#eWarning#n\r\nOnce you delete your character it is gone #r#eforever#n#k. We are not responsible for your use of this NPC.");
             cm.dispose();
       }  else if (selection == 7) {
           cm.sendOk("Okay, come back if you wish to delete your character.");
           cm.dispose();
    }

           else if (selection == 8) {
           if (cm.getPlayer().getGuildIdById(selectedchar) > 0 || cm.getPlayer().getId() == selectedchar) {
               cm.sendOk("You are either on the same character you wish to delete or they are in a guild.");
               cm.dispose();
          } else {
               cm.sendOk("Character #b" + cm.getPlayer().getNameById(selectedchar) + "#k has been deleted!");
               cm.getC().deleteCharacter(selectedchar);
               cm.dispose();
           }
       }
   }
}

MapleClient:
loadCharacterList
public String loadCharacterList(int serverId) throws SQLException {
StringBuilder chars = new StringBuilder();
int c = 1;
try {
for (CharNameAndId cni : loadCharactersInternal(serverId)) {
chars.append("\r\n#L" + c + "#" + c + ". " + MapleCharacter.loadCharFromDB(cni.id, this, false) + "#l");
if (c == 1) {
player.Character1 = (cni.id);
}
else if (c == 2) {
player.Character2 = (cni.id);
}
else if (c == 3) {
player.Character3 = (cni.id);
}
if (c == 4) {
player.Character4 = (cni.id);
}
else if (c == 5) {
player.Character5 = (cni.id);
}
c++;
}
} catch (Exception e) {
}
return chars.toString();
}[/QUOTE]
deleteCharacter
public void deleteCharacter(int cid) {
Connection con = DatabaseConnection.getConnection();
try {
PreparedStatement ps = con.prepareStatement("SELECT id, guildid, guildrank, name, allianceRank FROM characters WHERE id = ? AND accountid = ?");
ps.setInt(1, cid);
ps.setInt(2, accId);
ResultSet rs = ps.executeQuery();
if (!rs.next()) {
rs.close();
ps.close();
// return false;
}
if (rs.getInt("guildid") > 0) {
try {
LoginServer.getInstance().getWorldInterface().deleteGuildCharacter(new MapleGuildCharacter(cid, 0, rs.getString("name"), -1, 0, rs.getInt("guildrank"), rs.getInt("guildid"), false, rs.getInt("allianceRank")));
} catch (RemoteException re) {
rs.close();
ps.close();
// return false;
}
}
rs.close();
ps = con.prepareStatement("DELETE FROM wishlists WHERE charid = ?");
ps.setInt(1, cid);
ps.executeUpdate();
ps = con.prepareStatement("DELETE FROM characters WHERE id = ?");
ps.setInt(1, cid);
ps.executeUpdate();
String[] toDel = {"famelog", "inventoryitems", "keymap", "queststatus", "savedlocations", "skillmacros", "skills", "eventstats"};
for (String s : toDel) {
ps = con.prepareStatement("DELETE FROM `" + s + "` WHERE characterid = ?");
ps.setInt(1, cid);
ps.executeUpdate();
}
getChannelServer().removePlayer(player);
// return true;

} catch (SQLException e) {
e.printStackTrace();
// return false;
}
}


MapleCharacter
Ints
//Delete Characters
public int Character1;
public int Character2;
public int Character3;
public int Character4;
public int Character5;
//End Delete Characters
getGuildIdById
public static int getGuildIdById(int victimid) {
try {
PreparedStatement ps = DatabaseConnection.getConnection().prepareStatement("SELECT guildid FROM characters WHERE id = ?");
ps.setInt(1, victimid);
ResultSet rs = ps.executeQuery();
if (!rs.next()) {
rs.close();
ps.close();
return 0;
}
int guildid = rs.getInt("guildid");
rs.close();
ps.close();
return guildid;
} catch (Exception e) {
}
return 0;
}
Screenies:
Sparrow - [Add-On] Deleting characters without PIC. - RaGEZONE Forums

Sparrow - [Add-On] Deleting characters without PIC. - RaGEZONE Forums

Sparrow - [Add-On] Deleting characters without PIC. - RaGEZONE Forums

Sparrow - [Add-On] Deleting characters without PIC. - RaGEZONE Forums

Sparrow - [Add-On] Deleting characters without PIC. - RaGEZONE Forums
 
Custom Title Activated
Loyal Member
Joined
Jun 30, 2008
Messages
3,451
Reaction score
1,616
If the iPhone web could like posts, I would definitely have clicked it. Nice idea, never really thought of it. Too bad im addicted to gms like
 
Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
If the iPhone web could like posts, I would definitely have clicked it. Nice idea, never really thought of it. Too bad im addicted to gms like

Thanks Kev. xD
 
Custom Title Activated
Loyal Member
Joined
Aug 21, 2009
Messages
1,149
Reaction score
598
I did not read the whole thing, but it's done really un-code wisely, glad you admit it.

I like PIC, but yeah, most people does hate it... and if that's the case, a simple static PIC and sent could solve this dilemma.
 
Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
I did not read the whole thing, but it's done really un-code wisely, glad you admit it.

I like PIC, but yeah, most people does hate it... and if that's the case, a simple static PIC and sent could solve this dilemma.

Eh maybe someone can improve, I just released to share my idea really.
 
Joined
Jul 2, 2008
Messages
469
Reaction score
42
Code:
//Delete Characters
public int Character1;
public int Character2;
public int Character3;
public int Character4;
public int Character5;
//End Delete Characters
Code:
//Delete Characters
public int Character1, Character2, Character3, Character4, Character5;
//End Delete Characters
 
Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
Code:
//Delete Characters
public int Character1;
public int Character2;
public int Character3;
public int Character4;
public int Character5;
//End Delete Characters
Code:
//Delete Characters
public int Character1, Character2, Character3, Character4, Character5;
//End Delete Characters

Hm, I didn't think that would work for this purpose, thanks <3
 
Custom Title Activated
Loyal Member
Joined
Jun 30, 2008
Messages
3,451
Reaction score
1,616
public int[] characters; lol?


---------- Post added at 12:11 PM ---------- Previous post was at 12:09 PM ----------

Then ofcourse = new int[5];
 
Newbie Spellweaver
Joined
Nov 13, 2009
Messages
21
Reaction score
4
public int[] characters; lol?


---------- Post added at 12:11 PM ---------- Previous post was at 12:09 PM ----------

Then ofcourse = new int[5];
Code:
List<Integer> characters = new ArrayList<Integer>();
Array?:eek:tt1:
 
Last edited:
Experienced Elementalist
Joined
Mar 26, 2010
Messages
250
Reaction score
62
The point of PIC is so that even if you leak your user/pass, some stuff is still safe. Just remove the PIC all together if your going to do this.
 
bleh....
Loyal Member
Joined
Oct 15, 2008
Messages
2,898
Reaction score
1,129
The point of PIC is so that even if you leak your user/pass, some stuff is still safe. Just remove the PIC all together if your going to do this.

iirc a PIC is still required, even if you remove the system, to delete characters. I think the client forces it. Not sure though.

Anyways, to make it more safe, you should add a password requirement, just in case some idiot steals another persons account. Like... when they create a character, have them create a password specifically for this, so it's like a string PIC for if/when they decide to delete their char. It could also be used for other things if needed.
 
Custom Title Activated
Loyal Member
Joined
Aug 21, 2009
Messages
1,149
Reaction score
598
Eh maybe someone can improve, I just released to share my idea really.

Okay...

You just need to edit the method in DeleteCharHandler.java and set it to public static.

PHP:
public static byte deleteCharacter(int cid, int world) {

then...

PHP:
importPackage(Packages.net.login.handler);

status = -1;
var selectedCharacter;

function start() {
    var text = "Hello #h #, click on a character to delete it.#b\r\n" 
	for (var i = 0; i < cm.getClient().loadCharacterNames(cm.getClient().getWorld()).size(); text+= cm.getClient().loadCharacterNames(cm.getClient().getWorld()).get(i).equals(cm.getPlayer().getName()) ? "" : "\r\n#L" + i + "#" + cm.getClient().loadCharacterNames(cm.getClient().getWorld()).get(i) + ".", i++); 
	cm.sendSimple(text + "\r\n\r\n#e#L6#Information#k.");
}

function action(mode, type, selection) {
    status++;
    if (mode != 1) {
	    if (mode == 0 && type == 1)
		    cm.sendNext("Okay, come back if you wish to delete your character.");
        cm.dispose();
		return;
    }
    if (status == 0) {
		if (selection == 6) {
		    cm.sendNext("#eInformation#n\r\nThe purpose of this NPC is to delete your characters, since the only way you can delete your characters is with PIC Enabled.\r\n\r\n#eNotice#n\r\nWhen you select the option to delete your character, there will be a confirmation notice asking you if you are sure.\r\n\r\n#eWarning#n\r\nOnce you delete your character it is gone #r#eforever#n#k. We are not responsible for your use of this NPC.");
			cm.dispose();
		} else {
		    selectedCharacter = cm.getClient().loadCharacters(cm.getClient().getWorld()).get(selection);
            cm.sendYesNo( "Are you sure you wants to delete #r" + selectedCharacter.getName() + "#k?");
		}
    } else if (status == 1) {
		DeleteCharHandler.deleteCharacter(selectedCharacter.getId(), cm.getClient().getWorld());
		cm.sendOk("Character #b" + selectedCharacter.getName() + "#k has been deleted!");
        cm.dispose();
    }
}

And no need for all those need variables and what else you added.
 
Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
Okay...
You just need to edit the method in DeleteCharHandler.java and set it to public static.

PHP:
public static byte deleteCharacter(int cid, int world) {

then...

PHP:
importPackage(Packages.net.login.handler);

status = -1;
var selectedCharacter;

function start() {
    var text = "Hello #h #, click on a character to delete it.#b\r\n" 
	for (var i = 0; i < cm.getClient().loadCharacterNames(cm.getClient().getWorld()).size(); text+= cm.getClient().loadCharacterNames(cm.getClient().getWorld()).get(i).equals(cm.getPlayer().getName()) ? "" : "\r\n#L" + i + "#" + cm.getClient().loadCharacterNames(cm.getClient().getWorld()).get(i) + ".", i++); 
	cm.sendSimple(text + "\r\n\r\n#e#L6#Information#k.");
}

function action(mode, type, selection) {
    status++;
    if (mode != 1) {
	    if (mode == 0 && type == 1)
		    cm.sendNext("Okay, come back if you wish to delete your character.");
        cm.dispose();
		return;
    }
    if (status == 0) {
		if (selection == 6) {
		    cm.sendNext("#eInformation#n\r\nThe purpose of this NPC is to delete your characters, since the only way you can delete your characters is with PIC Enabled.\r\n\r\n#eNotice#n\r\nWhen you select the option to delete your character, there will be a confirmation notice asking you if you are sure.\r\n\r\n#eWarning#n\r\nOnce you delete your character it is gone #r#eforever#n#k. We are not responsible for your use of this NPC.");
			cm.dispose();
		} else {
		    selectedCharacter = cm.getClient().loadCharacters(cm.getClient().getWorld()).get(selection);
            cm.sendYesNo( "Are you sure you wants to delete #r" + selectedCharacter.getName() + "#k?");
		}
    } else if (status == 1) {
		DeleteCharHandler.deleteCharacter(selectedCharacter.getId(), cm.getClient().getWorld());
		cm.sendOk("Character #b" + selectedCharacter.getName() + "#k has been deleted!");
        cm.dispose();
    }
}

And no need for all those need variables and what else you added.

Thanks, nice work.
Edit: Yours doesn't provide a Guild/On the same character check because if your in a guild it won't let you delete it anyway. (And if your on the same character it messes up your console)

iirc a PIC is still required, even if you remove the system, to delete characters. I think the client forces it. Not sure though.

Anyways, to make it more safe, you should add a password requirement, just in case some idiot steals another persons account. Like... when they create a character, have them create a password specifically for this, so it's like a string PIC for if/when they decide to delete their char. It could also be used for other things if needed.

I'll be sure to do that, thanks Shawn.
 
Last edited:
Custom Title Activated
Loyal Member
Joined
Aug 21, 2009
Messages
1,149
Reaction score
598
Thanks, nice work.
Edit: Yours doesn't provide a Guild/On the same character check because if your in a guild it won't let you delete it anyway. (And if your on the same character it messes up your console)



I'll be sure to do that, thanks Shawn.

Mine doesn't check for the same character, because it doesn't add the same character into the character list.

In the same way, you can delete users with guilds, the delete method does remove it all. If he is the master, it will delete the whole guild, if not, will just remove that player from it. That's about it.
 
Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
Mine doesn't check for the same character, because it doesn't add the same character into the character list.

In the same way, you can delete users with guilds, the delete method does remove it all. If he is the master, it will delete the whole guild, if not, will just remove that player from it. That's about it.

Oh okay. Sweet, thanks.
 
Back
Top