Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
tnl Bar & exp in .ini
#1
Credits: GSD I think, for the .ini thingy. the rest is just a packet for the bar.

This will give your game a 'to next level' bar (exp) and also let you decide the different experience gaps between the levels:

Server Side
Add this at the bottom of modServerTCP:
Code:
Sub SendTNL(ByVal index As Long)
Dim Packet As String

    Packet = "PLAYERTNL" & SEP_CHAR & GetPlayerNextLevel(index) & SEP_CHAR & GetPlayerExp(index) & SEP_CHAR & END_CHAR
    Call SendDataTo(index, Packet)
End Sub

Now, on all places that you find:
Code:
Call SendHP(index)
        Call SendMP(index)
Add below:
Code:
Call SendTNL(index)
Now, in modDatabase, add:
Code:
Sub LoadExps()
Dim FileName As String
Dim i As Long

    Call CheckExps
    
    FileName = App.Path & "\experience.ini"
  
    For i = 1 To MAX_EXP
        Experience(i) = GetVar(FileName, "EXPERIENCE", "Exp" & i)
      
        DoEvents
    Next i
End Sub

Sub CheckExps()
    If Not FileExist("experience.ini") Then
        Dim i As Long
  
        For i = 1 To MAX_EXP
             Call PutVar(App.Path & "\experience.ini", "EXPERIENCE", "Exp" & i, i * 1500)
        Next i
    End If
End Sub

Sub ClearExps()
Dim i As Long

    For i = 1 To MAX_EXP
        Experience(i) = 0
    Next i
End Sub
Now at the top of modTypes, add:
Code:
Public Experience(1 To MAX_EXP) As Long
Now, replace:
Code:
Function GetPlayerNextLevel(ByVal Index As Long) As Long
    GetPlayerNextLevel = (GetPlayerLevel(Index) + 1) * (GetPlayerSTR(Index) + GetPlayerDEF(Index) + GetPlayerMAGI(Index) + GetPlayerSPEED(Index) + GetPlayerPOINTS(Index)) * 25
End Function
with:
Code:
Function GetPlayerNextLevel(ByVal index As Long) As Long
    GetPlayerNextLevel = Experience(GetPlayerLevel(index))
End Function
Client Side
Now in modHandleData: add this:
Code:
' Player tnl packet
    If LCase(Parse(0)) = "playertnl" Then
        Player(MyIndex).MaxExp = Val(Parse$(1))
        Player(MyIndex).Exp = Val(Parse$(2))
        
        If GetPlayerMaxExp(MyIndex) > 0 Then
            If GetPlayerExp(MyIndex) > 0 Then
                frmMirage.lblEXP.Caption = GetPlayerExp(MyIndex) & "/" & GetPlayerMaxExp(MyIndex)
               frmMirage.shpTNL.Width = (((GetPlayerExp(MyIndex) / 2000) / (GetPlayerMaxExp(MyIndex) / 2000)) * 2000)
            End If
        End If
        Exit Sub
Now add a picture box in frmMirage:
Code:
width = 2000
Height = 135
And make the picture box's BackColor the color you want the exp bar, or load a image to it. Name it: shpTNL

Add a label in the picture box, name it: lblEXP

Below:
Code:
Sub SetPlayerExp(ByVal Index As Long, ByVal Exp As Long)
    Player(Index).Exp = Exp
End Sub
Add:
Code:
Sub SetPlayerMaxExp(ByVal Index As Long, ByVal MaxExp As Long)
    Player(Index).MaxExp = MaxExp
End Sub

Function GetPlayerMaxExp(ByVal Index As Long) As Long
    GetPlayerMaxExp = Player(Index).MaxExp
End Function
Now below:
Code:
MaxSP As Long
in Type PlayerRec, add:
Code:
MaxExp As Long

Now add a ini filed name: experience.ini in the server folder, and add the following:
Code:
[EXPERIENCE]
Exp1=1500
Exp2=3000
Exp3=4500
Exp4=6000
Exp5=7500
etc. to your max level.
Now below:
Code:
Public Const MAX_SPELLS = 50
add:
Code:
Public Const MAX_EXP = 200
Now under:
Code:
Function GetPlayerExp(ByVal Index As Long) As Long
    GetPlayerExp = Player(Index).Exp
End Function

Sub SetPlayerExp(ByVal Index As Long, ByVal Exp As Long)
    Player(Index).Exp = Exp
End Sub
Add:
Code:
Sub SetPlayerMaxExp(ByVal Index As Long, ByVal MaxExp As Long)
    Player(Index).MaxExp = MaxExp
End Sub

Function GetPlayerMaxExp(ByVal Index As Long) As Long
    GetPlayerMaxExp = Player(Index).MaxExp
End Function
Reply
#2
Pretty nice.

Good to see some more tut's coming out!
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#3
It might be here in split up topics, not the bar and the ini together. But I posted it since it was requested.
Reply
#4
u cant post my request thats like agenst the magnacarta.
Reply
#5
Whats magnacarta? And nothing stops me from sharing this since I didn't write it only for you.
Reply
#6
King John, Pope Innocent (the 3rd I think) and the English Barons had a disagreement about whats rights Kings should be allowed.

