Jump to content

Question

Posted

hi,

I have this code and try to verify the time has passed when case occurred

Example in l2pcinstance:
 

private int assasins = 0;

switch(assasins) {
  case 2:
    Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed two times" + pk.getTarget().getName());
    break;
  case 3:
    Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed three times" + pk.getTarget().getName());
  default:
}

 

i need verify if the next kill (case 3) ocurred  < 10 seconds. if the time passed make a different announcements..

 

i think how see the code with my idea...

private int assasins = 0;
switch(assasins) {
  case 2:
    	Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed two times" + pk.getTarget().getName());
		ThreadPoolManager.getInstance().schedule(assasins = 3 , 10 * 1000);
    break;
  case 3:
    Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed" + pk.getTarget().getName());
		ThreadPoolManager.getInstance().schedule(assasins = 4 , 10 * 1000);
    break;
  default:
}

 

sorry my bad english :3

Recommended Posts

  • 0
Posted (edited)

No no no. You have to create a new long variable, set the time using system current time + 10sec on kill, then on the switch compare the time if your variable > current time. 

Edited by SweeTs
  • Upvote 1
  • 0
Posted

thanks sweets i try this..

private int assasins = 0;
switch(assasins) {
	case 1:
	//Here obtain time when case 1 ocurred
	long firstkill = System.currentTimeMillis();
  case 2:
    	long checktime = System.currentTimeMillis() - firstkill;
		if(checktime < 10000) {
			Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed two times" + pk.getTarget().getName()); 
			} else {
				Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed" + pk.getTarget().getName());
		}
    break;
  case 3:
   .........
    break;
  default:
}

but i get an error, in case 2 "The local variable firstkill may not have been initialized"

How to fix this? i try the fix but not obtain solution hahaha thanks!

  • 0
Posted (edited)

i tested and not work.. every kill obtain first case only, never update or increment the variable "assasins", i try implement this code in fandc files like mobius.. anye help me?

 

private int assasins = 0;

