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

[EO] Requesting coding help to display levels next to name


turbocookie
 Share

Recommended Posts

Hey i know there is a way to display a level under or above the players name but can i do this:

Turbocookie [lvlhere]

E.G  Turbocookie [68]

Im no programmer, but this is my attempt so show iv put effort in.

do i find this

>! If GetPlayerSprite(Index) < 1 Or GetPlayerSprite(Index) > NumCharacters Then
        TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(GetPlayerName(Index))))
        TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - 16
    Else
        ' Determine location for text
        TextX = ConvertMapX(GetPlayerX(Index) * PIC_X) + Player(Index).XOffset + (PIC_X \ 2) - getWidth(TexthDC, (Trim$(GetPlayerName(Index))))
        TextY = ConvertMapY(GetPlayerY(Index) * PIC_Y) + Player(Index).YOffset - (DDSD_Character(GetPlayerSprite(Index)).lHeight) + 16
    End If
>!     ' Draw name
    Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index), color)
End Sub

and in the line

```
    ' Draw name
    Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index), color)
```
do i just make it like

```
    ' Draw name
    Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index) & "["GetPlayerLevel(index)"]", color)

```
As i said, i dont really know what im doing, point me in the right direction? thanks.
Link to comment
Share on other sites

@Robin:

> Learn basic string concatenation. It's shown quite clearly how to do this in all examples of string handlers in the source.
>
> ```
> firstString = dataString & "[String here]" & anotherString & "[" & yetMoreString & "]"
>
> ```

Um, you have lose me at "concatenation" as i said, i am very basic.

Can you please leave a demonstation?

Reading what you said, this is the best i can do, tell me if its right.

```
Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index) & "[" & GetPlayerLevel(index) & "]" , colour)

```
Sorry for being really bad ): even the term strings kind of confuse me, i have a rough idea what they are, just cant explain it. thanks for reply so fast btw.
Link to comment
Share on other sites

Strings are basically a bunch of characters, example:
```
Dim A as String ' A is now a string.
Dim B as String ' B is now a string.
Dim C as String ' C is now a string.
A = "Bleh" ' Set A to Bleh.
B = "Blah" ' Set B to Blah
C = A & " " & B ' C is now "Bleh Blah"

```
The ampersand (&) is a signal to "add" the string together, or concatenate it.

Edit: small spelling fix.
Link to comment
Share on other sites

@Turbocookie:

> Sorry for being really bad ): even the term strings kind of confuse me, I have a rough idea what they are, just cant explain it. thanks for reply so fast btw.

When you don't understand a term you should Google it. I don't magically know what people are talking about. When I hear something I don't understand, I'm straight on the Google.

Teaching yourself to do your own research is a large part of being a programmer.

As for the code you posted it looks fine. Why don't you give it a try rather than just asking me if it'll work?
Link to comment
Share on other sites

@Robin:

> As for the code you posted it looks fine. Why don't you give it a try rather than just asking me if it'll work?

I tried it and got this error.

```
tilesetInUse(Map.Tile(X, y).Layer(I).tileset) = True

```
Im not sure if its related to that tough D:

EDIT: ok i worked out its not to do with that, but could you tell me what it is while we are here? i think i may have changed something accidently ):
Link to comment
Share on other sites

@Robin:

> I don't care. Go re-download the source.

No no, I got it working, that error is from that code I tried.

```
Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index) & "[" & GetPlayerLevel(index) & "]", colour)

```

EDIT: I think I know why, "[" and "]" arnt variables, I just down know how to display text because I want the level inside of [ and ]

Is there a variable to be like DrawText("TEXTHERE")
Thats just my random guess but yeah, i have no idea ):
Link to comment
Share on other sites

Your naming scheme is ambiguous. I'm not sure if the original source says color or if the original source says colour. I've used color in this example as per what you originally posted:

```
Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index) & "[" & GetPlayerLevel(Index) & "]", color)

```
This would be how you do it. Remove your original one and replace it with this.
Link to comment
Share on other sites

@Soul:

> Your naming scheme is ambiguous. I'm not sure if the original source says color or if the original source says colour. I've used color in this example as per what you originally posted:
>
> ```
> Call DrawText(TexthDC, TextX, TextY, GetPlayerName(Index) & "[" & GetPlayerLevel(Index) & "]", color)
>
> ```
> This would be how you do it. Remove your original one and replace it with this.

ah thankyou very much :) and yeah its just colour, it works C: i was kinda close for my first programming edit? :D thanks for fixing that up for me mate, close thread if you wish
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...