Thread: [PI - Beginners] Shops and Prices

Page 1 of 2 12 LastLast
Results 1 to 10 of 20
  1. #1 [PI - Beginners] Shops and Prices 
    Registered Member Game Developer's Avatar
    Join Date
    Sep 2011
    Posts
    70
    Thanks given
    2
    Thanks received
    5
    Rep Power
    11
    Purpose: Creating an entire new shop
    Difficulty: 1-2/10
    Assumed Knowledge: How to open .cfg and .java files, Finding Item ID's
    Files Modified/Used: .txt, .cfg and .java
    Tested On(if it applies): PI
    Last Updated: 25 Sept 2011
    Status: COMPLETE

    Note that this a total beginner guide, if you already know all of this dont start flaming its nubish >.<!
    Dont copy and paste everything! Try to understand what it all means!

    Spoiler for Click here to open the tutorial:
    Introduction:
    After having alot of trouble myself finding out how create a new shop I decided to make a clear tutorial myself. I am making this tutorial because i couldn't find any good tutorial on these forums myself.
    Note that this tutorial will only work on a PI (Project Insanity) server.

    Ok lets get started!
    If you want to make a shop yourself you would have to do 6 things:
    --1-- Find a non-combat NPC (with 0 combat and health etc).
    --2-- Spawn the NPC to the location of your choice.
    --3-- Create the shop itself.
    --4-- Adding items to the shop
    --5-- Make the NPC open the shop if you click on him.
    --6-- Changing the prices.
    --7-- Compile & Testing!
    --EXTRA-- How to make it a points-shop.

    --1-- FINDING A NON-COMBAT NPC
    Open your source. Most of the time you can find a NPC-list in here: Source -> Data -> cfg. If you cant find return to your source and press CTRL+F, search for "npc". When you are in here look for a file called npc.cfg. Open it in your notepad

    You will now see a large list of all monsters and NPC's in your source. If there are two 0's behind it means this NPC has a combat level of 0 and has 0 hitpoints.
    Example:
    npc = 209 Nulodion 0 0
    npc = 210 Grail_Maiden 0 0
    npc = 211 Sir_Percival 0 0
    npc = 212 King_Percival 0 0
    npc = 213 Merlin 0 0
    npc = 214 Peasant 0 0
    npc = 215 Peasant 0 0
    npc = 216 High_Priest 0 0
    npc = 217 Crone 0 0
    npc = 218 Galahad 0 0
    npc = 219 Fisherman 0 0
    npc = 220 The_Fisher_King 0 0
    If you found yourself a suitable NPC for your shop you have to remember the NPC-ID standing before the NPC's name. If you arent good in remembering things write it down somewhere! As an example for this tutorial I will use the NPC 213, Merlin.

    --2-- SPAWNING THE NPC TO THE LOCATION OF YOUR CHOICE
    Open your source. Most of the time you can find the "spawn-config.cfg" in here: Source -> Data -> cfg. If you cant find it, return to your source and press CTRL+F, search for "spawn"

    Open the file spawn-config.cfg. You will see once again a large list of all the monsters and NPC's that are spawned as soon as you log in.
    starting from left to right: first you will see the ID of the NPC that has to be spawned, follow by the x-coords and the y-coords of where the NPC has to be spawned on the map. Example:
    NPC ID - x-coords - y-coords-height-walk-maxhit-attack-defence-description.
    spawn = 36 3083 3495 0 0 0 0 0 0 Wyson_the_Gardener
    spawn = 213 3083 3496 0 0 0 0 0 0 Merlin
    After that you will see five 0's and a name which mean the following
    In this case they are all 0, because his height is normal, he cant walk, his max hit is 0, his attack is 0 and his defence is 0.

    Enter your own spawn here like this:
    spawn = NPC-ID 3083 3496 0 0 0 0 0 0 Description
    NPC-ID= your NPC ID
    If you use the x and y-coords I use in my example above, the NPC will spawn in the middle of Edgeville.

    Thats it for the spawning!


    --3-- CREATING THE SHOP ITSELF
    Open your source. Most of the time you can find the "shops.cfg" file in here: Source -> Data -> cfg. If you cant find it, return to your source and press CTRL+F, search for "shops" or "shop".

    You will see a list of all the shops you have in your source.
    Example:
    shop = 6 Armor_Store 2 2
    To create your own shop, look for a SHOP-ID that has not been used yet, I will use the SHOP-ID 6 as an example for this tutorial.

    In my shop above you will see from left to right: SHOP-ID, Name of the Shop, two 2's. The two 2's stand for if you can sell and buy to this shop.
    Make one yourself now. Again, make sure you use an ID that has not been used yet!

    --4-- ADDING ITEMS TO THE SHOP
    Adding items to a shop is very simpel, the only thing you need to know is the ID of the item you want to add to the shop.
    To look up the ID of an item go to Source -> Data -> Item. If you cant find it, return to your source and press CTRL+F, search for "item" or "items".
    If you found yourself the ID of the item you want to add to your shop, paste it behind your shop in the shops.cfg file, following by the ammount the shop has of this item, like this:
    shop = 6 Armor_Store 2 2 1127 50
    In this case I have added the ID of a rune platebody with the quanty of 50

    If you want to add more items to the shop, simply paste the next item ID behind the ammount of the previous item, like this:
    shop = 6 Armor_Store 2 2 1127 50 1079 50
    1079 = rune platelegs.


    --5-- MAKE THE NPC OPEN THE SHOP IF YOU CLICK ON HIM
    Open your source. Most of the time you can find the "ActionHandler.java" file in here: Source -> src -> server -> model -> players. If you cant find it, return to your source and press CTRL+F, search for "action".

    Open the actionhandler.java and press CTRL+F, search for "c.getShops().openShop" (just copy and paste from here).
    Keep looking until you find a piece of code thats looks like this:
    case 6750:
    c.getShops().openShop(77);
    break;

    case 2830:
    c.getShops().openShop(73);
    c.sendMessage("You currently have " + c.pkPoints + " points.");
    break;

    case 5030:
    c.getShops().openShop(74);
    c.sendMessage("You currently have " + c.pkPoints + " points.");
    break;

    case 1294:
    c.getShops().openShop(72);
    break;
    To add your own shop action typ the following:
    case NPC ID:
    c.getShops().openShop(SHOP ID);
    break;
    Enter the ID of your NPC and the ID of your shop on the right places.
    In my case this would be:
    case 213:
    c.getShops().openShop(6);
    break;
    --6-- CHANGING THE PRICES
    Open your source. Most of the time you can find the "prices.txt" in here: Source -> Data -> cfg. If you cant find it, return to your source and press CTRL+F, search for "prices.txt"

    When you have opened the file you will see a very long list with all the item ID's and the prices behind them. Saying this we are almost done already!
    Search the ID of the item you want to change price of and edit the number behind it to the price you want it to be!

    --7-- COMPILE AND TEST

    Make sure you save and close all windows you have opened and turn off your server. Look for the compiler in your source file and start compilen. If you find any errors post it on this thread and I or someone else will help you as soon as possible! Close the compiler correctly and test your shop in game!

    EXTRA - HOW TO MAKE IT A POINTS SHOP
    (NOT FINISHED YET)

    Open your source. Most of the time you can find the "shopassistant.java" in here: Source -> src -> server-> model -> shops. If you cant find it, return to your source and press CTRL+F, search for "shopassistant.java".

    When you open your file, you will see all the assistant a shop needs, such as letting you know how much an item is worth. That is what we are going to change first. A normal shop will tell you "This item current costs 20000 coins.", or something like that. We want it to become something like this: "This item current costs 10 (slayer/pking) points."

    Press CTRL + F and search for:
    public void buyFromShopPrice
    You should see codes that look like this:
    if (c.myShopId == 1) {
    c.sendMessage(c.getItems().getItemName(removeId)+" : currently costs " + getSpecialItemValue(removeId) + " slayer points.");
    return;
    }
    if (c.myShopId == 2) {
    c.sendMessage(c.getItems().getItemName(removeId)+" : currently costs " + getSpecialItemValue(removeId) + " PK points.");
    return;
    }
    We are going to make the exact same "if statement".
    I want the shop I used as an example in this tutorial to become a Slayer Points shop.

    First im going to explain what this piece of code meens:
    if (c.myShopId == 213) {
    c.sendMessage(c.getItems().getItemName(removeId)+": currently costs " + getSpecialItemValue(removeId) + " Slayer Points.");
    return;
    }
    This is the "if" statement that checks if you are using the right shop to continue reading the piece of code between the brackets( { and } ).
    Enter your SHOP-ID here, in my case, this is 213.
    The codes between the open ( { ) and close ( } ) brackets will be executed if the "if statement" is correct.
    A variable thats sends the message between the two " to the players chatbox.
    Gets the name of item you are checking the price from.
    Gets the price of the item in points, which we willbe making soon.
    Plain text that is send to the players chatbox

    Now thats done, create your own "if statement"!


    The next part we will be doing is making the shop an actual points shop. Still in the same file, look for "handleOtherShop(itemID)" with CTRL + F.
    You should see a piece of code that looks like this:
    if (c.myShopId == 1)
    {
    handleOtherShop(itemID);
    return false;
    }
    if (c.myShopId == 2)
    {
    handleOtherShop(itemID);
    return false;
    }
    This is also a piece of code that checks if the SHOP-ID is correct, simply copy and paste the statement below it and change the number to your SHOP-ID, in my case, this is 213. Make sure you paste the statement below or after the closing bracket of the statement above it!


    The next part is giving each singel item in the shop its own price. Still in the same file, look for "public int getSpecialItemValue" with CTRL + F.
    You will see a list of cases and returns. The numbers after the cases are the item id's, and the numbers after the returns are the prices of the items in points.
    If I would like to have my item 1079 (Rune Platelegs) have a price of 10 points, it would look like this:
    case 1079:
    return 10;
    Always place a " : " after the case number and a " ; " after the price.

    It is also possible to place multiple cases before a return, like this:
    case 1127:
    case 1079:
    return 10;
    This will safe you time and space. All the cases above the return now have the same price, which is 10, in my case.

    Safe and close shopassistant.java and use the compiler while your server is offline. Now log in and check your shop in game!



    IF THIS TUTORIAL HELPED YOU OUT A THANKS AND REP WOULD BE VERY NICE! GOOD LUCK!
    I offer free helping services to beginner Java, C#, CSS, HTML, PHP and Mysql programmers!
    If I helped you Then please Rep/Thank
    Reply With Quote  
     

  2. Thankful users:


  3. #2  
    Registered Member

    Join Date
    Sep 2011
    Posts
    1,140
    Thanks given
    385
    Thanks received
    398
    Rep Power
    474
    Quote Originally Posted by Game Developer
    Files Modified/Used: .txt, .cfg and .java
    I think it means actual files. (shops.cfg, etc)
    Reply With Quote  
     

  4. #3  
    Austin_
    Guest
    Nice tutorial and btw, you don't need to compile to edit a config file. But yeah, nice job.
    Reply With Quote  
     

  5. #4  
    Extreme Donator

    Jilic-Matt's Avatar
    Join Date
    May 2011
    Age
    29
    Posts
    1,612
    Thanks given
    799
    Thanks received
    494
    Rep Power
    540
    Quote Originally Posted by Austin_ View Post
    Nice tutorial and btw, you don't need to compile to edit a config file. But yeah, nice job.
    yeh tru u just need to reload the server good job tho this is handy and alot of info for the extremely new guys to rsps
    Reply With Quote  
     

  6. #5  
    Registered Member
    Tamatea's Avatar
    Join Date
    Aug 2010
    Posts
    1,317
    Thanks given
    401
    Thanks received
    357
    Rep Power
    2457
    nice tut enjoyed your effort. Although this is common knowledge, good for beginners i guess.
    Spoiler for sig too large:


    Attached image
    Attached image
    Reply With Quote  
     

  7. #6  
    q.q


    Join Date
    Dec 2010
    Posts
    6,519
    Thanks given
    1,072
    Thanks received
    3,535
    Rep Power
    4752
    Nice Effort
    Reply With Quote  
     

  8. #7  
    Registered Member Game Developer's Avatar
    Join Date
    Sep 2011
    Posts
    70
    Thanks given
    2
    Thanks received
    5
    Rep Power
    11
    Thanks guys, I will add the final part about making it a points shop when I get home from work in about errm.. 2,5 houres!
    I offer free helping services to beginner Java, C#, CSS, HTML, PHP and Mysql programmers!
    If I helped you Then please Rep/Thank
    Reply With Quote  
     

  9. #8  
    Registered Member Aleksandr's Avatar
    Join Date
    Sep 2006
    Age
    33
    Posts
    1,034
    Thanks given
    455
    Thanks received
    134
    Rep Power
    74
    Very nice tutorial, now this is a real tutorial...
    Al
    Attached image

    There is no RL, just AFK
    Reply With Quote  
     

  10. #9  
    Banned
    Join Date
    Aug 2011
    Posts
    396
    Thanks given
    66
    Thanks received
    14
    Rep Power
    0
    Good for new people
    Reply With Quote  
     

  11. #10  
    Registered Member Game Developer's Avatar
    Join Date
    Sep 2011
    Posts
    70
    Thanks given
    2
    Thanks received
    5
    Rep Power
    11
    Quote Originally Posted by ownerinsane View Post
    Good for new people
    Thank you
    I offer free helping services to beginner Java, C#, CSS, HTML, PHP and Mysql programmers!
    If I helped you Then please Rep/Thank
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Shops Prices
    By myK- in forum Help
    Replies: 2
    Last Post: 01-18-2011, 05:00 AM
  2. PI shops prices explanation
    By Chris SS in forum Requests
    Replies: 0
    Last Post: 10-13-2010, 04:13 AM
  3. [pi] shops prices?
    By Ninja assassin in forum Help
    Replies: 5
    Last Post: 09-21-2010, 10:22 PM
  4. [508] Item names and Prices in Shops
    By Whiz` in forum Tutorials
    Replies: 16
    Last Post: 06-19-2010, 07:20 PM
  5. shops prices
    By devildreams54 in forum Help
    Replies: 6
    Last Post: 06-24-2009, 11:09 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •