You've created a new NPC object but haven't actually spawned the NPC. In the typical server you would do:
NpcHandler.spawnNpc(id, x, y .....);
|
Alright so before I had the NPC at just 1 location and wanted to expand, the 1 location worked just fine I simply had
Inside the void Sequence. Which is just a 4 hour timer. However the code below does not work. It sends the text but does not send the NPC spawn.Code:NPC NPCraids = new NPC(7286, new Position(3105, 3934)); World.sendMessage("@mag@A Raid has started in the Mage Arena");
Code:public static void sequence() { if(timer.elapsed(TIME)) { timer.reset(); { int random = Misc.getRandom(4); switch(random) { case 0: NPC NPCraids = new NPC(7286, new Position(3105, 3934)); World.sendMessage("@mag@A Raid has started in the Mage Arena"); break; case 1: NPC NPCraids1 = new NPC(7286, new Position(2973, 3938)); World.sendMessage("@mag@A Raid has started South of Thermo Boss Teleport."); break; case 2: NPC NPCraids2 = new NPC(7286, new Position(3054, 10269)); World.sendMessage("@mag@A Raid has started in the Death Arena."); break; case 3: NPC NPCraids3 = new NPC(7286, new Position(3195, 3815)); World.sendMessage("@mag@A Raid has started East of Venenatis NPC."); break; case 4: NPC NPCraids4 = new NPC(7286, new Position(2984, 3911)); World.sendMessage("@mag@A Raid has started West of Wilderness Agility Teleport."); break; } }
I have a command which initiates sequence.
If you want to see the whole class -> http://pastebin.com/UWQDCv5H
Will Rep+,
Thanks.
You've created a new NPC object but haven't actually spawned the NPC. In the typical server you would do:
NpcHandler.spawnNpc(id, x, y .....);
Okay I added y but I don't see what you're getting at with the .....
I don't have NPCHandler just NPC.Code:public Position(int x, int y, int z) { this.x = x; this.y = y; this.z = z; }
Here is an example from Pest Control.
Changed to the following and no luck.Code:private static void spawnMainNPCs() { int knightHealth = 3000 - (PLAYERS_IN_BOAT * 14); int portalHealth = getDefaultPortalConstitution(); knight = spawnPCNPC(3782, new Position(2656,2592), knightHealth); //knight portals[0] = spawnPCNPC(6142, new Position(2628,2591), portalHealth); //purple portals[1] = spawnPCNPC(6143, new Position(2680,2588), portalHealth); //red portals[2] = spawnPCNPC(6144, new Position(2669,2570), portalHealth); //blue portals[3] = spawnPCNPC(6145, new Position(2645,2569), portalHealth); //yellow npcList.add(knight);
Code:public final class Raids { /** * 1 hour timer that resets. */ private static final int TIME = 14400000; /* * Calls the Stopwatch to keep track of time. */ public static Stopwatch timer = new Stopwatch().reset(); private static CopyOnWriteArrayList<NPC> npcList = new CopyOnWriteArrayList<NPC>(); /** * Spawns the NPC and resets the timer (4 hours) */ private static NPC[] raid = new NPC[5]; public static void sequence() { if(timer.elapsed(TIME)) { timer.reset(); { int random = Misc.getRandom(4); switch(random) { case 0: raid[0] = new NPC(7286, new Position(3105, 3934, 0)); World.sendMessage("@mag@A Raid has started in the Mage Arena"); break; case 1: raid[1] = new NPC(7286, new Position(2973, 3938, 0)); World.sendMessage("@mag@A Raid has started South of Thermo Boss Teleport."); break; case 2: raid[2] = new NPC(7286, new Position(3054, 10269, 0)); World.sendMessage("@mag@A Raid has started in the Death Arena."); break; case 3: raid[3] = new NPC(7286, new Position(3195, 3815, 0)); World.sendMessage("@mag@A Raid has started East of Venenatis NPC."); break; case 4: raid[4] = new NPC(7286, new Position(2984, 3911, 0)); World.sendMessage("@mag@A Raid has started West of Wilderness Agility Teleport."); break; } for(NPC n : raid) { npcList.add(n); return; } } } } }
The second one you created is worse than the first.
Read the code. You're missing the line which spawns the NPC itself. I find it odd though that the code you had before functioned as it was missing the spawning just as well, however this one with exact same code doesn't function. Odd.Code:public static void sequence() { if(timer.elapsed(TIME)) { timer.reset(); int random = Misc.getRandom(4); NPC raid = null; switch(random) { case 0: raid = new NPC(7286, new Position(3105, 3934)); World.sendMessage("@mag@A Raid has started in the Mage Arena"); break; case 1: raid = new NPC(7286, new Position(2973, 3938)); World.sendMessage("@mag@A Raid has started South of Thermo Boss Teleport."); break; case 2: raid = new NPC(7286, new Position(3054, 10269)); World.sendMessage("@mag@A Raid has started in the Death Arena."); break; case 3: raid = new NPC(7286, new Position(3195, 3815)); World.sendMessage("@mag@A Raid has started East of Venenatis NPC."); break; case 4: raid = new NPC(7286, new Position(2984, 3911)); World.sendMessage("@mag@A Raid has started West of Wilderness Agility Teleport."); break; } //You need to add a line here which will spawn the npc, in the matrix sources it'd look like.. if (raid != null) World.spawnNPC(raid); } }
post NPC() and spawnPCNPC() methods
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |