- Joined
- Jul 12, 2011
- Messages
- 1,229
- Reaction score
- 475
deleted content
Last edited:
Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature currently requires accessing the site using the built-in Safari browser.
I have the following piece of code in a NPC:
But for some reason, this isn't updating the number of GP, it's just setting the amount of points.PHP:cm.getGuild().gainGP((cm.getGuild().getGP()) + 5);
Is there any way to fix this?
If I do this, then it will set the 'gp' value in the guilds table to whatever number I set it to (in this case, +5). What that piece of code should be doing is getting the current amount of GP, and then adding 5 to that.
So if I had 3 points before I clicked the npc, I would have 8 after clicking it. But at the moment, I have 5 after clicking the npc.
I believe it's MapleBlade based.
Here are my methods in MapleCharacter.java (also found setGP, which doesn't seem to work either...):
PHP:public void setGP(int amount) { gp = gp + amount; Connection con = DatabaseConnection.getConnection(); PreparedStatement ps = null; try { ps = con.prepareStatement("UPDATE guilds SET `GP` = ? WHERE guildid = ?"); ps.setInt(1, gp); ps.setInt(2, guildid); ps.executeUpdate(); } catch (SQLException e) { } finally { try { if (ps != null && !ps.isClosed()) { ps.close(); } } catch (SQLException e) { } } } public int getGP() { return gp; } public void gainGP(int amount) { this.gp += amount; }
public void gainGP(int amount) {
this.gp += amount;
this.writeToDB(false);
this.guildMessage(MaplePacketCreator.updateGP(this.id, this.gp));
}
public void writeToDB(boolean bDisband) {
try {
Connection con = DatabaseConnection.getConnection();
if (!bDisband) {
StringBuilder builder = new StringBuilder();
builder.append("UPDATE guilds SET GP = ?, logo = ?, logoColor = ?, logoBG = ?, logoBGColor = ?, ");
for (int i = 0; i < 5; i++) {
builder.append("rank").append(i + 1).append("title = ?, ");
}
builder.append("capacity = ?, notice = ? WHERE guildid = ?");
try (PreparedStatement ps = con.prepareStatement(builder.toString())) {
ps.setInt(1, gp);
ps.setInt(2, logo);
ps.setInt(3, logoColor);
ps.setInt(4, logoBG);
ps.setInt(5, logoBGColor);
for (int i = 6; i < 11; i++) {
ps.setString(i, rankTitles[i - 6]);
}
ps.setInt(11, capacity);
ps.setString(12, notice);
ps.setInt(13, this.id);
ps.execute();
}
} else {
PreparedStatement ps = con.prepareStatement("UPDATE characters SET guildid = 0, guildrank = 5 WHERE guildid = ?");
ps.setInt(1, this.id);
ps.execute();
ps.close();
ps = con.prepareStatement("DELETE FROM guilds WHERE guildid = ?");
ps.setInt(1, this.id);
ps.execute();
ps.close();
this.broadcast(MaplePacketCreator.guildDisband(this.id));
}
} catch (SQLException se) {
}
}
Just by itself? o-o