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

    • General Trackers :   IPTorrents invite IPTorrents account 1 tb TorrentLeech invite Torrentleech account 1 tb buffer  InTheShaDow ( ITS ) account Acid-lounge invite Torrentday invite Crnaberza account Abn.Lol account Limit-of-eden account Norbits account Xspeeds account Xspeeds invite Bemaniso invite Wigornot account Bithumen invite Filelist account Funfile invite AvistaZ invite Potuk.net invite ResurrectThe.Net invite GrabThe.Info invite Greek-Team invite LinkoManija invite Fano.in account TreZzoR account Speed.cd invite Arab-torrents.net account Arabscene.me account Scenetime account 4thd.xyz invite Btarg.com.ar account Dedbit invite Estone.cc account Speedapp invite Finvip invite Fluxzone account GigaTorrents account Gimmepeers account Haidan.video invite Mojblink account Mycarpathians invite Newinsane.info account Oscarworld.xyz account Peers.FM invite Pt.msg.vg account Ransackedcrew account Redemption invite Scene-rush account Seedfile.io invite Teracod invite Torrent.ai account Torrentmasters invite Ttsweb invite X-files invite X-ite invite Ncore account TorrentHR account Rptorrents account BwTorrents account Superbits invite Krazyzone account Immortalseed account Tntracker invite Pt.eastgame.org account Bitturk account Rstorrent account Tracker.btnext invite Torrent-turk.de account BeiTai.PT account Pt.keepfrds account 52pt.site account Pthome account Torrentseeds account Aystorrent account Blues-brothers.biz invite Divteam account Thesceneplace invite CinemaMovies.pl account Brasiltracker account Patiodebutacas account Newheaven.nl account  Xthor account Swarmazon.club invite Bc-reloaded account Crazyspirits account Silentground invite Omg.wtftrackr invite Milkie.cc invite Breathetheword invite Madsrevolution account Chilebt account Yubraca account Uniongang.tv account Frboard account Exvagos account Diablotorrent account Microbit account Carp-hunter.hu account Majomparade.eu account Theshinning.me account Bithorlo account Youiv.info account Dragonworld-reloaded account Sharewood.tv account Partis.si account Digitalcore.club invite Fuzer.me account R3vuk.wtf invite Ztracker account 1 tb buffer 3changtrai account Best-core.info account Bitsite.us account Eliteunitedcrew invite Exitorrent.org account Hellastz account Tophos invite Torrent.lt account Sktorrent.eu account Oshen account Blackhattorrent account Pirata.digital account Esharenet account Ohmenarikgi.la Pirate-share account Immortuos account Kiesbits account Cliente.amigos-share.club account Broadcity invite Ilovetorzz account Torrentbytes account Polishsource account Portugas invite Shareisland account ArabaFenice account Hudbt.hust.edu.cn account Audiences account Nanyangpt account Pt.sjtu.edu.cn account Pt.zhixing.bjtu.edu.cn account Byr.pt invite Ptfiles invite Red-bits account Pt.hdpost.top account Irrenhaus.dyndns.dk (NewPropaganda) account Mnvv2.info (MaxNewVision V2) account 1ptba.com account Spidertk.top account Casa-Torrent (Teamctgame) account Film-paleis account Generation-free account Aftershock-tracker account Twilightsdreams account Back-ups.me invite Sor-next.tk ( Spirit Of Revolution ) account Tfa.tf ( The Falling Angels ) account Hdmayi account S-f-p.dyndns.dk ( Share Friends Projekt ) account Unlimitz.biz account Pttime account St-tracker.eu account New-retro.eu account Zbbit account Tigers-dl.net account Jptvts.us account Lat-team account Club.hares.top account Falkonvision-team account Concen account Drugari account Megamixtracker account T.ceskeforum account Peeratiko.org account Zamunda.se account Central-torrent.eu account h-o-d.org account Hdturk.club account Torrentleech.pl account Demonoid invite Lst.gg account Fakedoor.store account LaidBackManor account Vrbsharezone.co.uk invite Torrenteros account Arenaelite account Datascene account Tracker.0day.community Tapochek.net invite Jme-reunit3d account Ptchina invite Lesaloon account Exyusubs account Therebels.tv account Ubits.club invite Zmpt.cc account Turktorrent.us account Dasunerwarte account Funsharing account Hawke.uno account Monikadesign account Theoldschool.cc invite Fearnopeer account Alpharatio account Desitorrents account Wukongwendao.top account Chinapyg account Azusa.wiki account   Movies Trackers :   Pixelhd account Cinemageddon account DVDSeed account Cinemageddon account Cinemaz account Retroflix account Classix-unlimited - invite Movie-Torrentz (m2g.link) invite Punck-tracker.net account Tmghub account Tb-asian account Cathode-ray.tube account Greatposterwall account Telly account Arabicsource.net account   HD Trackers :   Hdf.world account HD-Only account Torrentland.li account HdSky account Hdchina account Chdbits account Totheglory account Hdroute account Hdhome account TorrentCCF aka et8.org account 3DTorrents invite HD-Torrents account Bit-HDTV account HDME.eu invite Hdarea.co account Asiancinema.me account JoyHD invite HDSpace invite CrazyHD invite Bluebird-hd invite Htpt.cc account Hdtime invite Ourbits.club account Hd4fans account Siambit account Privatehd account Springsunday account Tjupt account Hdcity.leniter invite Ccfbits account Discfan account Pt.btschool.club account Ptsbao.club invite Hdzone.me invite HDDolby account Danishbytes account Zonaq.pw account Tracker.tekno3d account Arabp2p account Hd-united account Reelflix.xyz account Hdatmos.club account Anasch.cc invite Tigris-t account Nethd.org account Hd.ai invite Hitpt.com account Hdmonkey account Dragonhd.xyz account Hdclub.eu account Forum.bluraycd.com account Carpt account Hdfun.me invite Pt.hdupt invite Puntotorrent account Ultrahd account Rousi.zip account Blutopia account   Music Trackers :   Dicmusic account Music-Vid account Open.cd account LzTr account ProAudioTorrents invite Jpopsuki invite TranceTraffic invite Audionews invite Kraytracker invite Libble.me invite Losslessclub invite Indietorrents.com invite Dimeadozen account Funkytorrents invite Karaokedl account zombtracker.the-zomb account Concertos invite Sugoimusic account Satclubbing.club invite Metal.iplay invite Psyreactor invite Panda.cd account Adamsfile account Freehardmusic account Tracker.hqmusic.vn accouunt Twilightzoom account 3 tb buffer Hiresmusic account Metalguru account   E-Learning Trackers :   BitSpyder invite Brsociety account Learnbits invite Myanonamouse account Libranet account 420Project account Learnflakes account Pt.soulvoice.club account P2pelite account Aaaaarg.fail invite Ebooks-shares.org account Abtorrents account   TV-Trackers :   Skipthecommericals Cryptichaven account TV-Vault invite Shazbat.TV account Myspleen account Tasmanit.es invite Tvstore.me account Tvchaosuk account Jptv.club account Tvroad.info   XXX - Porn Trackers :   FemdomCult account Pornbay account Pussytorrents account Adult-cinema-network account Bootytape account 1 Tb buffer Exoticaz account Bitporn account Kufirc account Gaytorrent.ru invite Nicept account Gay-torrents.org invite Ourgtn account Pt.hdbd.us account BitSexy account   Gaming Trackers :   Mteam.fr account BitGamer invite Retrowithin invite Gamegamept invite Cartoon/Anime/Comic Trackers : U2.dmhy account CartoonChaos invite Animetorrents account Nyaa.si account Mononoke account Totallykids.tv account Bakabt.me invite Revanime account Ansktracker account Tracker.shakaw.com.br invite Bt.mdan.org account Skyey2.com account Animetracker.cc   Sports Trackers :   MMA-Tracker invite T3nnis.tv invite AcrossTheTasman account RacingForMe invite Sportscult invite Ultimatewrestlingtorrents account Worldboxingvideoarchive invite CyclingTorrents account Xtremewrestlingtorrents account Tc-boxing invite Mma-torrents account Aussierul invite Xwt-classics account Racing4everyone account Talk.tenyardtracker account Stalker.societyglitch invite Extremebits invite   Software/Apps Trackers :   Ianon account Brokenstones account Appzuniverse invite Teamos.xyz account Graphics Trackers: Forum.Cgpersia account Gfxpeers account Forum.gfxdomain account Documentary Trackers: Forums.mvgroup account   Others   Fora.snahp.eu account Board4all.biz account Filewarez.tv account Makingoff.org/forum account Xrel.to account Undergunz.su account Corebay account Endoftheinter.net ( EOTI ) account Thismight.be invite Skull.facefromouter.space account Avxhm.se (AvaxHome) account Ssdforum account Notfake.vip account Intotheinter.net account Tildes.net invite Thetoonz account Usinavirtual account Hdclasico invite HispaShare account Valentine.wtf account Adit-hd account Forum-andr.net account Warezforums account Justanothermusic.site account Forbiddenlibrary.moe account Senturion.to account Movieparadise account Militaryzone account Dcdnet.ru account Sftdevils.net account Heavy-r.com account New-team.org account   NZB :   Drunkenslug account Drunkenslug invite Usenet-4all account Brothers-of-Usenet account Dognzb.cr invite Kleverig account Nzb.cat account Nzbplanet.net invite Ng4you.com account Nzbsa.co.za account Bd25.eu account NZB.to account   Prices start from 3 $ to 100 $   Payment methods: Crypto, Neteller, Webmoney, Revolut   If you want to buy something send me a pm or contact me on:   Email: morrison2102@gmail.com   Discord: LFC4LIFE#4173   Telegram: https://t.me/LFC4LIFE4173   Skype: morrison2102@hotmail.com
    • LOKAGAMERS - BANNER L2ETERNITY - ANIMATED BORDER
    • aha okay. If you dont have anything productive to contribute, then just dont comment, thanks!   I didnt ask for your opinion!
    • If you worry about such a thing then just don't start building one.    
    • Hello friends, I need help compiling the Skill.usk file, is there anyone experienced in this who can help me with this error?
  • Topics

×
×
  • Create New...