Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Display your Level on the GUI


Kemerd
 Share

Recommended Posts

Special thanks to

**[XerShade](http://www.touchofdeathforums.com/community/index.php?/user/79661-xershade/)**

for helping me fix a problem.

Well, this is just a simple little tutorial for making your level display on a label, onto your gui, for whatever reason you'd want it to, WHERE you want it to. It's simple, really.

Just make two labels. Make the first one's name, whatever your want. It doesn't mater. Just make the text:

```

Level:

```

Then, create another label, name it labellevel and make it's caption:

```

0

```

In modDatabase, search for:

```

SetPlayerLevel

```

and under:

```

If Index > MAX_PLAYERS Then Exit Sub

Player(Index).Level = Level

```

place:

```

frmMain.labellevel.Caption = Player(MyIndex).Level

```

There! You're done!

You can also use this for any other things that have levels and such. I used this for the Gathering Skills System, and it turned out quite good. Instead I went to the SetPlayerMiningXP, SetPlayerFishingXP, SetplayerWoodcuttingXP, and added a label.caption = Player(MyIndex).WoodcuttingXP.

Don't try to place these anywhere else, or it will not work.
Link to comment
Share on other sites

Shouldn't you also add a:

```

If Index == MyIndex Then

```

block around the Caption setting. This way it only updates if its actually for your player and not every time the client gets sent that sub for all other players on your map….

So it would be like:

```

If Index == MyIndex Then

frmMain.labellevel.Caption = Player(MyIndex).Level

End If

```
Link to comment
Share on other sites

SetPlayerLevel is called from HandlePlayerData which has to do with all players, not just your own. Thats why everything else in SetPlayerLevel works off of Index and not MyIndex. So although your only updating based on your own level, its being called every time HandlePlayerData is sent for any player.

It would probably be best to remove it from SetPlayerLevel and instead put it under HandlePlayerData.

In that sub, look for:

```

' Check if the player is the client player

If i = MyIndex Then

```
And put your code in that if statement's block. SetPlayerLevel is never called outside of HandlePlayerData and HandlePlayerData already checks if the data is for your own character.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...