Jump to content
  • 0

Check party member if within the cell and in the map


Mutate

Question


  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  12
  • Reputation:   0
  • Joined:  04/12/21
  • Last Seen:  

Hi Everyone,

I'm trying to implement a condition

- if the party member is not within 14 cell of the mvp killer ( that player will not receive a point ) 

Thank you in advance

here is the part of my code 

OnNPCKillEvent:
	if( getgmlevel() >= 60 ) end; // if gm.. event wont trigger
	for (.@i = 0; .@i < getarraysize(.mvp_id); .@i += 3 ) {
		if( killedrid == .mvp_id[.@i] && compare( strcharinfo(3), .maps$[.@i/3] ) ) {
			.@solopoints = .mvp_id[.@i+1];
			.@partypoints = .mvp_id[.@i+2];
			if( .haltevent ) { // temporarily disable while giving away rewards to avoid bugs
				dispbottom "Event is still giving away rewards. This kill wont not recorded.", 0xff0000;
				end;
			}
			query_sql( "INSERT INTO `mvp_ladder_rank` SET `char_id`='"+ getcharid(0) +"', `name`='"+ strcharinfo(0) +"', `day_kills` = '1', `week_kills` = '1', `month_kills` = '1', `all_kills` = '1' ON DUPLICATE KEY UPDATE `day_kills` = `day_kills` + 1, `week_kills`=`week_kills` + 1, `month_kills` = `month_kills` + 1,`all_kills` = `all_kills` + 1" );
			if( !getcharid(1) ) {
				if(.Option&8 && rand(100) < .chance) 
				{
					.@annouce = true;
					for (.@p = 0; .@p < getarraysize(.solo_reward); .@p+=2)
						getitem .solo_reward[.@p], .solo_reward[.@p+1];
				}
				if(.Option&16) {
					#MVPPOINTS += .@solopoints;	
					dispbottom "You got "+ .@solopoints +" MVP Points. Total: "+ #MVPPOINTS;
				}	
				if ( .@annouce )
					announce "[ "+ strcharinfo(0) +" ] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and received an item.", bc_all;
				else
					announce "[ "+ strcharinfo(0) +" ] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" alone at "+ strcharinfo(3), bc_all;
			} else {
				if ( rand(100) < .chance )
					.@chance = true;
				if ( .@chance )
					announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and received an item.", bc_all;
				else
					announce "[ System ] : Player ["+ strcharinfo(0) +"] of party ["+ strcharinfo(1) +"] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" at "+ strcharinfo(3), bc_all;
				getpartymember getcharid(1), 1;
				getpartymember getcharid(1), 2;
				for ( .@q = 0; .@q < $@partymembercount; ++.@q ) {
					
					if ( isloggedin( $@partymemberaid[.@q], $@partymembercid[.@q] ) ) {
						.@count_online++;
						
						if(.Option&16) {
							attachrid $@partymemberaid[.@q];
							getmapxy ( @map$, @x, @y, BL_PC );
							if ( distance(.@x, .@y, @x, @y) > 15 || @map$ != .@map$ ) {
								#MVPPOINTS += .@solopoints;	
								dispbottom "You got "+ .@solopoints +" MVP Points. Total: "+ #MVPPOINTS;								
								if ( .@annouce ) 
									announce "[ "+ strcharinfo(0) +" ] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" and received an item.", bc_all;
								else
									announce "[ "+ strcharinfo(0) +" ] has killed "+ getmonsterinfo( killedrid, MOB_NAME ) +" alone at "+ strcharinfo(3), bc_all;
								
							}
							else 
							#MVPPOINTS += .@partypoints / $@partymembercount;
							dispbottom "--------------------------------------------";
							dispbottom "You got "+ (.@partypoints / $@partymembercount) +" MVP Points. Total: "+ #MVPPOINTS;
							dispbottom "--------------------------------------------";
							
							.@partymemberaid[.@c] = $@partymemberaid[.@q];
							++.@c;
							
						}
					}
					
				}
				if ( .Option&8 && .@chance ) {
					for (.@p = 0; .@p < getarraysize(.party_reward); .@p+=2)
						getitem .party_reward[.@p], .party_reward[.@p+1];
				}
			}
			end;
		}
	}
	end;

 

Link to comment
Share on other sites

3 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  68
  • Reputation:   8
  • Joined:  05/12/20
  • Last Seen:  

This script is not  complete... Post it full....

Anyway, for what i can see it is already set this way u want
 

if ( distance(.@x, .@y, @x, @y) > 15 || @map$ != .@map$ ) {

I dunno where  theses scope varibles came from but assuming its getmapxy from mvp killer, it  means the party member shouuld be on 14 cells distance and also in the same map (obviously)

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  3
  • Topics Per Day:  0.00
  • Content Count:  12
  • Reputation:   0
  • Joined:  04/12/21
  • Last Seen:  

13 hours ago, buraquera said:

This script is not  complete... Post it full....

Anyway, for what i can see it is already set this way u want
 


if ( distance(.@x, .@y, @x, @y) > 15 || @map$ != .@map$ ) {

I dunno where  theses scope varibles came from but assuming its getmapxy from mvp killer, it  means the party member shouuld be on 14 cells distance and also in the same map (obviously)

Unfortunately i cannot share the whole script

 

Link to comment
Share on other sites

  • 0

  • Group:  Forum Moderator
  • Topic Count:  93
  • Topics Per Day:  0.02
  • Content Count:  10013
  • Reputation:   2345
  • Joined:  10/28/11
  • Last Seen:  

OnNPCKillEvent:
	getmapxy(.@map$, .@x, .@y, BL_PC);   // <----- YOU MISSED OUT THIS LINE

 

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