Mirage Source http://www.miragesource.net/forums/ |
|
Live Stats+ http://www.miragesource.net/forums/viewtopic.php?f=210&t=724 |
Page 1 of 2 |
Author: | DarkX [ Mon Nov 06, 2006 3:08 pm ] |
Post subject: | Live Stats+ |
Ok this is my 4th tutorial; I am not going to take all the credit; Programmers; DarkX; Leighland; Sonire difficulty: 1 out 5 This tutorial is going to show you how to do multiple things, here's a list: displaying your str, def, speed, magi, exp, and level. [font=Arial]Extra's[/font](not needed but looks spiffy) Displaying your Critical Hit Chance, Blocking Chance, and next level. This part is by Leighland Ok let's start off with the easiest part; server side... make a timer anywhere on frmServer name it w/e you want then double click it and add this into 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 now set the interval atleast 1000 and enabled = true Ok what this does is it makes the stats update every 1 minute or second( I can't remember(And there are other; better ways to do this part)) In modServerTCP find SendStats make it look like 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 Ok now to Client side in modHandleData find "Player Stats Packet" This is something almost anyone can figure out now that everythings done server side(let you know some features don't need to be put into Sub SendStats) make the Player Stats Packet look like this. Code: 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.lblSTR = GetPlayerSTR(MyIndex) frmMirage.lblDEF = GetPlayerDEF(MyIndex) frmMirage.lblSPEED = GetPlayerSPEED(MyIndex) frmMirage.lblMAGI = GetPlayerMAGI(MyIndex) frmMirage.lblLevel = GetPlayerLevel(MyIndex) frmMirage.lblExp = GetPlayerExp(MyIndex) I think the above is self explanitory, but if not; those are the packets in order there received on both server and client, then the rest of that little code is what makes the labels on frmMirage receive the info to display. FrmMirage ok Now make each of those labels on frmMirage somewhere; and name them lblstr, lbldef, lblspeed, lbllevel, lblmagi, and lblexp and that's all for the short end of the tutorial; Now for the extra's This is Sonire and I's code In the PlayerStatsPacket, just below Code: frmMirage.lblExp = GetplayerExp(MyIndex) add thisCode: frmMirage.lblBLOCK = Int(GetPlayerDEF(MyIndex) / 2) + Int(GetPlayerLevel(MyIndex) / 2) Ok explaining what this does, the first one getst the player block chance and displays it, the second one is the same just for Critical Hit Chance, and you probably don't want it but Next level displays the number of the level above yours aka level 37 it will display level 38frmMirage.lblHIT = Int(GetPlayerSTR(MyIndex) / 2) + Int(GetPlayerLevel(MyIndex) / 2) frmMirage.lblNextLvl = (GetPlayerLevel(MyIndex) + 1) Now to finish the extra's. On frmMirage add 3 more labels name them lblblock, lblHit, and lblNextLvl and your done. Hope this helps someone. |
Author: | Salt [ Mon Nov 06, 2006 3:20 pm ] |
Post subject: | |
and some people (like myself) are too lazy to register, so copy and paste may be a good idea (and no it's not like I was gonna take and use this, I don't program anymore, I just like to see what tuts people make now a days) |
Author: | DarkX [ Mon Nov 06, 2006 3:52 pm ] |
Post subject: | |
I booted the guy who is my other admin he's the one who turned that register thing on, but it's fixed now you can view without registering. |
Author: | ArchAngel [ Tue Nov 07, 2006 10:46 pm ] |
Post subject: | |
When I did this I got the "subscript out of range" error and it brought me to this Code: Sub SetPlayerSTR(ByVal Index As Long, ByVal STR As Long)
Player(Index).STR = STR End Sub |
Author: | DarkX [ Wed Nov 08, 2006 3:21 pm ] |
Post subject: | |
Post your "playerstats" packet that has the things from the tutorial and I'll see if I can help you. But subscript out of range was something that I had a while back while trying to figure out the tut that was origanally posted here, when it said that to me it turned out that the way the data was sent server side from sub SendStats was not matching the way it was recieved client side... In short try making the parses look the same way they are in "playerStats" as they are in Sendstats. here's an example Code: 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 That is the packet section of sendstats, now I'll show you somthing that won't work with that Code: If LCase(Parse(0)) = "playerstats" Then Now if you look, the thing that is wrong is that the parsed items like str,def,speed,magi,level and exp are recieved diffrently then they are sent from the server side. So as long as they don't match the server side data you'll almost always get errors.
Call SetPlayerSTR(MyIndex, Val(Parse(6))) Call SetPlayerDEF(MyIndex, Val(Parse(5))) Call SetPlayerSPEED(MyIndex, Val(Parse(4))) Call SetPlayerMAGI(MyIndex, Val(Parse(3))) Call SetPlayerLevel(MyIndex, Val(Parse(2))) Call SetPlayerExp(MyIndex, Val(Parse(1))) frmMirage.lblSTR = GetPlayerSTR(MyIndex) frmMirage.lblDEF = GetPlayerDEF(MyIndex) frmMirage.lblSPEED = GetPlayerSPEED(MyIndex) frmMirage.lblMAGI = GetPlayerMAGI(MyIndex) frmMirage.lblLevel = GetPlayerLevel(MyIndex) frmMirage.lblExp = GetPlayerExp(MyIndex) frmMirage.lblBLOCK = Int(GetPlayerDEF(MyIndex) / 2) + Int(GetPlayerLevel(MyIndex) / 2) frmMirage.lblHIT = Int(GetPlayerSTR(MyIndex) / 2) + Int(GetPlayerLevel(MyIndex) / 2) frmMirage.lblNextLvl = (GetPlayerLevel(MyIndex) + 1) Exit Sub |
Author: | ArchAngel [ Wed Nov 08, 2006 8:30 pm ] |
Post subject: | |
This is my Player Stats Packet: Code: ' ::::::::::::::::::::::::: ' :: Player stats packet :: ' ::::::::::::::::::::::::: 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.lblSTR = GetPlayerSTR(MyIndex) frmMirage.lblDEF = GetPlayerDEF(MyIndex) frmMirage.lblSPEED = GetPlayerSPEED(MyIndex) frmMirage.lblMAGI = GetPlayerMAGI(MyIndex) frmMirage.lblLevel = GetPlayerLevel(MyIndex) frmMirage.lblExp = GetPlayerExp(MyIndex) and my Send Stats 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 I'm going to try to change the parses like you said, i'l post what happens. |
Author: | DarkX [ Thu Nov 09, 2006 2:30 pm ] |
Post subject: | |
If you change the parses IF I remember correctly you have to change them to the same order in sendstats or you'll get this problem when you log into the game code(I'm purposely doing it like this so don't freak out) Run-Time error '6': Overflow now what happened here is I changed the str to parse6(Client Side) and level to parse 1 without changing it server side to match the client side. So I got Run-Time Error '6': which I think ment that the data doesn't match. |
Author: | DarkX [ Thu Nov 09, 2006 2:33 pm ] |
Post subject: | |
EDIT:::: I'm Sorry about double posting, it truely was an accident. :::::::EDIT Ok here's the origanal tutorial all this came from I don't remember who made it. [QOUTE] Here is my Visual Stats code. In modClientTCP go to Code: Sub HandleData Scroll down to Code: ' ::::::::::::::::::::::::: ' :: Player stats packet :: ' ::::::::::::::::::::::::: Replace Code: 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 With Code: If LCase(Parse(0)) = "playerstats" Then Call SetPlayerSTR(MyIndex, Val(Parse(1))) frmMirage.lblSTR.Caption = Player(MyIndex).STR Call SetPlayerDEF(MyIndex, Val(Parse(2))) 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(4))) frmMirage.lblLevel.Caption = Player(MyIndex).Level Call SetPlayerExp(MyIndex, Val(Parse(4))) frmMirage.lblEXP.Caption = Player(MyIndex).Exp Exit Sub End If And then go to frmMirage and make some labels and don't name them and set their captions to be STR, DEF, Speed, Magi, Level, and Exp. Make more labels except this time give them a null caption and Name them lblSTR, lblDEF, lblSPEED, lblMAGI, lblLevel, lblExp. and then put those where you want them to be and you're done! [/QOUTE] Ok do that then try the parts of this tutorial that are missing from it, assuming it doesn't work. |
Author: | ArchAngel [ Fri Nov 10, 2006 12:36 am ] |
Post subject: | |
Ok, thanks a lot for all your help. I'l try this when I get home. |
Author: | Matt [ Tue Dec 12, 2006 6:16 pm ] |
Post subject: | |
Just looking at the tut and what not, but wouldn't it be better to take this part: Code: 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.lblSTR = GetPlayerSTR(MyIndex) frmMirage.lblDEF = GetPlayerDEF(MyIndex) frmMirage.lblSPEED = GetPlayerSPEED(MyIndex) frmMirage.lblMAGI = GetPlayerMAGI(MyIndex) frmMirage.lblLevel = GetPlayerLevel(MyIndex) frmMirage.lblExp = GetPlayerExp(MyIndex) And make it look like this: Code: frmMirage.lblSTR = val(parse(1))
frmMirage.lblDEF = val(parse(2)) frmMirage.lblSPEED = val(parse(3)) frmMirage.lblMAGI = val(parse(4)) frmMirage.lblLevel = val(parse(5)) frmMirage.lblExp = val(parse(6)) ? Now, I didn't try this, so I could be wrong. Just the method you used, looked odd to me. |
Author: | William [ Tue Dec 12, 2006 6:41 pm ] |
Post subject: | |
Why would you want to send it constantly with a timer, and not only when its needed? |
Author: | Robin [ Tue Dec 12, 2006 6:45 pm ] |
Post subject: | |
William wrote: Why would you want to send it constantly with a timer, and not only when its needed?
Well, we managed to create a shit, perfectly un-optimized server using Timers already (for everything! How messed up is that?) so why not f*ck it up even more? [/sarcasm] |
Author: | William [ Tue Dec 12, 2006 6:48 pm ] |
Post subject: | |
Haha.. won't even answer that. |
Author: | Robin [ Tue Dec 12, 2006 6:49 pm ] |
Post subject: | |
lol. The sarcasm/insult wasn't aimed at you xD Just mirage's poor server programming. And Advocate's 'l33t' timing script. |
Author: | Matt [ Tue Dec 12, 2006 6:51 pm ] |
Post subject: | |
Huh? Wouldn't we be able to convert all timers to use gettickcount or something? |
Author: | Robin [ Tue Dec 12, 2006 7:29 pm ] |
Post subject: | |
Advocate wrote: Huh?
Wouldn't we be able to convert all timers to use gettickcount or something? -_- |
Author: | one [ Tue Dec 12, 2006 8:45 pm ] |
Post subject: | |
Advocate wrote: Huh?
Wouldn't we be able to convert all timers to use gettickcount or something? [sarcasm] wow, great idea x) [/sarcasm] what William means was only updating it when it shows up or if something is changed |
Author: | Matt [ Tue Dec 12, 2006 9:23 pm ] |
Post subject: | |
I know.. I only suggested getting rid of the timers, because if someone knows what they are doing, timers can be froze. Meaning anything that needs the timer, will not happen. I know this from experience. |
Page 1 of 2 | All times are UTC |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |