Jump to content

Custom nametags


Swald

Recommended Posts

Hello everyone!

I wonder if there is any way to implement custom nametags? I would like for example, append player IDs to their names or color them.

I discovered this thread but when I tried to use that approach on my server I got next error for nametags argument

TypeError: Cannot read property 'forEach' of undefined

When I logged out nametags I got next object:

{ setVariable: [Function], call: [Function] }

So looks like on current version of RAGE render event doesn't have nametags argument even though it is stated on wiki page.

Please tell me is it so or am I doing something wrong, I will appreciate any help.

Thanks.

Edited by Swald
  • Mask 1
Link to comment
Share on other sites

3 hours ago, MrPancakers said:

How come you linked the exact thread OP already linked in his post

--

Swald did you put all this code serverside? If it's all clientside it should work perfectly fine.

Chill dude as you can see he edited the topic after I answer

Edited by Robson
Link to comment
Share on other sites

10 часов назад, Robson сказал:

Chill dude as you can see he edited the topic after I answer

No, like it was said before, I put link in the very beginning and then just added some details.

 

14 часа назад, MrPancakers сказал:

Swald did you put all this code serverside? If it's all clientside it should work perfectly fine.

Thank you for response. I was running it on the clientside and I found out where was the problem. I forgot the line

mp.nametags.enabled = false

When I added it, nametags.forEach works just fine. But there is one more problem with implementation in linked thread. Looks like it was working properly on previous versions of RAGE but now it renders nametags in the right top corner of the screen because mp.game.graphics.drawText gets only two coordinates instead of three to render text at world coordinates (as is stated in documentation). And I didn't succeed in fetching Z-coordinate from nametag object.

Then I found the way to implement this feature using players pool (mp.players on clientside) and it worked except for player IDs. I got different IDs for same players so I guess clientside IDs do not synchronize with serverside.

Anyway I solved this issue just by appending player ID to player.name property on serverside.

Thanks everyone for responses, I hope my experience will help someone.

Link to comment
Share on other sites

37 minutes ago, Swald said:

No, like it was said before, I put link in the very beginning and then just added some details.

 

Thank you for response. I was running it on the clientside and I found out where was the problem. I forgot the line


mp.nametags.enabled = false

When I added it, nametags.forEach works just fine. But there is one more problem with implementation in linked thread. Looks like it was working properly on previous versions of RAGE but now it renders nametags in the right top corner of the screen because mp.game.graphics.drawText gets only two coordinates instead of three to render text at world coordinates (as is stated in documentation). And I didn't succeed in fetching Z-coordinate from nametag object.

Then I found the way to implement this feature using players pool (mp.players on clientside) and it worked except for player IDs. I got different IDs for same players so I guess clientside IDs do not synchronize with serverside.

Anyway I solved this issue just by appending player ID to player.name property on serverside.

Thanks everyone for responses, I hope my experience will help someone.

Correct clientside IDs aren't the real IDs, you need to use their remoteId to get the real player ID if you want to get their ID clientside.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...