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

    • Hi everyone, Since I’m no longer interested in L2 servers, if anyone is willing to continue the project, let me know. I’m currently selling the entire project. DM me for more information if you’re genuinely interested. I can offer limited free support for the first couple of months. It is not cheap. The sale includes the domain, the recently fully redesigned website, the updater, the interface, server files with Lucera ext source, and the database (excluding account passwords, emails, and other private information; character data can remain).   Server for test: https://lineage2.gold/download Server Info: https://lineage2.gold/info Over 110 videos YouTube playlist: https://www.youtube.com/watch?v=HO7BZaxUv2U&list=PLD9WZ0Nj-zstZaYeWxAxTKbX7ia2M_DUu&index=113  
    • You invent yourself a life - bad for you, one of the inner core dev, fernandopm, which worked hard over aCis quests from 2011 to 2016 is argentinian. I teached him back in time to work and make proper quests. My dev team comes from 10+ countries and I'm myself french. "Racist/nationalist" card ? Not working bro.   Not sure why I should thank you to send me questions, and regarding bug reports, so far, I got none of yours in either discord, gitlab, or forums. I'm sorry if you feel "ignored", but that's more a psychanalyst you need to speak with if you put emotions towards someones' appreciation over a forum. I never ignore a bug report, and if so (like skills reports), it's because I got a bigger plan (skills refactor, in that case). In any case, I delivered cookies for the bug report/fix, even if it dated of months, with proper credits over changesets. "Victim card" ? Not really working, but ok, maybe you're "emotional".   I barely make money out of aCis, for the spent time - simply selling my services, or even coding/administrating a minecraft/L2J server would make far more money. Breaking intentionally things would be stupid. If you don't understand I'm not the only one working on that pack, I can't help you. Also, the scale of edits is sometimes extreme - AI L2OFF ? 1800 files added. How do you want everything works in a single shot ? "Exploiting noobz for money" card ? Still not working, or I'm a terrible businessman.   Meanwhile - you shadow advertise your project, L2JOne (since 2017 btw) - you should maybe start by the beginning saying you're a competitor and aCis is actually a spike in your foot. That also explains why you act like that. RusAcis got the exact same strategy, speaking bad of me, saying they got unique fixes (you speak about I break things, they break and recode things 4 times sometimes, btw), but successfully reselling latest revision with poorly executed stuff. "aCis is good, Tryskell is ok, but I solve all issues in extreme low time so I can piss over him" card ? Mmmmhhhh.   Our conversation ends here if you want, I don't force ppl to speak with me if they don't want - hopefully, people would understand I'm not the arrogant one and the one who doesn't want to talk, or even collaborate. :). I understand you got your own project and got no will to improve aCis.   NOTE : I'm extremely happy for your call of ExShowServerPrimitive with getValidGeoLocation, extremely impressive. Arrogant, no. Sarcastic ? Maybe.   Good night everyone.
    • Hi. @GX-Ext, svn does not work. is there anywhere else where we can get source code? Thank you so much.
  • 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..

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