Mirage Source
http://miragesource.net/forums/

tnl Bar & exp in .ini
http://miragesource.net/forums/viewtopic.php?f=210&t=1315
Page 1 of 3

Author:  William [ Tue Feb 06, 2007 7:09 pm ]
Post subject:  tnl Bar & exp in .ini

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

Author:  Robin [ Tue Feb 06, 2007 7:49 pm ]
Post subject: 

Pretty nice.

Good to see some more tut's coming out!

Author:  William [ Tue Feb 06, 2007 8:02 pm ]
Post subject: 

It might be here in split up topics, not the bar and the ini together. But I posted it since it was requested.

Author:  zocheyado [ Tue Feb 06, 2007 8:29 pm ]
Post subject: 

u cant post my request thats like agenst the magnacarta.

Author:  William [ Tue Feb 06, 2007 8:30 pm ]
Post subject: 

Whats magnacarta? And nothing stops me from sharing this since I didn't write it only for you.

Author:  Robin [ Tue Feb 06, 2007 9:08 pm ]
Post subject: 

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.

Author:  William [ Tue Feb 06, 2007 9:12 pm ]
Post subject: 

okay =/

Author:  Robin [ Tue Feb 06, 2007 9:32 pm ]
Post subject: 

Hehehe.

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

But this animé is addicting..

Author:  Obsidian [ Tue Feb 06, 2007 9:38 pm ]
Post subject: 

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?

Author:  Rian [ Wed Feb 07, 2007 6:05 am ]
Post subject: 

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.

Author:  Aleano [ Wed Feb 07, 2007 6:13 am ]
Post subject: 

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!

Author:  Tony [ Wed Feb 07, 2007 8:44 am ]
Post subject: 

zocheyado wrote:
u cant post my request thats like agenst the magnacarta.


Then you shouldn't request :evil:

Author:  Matt [ Sat Feb 10, 2007 1:38 am ]
Post subject: 

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.)

Author:  William [ Sat Feb 10, 2007 2:31 pm ]
Post subject: 

Thats what this does :P

Author:  Aaron [ Tue Mar 27, 2007 2:29 am ]
Post subject:  hmm

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

Author:  Boo [ Tue Mar 27, 2007 2:48 am ]
Post subject: 

no, never place end if's after Exit Subs, only before :)

Author:  Matt [ Tue Mar 27, 2007 3:03 am ]
Post subject: 

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.

Author:  Aaron [ Tue Mar 27, 2007 3:42 am ]
Post subject: 

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 :)

Author:  Tony [ Tue Mar 27, 2007 6:22 am ]
Post subject: 

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

Author:  William [ Tue Mar 27, 2007 8:28 am ]
Post subject: 

theres nothing wrong with it?

Author:  Aaron [ Tue Mar 27, 2007 10:43 am ]
Post subject: 

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

Author:  William [ Tue Mar 27, 2007 11:16 am ]
Post subject: 

Ohh, one of those should be located server side.

Author:  Aaron [ Tue Mar 27, 2007 7:07 pm ]
Post subject: 

ahh ok :o my mistake then lol.

Author:  JohnY [ Tue Jul 31, 2007 12:31 am ]
Post subject:  Re: tnl Bar & exp in .ini

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

Can someone help me? Lol

Author:  Ramsey [ Tue Jul 31, 2007 12:33 am ]
Post subject:  Re: tnl Bar & exp in .ini

You did not add the MAX_EXP variable.

Page 1 of 3 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/