Jump to content
  • 0

NPC summon another NPC


luizinhomt

Question


  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  88
  • Reputation:   1
  • Joined:  01/05/13
  • Last Seen:  

Good evening everyone, could someone give an example of how I can make an NPC check if the player has 7 items defined in their inventory? If he has all the items, a cutin will appear and another NPC will appear. but the items will not be consumed by the first npc. In the second NPC he will check if he has the 7 items and a menu will appear to exchange these 7 items for another item. 

 the first npc will check if it has the necessary items if yes it will summon another npc, the second npc summoned will consume the items in exchange for another after completing the operation the summoned npc i.e. the second will disappear again

thank you all

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  132
  • Reputation:   53
  • Joined:  06/02/12
  • Last Seen:  

The player chooses one of the items? Or the NPC chooses one? The player receives multiple items?

geffen,151,48,5	script	First Person	1_M_LIBRARYMASTER,{
	//Put the IDs of the item below.
	setarray .@items, 909, 910, 911, 912, 913, 914, 915;

	if (isnpccloaked("Second Person") == 0) {
		npctalk "You can talk to him.", strnpcinfo(0), bc_self;
		end;
	}

	mes "[First Person]";
	mes "Hi, do you have all the items with you?";
	next;

	for (.@i=0;.@i< getarraysize(.@items);.@i++) {
		if (countitem(.@items[.@i]) < 1) {
			mes "[First Person]";
			mes "You don't have <ITEM>" + getitemname(.@items[.@i]) + "<INFO>" + .@items[.@i] + "</INFO></ITEM>.";
			close;
		}
	}

	mes "[First Person]";
	mes "You have everything. I will call him.";
	close2;
	cutin "war_y1", 2;
	cloakoffnpcself( "Second Person" );
	npctalk "Hello.", "Second Person", bc_self;
	end;
}

geffen,155,49,3	script	Second Person	4_M_FAIRYKID5,{
	//Put the IDs of the item below.
	setarray .@items, 909, 910, 911, 912, 913, 914, 915;

	//Put here the item IDs of the selection the player can choose from
	setarray .@reward, 714, 607, 12103;

	disable_items;
	mes "[Second Person]";
	mes "Hi, the first person told me you have the items.";
	
	if (getarraysize(.@reward) > 1) {
		mes "You can exchange them for one of these:";
		for (.@i=0;.@i< getarraysize(.@reward);.@i++)
			mes "- <ITEM>" + getitemname(.@reward[.@i]) + "<INFO>" + .@reward[.@i] + "</INFO></ITEM>";
		next;
		.@menu$ = "";
		for (.@i=0;.@i< getarraysize(.@reward);.@i++)
			.@menu$ += "- " + getitemname(.@reward[.@i]) + ":";
		.@s = select(.@menu$) - 1;
		mes "[Second Person]";
	}
	mes "Are you sure you want";
	mes "<ITEM>" + getitemname(.@reward[.@s]) + "<INFO>" + .@reward[.@s] + "</INFO></ITEM>?";
	next;
	if (select("No", "Yes, let's do this") == 1) {
		mes "[Second Person]";
		mes "I see.";
		close2;
		cutin "", 255;
		cloakonnpcself;
		end;
	}
	for (.@i=0;.@i< getarraysize(.@items);.@i++) {
		if (countitem(.@items[.@i]) < 1) {
			mes "[Second Person]";
			mes "You don't have <ITEM>" + getitemname(.@items[.@i]) + "<INFO>" + .@items[.@i] + "</INFO></ITEM>.";
			close2;
			cutin "", 255;
			cloakonnpcself;
			end;
		}
	}
	if ((MaxWeight - Weight) < 1000 || checkweight("Knife",1) == 0) {
		mes "^0000FF- You cannot continue due to your heavy weight. -^000000";
		close2;
		cutin "", 255;
		cloakonnpcself;
		end;
	}

	for (.@i=0;.@i < getarraysize(.@items);.@i++)
		delitem .@items[.@i], 1;

	getitem .@reward[.@s], 1;

	mes "[Second Person]";
	mes "Done.";	
	close2;
	cutin "", 255;
	cloakonnpcself;
	end;

OnInit:
	cloakonnpc;
	end;
}

 

  • Upvote 1
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  0
  • Topics Per Day:  0
  • Content Count:  132
  • Reputation:   53
  • Joined:  06/02/12
  • Last Seen:  

Good evening

Spoiler
geffen,151,48,5	script	First Person	1_M_LIBRARYMASTER,{
	//Put the IDs of the item below.
	setarray .@items, 909, 910, 911, 912, 913, 914, 915;

	if (isnpccloaked("Second Person") == 0) {
		npctalk "You can talk to him.", strnpcinfo(0), bc_self;
		end;
	}

	mes "[First Person]";
	mes "Hi, do you have all the items with you?";
	next;

	for (.@i=0;.@i< getarraysize(.@items);.@i++) {
		if (countitem(.@items[.@i]) < 1) {
			mes "[First Person]";
			mes "You don't have " + mesitemlink( .@items[.@i] ) + ".";
			close;
		}
	}

	mes "[First Person]";
	mes "You have everything. I will call him.";
	close2;
	cutin "war_y1", 2;
	cloakoffnpcself( "Second Person" );
	npctalk "Hello.", "Second Person", bc_self;
	end;
}

geffen,155,49,3	script	Second Person	4_M_FAIRYKID5,{
	//Put the IDs of the item below.
	setarray .@items, 909, 910, 911, 912, 913, 914, 915;

	//Put here the item the player will receive
	.@reward = 714;

	mes "[Second Person]";
	mes "Hi, the first person told me you have the items.";
	mes "Will you exchange them for the";
	mes mesitemlink( .@reward ) + "?";
	next;
	if (select("No", "Yes, let's do this") == 1) {
		mes "[Second Person]";
		mes "I see.";
		close2;
		cutin "", 255;
		cloakonnpcself;
		end;
	}
	for (.@i=0;.@i< getarraysize(.@items);.@i++) {
		if (countitem(.@items[.@i]) < 1) {
			mes "[Second Person]";
			mes "You don't have " + mesitemlink( .@items[.@i] ) + ".";
			close2;
			cutin "", 255;
			cloakonnpcself;
			end;

		}
	}
	if ((MaxWeight - Weight) < 1000 || checkweight("Knife",1) == 0) {
		mes "^0000FF- You cannot continue due to your heavy weight. -^000000";
		close2;
		cutin "", 255;
		cloakonnpcself;
		end;
	}

	for (.@i=0;.@i < getarraysize(.@items);.@i++)
		delitem .@items[.@i], 1;

	getitem .@reward, 1;

	mes "[Second Person]";
	mes "Done.";	
	close2;
	cutin "", 255;
	cloakonnpcself;
	end;

OnInit:
	cloakonnpc;
	end;
}

 

 

Edited by Racaae
correction
Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  88
  • Reputation:   1
  • Joined:  01/05/13
  • Last Seen:  

@Racaae Thank you very much for answering me, I am getting this error

You could do the trick of having the second NPC be able to exchange for more than one item like a quest UI where he will choose which of the items he wants to exchange for the necessary items.

erro1.png

Link to comment
Share on other sites

  • 0

  • Group:  Members
  • Topic Count:  27
  • Topics Per Day:  0.01
  • Content Count:  88
  • Reputation:   1
  • Joined:  01/05/13
  • Last Seen:  

Posted (edited)

Thank you very much, it was exactly what I needed!

Edited by luizinhomt
edit
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...