Jump to content
  • 0

PK Cleaner NPC Problem


Question

Recommended Posts

  • 0
Posted

change line:

if(player.getInventory().getItemByItemId(Config.PK_CLEAN_ID).getCount() < Config.PK_CLEAN_PRICE)

to:

L2ItemInstance item = player.getInventory().getItemByItemId(Config.PK_CLEAN_ID);
if(item != null && item.getCount() < Config.PK_CLEAN_PRICE)

  • 0
Posted

[PL] teraz  dziala ale choc kiedy mam pk i nie mam itema zeruje mi pk a gdy nie mam pk i klikne zeby wyczyscilo caly czas  mi pisze "Your karma cleaned, continue to play"

i mam tez :

http://s6.ifotos.pl/img/Przechwyt_rqrweep.PNG

 

[en]

when i no have item and have pk  npc clean mine pk

and  when no have pk  and click "clean" i have messesage

"Your karma cleaned, continue to play"

and i have :

http://s6.ifotos.pl/img/Przechwyt_rqrweep.PNG

how to fix it?

 

 

  • 0
Posted

First of all , i really love that

 

/**

* Author: Leki

*/

 

Good job Leki with your share .

Anyway , keeping onpost , all gonna work for sure , i read the whole code and didn't found something wrong . Maybe there should be the problem :

 

 else if(player.getKarma() == 0)
                                player.sendMessage("You don't have any karma, i cannot change it any lower!");
                else // here should be added another if ? Not sure 

As Leki said , " I don't know H5 core as good as interlude ". The best developers for hi5 that i know are from "L2jHidden" project .You should contact them.

 

Good luck in fixing your problem .

  • 0
Posted

add the {} to the else block

before

                               player.setKarma(0);

{

after

                                player.sendMessage("Your karma cleaned, continue to play!"); 

}

add an else before the super(...) call, we dont need it if it was CleanPK

 

add "final" to

L2ItemInstance item = player.getInventory().getItemByItemId(Config.PK_CLEAN_ID);

this is not an error but will have better performance

  • 0
Posted

As wrote vampir, if you haven't the item, it tries to find setCount from a null item, so you will have a NPE in case you haven't the item and try to speak with the PK remover dude. And that will happen on every chronicle, even IL, until you edited method.

 

"final" keyword doesn't impact performance at all, but it's a security for coder. He knows this stuff won't be edited by future edition. You could drop entire final keys from the code with no change. You're right to use "final" when you can, cause it's a good use.

 

A contrario, "static" keyword improves performance, as that method/variable will be shared amongst instances of that class (case of loggers, for example : you use static, only one logger is created for all instances). It means too if you edited (in case of a variable) it, it will affect all instances. So it must be used only when you need it.

 

Just saying.

 

About

super.onBypassFeedback(player, command);

, generally it's with a "else" before. Like that even if that npc hasn't the command, he inherits of others commands "in case of".

 

Finaly, L2PcInstance got a useful check you're using, but you use it bad.

 

					if (!player.destroyItemByItemId("SevenSigns", stoneType, stonesNeeded, this, true))
					return;

 

destroyItemByItemId returns a boolean which mean you can drop the previous check about count. You get ride of one check, and of the NPE in same time and reduces code.

 


 

@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
if (command.startsWith("CleanPK"))
{
	if(player.destroyItemByItemId("CleanKarma", Config.PK_CLEAN_ID, Config.PK_CLEAN_PRICE, this, true))
	{
		player.setKarma(0);
		player.sendMessage("Your karma is cleaned.");       
	}
	else
		player.sendMessage("You don't have enough required items.");
}
else 
	super.onBypassFeedback(player, command);
}

  • 0
Posted

[pl]dobra wszystko  dziala thx Vampir i sorry ze ci zawracalem przyslowiowa dupe :P tylko mi wyskakuje gdy nacisne clean "L2PKCleanerInstance:

Unkown NPC bypass: "cleanPK" npcid: 9999" ale to chyba nic waznego. aa ps moge z 1 sprawa do ciebie na PM ?

  • 0
Posted

"final" keyword doesn't impact performance at all

they do, since you have a var that can only de intialized once, the VM can use it read-only, and that will increase the performance.

 

[...] declaring a final field helps the optimizer make better optimization decisions, because if the compiler knows the field's value will not change, it can safely cache the value in a register.

http://www.ibm.com/developerworks/java/library/j-jtp1029/index.html

 

