Jump to content

[HELP] not work refresh Label


[M]ister

Recommended Posts

Posted

Hello again, I added in a gui a label with the name of the player without the color code, and when any player open the gui the label name is updated, (more is not working)

              ... 
local name = string.gsub(getPlayerName(localPlayer), "#%x%x%x%x%x%x", "") 
Label = guiCreateLabel(68, 83, 252, 15, "Your Name: ", false, window) 
function refreshStats() 
    if guiGetVisible(window,true) then 
       guiSetText(Label,"Your Name: "..name) 
    end 
end 
addEventHandler("onClientRender", getRootElement(), refreshStats) 
              ... 

Posted

Of course it won't update, that's because you put getPlayerName outside the refreshStats function, so it'll always use the name obtained when resource started.

Posted

this? It was the first thing I tried, and did not work, I will try again.

Edit: LoL now picked up, I must have done something wrong before :lol:

             ... 
Label = guiCreateLabel(68, 83, 252, 15, "Your Name: ", false, window) 
function refreshStats() 
local name = string.gsub(getPlayerName(localPlayer), "#%x%x%x%x%x%x", "") 
    if guiGetVisible(window,true) then 
       guiSetText(Label,"Your Name: "..name) 
    end 
end 
addEventHandler("onClientRender", getRootElement(), refreshStats) 
              ... 

Posted

Thanks again Solidsnake14. To enjoy the post, just want to ask another question: How could be showing the name of the player with the colors (hidden code)

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