The document changed what the King could be able to do, and gave more rights to the people of the country.

It lead to constitutional law. Even more famous than The Bill of Rights and United States Constitution.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#7
okay =/
Reply
#8
Hehehe.

Sorry, missed out the most-important bit from the middle xD

But this animé is addicting..
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#9
Hahaha, that was great, Kite. I was actually about to post something close to that.

But it really didn't grant the people more freedom... it granted the Nobility more power over their people (power that was stricken from the King)...

[On Topic]
Anyways, why are you looking to add this to a game?
Reply
#10
zocheyado Wrote:u cant post my request thats like agenst the magnacarta.

Please tell me that's some strange ass sarcasm of some sort. Most people here a fully capable of adding TNL and a TNL bar.

So, if you wanna be greedy about features you want in your game, the best option is to add them yourself. People that request tutorials and expected them to be Private Messaged to them in a password secured zip folder are retarded. If you request a tutorial, you're either not gonna see it at all, or everyone in the community will see it in the Tutorials section.
Reply
#11
Sonire Wrote:
zocheyado Wrote:u cant post my request thats like agenst the magnacarta.

Please tell me that's some strange ass sarcasm of some sort. Most people here a fully capable of adding TNL and a TNL bar.

So, if you wanna be greedy about features you want in your game, the best option is to add them yourself. People that request tutorials and expected them to be Private Messaged to them in a password secured zip folder are retarded. If you request a tutorial, you're either not gonna see it at all, or everyone in the community will see it in the Tutorials section.

You freakin said it! Right on. :wink: I fear the people today are pampered a little too much. Gotta let em figure things out on their own as we once did. Trial and freakin error!
Reply
#12
zocheyado Wrote:u cant post my request thats like agenst the magnacarta.

Then you shouldn't request :evil:
Reply
#13
You do know that you can just parse the next level information to the client and use that, right? That's how I did it. Works great.

(Sorry if that's what this does, I didn't read it. Since I'm on dial up now, I'm VERY impatient.)
Reply
#14
Thats what this does Tongue
Reply
#15
Ya...kind of a necropost...but I was skimming through random things on the forum and noticed something. For this part...

Quote:' Player tnl packet
If LCase(Parse(0)) = "playertnl" Then
Player(MyIndex).MaxExp = Val(Parse$(1))
Player(MyIndex).Exp = Val(Parse$(2))

If GetPlayerMaxExp(MyIndex) > 0 Then
If GetPlayerExp(MyIndex) > 0 Then
frmMirage.lblEXP.Caption = GetPlayerExp(MyIndex) & "/" & GetPlayerMaxExp(MyIndex)
frmMirage.shpTNL.Width = (((GetPlayerExp(MyIndex) / 2000) / (GetPlayerMaxExp(MyIndex) / 2000)) * 2000)
End If
End If
Exit Sub

Shouldn't there be another End If after Exit Sub? Otherwise wouldn't there be an error within "modHandleData"?

sorry :oops: was really bored and needed something to do. lol
Reply
#16
no, never place end if's after Exit Subs, only before Smile
Reply
#17
Well, since there are 3 If statements, and only 2 end ifs, I would say yes. If you look at all the other packets in there, they have an end if AFTER the exit sub. So I truly hope you were joking when saying that Boo.
Reply
#18
Well if I am wrong then please correct me. :o Though I am just saying what looks correct to me.

*edit* also forgot to mention that, i believe there is only 1 of this line in the client side...

Quote:Sub SetPlayerExp(ByVal Index As Long, ByVal Exp As Long)
Player(Index).Exp = Exp
End Sub

which means you would end up putting in this...

Quote:Sub SetPlayerMaxExp(ByVal Index As Long, ByVal MaxExp As Long)
Player(Index).MaxExp = MaxExp
End Sub

Function GetPlayerMaxExp(ByVal Index As Long) As Long
GetPlayerMaxExp = Player(Index).MaxExp
End Function

twice in the same module...which cant be a good thing. :? Or maybe it was just a typo by william. Though good night, going to sleep now Smile
Reply
#19
I think you can't read, tuder.

Quote:Sub SetPlayerMaxExp(ByVal Index As Long, ByVal MaxExp As Long)
Player(Index).MaxExp = MaxExp
End Sub

Function GetPlayerMaxExp(ByVal Index As Long) As Long
GetPlayerMaxExp = Player(Index).MaxExp
End Function
Reply
#20
theres nothing wrong with it?
Reply
#21
hmm ill go a little further in depth with what i mean...maybe i am wrong...probably am but im just making my statement

Quote:Server Side
Add this at the bottom of modServerTCP:
Code:
Sub SendTNL(ByVal index As Long)
Dim Packet As String

Packet = "PLAYERTNL" & SEP_CHAR & GetPlayerNextLevel(index) & SEP_CHAR & GetPlayerExp(index) & SEP_CHAR & END_CHAR
Call SendDataTo(index, Packet)
End Sub


