19-06-2006, 07:03 PM
This was based on the following script at:
http://www.touchofdeathproductions.com/scripts.html
By Unknown_raven
Difficulty: 4/5 (Requires some programming ability)
It uses a flag system which can become confusing but I'll leave a sample quest at the end of this tutorial for all to see.
Server Side
Create a new Module.
Name it modQuest and add the folowing:
Now I'll explain how this works. Basically you are using a system of flags to detrmine how much of the quest has been completed, and it also prevents parts of the quest which were allready finished from being done again, such as recieveing the reward for the quest.
Function GetFlagHeight - This function is pretty self explanatory. It access the file 'flags.ini" and checks to see what the current flag's height is. This is specified by the "flagnum". An example of how this could be used is:
Sub RaiseFlag - This again is quite obvious. It raises the flag specified by "flagnum" so that any event that allready happened cannot happen again. See the above code example to see how it works.
Sub LowerFlag - This again is quite obvious. It lowers the flag specified by "flagnum" so that any event that allready happened can happen again. I haven't exactly thought of any real way this might come into play during a quest but maybe someone else can.
Sub SetFlag - This is used to set the height of a flag to a specific height. I haven't needed to use it in my quests yet because they're all hide and go seek quests, so a few IF statements with the getflagheight and raiseflag commands is suitable.
There, now that we have a basic understanding of what each function/sub routine does, let's move on to getting these quests to work.
First fo all we want to make sure that each players has some flags, otherwise the quests won't work.
Open up modGameLogic (still server side):
Find:
And right under it add:
[code]
Dim BeenFlagged As Boolean, Num As Integer
Dim filename1 As String
filename1 = App.Path & "\flags\" & GetPlayerName(index) & ".ini"
If Not FileExist(filename1) Then
BeenFlagged = False
End If
If BeenFlagged = False Then
Num = 1
'Change the 3 to number of flags you want per player
Do While Num
http://www.touchofdeathproductions.com/scripts.html
By Unknown_raven
Difficulty: 4/5 (Requires some programming ability)
It uses a flag system which can become confusing but I'll leave a sample quest at the end of this tutorial for all to see.
Server Side
Create a new Module.
Name it modQuest and add the folowing:
Code:
Option Explicit
Function GetFlagHeight(ByVal index As Integer, ByVal Flagnum As Integer) As Long
Dim X
Dim filename As String
filename = App.Path & "\flags\" & getplayername(index) & ".ini"
X = GetVar(filename, GetPlayerName(index), "Flag" & Flagnum)
GetFlagHeight = X
Call SendDataTo(index, ("FLAGHEIGHT" & SEP_CHAR & X & SEP_CHAR & Flagnum & SEP_CHAR & END_CHAR))
End Function
Sub RaiseFlag(ByVal index As Integer, ByVal Flagnum As Integer, ByVal height As Integer)
Dim filename As String
filename = App.Path & "\flags\" & getplayername(index) & ".ini"
Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(GetVar(filename, GetPlayerName(index), "Flag" & Flagnum) + height))
End Sub
Sub LowerFlag(ByVal index As Integer, ByVal Flagnum As Integer, ByVal height As Integer)
Dim filename As String
filename = App.Path & "\flags\" & getplayername(index) & ".ini"
Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(GetVar(filename, GetPlayerName(index), "Flag" & Flagnum) - height))
End Sub
Sub SetFlag(ByVal index As Integer, ByVal Flagnum As Integer, ByVal height As Integer)
Dim filename As String
filename = App.Path & "\flags\" & getplayername(index) & ".ini"
Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(0))
Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(GetVar(filename, GetPlayerName(index), "Flag" & Flagnum) + height))
Call PutVar(filename, GetPlayerName(index), "Flag" & Flagnum, STR(height))
End Sub
Now I'll explain how this works. Basically you are using a system of flags to detrmine how much of the quest has been completed, and it also prevents parts of the quest which were allready finished from being done again, such as recieveing the reward for the quest.
Function GetFlagHeight - This function is pretty self explanatory. It access the file 'flags.ini" and checks to see what the current flag's height is. This is specified by the "flagnum". An example of how this could be used is:
Code:
If GetFlagHeight(index, 1) = 0 Then [b] ' Check the height of flag 1[/b]
Call PlayerMsg(index, "Janelle Says: 'Hi, could you do this quest for me? I need you to go to the forest and see if it is muddy.'", 10) ' Give the player the quest.
Call RaiseFlag(index, 1, 1) ' Raise the flag by one so that flag 1's height now = 1, and since it = 1 and not 0, the above event can't happen again.
End If
Sub RaiseFlag - This again is quite obvious. It raises the flag specified by "flagnum" so that any event that allready happened cannot happen again. See the above code example to see how it works.
Sub LowerFlag - This again is quite obvious. It lowers the flag specified by "flagnum" so that any event that allready happened can happen again. I haven't exactly thought of any real way this might come into play during a quest but maybe someone else can.
Sub SetFlag - This is used to set the height of a flag to a specific height. I haven't needed to use it in my quests yet because they're all hide and go seek quests, so a few IF statements with the getflagheight and raiseflag commands is suitable.
There, now that we have a basic understanding of what each function/sub routine does, let's move on to getting these quests to work.
First fo all we want to make sure that each players has some flags, otherwise the quests won't work.
Open up modGameLogic (still server side):
Find:
Code:
Sub JoinGame(ByVal index As Long)
And right under it add:
[code]
Dim BeenFlagged As Boolean, Num As Integer
Dim filename1 As String
filename1 = App.Path & "\flags\" & GetPlayerName(index) & ".ini"
If Not FileExist(filename1) Then
BeenFlagged = False
End If
If BeenFlagged = False Then
Num = 1
'Change the 3 to number of flags you want per player
Do While Num