[Help] Spawning NPC Via Command.

08/24/2009 04:35 yoshmoma#1
I've been working at this for a bit and I'm at a loss as to why this wont work. I'm essentially trying to make an event NPC that will appear when I type in "/event on" and then disappear when I type "/event off". At the moment nothing will show up unless the type of NPC is a guild gate (I've tried like 5 or 6 different IDs), and it wont disappear if I type "/event off", however if I leave the area and come back the gate is gone. I'm assuming it has something to do with not storing anything in the DB or with not refreshing/spawning correctly. Any insight would be great:
Code:
if (Splitter[0] == "/event")
{
	if (Splitter[1] == "on")
	{
		World.Event = true;
		EventNPC = new SingleNPC(97979, 290, 2, 0, 447, 386, 1002, 0);
                World.NPCSpawns(EventNPC);
		foreach (DictionaryEntry DE in World.AllChars)
		{                                                    
			Character Chaar = (Character)DE.Value;
			World.SendMsgToAll("The event NPC has been activated, find him and answer his questions for a reward!", "SYSTEM", 2011);
		}
                                                   
            }
           if (Splitter[1] == "off")
           {
              foreach (DictionaryEntry DE in World.AllChars)
              {
	      		Character Chaar = (Character)DE.Value;
                        World.SendMsgToAll("The event is over, hope everyone had fun!", "SYSTEM", 2011);
	      }
              World.Event = false;
              
                                                    
              EventNPC.Map = 999;
              EventNPC.X = 999;
              EventNPC.Y = 999;
              World.NPCSpawns(EventNPC);
             }
                                            
}
08/24/2009 04:44 hunterman01#2
I gotta give you props about the idea it is pretty custom
08/24/2009 04:59 yoshmoma#3
Quote:
Originally Posted by hunterman01 View Post
I gotta give you props about the idea it is pretty custom
Yeah I intend to put a random number generator in there and pick like 10 map spots so it spawns randomly. But sadly I can't get it to spawn/disappear properly.
08/24/2009 05:06 raidenx123#4
Im not a coder, but dont you need a packet to update the NPCSpawn
08/24/2009 05:16 rubenz#5
lol emme released something to activate a npc but this npc wont spawn right away you most liekyl either have to restart or like send a few packets like raiden said
08/24/2009 05:19 kinshi88#6
You have to send the Npc Spawn Packet.
08/24/2009 05:21 raidenx123#7
:) so i was right :rolleyes:
08/24/2009 05:32 yoshmoma#8
So instead of:
Code:
World.NPCSpawns(EventNPC);
I should be using:
Code:
General.MyPackets.SpawnNPC(EventNPC)
Correct?

Edit: Obviously not, gates wont even show up now lol xD. Am I forgetting a packet?
08/25/2009 19:53 yoshmoma#9
I'm still having troubles with this and would really like some insight into which packets I should be sending other than:
Code:
General.MyPackets.SpawnNPC(EventNPC);
08/25/2009 20:22 kinshi88#10
I just send the Spawn Npc Packet (ID 2030)

And the Npc appeared.
Seems pretty simple. =P
08/26/2009 20:20 yoshmoma#11
Quote:
Originally Posted by kinshi88 View Post
I just send the Spawn Npc Packet (ID 2030)

And the Npc appeared.
Seems pretty simple. =P
Yeah I got that working fine now, but my current problem is it disappears if I leave the area. Or if I'm not in it to begin with. Say I spawn the npc, leave the screen just so that npc isn't in it anymore, then walk back and it's gone. If I'm not in the screen when it spawns it looks like it never spawned. Any ideas on how to fix this?