No. Just no.
Think about your code logically - if two people use *any* trapdoor simultaneously, both will be teleported to the same location.
|
Probably not the best way, but quickly wrote this up someone else might find this of use.
Then again not much difference then handling it via actionhandler.java
Updated thanks to @Mige5
Code:public class Dungeons { /*Erethium RSPS*/ private static void useDoor(final Client c, final int index) { c.teleX = data[index][1]; c.teleY = data[index][2]; c.teleZ = data[index][3]; c.startAnimation(4597); c.sendMessage("You open the trap door..."); EventManager.getSingleton().addEvent(new Event() { @Override public void execute(EventContainer container) { c.getPA().movePlayer(c.teleX,c.teleY,c.teleZ); c.startAnimation(9730); c.sendMessage("You climb down the trap door..."); container.stop(); } }, 5); } private static int[][] data = { //ObjectID, Xcoords, Ycoords, Zcoords {26933, 3097, 9868, 0}, //Edgevile Dungeon {1755, 3096, 3468, 0}}; //Cockroach Dungeon public static boolean Trapdoor(Client c, int object) { for(int i = 0; i < data.length; i++) { if(object == data[i][0]) { useDoor(c, i); return true; } } return false; } }Code:if (Dungeons.Trapdoor(c, objectType)) { return; }
Last edited by Code Kiwi; 05-14-2018 at 04:32 AM.
Ahh, i see now hehe. Just tested it.
http://prntscr.com/jh9fc1
Curious, would this be more rightful?
c.getPA().movePlayer(data[I][1] ,data[I][2] ,data[I][3]);
also u can reduce unnecessary looping:
Code:if (Dungeons.Trapdoor(c, objectType)) { return; }Code:public static boolean Trapdoor(Client c, int object) { for(int i = 0; i < data.length; i++) { if(object == data[i][0]) { useDoor(c, i); return true; } } return false; } }Code:public static void useDoor(final Client c, final int index) { teleX = data[index][1]; teleY = data[index][2]; teleZ = data[index][3]; c.startAnimation(4597); c.sendMessage("You open the trap door..."); ....
Thanks for the snippet not going to use this code i made it way better
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |