Kemerd Posted August 9, 2011 Author Share Posted August 9, 2011 Just don't do this.I decided this was stupid. Tried to delete but…**BOTH CLIENT AND SERVER**In mod constantsunder ' General constants add```Public Const MAX_CONVS As Byte = 255```under ' Game editor constants add```Public Const EDITOR_CONV As Byte = 7```in modEnumerationsat the bottom of the "s" list add``` SChatUpdate SConvEditor SUpdateConv```at the bottom of the "c" list add``` CChatOption CRequestEditConv CSaveConv CRequestConvs```in modTypesunder ' Public data structures add```Public Conv(1 To MAX_CONVS) As ConvWrapperRec```at the bottom of Private Type NpcRec add``` Conv As Long Convo As Boolean```add to the bottom of Private Type MapNpcRec``` c_lastDir As Byte c_inChatWith As Long```at the bottom of modTypes add```Private Type ConvRec Conv As String rText(1 To 4) As String rTarget(1 To 4) As Long Event As Long Data1 As Long Data2 As Long Data3 As LongEnd TypePrivate Type ConvWrapperRec Name As String * NAME_LENGTH chatCount As Long Conv() As ConvRecEnd Type```**CLIENT SIDE**Add the attached editor to your Client.[http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=74220.0;attach=19037](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=74220.0;attach=19037)In modClientTCP add at the bottom```Public Sub SendRequestEditConv() Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.WriteLong CRequestEditConv SendData Buffer.ToArray() Set Buffer = NothingEnd SubPublic Sub SendSaveConv(ByVal Convnum As Long) Dim Buffer As clsBuffer Dim i As Long Dim x As Long Set Buffer = New clsBuffer Buffer.WriteLong CSaveConv Buffer.WriteLong Convnum With Conv(Convnum) Buffer.WriteString .Name Buffer.WriteLong .chatCount For i = 1 To .chatCount Buffer.WriteString .Conv(i).Conv For x = 1 To 4 Buffer.WriteString .Conv(i).rText(x) Buffer.WriteLong .Conv(i).rTarget(x) Next Buffer.WriteLong .Conv(i).Event Buffer.WriteLong .Conv(i).Data1 Buffer.WriteLong .Conv(i).Data2 Buffer.WriteLong .Conv(i).Data3 Next End With SendData Buffer.ToArray() Set Buffer = NothingEnd SubSub SendRequestConvs() Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.WriteLong CRequestConvs SendData Buffer.ToArray() Set Buffer = NothingEnd SubPublic Sub SendChatOption(ByVal Index As Long) Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.WriteLong CChatOption Buffer.WriteLong Index SendData Buffer.ToArray() Set Buffer = NothingEnd Sub```in modDatabase add at the bottom```Sub ClearConv(ByVal Index As Long) Call ZeroMemory(ByVal VarPtr(Conv(Index)), LenB(Conv(Index))) Conv(Index).Name = vbNullString ReDim Conv(Index).Conv(1)End SubSub ClearConvs() Dim i As Long For i = 1 To MAX_CONVS Call ClearConv(i) NextEnd Sub```in modGameEditors add at the bottom```' /////////////////' // Conv Editor //' /////////////////Public Sub ConvEditorInit() Dim i As Long, n As Long On Error Resume Next If frmEditor_Conv.Visible = False Then Exit Sub EditorIndex = frmEditor_Conv.lstIndex.ListIndex + 1 With frmEditor_Conv .txtName.text = Trim$(Conv(EditorIndex).Name) If Conv(EditorIndex).chatCount = 0 Then Conv(EditorIndex).chatCount = 1 ReDim Preserve Conv(EditorIndex).Conv(1 To Conv(EditorIndex).chatCount) End If For n = 1 To 4 .cmbReply(n).Clear .cmbReply(n).AddItem "None" For i = 1 To Conv(EditorIndex).chatCount .cmbReply(n).AddItem i Next Next .scrlChatCount = Conv(EditorIndex).chatCount .scrlConv.Max = Conv(EditorIndex).chatCount .scrlConv.Value = 1 .txtConv = Conv(EditorIndex).Conv(.scrlConv.Value).Conv For i = 1 To 4 .txtReply(i).text = Conv(EditorIndex).Conv(.scrlConv.Value).rText(i) .cmbReply(i).ListIndex = Conv(EditorIndex).Conv(.scrlConv.Value).rTarget(i) Next .cmbEvent.ListIndex = Conv(EditorIndex).Conv(.scrlConv.Value).Event .scrlData1.Value = Conv(EditorIndex).Conv(.scrlConv.Value).Data1 .scrlData2.Value = Conv(EditorIndex).Conv(.scrlConv.Value).Data2 .scrlData3.Value = Conv(EditorIndex).Conv(.scrlConv.Value).Data3 End With Conv_Changed(EditorIndex) = TrueEnd SubPublic Sub ConvEditorOk() Dim i As Long For i = 1 To MAX_CONVS If Conv_Changed(i) Then Call SendSaveConv(i) End If Next Unload frmEditor_Conv Editor = 0 ClearChanged_ConvEnd SubPublic Sub ConvEditorCancel() Editor = 0 Unload frmEditor_Conv ClearChanged_Conv ClearConvs SendRequestConvsEnd SubPublic Sub ClearChanged_Conv() ZeroMemory Conv_Changed(1), MAX_CONVS * 2 ' 2 = boolean lengthEnd Sub```In modGlobalsunder 'gui add```Public inChat As Boolean```under ' Editor edited items array add```Public Conv_Changed(1 To MAX_CONVS) As Boolean```In modHandleDataAt the bottom of Public Sub InitMessages() add``` HandleDataSub(SChatUpdate) = GetAddress(AddressOf HandleChatUpdate) HandleDataSub(SConvEditor) = GetAddress(AddressOf HandleConvEditor) HandleDataSub(SUpdateConv) = GetAddress(AddressOf HandleUpdateConv)```at the bottom of modHandleData add``` Private Sub HandleConvEditor() Dim i As Long With frmEditor_Conv Editor = EDITOR_CONV .lstIndex.Clear ' Add the names For i = 1 To MAX_CONVS .lstIndex.AddItem i & ": " & Trim$(Conv(i).Name) Next .Show .lstIndex.ListIndex = 0 ConvEditorInit End WithEnd SubPrivate Sub HandleUpdateConv(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Convnum As Long Dim Buffer As clsBuffer Dim i As Long Dim x As Long Set Buffer = New clsBuffer Buffer.WriteBytes Data() Convnum = Buffer.ReadLong With Conv(Convnum) .Name = Buffer.ReadString .chatCount = Buffer.ReadLong ReDim Conv(Convnum).Conv(1 To .chatCount) For i = 1 To .chatCount .Conv(i).Conv = Buffer.ReadString For x = 1 To 4 .Conv(i).rText(x) = Buffer.ReadString .Conv(i).rTarget(x) = Buffer.ReadLong Next .Conv(i).Event = Buffer.ReadLong .Conv(i).Data1 = Buffer.ReadLong .Conv(i).Data2 = Buffer.ReadLong .Conv(i).Data3 = Buffer.ReadLong Next End With Set Buffer = NothingEnd SubPrivate Sub HandleChatUpdate(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer Dim i As Long Dim npcNum As Long Dim mT As String Dim o1 As String Dim o2 As String Dim o3 As String Dim o4 As String Set Buffer = New clsBuffer Buffer.WriteBytes Data() npcNum = Buffer.ReadLong mT = Buffer.ReadString o1 = Buffer.ReadString o2 = Buffer.ReadString o3 = Buffer.ReadString o4 = Buffer.ReadString Set Buffer = Nothing ' if npcNum is 0, exit the chat system If npcNum = 0 Then inChat = False frmMain.picChat.Visible = False Exit Sub End If ' setup the main window frmMain.lblChatName.Caption = Trim$(NPC(npcNum).Name) frmMain.lblChat.Caption = mT frmMain.lblChatOpt(1).Caption = o1 frmMain.lblChatOpt(2).Caption = o2 frmMain.lblChatOpt(3).Caption = o3 frmMain.lblChatOpt(4).Caption = o4 ' render the face frmMain.picChatFace.Picture = LoadPicture(App.Path & GFX_PATH & "\faces\" & NPC(npcNum).Sprite & ".bmp") ' make it visible frmMain.picChat.Visible = True ' can't move inChat = TrueEnd Sub```**FORM WORK/CODE**in frmMainfind your way to you admin panel and make a new editor cmd button as shown![](http://www.mediafire.com/imgbnc.php/4f4e08fe8d93367bd088fffc27a5474e3646c59b421a562b88a0d42828c11a5f6g.jpg)2x click it and add```If GetPlayerAccess(MyIndex) < ADMIN_DEVELOPER Then AddText "You need to be a high enough staff member to do this!", AlertColor Exit SubEnd If SendRequestEditConv```Now make a Pic box and arrange it to look like this![](http://www.mediafire.com/imgbnc.php/f6c2d5b102ef7b3a5270f4df1c9161db2da2b4d0c75535e8fd1784a5fd4f4e806g.jpg)Name the parts as follows:Large pic box = picChatsmall pic box = picChatFacetop left label = lblChatNamebottom left label = lblChat (make this one large)name all the labels on the rightlblChatOptand give each one an index in order, index can be found in the properties window.lblChatOpt (1)lblChatOpt (2)lblChatOpt (3)lblChatOpt (4)2x click one of the options, any of them, and add```Private Sub lblChatOpt_Click(Index As Integer) SendChatOption IndexEnd Sub```if you set up the index for each right they should all link to that piece of code.In frmEditor_NPCStretch the right side of the form out a bit and add in the shown parts![](http://www.mediafire.com/imgbnc.php/5a2573f1e0cb21807acc2a0e0a8a6932bc2819a6decce7930d0263d337cd796b6g.jpg)Name the parts as follows:checkbox = Chkconvframe = FraConvlabel = LblConvNumscrollbar = ScrlConvSet FraConv visible to False2x click Chkconv and add``` If Chkconv.Value = 1 Then FraConv.Visible = True NPC(EditorIndex).Convo = True Else FraConv.Visible = False NPC(EditorIndex).Convo = False End If```2x click ScrlConv and add``` If scrlConv.Value > 0 Then lblConvNum.Caption = "Conv: " & Trim$(Conv(scrlConv.Value).Name) Else lblConvNum.Caption = "Conv: None" End If NPC(EditorIndex).Conv = scrlConv.Value```In modGame Editorsin Public Sub NpcEditorInit()ABOVE ' find the sound we have set add``` If NPC(EditorIndex).Convo = True Then .FraConv.Visible = True .ScrlConv.Value = NPC(EditorIndex).Conv .LblConvNum.Caption = NPC(EditorIndex).Conv .Chkconv.Value = 1 Else .FraConv.Visible = False .ScrlConv.Value = 1 .LblConvNum.Caption = NPC(EditorIndex).Conv .Chkconv.Value = 0 End If```**SERVER SIDE**Add the attached modConv to your project[http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=74220.0;attach=19038](http://www.touchofdeathforums.com/smf/index.php?action=dlattach;topic=74220.0;attach=19038)in modCombatin Public Function CanPlayerAttackNpcunder```If NpcX = GetPlayerX(attacker) Then If NpcY = GetPlayerY(attacker) Then```add``` If NPC(npcNum).Behaviour = NPC_BEHAVIOUR_FRIENDLY Then If NPC(npcNum).Convo = True Then InitChat attacker, mapNum, mapNpcNum End If Exit Function End If```**OPTIONAL**If you already have the Speech Window mod add this instead of the last part``` If NPC(npcNum).Behaviour = NPC_BEHAVIOUR_FRIENDLY Then If NPC(npcNum).Convo = False Then Call SpeechWindow(attacker, Trim$(NPC(npcNum).AttackSay), npcNum) Else InitChat attacker, mapNum, mapNpcNum End If Exit Function End If```In modDatabase add at the bottom```' ***********' ** Convs **' ***********Sub SaveConvs() Dim i As Long For i = 1 To MAX_CONVS Call SaveConv(i) NextEnd SubSub SaveConv(ByVal convNum As Long) Dim filename As String Dim i As Long, x As Long, F As Long filename = App.Path & "\data\convs\conv" & convNum & ".dat" F = FreeFile Open filename For Binary As #F With Conv(convNum) Put #F, , .Name Put #F, , .chatCount For i = 1 To .chatCount Put #F, , CLng(Len(.Conv(i).Conv)) Put #F, , .Conv(i).Conv For x = 1 To 4 Put #F, , CLng(Len(.Conv(i).rText(x))) Put #F, , .Conv(i).rText(x) Put #F, , .Conv(i).rTarget(x) Next Put #F, , .Conv(i).Event Put #F, , .Conv(i).Data1 Put #F, , .Conv(i).Data2 Put #F, , .Conv(i).Data3 Next End With Close #FEnd SubSub LoadConvs() Dim filename As String Dim i As Long, n As Long, x As Long, F As Long Dim sLen As Long Call CheckConvs For i = 1 To MAX_CONVS filename = App.Path & "\data\convs\conv" & i & ".dat" F = FreeFile Open filename For Binary As #F With Conv(i) Get #F, , .Name Get #F, , .chatCount If .chatCount > 0 Then ReDim .Conv(1 To .chatCount) For n = 1 To .chatCount Get #F, , sLen .Conv(n).Conv = Space$(sLen) Get #F, , .Conv(n).Conv For x = 1 To 4 Get #F, , sLen .Conv(n).rText(x) = Space$(sLen) Get #F, , .Conv(n).rText(x) Get #F, , .Conv(n).rTarget(x) Next Get #F, , .Conv(n).Event Get #F, , .Conv(n).Data1 Get #F, , .Conv(n).Data2 Get #F, , .Conv(n).Data3 Next End With Close #F NextEnd SubSub CheckConvs() Dim i As Long For i = 1 To MAX_CONVS If Not FileExist("\data\convs\conv" & i & ".dat") Then Call SaveConv(i) End If NextEnd SubSub ClearConv(ByVal index As Long) Call ZeroMemory(ByVal VarPtr(Conv(index)), LenB(Conv(index))) Conv(index).Name = vbNullString ReDim Conv(index).Conv(1)End SubSub ClearConvs() Dim i As Long For i = 1 To MAX_CONVS Call ClearConv(i) NextEnd Sub```In modGeneralin Public Sub InitServer()under ' Check if the directory is there, if its not make itadd```ChkDir App.Path & "\Data\", "convs"```under Public Sub ClearGameData() add``` Call SetStatus("Clearing conversations...") Call ClearConvs```under Private Sub LoadGameData() add``` Call SetStatus("Loading conversations...") Call LoadConvs```in modHadleDataunder Public Sub InitMessages() add``` HandleDataSub(CChatOption) = GetAddress(AddressOf HandleChatOption) HandleDataSub(CRequestEditConv) = GetAddress(AddressOf HandleRequestEditConv) HandleDataSub(CSaveConv) = GetAddress(AddressOf HandleSaveConv) HandleDataSub(CRequestConvs) = GetAddress(AddressOf HandleRequestConvs)```and at the bottom of modHandleData add```Sub HandleChatOption(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer Dim i As Long Set Buffer = New clsBuffer Buffer.WriteBytes Data() chatOption index, Buffer.ReadLong Set Buffer = NothingEnd Sub' :::::::::::::::::::::::::::::' :: Request edit Conv packet ::' :::::::::::::::::::::::::::::Sub HandleRequestEditConv(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim Buffer As clsBuffer ' Prevent hacking If GetPlayerAccess(index) < ADMIN_DEVELOPER Then Exit Sub End If Set Buffer = New clsBuffer Buffer.WriteLong SConvEditor SendDataTo index, Buffer.ToArray() Set Buffer = NothingEnd Sub' :::::::::::::::::::::::' :: Save Conv packet ::' :::::::::::::::::::::::Sub HandleSaveConv(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) Dim convNum As Long Dim Buffer As clsBuffer Dim i As Long Dim x As Long ' Prevent hacking If GetPlayerAccess(index) < ADMIN_DEVELOPER Then Exit Sub End If Set Buffer = New clsBuffer Buffer.WriteBytes Data() convNum = Buffer.ReadLong ' Prevent hacking If convNum < 0 Or convNum > MAX_CONVS Then Exit Sub End If With Conv(convNum) .Name = Buffer.ReadString .chatCount = Buffer.ReadLong ReDim .Conv(1 To .chatCount) For i = 1 To .chatCount .Conv(i).Conv = Buffer.ReadString For x = 1 To 4 .Conv(i).rText(x) = Buffer.ReadString .Conv(i).rTarget(x) = Buffer.ReadLong Next .Conv(i).Event = Buffer.ReadLong .Conv(i).Data1 = Buffer.ReadLong .Conv(i).Data2 = Buffer.ReadLong .Conv(i).Data3 = Buffer.ReadLong Next End With ' Save it Call SendUpdateConvToAll(convNum) Call SaveConv(convNum) Call AddLog(GetPlayerName(index) & " saved Conv #" & convNum & ".", ADMIN_LOG)End SubSub HandleRequestConvs(ByVal index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long) SendConvs indexEnd Sub```In modPlayerin Sub JoinGameunder ' Send some more little goodies, no need to explain theseadd```Call SendConvs(index)```in modServerTCP add at the bottom```Sub SendConvs(ByVal index As Long) Dim i As Long For i = 1 To MAX_CONVS If LenB(Trim$(Conv(i).Name)) > 0 Then Call SendUpdateConvTo(index, i) End If NextEnd SubSub SendUpdateConvToAll(ByVal convNum As Long) Dim packet As String Dim Buffer As clsBuffer Dim i As Long Dim x As Long Set Buffer = New clsBuffer Set Buffer = New clsBuffer Buffer.WriteLong SUpdateConv Buffer.WriteLong convNum With Conv(convNum) Buffer.WriteString .Name Buffer.WriteLong .chatCount For i = 1 To .chatCount Buffer.WriteString .Conv(i).Conv For x = 1 To 4 Buffer.WriteString .Conv(i).rText(x) Buffer.WriteLong .Conv(i).rTarget(x) Next Buffer.WriteLong .Conv(i).Event Buffer.WriteLong .Conv(i).Data1 Buffer.WriteLong .Conv(i).Data2 Buffer.WriteLong .Conv(i).Data3 Next End With SendDataToAll Buffer.ToArray() Set Buffer = NothingEnd SubSub SendUpdateConvTo(ByVal index As Long, ByVal convNum As Long) Dim packet As String Dim Buffer As clsBuffer Dim i As Long Dim x As Long Set Buffer = New clsBuffer Buffer.WriteLong SUpdateConv Buffer.WriteLong convNum With Conv(convNum) Buffer.WriteString .Name Buffer.WriteLong .chatCount For i = 1 To .chatCount Buffer.WriteString .Conv(i).Conv For x = 1 To 4 Buffer.WriteString .Conv(i).rText(x) Buffer.WriteLong .Conv(i).rTarget(x) Next Buffer.WriteLong .Conv(i).Event Buffer.WriteLong .Conv(i).Data1 Buffer.WriteLong .Conv(i).Data2 Buffer.WriteLong .Conv(i).Data3 Next End With SendDataTo index, Buffer.ToArray() Set Buffer = NothingEnd SubSub SendChatUpdate(ByVal index As Long, ByVal npcNum As Long, ByVal mT As String, ByVal o1 As String, ByVal o2 As String, ByVal o3 As String, ByVal o4 As String) Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.WriteLong SChatUpdate Buffer.WriteLong npcNum Buffer.WriteString mT Buffer.WriteString o1 Buffer.WriteString o2 Buffer.WriteString o3 Buffer.WriteString o4 SendDataTo index, Buffer.ToArray() Set Buffer = NothingEnd Sub```in modtypesadd to the botom of Public Type TempPlayerRec``` inChatWith As Long curChat As Long c_mapNum As Long c_mapNpcNum As Long```**DONE**TEDA! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now