I have been working on modifying a script for a starting point and I am having a lot of trouble. I have looked at various other user files for the past week and looked at some guides posted here on making a teleporter but none seem to answer my question.
What I would like / trying to do:
1. Upon "Right Clicking" the teleporter I want it to detect the realm a user is and jump them to a specific location. I can't seem to understand how to accomplish this. It would be cool if it also could cast a spell or some sort of animation while performing this action.
Currently I have it so that the user has to right click the NPC and it prompts the user to select "YES" in order for the logic to work (this does work). I am new to the entire DOLSERVER project and am trying to learn how to program on this fun project.
I have attached the script below, as you can tell the script is not written by me. I hope someone can share their expertise on the this matter.
- Code: Select all
/////////////////////////////////////////////////// //////// Universial Teleporter //////// //////// Written by Solomon //////// //////// //////// /////////////////////////////////////////////////// // This is an all in one Teleporter that seperates locations based on realm for more than one zone. There is a extra click // that players have to make in order for me to make this placeable in any zone without having to write to much extra code. // feel free to edit to elimate the extra click if you wish. using System; using DOL.GS; using DOL.Events; using DOL.GS.PacketHandler; using log4net; using System.Reflection; namespace DOL.GS.Scripts { public class UNTeleporter: GameNPC { private static readonly ILog log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); public override bool AddToWorld() { Model = 175; Name = "TELEPORTER"; GuildName = "Unknown Server"; Level = 50; Size = 60; return base.AddToWorld(); } public override bool Interact(GamePlayer player) { if (!base.Interact(player)) return false; //TurnTo(player.X,player.Y); /* I know the code belongs here but it doesn't appear to work */ /*(Below is for test only */ player.Out.SendMessage("Hi " + player.Name + " would you like to fight for your realm [Yes]?", eChatType.CT_Say, eChatLoc.CL_PopupWindow); return true; } public override bool WhisperReceive(GameLiving source, string str) { if(!base.WhisperReceive(source,str)) return false; if(!(source is GamePlayer)) return false; GamePlayer t = (GamePlayer) source; TurnTo(t.X,t.Y); switch(str) { case "Yes": if (t.Realm == eRealm.Albion) t.MoveTo(238, 535190, 535221, 5408, 3773); if (t.Realm == eRealm.Hibernia) t.MoveTo(238, 535190, 535221, 5408, 3773); if (t.Realm == eRealm.Midgard) t.MoveTo(238, 535190, 535221, 5408, 3773); break; default: break; } return true; } private void SendReply(GamePlayer target, string msg) { target.Client.Out.SendMessage( msg, eChatType.CT_Say,eChatLoc.CL_PopupWindow); } [ScriptLoadedEvent] public static void OnScriptCompiled(DOLEvent e, object sender, EventArgs args) { log.Info("\tTeleporter initialized: true"); } } }