public static int Dialog(GameClient Hero, string[] dlg)
{
There are thousands of ways to accomplish the same thing, but since you are trying to make things shorter, why keep passing that parameter all the time? Instead of passing it once?
I don`t get how is this a shortcut though, I thought that those strings replaced lines of code where you send the dialog packets. If it is like this then you`re theoretically doubling the execution time of the parsing of an NPC.
I don`t get how is this a shortcut though, I thought that those strings replaced lines of code where you send the dialog packets. If it is like this then you`re theoretically doubling the execution time of the parsing of an NPC.
That's 'cuz I was originally going to integrate my entire scripting system into this souce but never got around to it albeit, I wanted to make things as user-friendly as possible.
Strings = user friendly,
Brackets, semi-colons, parameters are not sadly.
That's 'cuz I was originally going to integrate my entire scripting system into this souce but never got around to it albeit, I wanted to make things as user-friendly as possible.
Strings = user friendly,
Brackets, semi-colons, parameters are not sadly.
I certainly see your point there, but scripting in games IMO should be done by someone who has at least a bit of experience in programming, thus making it similar to a language which many are familiar with has more advantages.
I certainly see your point there, but scripting in games IMO should be done by someone who has at least a bit of experience in programming, thus making it similar to a language which many are familiar with has more advantages.
Just my two cents though
Since all my NPCs were home coded, my community pitched in with coding a lot of them, and they were done in a language everyone's familiar with.
Code:
' By: Wolf
' Npc: 10021
' Name: ArenaGuard
Imports System
Imports ConquerScriptLinker
Partial Public Class NpcEngine
Public Shared Sub ArenaGuard()
Dim dlg As String() = Nothing
Select Case OptionID
Case 0
ReDim dlg(2)
dlg(0) = "TEXT Hello would you like to enter the PK Arena for 50 silvers?"
dlg(1) = "OPTION1 Yes, here you go."
dlg(2) = "OPTION-1 No thanks."
Case 1
If Player.Money >= 50 Then
Player.Money -= 50
Command("@mm 1005 50 50")
Else
ReDim dlg(1)
dlg(0) = "TEXT I'm sorry you dont have 50 silvers."
dlg(1) = "OPTION-1 Oh, I will go work my corner more."
End If
End Select
If Not dlg Is Nothing Then
Dialog(dlg)
End If
End Sub
End Class
Notice how the dialog functions are handled for you, also, no packet-knowledge is required and is internally done as required by the engine to synchronize the client as such. I'd explain the Engine setup, but it's overly complicated to explain how everything works at this time, for instance; this is jut setting it up;
Code:
private static ScriptExtension GenerateExtension()
{
ScriptExtension extend = new ScriptExtension("Engine", "VB");
extend.AddPreprocess("'#new_assembly System.Core.dll");
extend.AddPreprocess("'#assembly " + ServerDatabase.Startup + "\\ConquerScriptLinker.dll");
extend.AddNamespace("Imports ConquerScriptLinker");
extend.AddVariable("Public Shared DatabasePath As String = \"" + ServerDatabase.Path + "\"");
extend.AddVariable("Public Shared Player As INpcPlayer");
extend.AddVariable("Public Shared NativeDialog As Func(Of INpcPlayer, String(), Int32)");
extend.AddVariable("Public Shared NativeCommand As Func(Of INpcPlayer, String, Int32)");
extend.AddVariable("Public Shared FindPlayerByName As Func(Of String, INpcPlayer)");
extend.AddVariable("Public Shared FindPlayerByUID As Func(Of UInt32, INpcPlayer)");
extend.AddVariable("Public Shared QueryDatabase As Func(Of String, String, String, String, String)");
extend.AddVariable("Public Shared WriteDatabase As Func(Of String, String, String, String, Int32)");
extend.AddVariable("Public Shared timeGetTime As Func(Of UInt32)");
extend.AddVariable("Public Shared GuildPoleID As Func(Of UInt16)");
extend.AddVariable("Public Shared FlipGate As Func(Of UInt32, Int32)");
extend.AddVariable("Public Shared GenerateLotteryItem As Func(Of Int32, INpcItem)");
extend.AddFunction(
"Public Shared Sub Dialog(ByVal Dlg As String())\r\n" +
"\tNativeDialog(Player, Dlg)\r\n" +
"End Sub"
);
extend.AddFunction(
"Public Shared Sub Command(ByVal Cmd As String)\r\n" +
"\tNativeCommand(Player, Cmd)\r\n" +
"End Sub"
);
extend.AddExternalClass(
"\r\nPartial Public Class NpcEngine\r\n" +
"Inherits Engine\r\n" +
"\tPublic Shared NpcID As UInt32\r\n" +
"\tPublic Shared OptionID As Byte\r\n" +
"\tPublic Shared Input As String\r\n" +
"End Class\r\n"
);
extend.AddExternalClass(
"\r\nPartial Public Class ItemEngine\r\n" +
"Inherits Engine\r\n" +
"\tPublic Shared Item as INpcItem\r\n" +
"End Class\r\n"
);
return extend;
}
private static void LinkScriptMethods()
{
Engine.RegisterGlobalVariable("Engine", "NativeDialog", new Func<INpcPlayer, string[], int>(Dialog));
Engine.RegisterGlobalVariable("Engine", "NativeCommand", new Func<INpcPlayer, string, int>(Command));
Engine.RegisterGlobalVariable("Engine", "FindPlayerByName", new Func<string, INpcPlayer>(FindPlayerByName));
Engine.RegisterGlobalVariable("Engine", "FindPlayerByUID", new Func<uint, INpcPlayer>(FindPlayerByUID));
Engine.RegisterGlobalVariable("Engine", "QueryDatabase", new Func<string, string, string, string, string>(QueryDatabase));
Engine.RegisterGlobalVariable("Engine", "WriteDatabase", new Func<string, string, string, string, int>(WriteDatabase));
Engine.RegisterGlobalVariable("Engine", "timeGetTime", new Func<uint>(timeGetTime));
Engine.RegisterGlobalVariable("Engine", "GuildPoleID", new Func<ushort>(GuildPoleID));
Engine.RegisterGlobalVariable("Engine", "FlipGate", new Func<uint, int>(FlipGate));
Engine.RegisterGlobalVariable("Engine", "GenerateLotteryItem", new Func<int, INpcItem>(GenerateLotteryItem));
}
public static void Init()
{
Engine = new ScriptEngine("VB");
Engine.Extension = GenerateExtension();
Engine.BuildPath = ServerDatabase.Path + "\\Scripts\\";
LinkScriptMethods();
CreateDefinedFiles();
}
i don't like it, i feel it could be a lot easier. in my opinion that isn't user friendly, i actually find VB harder to look at than C# (obviously because im used to it).
An example of something i have set up:
Code:
SetText("Hello would you like to enter the PK Arena for 50 silvers?");
option = AddOptions("Yes, here you go.", "No thanks");
if(option == 1) {
if(HasMoney(50)) {
RemoveMoney(50);
Teleport(1005, 50, 50);
} else {
SetText("I'm sorry you dont have 50 silvers.");
AddOptions("Oh, I will go work my corner more.");
}
}
maybe someone should create a thread on here about script engines and see what people can come up with, it can be judged by ease of use, speed and control.
From my old community i remember someone had the easiest setup i have ever seen, it went something like this
Code:
:start
text "Hello would you like to enter the PK Arena for 50 silvers?"
option1 "Yes, here you go."
option2 "No thanks."
:answer1
if hasmoney 50 goto tp else goto fail
:tp
money -50
teleport 1005 50 50
:fail
text "You dont have enough money"
option1 "Oh, I will go work my corner more"
Hilfe bei Shortcut und Gui 10/06/2010 - AutoIt - 8 Replies Hallo :)
Ich bin relativ neu in Auto it und wollte fragen wie ich bei meinem Script ein Exit Shortcut machen kann?
Ausserdem wollte ich frage wie ich ein Gui erstelle bei dem man nur euf einen Knopf drücken muss und dann reconnectet wird...?
HotKeySet ("^!{s}","start")
Func start()
Run ("C:\Program Files\Mozilla Firefox\firefox.exe")
WinWaitActive ("Google - Mozilla Firefox")
SRO DB-BOT Shortcut Key 06/09/2010 - SRO Private Server - 10 Replies Hi,
can someone tell me if there is a shortcut key to pop-up the botmenu? Like in isrobot. Pos1 or something.
Since I am using Windows 7 it does cause trouble alt+tab with the bot.
It wont appear anymore! Windows xp didn´t hat this problem.
Thanks alot
Vista EO Shortcut 04/20/2009 - EO Exploits, Hacks, Tools & Macros - 6 Replies As most of us know there are some errors with Vista and EO's play.exe and autopatch.exe
Ive edited my own shortcut (recently got Vista) so it works a lot better.
Jusrt replace this shortcut with your old one IF you have Vista.
give thx if you like xD
or
give thx for the effort
xDxD
COOL SHORTCUT 09/22/2008 - Zero - 8 Replies hey im new to zero, only playing for a couple of weeks and im not sure if everyone already knows this... but here it goes
to make all robots dissapear press CTRL + tab !
this is great for market and robots re-appear when u move
less lag
;)