Golf Posted April 23, 2015 Author Share Posted April 23, 2015 Mystery Box System 1.0At the end of tutorial it should look like this:![](http://i.imgur.com/jjOc0MW.png)**Client side**In frmEditor_Item add new frame fraBox and in that frame add label lblBox and scrollbar scrlBoxIt should look like this![](http://i.imgur.com/nCvDCUg.png)In scrlBox code add:``` If EditorIndex < 1 Or EditorIndex > MAX_ITEMS Then Exit Sub lblBox.Caption = "Box: " & scrlBox.value item(EditorIndex).CBoxNumber = scrlBox.value Exit Sub```Now in cmbType List at the end add "Box"In modConstants add:```Public Const ITEM_TYPE_BOX As Byte = 9```In modEnumerations add:```SMysteryBox```In modGameEditors in sub ItemInit before End With add``` 'Box If (frmEditor_Item.cmbType.ListIndex = ITEM_TYPE_BOX) Then frmEditor_Item.fraBox.Visible = True frmEditor_Item.scrlBox.value = .CBoxNumber Else frmEditor_Item.fraBox.Visible = False End If```In modHandleData in sub InitMessages add:```HandleDataSub(SMysteryBox) = GetAddress(AddressOf HandleMysteryBox)```In same module add:```Private Sub HandleMysteryBox(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim itemnumber As ByteDim value As String Set Buffer = New clsBuffer Buffer.WriteBytes Data() itemnumber = Buffer.ReadLong value = Buffer.ReadString OpenMystery itemnumber, valueEnd Sub```Create new module and name it modMysteryBox and add in it :```Public Sub OpenMystery(ByVal itemnum As Integer, ByVal value As String)Dim itempic As Longitempic = item(itemnum).PicfrmMysteryBox.ShowfrmMysteryBox.lblItemName.Caption = value & " " & item(itemnum).NameEnd Sub```In ModGeneral in sub LoadGUI add:```frmMysteryBox.Picture = LoadPicture(App.Path & "\data files\graphics\gui\main_mystery.bmp")```In modTypes in Type ItemRec add:```CBoxNumber As Byte```**SERVER SIDE**Create new module and name it modBox and in it add:```Public Sub OpenMystery(index As Long, caseID As Long)Dim n As Byte Select Case caseID Case "0" PlayerMsg index, "I feel lucky today!", White PlayerMsg index, "You've obtained Nothing", Red SendPlayerData index Case "1" PlayerMsg index, "I feel lucky today!", White n = Random(0, 20) If (n < 1) Then Call GiveInvItem(index, 1, 100000, True) PlayerMsg index, "You've obtained 100k $", Red SendMysteryBox index, 1, "100k" ElseIf (n < 5) Then Call GiveInvItem(index, 1, 1000000, True) PlayerMsg index, "You've obtained 1M $", Red SendMysteryBox index, 1, "1 Million" Else Call GiveInvItem(index, 1, 1, True) PlayerMsg index, "You've obtained 1$", Red SendMysteryBox index, 1, "1" SendPlayerData index End If Case Else End SelectEnd Sub```In modConstants add:```Public Const ITEM_TYPE_BOX As Byte = 9```In modEnumerations add:```SMysteryBox```In modServerTcp add :```Public Sub SendMysteryBox(ByVal index As Long, ByVal itemnum As Long, ByVal Value As String) SendActionMsg GetPlayerMap(index), "I just won " & Value & " " & Item(itemnum).Name, Pink, ACTIONMSG_SCROLL, GetPlayerX(index) * 32, GetPlayerY(index) * 32 Dim Buffer As clsBuffer Set Buffer = New clsBuffer Buffer.WriteLong SMysteryBox Buffer.WriteLong itemnum Buffer.WriteString Value SendDataTo index, Buffer.ToArray Set Buffer = NothingEnd Sub```In modPlayer in sub UseItem before End Select add:``` Case ITEM_TYPE_BOX 'get box number n = Item(itemnum).CBoxNumber Call OpenMystery(index, n) Call TakeInvItem(index, itemnum, 1)```In modTypes in Type ItemRec add```CBoxNumber As Byte```Now you are DONE!**Without this system wont work!****Download files [here](https://www.mediafire.com/?agukh66lbf1xxgx).****Paste main_mystery.bmp in data files\graphics\GUI****Inside client source in folder Forms open frmMysteryBox . Also paste frmMysteryBox in src folder.** Link to comment Share on other sites More sharing options...
JeffSventora Posted April 23, 2015 Share Posted April 23, 2015 Why not post this when it's written? Sounds like a cool idea but there's nothing to see here :( Link to comment Share on other sites More sharing options...
BeNjO Posted April 23, 2015 Share Posted April 23, 2015 Already done and released under "Chests", random loot decider. Will be nice to compare systems :) And seriously, Nice work on the 9 line posts and then getting tired. I'm sure that was a lot of work :) Link to comment Share on other sites More sharing options...
Golf Posted April 23, 2015 Author Share Posted April 23, 2015 Done !Well,I wasn't really tired I needed to go to school so I didn't have time to finish it.Now its finished! (With Images) Link to comment Share on other sites More sharing options...
Golf Posted April 24, 2015 Author Share Posted April 24, 2015 Update:Server side:In modServerTCP in sub SendMysteryBox.At the top of sub add :```SendActionMsg GetPlayerMap(index), "I just won " & Value & " " & Item(itemnum).Name, Pink, ACTIONMSG_SCROLL, GetPlayerX(index) * 32, GetPlayerY(index) * 32``` Link to comment Share on other sites More sharing options...
abhi2011 Posted April 24, 2015 Share Posted April 24, 2015 Nice work. I read through the code but I found that this only rewards the player with the first item. Why not expand on this idea? Like the game maker can decide which item(s) to give, how many of those items to give, check for inventory space before giving the item and stuff. Link to comment Share on other sites More sharing options...
Golf Posted April 24, 2015 Author Share Posted April 24, 2015 Well , you can edit code to edit rewards, also Box Editor can be added :)And mystery box rewards with only one random item thats why its mystery. Link to comment Share on other sites More sharing options...
DarkDino Posted April 29, 2015 Share Posted April 29, 2015 Nice tutorial, In select case you don't need use the "" (Case "0") because caseID var are a Long/Number :)!. Link to comment Share on other sites More sharing options...
hisherwin Posted April 29, 2015 Share Posted April 29, 2015 Yay! Boxes that contain only gold coins..….........Erm, it's not Mystery at all O.o 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