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

[EO] Player/NPC names hover option


Terrakion
 Share

Recommended Posts

This tutorial will teach you how to make an option for this tutorial: http://www.touchofdeathforums.com/smf/index.php/topic,72388.0.html

so, the credit goes to him for the feature, and the credit goes to me for the option.

ok, let's start.

Go to frmMain, search for picOptions and add:
1 label with caption of - Names. Make sure to change its font to 'Georgia' and make it bold. Then, make 2 options. Put them below your 'Names' label. name one optS and another optH. optS is for showing names, and optS is for not showing them. Then, put in their captions: Show and Hide, depending the option.

Now, to the code: (the following code is from Xlithlan's tutorial, just edited to fit this tutorial)

Go to modDirectDraw7, search for **' Draw player names**, and replace the following code:
```
' draw player names
    For i = 1 To Player_HighIndex
        If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
            Call DrawPlayerName(i)
        End If
    Next

    ' draw npc names
    For i = 1 To Npc_HighIndex
        If MapNpc(i).num > 0 Then
            Call DrawNpcName(i)
        End If
    Next
```
with:
```
    ' draw player names
    If frmMain.optH.Value = True Then
        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
Else
    For i = 1 To Player_HighIndex
        If IsPlaying(i) And GetPlayerMap(i) = GetPlayerMap(MyIndex) Then
            Call DrawPlayerName(i)
        End If
    Next
    End If

    ' draw npc names
    If frmMain.optH.Value = True Then
        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
Else
    For i = 1 To Npc_HighIndex
        If MapNpc(i).num > 0 Then
            Call DrawNpcName(i)
        End If
    Next
    End If
```
Now, go to modTypes, search for **Private Type OptionsRec**, and at the end (after debug As byte), add:
```
ShowNames As Byte
```
Now go to modDatabse, search for **Public Sub SaveOptions()** and before:
```
'error handler
```Add:
```
Call PutVar(fileName, "Options", "ShowNames", Str(Options.Debug))
```
Then, below that Sub, you will find **Public Sub LoadOptions()** and just before where it says **SaveOptions**, add:
```
Options.ShowNames = 0
```
in that same Sub, just before the FIRST **End If**, add:
```
Options.ShowNames = GetVar(fileName, "Options", "ShowNames")
```
Then, in that sub, before it says **'error handler**, add:
```
    If Options.ShowNames = 0 Then
        frmMain.optS.Value = True
    Else
        frmMain.optH.Value = True
    End If
```
and finally, add this at the bottom of frmMain's code:
```
Private Sub opts_Click()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Options.ShowNames = 0
    SaveOptions

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "optW_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub

Private Sub opth_Click()
    ' If debug mode, handle error then exit out
    If Options.Debug = 1 Then On Error GoTo errorhandler

    Options.ShowNames = 1
    SaveOptions

    ' Error handler
    Exit Sub
errorhandler:
    HandleError "optR_Click", "frmMain", Err.Number, Err.Description, Err.Source, Err.HelpContext
    Err.Clear
    Exit Sub
End Sub
```
and lastly, go to config.ini and at the bottom (after debug= 0 or w/e), add:
```
ShowNames= 0
```If you don't add this to your config.ini, you will receive a RTE.

Hope this helps you all, i felt like contributing to the community for the first time…. may post more tutorials.
Link to comment
Share on other sites

  • 3 weeks later...
This is my code except worded differently, and a lot longer, for no reason -.-  I fail to see how interchanging my "HoverNames" and your "ShowNames" constitutes as a tutorial.  In addition, you need to follow the extra steps that I detailed to complete the option feature.  That was the first time I figured out how to code a feature(be it something small) all by myself, so I am very…_touchy_…about this.

For future reference, I advise you to read [this](http://www.plagiarism.org/plag_article_what_is_plagiarism.html), Terrakion, it could keep you out of a lot of trouble in the future.
Link to comment
Share on other sites

@Terrakion:

> This tutorial will teach you how to make an option for this tutorial: http://www.touchofdeathforums.com/smf/index.php/topic,72388.0.html

Kinda like how I did…except ten days earlier than you did...with your topic LINKED to the topic where I posted mine...

@terrakion:

> Hope this helps you all, i felt like contributing to the community for the first time….

Your probablly feeling how I felt.  10 days before you posted this.  I seriously suggest you read [this](http://www.plagiarism.org/plag_article_what_is_plagiarism.html), before you attempt to 'contribute' again.
Link to comment
Share on other sites

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