Jump to content
  • 0

[Rquest]Instances


Archagnel

Question

Hello im doing one custom thing now but Im wondering how to create Instance for each player with stats that will be hold until shutdown/restart. For example im calling function DoSomething() in doDie from L2PcInstance in which I want to read or create if not exist Instance for each player(killer) with few statics for example I want hold there pvp stats, if something happens im raising it or reseting.

Im thinking to do something similar like they have done in l2jFrozen:

 

public class CustomPvpSystem{

 

  public CustomPvpSystem(L2PcInstance killer, L2PcInstance victim){

      this.setKiller(killer);

      this.setVictim(victim);

...

Pvp pvp = PvpTable.getInstance().getPvp(killer.getObjectId(), victim.getObjectId(), systemDay);

...

and in pvptable class:

...

private static PvpTable _instance = null;

...

  public static PvpTable getInstance(){

      if(_instance == null){

        _instance = new PvpTable();

      }

     

      return _instance;

  }

 

 

Will something like this work with this return instance ? Or can I do this easier?

 

And the second question, how can I random array ? For example I have ex[] = {1,2,3,4} and I want to random this array but inside, NOT like to get random from this array.

Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Hello im doing one custom thing now but Im wondering how to create Instance for each player with stats that will be hold until shutdown/restart. For example im calling function DoSomething() in doDie from L2PcInstance in which I want to read or create if not exist Instance for each player(killer) with few statics for example I want hold there pvp stats, if something happens im raising it or reseting.

Im thinking to do something similar like they have done in l2jFrozen:

 

public class CustomPvpSystem{

 

  public CustomPvpSystem(L2PcInstance killer, L2PcInstance victim){

      this.setKiller(killer);

      this.setVictim(victim);

...

Pvp pvp = PvpTable.getInstance().getPvp(killer.getObjectId(), victim.getObjectId(), systemDay);

...

and in pvptable class:

...

private static PvpTable _instance = null;

...

  public static PvpTable getInstance(){

      if(_instance == null){

        _instance = new PvpTable();

      }

     

      return _instance;

  }

 

 

Will something like this work with this return instance ? Or can I do this easier?

 

And the second question, how can I random array ? For example I have ex[] = {1,2,3,4} and I want to random this array but inside, NOT like to get random from this array.

 

Would you explain us more about this instance...

Becouse i'm 50% sure i can give you one already done, and you can modify it howeva you want...

Give me more info what exacly you wanna happend?

1v1 or?

Link to comment
Share on other sites

  • 0

It doesnt matter what Instance I want... i want to know it as a global issue, but I want to do something like this http://maxcheaters.com/forum/index.php?topic=228394.0 but i dont want to hold this: rewardConsecutiveKillCount in L2Pcinstance, I want to hold this in new java file. For example I create:

Rewards.java

here:

public class Rewards {

private int rewardConsecutiveKillCount = 0;

 

public void Increase() {

rewardConsecutiveKillCount++;

}

public int getCounts() {

return rewardConsecutiveKillCount;

}

 

}

I want something like this and where should call this function to get this for every player that killed someone to hold his counts (I know something like this would hold this only until restart) ?

Link to comment
Share on other sites

  • 0

If you want to safe it even after rr it must be  in database...

			rewardConsecutiveKillCount = "0":
		 con = L2DatabaseFactory.getInstance().getConnection()
		 setrewardConsecutiveKillCount = 0

 

I'm not good in java but this looks so/so to me :D

Link to comment
Share on other sites

  • 0

Arrays are static, once written they can't be edited. You must use a list, than you use shuffle() from Collections.

http://blog.ryanrampersad.com/2008/10/shuffle-an-array-in-java/

 


 

About your first question, I didn't really get it. Basically you have to create a new object filled with good parameters. Probably something like :

 

new CustomPvpSystem(killer, victim);

 

Check L2JFrozen and see how that class is used ?

Link to comment
Share on other sites

  • 0

I know how to write something to sql, thats not what I was asking for even I said I dont want it so u are just spamming.

 

I don't know if there is a way to safe something after restart without connection with database...

anyway gl ;)

Link to comment
Share on other sites

  • 0

I don't know if there is a way to safe something after restart without connection with database...

anyway gl ;)

Are u dumb or blind? Read what I have written before u post ok ?

Hello im doing one custom thing now but Im wondering how to create Instance for each player with stats that will be hold until shutdown/restart.

 

Anyway I did it, topic can be locked.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock