Jump to content
  • 0

Question

Posted

heya dudes i try to Edit a legend system like that.

 

i made this smaller just added the last 2

private static final String UPDATE_CHARACTER = "UPDATE characters SET ,language=?,punishment_level=?,donator=?,enddate=? WHERE charId=?";

 

private static final String RESTORE_CHARACTER = "SELECT ,language,punishment_level,donator,enddate FROM characters WHERE charId=?";

 

 

private boolean _donator = false;

private long _PremiumEndDate;

 

public boolean isdonator()

{

return _donator;

}

 

public void setdonator(boolean donator)

{

_donator = donator;

}

 

public void setdonator(int donator)

{

return;

}

 

private long enddate()

{

return _PremiumEndDate;

}

 

public void setPremiumEndTime(long endDate)

{

_PremiumEndDate = endDate;

}

 

public long getPremiumEndTime()

{

      return _PremiumEndDate;

}

 

 

all ok

 

that in UPDATE_CHAR 

 

statement.setInt(54, isdonator() ? 1 : 0);

statement.setLong(55, enddate());

 

that in RESTORE_CHAR

 

restorePremServiceData(player,rset.getString("char_name"));

 

now the restorePremServiceData:

 

private static void PStimeOver(String char_name)

{

Connection con = null;

try

{

con = L2DatabaseFactory.getInstance().getConnection();

PreparedStatement statement = con.prepareStatement(UPDATE_CHARACTER);

statement.setInt(1, 0);

statement.setLong(2, 0);

statement.setString(3, char_name);

statement.execute();

statement.close();

}

catch (SQLException e)

{

_log.warning("PremiumService:  Could not increase data");

}

finally

{

L2DatabaseFactory.close(con);

}

}

 

public static void restorePremServiceData(L2PcInstance player, String char_name)

{

boolean sucess = false;

Connection con = null;

try

{

con = L2DatabaseFactory.getInstance().getConnection();

PreparedStatement statement = con.prepareStatement(RESTORE_CHARACTER);

statement.setString(1, char_name);

ResultSet rset = statement.executeQuery();

while (rset.next())

{

sucess = true;

if (Config.USE_LEGENDSERVICE)

{

if (rset.getLong("enddate") <= System.currentTimeMillis())

{

PStimeOver(char_name);

player.setdonator(0);

}

else

{

player.setdonator(rset.getInt("donator")==1);

player.setPremiumEndTime(rset.getLong("enddate"));

}

}

else

player.setdonator(0);

}

 

rset.close();

statement.close();

}

catch (Exception e)

{

_log.warning("PremiumService: Could not restore PremiumService data for:" + char_name + "." + e);

e.printStackTrace();

}

finally

{

L2DatabaseFactory.close(con);

}

 

if (!sucess)

{

player.setdonator(0);

}

}

 

at last the Admincommand:

 

private static final String[] ADMIN_COMMANDS =

{

"admin_premium_menu",

"admin_premium_add1",

"admin_premium_add2",

"admin_premium_add3",

"admin_premium_end"

};

 

private static final String UPDATE_CHARACTER = "UPDATE characters SET donator=?,enddate=? WHERE char_name=?";

private static final Logger _log = Logger.getLogger(AdminPremium.class.getName());

 

@Override

public boolean useAdminCommand(final String command, final L2PcInstance activeChar)

{

if (command.equals("admin_premium_menu"))

{

AdminHelpPage.showHelpPage(activeChar, "premium_menu.htm");

}

else if (command.startsWith("admin_premium_add1"))

{

try

{

final String val = command.substring(19);

addPremiumServices(1, val);

}

catch (final StringIndexOutOfBoundsException e)

{

activeChar.sendMessage("Err");

}

}

else if (command.startsWith("admin_premium_add2"))

{

try

{

final String val = command.substring(19);

addPremiumServices(2, val);

}

catch (final StringIndexOutOfBoundsException e)

{

activeChar.sendMessage("Err");

}

}

else if (command.startsWith("admin_premium_add3"))

{

try

{

final String val = command.substring(19);

addPremiumServices(3, val);

}

catch (final StringIndexOutOfBoundsException e)

{

activeChar.sendMessage("Err");

}

}

else if (command.startsWith("admin_premium_end"))

{

try

{

final String val = command.substring(19);

addPremiumServices(0, val);

}

catch (final StringIndexOutOfBoundsException e)

{

activeChar.sendMessage("Err");

}

}

 

return true;

}

 

private void addPremiumServices(final int Months, final String char_name)

{

Connection con = null;

try

{

final Calendar finishtime = Calendar.getInstance();

finishtime.setTimeInMillis(System.currentTimeMillis());

finishtime.set(Calendar.SECOND, 0);

finishtime.add(Calendar.MONTH, Months);

 

con = L2DatabaseFactory.getInstance().getConnection();

final PreparedStatement statement = con.prepareStatement(UPDATE_CHARACTER);

statement.setInt(1, 1);

statement.setLong(2, finishtime.getTimeInMillis());

statement.setString(3, char_name);

statement.execute();

statement.close();

}

catch (final SQLException e)

{

_log.info("PremiumService:  Could not increase data");

}

finally

{

L2DatabaseFactory.close(con);

}

}

 

all works ok just the problem is after relog char the donator and enddate is 0 every time if i add and they relog its 0 so what happened ?

 

Thanks for help

5 answers to this question

Recommended Posts

  • 0
Posted

i didnt read all of that, but you use database to save the premium state, so its good to know if you dont save or dont load that data, so set some1 premium and take a look at te database if the changes are done

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Thnx for share, i can't pm u for password  
    • I'm looking for the best current files that are up to date for the year 2025, not files that are stuck in 2020.
    • EXOPLANET 2.0     GRAND OPENING 09.05.2025 We are thrilled to announce the upcoming launch of a brand new server. This isn’t just a copy of the previous server – it’s the next step in the development of Exoplanet. Based on our past experience, we’re bringing you a server that is faster, more stable, and more fun than ever before.     GRAND OPENING:  09.05.2025 at 20:00 GMT+1 BETA TEST:   04.05.2025    Client: High Five Rates: x10   Website: https://l2exoplanet.net Facebook: https://www.facebook.com/L2-Exoplanet-106811564103836 Discord: https://discord.gg/4fzhW7ZSPc         Game Rates    Experience: x10  Skill Points: x10  Adena: x8  Drop: x8  Spoil: x8  Quest: x5  Raid Boss Drop: x5  Fame: x2  Epaulette: x8  Manor: x8      Safe Enchant: +3  Maximum Enchant: +16  Normal Scroll Chance: 60%  Blessed Scroll Chance: 63%  Attribute Stone Chance: 50%  Attribute Crystal Chance: 30%      Game Settings    Multibox - 3 game clients per HWID  Autoloot  Autolearn Skills Auto Farm  NPC Buffer   Buff Slots (24+4/12)  Buff Duration (2h)  Olympiad Period 7days (new heroes appear every monday)  Seven Signs Period  Class Transfer for Adena  Max Sub-Class 3  Sub-Class Max Level 85  Essence Interface  Champions System  Vote Reward System  Dayli Reward System  PC Points Reward (500PC = 1 Donate Coin)      Epic Bosses Respawn Times     Queen Ant:  24 Hours +/- 4 Hours   Beleth: 3 Days +/- 8 Hours   Baium: 3 Days +/- 8 Hours   Antharas: 4 Days +/- 8 Hours   Valakas:  5 Days +/- 8 Hours     Instance Info     Normal Freya = 6 Players   Hard Freya = 12 Players   Frintezza = 6 Players   Zaken 83 Day = 6 Players   Zaken 60 Day = 6 Players   Zaken Nightly = 9 Players   Tiat = 6 Players   Beleth = 12 Players
    • EXOPLANET 2.0     GRAND OPENING 09.05.2025 We are thrilled to announce the upcoming launch of a brand new server. This isn’t just a copy of the previous server – it’s the next step in the development of Exoplanet. Based on our past experience, we’re bringing you a server that is faster, more stable, and more fun than ever before.     GRAND OPENING:  09.05.2025 at 20:00 GMT+1 BETA TEST:   04.05.2025    Client: High Five Rates: x10   Website: https://l2exoplanet.net Facebook: https://www.facebook.com/L2-Exoplanet-106811564103836 Discord: https://discord.gg/4fzhW7ZSPc         Game Rates    Experience: x10  Skill Points: x10  Adena: x8  Drop: x8  Spoil: x8  Quest: x5  Raid Boss Drop: x5  Fame: x2  Epaulette: x8  Manor: x8      Safe Enchant: +3  Maximum Enchant: +16  Normal Scroll Chance: 60%  Blessed Scroll Chance: 63%  Attribute Stone Chance: 50%  Attribute Crystal Chance: 30%      Game Settings    Multibox - 3 game clients per HWID  Autoloot  Autolearn Skills Auto Farm  NPC Buffer   Buff Slots (24+4/12)  Buff Duration (2h)  Olympiad Period 7days (new heroes appear every monday)  Seven Signs Period  Class Transfer for Adena  Max Sub-Class 3  Sub-Class Max Level 85  Essence Interface  Champions System  Vote Reward System  Dayli Reward System  PC Points Reward (500PC = 1 Donate Coin)      Epic Bosses Respawn Times     Queen Ant:  24 Hours +/- 4 Hours   Beleth: 3 Days +/- 8 Hours   Baium: 3 Days +/- 8 Hours   Antharas: 4 Days +/- 8 Hours   Valakas:  5 Days +/- 8 Hours     Instance Info     Normal Freya = 6 Players   Hard Freya = 12 Players   Frintezza = 6 Players   Zaken 83 Day = 6 Players   Zaken 60 Day = 6 Players   Zaken Nightly = 9 Players   Tiat = 6 Players   Beleth = 12 Players      
  • Topics

×
×
  • Create New...