Jump to content
  • 0

NPC only read first array listed


pajodex

Question


  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

Hi,

Can I get some help with my script. I wanted it to be that players will get some 'special item' at all maps listed in my array. Problem is, it only reads the first list in array which is 'moc_pryd06'

Here is my *noob* script:

 

-	script	#mvp_kill	-1,{
 
OnNPCKillEvent:
setarray .@t_maps$[0],"moc_pryd06","lhz_dun03","gld2_prt","abbey02","ayo_dun02","lhz_dun04","ra_fild02","xmas_fild01","dic_dun02","beach_dun","iz_dun05","tur_dun04","lhz_dun02","jupe_core","moc_fild22","anthell02","odin_tem03","lhz_dun03","gon_dun03","gef_fild02","thana_boss","gef_fild10","ein_dun02","gef_fild14","moc_pryd04","dew_dun01","in_sphinx5","niflheim","moc_fild17","xmas_dun02","ice_dun03","kh_dun02","treasure02","moc_prydn2","pay_dun04","ra_san05","mosk_dun03","ama_dun03","thor_v03","gef_dun01","mjolnir_04","abyss_03","dic_dun03","prt_sewb4","pay_fild11","gef_dun02","gl_chyard","ra_fild03","ra_fild04","ve_fild01","ve_fild02","lou_dun03","prt_maze03","bra_dun02";
	
if ( getmonsterinfo( killedrid, MOB_MVPEXP )) {
	if ( strcharinfo(3) == .@t_maps$[.@a] && rand(100) < 90 ) {
			if ( getcharid(1) ) {
				getpartymember getcharid(1), 1;
				getpartymember getcharid(1), 2;
				for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
					if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) { 
						.@partymemberaid[.@c] = $@partymemberaid[.@i];
						.@c++;
					}
				}
				getitem 30017, 1, .@partymemberaid[ rand( .@c ) ];
				announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and got reward at "+ strcharinfo(3), bc_all;
			}
			else {
				getitem 30017, 1;
				announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and got an MVP Badge at "+ strcharinfo(3), bc_all;
			}
		}
	else {
	if ( strcharinfo(3) == instance_mapname("06guild_01") ) end;
		if ( getcharid(1) ) {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" at "+ strcharinfo(3), bc_all;
		} else {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" alone at "+ strcharinfo(3), bc_all;
		}
	}
}

end;
}

 

Link to comment
Share on other sites

8 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

Still the same. Script only works at moc_pryd06. @Azrael-

Link to comment
Share on other sites

  • 0

  • Group:  Developer
  • Topic Count:  36
  • Topics Per Day:  0.01
  • Content Count:  587
  • Reputation:   431
  • Joined:  01/26/16
  • Last Seen:  

You also have to loop through the .@t_map$ array.

From 

	if ( strcharinfo(3) == .@t_maps$[.@a] && rand(100) < 90 ) {

.@a wasn't assigned before, so its value is 0, and the condition becomes strcharinfo(3) == .@t_map$[0] which compares the character's map with the first entry in .@t_map$.

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

56 minutes ago, Secrets said:

You also have to loop through the .@t_map$ array.

I changed it to 

if ( strcharinfo(3) == .t_maps$[0] && rand(100) < 90 ) {

Still the same :\ 

Sorry I tried reading in script_commands but it barely helped.

 

Edited by pajodex
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

@Secrets I modified my script and added the `loop thing`

-	script	#mvp_kill	-1,{

OnInit:
setarray .t_maps$[0],"moc_pryd06","lhz_dun03","gld2_prt","abbey02","ayo_dun02","lhz_dun04","ra_fild02","xmas_fild01","dic_dun02","beach_dun","iz_dun05","tur_dun04","lhz_dun02","jupe_core","moc_fild22","anthell02","odin_tem03","lhz_dun03","gon_dun03","gef_fild02","thana_boss","gef_fild10","ein_dun02","gef_fild14","moc_pryd04","dew_dun01","in_sphinx5","niflheim","moc_fild17","xmas_dun02","ice_dun03","kh_dun02","treasure02","moc_prydn2","pay_dun04","ra_san05","mosk_dun03","ama_dun03","thor_v03","gef_dun01","mjolnir_04","abyss_03","dic_dun03","prt_sewb4","pay_fild11","gef_dun02","gl_chyard","ra_fild03","ra_fild04","ve_fild01","ve_fild02","lou_dun03","prt_maze03","bra_dun02";
.@j = 0;
end;

OnNPCKillEvent:
if ( getmonsterinfo( killedrid, MOB_MVPEXP )) {
	for (.@a = 0; .@a < getarraysize(.t_maps$); .@a++) {
	if ( strcharinfo(3) == .t_maps$[.@a]  && rand(100) < 90 ) {
			if ( getcharid(1) ) {
				getpartymember getcharid(1), 1;
				getpartymember getcharid(1), 2;
				for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
					if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) { 
						.@partymemberaid[.@c] = $@partymemberaid[.@i];
						.@c++;
					}
				}
				getitem 30017, 1, .@partymemberaid[ rand( .@c ) ];
				announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and got reward at "+ strcharinfo(3), bc_all;
			}
			else {
				getitem 30017, 1;
				announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and got an MVP Badge at "+ strcharinfo(3), bc_all;
			}
		}
	else {
	if ( strcharinfo(3) == instance_mapname("06guild_01") ) end;
		if ( getcharid(1) ) {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" at "+ strcharinfo(3), bc_all;
		} else {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" alone at "+ strcharinfo(3), bc_all;
		}
	}
  }
end;
}
}

