(RESOLVED) Problem with Teleporter / Can't figure this out..

For any problems with Dawn of Light website or game server, please direct questions and problems here.

Moderator: Support Team

(RESOLVED) Problem with Teleporter / Can't figure this out..

Postby sryker1911 » Thu Jun 19, 2014 3:22 am

Hi,

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"); } } }
Last edited by sryker1911 on Fri Jun 20, 2014 1:05 am, edited 1 time in total.
sryker1911
DOL Visitor
 
Posts: 7
Joined: Thu Jun 19, 2014 3:14 am

Re: Problem with Teleporter / Can't figure this out..

Postby Tolakram » Thu Jun 19, 2014 12:22 pm

Could it be that one of the base calls is doing a realm check and refusing to talk to the player it not the same realm as the npc? For this case I might ignore the base class checks.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Problem with Teleporter / Can't figure this out..

Postby sryker1911 » Thu Jun 19, 2014 3:55 pm

I haven't tested yet, but does this look correct?
Code: Select all
public override bool Interact(GamePlayer player) { if (!base.Interact(player)) if (!player.InCombat) { if(player.Realm == eRealm.Albion){ player.MoveTo(200, 350880, 490740, 5488, 1089); } else if(player.Realm == eRealm.Hibernia){ player.MoveTo(200, 349675, 494164, 5150, 1648); } else if(player.Realm == eRealm.Midgard){ player.MoveTo(200, 344387, 493832, 5165, 2457); } } else { player.Client.Out.SendMessage("You can't port while in combat.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); } /* { 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); }*/ return true; }




Ignore Below


Thanks Tolokram, do you know why doing this doesn't work? Is there any easier way of doing or forcing the teleport to occur? I tried looked at the hastener code to see how that works but Im not understanding. I think the T.MoveTo may not work in this case? Do I have to call something else?

Ignore Below
Code: Select all
public override bool Interact(GamePlayer player) if(!(source is GamePlayer)) return false; GamePlayer t = (GamePlayer) source; TurnTo(t.X,t.Y); { 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); return true; }
sryker1911
DOL Visitor
 
Posts: 7
Joined: Thu Jun 19, 2014 3:14 am

Re: Problem with Teleporter / Can't figure this out..

Postby Tolakram » Thu Jun 19, 2014 7:00 pm

Looks fine, except I don't like the way you lined up the curly braces. :D

I would ass some logging to the console to make sure you are hitting the code you think you should be hitting. The cheap and easy way to debug.
- Mark
User avatar
Tolakram
Storm / Storm-D2 Admin
 
Posts: 9189
Joined: Tue Jun 13, 2006 1:49 am
Location: Kentucky, USA

Re: Problem with Teleporter / Can't figure this out..

Postby Tralon » Thu Jun 19, 2014 11:01 pm

use switch and case like
Code: Select all
switch(realm) { case Albion: { player.MoveTo(reg,x,y,z,heading); } break case Midgard....... }
Its very easy and its just 1 check
instead of a if method
(x)====|X|xxxxxxxxxxxxxxxxxxxxxxx>
Tralon
DOL Experienced
 
Posts: 176
Joined: Tue Jan 29, 2013 2:52 pm

Re: Problem with Teleporter / Can't figure this out..

Postby Tralon » Fri Jun 20, 2014 12:31 am

I can show you what i mean but without wrong stuff i wrote the post before.

So here is my interact method i also put the switch and case thing in so its better for communication: BUT this is for the mob u need to set that the player.Realm need to be albion or midgard or hibernia, atm the realm is of the mob so if the mob is realm 3 it gives the eRealm.Hibernia part instead of Midgard and Albion: here my example
Code: Select all
public override bool Interact(GamePlayer player) { if (base.Interact(player)) switch(Realm) { case eRealm.Albion: SayTo(player, "Greetings, i have different teleports for you, which you want to port to ? \n"+ "\n"+ "[Demon Breach] is a RvR Dungeon. You can farm Bountypoints, if you kill Mobs(LvL 45-100). The Epic Boss Mobs need to be killed in group. \n"+ "\n"+ "[Molvik __ RvR] is the Main-RvR Zone. You can teleport back to the Setup of your Realm! \n"); break; case eRealm.Midgard: SayTo(player, "Greetings, i have different teleports for you, which you want to port to ? \n"+ "\n"+ "[Demon Breach] is a RvR Dungeon. You can farm Bountypoints, if you kill Mobs(LvL 45-100). The Epic Boss Mobs need to kill in group. \n"+ "\n"+ "[Molvik __ RvR] is the Main-RvR Zone. You can teleport back to the Setup of your Realm! \n"); break; case eRealm.Hibernia: SayTo(player, "Greetings, i have different teleports for you, which you want to port to ? \n"+ "\n"+ "[Demon Breach] is a RvR Dungeon. You can farm Bountypoints, if you kill Mobs(LvL 45-100). The Epic Boss Mobs need to kill in group. \n"+ "\n"+ "[Molvik __ RvR] is the Main-RvR Zone. You can teleport back to the Setup of your Realm! \n"); break; default: SayTo(player, "I have no Realm set, so don't know what locations to offer.."); [color=#FF0000]// THIS SHOWS THAT THE MOB NEEDS THE REALM[/color] break; } return true; }

Now if you want that the mob is neutral just set player.Realm and all is fixed but now the best part is your teleport, after interact you want to teleport

so use switch and case again, its very easy and faster than if....

so here my Example:
Code: Select all
switch (player.Realm) //[color=#FF0000] It checks now if the player.realm is really the realm in the case[/color] { case eRealm.Albion: switch (str) { /*_________________________________________________________________________________________________*/ case "Demon Breach": if (!player.InCombat) { foreach (GamePlayer t in this.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) t.Out.SendSpellCastAnimation(this, 4953, 6); player.MoveTo(489, 39899, 43127, 27579, 2046); } else { player.Client.Out.SendMessage("You can't port while in combat.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); } break; /*__________________________________________________________________________________________________*/ case "Molvik __ RvR": if (!player.InCombat) { foreach (GamePlayer t in this.GetPlayersInRadius(WorldMgr.VISIBILITY_DISTANCE)) t.Out.SendSpellCastAnimation(this, 4953, 6); player.MoveTo(241, 532053, 542023, 5992, 3325); } else { player.Client.Out.SendMessage("You can't port while in combat.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); } break; } break;
i hope it helped a lot..

best regards
Tralon
(x)====|X|xxxxxxxxxxxxxxxxxxxxxxx>
Tralon
DOL Experienced
 
Posts: 176
Joined: Tue Jan 29, 2013 2:52 pm

Re: Problem with Teleporter / Can't figure this out..

Postby sryker1911 » Fri Jun 20, 2014 12:48 am

This is what I have now, although it compiles it does not work still. When I right click on the NPC it does not port me to the location. What else could I be missing?
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 = 441; Name = "TELEPORTER"; GuildName = "Unknown Server"; Level = 50; Size = 60; return base.AddToWorld(); } public override bool Interact(GamePlayer player) { if (!base.Interact(player)) if (!player.InCombat) //switch (player.Realm) switch(player.Realm) { case eRealm.Albion: player.MoveTo(238, 535190, 535221, 5408, 3773); break; case eRealm.Midgard: player.MoveTo(238, 535190, 535221, 5408, 3773); break; case eRealm.Hibernia: player.MoveTo(238, 535190, 535221, 5408, 3773); break; } else { player.Client.Out.SendMessage("You can't port while in combat.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); } 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"); } } }
sryker1911
DOL Visitor
 
Posts: 7
Joined: Thu Jun 19, 2014 3:14 am

Re: Problem with Teleporter / Can't figure this out..

Postby sryker1911 » Fri Jun 20, 2014 1:03 am

figured it out only because you posted that. I see my errors now but i have to understand them so this will take some time. Thank you Tolokram and Tralon for your help on this.

sorry im such a noob :)


Working Code Below as of 6/19/2014
Code: Select all
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 = 441; Name = "TELEPORTER"; GuildName = "Unknown Server"; Level = 50; Size = 60; return base.AddToWorld(); } public override bool Interact(GamePlayer player) { if (base.Interact(player)) switch(Realm) { case eRealm.Albion: SayTo(player, "Greetings, i have different teleports for you, whic"); player.MoveTo(238, 535190, 535221, 5408, 3773); break; case eRealm.Midgard: SayTo(player, "Greetings, i have different teleports for you, whic"); player.MoveTo(238, 535190, 535221, 5408, 3773); break; case eRealm.Hibernia: SayTo(player, "Greetings, i have different teleports for you, whic"); player.MoveTo(238, 535190, 535221, 5408, 3773); break; default: SayTo(player, "I have no Realm set, so don't know what locations to offer.."); // THIS SHOWS THAT THE MOB NEEDS THE REALM break; } return true; } /*switch(player.Realm) { case eRealm.Albion: player.Client.Out.SendMessage("HI YOU.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); player.MoveTo(238, 535190, 535221, 5408, 3773); break; case eRealm.Midgard: player.Client.Out.SendMessage("HI YOU.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); player.MoveTo(238, 535190, 535221, 5408, 3773); break; case eRealm.Hibernia: player.Client.Out.SendMessage("HI YOU.", eChatType.CT_Say, eChatLoc.CL_PopupWindow); player.MoveTo(238, 535190, 535221, 5408, 3773); break; }*/ 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"); } } }
sryker1911
DOL Visitor
 
Posts: 7
Joined: Thu Jun 19, 2014 3:14 am

Re: (RESOLVED) Problem with Teleporter / Can't figure this o

Postby Tralon » Fri Jun 20, 2014 11:31 am

Your error is that u set the teleport instantly in the interact method:

make a Whisper method where it search for the whisper in interact like " DO YOU WANT TO PORT TO [GOTHWAITE]? ""

Then if u click on Gothwaite it searches the String in interact: like
switch (str)
{
case "GOTHWAITE":
{
player.moveto......
}
break;
}
(x)====|X|xxxxxxxxxxxxxxxxxxxxxxx>
Tralon
DOL Experienced
 
Posts: 176
Joined: Tue Jan 29, 2013 2:52 pm

Re: (RESOLVED) Problem with Teleporter / Can't figure this o

Postby Joku » Tue Oct 14, 2014 6:37 pm

is this teleporter finished yet? i have some questions about it, had several problems on creating it - sorry if this post is dead already :/ - if it is, could anybody share a teleporter like this? my scripting talent isnt the best :(

Thank you

Joku
Joku
DOL Apprentice
 
Posts: 27
Joined: Wed Jul 30, 2014 11:28 am


Return to “%s” Support

Who is online

Users browsing this forum: No registered users and 1 guest