Now, on all places that you find:
Code:
Call SendHP(index)
Call SendMP(index)

Add below:
Code:
Call SendTNL(index)

Now, in modDatabase, add:
Code:
Sub LoadExps()
Dim FileName As String
Dim i As Long

Call CheckExps

FileName = App.Path & "\experience.ini"

For i = 1 To MAX_EXP
Experience(i) = GetVar(FileName, "EXPERIENCE", "Exp" & i)

DoEvents
Next i
End Sub

Sub CheckExps()
If Not FileExist("experience.ini") Then
Dim i As Long

For i = 1 To MAX_EXP
Call PutVar(App.Path & "\experience.ini", "EXPERIENCE", "Exp" & i, i * 1500)
Next i
End If
End Sub

Sub ClearExps()
Dim i As Long

For i = 1 To MAX_EXP
Experience(i) = 0
Next i
End Sub

Now at the top of modTypes, add:
Code:
Public Experience(1 To MAX_EXP) As Long

Now, replace:
Code:
Function GetPlayerNextLevel(ByVal Index As Long) As Long
GetPlayerNextLevel = (GetPlayerLevel(Index) + 1) * (GetPlayerSTR(Index) + GetPlayerDEF(Index) + GetPlayerMAGI(Index) + GetPlayerSPEED(Index) + GetPlayerPOINTS(Index)) * 25
End Function

with:
Code:
Function GetPlayerNextLevel(ByVal index As Long) As Long
GetPlayerNextLevel = Experience(GetPlayerLevel(index))
End Function

Client Side
Now in modHandleData: add this:
Code:
' Player tnl packet
If LCase(Parse(0)) = "playertnl" Then
Player(MyIndex).MaxExp = Val(Parse$(1))
Player(MyIndex).Exp = Val(Parse$(2))

If GetPlayerMaxExp(MyIndex) > 0 Then
If GetPlayerExp(MyIndex) > 0 Then
frmMirage.lblEXP.Caption = GetPlayerExp(MyIndex) & "/" & GetPlayerMaxExp(MyIndex)
frmMirage.shpTNL.Width = (((GetPlayerExp(MyIndex) / 2000) / (GetPlayerMaxExp(MyIndex) / 2000)) * 2000)
End If
End If
Exit Sub

Now add a picture box in frmMirage:
Code:
width = 2000
Height = 135

And make the picture box's BackColor the color you want the exp bar, or load a image to it. Name it: shpTNL

Add a label in the picture box, name it: lblEXP

Below:
Code:
Sub SetPlayerExp(ByVal Index As Long, ByVal Exp As Long)
Player(Index).Exp = Exp
End Sub

Add:
Code:
Sub SetPlayerMaxExp(ByVal Index As Long, ByVal MaxExp As Long)
Player(Index).MaxExp = MaxExp
End Sub

Function GetPlayerMaxExp(ByVal Index As Long) As Long
GetPlayerMaxExp = Player(Index).MaxExp
End Function

Now below:
Code:
MaxSP As Long

in Type PlayerRec, add:
Code:
MaxExp As Long


Now add a ini filed name: experience.ini in the server folder, and add the following:
Code:
[EXPERIENCE]
Exp1=1500
Exp2=3000
Exp3=4500
Exp4=6000
Exp5=7500
etc. to your max level.

Now below:
Code:
Public Const MAX_SPELLS = 50

add:
Code:
Public Const MAX_EXP = 200

Now under:
Code:
Function GetPlayerExp(ByVal Index As Long) As Long
GetPlayerExp = Player(Index).Exp
End Function

Sub SetPlayerExp(ByVal Index As Long, ByVal Exp As Long)
Player(Index).Exp = Exp
End Sub


Code:
Sub SetPlayerMaxExp(ByVal Index As Long, ByVal MaxExp As Long)
Player(Index).MaxExp = MaxExp
End Sub

Function GetPlayerMaxExp(ByVal Index As Long) As Long
GetPlayerMaxExp = Player(Index).MaxExp
End Function

unless i cant read...then i think those lines are exactly the same and added withing the exact same area. Because this line of code,

Quote:Sub SetPlayerExp(ByVal Index As Long, ByVal Exp As Long)
Player(Index).Exp = Exp
End Sub

is a part of this line of code

Quote:Function GetPlayerExp(ByVal Index As Long) As Long
GetPlayerExp = Player(Index).Exp
End Function

Sub SetPlayerExp(ByVal Index As Long, ByVal Exp As Long)
Player(Index).Exp = Exp
End Sub

or maybe im just seeing things :o
Reply
#22
Ohh, one of those should be located server side.
Reply
#23
ahh ok :o my mistake then lol.
Reply
#24
After adding every single line of code and gone through it multiple times,
I still haven't developped my skill far enough to know how to define a variable. xD

I feel like if someone tells me I know what it is, but I can't find it out though =.=

[Image: variablenotdefinedyo8.png]

Can someone help me? Lol
Reply
#25
You did not add the MAX_EXP variable.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)