DjSt3rios Posted May 17, 2011 Share Posted May 17, 2011 Hello, im new here and i would like to ask something. In race resource, i changed the name tag colour, i made it to check the name color of the player, and put the same color in the tag. It was like that: local r,g,b = 255,255,255 and i changed it to this: local r,g,b = getPlayerNametagColor ( player ) but its not working, can somebody help me? Link to comment
Try Posted May 17, 2011 Share Posted May 17, 2011 ?????????????????? Sorry i dont understand you need get player name color to put at name again? Link to comment
DjSt3rios Posted May 17, 2011 Author Share Posted May 17, 2011 Well in race name if ur name is #FF0000Test on the top of the car it appears as WHITE. Well, i want to make it red. Link to comment
TAPL Posted May 17, 2011 Share Posted May 17, 2011 make it red? this will make it red local r,g,b = 255,0,0 Link to comment
DjSt3rios Posted May 18, 2011 Author Share Posted May 18, 2011 I mean IF ur name is read.. i want to automatically check the name color of every player, and put the right color for every player. if ur name is red, i want the text to appear red, if ur name is green, i want the text to appear green, thats what i mean.. Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 (edited) EDIT: here it is --serverside! function process() local players=getElementsByType("player") for _,v in pairs(players) do processPlayer(v) end end function processPlayer(p) local Player=source or p local nick=getPlayerName(Player) local colorcode=nick:match("^#%x%x%x%x%x%x") if colorcode then local red,blue,green=getColorFromString(colorcode) setPlayerNametagColor(Player,red,blue,green) end setPlayerName(Player,nick:gsub("#%x%x%x%x%x%x","")) end addEventHandler("onResouceStart",getResourceRootElement(),process) addEventHandler("onPlayerJoin",getRootElement(),processPlayer) addEventHandler("onPlayerChangeNick",getRootElement(),processPlayer) Edited May 19, 2011 by Guest Link to comment
DjSt3rios Posted May 18, 2011 Author Share Posted May 18, 2011 Yes but i want the code to put the name color on the top of the car, not on TAB or sth.. it works fine in TAB, but i want a code to read the color of the name, and put it on the top of the car, because now its always white even if the player name is red for example.. Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 setNametagColor does exactly that. Link to comment
DjSt3rios Posted May 18, 2011 Author Share Posted May 18, 2011 Well i dont think i need to do it like that. In Race it uses this: dxDrawText (getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) so i need to use dxDrawText.. Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 but i showed you how to get the r g b out of hex string, (need to be server side tough), use that, then transfer r g b to client, and then tocolor(r,g,b,255) for setting color. but keep the gsub + setname at serverside script. Link to comment
DjSt3rios Posted May 18, 2011 Author Share Posted May 18, 2011 I tried to do it, but it didnt work Link to comment
Try Posted May 18, 2011 Share Posted May 18, 2011 Can i try? I don't tested, Try this: function carcolor() function ( thePlayer ) local r, g, b = getPlayerNametagColor ( thePlayer ) setVehicleColor ( thePlayer , r, b, g, 0 ) end addCommandHandler ( "namecolor", carcolor ) Try Link to comment
DjSt3rios Posted May 18, 2011 Author Share Posted May 18, 2011 Well i tried something like this but its not working. Btw i want the name color to change, not vehicle. The name which is on the top of the car.. Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 ok try this add the script i showed before serverside, and then do this: r,g,b=getPlayerNametagColor(player) 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
Try Posted May 18, 2011 Share Posted May 18, 2011 hmm you need car color be name color function carcolor(thePlayer) local r = getVehicleColor(thePlayer) setPlayerName(thePlayer, r..getPlayerName(thePlayer)) end addCommandHandler("test",carcolor) ___________ Sorry Guy i read what i writed at the other post and its wrong Try: function carcolor( thePlayer ) local r, g, b = getPlayerNametagColor ( thePlayer ) setVehicleColor ( thePlayer , r, b, g, 0 ) end addCommandHandler ( "namecolor", carcolor ) Link to comment
karlis Posted May 18, 2011 Share Posted May 18, 2011 hmm you need car color be name color function carcolor(thePlayer) local r = getVehicleColor(thePlayer) setPlayerName(thePlayer, r..getPlayerName(thePlayer)) end addCommandHandler("test",carcolor) ___________ Sorry Guy i read what i writed at the other post and its wrong Try: function carcolor( thePlayer ) local r, g, b = getPlayerNametagColor ( thePlayer ) setVehicleColor ( thePlayer , r, b, g, 0 ) end addCommandHandler ( "namecolor", carcolor ) this makes zero sense, nor vehicle color id works on nicks, nor vehicles work on rgb(until 1.1). and the fact is HE DIDNT EVEN ASK FOR VEHICLE COLOR Link to comment
DjSt3rios Posted May 18, 2011 Author Share Posted May 18, 2011 Hmm, now the color is light green, its not showing it properly any help? Link to comment
karlis Posted May 19, 2011 Share Posted May 19, 2011 Hmm, now the color is light green, its not showing it properly any help? you used that code i made serverside, then put tag color to dxdrawtext? Link to comment
DjSt3rios Posted May 19, 2011 Author Share Posted May 19, 2011 in nametags.lua i put this: r,g,b=getPlayerNametagColor(player) and then it has this code: dxDrawText (getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) and in the same file, in the end, i added this: function process() players=getElementsByType("player") for _,v in pairs(players) do processPlayer(v) end end function processPlayer(p) local Player=source or p local nick=getPlayerName(Player) local colorcode=nick:match("^#%x%x%x%x%x%x") if colorcode then local red,blue,green=getColorFromString(colorcode) setPlayerNametagColor(Player,red,blue,green) end setPlayerName(Player,nick:gsub("#%x%x%x%x%x%x","")) end addEventHandler("onResouceStart",getResourceRootElement(),process) addEventHandler("onPlayerJoin",getRootElement(),processPlayer) addEventHandler("onPlayerChangeNick",getRootElement(),processPlayer) and with this it appears light green Link to comment
karlis Posted May 19, 2011 Share Posted May 19, 2011 please use [ lua] code here [/lua] (whithout the space at front) or [/code] this have to be in clientside, in nametags.lua i suppose. ... local r,g,b=getPlayerNametagColor(player) dxDrawText (getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) ... and this have to be serverside, in other script file. function process() players=getElementsByType("player") for _,v in pairs(players) do processPlayer(v) end end function processPlayer(p) local Player=source or p local nick=getPlayerName(Player) local colorcode=nick:match("^#%x%x%x%x%x%x") if colorcode then local red,blue,green=getColorFromString(colorcode) setPlayerNametagColor(Player,red,blue,green) end setPlayerName(Player,nick:gsub("#%x%x%x%x%x%x","")) end addEventHandler("onResouceStart",getResourceRootElement(),process) addEventHandler("onPlayerJoin",getRootElement(),processPlayer) addEventHandler("onPlayerChangeNick",getRootElement(),processPlayer) [code=lua] code here Link to comment
DjSt3rios Posted May 19, 2011 Author Share Posted May 19, 2011 I put it in race_server.lua but still its not working properly plus it changes my name like 100 times, but i removed the code SetPlayerName Link to comment
karlis Posted May 19, 2011 Share Posted May 19, 2011 oh, theres a inf loop, fixing it. anyway you need the setname so you won't see the colorcodes in the textdraw EDIT:heres the fix countless more edits:optimizng function process() players=getElementsByType("player") for _,v in pairs(players) do processPlayer(v) end end function processPlayer(p) local Player=source or p local nick=getPlayerName(Player) local newnick=nick:gsub("#%x%x%x%x%x%x","") local colorcode=nick:match("^#%x%x%x%x%x%x") if newnick~=nick then setPlayerName(Player,newnick) if colorcode then local red,green,blue=getColorFromString(colorcode) setPlayerNametagColor(Player,red,green,blue) end end end addEventHandler("onResouceStart",getResourceRootElement(),process) addEventHandler("onPlayerJoin",getRootElement(),processPlayer) addEventHandler("onPlayerChangeNick",getRootElement(),processPlayer) Link to comment
DjSt3rios Posted May 19, 2011 Author Share Posted May 19, 2011 still.. colors are random with this... Link to comment
karlis Posted May 19, 2011 Share Posted May 19, 2011 no errors in both client and server? 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