protected void doPKPVPManage(Creature....
                             
                             long firstkill = System.currentTimeMillis() + 10 * 1000;
                             switch(assasins) {
                               case 1:
                               Announcements.getInstance().announceToAll("Test First Kill VAR:" + assasins);
                               break;
                               case 2:
                               if(System.currentTimeMillis() - firstkill > 10000) {
                                 Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed" + pk.getTarget().getName());
                               } else { 
                                 Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed two times in a row!" + pk.getTarget().getName()); 
                               }
                               break;
                               case 3:
                               if(System.currentTimeMillis() - firstkill > 20000) {
                                 Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed" + pk.getTarget().getName()); 
                               } else { 
                                 Announcements.getInstance().announceToAll("Player " + pk.getName() + " has killed three times in a row!" + pk.getTarget().getName()); 
                               }
                               break;
                               case 4: 
                               ...... 
                               break; 
                               default: 
                             }

 

Out Put only first case

Edited by StarSCreams
add
  • 0
Posted (edited)

this is happening because the variable firstkill is inside the kill method. Put it after assasins... 

generally follow this :

private long firstkill = 0L;

 

the firstkill variable must be used after the end of the switch.

switch(something)
{
	case 1:
		...
	brake;
	case 2:
		...
	break;
}

firstkill = System.currentTimeMillis() + (10*1000); //or instantly 10000 

the only thing you have to do is to check the the current time - firstkill  is > 10000 then 10 seconds  are passed

p.s Edited 

example in case 1:

 

switch(assasins)
{
  case 1:
    if (System.currentTimeMillis() - firstkill > 10000)
        10 seconds passed
    else
        not passed yet
  	break;
  cases X...
 	 ....
 	 ....
}

firstkill = System.currentTimeMillis() + (10 * 1000);

 

Edited by melron
  • 0
Posted (edited)

hey melron, thanks for you reply, you fix one of my problems (How to check if 10 seconds passed), but my other problem not fix..

 

i make the clean code to check it work, but never increment the variable..

Example:

private int assasins = 0;

protected void doPKPVPManage(Creature....

			.....
			//Line: @@ -4286,6 +4319,37 @@

			//Here my code check if pvpkill and update +1 kills to db
				pk.setPvpKills(pk.getPvpKills() + 1);
				
				assasins++;
				
				switch(assasins) {
					case 1:
						Announcements.getInstance().announceToAll("FIRST KILL VARIABLE: " + assasins);
					break;
					case 2:
						Announcements.getInstance().announceToAll("SECOND KILL VARIABLE: " + assasins);
					break;
					case 3:
						Announcements.getInstance().announceToAll("THIRD KILL VARIABLE: " + assasins);
					break;
					case 4:
						Announcements.getInstance().announceToAll("FOUR KILL VARIABLE: " + assasins);
					break;
					default:
							Announcements.getInstance().announceToAll("DEFAULT KILL++ VARIABLE: " + assasins);
					break;
				}

 

Ingame, i made more than 10 kills only show FIRST ANNOUNCEMENT u.u

 

Thanks for help me!

Edited by StarSCreams
  • 0
Posted (edited)

be sure that your variable assasins is a global variable. the code you posted seems running fine without problems

Edited by melron
  • 0
Posted (edited)
12 minutes ago, melron said:

be sure that your variable assasins is a global variable. the code you posted seems running fine without problems

how to check if my variable is global? i add to my variable static to make a global..

public static int assasins = 0;

 

but obtain same result, only show first kill

Edited by StarSCreams
  • 0
Posted (edited)

no you dont need it as static you need it instanceid ... just put the variable out of any method. if you still have problems add me in skype

Edited by melron
  • 0
Posted (edited)
25 minutes ago, melron said:

no you dont need it as static you need it instanceied ... just put the variable out of any method. if you still have problems add me in skype

thanks for you support, i found the problem.. i have put ondie character class:  assasins = 0;

but set 0 when any character dies not the killer for stop kills in a row.. i try find the fix now hahaha thanks!!!

Edited by StarSCreams
  • 0
Posted

hi, i try to fix my last problem but i can't...

 

i add assasins = 0; in protected void onDeath(Creature killer) .... to stop killingspree

and not increment assasins++; in protected void doPKPVPManage(Creature killer)

how to check if killer is dead? or how to fix? i upload my Player.java in paste bin if any can help me, search: //killingspree to see if my code is correct..

https://pastebin.com/hGXgnsUV

 

Thanks all!

  • 0
Posted

From the beginning, what's your whole idea? If time < 10s from previous kill send other message than default? Counting from first kill, or 2nd - > 3rd send other message as well? 

  • 0
Posted
7 hours ago, SweeTs said:

From the beginning, what's your whole idea? If time < 10s from previous kill send other message than default? Counting from first kill, or 2nd - > 3rd send other message as well? 

the messages and kills works, but when i add assassins = 0; in... protected void onDeath(Creature killer)..., don't work anymore. i add that to stop killing spree
to create this I followed this example: http://www.maxcheaters.com/topic/107756-sharefreya-killing-spree/

 

I hope you understand me i am from argentine and i do not know how to express myself very well in english u.u

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

    • Hello, I’m working on decrypting the Init packet that the server sends to the client during login. This packet is treated specially and contains the Blowfish keys used to encrypt and decrypt subsequent packets. Although it isn’t encrypted irreversibly and should be reversible, I haven’t succeeded yet. My goal is to extract the Blowfish key to decrypt certain client packets without disrupting the normal session flow. I can inject a DLL to sniff the packets, and with that I plan to develop a module that extends the client’s functionality. For example, after logging in, this module would capture all the data the client receives (character data, etc.). Additionally, it could listen for real-time server events, enabling integrations with Discord SDKs or other systems, thereby expanding Lineage 2’s capabilities. Init packet(0x00) LoginServer. Currently in the java Cores I checked there is no decode function for this package, only encript.
    • whats password from the archivie ?
    • All that shit are false positives of the vanganth cliext, sources are well and who sell it is a big scammer
    • Information Selling a premium Lineage 2 High Five (L2J) project with active development, available by subscription. Includes Git support and access to compiled or full source code. Ideal for serious server owners seeking stability and performance, uniqueness and well-done features.   General Project Specifications: JDK Version: 23 -> 24 Chronicle: HighFive Structure: Core & Datapack merged into a single project Database: MariaDB Database Driver: HicariCP GIT Website: gitlab.com   Features include (but are not limited to):   1. Tournament Single & Party (Check Youtube Video) 2. Faction (Check Youtube Video) 3. Event Engine (Check Youtube Video) 4. Sell Buff System (Check Youtube Video) 5. Start UP System (Check Youtube Video) 6. User Panel 7. Visual - Dress me System 8. Donate Store 9. Automatic Farm System (Check Youtube Video) 10. Captcha (Anti-BOT) (Check Youtube Video) 11. Auction (Check Youtube Video) 12. Vote (API) 13. Admin Real Time Balance (Check Youtube Video) 14. Achievements (Check Youtube Video) 15. Daily Mission (Check Youtube Video) 16. A.I. Bot (Check Youtube Video) 17. Rebirth 18. Daily Reward  19. Skill Tree - Ability System 20. Craft System 21. Twitch Automatic Reward (Check Youtube Video) 22. Quiz Game (Check Youtube Video) 23. Automatic Item Enchant (Check Youtube Video) 24. Secondary Auth Using Google Authenticator (Check Youtube Video) 25. Gm Shop - Gatekeeper - Scheme Buffer   How to get Access (Payment Subscription): To get Access you either pay monthly subscription to GIT for source or Compiled. Project is currently active and has at least 1-2 commit / day.  Clients in both Compiled & Source subscription can request features or any addon in already existing mods inside discord.   Price per Month (Source) in GIT: 250 Eur Price per Month (Compiled) in GIT: 100 Eur   Contact: To get Access or ask further information join discord  https://discord.gg/gKAsAhJNuq      
  • Topics

×
×
  • Create New...