[Guide] Stall-Function 4 VB
*Update*
We got now MultiPlayer-Support for Stall.
Add this to your modGlobal.bas
Code:
Private Type pData
...
...
NewStall As Boolean
StallIsOpen As Boolean
StallName As String
StallWelcomeMessage As String
End Type
Add this to your modGamerServer.bas
ParseGameData opCodes:
Code:
Case "7049" 'Stallname Request first time
HandleStallNameRequest index, sData
Case "71A8" 'Various Stall Functions
HandleStallOperations index, sData
Case "761F" 'Go Inside Stall
HandleGoInsideStall index, sData
Case "76E7" 'Leave Stall
HandleLeaveStall index, sData
Case "742C" 'Close Stall
CloseStall index, sData
Now the 5 Functions
When Player Wants to Create StreetStall:
Code:
Public Function HandleStallNameRequest(index As Integer, data As String)
PlayerData(index).StallName = Mid(data, 5, (Len(data) - 4))
fData = "df30" & "0000"
fData = fData & PlayerData(index).CharID
pLen = (Len(PlayerData(index).StallName)) / 4 '/4 because [1char] = [2hex chars] + [00]
fData = fData & WordFromInteger(pLen)
fData = fData & PlayerData(index).StallName & "00000000"
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
PlayerData(index).NewStall = True
End Function
Every StallOperation (Open, Modify, ChangeName):
Code:
Public Function HandleStallOperations(index As Integer, data As String)
Select Case Left(data, 2)
Case "02" 'put item in stall
'this is what we are on now
Case "05" 'clicked the Open/Modify button
fData = "A8B1" & "0000"
fData = fData & "01" & "05"
Select Case Mid(data, 3, 2)
Case "01" 'Open the stall
Select Case Right(data, 2)
Case "00" 'without stallnetwork
fData = fData & "0100"
Case "01" 'with stallnetwork
fData = fData & "014A"
Case "03" 'Client saved that you want to use stallnetwork
fData = fData & "0103"
End Select
Case "00" 'Modify the stall
Select Case Right(data, 2)
Case "00" 'without stallnetwork
fData = fData & "0000"
Case "03" 'with stallnetwork
fData = fData & "0003"
End Select
End Select
If PlayerData(index).StallIsOpen = True Then
PlayerData(index).StallIsOpen = False
Else
PlayerData(index).StallIsOpen = True
End If
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
Case "06"
PlayerData(index).StallWelcomeMessage = Mid(data, 7, (Len(data) - 6))
If PlayerData(index).NewStall = True Then
fData = "49B0" & "0000"
fData = fData & "01"
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
PlayerData(index).NewStall = False
End If
fData = "A8B1" & "0000"
fData = fData & "01"
fData = fData & "06"
pLen = (Len(PlayerData(index).StallWelcomeMessage)) / 4 '/4 becaus [1char] = [2hex chars] + [00]
fData = fData & WordFromInteger(pLen)
fData = fData & PlayerData(index).StallWelcomeMessage
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
Case "07"
PlayerData(index).StallName = Mid(data, 7, (Len(data) - 6))
fData = "B734" & "0000"
fData = fData & PlayerData(index).CharID
pLen = (Len(PlayerData(index).StallName)) / 4 '/4 becaus [1char] = [2hex chars] + [00]
fData = fData & WordFromInteger(pLen)
fData = fData & PlayerData(index).StallName
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
End Select
End Function
Code:
Public Function HandleGoInsideStall(index As Integer, data As String)
Dim StallOwnerID As String
Dim StallOwnerWinSock As Integer
StallOwnerID = Left(data,
For i = 1 To UBound(PlayerData)
If PlayerData(i).CharID = StallOwnerID Then
StallOwnerWinSock = i
Exit For
End If
Next i
fData = "AB36" & "0000"
fData = "C5346203"
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
frmMain.GameSocket(index).SendData cv_StringFromHex(fData)
fData = "1FB6" & "0000"
fData = fData & "01"
fData = fData & StallOwnerID
pLen = (Len(PlayerData(StallOwnerWinSock).StallWelcomeMessage) / 4)
fData = fData & WordFromInteger(pLen)
fData = fData & PlayerData(StallOwnerWinSock).StallWelcomeMessage
Select Case PlayerData(StallOwnerWinSock).StallIsOpen
Case True
fData = fData & "0100" 'Send that the target is open allready
Case False
fData = fData & "0000" 'Send that the target stall is in modifying status
End Select
fData = fData & "FF00"
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
frmMain.GameSocket(index).SendData cv_StringFromHex(fData)
frmMain.lstGameServerPacketsOut.additem fData
fData = "6032" & "0000"
fData = fData & "02" 'Let Player appear in StallVisitor-List
fData = fData & PlayerData(index).CharID
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).CharID = StallOwnerID Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
frmMain.lstGameServerPacketsOut.additem fData
End Function
When player leaves a StreetStall:
Code:
Public Function HandleLeaveStall(index As Integer, data As String)
fData = "E7B6" & "0000"
fData = fData & "01"
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
frmMain.GameSocket(index).SendData cv_StringFromHex(fData)
frmMain.lstGameServerPacketsOut.additem fData
fData = "6032" & "0000"
fData = fData & "01" 'Let Player disappear in StallVisitor-List
fData = fData & PlayerData(index).CharID
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
frmMain.lstGameServerPacketsOut.additem fData
End Function
When player closes his Stall:
Code:
Public Function CloseStall(index As Integer, data As String)
fData = "D133" & "0000"
fData = fData & PlayerData(index).CharID
fData = fData & "17"
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
fData = "2CB4" & "0000"
fData = fData & "01"
pLen = (Len(fData) -
/ 2
fData = WordFromInteger(pLen) & fData
For i = 1 To UBound(PlayerData)
If PlayerData(i).Ingame = True Then
frmMain.GameSocket(i).SendData cv_StringFromHex(fData)
End If
Next i
End Function