[Release] Activate/Un-Activate NPC by Command.

12/09/2008 21:17 _Emme_#1
So ive seen alot of you wanted this, well here it is, coded this in about 4minutes total and never tested it,so you will probably be the first one.

So, all you actually do is to make the server check if xxx is activated, if it is, it shows the real npc chat, if it isnt, it tells you that it isnt. And you activate/unactivate the xxx with a command. Well here you are:



In General.cs , under : public static System.Timers.Timer Thetimer;

Code:
public static bool CanTalkToNPC = false;

Search for : if (Splitter[0] == "/ServerRestart")

Above that , add:


Code:
if (Splitter[0] == "/startnpc")
                                        {
                                            string K = "";
                                            if (General.CanTalkToNPC)
                                            {
                                            K = "un-activated!";
                                           General.CanTalkToNPC = false;
                                            }
                                            if (!General.CanTalkToNPC)
                                            {
                                            K = "activated!";
                                            General.CanTalkToNPC = true;
                                             }
                                             World.SendMsgToAll("The xxxx NPC has been " + K, "NPCHandeler", 2005);
                                         }
This is how the command works:
If you type /startnpc , it will check if the npc is activated. If the npc(s) is activated, they will be un activated, and vice versa. Also it announce the status of the npc.





And this is an example of how to NPC code work:

Search for : if (CurrentNPC == 12)

Until you get to the NPC TALK


Above, add this:



Code:
if (CurrentNPC == 1339)
                            {
                                if (!General.CanTalkToNPC)
                                {
                                    SendPacket(General.MyPackets.NPCSay("This NPC is not started yet. Please wait for an announcment!"));
                                    SendPacket(General.MyPackets.NPCLink("Okay.", 255));
                                    SendPacket(General.MyPackets.NPCSetFace(30));
                                    SendPacket(General.MyPackets.NPCFinish());
                                }
                                else
                                {
                                    SendPacket(General.MyPackets.NPCSay("Hello there! Want me to teleport you to xxxx?"));
                                    SendPacket(General.MyPackets.NPCLink("Sure", 1));
                                    SendPacket(General.MyPackets.NPCLink("Just passing by..", 255));
                                    SendPacket(General.MyPackets.NPCSetFace(30));
                                    SendPacket(General.MyPackets.NPCFinish());
                                }
                            }
Now that is an example how it could look like.



Hope it gave you any ideas or/and knowledge. Atleast I hope I helped someone.


Emme
12/10/2008 02:02 Incariuz#2
Hmmm... I never thought of doing something like this. Probably won't test this itself, but it gives me an idea. Setting NPC's to some sort of timer, in which at certain times they'll appear for quests or what not, and the rest of the time, have their location switched to an unreachable map.
12/10/2008 08:55 !DeX!#3
Thanks emme So Much
12/10/2008 09:14 damianpesta#4
Quote:
Originally Posted by E*PvPers View Post
Thanks emme So Much
Im still Waiting to get hacked Mr.(Hacker) lol And Still i didnt Get it ... hmm lets see ,maybe your just full of shit?
12/10/2008 09:18 !DeX!#5
Quote:
Originally Posted by damianpesta View Post
Im still Waiting to get hacked Mr.(Hacker) lol And Still i didnt Get it ... hmm lets see ,maybe your just full of shit?
wanne try Give me ur IP and tell Bye bye to ur PC
12/10/2008 09:58 _Emme_#6
Press thanks if you liked this, e.x used it, got ideas, or just like it.

And for the timer, thats very easy. Add a timer in the SingleNPC class as I call it, of lets say 10 minutes. Now, start the NPC + the timer by using a command, like this:

if (Splitter[0] == "/start")
{
SingleNPC G = new SingleNPC(INFO HERE, ALSO THE TIMER HERE);
Spawn G;
}

Now a timer is started, on what time you defined it to in the code above. Now you can do like this for the timer:


if (Timer_Elapsed)
{
foreach (DictionaryEntry DE in NPCs.AllNPCs)
{
SingleNPC Npc = (SingleNPC)DE.Value;

if (Npc.UID == NPCUIDHERE)
Npc.X == 999;
Npc.Y == 999;
Npc.Map == 999;
}
}



Well something like that, I never actually did this and it was directly coded in e*pvp
12/10/2008 14:56 ~jochemke~#7
Emme i love u so much
that was much easier then i thought
i thought it was so difficult xD
12/10/2008 15:06 _Emme_#8
press thanks then..
12/10/2008 15:07 ~jochemke~#9
rofl forgot to do that
tnx for remembering
keep up the good work

ps: u gonna release more these days?
12/10/2008 15:34 _Emme_#10
Sure,just gimme ideas.
12/10/2008 15:40 ~jochemke~#11
well about the treasure hunt when the box drops something u can't pick it up
how to fix that?
12/10/2008 19:06 _Emme_#12
You cant pick it up? Wierd, well lets see if someone else got that error. Besides, post in the thread for that subject.
12/10/2008 19:14 damianpesta#13
Quote:
Originally Posted by E*PvPers View Post
wanne try Give me ur IP and tell Bye bye to ur PC
What Kind of Hacker Needs IP to Pwn Someones Comp? I lol'd now ... seriously get a life rather than talking shit just like 10 year old kid
12/10/2008 22:17 ~jochemke~#14
Quote:
Originally Posted by EmmeTheCoder View Post
You cant pick it up? Wierd, well lets see if someone else got that error. Besides, post in the thread for that subject.
kk posted in treasure hunt topic
12/10/2008 22:30 tao4229#15
You can't do shit with only an IP.
The only way you can even connect to the host is through an open port, or a bridging program. If they're blocking their router, you have no access.
Even then, you can't connect unless a program is running on the port, which means you'd have to install it some way.