Thread: Adding more realistic prices to your server- Matrix but could be easily used for more

Page 1 of 3 123 LastLast
Results 1 to 10 of 24
  1. #1 Adding more realistic prices to your server- Matrix but could be easily used for more 
    Donator

    Old Oak's Avatar
    Join Date
    May 2011
    Age
    26
    Posts
    1,552
    Thanks given
    544
    Thanks received
    435
    Rep Power
    189
    I was helping a friend do this with his NRS3server source and I thought this would be good to share with the community. This is a good idea because I think the cache's item prices are wack. Also, people were changing item's prices one by one and that just made me

    Credits to the developer of NRS3Server for the first few steps in this tutorial.

    Firstly, if you are already using the NRS3Server source, you do not need to do Steps 1 or 2, but to follow the tutorial exactly, you should change the name from getGEPrices to getTipitPrices.


    Step one

    Go to src>com>rs>cache>loaders>ItemDefinitions.java
    Then add all of this code into the class...
    Code:
    public int getTipitPrice() {
    		try {
    			for (String lines : FileUtilities.readFile("./data/items/tipit_dump.txt")) {
    				String[] data = lines.split(" - ");
    				if (Integer.parseInt(data[0]) == id) return Integer.parseInt(data[1]);
    			}
    		} catch (NumberFormatException e) {
    			e.printStackTrace();
    		} catch (IOException e) {
    			e.printStackTrace();
    		}
    		return -1;
    	}
    	
    	public static class FileUtilities {
    
    
    
    		public static final int BUFFER = 1024;
    
    
    
    		public static boolean exists(String name) {
    
    			File file = new File(name);
    
    			return file.exists();
    
    		}
    
    
    
    		public static ByteBuffer fileBuffer(String name) throws IOException {
    
    			File file = new File(name);
    
    			if(!file.exists())
    
    				return null;
    
    			FileInputStream in = new FileInputStream(name);
    
    
    
    			byte[] data = new byte[BUFFER];
    
    			int read;
    
    			try {
    
    				ByteBuffer buffer = ByteBuffer.allocate(in.available() + 1);
    
    				while ((read = in.read(data, 0, BUFFER)) != -1) {
    
    					buffer.put(data, 0, read);
    
    				}
    
    				buffer.flip();
    
    				return buffer;
    
    			} finally {
    
    				if (in != null)
    
    					in.close();
    
    				in = null;
    
    			}
    
    		}
    
    
    
    		public static void writeBufferToFile(String name, ByteBuffer buffer) throws IOException {
    
    			File file = new File(name);
    
    			if(!file.exists())
    
    				file.createNewFile();
    
    			FileOutputStream out = new FileOutputStream(name);
    
    			out.write(buffer.array(), 0, buffer.remaining());
    
    			out.flush();
    
    			out.close();
    
    		}
    
    
    
    		public static LinkedList<String> readFile(String directory) throws IOException {
    
    			LinkedList<String> fileLines = new LinkedList<String>();
    
    			BufferedReader reader = null;
    
    			try {
    
    				reader = new BufferedReader(new FileReader(directory));
    
    				String string;
    
    				while ((string = reader.readLine()) != null) {
    
    					fileLines.add(string);
    
    				}
    
    			} finally {
    
    				if (reader != null) {
    
    					reader.close();
    
    					reader = null;
    
    				}
    
    			}
    
    			return fileLines;
    
    		}
    
    
    
    	}
    Then add these imports if you don't already have them.

    Code:
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.FileReader;
    import java.io.IOException;
    import java.nio.ByteBuffer;
    import java.util.LinkedList;

    Step two

    Download this file: [Only registered and activated users can see links. ]

    Then, place that file in you Data>Items folder

    This is from sometime in August so its not too far away and contains all the items we use in matrix.



    Step Three


    Now go to src>com>rs>game>player>content>Shop.java

    Now, simply any time you see this
    Code:
    item.getDefinitions().getValue();
    change it to this
    Code:
    item.getDefinitions().getTipitPrice();

    And then you should be good to go, if you have any problems just leave a reply and I'll help you out.

    Tyluur gets credit for the tipit dump
    Reply With Quote  
     


  2. #2  
    Donator


    Join Date
    Jul 2012
    Age
    23
    Posts
    1,954
    Thanks given
    1,035
    Thanks received
    459
    Rep Power
    89
    Nice idea
    Reply With Quote  
     

  3. #3  
    Donator

    Old Oak's Avatar
    Join Date
    May 2011
    Age
    26
    Posts
    1,552
    Thanks given
    544
    Thanks received
    435
    Rep Power
    189
    Thanks
    Reply With Quote  
     

  4. #4  
    Banned

    Join Date
    Oct 2010
    Posts
    717
    Thanks given
    82
    Thanks received
    131
    Rep Power
    0
    So this will make the server read the prices off the txt file, instead of the cache?
    Reply With Quote  
     

  5. Thankful user:


  6. #5  
    Here we go again

    Lystuya's Avatar
    Join Date
    Sep 2011
    Posts
    2,739
    Thanks given
    1,149
    Thanks received
    906
    Discord
    View profile
    Rep Power
    667
    Nice. Might use.
    2012:
    [Only registered and activated users can see links. ]
    2013:
    [Only registered and activated users can see links. ]
    2020:
    ?
    Reply With Quote  
     

  7. #6  
    Strive for whats best.

    Chaz's Avatar
    Join Date
    Jul 2012
    Age
    25
    Posts
    2,506
    Thanks given
    376
    Thanks received
    613
    Rep Power
    170
    Nice luke!
    Reply With Quote  
     

  8. #7  
    Exoria
    Aksel's Avatar
    Join Date
    Jan 2012
    Age
    25
    Posts
    1,449
    Thanks given
    238
    Thanks received
    498
    Rep Power
    56
    Wont use this for its original purpose, but you gave me an idea
    Reply With Quote  
     

  9. #8  
    Registered Member

    Join Date
    Dec 2012
    Posts
    3,006
    Thanks given
    899
    Thanks received
    929
    Rep Power
    2548
    Great release, not going to use though
    Reply With Quote  
     

  10. #9  
    [MLP]
    My Little Pony's Avatar
    Join Date
    Aug 2012
    Posts
    316
    Thanks given
    32
    Thanks received
    25
    Rep Power
    10
    I use a method like this to two other similar things.
    Nice release.
    Reply With Quote  
     

  11. #10  
    touched like seafood
    Tyluur's Avatar
    Join Date
    Jun 2010
    Age
    23
    Posts
    4,836
    Thanks given
    1,676
    Thanks received
    1,563
    Discord
    View profile
    Rep Power
    1386
    I created that dump and sold a service to somebody for it. This isn't yours to release, at least give me credits.

    I'm still laughing at the FileUtilities class in ItemDefinitions. I did that cause I was lazy.
    [Only registered and activated users can see links. ] | [Only registered and activated users can see links. ] | [Only registered and activated users can see links. ] (official dog of rune-server)
    Quote Originally Posted by blakeman8192 View Post
    Keep trying. Quitting is the only true failure.
    Reply With Quote  
     

  12. Thankful user:


Page 1 of 3 123 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. Replies: 11
    Last Post: 12-21-2012, 06:44 PM
  2. Any realistic server?
    By Kaligrok in forum Help
    Replies: 1
    Last Post: 04-01-2010, 08:41 AM
  3. Changing prices of server and adding items.
    By Rebels str in forum Help
    Replies: 4
    Last Post: 12-24-2009, 08:54 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •