John Smith Posted August 1, 2014 Share Posted August 1, 2014 hello i got one question i have my own nametags and i want that if a player has nick like with two colors that those 2 colors get drawn in nametag but theres just one color and that color is random one which freeroam decides i seen in scoreboard resource that there is used getColorFromString to draw multiple colors but i didnt understand how to put it in my script does anyone know how should the line look to get all colors in nametag and draw it? Link to comment
Walid Posted August 1, 2014 Share Posted August 1, 2014 Sorry i don't undrestand your question but As i undrestand you are asking about how to change name tag color , you can use html color codes like this ex : #FFFFFFName Link to comment
John Smith Posted August 1, 2014 Author Share Posted August 1, 2014 lol i know how to use html color codes,thats not the problem the problem is here in example dxDrawText( string.gsub(getElementData(v,"pnick"), "#%x%x%x%x%x%x", ""), x, y, x, y, tocolor(rr, gg, bb), scale + ( 15 - dist ) * 0.02, myFont ) -- using gsub thing to remove e.g #FF0000 from nametag text lets say theres player Mike and that all regular players with no team have white nametag color so it will draw text Mike in White color however if mike decides to have two colors like #00ff00Mi#0000ffke then on chat and scoreboard he will have green-blue nick but on my nametag system he will still have default white Mike text and i want that if he has html color codes in name that it updates so that he also has two colors on my nametag system i hope you understand what i meant now Link to comment
Anubhav Posted August 1, 2014 Share Posted August 1, 2014 Its not HTML colors. HTML don't have colors. Its hex codes lol. What is pnick? What is it data. Link to comment
John Smith Posted August 1, 2014 Author Share Posted August 1, 2014 its players nick with /pnick instead of /nick Link to comment
Anubhav Posted August 1, 2014 Share Posted August 1, 2014 I am not sure what do you want do, If I am right you are making a text on screen which shows player name right? Link to comment
John Smith Posted August 1, 2014 Author Share Posted August 1, 2014 yeah its already drawn and its showing name totally fine im just trying to show the thing i wanna make but idk how if player doesnt have any hex color codes then his name looks like this Mike - in white color but if he has 2 or more colors on his nick its suppost to be like Mike but on my nametag system it still shows Mike in white color instead of those above 2 colors actually in my server the player can have infinite number of colors on his name but in here showing just 2 ones as example Link to comment
Anubhav Posted August 1, 2014 Share Posted August 1, 2014 The string.gsub will remove ALL HEX codes. Link to comment
John Smith Posted August 1, 2014 Author Share Posted August 1, 2014 it will remove hex codes in way of this before - #00FF00Mi#0000FFke later - Mike but its still not in 2 colors in nametag and i believe there are no 2 colors in nametag because i would need to remove gsub thing and somehow use getColorFromString function but i dont know how to use it so i didnt remove it yet can you help me with how to use getColorFromString in this case? Link to comment
Anubhav Posted August 1, 2014 Share Posted August 1, 2014 I'm not sure how do with it. I don't think its possible to check 2 hex in nick. You may suggest it. Link to comment
John Smith Posted August 1, 2014 Author Share Posted August 1, 2014 you think its not possible?how?half of mta servers got nametag system like that,most popular ones in race would be TG or FFS and theres even the code in dxscoreboard which does this if column.name == "name" then local playerName = getElementData( player, "pnick" ) -- here i changed the definition so it puts that data on scoreboard if serverInfo.allowcolorcodes then if string.find( playerName, "#%x%x%x%x%x%x" ) then local colorCodes = {} while( string.find( playerName, "#%x%x%x%x%x%x" ) ) do local startPos, endPos = string.find( playerName, "#%x%x%x%x%x%x" ) if startPos then colorCode = string.sub( playerName, startPos, endPos ) table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } ) playerName = string.gsub( playerName, "#%x%x%x%x%x%x", "", 1 ) i just dont know how to "transform" this code into my code so that it would work Link to comment
Saml1er Posted August 16, 2014 Share Posted August 16, 2014 Lol then simply don't remove hex codes in your nametag script. dxDrawText( getElementData(v,"pnick"), x, y, x, y, tocolor(rr, gg, bb), scale + ( 15 - dist ) * 0.02, myFont ,false,false,false,true) Link to comment
John Smith Posted August 16, 2014 Author Share Posted August 16, 2014 Lol then simply don't remove hex codes in your nametag script. dxDrawText( getElementData(v,"pnick"), x, y, x, y, tocolor(rr, gg, bb), scale + ( 15 - dist ) * 0.02, myFont ,false,false,false,true) there still wont be any other color, but just one,the nametag color which freeroam sets by default and it will also look like this #00FF00Mi#0000FFke -- an example Link to comment
Saml1er Posted August 16, 2014 Share Posted August 16, 2014 Lol then simply don't remove hex codes in your nametag script. dxDrawText( getElementData(v,"pnick"), x, y, x, y, tocolor(rr, gg, bb), scale + ( 15 - dist ) * 0.02, myFont ,false,false,false,true) there still wont be any other color, but just one,the nametag color which freeroam sets by default and it will also look like this #00FF00Mi#0000FFke -- an example No it won't. Test the code and you'll see. EDIT: I made a typo, copy again. dxDrawText( getElementData(v,"pnick"), x, y, x, y, tocolor(rr, gg, bb), scale + ( 15 - dist ) * 0.02, myFont ,"left","top",false,false,true) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now