| Mirage Source http://miragesource.net/forums/ |
|
| Live/Visual Stats http://miragesource.net/forums/viewtopic.php?f=210&t=375 |
Page 1 of 2 |
| Author: | DarkX [ Sun Aug 13, 2006 3:03 am ] |
| Post subject: | Live/Visual Stats |
Hey I got bored and started writting a visual/live stats code and I can't get them to become live(AKA) they won't automatically update themselves. You have to log off to make them work. I was wondering if someone could help me with this. Or post a working tutorial for this such thing. Thanks in advance. |
|
| Author: | Misunderstood [ Sun Aug 13, 2006 3:47 am ] |
| Post subject: | |
whenever the stats update, send the client the updated info. Duh |
|
| Author: | Robin [ Sun Aug 13, 2006 11:26 am ] |
| Post subject: | |
DarkX wrote: Hey I got bored and started writting a visual/live stats code and I can't get them to become live(AKA) they won't automatically update themselves. You have to log off to make them work. I was wondering if someone could help me with this. Or post a working tutorial for this such thing.
Thanks in advance. In modHandleData, find any packets which have things like "player(index).STR =" etc. and underneath, have a label or something in frmMirage updated with that information. If there isn't any packets which send this info, make one. |
|
| Author: | DarkX [ Mon Aug 14, 2006 1:55 am ] |
| Post subject: | |
Quote: In modHandleData, find any packets which have things like "player(index).STR =" etc. and underneath, have a label or something in frmMirage updated with that information.
If there isn't any packets which send this info, make one. You mean like these? Code: If LCase(Parse(0)) = "playerstats" Then
Call SetPlayerSTR(MyIndex, Val(Parse(6))) frmMirage.lblSTR.Caption = Player(MyIndex).STR Call SetPlayerDEF(MyIndex, Val(Parse(5))) frmMirage.lblDEF.Caption = Player(MyIndex).DEF Call SetPlayerSPEED(MyIndex, Val(Parse(3))) frmMirage.lblSPEED.Caption = Player(MyIndex).SPEED Call SetPlayerMAGI(MyIndex, Val(Parse(4))) frmMirage.lblMAGI.Caption = Player(MyIndex).MAGI Call SetPlayerLevel(MyIndex, Val(Parse(2))) frmMirage.lblLevel.Caption = Player(MyIndex).Level Call SetPlayerExp(MyIndex, Val(Parse(1))) frmMirage.lblEXP.Caption = Player(MyIndex).Exp Exit Sub End If Sorry, still very new to this half of VB, how exactly would I do that. I tried something earlier on in the week, but I'm still not sure how you mean. |
|
| Author: | Leighland [ Thu Aug 17, 2006 7:35 pm ] |
| Post subject: | |
That would work. The only thing is the stats will only be updated whenever you do something that calls the SendStats procedure on the server. So on the server, on frmServer, make a new timer and put this code in it: Code: Dim i As Byte For i = 1 To MAX_PLAYERS If IsPlaying(i) And IsConnected(i) Then Call SendStats(i) End If Next i Interval: 1000 Enabled: True This will update every players stats every second. EDIT: I also think you may have the code a little messed up. Open the Server source code and change the following things. I'm just going to post the code for what I think you're trying to do. in modServerTCP, find: Code: Sub SendStats(ByVal Index As Long) Dim Packet As String Packet = "PLAYERSTATS" & SEP_CHAR & GetPlayerSTR(Index) & SEP_CHAR & GetPlayerDEF(Index) & SEP_CHAR & GetPlayerSPEED(Index) & SEP_CHAR & GetPlayerMAGI(Index) & SEP_CHAR & END_CHAR Call SendDataTo(Index, Packet) End Sub Replace it with this: Code: Sub SendStats(ByVal Index As Long) Dim Packet As String Packet = "PLAYERSTATS" & SEP_CHAR & GetPlayerSTR(Index) & SEP_CHAR & GetPlayerDEF(Index) & SEP_CHAR & GetPlayerSPEED(Index) & SEP_CHAR & GetPlayerMAGI(Index) & SEP_CHAR & GetPlayerLevel(Index) & SEP_CHAR & GetPlayerExp(Index) & SEP_CHAR & END_CHAR Call SendDataTo(Index, Packet) End Sub Now right here I'll explain a little something, just because it doesn't seem you understand how parsing works :). We send data to the client in a certain order. That order determines how we will later pick up the data on the client side. If you read it wrong on the client side, you could be displaying magi on your strength label, or displaying the players experience on the speed label... which we don't want. Lol. So here's how the serve ris going to send that above data to the client: 0. "PLAYERSTATS" 1. GetPlayerSTR(Index) 2. GetPlayerDEF(Index) 3. GetPlayerSPEED(Index) 4. GetPlayerMAGI(Index) 5. GetPlayerLevel(Index) 6. GetPlayerExp(Index) Now... open up the client source code and in modHandleData find the following: Code: ' ::::::::::::::::::::::::: ' :: Player stats packet :: ' ::::::::::::::::::::::::: If LCase(Parse(0)) = "playerstats" Then Call SetPlayerSTR(MyIndex, Val(Parse(1))) Call SetPlayerDEF(MyIndex, Val(Parse(2))) Call SetPlayerSPEED(MyIndex, Val(Parse(3))) Call SetPlayerMAGI(MyIndex, Val(Parse(4))) Exit Sub End If Replace it with this: Code: ' ::::::::::::::::::::::::: ' :: Player stats packet :: ' ::::::::::::::::::::::::: If LCase(Parse(0)) = "playerstats" Then Call SetPlayerSTR(MyIndex, Val(Parse(1))) Call SetPlayerDEF(MyIndex, Val(Parse(2))) Call SetPlayerSPEED(MyIndex, Val(Parse(3))) Call SetPlayerMAGI(MyIndex, Val(Parse(4))) Call SetPlayerLevel(MyIndex, Val(Parse(5))) Call SetPlayerExp(MyIndex, Val(Parse(6))) Exit Sub End If Notice how we read it on the client in the same order as we sent it from the server? This not only makes the code cleaner and easy to find bugs, but it also makes sure we know exactly which variable we are setting each stat too. The way your code looks, judging that your server side code sends the stats in the same order I have, you woudl be setting the players strength level to whatever the value of their experience was. Which isn't good, obviously. Now, let's add the stuff to display that. Make sure you edit the following code to suit your labels. Code: ' :::::::::::::::::::::::::
' :: Player stats packet :: ' ::::::::::::::::::::::::: If LCase(Parse(0)) = "playerstats" Then Call SetPlayerSTR(MyIndex, Val(Parse(1))) Call SetPlayerDEF(MyIndex, Val(Parse(2))) Call SetPlayerSPEED(MyIndex, Val(Parse(3))) Call SetPlayerMAGI(MyIndex, Val(Parse(4))) Call SetPlayerLevel(MyIndex, Val(Parse(5))) Call SetPlayerExp(MyIndex, Val(Parse(6))) frmMirage.LblStrength = GetPlayerSTR(MyIndex) frmMirage.LblDefense = GetPlayerDEF(MyIndex) frmMirage.LblSpeed = GetPlayerSPEED(MyIndex) frmMirage.LblMagic = GetPlayerMAGI(MyIndex) frmMirage.LblLevel = GetPlayerLevel(MyIndex) frmMirage.LblExp = GetPlayerExp(MyIndex) Exit Sub End If This will now send the stats, experience, and level of each player connected to your server every second and display it on the labels you make on frmMirage. If you ahve any problems just post. |
|
| Author: | Robin [ Fri Aug 18, 2006 11:20 am ] |
| Post subject: | |
Leighland wrote: That would work. The only thing is the stats will only be updated whenever you do something that calls the SendStats procedure on the server. So on the server, on frmServer, make a new timer
That's as bad as sending the HP, MP and SP every ten seconds!!!! Using timers for something like that is really bad programming. All you need to do is go to frmTraining, press the 'train' button, find out what packet is sent. Go serverside, find that packet in handledata, then at the bottom add: Code: Call SendPlayerStats(index) Then make a new sub in modServerTCP: Code: Public Sub SendPlayerStats(byval Index as long)
dim packet as string Packet = "updatedstats" & SEP_CHAR & "have what ever stats you want here" & SEP_CHAR & END_CHAR Call SendDataTo(index, packet) end sub Then in clientside modHandleData, add a new packet called "updatedstats" and have all your labels updated with the values recieved in the packet ~Kite (I did that all off the top of my head, so I didn't write down all the stat's etc.) |
|
| Author: | DarkX [ Fri Aug 18, 2006 4:03 pm ] |
| Post subject: | |
Ok Kite I know what your talking about, but I couldn't get it to work. Leighland's on the other hand, after a short amount of tweaking I got it to work... I thank both of you very much (I will try and figure out how to get yours working Kite) Thanks!!! |
|
| Author: | Robin [ Sat Aug 19, 2006 11:46 am ] |
| Post subject: | |
Sorry my post didn't give more information, but I don't have internet and VB6.0 on the same pc I'll see if I can write up a tutorial for it when I get a few minutes spare. Glad to see you got Leigh's one working though! ~Kite |
|
| Author: | DarkX [ Sun Aug 20, 2006 12:11 am ] |
| Post subject: | |
Well, I got yours somewhat working, but I had couldn't get it to where it automatically updates itself, you had to type /stats or press the stats button. Or find away to get the form your on to reload. |
|
| Author: | Coke [ Sun Aug 20, 2006 12:21 am ] |
| Post subject: | |
I equally have had such problems with efficiently displaying stats >.< |
|
| Author: | DarkX [ Sun Aug 20, 2006 12:23 am ] |
| Post subject: | |
Unfortunately had to deal with those tricky stats, but thanks to leighland and Kite here things are finally working, where I can't get Kites to work I got leighlands working and it perfectly updates every 5 seconds. |
|
| Author: | Coke [ Sun Aug 20, 2006 12:45 am ] |
| Post subject: | |
The issue with that method is imagin when you have say 10 players online, think of the packet spamming! eeeek! Has anyone tried adding to the packets? For instance, the client sends a packet to the server saying you just earnt 15 experience, why then can the server not reply with an experience update? Also another 'want' for me if this was working would be for it to then blt the experience just earnt onto the players sprite, i think i saw gsd do something similar once and it was quite neat :] |
|
| Author: | DarkX [ Sun Aug 20, 2006 12:47 am ] |
| Post subject: | |
Well couldn't you modify the bltPlayerDamage, to be bltPlayerEXP, so when the player gets some exp it blts that plus the letters EXP above there head? |
|
| Author: | Robin [ Mon Aug 21, 2006 10:14 am ] |
| Post subject: | |
I got home, all ready to write up a tutorial for this, but when I got onto the source, I pressed the button in frmTraining, followed the string of packets, eventually came client side and just added: Code: If Index = MyIndex then
frmMirage.lblW/e = val(Parse(w/e)) end if At the end of one of the stat's packets. This packet is sent when you log in, or when you send training packets. I don't know why it doesn't work for you. ps. I did that on Mirage 3.03 ~Kite |
|
| Author: | DarkX [ Mon Aug 21, 2006 11:17 am ] |
| Post subject: | |
Yeah who knows if it'll work on MSE |
|
| Author: | Robin [ Mon Aug 21, 2006 12:26 pm ] |
| Post subject: | |
The stat's weren't changed in MSE Build 1. I'm just saying, I did it in 3.03. |
|
| Author: | DarkX [ Mon Aug 21, 2006 1:39 pm ] |
| Post subject: | |
I know but I have a problem with installing certain codes, like that (for some odd reason I have trouble with installing small crap like that. |
|
| Page 1 of 2 | All times are UTC |
| Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |
|