Works now, however, the announce part does this:

image.png.a984bbf0ff23cf2cdc4e809677c972d6.png

XD Sorry, I'm still learning

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 have x2 lhz_dun03 map in your list.
  • Note that some MVP already have a label (MVP in lhz_dun03 and lhz_dun04 for example).
OnNPCKillEvent:

This special label triggers when a player kills a monster without label.

 

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  78
  • Topics Per Day:  0.03
  • Content Count:  436
  • Reputation:   167
  • Joined:  12/12/17
  • Last Seen:  

24 minutes ago, Capuche said:
  • You have x2 lhz_dun03 map in your list.
  • Note that some MVP already have a label (MVP in lhz_dun03 and lhz_dun04 for example).

1. Removed 1 lhz_dun03

2. Where can I see the labels of those MVPs? Just wanna check it out. Or should I just completely remove OnNPCKillEvent on both lhz_dun03 and lhz_dun04 off the list to avoid conflicts

 

 

Here is my new code, its working as I wanted it to be. Thanks to @Secrets and @Nitrous(via discord) for the help

-	script	#mvp_kill	-1,{

OnInit:
setarray .t_maps$[0],"moc_pryd06","lhz_dun03","gld2_prt","abbey02","ayo_dun02","lhz_dun04","ra_fild02","xmas_fild01","dic_dun02","beach_dun","iz_dun05","tur_dun04","lhz_dun02","jupe_core","moc_fild22","anthell02","odin_tem03","gon_dun03","gef_fild02","thana_boss","gef_fild10","ein_dun02","gef_fild14","moc_pryd04","dew_dun01","in_sphinx5","niflheim","moc_fild17","xmas_dun02","ice_dun03","kh_dun02","treasure02","moc_prydn2","pay_dun04","ra_san05","mosk_dun03","ama_dun03","thor_v03","gef_dun01","mjolnir_04","abyss_03","dic_dun03","prt_sewb4","pay_fild11","gef_dun02","gl_chyard","ra_fild03","ra_fild04","ve_fild01","ve_fild02","lou_dun03","prt_maze03","bra_dun02";
end;

OnNPCKillEvent:
if ( getmonsterinfo( killedrid, MOB_MVPEXP )) {
	for (.@a = 0; .@a < getarraysize(.t_maps$); .@a++) {
	if ( strcharinfo(3) == instance_mapname("06guild_01") ) end;
	if ( strcharinfo(3) == instance_mapname("force_1-1") ) end;
	if ( strcharinfo(3) == .t_maps$[.@a] && rand(100) < 90 ) {
			if ( getcharid(1) ) {
				getpartymember getcharid(1), 1;
				getpartymember getcharid(1), 2;
				for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
					if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) { 
						.@partymemberaid[.@c] = $@partymemberaid[.@i];
						.@c++;
					}
				}
				getitem 30017, 1, .@partymemberaid[ rand( .@c ) ];
				//dispbottom "You got an MVP Badge!";
			}
			else {
				getitem 30017, 1;
				//dispbottom "You got an MVP Badge!";	
			}
		}
	}
	if ( getcharid(1) ) {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" at "+ strcharinfo(3), bc_all;
		} 
		else {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" alone at "+ strcharinfo(3), bc_all;
		}

	end;
	}
}

 

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   3
  • Joined:  11/14/17
  • Last Seen:  

-	script	#mvp_kill	-1,{
 
