Jump to content
  • 0

setup a npc that requires a party member


Question

Posted

hey guys,

 

is there a way to set a npc that it only will work if partymember a is talking to him and another party member must be very close to the npc so it will only trigger then?

 

i've seen something like this on ohmygods king of the hill script but could not recreate it ^^

 

thank you in advance!

7 answers to this question

Recommended Posts

  • 1
Posted
prontera,150,148,5	script	ghjklmkjh	58,{
	
	getmapxy .@map$, .@x, .@y, 0;
	if( !getcharid(1) ) {// must be in a party
		mes "you aren't in a party. GOood bye.";
		close;
	}
	else if( distance( .@x, .@y, .x_npc, .y_npc ) > .minimal_distance ) {// the player must be near to the npc
		mes "come near to me.";
		close;
	}
	getpartymember getcharid(1), 0;// get party member's name
	
	if( 2 > $@partymembercount ) {
		mes "you are alone in the party !";
		close;
	}
	while( .@i < $@partymembercount ) {
		if( getcharid( 0,$@partymembername$[.@i] ) && $@partymembername$[.@i] != strcharinfo(0) ) {// is online ?
			getmapxy .@map$, .@x, .@y, 0, $@partymembername$[.@i];// = x, y, map name
			if( distance( .@x, .@y, .x_npc, .y_npc ) <= .minimal_distance && .@map$ == .map_npc$ ) break;
		}
		set .@i, .@i + 1;
	}
	if( .@i == $@partymembercount )// none of them were close
		mes "another party member must be very close to me.";
	else
		mes "2 players of the same party are close to me. it's working !";
	close;
OnInit:
	getmapxy .map_npc$, .x_npc, .y_npc, 1;
	set .minimal_distance, 5;
	end;
}

You're right, take this one

Posted


prontera,150,148,5 script ghjklmkjh 58,{

getmapxy .@map$, .@x, .@y, 0;

if( !getcharid(1) ) {// must be in a party

mes "you aren't in a party. GOood bye.";

close;

}

else if( distance( .@x, .@y, .x_npc, .y_npc ) > .minimal_distance ) {// the player must be near to the npc

mes "come near to me.";

close;

}

getpartymember getcharid(1), 0;// get party member's name

if( !instance_check_party( getcharid(1),2 ) ) {// check also if other members are online - stop before the loop

mes "you are alone in the party !";

close;

}

while( .@i < $@partymembercount ) {

if( getcharid( 0,$@partymembername$[.@i] ) ) {// is online ?

getmapxy .@map$, .@x, .@y, 0, $@partymembername$[.@i];// = x, y, map name

if( distance( .@x, .@y, .x_npc, .y_npc ) <= .minimal_distance && .@map$ == .map_npc$ ) break;

}

.@i++;

}

if( .@i == $@partymembercount )// none of them were close

mes "another party member must be very close to me.";

else

mes "2 players of the same party are close to me. it's working !";

close;

OnInit:

getmapxy .map_npc$, .x_npc, .y_npc, 1;

.minimal_distance = 5;

end;

}

Posted (edited)


[Error]:  Loading NPC file: npc/custom/test3.txt
script error on npc/custom/test3.txt line 13
    parse_simpleexpr: unmatch ')'
     8 :        else if( distance( .@x, .@y, .x_npc, .y_npc ) > .minimal_distance ) {
     9 :                mes "come near to me.";
    10 :                close;
    11 :        }
    12 :        getpartymember getcharid(1), 0;
*   13 :        if(!instance_check_party'('getcharid(1),2)) {
 

 

thats the error i get could you please watch over this?

Edited by Breaker
Posted

You don't use rA.. try this

 

prontera,150,148,5	script	ghjklmkjh	58,{
	
	getmapxy .@map$, .@x, .@y, 0;
	if( !getcharid(1) ) {// must be in a party
		mes "you aren't in a party. GOood bye.";
		close;
	}
	else if( distance( .@x, .@y, .x_npc, .y_npc ) > .minimal_distance ) {// the player must be near to the npc
		mes "come near to me.";
		close;
	}
	getpartymember getcharid(1), 0;// get party member's name
	
	if( 2 > $@partymembercount ) {
		mes "you are alone in the party !";
		close;
	}
	while( .@i < $@partymembercount ) {
		if( getcharid( 0,$@partymembername$[.@i] ) ) {// is online ?
			getmapxy .@map$, .@x, .@y, 0, $@partymembername$[.@i];// = x, y, map name
			if( distance( .@x, .@y, .x_npc, .y_npc ) <= .minimal_distance && .@map$ == .map_npc$ ) break;
		}
		set .@i, .@i + 1;
	}
	if( .@i == $@partymembercount )// none of them were close
		mes "another party member must be very close to me.";
	else
		mes "2 players of the same party are close to me. it's working !";
	close;
OnInit:
	getmapxy .map_npc$, .x_npc, .y_npc, 1;
	set .minimal_distance, 5;
	end;
}
Posted

hey buddy that works thank you but its not checking if there is another member next to the npc like the one who is talking another member just must be online it doesnt matter where he stands

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