Jump to content
  • 0

npc shop with menu


kommie

Question


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

I was trying to make a pet shop npc that had a menu like Pet Food, Pet Armor, Taming Items

And each area had the items. But I cant seem to figure out how to do that.

 

zhakastia, 123,69,4     script      Molly, Pet Shop  890,{

    mes .name$;
    mes "Hello!";
    mes "Would you like to look at the shop?";
    next;
    if(select("Pet Food:Pet Armor: Taming Items:Not Today") == 4) {
        close;

 

But Im not sure if this is correct or what to do next.

(I may of put this in the wrong area sorry)

Edited by kommie
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • -1

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  182
  • Reputation:   36
  • Joined:  01/26/12
  • Last Seen:  

According to what's on /doc/script_commands.txt

** Define a shop/cashshop NPC.

-%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}
<map name>,<x>,<y>,<facing>%TAB%shop%TAB%<NPC Name>%TAB%<sprite id>,<itemid>:<price>{,<itemid>:<price>...}

[...]

The item id is the number of item in the 'item_db.txt' database. If Price is set
to -1, the 'buy price' given in the item database will be used. Otherwise, the
price you gave will be used for this item, which is how you create differing
prices for items in different shops

 

So you'll have to proceed like this (shops only):

// Please add yourself the items you want to sell, last one doesn't need a comma
-	shop PetFoodShop	-1,item_id1:price1,item_id2:price2,(...),item_idN:priceN
-	shop PetArmorShop	-1,item_id1:price1,item_id2:price2,(...),item_idN:priceN
-	shop TamingItemsShop	-1,item_id1:price1,item_id2:price2,(...),item_idN:priceN

 

Hope I helped.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  182
  • Reputation:   36
  • Joined:  01/26/12
  • Last Seen:  

First of all: you're missing all closing curlies. Those missing curlies are errors, so I suggest you to automatically close them once you open a curly and then working on its inside. Then, you've never set the .name$ variable and that'll make you get more errors. Also, I'd better use a switch so you can easily control each of the cases in a menu with more than 2 options, like this:

zhakastia,123,69,4	script	Molly, Pet Shop	890,{
	mes "Molly, Pet Shop";
	mes "Hello!";
	mes "Would you like to look at the shop?";
	next;
	switch(select("Pet Food:Pet Armor:Taming Items:Not Today")) {
		case 1: // Pet Food
			// Whatever you want to do here, I suggest using callshop because that's what I understand you want
			break; // If you don't use break, then case 2 will also be run instead of directly finishing the switch statement
		case 2: // Pet Armor
			// Same thing as in case 1
			break; // If break is not present, case 3 will also be run
		case 3: // Taming Items
			// Same.
			break; // Same as the other breaks
		default: // Any other case not covered above. "Not today" in this example.
			mes "See you again!";
			// You don't need to break here
	}
	close; // This close statement will be run after all the switch statement
}

I'll let you finish your script with these directions /no1 .

Link to comment
Share on other sites


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

So it would be something like this? Also thank you for the reply

 

    zhakastia,123,69,4    script Molly, Pet Shop    890,{
    mes "Molly, Pet Shop";
    mes "Hello!";
    mes "Would you like to look at the shop?";
    next;
    switch(select("Pet Food:Pet Armor:Taming Items:Not Today")) {
    case 1: // Pet Food
    504:-1000,
    break;
    case 2: // Pet Armor
    10013:-1000,
    break; 
    case 3: // Taming Items
    12358:-5000000,
    break;
    default: // Any other case not covered above. "Not today" in this example.
    mes "See you again!";
    }
    close; 
    }

Edited by kommie
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:  

*callshop "<name>",<option>;

These are a series of commands used to create dynamic shops.

The callshop function calls a invisible shop (view -1) as if the player clicked on it.

For the options on callShop:

    0 = The normal window (buy, sell and cancel)

    1 = The buy window

    2 = The sell window

    

Example:

callshop "DaShop",1;    //Will call the shop named DaShop and opens the buy menu.

Callshop

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  182
  • Reputation:   36
  • Joined:  01/26/12
  • Last Seen:  

Well, I've restructured it a bit because I thought it'd be better. You needed to declare shops outside the script and then use callshop to call them on the script, just like the script I've written here:

zhakastia,123,69,4	script	Molly, Pet Shop	890,{
	mes "Molly, Pet Shop";
	mes "Hello!";
	mes "Would you like to look at the shop?";
	next;
	switch(select("Pet Food:Pet Armor:Taming Items:Not Today")) {
		case 1: // Pet Food
			mes "I'll open the Pet Food Shop for you";
			close2; // Closes the NPC dialog without ending the script
			callshop "PetFoodShop",1; // Only Sell window
			end; // We end the script just after opening the shop so no need to break
		case 2: // Pet Armor
			mes "I'll open the Pet Armor Shop for you";
			callshop "PetArmorShop",1;
			end;
		case 3: // Taming Items
			mes "I'll open the Taming Items Shop for you";
			callshop "TamingItemsShop",1;
			end;
		default: // Any other case not covered above. "Not today" in this example.
			mes "See you again!";
			close; // This statement closes and ends the script so no need to end again
	}
	// No need to close or end anything at this point
}

// Please add yourself the items you want to sell, last one doesn't need a comma
-	shop	PetFoodShop	-1,
-	shop	PetArmorShop	-1,
-	shop	TamingItemsShop	-1,

 

Now you only need to add the items you want to sell and their price on the shops at the end of the code.

Link to comment
Share on other sites


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

Thank you! I just make sure I got the correct I add the items i want after the -1 right? (its been ages since I scripted and this callshop is all new to me :x)

Sorry It took so long to see this and ask havent had net for a awhile.

Edited by kommie
Link to comment
Share on other sites


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

mkay I thought thats how It went but I just wanted to make sure. Thank You So Much for your help :D

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