Newbie Spellweaver
- Joined
- Feb 23, 2012
- Messages
- 31
- Reaction score
- 18
I just coded this thing to challenge myself, as I am a new(er) coder. It might be of some use to somebody. I would also like feedback from the community. I realize that there might be some better ways to code this, but this is how I did it. If there is a better way, I would definitely like to hear it. No flaming please <3 My first release.
In MapleCharacter.java, add
and
and
and
In NPCConversationManager.java, add
In MySQL, execute this:
Here is a sample code for my Wild Hunter skill fixer:
You have to take out the cm.giveSkill() since you have to get your own giveSkill method.
Intended for TetraSEA/Lithium
If you don't know where to put them, just take some key words from my code and ctrl+f.
In MapleCharacter.java, add
Code:
private static int[] usedNpc = new int[] {0};
private boolean changed_usednpc;
Code:
public final boolean getUsedNpc(int npc) {
for (int i = 0; i < usedNpc.length; i++) {
if (usedNpc[i] == npc)
return true;
} return false;
}
public final void setUsedNpc(int npc) {
if (usedNpc[0] == 0) {
MapleCharacter.usedNpc[0] = npc;
this.changed_usednpc = true;
} else {
int[] rice = MapleCharacter.usedNpc;
usedNpc = new int[rice.length+1];
MapleCharacter.usedNpc[rice.length] = npc;
this.changed_usednpc = true;
}
}
Code:
ps = con.prepareStatement("SELECT npc FROM usednpc WHERE charid = ?");
ps.setInt(1, charid);
rs = ps.executeQuery();
int n = 0;
while (rs.next()) {
usedNpc[n] = rs.getInt("npc");
n++;
}
rs.close();
ps.close();
Code:
if (changed_usednpc) {
deleteWhereCharacterId(con, "DELETE FROM usednpc WHERE charid = ?");
ps = con.prepareStatement("INSERT INTO usednpc (charid, npc) VALUES (?, ?)");
ps.setInt(1, id);
for (int i = 0; i < usedNpc.length; i++) {
if (usedNpc[i] > 0) {
ps.setInt(2, usedNpc[i]);
ps.execute();
}
}
ps.close();
}
In NPCConversationManager.java, add
Code:
public void setUsedNpc(int npc) {
c.getPlayer().setUsedNpc(npc);
}
public boolean getUsedNpc(int npc) {
if (c.getPlayer().getUsedNpc(npc)) {
return true;
}
return false;
}
In MySQL, execute this:
Code:
ADD TABLE IF NOT EXISTS usednpc (charid int(11), npc int(11));
Here is a sample code for my Wild Hunter skill fixer:
Code:
var status;
var npc;
var successful = false;
function start() {
status = -1;
action(1,0,0);
}
function action(mode, type, selection) {
npc = 9900003;
successful = cm.getUsedNpc(npc);
if (mode != 1) {
cm.dispose();
return;
} else
status++;
if (status == 0) {
if (cm.getJob() != 3312) {
cm.sendOk("I am of no use to you.");
cm.dispose();
return;
} else
cm.sendYesNo("Would you like to fix your 4th job skills?\r\n#bOnly#k if their master level is 0.");
} else if (status == 1) {
if (successful)
cm.sendOk("You've already used this npc!");
else {
cm.giveSkill(33120000, 0, 10);
cm.giveSkill(33121001, 0, 10);
cm.giveSkill(33121009, 0, 10);
cm.sendOk("Your 4th job skills' master levels are now 10.");
cm.setUsedNpc(npc);
}
cm.dispose();
return;
}
}
Intended for TetraSEA/Lithium
If you don't know where to put them, just take some key words from my code and ctrl+f.
Last edited: