Jump to content
  • 0

One more slight problem...


Question

Posted

Hello, I have posted on the eAthena board before to fix a slight problem and here I am, posting again but this time, on the new board. My problem this time is as follow:

How do you reset the event after a players logs off in the middle of it or dies? I want that sort of player to be able to access it again until it is completed once.

Here's the specific NPC script, forgive the bulky mess.

//========================================================
	//SCRIPT: PRACTICE			  
//========================================================
//================NPC INSTRUCTOR EIDOLON==================

poring_c01,101,108,5	script	Instructor Eidolon::eid_pract0	704,{
switch(teach_novice)
	{
		case 7:
			mes "[Eidolon]";
  					 mes "I will summon 10 monsters";
  					 mes "for you to uh... vanquish.";
  					 next;
  					 mes "[Eidolon]";
  					 mes "To attack a monster, simply";
			mes "left click on it repeatedly.";
  					 next;
  					 mes "[Eidolon]";
  					 mes "You can also use the ^0000FF/nc^000000 command";
  					 mes "which will allow you to uh...";
  					 mes "auto-attack after clicking";
  					 mes "your target once.";
  					 next;
  					 mes "^CC0000As he chants a summoning";
  					 mes "spell, you cannot help but feel";
  					 mes "slight anxiety due to being";
  					 mes "inexperienced in battle.^000000";
  				 areamonster "this",109,100,99,90,"Poring",1725,10,"eid_pract0::OnPKill";
			hideonnpc "eid_pract0";
			initnpctimer "eid_pract0";
  				 close2;
			set $PAmount, 10;
			end;
	}			
	OnPKill:
		set $PAmount, $PAmount - 1;
			if($PAmount == 0)
				{
				announce "Well done.",bc_npc,0xFFFF00;
				hideoffnpc "eid_pract0";
				areawarp "poring_c01",0,0,350,350, "poring_w02",77,87;
				stopnpctimer "eid_pract0";
				detachnpctimer "eid_pract0";
				set teach_novice, 8;
				}
				else
				{
				announce ""+ $PAmount +" porings left.",bc_npc,0xFFFF00;
				}
				end;

				OnTimer5000:
				announce "You have 2 minutes to complete the uh... task.",bc_npc,0xFFFF00;
				end;

				OnTimer100000:
					announce "1 minute left.",bc_npc,0xFFFF00;
					end;

				OnTimer200000:
					announce "Time's up.",bc_npc,0xFFFF00;
					killmonster "poring_c01","eid_pract0::OnPKill";
					areawarp "poring_c01",0,0,350,350, "poring_w02",96,200;
					hideoffnpc "eid_pract0";
					stopnpctimer"eid_pract0";
					detachnpctimer "eid_pract0";
					end;
}

//Need to reset when player logs out or dies.

2 answers to this question

Recommended Posts

Posted

Luckily you have two very helpfull commands:

OnPCDieEvent

OnPCLogoutEvent

You could use them like this:

//========================================================
	//SCRIPT: PRACTICE			  
//========================================================
//================NPC INSTRUCTOR EIDOLON==================

poring_c01,101,108,5	script	Instructor Eidolon::eid_pract0	704,{
switch(teach_novice)
	{
		case 7:
			mes "[Eidolon]";
  					 mes "I will summon 10 monsters";
  					 mes "for you to uh... vanquish.";
  					 next;
  					 mes "[Eidolon]";
  					 mes "To attack a monster, simply";
			mes "left click on it repeatedly.";
  					 next;
  					 mes "[Eidolon]";
  					 mes "You can also use the ^0000FF/nc^000000 command";
  					 mes "which will allow you to uh...";
  					 mes "auto-attack after clicking";
  					 mes "your target once.";
  					 next;
  					 mes "^CC0000As he chants a summoning";
  					 mes "spell, you cannot help but feel";
  					 mes "slight anxiety due to being";
  					 mes "inexperienced in battle.^000000";
  				 areamonster "this",109,100,99,90,"Poring",1725,10,"eid_pract0::OnPKill";
			hideonnpc "eid_pract0";
			initnpctimer "eid_pract0";
  				 close2;
			set $PAmount, 10;
			end;
	}			
	OnPKill:
		set $PAmount, $PAmount - 1;
			if($PAmount == 0)
				{
				announce "Well done.",bc_npc,0xFFFF00;
				hideoffnpc "eid_pract0";
				areawarp "poring_c01",0,0,350,350, "poring_w02",77,87;
				stopnpctimer "eid_pract0";
				detachnpctimer "eid_pract0";
				set teach_novice, 8;
				}
				else
				{
				announce ""+ $PAmount +" porings left.",bc_npc,0xFFFF00;
				}
				end;

				OnTimer5000:
				announce "You have 2 minutes to complete the uh... task.",bc_npc,0xFFFF00;
				end;

				OnTimer100000:
					announce "1 minute left.",bc_npc,0xFFFF00;
					end;

				OnTimer200000:
					announce "Time's up.",bc_npc,0xFFFF00;
					killmonster "poring_c01","eid_pract0::OnPKill";
				OnPCDieEvent:
				OnPCLogoutEvent:
					if(!$PAmount) end; //We only want to run this if there are still Porings left over
					areawarp "poring_c01",0,0,350,350, "poring_w02",96,200;
					hideoffnpc "eid_pract0";
					stopnpctimer"eid_pract0";
					detachnpctimer "eid_pract0";
					end;
}

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...