JohnPony Posted October 15, 2012 Author Share Posted October 15, 2012 **Option 1, Download the client & server with this feature added.**[http://www.mmorpgcre…tionHouseEO.rar](http://www.mmorpgcreation.com/AuctionHouseEO.rar)**Option 2, Add the tutorial into your existing project.**First off download this attachment set and add it to the server and client.[http://www.mmorpgcre…/Attachment.rar](http://www.mmorpgcreation.com/Attachment.rar)Now we will start with the client.Add frmAuction and modAuction to your project if you have no already.Now in modHandleData add:```HandleDataSub(SAuct) = GetAddress(AddressOf HandleRecieveAAucts)```And at the bottom add:```Private Sub HandleRecieveAAucts(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim num As LongDim i As LongSet Buffer = New clsBuffer With Buffer .WriteBytes Data For i = 1 To 100 Auction(i).Owner = .ReadString Auction(i).Item = .ReadLong Auction(i).Price = .ReadLong Auction(i).MaxBid = .ReadLong Auction(i).EndDate = .ReadLong Auction(i).Amount = .ReadLong Auction(i).Bid = .ReadLong Next i End With Set Buffer = NothingWith frmAuctions .lstAuctions.Clear For i = 1 To 100 If Auction(i).Owner <> vbNullString Then .lstAuctions.AddItem Item(Auction(i).Item).Name & " Price: " & Auction(i).Price Else .lstAuctions.AddItem "Empty" End If Next iEnd WithEnd Sub```Next in modGraphics in Public Sub DrawGDI() add:```If frmAuctions.fraNew.Visible Then If CurrentAuctionselections <> 0 Then DrawAuctionItemDesc CurrentAuctionselections End If End If```And at the bottom of modGraphics add:```Public Sub DrawAuctionItemDesc(ByVal ItemNum As Long)Dim rec As RECT, rec_pos As RECT, srcRect As D3DRECT, destRect As D3DRECTDim itempic As Long' If debug mode, handle error then exit outIf Options.Debug = 1 Then On Error GoTo errorhandler'frmMain.picItemDescPic.ClsIf ItemNum > 0 And ItemNum <= MAX_ITEMS Then itempic = Item(GetPlayerInvItemNum(MyIndex, ItemNum)).Pic If itempic = 0 Then Exit Sub Direct3D_Device.Clear 0, ByVal 0, D3DCLEAR_TARGET, D3DColorRGBA(0, 0, 0, 0), 1#, 0 Direct3D_Device.BeginScene With rec .Top = 0 .Bottom = .Top + PIC_Y .Left = Tex_Item(itempic).Width / 2 .Right = .Left + PIC_X End With With rec_pos .Top = 0 .Bottom = 64 .Left = 0 .Right = 64 End With RenderTextureByRects Tex_Item(itempic), rec, rec_pos With destRect .X1 = 0 .Y1 = 0 .y2 = 64 .x2 = 64 End With Direct3D_Device.EndScene Direct3D_Device.Present destRect, destRect, frmAuctions.picItem.hWnd, ByVal (0)End If' Error handlerExit Suberrorhandler:HandleError "DrawAuctionItemDesc", "modGraphics", Err.Number, Err.Description, Err.Source, Err.HelpContextErr.ClearExit SubEnd Sub```Next will involve adding a button or label of some sort, and adding this to the click handler:```frmAuctions.Visible = TruefrmAuctions.fraMain.Visible = TruefrmAuctions.fraNew.Visible = FalsefrmAuctions.fraBuy.Visible = FalseCall SendGetAuctions```Now in Private Sub picInventory_DblClick() Add:```If IsPickingItem = True Then CurrentAuctionselections = InvNum IsPickingItem = False Exit Sub End If```Above:```' use item if not doing anything else If Item(GetPlayerInvItemNum(MyIndex, InvNum)).Type = ITEM_TYPE_NONE Then Exit Sub Call SendUseItem(InvNum) Exit SubEnd If```And finally with the server packets add:```SAuct```and with the client packets add:```CAddAuctCCheckAuctCBid```Now lets move on to the server.Add the appropriate files included with the attachments into your server's source.in modDatabase add:```Public Sub SaveAuctions(ByVal AuctionNum As Long)Dim Filename As StringDim F As LongFilename = App.path & "\data\auctions\auction" & AuctionNum & ".dat"F = FreeFileOpen Filename For Binary As #FPut #F, , Auction(AuctionNum)Close #FEnd SubPublic Sub CheckAuctions()Dim i As LongFor i = 1 To 100If Not FileExist("\data\auctions\auction" & i & ".dat") ThenCall SaveAuction(i)End IfNext iEnd SubSub SaveAuction(ByVal AuctionNum As Long)Dim Filename As StringDim F As LongFilename = App.path & "\data\auctions\auction" & AuctionNum & ".dat"F = FreeFileOpen Filename For Binary As #FPut #F, , Auction(AuctionNum)Close #FEnd SubSub LoadAuctions()Dim Filename As StringDim F As LongDim i As LongCall CheckAuctionsFor i = 1 To 100Filename = App.path & "\data\auctions\auction" & i & ".dat"F = FreeFileOpen Filename For Binary As #FGet #F, , Auction(i)Close #FNext iEnd Sub```And in modGeneral in InitServer add:```ChkDir App.path & "\Data\", "auctions"```Next in sub LoadGameData() add:```Call SetStatus("Starting Up The Auction House...")Call LoadAuctions```Next in modHandleData add:```HandleDataSub(CAddAuct) = GetAddress(AddressOf HandleAddAuction)HandleDataSub(CCheckAuct) = GetAddress(AddressOf HandleGetAuctions)HandleDataSub(CBid) = GetAddress(AddressOf HandleBid)```And at the bottom of the module add:```Private Sub HandleGetAuctions(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Call SendAuctions(Index)End SubPrivate Sub HandleAddAuction(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim InvItem As LongDim ItemNum As LongDim Price As LongDim MaxPrice As LongDim Buffer As clsBufferSet Buffer = New clsBufferBuffer.WriteBytes Data()InvItem = Buffer.ReadLongPrice = Buffer.ReadLongMaxPrice = Buffer.ReadLongSet Buffer = NothingItemNum = GetPlayerInvItemNum(Index, InvItem)If Price <> 0 ThenCall AddAuction(Index, ItemNum, 1, Price, MaxPrice)ElseCall PlayerMsg(Index, "Your Price Must Be Above 0!", Red)End IfEnd Sub```now in modServerTcp at the bottom add:```Public Sub SendAuctions(Optional Index As Long)Dim Buffer As clsBufferDim i As LongSet Buffer = New clsBufferBuffer.WriteLong SAuctFor i = 1 To 100 With Auction(i) Buffer.WriteString .Owner Buffer.WriteLong .Item Buffer.WriteLong .Price Buffer.WriteLong .MaxBid Buffer.WriteLong .EndDate Buffer.WriteLong .Amount Buffer.WriteLong .Bid End WithNext iIf Index = 0 Then SendDataToAll Buffer.ToArrayElse SendDataTo Index, Buffer.ToArrayEnd IfSet Buffer = NothingEnd Sub```and in modServerLoop in Sub ServerLoop() add:```Dim LastCheckAuction As Long```At the top and```If Tick > LastCheckAuction Then For i = 1 To 100 If Auction(i).Owner <> vbNullString Then Call RemoveDeadAuction(i) End If Next i LastCheckAuction = GetTickCount + 300000 End If```Somewhere in the procedure.Now lets head over to modPlayer and in Sub JoinGame() add:```If Player(Index).BidWon > 0 Then Call PlayerMsg(Index, "You Have Won A Auction!", Red) Call GiveInvItem(Index, Player(Index).BidWon, Player(Index).BidWonAmount, True) Player(Index).BidWon = 0 Player(Index).BidWonAmount = 0End If```And:``` If Player(Index).Money > 0 Then Call PlayerMsg(Index, "You Reieve Money From The Auction House!", Red) Call GiveInvItem(Index, 1, Player(Index).Money, True) Player(Index).Money = 0 End If```And last but not least add:```SAuct```with the server packets and:```CAddAuctCCheckAuctCBid```with the client packets.And finally add:```Money As LongBidWon As LongBidWonAmount as long```To the bottom of the player recCongratulations, you are done.If you notice any bugs, or find any; feel free to post below! Link to comment Share on other sites More sharing options...
JohnPony Posted October 15, 2012 Author Share Posted October 15, 2012 **Addons & Extras:**if you added this tutorial before 10/18/2012 please add the following bugfix:Anyone who has already begun the tutorial, add the following things to modAuctions server side.```Private Sub AuctionSoldOut(ByVal AuctionNum As Long, ByVal Name As String)Dim i As LongDim Filename As StringDim F As LongDim PlayerName As Stringi = Player_HighIndex + 3Call ClearPlayer(i)Filename = App.path & "\data\accounts\" & Trim(Name) & ".bin"F = FreeFileOpen Filename For Binary As #FGet #F, , Player(i)Close #FPlayer(i).Money = Auction(AuctionNum).BidFilename = App.path & "\data\accounts\" & Trim(Name) & ".bin"F = FreeFileOpen Filename For Binary As #FPut #F, , Player(i)Close #FCall ClearPlayer(i)End Sub```And in BidOnAuction replace the previous bid procedure with this:```' Lets check if we won!If Bid >= Auction(AuctionNum).MaxBid ThenCall PlayerMsg(Index, "You Have Won " & Trim$(Item(Auction(AuctionNum).Item).Name) & " !", Red)Call GiveInvItem(Index, Auction(AuctionNum).Item, 0, True)If SellerIndex <> 0 ThenCall GiveInvItem(SellerIndex, 1, Auction(AuctionNum).Bid, True)Call PlayerMsg(SellerIndex, "Your auction has sold!", Red)ElseCall AuctionSoldOut(AuctionNum, Auction(AuctionNum).Owner)End IfCall DestroyAuction(AuctionNum)Call SendAuctionsElse' We are not quite there yet ;DCall PlayerMsg(Index, "You Are " & Auction(AuctionNum).MaxBid - Bid & " Away from winning this auction!", Red)End If```Find``` If Player(Index).Money > 0 Then```in Sub JoinGame and replace it with:```If Player(Index).Money > 0 Then Call PlayerMsg(Index, "You Reieve Money From The Auction House!", Red) Call GiveInvItem(Index, 1, Player(Index).Money, True) Player(Index).Money = 0End If``````Private Sub HandleBid(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Dim Buffer As clsBufferDim Bid As LongDim Num As LongSet Buffer = New clsBuffer Buffer.WriteBytes Data With Buffer Num = .ReadLong Bid = .ReadLong End With Call BidOnAuction(Index, Bid, Num)Set Buffer = NothingEnd Sub``` Link to comment Share on other sites More sharing options...
Alerd Posted October 15, 2012 Share Posted October 15, 2012 work to eo 2.3? or only work to eo 3.0? Link to comment Share on other sites More sharing options...
JohnPony Posted October 15, 2012 Author Share Posted October 15, 2012 > work to eo 2.3? or only work to eo 3.0?Besides the rendering procedure part of the tutorial, yes.I'll show you how to do the same in DD7 if you cannot figure it out yourself. Link to comment Share on other sites More sharing options...
Neroxx Posted October 16, 2012 Share Posted October 16, 2012 how do I compile…? Link to comment Share on other sites More sharing options...
highonpaint Posted October 16, 2012 Share Posted October 16, 2012 > how do I compile…?You need to go to file create new .exe or whatever the client is called Link to comment Share on other sites More sharing options...
Neroxx Posted October 16, 2012 Share Posted October 16, 2012 > You need to go to file create new .exe or whatever the client is calledCould you explain it a little better please? c: Link to comment Share on other sites More sharing options...
Nazban Posted October 16, 2012 Share Posted October 16, 2012 Omfg an Auction House…!? Is this for real does it even work? This has got to be hands down one of my favorite addons I have seen in a bit. Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 Could you make it so that when a player steps a tile it activates the action house form ? (don't need to do the scripted tile system, just make the functions to send the packets to open the window, I suck at the Client-Server Interaction :\ Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 Tested it and it says:compile error: variable not defined ( HandleDataSub(CCheckAuct) = GetAddress(AddressOf HandleGetAuctions) ) Link to comment Share on other sites More sharing options...
highonpaint Posted October 17, 2012 Share Posted October 17, 2012 > Omfg an Auction House…!? Is this for real does it even work? This has got to be hands down one of my favorite addons I have seen in a bit.Yes it works it is actually really good Link to comment Share on other sites More sharing options...
highonpaint Posted October 17, 2012 Share Posted October 17, 2012 > Tested it and it says:> > compile error: variable not defined ( HandleDataSub(CCheckAuct) = GetAddress(AddressOf HandleGetAuctions) )you have maybe made a error somewhere? Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 don't think so, I did it calmly and with attention, maybe he might have forgotten to put it Link to comment Share on other sites More sharing options...
highonpaint Posted October 17, 2012 Share Posted October 17, 2012 can you add me on skype and send me your client folder I will do it for you if you want Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 just put the code for HandleGetAuctions() here, as easy as that xD Link to comment Share on other sites More sharing options...
highonpaint Posted October 17, 2012 Share Posted October 17, 2012 kk Link to comment Share on other sites More sharing options...
Ertzel Posted October 17, 2012 Share Posted October 17, 2012 Server Side in modHandleData```Private Sub HandleGetAuctions(ByVal Index As Long, ByRef Data() As Byte, ByVal StartAddr As Long, ByVal ExtraVar As Long)Call SendAuctions(Index)End Sub```Then SendAuctions is in modServerTCP and is the following incase you don't have it```Public Sub SendAuctions(Optional Index As Long)Dim buffer As clsBufferDim i As LongSet buffer = New clsBufferbuffer.WriteLong SAuctFor i = 1 To 100 With Auction(i) buffer.WriteString .Owner buffer.WriteLong .Item buffer.WriteLong .Price buffer.WriteLong .MaxBid buffer.WriteLong .EndDate buffer.WriteLong .Amount buffer.WriteLong .Bid End WithNext iIf Index = 0 Then SendDataToAll buffer.ToArrayElse SendDataTo Index, buffer.ToArrayEnd IfSet buffer = NothingEnd Sub``` Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 could you also give the the HandleBid() ? (maybe he deleted it while editing the post…)I have the SendAuctions(), just look at the main post and see if it's not really there, my pc might have something wrong with it, but I see there are stuff missing Link to comment Share on other sites More sharing options...
Ertzel Posted October 17, 2012 Share Posted October 17, 2012 Download the completed server/client sources in the main topic and rip the pieces mission in the tutorial out from them. Thats all I did to get you the info above and you can do it on your own easier then me doing it on my own and then posting it for you to still have to do on your own…. Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 $hit, didn't think of that XD Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 could someone help me putting this is CS:DE, I'm getting errors in the GDI part cause it's written in a different way s:nvm, did it somehow… Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 houm… when I put an item for trade and then try to buy it it throws and RTE 76: Path not found, and it highlights this:---- Le Code -----------------------------------------------------' Outputs string to text fileSub AddLog(ByVal Text As String, ByVal FN As String)Dim Filename As StringDim F As LongIf ServerLog ThenFilename = App.Path & "\data\logs\" & FNIf Not FileExist(Filename, True) ThenF = FreeFileOpen Filename For Output As #FClose #FEnd IfF = FreeFileOpen Filename For Append As #FPrint #F, Time & ": " & TextClose #FEnd IfEnd Sub–------------------------------------------------------------- Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 why do I get the feeling it has something to do with this:``` 'Something went south, most likely a account deletion. Log it just incase Call AddLog("Auction Failed To Find A Player And Return " & Bid & " To Them!", "")```Is it because I was the one who put the item for sale ? Link to comment Share on other sites More sharing options...
Slasheree Posted October 17, 2012 Share Posted October 17, 2012 you sure you tested it all, I comented out the Call AddLog and now it all works, but if I Place a Bid equal to the Buy out price it gives me and error and goes to the Sub ClearPlayer() ._. Link to comment Share on other sites More sharing options...
Ertzel Posted October 17, 2012 Share Posted October 17, 2012 I can use the auction house perfectly fine without any errors. You might want to go back to a fresh version of whatever Eclipse your using from before you added in the auction system and re-add it by ripping it out of the pre-compiled source since the tutorial is missing peaces and it looks like your current source also is. 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