Hello there, since scripting has just been added to Eclipse Dawn 2.1.0, I figured I’d make a quick tutorial that shows you how easy it can be to add new functionality to your server by just changing a few files! Now, then… Let’s get started shall we?

Step 1: Your server.

Make sure your server is up to date, and running AT LEAST Eclipse Dawn 2.1.0, it will not work in lower versions or any other custom Eclipse Version. Please note that it does not matter whether your server is running or not, there’s a method of reloading the scripts while the server runs.

Step 2: Making directories.

Since my script uses specific directories to store Data, let’s make them!

Head into your Server Directory and click on Data, once in there make a new folder called ScriptData and go inside it, in there make another folder called Frankenstein and enter it as well, then finaly in there make a new folder called Chests. If all went well, you should now have the following folder structure to get where you are: *\data\scriptdata\frankenstein\chests*.

Head back to your Server Directory and click the Scripts folder, once in there make a new folder called **User **and go inside it, in there make another called Frankenstein. If all went well, your folder structure should be as follows: data\scripts\user

The reason I chose these names are simply to keep things organized in the future should I want to add more scripts of my own, or another user. But do bear in mind that it does not matter what folder structure you use, as long as you rewrite the script(s) to reflect the changes.

Step 3: Creating the file script file.

First, copy the following script:

Function GetPlayerChestState(Index, Chest)
GetPlayerChestState = GetVar("data\scriptdata\frankenstein\chests\cheststate.ini", GetPlayerName(Index), CSTR(Chest))
' Error checking below, if the record is empty it returns a blank string.
' And a blank string can't be converted to a Long, so that's why we need to check this manually.
If GetPlayerChestState = "" Then
GetPlayerChestState = ChestStateFull
GetPlayerChestState = CLNG(GetPlayerChestState)
End If

End Function

Sub SetPlayerChestState(Index, Chest, State)
PutVar "data\scriptdata\frankenstein\chests\cheststate.ini", GetPlayerName(Index), CSTR(Chest), CSTR(State)
End Sub

Function GetChestMaxItems(Chest)
GetChestMaxItems = CLNG(GetVar("data\scriptdata\frankenstein\chests\chestcontent.ini", CSTR(Chest), "MaxItems"))
End Function

Function GetChestItemNum(Chest, Item)
GetChestItemNum = CLNG(GetVar("data\scriptdata\frankenstein\chests\chestcontent.ini", CSTR(Chest), "Item" & CSTR(Item) & "Num"))
End Function

Function GetChestItemVal(Chest, Item)
GetChestItemVal = CLNG(GetVar("data\scriptdata\frankenstein\chests\chestcontent.ini", CSTR(Chest), "Item" & CSTR(Item) & "Val"))
End Function

Sub OpenChest(Index, Chest, OpenMsg, EmptyMsg)
Dim i, MaxItems, Item, Val, Name

' Check if the chest is empty for this player before we begin.
If GetPlayerChestState(Index, Chest) <> ChestStateEmpty Then

' The chest seems to be alright for this guy, let's move on!
' Retrieve the max amount of items in this chest.
MaxItems = GetChestMaxItems(Chest)

' And time to loop through this mess, we want to hand out the items to the player, after all.
For i = 1 to MaxItems

' Retrieve the item number and amounts.
Item = GetChestItemNum(Chest, i)
Val = GetChestItemVal(Chest, i)

' Hand it out
GivePlayerItem Index, Item, Val


' Set the chest state to empty.
SetPlayerChestState Index, Chest, ChestStateEmpty

' Done! Let's notify our player of his opened chest!
PlayerMsg Index, OpenMsg, BrightRed

' Seems like this player's opened the chest before.
' Let's notify them.
PlayerMsg Index, EmptyMsg, BrightRed
End If

End Sub