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

Show Character Level Above Name with Option


troglodite
 Share

Recommended Posts

With this tutorial we´ll make an option to show on/off the level of our character in the screen

I didnt found a tutorial like this in search, so I did it myself and I want to share it with you

**CLIENT SIDE**

Search

```
Private Type OptionsRec
```
Paste above the **End Type**

```
Level As Byte
```

Search

```
Public Sub SaveOptions()
```
Paste above the **' Error handler**

```
Call PutVar(fileName, "Options", "Level", Str(Options.Level))
```

Search

```
Public Sub LoadOptions()
```
Paste above the **SaveOptions**

```
Options.Level = 0
```
Under

```
Options.Debug = GetVar(fileName, "Options", "Debug")
```
Paste

```
Options.Level = GetVar(fileName, "Options", "Level")
```

Paste above the **' Error handler**

```
If Options.Level = 0 Then

frmMain.optLvlOff.Value = True

Else

frmMain.optLvlOn.Value = True

End If
```

Search

```
Public Sub DrawPlayerName(ByVal Index As Long)
```
Under

```
End Sub
```
Paste

```
Public Sub DrawPlayerLevel(ByVal Index As Long)

Dim TextX As Long

Dim TextY As Long

Dim color As Long

Dim Level As String

' If debug mode, handle error then exit out

If Options.Debug = 1 Then On Error GoTo errorhandler

' Check access level

If GetPlayerPK(Index) = NO Then

Select Case GetPlayerAccess(Index)

Case 0

color = RGB(255, 120, 70)

Case 1

color = QBColor(DarkGrey)

Case 2

color = QBColor(BrightGreen)

Case 3

color = QBColor(BrightCyan)

Case 4

color = QBColor(BrightRed)

End Select

Else

color = QBColor(BrightRed)

End If

If Player(Index).Invisible = True Then

Level = ""

Else

If GetPlayerAccess(Index) = 0 Then

Level = "Lvl" & GetPlayerLevel(Index)

ElseIf GetPlayerAccess(Index) = 1 Then

Level = "Lvl" & GetPlayerLevel(Index)

ElseIf GetPlayerAccess(Index) = 2 Then

Level = "Lvl" & GetPlayerLevel(Index)

ElseIf GetPlayerAccess(Index) = 3 Then

Level = "Lvl" & GetPlayerLevel(Index)

ElseIf GetPlayerAccess(Index) = 4 Then

Level = "Lvl" & GetPlayerLevel(Index)

End If

End If

' calc pos

TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(Level)))

If GetPlayerSprite(Index) < 1 Or GetPlayerSprite(Index) > NumCharacters Then

TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - 4

Else

' Determine location for text

TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - (DDSD_Character(GetPlayerSprite(Index)).lHeight / 4) + 4

End If

' Draw level

Call DrawText(TexthDC, TextX, TextY, Level, color)

' Error handler

Exit Sub

errorhandler:

HandleError "DrawPlayerLevel", "modText", Err.Number, Err.Description, Err.Source, Err.HelpContext

Err.Clear

Exit Sub

End Sub
```

**Now the Option**

In _FrmMain_, inside _picOptions_ (the PictureBox)

Make a label

Name: Label51

Caption: Level

Make an OptionButton

Name: optLvlOn

Caption: On

Value: False

Make an OptionButton

Name: optLvlOff

Caption: Off

Value: False

Should look like this:

>! ![](http://i42.tinypic.com/2d1f8h.jpg)

**DONE!**

Example:

![](http://i44.tinypic.com/2zq7peg.jpg)
Link to comment
Share on other sites

> [http://www.touchofde…show-npc-levels](http://www.touchofdeathforums.com/community/index.php?/topic/121629-eo-show-npc-levels) for npc level. There is one for showing with options.

Its for NPC ![:huh:](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/huh.png)
Link to comment
Share on other sites

  • 4 weeks later...
Thank you.

EDIT:

Type Missmatch at line "Options.Level = GetVar(FileName, "Options", "Level")"

Any help on that? Maybe the sollution AND the reason why it's happening for correcting further problems on my own? ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)
Link to comment
Share on other sites

> Thank you.
>
> EDIT:
>
> Type Missmatch at line "Options.Level = GetVar(FileName, "Options", "Level")"
>
> Any help on that? Maybe the sollution AND the reason why it's happening for correcting further problems on my own? ![:)](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/smile.png)

I think is that

Put the line in config.ini, at the bottom of [OPTIONS]:

**Level = 1**
Link to comment
Share on other sites

  • 1 year later...

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