Jump to content
  • 0

[Rquest]Instances


Question

Posted

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.

7 answers to this question

Recommended Posts

  • 0
Posted

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?

  • 0
Posted

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) ?

  • 0
Posted

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

  • 0
Posted

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 ?

  • 0
Posted

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 ;)

  • 0
Posted

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.

Guest
This topic is now closed to further replies.


  • Posts

    • 我们计划在我们的Telegram频道为3000名订阅者举办大型竞赛和抽奖活动。 订阅并获取我们项目的最新消息、更新和变动:竞赛、抽奖、新产品、折扣、优惠码以及更多内容! 在我们的竞赛和抽奖活动中,顶级合作伙伴也可以参与,这一定会引起您的关注! ➡ Telegram频道: https://t.me/accsforyou_shop✅ 链接: 数字商品商店 (网站): 前往 购买Telegram Stars的Telegram机器人: 前往 SMM面板: 前往 – 推广您的社交媒体账户。 商店Telegram机器人: 前往 我们为您呈现在本平台购买产品和服务的最新促销与特别优惠: 1. 使用促销码OCTOBER2025(8%折扣)即可在10月通过我们的网站或机器人购物!您也可以使用促销码SOCNET(15%折扣)完成首次购买。 2. 注册后只需按照以下模板写下您的用户名即可获得1美元账户余额或10–20%的折扣:"SEND ME BONUS, MY USERNAME IS..." – 需要在我们的论坛帖子中发布! 3. 第一次试用SMM面板即可获得1美元:只需在我们的网站(支持)提交主题为“Get Trial Bonus”的工单。 4. 我们的Telegram频道和购买Stars的机器人中每周都有Telegram Stars赠送活动! 新闻: ➡ Telegram频道: https://t.me/accsforyou_shop✅ ➡ WhatsApp频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t✅ ➡ Discord服务器: https://discord.gg/y9AStFFsrh✅ 联系方式与支持: ➡ Telegram: https://t.me/socnet_support✅ ➡ WhatsApp: https://wa.me/79051904467✅ ➡ Discord: socnet_support ✅ ➡ ✉ 邮箱: solomonbog@socnet.store ✅
    • 我们计划在我们的Telegram频道为3000名订阅者举办大型竞赛和抽奖活动。 订阅并获取我们项目的最新消息、更新和变动:竞赛、抽奖、新产品、折扣、优惠码以及更多内容! 在我们的竞赛和抽奖活动中,顶级合作伙伴也可以参与,这一定会引起您的关注! ➡ Telegram频道: https://t.me/accsforyou_shop✅ 链接: 数字商品商店 (网站): 前往 购买Telegram Stars的Telegram机器人: 前往 SMM面板: 前往 – 推广您的社交媒体账户。 商店Telegram机器人: 前往 我们为您呈现在本平台购买产品和服务的最新促销与特别优惠: 1. 使用促销码OCTOBER2025(8%折扣)即可在10月通过我们的网站或机器人购物!您也可以使用促销码SOCNET(15%折扣)完成首次购买。 2. 注册后只需按照以下模板写下您的用户名即可获得1美元账户余额或10–20%的折扣:"SEND ME BONUS, MY USERNAME IS..." – 需要在我们的论坛帖子中发布! 3. 第一次试用SMM面板即可获得1美元:只需在我们的网站(支持)提交主题为“Get Trial Bonus”的工单。 4. 我们的Telegram频道和购买Stars的机器人中每周都有Telegram Stars赠送活动! 新闻: ➡ Telegram频道: https://t.me/accsforyou_shop✅ ➡ WhatsApp频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t✅ ➡ Discord服务器: https://discord.gg/y9AStFFsrh✅ 联系方式与支持: ➡ Telegram: https://t.me/socnet_support✅ ➡ WhatsApp: https://wa.me/79051904467✅ ➡ Discord: socnet_support ✅ ➡ ✉ 邮箱: solomonbog@socnet.store ✅
    • 我们计划在我们的Telegram频道为3000名订阅者举办大型竞赛和抽奖活动。 订阅并获取我们项目的最新消息、更新和变动:竞赛、抽奖、新产品、折扣、优惠码以及更多内容! 在我们的竞赛和抽奖活动中,顶级合作伙伴也可以参与,这一定会引起您的关注! ➡ Telegram频道: https://t.me/accsforyou_shop✅ 链接: 数字商品商店 (网站): 前往 购买Telegram Stars的Telegram机器人: 前往 SMM面板: 前往 – 推广您的社交媒体账户。 商店Telegram机器人: 前往 我们为您呈现在本平台购买产品和服务的最新促销与特别优惠: 1. 使用促销码OCTOBER2025(8%折扣)即可在10月通过我们的网站或机器人购物!您也可以使用促销码SOCNET(15%折扣)完成首次购买。 2. 注册后只需按照以下模板写下您的用户名即可获得1美元账户余额或10–20%的折扣:"SEND ME BONUS, MY USERNAME IS..." – 需要在我们的论坛帖子中发布! 3. 第一次试用SMM面板即可获得1美元:只需在我们的网站(支持)提交主题为“Get Trial Bonus”的工单。 4. 我们的Telegram频道和购买Stars的机器人中每周都有Telegram Stars赠送活动! 新闻: ➡ Telegram频道: https://t.me/accsforyou_shop✅ ➡ WhatsApp频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t✅ ➡ Discord服务器: https://discord.gg/y9AStFFsrh✅ 联系方式与支持: ➡ Telegram: https://t.me/socnet_support✅ ➡ WhatsApp: https://wa.me/79051904467✅ ➡ Discord: socnet_support ✅ ➡ ✉ 邮箱: solomonbog@socnet.store ✅
    • 我们计划在我们的Telegram频道为3000名订阅者举办大型竞赛和抽奖活动。 订阅并获取我们项目的最新消息、更新和变动:竞赛、抽奖、新产品、折扣、优惠码以及更多内容! 在我们的竞赛和抽奖活动中,顶级合作伙伴也可以参与,这一定会引起您的关注! ➡ Telegram频道: https://t.me/accsforyou_shop✅ 链接: 数字商品商店 (网站): 前往 购买Telegram Stars的Telegram机器人: 前往 SMM面板: 前往 – 推广您的社交媒体账户。 商店Telegram机器人: 前往 我们为您呈现在本平台购买产品和服务的最新促销与特别优惠: 1. 使用促销码OCTOBER2025(8%折扣)即可在10月通过我们的网站或机器人购物!您也可以使用促销码SOCNET(15%折扣)完成首次购买。 2. 注册后只需按照以下模板写下您的用户名即可获得1美元账户余额或10–20%的折扣:"SEND ME BONUS, MY USERNAME IS..." – 需要在我们的论坛帖子中发布! 3. 第一次试用SMM面板即可获得1美元:只需在我们的网站(支持)提交主题为“Get Trial Bonus”的工单。 4. 我们的Telegram频道和购买Stars的机器人中每周都有Telegram Stars赠送活动! 新闻: ➡ Telegram频道: https://t.me/accsforyou_shop✅ ➡ WhatsApp频道: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t✅ ➡ Discord服务器: https://discord.gg/y9AStFFsrh✅ 联系方式与支持: ➡ Telegram: https://t.me/socnet_support✅ ➡ WhatsApp: https://wa.me/79051904467✅ ➡ Discord: socnet_support ✅ ➡ ✉ 邮箱: solomonbog@socnet.store ✅
  • Topics

×
×
  • 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