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

    • I am selling my l2jeternity high five (all inclusive option $300) license+daily $50(mission) mod, autofarm, this is a very good and stable H5 assembly on market if you know how to run it properly, project developer LordWinter also a very passionate person and active in daily basis, because I am no longer using it, selling this out to put in good use for new h5 l2project. I am selling this for $180, pm me for details/offer. thanks *Sale and rebinding with the consent of the developer LordWinter payment option : paypal/crypto telegram: @arcadin77  
    • Hello friends, good morning, good afternoon or good evening, depending on the time you are seeing this! I have been trying to decompile and compile again with only the classes that I want LineageEffect.u for a few days now, but I have not been successful. Could someone help me by clearing up some doubts about how I can do this work and be successful?!
    • **INTERLUDE REMASTERED** Moonland is a server that's been running for about three years without wipe, and they don't plan on wiping it anytime soon. I'm selling my items or even the account due to not having much time to play anymore. I'm selling only for $$$. Not going to disclose my nickname in the server, but here are some of the items: Lvl 5 equipment for both mage and fighter +100 mage pvp set 2mastery jewels for fighter, 2 for mage, blessed antharas, blessed queen ant, ring of fallen angel, earring of fafurion. 1k + col, VIP cosmetics for armor, agathion and weapons(duals + mage wep)   I'm only selling for real money via paypal or cs2 skins so don't offer me anything else.
    • ➡ Discount for your purchase: MAY2025 (10% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
  • Topics

×
×
  • Create New...