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

Player/NPC Names on Mouse Hover


EclipseCommunity
 Share

Recommended Posts

This will change it so that player and npc names only appear when you hover the mouse over their character.

**CLIENT**

Find **' Draw player names** and **' Draw npc names**

Replace both sections with the following:
```
    ' draw player names
    For i = 1 To Player_HighIndex
        If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
            If CurX = Player(i).x And CurY = Player(i).y Then
                Call DrawPlayerName(i)
            End If
        End If
    Next

    ' draw npc names
    For i = 1 To Npc_HighIndex
        If MapNpc(i).num > 0 Then
            If CurX = MapNpc(i).x And CurY = MapNpc(i).y Then
                Call DrawNpcName(i)
            End If
        End If
    Next
```
You may wish to extend this feature by adding the option to turn it on and off from the options box.
Link to comment
Share on other sites

@Smore:

> Good feature, bad tutorial. You didn't say where to search for the code, lots of new programmers would be really confused by this.

> Find ' Draw player names and ' Draw npc names

If they don't know how to search then they shouldn't bother programming.
Link to comment
Share on other sites

@Smore:

> Good feature, bad tutorial. You didn't say where to search for the code, lots of new programmers would be really confused by this.

There's only 1 ' Draw player names and ' Draw player names in the whole client code. If you're too incapable to search, then you shouldn't even be trying to program. Simples.
Link to comment
Share on other sites

There's an OptionsRec in modTypes, add **HoverNames As Byte** to the bottom.
Add 2 option buttons to the options window on the main interface (Call them whatever you want).

For the option button that keeps names shown at ALL times, add this code to the sub routine:

**Options.HoverNames = 0**

And for the option that only shows names on mouse hover:

**Options.HoverNames = 1**

Then replace that whole block of code posted above to this:

```
    ' draw player names
    For i = 1 To Player_HighIndex
        If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
            If Options.HoverName = 1 Then
                If CurX = Player(i).x And CurY = Player(i).y Then
                    Call DrawPlayerName(i)
                End If
            End If
        End If
    Next

    ' draw npc names
    For i = 1 To Npc_HighIndex
        If MapNpc(i).num > 0 Then
            If Options.HoverName = 1 Then
                If CurX = MapNpc(i).x And CurY = MapNpc(i).y Then
                    Call DrawNpcName(i)
                End If
            End If
        End If
    Next
```
Not tested but should work.
Link to comment
Share on other sites

There is a problem with it, if you put it on the Options menu.  If it's set on Off, and off is Option.HoverNames = 0, it makes it so you never see names, not always, although i may have misunderstood and was supposed to put it on 'On'.  Also, you get a compile error if you use the lower code, you need to change```
If Options.HoverName = 1 Then
```to```
If Options.HoverNames = 1 Then
```  You need to add the s to the end.
Link to comment
Share on other sites

Sorry for the double-post, but also, make sure you add HoverNames= 1 or 0 to your config.ini, depending if you want this feature on or off by default, you also need to add```
    ' save to config.ini
    SaveOptions
```beneath the Options.HoverNames = 0 and Options.HoverNames = 1\. I tried this, although it didn't work and i don't know why, I'll investigate after I finish my essay(damned AP classes)

EDIT:  Alright, I found the problem(as to why it doesn't save in config.ini).  Go to ModDatabase, and search```
    Call PutVar(fileName, "Options", "Debug", Str(Options.Debug))
```and add this below```
    Call PutVar(fileName, "Options", "HoverNames", Str(Options.HoverNames))
```  Now it will save the player's preference in config.ini.
Link to comment
Share on other sites

Yeah, np, I'm gonna see if I can edit it so it shows the names all the time, although I doubt I'll be able to with my knowledge of vb6.

Edit:
I figured it out, swap Xlithan's code with this one, when your option for On is Option.HoverNames = 1, and Off is Option.HoverNames = 0.  Setting it to On will make it so you have to hover over the character to see their name, while turning it off will display their name all the time.```
    ' draw player names
    For i = 1 To Player_HighIndex
        If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
            If CurX = Player(i).x And CurY = Player(i).y And Options.HoverNames = 1 Or Options.HoverNames = 0 Then
                Call DrawPlayerName(i)
            End If
        End If
    Next

    ' draw npc names
    For i = 1 To Npc_HighIndex
        If MapNpc(i).num > 0 Then
            If CurX = MapNpc(i).x And CurY = MapNpc(i).y And Options.HoverNames = 1 Or Options.HoverNames = 0 Then
                Call DrawNpcName(i)
            End If
        End If
    Next
```  Make sure you also added
HoverNames= either 0 or 1 depending on if you want names displayed all the time or not by default to the bottom of your config.ini, and```
    ' save to config.ini
    SaveOptions
```below Option.HoverNames = 0 or 1 in both parts of frmMain.  And finally, search ModDatabase for```
Call PutVar(fileName, "Options", "Debug", Str(Options.Debug))
```and under it add```
    Call PutVar(fileName, "Options", "HoverNames", Str(Options.HoverNames))
```  and that should be it.  Please, tell me if I've forgoten anything in my previous posts, you need all of it.
Link to comment
Share on other sites

Hey guys, I found one other thing you need to add before this is complete.  In ModDatabase, you need to search for```
Options.Debug = 0
```(its the only one, but if you want to be sure, check that you're in Sub LoadOptions)  but anyways, search for that, and under it add```
Options.HoverNames = 1
```
Link to comment
Share on other sites

  • 2 weeks later...
  • 3 weeks 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...