OnNPCKillEvent:
if ( getmonsterinfo( killedrid, MOB_MVPEXP )) {
	if ( strcharinfo(3) == .t_maps$ && rand(100) < 90 ) {
			if ( getcharid(1) ) {
				getpartymember getcharid(1), 1;
				getpartymember getcharid(1), 2;
				for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
					if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) { 
						.@partymemberaid[.@c] = $@partymemberaid[.@i];
						.@c++;
					}
				}
				getitem 30017, 1, .@partymemberaid[ rand( .@c ) ];
				announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and got reward at "+ strcharinfo(3), bc_all;
			}
			else {
				getitem 30017, 1;
				announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and got an MVP Badge at "+ strcharinfo(3), bc_all;
			}
		}
	else {
	if ( strcharinfo(3) == instance_mapname("06guild_01") ) end;
		if ( getcharid(1) ) {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" at "+ strcharinfo(3), bc_all;
		} else {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" alone at "+ strcharinfo(3), bc_all;
		}
	}
}

OnInit:
setarray .t_maps$[0],"moc_pryd06","lhz_dun03","gld2_prt","abbey02","ayo_dun02","lhz_dun04","ra_fild02","xmas_fild01","dic_dun02","beach_dun","iz_dun05","tur_dun04","lhz_dun02","jupe_core","moc_fild22","anthell02","odin_tem03","lhz_dun03","gon_dun03","gef_fild02","thana_boss","gef_fild10","ein_dun02","gef_fild14","moc_pryd04","dew_dun01","in_sphinx5","niflheim","moc_fild17","xmas_dun02","ice_dun03","kh_dun02","treasure02","moc_prydn2","pay_dun04","ra_san05","mosk_dun03","ama_dun03","thor_v03","gef_dun01","mjolnir_04","abyss_03","dic_dun03","prt_sewb4","pay_fild11","gef_dun02","gl_chyard","ra_fild03","ra_fild04","ve_fild01","ve_fild02","lou_dun03","prt_maze03","bra_dun02";
end;
}

 

Link to comment
Share on other sites

  • -1

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  23
  • Reputation:   3
  • Joined:  11/14/17
  • Last Seen:  

-	script	#mvp_kill	-1,{

OnInit:
setarray .t_maps$[0],"moc_pryd06","lhz_dun03","gld2_prt","abbey02","ayo_dun02","lhz_dun04","ra_fild02","xmas_fild01","dic_dun02","beach_dun","iz_dun05","tur_dun04","lhz_dun02","jupe_core","moc_fild22","anthell02","odin_tem03","lhz_dun03","gon_dun03","gef_fild02","thana_boss","gef_fild10","ein_dun02","gef_fild14","moc_pryd04","dew_dun01","in_sphinx5","niflheim","moc_fild17","xmas_dun02","ice_dun03","kh_dun02","treasure02","moc_prydn2","pay_dun04","ra_san05","mosk_dun03","ama_dun03","thor_v03","gef_dun01","mjolnir_04","abyss_03","dic_dun03","prt_sewb4","pay_fild11","gef_dun02","gl_chyard","ra_fild03","ra_fild04","ve_fild01","ve_fild02","lou_dun03","prt_maze03","bra_dun02";
end;

OnNPCKillEvent:
if ( getmonsterinfo( killedrid, MOB_MVPEXP ) && rand(100) < 90 ) {
	if ( strcharinfo(3) == .t_maps$ ) {
			if ( getcharid(1) ) {
				getpartymember getcharid(1), 1;
				getpartymember getcharid(1), 2;
				for ( .@i = 0; .@i < $@partymembercount; .@i++ ) {
					if ( isloggedin( $@partymemberaid[.@i], $@partymembercid[.@i] ) ) { 
						.@partymemberaid[.@c] = $@partymemberaid[.@i];
						.@c++;
					}
				}
				getitem 30017, 1, .@partymemberaid[ rand( .@c ) ];
				announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and got reward at "+ strcharinfo(3), bc_all;
			}
			else {
				getitem 30017, 1;
				announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and got an MVP Badge at "+ strcharinfo(3), bc_all;
			}
		}
	else {
	if ( strcharinfo(3) == instance_mapname("06guild_01") ) end;
		if ( getcharid(1) ) {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" at "+ strcharinfo(3), bc_all;
		} else {
		announce "[ System ] : Player ["+ strcharinfo(0) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" alone at "+ strcharinfo(3), bc_all;
		}
	}
}
end;
}

 

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