Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • SantaHoHo: you wont regret when u join really nice server
      December 10, 2019, 06:35:18 PM
    • SantaHoHo: need staff :)
      December 10, 2019, 06:35:08 PM
    • SantaHoHo: divinescape.eu5.org
      December 10, 2019, 06:35:00 PM
    • SantaHoHo:[link]
      December 10, 2019, 06:34:39 PM
    • Moneyking800: Yanille is back! We’re in beta looking for new players. We are small around 5-10 players on at anytime atm looking for active testers to build off of! Yanille-os.com
      December 10, 2019, 06:14:45 PM
    • drubrkletern: be honest with me boss
      December 06, 2019, 01:31:52 AM
    • drubrkletern: now is it really that unique
      December 06, 2019, 01:31:47 AM
    • SuperNativeZ: COME PLAY THE MOST UNIQUE CUSTOM RSPS #1 [link][link][link]
      December 05, 2019, 09:22:55 PM
    • SuperNativeZ: FASTEST GROWING #1 UNIQUE CUSTOM RSPS [link][link][link]
      December 05, 2019, 09:22:42 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 60+ online : [link]
      December 05, 2019, 02:48:39 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 40+ online : [link]
      December 05, 2019, 02:48:31 PM
    • Cole1497: you click any of these links? those boner pills theyre selling are wicked
      December 04, 2019, 05:58:03 PM
    • Cole1497: oh shit vain whats crackin
      December 04, 2019, 05:57:49 PM
    • ArtexAdv: FASTEST GROWING #1 UNIQUE CUSTOM RSPS [link]
      December 04, 2019, 06:30:27 AM
    • Vain_: where the boys at
      December 01, 2019, 03:20:36 PM
    • black evil111: They should close this down, mostly the downloads section. The mods dont know how to do their jobs worth shit and its no excuse like "we have real life stuff going on" everyones replacable. Speaking of replacable, fix download links! Before I go to rune-server.
      December 01, 2019, 01:50:26 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 40+ online : [link]
      November 28, 2019, 12:41:24 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 40+ online : [link]
      November 28, 2019, 12:40:42 PM
    • 1strangler77: how do i post pictures on a post
      November 24, 2019, 05:16:18 PM
    • ragnoroker: New Server - Unique - Awesome Community - Start your adventure - 40+ online : [link]
      November 23, 2019, 08:23:51 PM

    Show Posts

    This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


    Messages - penguinimp

    Pages: [1] 2
    1
    Server Help / Re: [Ruse] Particle offset help
    « on: March 06, 2019, 04:07:25 PM »
    I'm pretty interested if a solution was ever found for this.
    edit: I know this was a gravedig there isn't a lot of topics anyways

    2
    Java Programming / [Help] Loop over multiple maps
    « on: April 10, 2018, 05:59:19 PM »
    I'm not sure how to loop over multiple maps, does anyone have a solution for this?

    I've created a couple Tree Maps, but I'd like to loop over all of them and do the same action on each of them.

    in my mind I want something like
    Code: Java
    1.             object[]? maps =[accountData, characterData];
    2.             for(map IN maps){
    3.                 for(Entry<String, String> entry : map.entrySet()){
    4.                     if(k !=null){
    5.                         if(v !=null){
    6.                             characterfile.write(entry.getKey()+" = ", 0, entry.getKey().length()+3);
    7.                             characterfile.write(entry.getValue(), 0, entry.getValue().length());
    8.                             characterfile.newLine();
    9.                         }else{
    10.                             p.sendMessage("k: "+ k +" v: "+ v);
    11.                         }
    12.                     }
    13.                 }
    14.             }
    15.  

    This is my crappy solution of 2 loops (which could be even more)
    Code: Java
    1.             //TODO there has got to be a way to loop over multiple maps
    2.             p.sendMessage("./Data/characters/"+ p.playerName+".txt");
    3.             characterfile.write("[ACCOUNT]", 0, 9);
    4.             characterfile.newLine();
    5.             for(Entry<String, String> entry : accountData.entrySet()){
    6.                 if(k !=null){
    7.                     if(v !=null){
    8.                         characterfile.write(entry.getKey()+" = ", 0, entry.getKey().length()+3);
    9.                         characterfile.write(entry.getValue(), 0, entry.getValue().length());
    10.                         characterfile.newLine();
    11.                     }else{
    12.                         p.sendMessage("k: "+ k +" v: "+ v);
    13.                     }
    14.                 }
    15.             }
    16.  
    17.             characterfile.write("[CHARACTER]", 0, 11);
    18.             characterfile.newLine();
    19.             for(Entry<String, String> entry : characterData.entrySet()){
    20.                 if(k !=null){
    21.                     if(v !=null){
    22.                         characterfile.write(entry.getKey()+" = ", 0, entry.getKey().length()+3);
    23.                         characterfile.write(entry.getValue(), 0, entry.getValue().length());
    24.                         characterfile.newLine();
    25.                     }else{
    26.                         p.sendMessage("k: "+ k +" v: "+ v);
    27.                     }
    28.                 }
    29.             }
    30.             characterfile.close();
    31.  



    Edit: here is my solution
    Code: Java
    1.             characterfile =newBufferedWriter(newFileWriter("./Data/characters/"+ p.playerName+".txt"));
    2.             p.sendMessage("./Data/characters/"+ p.playerName+".txt");
    3.             TreeMap[] dataMaps   ={accountData, characterData};
    4.             String[] map_strings ={"ACCOUNT",   "CHARACTER"};
    5.             for(int i =0; i < dataMaps.length; i++){
    6.                 characterfile.write("["+map_strings[i]+"]", 0, map_strings[i].length()+2);
    7.                 characterfile.newLine();
    8.                 //java think this is unsafe, maybe investigate a better solution in the future
    9.                 Set<Entry<String, String>> entries = dataMaps[i].entrySet();
    10.                 for(Entry<String, String> entry : entries){
    11.                     if(entry.getKey()!=null){
    12.                         if(entry.getValue()!=null){
    13.                             characterfile.write(entry.getKey()+" = ", 0, entry.getKey().length()+3);
    14.                             characterfile.write(entry.getValue(), 0, entry.getValue().length());
    15.                             characterfile.newLine();
    16.                         }else{
    17.                             p.sendMessage("k: "+ entry.getKey()+" v: "+ entry.getValue());
    18.                         }
    19.                     }
    20.                 }
    21.                 characterfile.newLine();
    22.             }
    23.             characterfile.close();
    24.  

    3
    Server Help / Re: need bank and trading help
    « on: February 27, 2017, 03:42:39 PM »
    random guess entirely but your deposit code probably does something like this..



    Code: Java(TM) 2 Platform Standard Edition 5.0
    1. for(i = 1; i <= deposit_list.length; i++){
    2.  
    3. }

    when it should be something like this.

    Code: Java(TM) 2 Platform Standard Edition 5.0
    1. for(i = 0; i < deposit_list.length; i++){
    2.  
    3. }

    4
    I'm not really sure what your issue is but an idea you can try... is to put this statement


    Code: Java(TM) 2 Platform Standard Edition 5.0
    1. if(!inTrade || !validClient(trade_reqId) || !canOffer){

    in to 3 separate if statements, and doing a "t8", "t9", and "t10" see if that might help narrow it down *shrug*

    5
    Server Help / Re: Slayer points [PI]
    « on: January 30, 2017, 03:02:58 PM »
    The fairly common problem I see when this happens is that they are checking to see if you have enough coins (item id 995) but then spend your slayer points

    Unsure but maybe that will help narrow down your search.

    6
    Development Teams / Excellent Developer Looking for comrads
    « on: October 29, 2016, 10:20:12 PM »
    I'm an Excellent Developer been doing fullstack development work for a few years.
    I know Java, Php, Perl, Ruby, Python, Bash, Linux, MySQL, HTML, CSS, JS (and many libraries)

    I got the idea of starting a new server, but doing it by your self is pretty lame, boring, and tiresome.

    I was wondering if there is any old school developers that wanted to build a server using git,

    I work at a webhosting company, so I have multiple high end vps servers for beta/live environments and you can develop from your computer using what ever ide your want and I can learn puppet/chief/whatever for deploying your work done in git to the servers.

    We'll do code reviews. and use traditional scrum/agile development with 2 week sprints.

    You can have as much time off since this is a private server and no plans to make real money.
    basically work when ever you want but what ever you commit to in a 2 week period you must get done.

    Any old school moparscape users interested in setting something up like this with me?

    Thinking we'll do a 317 source but really I'm game for anything.

    7
    o.O what happened to my guide? it's all gone :(

    8
    Development Teams / Looking for a few more people PI
    « on: May 06, 2016, 07:05:35 PM »
    Hey MoparScape community,

    Quick Introduction of myself, I have an advanced knowledge on how Linux works, I am a full time full stack perl developer for a living and some friends and I decided we want to get a PI server up and running 3 developers is a little small so we're looking for a couple more, we'll be using Git for version control if you don't know what that is, I'll teach you, but if you have git experience, it's going to be a huge step.


    Server Info:
    OS:          CentOS 6.6 (Linux)
    CPU:          4 x 3.3 GHz
    storage:    1TB (Mirrored)
    RAM:         16GB
    bandwidth: 15TB

    Source: Project Insanity
    Client: Revision: 317 Cache: 474
    Paid? No.

    We have 3 positions open,
    We need:
        jr client java developer, specialized in clients specifically custom objects.
        jr server java developer,
        jr Quality assurance, (a tester)

    Requirements
    - Intermediate knowledge with Java

    Technologies we will be using
    - Web Development, Html, Js, Css
    - MySQL
    - Git
    - Alpha / Beta  |  Live environments, Ideally everyone will have their own alpha environment.



    Our Current Team
        Developers
            Steven        - Owner / Client developer
            Penguinimp - Team Lead Developer / Web Developer
            Cracked      - Jr Developer

        System Admins
            Encrypted

        Graphic Designers
            Andrew

    9
    Why perl?
    Just what the company I work uses, haha I know other languages, I need to pickup Ruby and Python still at some point.

    I have no formal development training, I basically moved up in the company from a technical support position, and when they hired me they said we know you don't have schooling, but you are more qualified then the other people we interviewed.

    11
    General Programming / Re: Advent of Code
    « on: December 04, 2015, 01:29:08 PM »
    Python is pretty great tho... for string manipulation at least
    Agreed. It's why I'll use perl.

    Day 1
    (click to show/hide)


    day 2
    (click to show/hide)

    12
    Server Tutorials / Re: How to: epoch times
    « on: December 03, 2015, 09:34:44 AM »
    When would you ever need System.nanoTime(); ?

    13
    Server Tutorials / How to: epoch times
    « on: December 03, 2015, 01:42:59 AM »
    This guide is for meant for newer developers to the runescape private server community.

    Difficulty? 1/10

    Quick note: About me:
    I'm a perl developer so I use snake case instead of camel case, out of habit if you don't like it, change it in your version, I develop a private server that will likely never go live and likely never be released, so I haven't cared to fix it. If i do decide to release it, and it's not hard to write a script to change snake case to camel case.

    Alright let's talk politics real quick.
    Many people in the Java community prefer System.currentTimeMillis() to Epoch because it's built in, I have a personal preference and tend to like Epoch better being a perl developer, I'll list reasons below. In terms of use, epoch saves you character strokes but you lose out on millisecond accuracy.

    Q/A
    Q: Is this a copy paste guide?
    A: No, unfortunately not.

    Q: Why would you teach this? What's your goal?
    A: My goal is to teach you to use epoch, and stop using custom timers in process() at the same time.

    Q: What is Epoch?
    A: Epoch is the the amount of seconds since 1970, Jan 1

    Q: Why would I ever use it?
    A: Epoch is good for keeping time, even when your users are offline, and has a really positive bonus of keeping timers out of
    Code: Java
    1. sub process(){

    Q: I already have a timer what is epoch good for?
    A: Firstly to answer this question you have to consider that your code
    Code: Java
    1. timer--;
    is not better, it's highly inaccurate and latency can make your timer turn 500ms in to 518ms, not a huge deal, until it is.
    Instead of keep track of a timer you can just keep track of the moment you can perform an action.

    Q: Isn't System.currentTimeMillis() more accurate?
    A: Yeah, if you need to be millisecond accuracy use System.currentTimeMillis()
    But if you are using timer--; in your process() you probably don't care how accurate it is.
    Also: I'd like to pose this question. if you aren't doing combat related things, do you really need to be that accurate?

    Q: Wait you are using System.currentTimeMillis() to get your Epoch time;
    A: Not a question, and oh shoot you caught me, I am cheating technically I am using System.currentTimeMillis() and dividing by 1000;

    Q: What's the difference?
    A: Epoch is System.currentTimeMillis()/1000, so you can can save character strokes, instead of typing 1000 for 1 second, you use 1, or if you want 60 minutes, 3600, instead of 3600000, in my mind that is easier to manage and keep track.
    We live in an age where developer time is more expensive then hardware.

    Q: And what's the difference code wise?
    A:
    System.currentTimeMillis()
    Code: Java
    1.     if((System.currentTimeMillis()- lastAction >=1000)&&!IsMining){
    2.  
    Epoch
    Code: Java
    1.     if(epoch_now()- lastAction >1&&!IsMining){
    2.  



    Let's get in to the code it's self you don't need to import any libraries this is all core.

    1: you'll need 3 new subroutines epoch_now(), date_to_epoch(), epoch_to_date();

    Code: Java
    1.     publiclong epoch_now(){
    2.         returnSystem.currentTimeMillis()/1000;
    3.     }
    4.     publiclong date_to_epoch(String date){
    5.         //date format: 01/01/1970 01:00:00
    6.         long epoch;
    7.         try{
    8.             epoch =new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse(date).getTime()/1000;
    9.         }catch(Exception e){
    10.             //Should probably fail... Instead of setting it to now...
    11.             epoch = epoch_now();
    12.         }
    13.         return epoch;
    14.     }
    15.     publicString epoch_to_date(long epoch){
    16.         returnnew java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss").format(new java.util.Date(epoch*1000));
    17.     }

    often times you will see this
    Code: Java
    1. long lastAction =System.currentTimeMillis();
    2.  

    Instead use
    Code: Java
    1. long lastAction = epoch_now();
    2.  


    the concept is you can make specific actions only available every so often.

    So often times on the old delta servers you would see something like this on objects
    Code: Java
    1. if(objectID ==190&&System.currentTimeMillis()- lastAction > actionInterval){
    2.     WalkTimer(0, 2);
    3.     actionInterval =10000;//10 seconds
    4.     lastAction =System.currentTimeMillis();
    5. }
    6.  

    you could convert to something like this
    Code: Java
    1. if(objectID ==190&& epoch_now()- lastAction > actionInterval){
    2.     WalkTimer(0, 2);
    3.     actionInterval =10;//seconds
    4.     lastAction = epoch_now()
    5. }
    6.  

    as long as you are not constantly needing to display a timer you could do something like this

    assuming you set pcNext when the game ends
    Code: Java
    1.     int pcTimeBetween =180;//3 minutes
    2.     int pcNext = epoch_now()+pcTimeBetween;
    3.  
    Code: Java
    1.     sM("Game starts in: "+(PlayerHandler.pcNext-epoch_now()));
    2.  

    Instead of keeping track of the timer and constantly update it.
    Code: Java
    1.     sM("Game starts in: "+PlayerHandler.pcWaitTimer);
    2.  


    Once you have gotten it figured out a bit more, you can start saving these epochtimers to your character and when you login, do some math and figure out if it's been 5 minutes since you last prayed, teleported, killed a daily boss, or set up an energy system where you restore energy every 25 minutes with a maximum of 5.

    14
    Server Tutorials / Re: [PI]Bob repairing broken barrows
    « on: November 03, 2015, 10:07:47 AM »
    While yes it works, there are significant changes you should adapt

    I agree with superman,

    since this is all the same  except for the IF

    Code: Java
    1.       if(itemId ==4950  || itemId ==4949|| itemId ==4948|| itemId ==4947|| itemId ==4946
    2.             && npcId ==519){//karil's skirt
    3.          c.getDH().sendDialogues(534, 519);
    4.          c.barrowsID= itemId;
    5.       }
    6.  
    7.  
    8.       if(itemId ==4860  || itemId ==4959|| itemId ==4958|| itemId ==4957|| itemId ==4956
    9.             && npcId ==519){//ahrim's hood
    10.          c.getDH().sendDialogues(534, 519);
    11.          c.barrowsID= itemId;
    12.       }
    13.  

    you can combine it

    Code: Java
    1.      switch(itemId){
    2.         case4950://karil's skirt
    3.         case4949:
    4.         case4948:
    5.         case4947:
    6.         case4946:
    7.         case4944://karil's top
    8.         case4943:
    9.         case4942:
    10.         case4941:
    11.         case4940:
    12.         case4932://karil's coif
    13.         case4931:
    14.         case4930:
    15.         case4929:
    16.         case4928:
    17.         case4938://karil's crossbow
    18.         case4937:
    19.         case4936:
    20.         case4935:
    21.         case4934:
    22.             if(npcId ==519){
    23.                 c.getDH().sendDialogues(534, 519);
    24.                 c.barrowsID= itemId;
    25.             }
    26.      }
    27.  

    you could do something like this (not tested, might have a syntax error)
    Code: Java
    1.   int[][] barrows ={{4884,4883,4882,4881,4880},{4896,4895,4894,4893,4892}};
    2.   int[] fixed_barrows ={4716,4720};
    3.   int fixed_item =0;
    4.   for(int i =0; i < barrows.length; i++){
    5.       for(int i2 =0; i2 < barrows[0].length; i++){
    6.            if(c.barrowsID== barrows[i][i2]){
    7.                fixed_item = fixed_barrows[i];
    8.            }
    9.       }
    10.   }
    11.  
    12.  

    Or you can use a switch

    Code: Java
    1.     int fixed_item =0;
    2.     switch(c.barrowsID){
    3.         case4884:
    4.         case4883:
    5.         case4882:
    6.         case4881:
    7.         case4880:
    8.             fixed_item =4716;
    9.             break;
    10.         case4896:
    11.         case4895:
    12.         case4894:
    13.         case4893:
    14.         case4892:
    15.             fixed_item =4720;
    16.             break;
    17.     }
    18.  

    Code: Java
    1.   if(fixed_item >0){
    2.         if(c.getItems().playerHasItem(995, 250000)){
    3.            c.getItems().deleteItem(995, c.getItems().getItemSlot(995), 250000);
    4.            c.getItems().deleteItem(c.barrowsID, 1);
    5.            c.getItems().addItem(fixed_item, 1);
    6.            c.barrowsID=0;
    7.            c.sendMessage("You repair the "+ItemAssistant.getItemName(barrowsID).toLowerCase()+".");
    8.            c.getPA().closeAllWindows();
    9.         }else{
    10.            c.sendMessage("You do not have enough gold to repair that.");
    11.            c.getPA().closeAllWindows();
    12.            c.barrowsID=0;
    13.         }
    14.     }
    15.  

    Either have their own advantages, but if/else if/else if/else isn't really a solution even though it's used every where, when you look through your source.
    It's used because someone didn't know that, that isn't a solution.

    I commend the work you've done, and I'm not looking down on you for writing it, but there are better ways to write the code, and this isn't a tutorial it's more of a snippet.

    15
    I updated my Mac OS to yosemite, and to my surprise I lost java, it didn't have java installed;

    So I installed java jdk, and when I run the client I just get a program with a white screen.


    Here's the command I ran

    Code: Bash
    1. $ ./run.sh
    2.  

    Here is what I get back
    Welcome to a [INSERT NAME HERE] Client!

    the bash script is simply
    Code: Bash
    1. java -Xmx500M EGUI
    2.  

    Code: Bash
    1. $ java -version
    2. java version "1.8.0_45"
    3. Java(TM) SE Runtime Environment (build 1.8.0_45-b14)
    4. Java HotSpot(TM)64-Bit Server VM (build 25.45-b02, mixed mode)
    5.  


    EDIT: Okay Solution time: The problem was I am using a jdk that is to new
    Found this guide.

    After installing jdk 1.6.0_65,
    modifying ~/.bashrc file
    Code: Bash
    1. exportJAVA_6_HOME=/System/Library/Frameworks/JavaVM.framework/Home
    2. exportJAVA_7_HOME=/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home
    3. exportJAVA_8_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
    4. exportJAVA_HOME=$JAVA_8_HOME
    5. aliasjava6_e='export JAVA_HOME=$JAVA_6_HOME'
    6. aliasjava7_e='export JAVA_HOME=$JAVA_7_HOME'
    7. aliasjava8_e='export JAVA_HOME=$JAVA_8_HOME'
    8. aliasjava6='/System/Library/Frameworks/JavaVM.framework/Home/bin/java'
    9. aliasjava7='/Library/Java/JavaVirtualMachines/jdk1.7.0_79.jdk/Contents/Home/bin/java'
    10. aliasjava8='/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/bin/java'
    11.  
    opening a new bash session
    Code: Bash
    1. $ bash
    2. java6_e
    3. ./run.sh
    4. $ ./run.sh
    5. Exception in thread "main" java.lang.UnsupportedClassVersionError: EGUI : Unsupported major.minor version 52.0
    6.         at java.lang.ClassLoader.defineClass1(Native Method)
    7.         at java.lang.ClassLoader.defineClass(ClassLoader.java:800)
    8. java -Xmx500M EGUI
    9.         at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
    10. exportJAVA_6_HOME=/System/Library/Frameworks/JavaVM.framework/Home
    11.         at java.net.URLClassLoader.defineClass(URLClassLoader.java:449)
    12.         at java.net.URLClassLoader.access$100(URLClassLoader.java:71)
    13.         at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
    14.         at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    15.         at java.security.AccessController.doPrivileged(Native Method)
    16.         at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
    17.         at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
    18.         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
    19.         at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
    20.         at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:482)
    21.  

    Meaning I compiled it in jdk8 at some point, so need to compile it again in jdk6
    Code: Bash
    1. javac *.java
    2.  
    Code: Bash
    1. ./run.sh
    2.  

    Works like a charm.

    16
    Server Help / Re: Creating a new player object
    « on: April 22, 2015, 10:18:15 AM »
    I'm really just trying to create a temporary player who can do all the things a player can do without giving the benefits to a player.
    There are a lot of variables on the server i've decided to clean up, such as
    Code: Java
    1. temp.SlayerKills++;
    and I don't want to award a player kills when he didn't kill that npc

    You're recommendations are useful, here is how a Player Class is created,
    Code: Java
    1.     publicstatic Player players[]=new Player[maxPlayers];
    2.  


    Quote
    As for your error: I believe the client class is capitalized, therefore meaning you need to capitalize it in your code.

    client is lower case in every place I can find (inconsistencies in all the places...) it's also named client.java
    Code: Java
    1. publicclass client extends Player implementsRunnable{
    2.  


    Quote
    Either that, or you need to add the imports,

    I don't see any imports in PlayerHandler.java, and Player.java beyond these

    Code: Java
    1. importjava.util.Calendar;
    2. importjava.util.GregorianCalendar;
    3.  


    Quote
    or you're missing a no-args constructor for the Client class.

    Oh I think this is probably it,

    I believe this is a constructor in the client.java file, in theory I need to create another client method with no arguments,
    any recommendations for converting this?
    Code: Java
    1.     public client(java.net.Socket s, int _playerId){
    2.         super(_playerId);
    3.         mySock = s;
    4.         try{
    5.             in = s.getInputStream();
    6.             out = s.getOutputStream();
    7.             //in = new java.io.DataInputStream(s.getInputStream());
    8.             //out = new DataOutputStream(s.getOutputStream());
    9.         }catch(java.io.IOException ioe){
    10.             misc.println("Exception of data!");
    11.             server.logError(ioe.getMessage());
    12.         }
    13.  
    14.         outStream =new stream(newbyte[bufferSize]);
    15.         outStream.currentOffset=0;
    16.         inStream =new stream(newbyte[bufferSize]);
    17.         inStream.currentOffset=0;
    18.  
    19.         readPtr = writePtr =0;
    20.         buffer = buffer =newbyte[bufferSize];
    21.     }
    22.  


    I've thought about it and while I don't have time to test it, I'm thinking this is probably what I want.
    Code: Java
    1.     public client(int _playerId){
    2.         super(_playerId);
    3.     }
    4.  

    17
    Server Help / Creating a new player object
    « on: April 22, 2015, 12:43:15 AM »
    tdltr; (I need help creating a new tempoary player object, that I can immediately delete, so that I can give this temporary fake player benefits without affecting real players)

    Unfortunately I don't have a full grasp on how to create an object in java, seems simple enough
    you do a
    Code: Java
    1. publicclass ClassName(){
    2.     int testData =1;
    3. }
    4.  
    then in another part of the code
    Code: Java
    1. public ClassName nameOfObject =new ClassName();
    2.  

    Pretty Simple

    Here is my desire, When an NPC dies by another npc, and temp comes back as null, we create a npc object that can enact as a player, (renaming player to entity, later) with the variable name of temp (btw who named these variables? why not player? i'll rename later...)

    however we aren't doing a new client it's doing a conversion of a number to a (client) (this is the part I don't fully understand)
    So as a temporary work around, I am using an existing player object, however, Ideally what I want to do is create a new player object, and then kill that object after one use.


    Code: Java
    1. client temp =(client) server.playerHandler.players[npcs[i].getKiller()];
    2. if(temp ==null){
    3.     for(int j =1; j < server.playerHandler.maxPlayers; j++){
    4.         if(server.playerHandler.players[j]!=null){
    5.             temp =(client) server.playerHandler.players[j];
    6.             println("TEMP: "+temp);
    7.             if(temp !=null){
    8.                 break;
    9.             }
    10.         }
    11.     }
    12. }
    13.  


    What I want is something like however client.java is a child on Player.java, and that's a bit confusing.
    Code: Java
    1. client player =new client();
    2.  

    and be able to call player subroutines

    I need to be able to use a stillgfx, distranceToPoint methods, and drop equipment for this player then when ready destroy this object.
    Code: Java
    1. player.stillgfx(bombgfx, npcs[i].absY, npcs[i].absX);
    2.  

    Pretty simple, any got a few minutes to help me out?


    Here's my compiler
    Code: Java
    1. NPCHandler.java:3000: cannot find symbol
    2. symbol  : constructor client()
    3. location:class client
    4.                         client npc  =new client();
    5.  

    18
    Meh, Someone else grave dug it, I didn't look at the date. My bad.

    19
    Server Help / Re: Bank all tab error - Please help!!
    « on: April 15, 2015, 05:01:40 PM »
    Code: Java
    1.     publicboolean bankHasSpace(){
    2.         for(int i =0; i < playerBankSize; i++){
    3.             if(bankItems[i]==-1){
    4.                 returntrue;
    5.             }
    6.         }
    7.         returnfalse;
    8.     }

    Code: Java
    1.         publicboolean bankHasSpace(){
    2.                 return bankItems[playerBankSize-1]==-1;
    3.         }

    Appreciated, going to the end of the array and seeing if you have space will usually work, it won't always work if your bank is full and you with draw and item in the middle of the bank (unless you rebuild the array)

    Which might be the case in all sources, I'm completely recoding every method I find in the delta source I found because I've realized everything is terrible.

    @on topic

    if you do decide to use this method
    Code: Java
    1.         publicboolean bankHasSpace(){
    2.                 return bankItems[playerBankSize-1]==-1;
    3.         }
    4.  
    You don't need to call
    Code: Java
    1. if(bankHasSpace()){
    you can simply use
    Code: Java
    1. if(bankItems[playerBankSize-1]==-1){

    20
    Server Help / Re: Bank all tab error - Please help!!
    « on: April 15, 2015, 04:56:53 PM »
    One server I first delta server I developed when I picked it up always gave null all the time of clicking it. It's array was wrong, it checked your inventory from 1-29 instead of 0-28, might also be worth while to check.


    depending on your methods you could do something like this
    Code: Java
    1.     publicboolean bankHasSpace(int itemToCheck){
    2.         for(int i =0; i < playerBankSize; i++){
    3.             if(bankItems[i]==-1|| bankItems[i]== itemToCheck){
    4.                 returntrue;
    5.             }
    6.         }
    7.         returnfalse;
    8.     }
    9.     publicvoid bankAll(){
    10.         for(int i =0; i < playerItems.length; i++){
    11.             if(playerItems[i]!=-1){
    12.                 if(bankHasSpace()){
    13.                     bankItem(playerItems[i], i, playerItemsN[i]);
    14.                 }else{
    15.                     break;
    16.                 }
    17.             }
    18.         }
    19.     }
    20.  

    Or you can modify your bankItem method and make sure it declines to put it in the bank if you don't have room. Not sure how yours is written.

    The more correct method might be to create a new bankItem that will handle an array of arrays one array for each item (itemid, and slot) of the items from your inventory and then you don't need to do a bankHasSpace() for every item, more correct, harder to do, up to you.

    Pages: [1] 2
    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal