Jump to content
  • 0

Question

Posted

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;
		}

 

11 answers to this question

Recommended Posts

  • 1
Posted (edited)

 

-	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
  • 0
Posted
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

  • 0
Posted

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;

 

  • 0
Posted
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

  • 0
Posted
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? 

  • 0
Posted
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

  • 0
Posted
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 :))

  • 0
Posted
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!

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...