|
|
This tutorial assumes a very basic knowledge in programming. The Scriptnyx language is using the common base of programming languages and is in fact strongly inspired from BASIC.
The structure of this tutorial is as follows:
1 - Purpose of ScriptNyx
2 - A basic scriptnyx
3 - Type and keywords
4 - Running the scriptnyx
5 - Events
6 - References
---------------------------------------------------------------------------------------------------
1 - Purpose of ScriptNyx
Scriptnyx has been created in order to extend the behavior of a classic nadeo dedicated server. We want this server to do more!
The ScriptNyx technology is based a very simple language created by DND Networks to communicate easily with the Nadeo Dedicated Server. In fact, ScriptNyx will enable you to customize your Onyx Server, they can be considered as plugins for your server.
Some of them are "System" as they are needed to make your server working fine.
Others are "User", meaning they are up to you
.
Your scriptNyx must have ".nyx" (or .cyx if encrypted) as extension and you can give the full network path or local path when adding your scriptnyx:
example of network path: http://www.script.com/control.nyx?args=adminLogin (script located in the dndnetworks server)
example of local path: control.nyx?args=adminLogin (script located in the directory of Onyx.exe)
To set arguments to your scriptNyx: just follow the following synthax: script.nyx?args=ARG1,ARG2,ARG3,ARG4 this will mean that your method onLoad has 4 arguments.
2 - A basic scriptnyx
After this presentation, let s get stated with a basic scriptnyx.
string helloMsg = "Welcome to my Onyx Server, "
string ads = "Visit $l[http://scriptnyx.dndnetworks]ScriptNyx Website!!!
func displayAd()
##we display the ad to everybody
dnd.chatSend(ads,"","")
##we call this method again in 5 minutes
timer(5*60*1000,"displayAd")
endfunc
##called when the script is loaded
func onLoad()
displayAd()
endfunc
##called when a player connects
func onPlayerConnect(string login, string nickname, bool isSpec)
## we display the welcome message to the user
dnd.chatSend(helloMsg + nickname,"",login)
endfuncThis script will display a welcome message to the player who connects and will display a message every 5 minutes to all connected players.
- helloMsg and ads are globlal variables, visible on the all the script
(if you declare a variable inside a method, the visibility will be only the method)
- onLoad and onPlayerConnect are event functions, they are called on specific events by the scriptnyx engine. (Event functions always begins by "on", full list of event functions in section 5)
- dnd.chatSendand timer are methods who belongs the API. Here you will find a documentation ScriptNyx API. (Be aware: a method can exist for a game and not exist for another one, use the combobox to filter)
- displayAd is function defined by us.
3 - Type and keywords
In Scriptnyx, there are five data types
- int (Integer)
- string (String)
- double (Double)
- bool (Boolean)
About keywords, here is the list:
if, then, endif, else, elsif, elseif, while, endwhile, func, endfunc, return, int, bool, string, double.
and predefined from the API: false, NULL, pi, true
Example:
if
if(login=="loginAdmin1")
dnd.chatSend("Your are admin!","",login)
elsif(login=="loginAdmin2")
dnd.chatSend("Your are admin!","",login)
endifwhile
int size = dnd.getLength()
int i = 0
string filename= ""
while(i<size)
filename = dnd.getChallengeAt(i)
i = i + 1
endwhilefunc
func test(string arg1, int arg2, double arg3)
dnd.println("test called with ["+arg1+","+arg2+","+arg3+"]")
endfuncFor more details about the language specification, follow this link
4 - Running the scriptnyx
Two ways to run a scriptnyx exist, one through the Scriptnyx validator, the other one is to deploy it in you Onyx server.
ScriptNyx Validator
The ScriptNyx Validator is provided to you to validate your script in order to speed up your development and to encrypt your scriptnyx to hide your implementation in case of sensitive data. It runs only on Windows and can be downloaded here.
This Script validator will call only the onLoad method. If you want to test event functions, you will have to call them in the onLoad function.
Onyx Server
To deploy your script in an onyx server, you should either use Onyx Controller (ScriptNyx Tab) or the "Manage Your ScritpNyx Here" button if you have Onyx Desktop Edition.
You will have to specify the local path to your script or the internet link if your script is located on a http server.
Your script can generate some errors. Errors are displayed on the log:
on the Desktop Edition: go to the "console" tab in the interface.
on the Server Edition: edit the file "log" in your onyx directory.
5 - Events
The scriptnyx engine running on Onyx throw some events and are forwarded to your script. You can catch these events by implementing funtions. All the event functions begins by "on". You cannot change the signature of the method
Here is the list:
##a player connects func onPlayerConnect(string login, string nickname, bool isSpec) endfunc ##a player disconnects func onPlayerDisconnect(string login, string nickname, bool isSpec) endfunc ##chat message received func onPlayerChat(string login,string message) endfunc ##server command received (Server command begins by /, example "/help") func onServerCommand(string command, string login, string args) endfunc ##player answered to a window (Nations Only) func onPlayerServerMessageAnswer(string login, int answer) endfunc ##script loading func onLoad() endfunc ##script unloading func onUnLoad() endfunc ##challenge begins func onBeginChallenge(string filename) endfunc ##challenge ends func onEndChallenge(string filename) endfunc ##round begins func onBeginRound() endfunc ##status server changed func onStatusChanged(int statusCode, string statusName) endfunc ##player go through a checkpoint func onPlayerCheckpoint(string login, int time, int score, int checkpointIndex) endfunc ##player finishes challenges func onPlayerFinish(string login, int timeOrScore) endfunc ##event receives (for advanced users only) func onEvent(string param) endfunc ##player answered manialink page (United only) func onPlayerManialinkPageAnswer(string login, int answer) endfunc ## method xmlrpc Echo has been called (for advanced users only) (United only) func onEcho(string sInternal, string sPublic) endfunc
6 - References
Lots of scriptnyx already exist, you can now write your own and share it with the community using the scriptnyx website.
Here is some scriptnyx example:
JukeBox.nyx, MapInfo.nyx, RSS.nyx, Dictionary.nyx, Control.nyx, ServerCommand.nyx, GuessNumber.nyx, RandomMode.nyx ...
Here are links to website related to ScriptNyx:
Home Page
Latest SciptNyx
Language Specification
ScriptNyx API
Share Your ScriptNyx
Home | Share your script with the community and upload your own script | Contact
Update your script by using email: scriptnyx@dndnetworks.com
Powered by DnD Networks Copyright © 2005-2006 DnD Networks