Jump to content
  • 0

setup a npc that requires a party member


Breaker

Question


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  35
  • Reputation:   0
  • Joined:  05/27/12
  • Last Seen:  

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!

Link to comment
Share on other sites

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

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

Link to comment
Share on other sites


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

that it only will work if partymember a is talking to him

Getcharid

 

 

hey guys,

 

another party member must be very close to the npc so it will only trigger then?

Use Getpartymember to get the account ID of the member.

Make a loop, attach the member of the party to the script with Attachrid  + check his distance with Getmapxy + Distance

  • Upvote 1
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  35
  • Reputation:   0
  • Joined:  05/27/12
  • Last Seen:  

um.. could you please make a easy example? tried mine but doesnt work

Link to comment
Share on other sites


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


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;

}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  35
  • Reputation:   0
  • Joined:  05/27/12
  • Last Seen:  


[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
Link to comment
Share on other sites


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

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;
}
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  13
  • Topics Per Day:  0.00
  • Content Count:  35
  • Reputation:   0
  • Joined:  05/27/12
  • Last Seen:  

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

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