| Mirage Source http://www.miragesource.net/forums/ |
|
| Shops Not Showing Up http://www.miragesource.net/forums/viewtopic.php?f=201&t=1832 |
Page 1 of 1 |
| Author: | James [ Mon May 21, 2007 4:00 am ] |
| Post subject: | Shops Not Showing Up |
I place a shop on a map, and if i have a Spell in there, it will tell me that teh spell can be sued by X class, or all clases, but it will NOT show the trade form. here is my shop code: ModHandleData (Server) Code: ' :::::::::::::::::: ' :: Trade packet :: ' :::::::::::::::::: If LCase$(Parse(0)) = "trade" Then If Map(GetPlayerMap(Index)).Shop > 0 Then Call SendTrade(Index, Map(GetPlayerMap(Index)).Shop) Else Call PlayerMsg(Index, "There is no shop here.", BrightRed) End If Exit Sub End If ModServerTCP Code: Sub SendTrade(ByVal Index As Long, ByVal ShopNum As Long) Dim Packet As String Dim I As Long, X As Long, y As Long Packet = "TRADE" & SEP_CHAR & Trim$(ShopNum) & SEP_CHAR & Shop(ShopNum).FixesItems & SEP_CHAR For I = 1 To MAX_TRADES Packet = Packet & Shop(ShopNum).TradeItem(I).GiveItem & SEP_CHAR & Shop(ShopNum).TradeItem(I).GiveValue & SEP_CHAR & Shop(ShopNum).TradeItem(I).GetItem & SEP_CHAR & Shop(ShopNum).TradeItem(I).GetValue & SEP_CHAR ' Item # X = Shop(ShopNum).TradeItem(I).GetItem If Item(X).Type = ITEM_TYPE_SPELL Then ' Spell class requirement y = Spell(Item(X).Data1).ClassReq If y = 0 Then Call PlayerMsg(Index, Trim$(Item(X).name) & " can be used by all classes.", Yellow) Else Call PlayerMsg(Index, Trim$(Item(X).name) & " can only be used by a " & GetClassName(y - 1) & ".", Yellow) End If End If Next I Packet = Packet & END_CHAR Call SendDataTo(Index, Packet) End Sub ModHandleData (Client) Code: ' ::::::::::::::::::
' :: Trade packet :: ' :::::::::::::::::: If (LCase(Parse(0)) = "trade") Then ShopNum = Val(Parse(1)) If Val(Parse(2)) = 1 Then frmTrade.picFixItems.Visible = True Else frmTrade.picFixItems.Visible = False End If N = 3 For I = 1 To MAX_TRADES GiveItem = Val(Parse(N)) GiveValue = Val(Parse(N + 1)) GetItem = Val(Parse(N + 2)) GetValue = Val(Parse(N + 3)) If GiveItem > 0 And GetItem > 0 Then frmTrade.lstTrade.AddItem "Give " & Trim(Shop(ShopNum).name) & " " & GiveValue & " " & Trim(Item(GiveItem).name) & " for " & GetValue & " " & Trim(Item(GetItem).name) End If N = N + 4 Next I If frmTrade.lstTrade.ListCount > 0 Then frmTrade.lstTrade.ListIndex = 0 End If frmTrade.Show vbModal Exit Sub End If Any idea why the thing isn't popping up? |
|
| Author: | Ramsey [ Mon May 21, 2007 4:04 am ] |
| Post subject: | |
Isn't there suppose to be a frmTrade.Visible? |
|
| Author: | James [ Mon May 21, 2007 4:08 am ] |
| Post subject: | |
No, check your source, its the same. I also setup a block in the Client-Side handledata sub to alert me when it recieves the TRADE packet from the server, and after I type /trade, it does NOT recieve the trade packet. odd. |
|
| Author: | William [ Mon May 21, 2007 10:15 am ] |
| Post subject: | |
It looks fine, the only difference to my code is that I have: Code: If frmTrade.Visible = True Then
frmTrade.Visible = False Else frmTrade.Show vbModal End If But it should not matter anything. |
|
| Author: | Matt [ Mon May 21, 2007 1:07 pm ] |
| Post subject: | |
Actually, it should matter. I too have that bit of code William. How can you expect it to show frmTrade, if you don't have it call to show it? |
|
| Author: | William [ Mon May 21, 2007 1:47 pm ] |
| Post subject: | |
He already have: Code: frmTrade.Show vbModal
So it should not make much a difference. |
|
| Author: | James [ Mon May 21, 2007 9:03 pm ] |
| Post subject: | |
Again, to remind everyone, it isnt even sending the packet with the trade, because modhandleData isnt recognizing it.. |
|
| Author: | William [ Mon May 21, 2007 9:04 pm ] |
| Post subject: | |
then try to name it something else. |
|
| Author: | James [ Tue May 22, 2007 2:20 am ] |
| Post subject: | |
I setup breaks on the server in debug mode to tell me WHEN it was calling SendDataTo(Index, packet). Well, to my surprise, after the Next I, it was skipped. I don't even know...why? I mean, I recently changed some of the things from integers, to longs, and vice versa, so here are all of my recs and stuff with shops. Client Side Code: Type TradeItemRec GiveItem As Long GiveValue As Long GetItem As Long GetValue As Long End Type Type ShopRec name As String * NAME_LENGTH JoinSay As String * 255 LeaveSay As String * 255 FixesItems As Byte TradeItem(1 To MAX_TRADES) As TradeItemRec End Type Code: ' Request Trade If LCase(Mid(MyText, 1, 6)) = "/trade" Then Call SendData("trade" & SEP_CHAR & END_CHAR) MyText = "" Exit Sub End If Code: Private Sub picTrade_Click() Call SendData("trade" & SEP_CHAR & END_CHAR) End Sub Code: ' :::::::::::::::::: ' :: Trade packet :: ' :::::::::::::::::: If (LCase(Parse(0)) = "trade") Then ShopNum = Val(Parse(1)) If Val(Parse(2)) = 1 Then frmTrade.picFixItems.Visible = True Else frmTrade.picFixItems.Visible = False End If n = 3 For I = 1 To MAX_TRADES GiveItem = Val(Parse(n)) GiveValue = Val(Parse(n + 1)) GetItem = Val(Parse(n + 2)) GetValue = Val(Parse(n + 3)) If GiveItem > 0 And GetItem > 0 Then frmTrade.lstTrade.AddItem "Give " & Trim(Shop(ShopNum).name) & " " & GiveValue & " " & Trim(Item(GiveItem).name) & " for " & GetValue & " " & Trim(Item(GetItem).name) End If n = n + 4 Next I If frmTrade.lstTrade.ListCount > 0 Then frmTrade.lstTrade.ListIndex = 0 End If frmTrade.Show vbModal Exit Sub End If Server Side Code: Type TradeItemRec GiveItem As Long GiveValue As Long GetItem As Long GetValue As Long End Type Type ShopRec name As String * NAME_LENGTH JoinSay As String * 255 LeaveSay As String * 255 FixesItems As Byte TradeItem(1 To MAX_TRADES) As TradeItemRec End Type Code: ' :::::::::::::::::: ' :: Trade packet :: ' :::::::::::::::::: If LCase$(Parse(0)) = "trade" Then If Map(GetPlayerMap(Index)).Shop > 0 Then Call SendTrade(Index, Map(GetPlayerMap(Index)).Shop) Else Call PlayerMsg(Index, "There is no shop here.", BrightRed) End If Exit Sub End If Code: Sub SendTrade(ByVal Index As Long, ByVal ShopNum As Long)
Dim Packet As String Dim I As Long, X As Long, y As Long Packet = "TRADE" & SEP_CHAR & Trim$(ShopNum) & SEP_CHAR & Shop(ShopNum).FixesItems & SEP_CHAR For I = 1 To MAX_TRADES Packet = Packet & Trim$(Shop(ShopNum).TradeItem(I).GiveItem) & SEP_CHAR & Trim$(Shop(ShopNum).TradeItem(I).GiveValue) & SEP_CHAR & Trim$(Shop(ShopNum).TradeItem(I).GetItem) & SEP_CHAR & Trim$(Shop(ShopNum).TradeItem(I).GetValue) & SEP_CHAR ' Item # X = Trim$(Shop(ShopNum).TradeItem(I).GetItem) If Item(X).Type = ITEM_TYPE_SPELL Then ' Spell class requirement y = Spell(Item(X).Data1).ClassReq If y = 0 Then Call PlayerMsg(Index, Trim$(Item(X).name) & " can be used by all classes.", Yellow) Else Call PlayerMsg(Index, Trim$(Item(X).name) & " can only be used by a " & GetClassName(y - 1) & ".", Yellow) End If End If Next I Packet = Packet & END_CHAR Call SendDataTo(Index, Packet) End Sub So, the last line here, SendDataTo(Index, Packet) Isn't even being activated, for an unknown reason. Sorry for the code repeat, just here for quick reference. |
|
| Author: | James [ Tue May 22, 2007 2:49 am ] |
| Post subject: | |
The error happens AFTER I (in the SendTrade Sub Server Side) goes through the I which is one more than the trades in the shop. If the shop has 3 trades, once the sub goes through 4, it exits the sub. I don't know why... |
|
| Author: | James [ Tue May 22, 2007 3:04 am ] |
| Post subject: | |
Tripple post, SORRY! Fixed. I added an if statement to make sure X was greater than 0, of not then it doesn't do anything. This, for some odd reason, fixed it, and therefore, everything works. This can be locked/saved for future problems of this sort. |
|
| Page 1 of 1 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|