Hello I put event monument in my acis however the player only wins the item if you have online if the player had ofline appears that mistake someone help me?
private static void addReward(int obj_id, boolean duple)
{
Player player = World.getInstance().getPlayer(obj_id);
if(player != null && player.isOnline())
{
InventoryUpdate iu = new InventoryUpdate();
final Item reward = ItemTable.getInstance().getTemplate(Config.EVENT_MONUMENT_STATUET_REWARD_ID);
player.getInventory().addItem("top", Config.EVENT_MONUMENT_STATUET_REWARD_ID, duple ? Config.EVENT_MONUMENT_STATUET_REWARD_AMOUNT * 2 : Config.EVENT_MONUMENT_STATUET_REWARD_AMOUNT,player, null);
player.sendMessage("Voce ganhou " + reward.getName() + ".");
player.getInventory().updateDatabase();
player.sendPacket(iu);
}
else
{
addOfflineItem(obj_id, Config.EVENT_MONUMENT_STATUET_REWARD_ID, duple ? Config.EVENT_MONUMENT_STATUET_REWARD_AMOUNT * 2 : Config.EVENT_MONUMENT_STATUET_REWARD_AMOUNT);
}
}
private static void addOfflineItem(int owner_id, int item_id, int count)
{
try(Connection con = L2DatabaseFactory.getInstance().getConnection())
{
PreparedStatement st = con.prepareStatement("SELECT count FROM items WHERE item_id = ? and owner_id = ?");
st.setInt(1,item_id);
st.setInt(2,owner_id);
ResultSet rs = st.executeQuery();
int total = 0;
while (rs.next())
{
total = rs.getInt("count");
}
st.close();
rs.close();
st = con.prepareStatement("SELECT MAX(object_id) as objid FROM items");
st.executeQuery();
rs = st.executeQuery();
int obj_id = 0;
while (rs.next())
{
obj_id = rs.getInt("objid") + 1000;
}
st.close();
rs.close();
if(total == 0)
{
st = con.prepareStatement("INSERT INTO items VALUES (?, ?, ?, ?, 0, 'INVENTORY', 0, 0, 0, NULL, 0, 0, -1)");
st.setLong(1,owner_id);
st.setLong(2,obj_id);
st.setInt(3,item_id);
st.setInt(4, count);
st.execute();
st.close();
}
else
{
st = con.prepareStatement("UPDATE items SET count = ? WHERE owner_id = ? and item_id = ? ");
st.setInt(1, total + count);
st.setLong(2, owner_id);
st.setLong(3, item_id);
st.execute();
st.close();
}
}
catch (SQLException e)
{
_log.severe("Could not update item char: " + e);
}
}
Alright, since we’re already disturbing the dead, let me toss my shovel in too. Thanks for the update, this place hasn’t seen activity since Maxtor discovered extracurricular festivals, so any sign of life is basically breaking news at this point.
Arena, x200, 1+1 and now “final stages”? sounds like someone’s actually pushing this thing forward instead of just daydreaming on Discord. Good. Maybe some oxygen will flow back into this fossil of a forum.
As for staff recruitment… yeah, filtering out the “english no good but i can be gm pls sir” crowd is probably the smartest move I’ve seen here in years. Might actually keep the circus level to a minimum.
Post the site when it’s ready. Some of us are still lurking like cursed background processes you can’t kill even with kill -9.
And don’t worry about the whole “messenger” thing, nobody here cares enough to start drama. You could post patch notes written in crayon and half the userbase still wouldn’t log in (only the true @Kara can do that).
Anyway, keep the updates coming. If this project actually launches, it might be the first resurrection this graveyard has ever witnessed.
Question
l2jkain
Hello I put event monument in my acis however the player only wins the item if you have online if the player had ofline appears that mistake someone help me?
private static void addReward(int obj_id, boolean duple) { Player player = World.getInstance().getPlayer(obj_id); if(player != null && player.isOnline()) { InventoryUpdate iu = new InventoryUpdate(); final Item reward = ItemTable.getInstance().getTemplate(Config.EVENT_MONUMENT_STATUET_REWARD_ID); player.getInventory().addItem("top", Config.EVENT_MONUMENT_STATUET_REWARD_ID, duple ? Config.EVENT_MONUMENT_STATUET_REWARD_AMOUNT * 2 : Config.EVENT_MONUMENT_STATUET_REWARD_AMOUNT,player, null); player.sendMessage("Voce ganhou " + reward.getName() + "."); player.getInventory().updateDatabase(); player.sendPacket(iu); } else { addOfflineItem(obj_id, Config.EVENT_MONUMENT_STATUET_REWARD_ID, duple ? Config.EVENT_MONUMENT_STATUET_REWARD_AMOUNT * 2 : Config.EVENT_MONUMENT_STATUET_REWARD_AMOUNT); } } private static void addOfflineItem(int owner_id, int item_id, int count) { try(Connection con = L2DatabaseFactory.getInstance().getConnection()) { PreparedStatement st = con.prepareStatement("SELECT count FROM items WHERE item_id = ? and owner_id = ?"); st.setInt(1,item_id); st.setInt(2,owner_id); ResultSet rs = st.executeQuery(); int total = 0; while (rs.next()) { total = rs.getInt("count"); } st.close(); rs.close(); st = con.prepareStatement("SELECT MAX(object_id) as objid FROM items"); st.executeQuery(); rs = st.executeQuery(); int obj_id = 0; while (rs.next()) { obj_id = rs.getInt("objid") + 1000; } st.close(); rs.close(); if(total == 0) { st = con.prepareStatement("INSERT INTO items VALUES (?, ?, ?, ?, 0, 'INVENTORY', 0, 0, 0, NULL, 0, 0, -1)"); st.setLong(1,owner_id); st.setLong(2,obj_id); st.setInt(3,item_id); st.setInt(4, count); st.execute(); st.close(); } else { st = con.prepareStatement("UPDATE items SET count = ? WHERE owner_id = ? and item_id = ? "); st.setInt(1, total + count); st.setLong(2, owner_id); st.setLong(3, item_id); st.execute(); st.close(); } } catch (SQLException e) { _log.severe("Could not update item char: " + e); } }7 answers to this question
Recommended Posts