The revised memory model proposed by JSR 133 includes special provisions for final fields, provisions that are absent from the existing specification. Newer VMs already implement this specification, and treat final fields accordingly. Because final fields are assigned exactly once, aggressive optimizations in a multithreaded context become possible. Specifically, a field doesn't need to be ever reloaded, since its value is guaranteed never to change.

http://renaud.waldura.com/doc/java/final-keyword.shtml

 

Example of Strings differences (final/ not final). nothing to do with our case, but still a relation between "final" and "performance"

http://www.coderanch.com/t/518466/Performance/java/Compiler-optimization-final-variables

 

 

This is a minimal impove. And there are things that can give a lot more than this (for example direct access and not getters/setters, inside the class) or use C++. But still impact on performance

  • 0
Posted

In your own IBM link, you can read

While performance is not a good reason to declare a class or method as final, there are still good reasons to sometimes write final classes.

 

Seems only variables worth to put final. I don't believe you gain something like even 1%, the main point is immutation (or whatever it's named).

  • 0
Posted

I agree, so best thing is to make variables final if they are outside methods, otherwise it's not that important and code isnt readable that well as before.

Guest
This topic is now closed to further replies.


  • Posts

    • Server owners, Top.MaxCheaters.com is now live and accepting Lineage 2 server listings. There is no voting, no rankings manipulation, and no paid advantages. Visibility is clean and equal, and early listings naturally appear at the top while the platform grows. If your server is active, it should already be listed. Submit here https://Top.MaxCheaters.com This platform is part of the MaxCheaters.com network and is being built as a long-term reference point for the Lineage 2 community. — MaxCheaters.com Team
    • ⚙️ General Changed “No Carrier” title to “Disconnected” to avoid confusion after abnormal DC. On-screen Clan War kill notifications will no longer appear during Sieges, Epics, or Events. Bladedancer or SwordSinger classes can now log in even when Max Clients (2) is reached, you cannot have both at the same time. The max is 3 clients. Duels will now be aborted if a monster aggros players during a duel (retail-like behavior). Players can no longer send party requests to blocked players (retail-like). Fixed Researcher Euclie NPC dialogue HTML error. Changed Clan leave/kick penalty from 12 hours to 3 hours. 🧙 Skills Adjusted Decrease Atk. Spd. & Decrease Speed land rates in Varka & FoG. Fixed augmented weapons not getting cooldown when entering Olympiad. 🎉 Events New Team vs Team map added. New Save the King map added (old TvT map). Mounts disabled during Events. Letter Collector Event enabled Monsters drop letters until Feb. 13th Louie the Cat in Giran until Feb. 16th Inventory slots +10 during event period 📜 Quests Fixed “Possessor of a Precious Soul Part 1” rare stuck issue when exceeding max quest items. Fixed Seven Signs applying Strife buff/debuff every Monday until restart. 🏆 Milestones New milestone: “Defeat 700 Monsters in Varka” 🎁 Rewards: 200 Varka’s Mane + Daily Coin 🌍 NEW EXP Bonus Zones Hot Springs added Varka Silenos added (hidden spots excluded) As always, thank you for your support! L2Elixir keeps evolving, improving, and growing every day 💙   Website: https://l2elixir.org/ Discord: https://discord.gg/5ydPHvhbxs
    • https://sms.pro/ — we are an SMS activation platform  seeking partners  mobile number providers  mobile number owners  owners of GSM modems  SIM card owners We process 1,000,000 activations every day.  寻找合作伙伴  手机号码提供商  手机号码持有者  GSM调制解调器持有者  SIM卡持有者 我们每天处理1,000,000次激活。  Ищем партнеров  Владельцы сим карт  провайдеров  владельцев мобильных номеров  владельцев модемов  Обрабатываем от 1 000 000 активаций в день ⚡️ Fast. Reliable.   https://sms.pro/ Support: https://t.me/alismsorg_bot
    • "WHAT I WILL SEE ON NEW SEASON ? *More easy farm and augment than ever before ! *Free VIP characters for everyone for first 2 days after opening ! Improved olympiad engine to work more correctly. 3 New skins / outfits. Fixed raid boss spawns. Fixed olympiad crit errors. New farming Ivory Tower area. Fixed augmentation rate. Increased all mob drops rate by +20%. And much more..."   1. I have clicked VIP 23.01.2026 20:00 a few second after open server. 2 Days is 48h. Now 24.01.2026 I have 17 hours left, so my VIP will expire 08:00 25.01.2026. Where is 12h? SCAM.   2. Where is ivory tower area?   3. When next wipe?   
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..