Jump to content
  • 0

OnPcDieEvent in instances


ToiletMaster

Question


  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  276
  • Reputation:   7
  • Joined:  08/11/12
  • Last Seen:  

Hi Guys,

i've been trying to figure out this for quite sometime but after searching around and tinkering around i just can't seem to find out where is the issue here.

this works outside of the instance but within the instance, i get a weird error from the console

(map_mapname2mapid) mapindex_name2id: Map "" not found in index list!

I'm not sure how it works since it's kinda my first time using OnPcDieEvent in instances. Would appreciate if someone could point me to the right direction! Generally what I'm trying to achieve is that once you go in and die 3 times, your entire party should automatically get warped out.

 

-	script	Controller	-1,{
	OnPcDieEvent:
		if(instance_mapname(strcharinfo(3)) != instance_mapname("instance") ){end;}
		if(.chance == 3){ mapwarp instance_mapname("instance"),"prontera",150,150; end;}
		
		.chance++;
		mapannounce strnpcinfo(4),strcharinfo(0)+" has died! you only have "+(3 - .chance)+" lives remaining.",bc_all;
		end;
		}

 

Link to comment
Share on other sites

11 answers to this question

Recommended Posts

  • 1

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

 

-	script	Controller	-1,{
OnPcDieEvent:
	if (strcharinfo(3) == instance_mapname("geffen")) {
		'chance++;
		if ('chance == 3)
			mapwarp instance_mapname("geffen"),"prontera",150,150;
		else
			mapannounce instance_mapname("geffen"), "" + strcharinfo(0) + " has died! you only have " + (3 - 'chance) + " lives remaining.", bc_all;
	}
	end;
}

should work.

 

About the script with the timer : forget it. After reading the commit, https://github.com/rathena/rathena/commit/9c46f3e6ba288c71f098b12834ea25779eadbc0e just prevent to duplicate npcs with script event in instance.

 

Notes:

- strcharinfo(3) return the real map name of the player.

- instance_mapname doc :

If no instance ID is specified,
the instance the script is attached to is used. If the script is not attached to
an instance, the instance of the currently attached player is used (if it is a
character, party, guild or clan mode).

Within your OnPCDieEvent instance_mapname will use by default the instance id attached to the player.

 

EDIT: @crazyarashi please double check your script before posting!

Edited by Capuche
  • Upvote 1
  • MVP 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

19 minutes ago, ToiletMaster said:

Hi Guys,

i've been trying to figure out this for quite sometime but after searching around and tinkering around i just can't seem to find out where is the issue here.

this works outside of the instance but within the instance, i get a weird error from the console


(map_mapname2mapid) mapindex_name2id: Map "" not found in index list!

I'm not sure how it works since it's kinda my first time using OnPcDieEvent in instances. Would appreciate if someone could point me to the right direction! Generally what I'm trying to achieve is that once you go in and die 3 times, your entire party should automatically get warped out.

 


-	script	Controller	-1,{
	OnPcDieEvent:
		if(instance_mapname(strcharinfo(3)) != instance_mapname("instance") ){end;}
		if(.chance == 3){ mapwarp instance_mapname("instance"),"prontera",150,150; end;}
		
		.chance++;
		mapannounce strnpcinfo(4),strcharinfo(0)+" has died! you only have "+(3 - .chance)+" lives remaining.",bc_all;
		end;
		}

 

Following because I  am working with instances right now and will need this

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

  • 0

  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  276
  • Reputation:   7
  • Joined:  08/11/12
  • Last Seen:  

1 hour ago, Capuche said:

 

if that were really the case, would there be any alternatives on how to be able to do the same thing? :o

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

You can, for example, attach a timer to the character.


	@instance_map$ = instance_mapname("instance");
	deltimer strnpcinfo(0) + "::OnAtcommand4";
	addtimer 300, strnpcinfo(0) + "::OnAtcommand4";
	end;

OnAtcommand4:
	if (strcharinfo(3) != @instance_map$) {
		@instance_map$ = "";
		end;
	}
	addtimer 300, strnpcinfo(0) + "::OnAtcommand4";
	if (Hp < 1) {
		'chance++;	// 'var attached to the instance
		if ('chance == 3)
			mapwarp @instance_map$,"prontera",150,150;
		else {
			mapannounce @instance_map$, strcharinfo(0) + " has died! you only have " + (3 - 'chance) + " lives remaining.",bc_all;
			recovery 0;
		}
	}
	end;

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

7 hours ago, ToiletMaster said:

Hi Guys,

i've been trying to figure out this for quite sometime but after searching around and tinkering around i just can't seem to find out where is the issue here.

this works outside of the instance but within the instance, i get a weird error from the console


(map_mapname2mapid) mapindex_name2id: Map "" not found in index list!

I'm not sure how it works since it's kinda my first time using OnPcDieEvent in instances. Would appreciate if someone could point me to the right direction! Generally what I'm trying to achieve is that once you go in and die 3 times, your entire party should automatically get warped out.

 


-	script	Controller	-1,{
	OnPcDieEvent:
		if(instance_mapname(strcharinfo(3)) != instance_mapname("instance") ){end;}
		if(.chance == 3){ mapwarp instance_mapname("instance"),"prontera",150,150; end;}
		
		.chance++;
		mapannounce strnpcinfo(4),strcharinfo(0)+" has died! you only have "+(3 - .chance)+" lives remaining.",bc_all;
		end;
		}

 

That's because instance_mapname () needs two parameters unless it's within the instance itself... which this npc is not...

So...

Instance_mapname ("instance", @instance_id) assuming the player has it stored on them... should work :D

Both instance_mapname () need to have ID because this event is not attached to the instance itself

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  276
  • Reputation:   7
  • Joined:  08/11/12
  • Last Seen:  

14 hours ago, Capuche said:

You can, for example, attach a timer to the character.



	@instance_map$ = instance_mapname("instance");
	deltimer strnpcinfo(0) + "::OnAtcommand4";
	addtimer 300, strnpcinfo(0) + "::OnAtcommand4";
	end;

OnAtcommand4:
	if (strcharinfo(3) != @instance_map$) {
		@instance_map$ = "";
		end;
	}
	addtimer 300, strnpcinfo(0) + "::OnAtcommand4";
	if (Hp < 1) {
		'chance++;	// 'var attached to the instance
		if ('chance == 3)
			mapwarp @instance_map$,"prontera",150,150;
		else {
			mapannounce @instance_map$, strcharinfo(0) + " has died! you only have " + (3 - 'chance) + " lives remaining.",bc_all;
			recovery 0;
		}
	}
	end;

 

Thanks for the alternative! I'll give this a try and see if this is possible tonight. 

12 hours ago, Z3R0 said:

That's because instance_mapname () needs two parameters unless it's within the instance itself... which this npc is not...

So...

Instance_mapname ("instance", @instance_id) assuming the player has it stored on them... should work :D

Both instance_mapname () need to have ID because this event is not attached to the instance itself

That's interesting! I wasn't aware of that too! I'll give this a try as well and see if that works. Though generally since onPCDieEvent is a global call, I guess would it make sense to attach timers on their players itself like Capuche mentioned? 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  276
  • Reputation:   7
  • Joined:  08/11/12
  • Last Seen:  

17 hours ago, Capuche said:

You can, for example, attach a timer to the character.



	@instance_map$ = instance_mapname("instance");
	deltimer strnpcinfo(0) + "::OnAtcommand4";
	addtimer 300, strnpcinfo(0) + "::OnAtcommand4";
	end;

OnAtcommand4:
	if (strcharinfo(3) != @instance_map$) {
		@instance_map$ = "";
		end;
	}
	addtimer 300, strnpcinfo(0) + "::OnAtcommand4";
	if (Hp < 1) {
		'chance++;	// 'var attached to the instance
		if ('chance == 3)
			mapwarp @instance_map$,"prontera",150,150;
		else {
			mapannounce @instance_map$, strcharinfo(0) + " has died! you only have " + (3 - 'chance) + " lives remaining.",bc_all;
			recovery 0;
		}
	}
	end;

 

Hi Capuche,


I've tested this and for some reason it doesn't seem to work, i've changed the parameters and set the npc to give the timer but unfortunately it doesn't seem to work for some reason, it doesn't do any count upon dying

 

14 hours ago, Z3R0 said:

That's because instance_mapname () needs two parameters unless it's within the instance itself... which this npc is not...

So...

Instance_mapname ("instance", @instance_id) assuming the player has it stored on them... should work :D

Both instance_mapname () need to have ID because this event is not attached to the instance itself

Suprisingly i've tested this as well and it doesn't seem to work for some reason, i've added my instance ID in together with the name of the map but unfortunately it doesn't work either, is it possible if you could where it went wrong?

 

-	script	Controller	-1,{
	
	OnPcDieEvent:
		if(instance_mapname(strcharinfo(3)) != instance_mapname("map_name",100) ){end;}
		if(.chance == 3){ mapwarp instance_mapname("map_name",100),"prontera",150,150; end;}
		
		.chance++;
		mapannounce strnpcinfo(4),strcharinfo(0)+" has died! you only have "+(3 - .chance)+" lives remaining.",bc_all;
		end;
		}		

my instance ID in the instance_db is 100, i've set that here and it doesn't work, alternatively i've tried with the name of the instance as well but it doesn't work either

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  50
  • Topics Per Day:  0.02
  • Content Count:  763
  • Reputation:   227
  • Joined:  02/11/17
  • Last Seen:  

prontera,255,55,5	test123	445,{
OnStart:
set .@party_id, getcharid(1); //add this
}


-	script	Controller	-1,{
	
OnPcDieEvent:	
	if(.@party_id == !instance_mapname(".map$",100){ 
	end;
	} else {
	mapannounce strnpcinfo(4),strcharinfo(0)+" has died! you only have "+(3 - .chance)+" lives remaining.",bc_all;
	.chance++;
	end;
	}
	if(.chance == .maxlives$){ 
	mapwarp "instance_mapname(".map$")","prontera",<255>,<55>{,2,.@party_id};
	end;
	}

	
	

OnInit:
	set .map$,"map_name";
	set .maxlives$,3;
	
}
	

try this :))

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  76
  • Topics Per Day:  0.02
  • Content Count:  276
  • Reputation:   7
  • Joined:  08/11/12
  • Last Seen:  

1 hour ago, Capuche said:

 


-	script	Controller	-1,{
OnPcDieEvent:
	if (strcharinfo(3) == instance_mapname("geffen")) {
		'chance++;
		if ('chance == 3)
			mapwarp instance_mapname("geffen"),"prontera",150,150;
		else
			mapannounce instance_mapname("geffen"), "" + strcharinfo(0) + " has died! you only have " + (3 - 'chance) + " lives remaining.", bc_all;
	}
	end;
}

should work.

 

About the script with the timer : forget it. After reading the commit, https://github.com/rathena/rathena/commit/9c46f3e6ba288c71f098b12834ea25779eadbc0e just prevent to duplicate npcs with script event in instance.

 

Notes:

- strcharinfo(3) return the real map name of the player.

- instance_mapname doc :


If no instance ID is specified,
the instance the script is attached to is used. If the script is not attached to
an instance, the instance of the currently attached player is used (if it is a
character, party, guild or clan mode).

Within your OnPCDieEvent instance_mapname will use by default the instance id attached to the player.

 

EDIT: @crazyarashi please double check your script before posting!

Tested and working perfectly! Thank you very much for the help!

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  39
  • Topics Per Day:  0.01
  • Content Count:  615
  • Reputation:   201
  • Joined:  11/09/11
  • Last Seen:  

Ah there we go thanks @crazyarashi nice call...

Link to comment
Share on other sites

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.

×
×
  • Create New...