#Paper Posted October 20, 2010 Share Posted October 20, 2010 this is the script for make the tag name in race gm, how i can generate the tagname's color random? local r,g,b = 255,127,36 dxDrawText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE,"default", "center", "bottom", false, false, false ) Link to comment
dzek (varez) Posted October 20, 2010 Share Posted October 20, 2010 math.random(0,255) will return random value from 0-255 range Link to comment
#Paper Posted October 20, 2010 Author Share Posted October 20, 2010 math.random(0,255) will return random value from 0-255 range can you post the modified string? pls? Link to comment
dzek (varez) Posted October 20, 2010 Share Posted October 20, 2010 first - you have to store 3 colors for every player. so something like that will be needed: -- server side!! addEventHandler("onPlayerJoin", getRootElement(), function() local col = { math.random(0,255), math.random(0,255), math.random(0,255) } setElementData(source, "color", col) end) -- then on drawing function (client): local col=getElementData(player, "color") local r=col[1] local g=col[2] local b=col[3] dxDrawText (getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE,"default", "center", "bottom", false, false, false ) Link to comment
#Paper Posted October 21, 2010 Author Share Posted October 21, 2010 first - you have to store 3 colors for every player. so something like that will be needed: -- server side!! addEventHandler("onPlayerJoin", getRootElement(), function() local col = { math.random(0,255), math.random(0,255), math.random(0,255) } setElementData(source, "color", col) end) -- then on drawing function (client): local col=getElementData(player, "color") local r=col[1] local g=col[2] local b=col[3] dxDrawText (getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE,"default", "center", "bottom", false, false, false ) ty varez! work! YOU ARE PRO! 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