Thread: 5 Portals teleporting to same location

Results 1 to 7 of 7
  1. #1 5 Portals teleporting to same location 
    Registered Member
    Join Date
    Mar 2018
    Posts
    3
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Hi, I have made 6 portals, and just finished adding code telling them where to tele to. But now they all tele to the where the last portal is supposed to take you.

    Here is ObjectDef

    Code:
    		switch(i) {
    			case 2465: //ID for portal
    				objectDef.name = "Rock Crab Portal";
    				objectDef.actions[0] = "Enter"; // These are the different right click options
    				objectDef.actions[1] = null;
    				objectDef.actions[2] = null;
    				objectDef.actions[3] = null;
    				objectDef.actions[4] = null;
    				objectDef.description = "A portal to genetically modified Rock Crabs.".getBytes();
    			break;
    		}
    		
    		switch(i) {
    			case 2466: //ID for portal
    				objectDef.name = "Slayer Tower Portal";
    				objectDef.actions[0] = "Enter"; // These are the different right click options
    				objectDef.actions[1] = null;
    				objectDef.actions[2] = null;
    				objectDef.actions[3] = null;
    				objectDef.actions[4] = null;
    				objectDef.description = "A portal to Slayer Tower.".getBytes();
    			break;
    		}
    		
    		switch(i) {
    			case 2467: //ID for portal
    				objectDef.name = "Dagganoth Kings Portal";
    				objectDef.actions[0] = "Enter"; // These are the different right click options
    				objectDef.actions[1] = null;
    				objectDef.actions[2] = null;
    				objectDef.actions[3] = null;
    				objectDef.actions[4] = null;
    				objectDef.description = "Come Prepared!".getBytes();
    			break;
    		}
    		
    		switch(i) {
    			case 2468: //ID for portal
    				objectDef.name = "Mining Portal";
    				objectDef.actions[0] = "Enter"; // These are the different right click options
    				objectDef.actions[1] = null;
    				objectDef.actions[2] = null;
    				objectDef.actions[3] = null;
    				objectDef.actions[4] = null;
    				objectDef.description = "A portal to the mining area.".getBytes();
    			break;
    		}
    		
    		switch(i) {
    			case 2469: //ID for portal
    				objectDef.name = "TzHaar City Portal";
    				objectDef.actions[0] = "Enter"; // These are the different right click options
    				objectDef.actions[1] = null;
    				objectDef.actions[2] = null;
    				objectDef.actions[3] = null;
    				objectDef.actions[4] = null;
    				objectDef.description = "Can you defeat Jad?".getBytes();
    			break;
    		}
    		
    		switch(i) {
    			case 2470: //ID for portal
    				objectDef.name = "Woodcutting Portal";
    				objectDef.actions[0] = "Enter"; // These are the different right click options
    				objectDef.actions[1] = null;
    				objectDef.actions[2] = null;
    				objectDef.actions[3] = null;
    				objectDef.actions[4] = null;
    				objectDef.description = "A portal to the woodcutting area.".getBytes();
    			break;
    		}
    Here is ActionHandler

    Code:
    			case 2465:
    				{c.getPA().movePlayer(2677, 3717, 0);
    				}
    				
    			case 2466:
    				{c.getPA().movePlayer(3423, 3538, 0);
    				}
    				
    			case 2467:
    				{c.getPA().movePlayer(1912, 4367, 0);
    				}
    				
    			case 2468:
    				{c.getPA().movePlayer(3043, 9781, 0);
    				}
    				
    			case 2469:
    				{c.getPA().movePlayer(2445, 5178, 0);
    				}
    				
    			case 2470:
    				{c.getPA().movePlayer(2702, 3397, 0);
    				}
    Thanks in advance.
    Reply With Quote  
     

  2. #2  
    Respected Member


    Kris's Avatar
    Join Date
    Jun 2016
    Age
    26
    Posts
    3,638
    Thanks given
    820
    Thanks received
    2,642
    Rep Power
    5000
    What the fuck lol
    If you don't know how to use a switch block, don't use it at all.
    The first piece of code should be as follows..
    Code:
    switch(i) {
    case 2465: //ID for portal
    ...
    break;
    case 2466: //ID for portal
    ...
    break;//etc you get the point.
    The second piece is missing breaks/returns. It needs to look as this:
    Code:
    switch(id) {
    case 2465:
    c.getPA().movePlayer(2677, 3717, 0);
    break;
    case 2466:
    c.getPA().movePlayer(3423, 3538, 0);
    break;
    }
    etc..
    Attached image
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Registered Member
    Join Date
    Mar 2018
    Posts
    3
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by Kris View Post
    What the fuck lol
    If you don't know how to use a switch block, don't use it at all.
    The first piece of code should be as follows..
    Code:
    switch(i) {
    case 2465: //ID for portal
    ...
    break;
    case 2466: //ID for portal
    ...
    break;//etc you get the point.
    The second piece is missing breaks/returns. It needs to look as this:
    Code:
    switch(id) {
    case 2465:
    c.getPA().movePlayer(2677, 3717, 0);
    break;
    case 2466:
    c.getPA().movePlayer(3423, 3538, 0);
    break;
    }
    etc..

    Thanks for the reply, yeah I'm just copy and pasting, trying to learn as I go. I changed the ActionHandler to this:
    Code:
    		switch(id) {
    		case 2465:
    		c.getPA().movePlayer(2677, 3717, 0);
    		break;
    		case 2466:
    		c.getPA().movePlayer(3423, 3538, 0);
    		break;
    		case 2467:
    		c.getPA().movePlayer(1912, 4367, 0);
    		break;
    		case 2468:
    		c.getPA().movePlayer(3043, 9781, 0);
    		break;
    		case 2469:
    		c.getPA().movePlayer(2445, 5178, 0);
    		break;
    		case 2470:
    		c.getPA().movePlayer(2702, 3397, 0);
    		break;
    		}
    it says cannot find symbol ( or i.


    Also, regarding the first part, do you just have an issue on the formatting? I don't even know what a switch block is, let alone how to use it.
    Reply With Quote  
     

  5. #4  
    Registered Member

    Join Date
    Apr 2016
    Posts
    309
    Thanks given
    294
    Thanks received
    64
    Rep Power
    275
    Quote Originally Posted by tvlly View Post
    Thanks for the reply, yeah I'm just copy and pasting, trying to learn as I go. I changed the ActionHandler to this:
    Code:
    		switch(id) {
    		case 2465:
    		c.getPA().movePlayer(2677, 3717, 0);
    		break;
    		case 2466:
    		c.getPA().movePlayer(3423, 3538, 0);
    		break;
    		case 2467:
    		c.getPA().movePlayer(1912, 4367, 0);
    		break;
    		case 2468:
    		c.getPA().movePlayer(3043, 9781, 0);
    		break;
    		case 2469:
    		c.getPA().movePlayer(2445, 5178, 0);
    		break;
    		case 2470:
    		c.getPA().movePlayer(2702, 3397, 0);
    		break;
    		}
    it says cannot find symbol ( or i.


    Also, regarding the first part, do you just have an issue on the formatting? I don't even know what a switch block is, let alone how to use it.
    He’s saying to get a basic understanding of java before messing around w rsps. Will make it easier on ya
    Attached image
    Reply With Quote  
     

  6. Thankful user:


  7. #5  
    Registered Member
    Join Date
    Mar 2018
    Posts
    3
    Thanks given
    0
    Thanks received
    1
    Rep Power
    0
    Quote Originally Posted by Trickk View Post
    He’s saying to get a basic understanding of java before messing around w rsps. Will make it easier on ya
    Yeah I'm sure. I'm just having a lot of fun with it and picking some things up as I go. I have no doubt I'll hit a wall eventually



    EDIT: Fixed. The compiling error was because I already had the switch(id) above. Just needed the breaks.
    Reply With Quote  
     

  8. Thankful user:


  9. #6  
    Donator
    tsdm's Avatar
    Join Date
    Jul 2017
    Posts
    31
    Thanks given
    6
    Thanks received
    17
    Rep Power
    31
    Use eclipse which shows the errors right click and fix is available for fixing shit most the time.
    Reply With Quote  
     

  10. Thankful user:


  11. #7  
    Registered Member 2nubs1cup's Avatar
    Join Date
    Jan 2013
    Posts
    972
    Thanks given
    77
    Thanks received
    90
    Rep Power
    15
    Quote Originally Posted by tvlly View Post
    Yeah I'm sure. I'm just having a lot of fun with it and picking some things up as I go. I have no doubt I'll hit a wall eventually



    EDIT: Fixed. The compiling error was because I already had the switch(id) above. Just needed the breaks.
    When you do a switch block you don't keep adding Switch () everytime just once.

    Ex.)
    Code:
    Switch (i) {
         case ##:
         break;
         case##:
         break;
    }
    Reply With Quote  
     

  12. Thankful user:



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: 2
    Last Post: 04-13-2014, 11:09 PM
  2. Replies: 22
    Last Post: 02-20-2013, 02:11 AM
  3. Making A Simple Portal to Teleport to Places
    By G R A P E D in forum Tutorials
    Replies: 8
    Last Post: 08-18-2009, 01:34 AM
  4. Replies: 15
    Last Post: 11-21-2007, 10:52 PM
  5. Teleporting to Random Locations
    By mrgibblet in forum Tutorials
    Replies: 10
    Last Post: 10-23-2007, 04:50 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
  •