Cavorta Posted July 11, 2011 Share Posted July 11, 2011 Color codes to people on the server how the R, G, B, as you project? Which functions are used? Link to comment
JR10 Posted July 11, 2011 Share Posted July 11, 2011 Hex To RGB : getColorFromString ? RGB To Hex: function RGB2HEX(r,g,b) return string.format("#%02X%02X%02X", r,g,b) end Link to comment
Cavorta Posted July 11, 2011 Author Share Posted July 11, 2011 Are you a writer export function for RGB to HEX? EDİT: For example, the player's name Cavo # 990000RTA Would you show it as RGB? As in the EPG server. Link to comment
qaisjp Posted July 11, 2011 Share Posted July 11, 2011 No you wouldn't it isn't possible to set and RGB midway without using hex. However, if you need to type /wt CavoRTA without hex, you can use string.gsub (find the hex remover) when using getPlayerFromName. Link to comment
Cavorta Posted July 11, 2011 Author Share Posted July 11, 2011 So how did the EPG? Do you have a knowledge? Link to comment
tigerman Posted July 11, 2011 Share Posted July 11, 2011 This code is somewhere in this forum, but clearly ur too lazy to use search and im not helping either to copy theyr ideas Link to comment
qaisjp Posted July 11, 2011 Share Posted July 11, 2011 They used hex... Basically: outputChatBox("Hello #ff0000World, #00ff00NICE?!", 0, 0, 255) (edit respectively for server side) would output: Hello World, NICE?! Link to comment
Cavorta Posted July 11, 2011 Author Share Posted July 11, 2011 You have not understood me. EPG server gonna like it. As an example, the name of Cavo # FF0000rta dxDrawText Cavorta function as a write. Link to comment
tigerman Posted July 11, 2011 Share Posted July 11, 2011 Code by MTA forum moderator Aiboforcen function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..string.sub(col, 1, 2)), tonumber("0x"..string.sub(col, 3, 4)), tonumber("0x"..string.sub(col, 5, 6)), 255) end last = e+1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end copy it under nametags.lua functions and replace dxDrawText with dxDrawColorText Link to comment
JR10 Posted July 11, 2011 Share Posted July 11, 2011 , running? you must use the function. Link to comment
Cavorta Posted July 11, 2011 Author Share Posted July 11, 2011 Code is: function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if s ~= 1 or cap ~= "" then local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) ax = ax + w color = tocolor(tonumber("0x"..string.sub(col, 1, 2)), tonumber("0x"..string.sub(col, 3, 4)), tonumber("0x"..string.sub(col, 5, 6)), 255) end last = e+1 s, e, cap, col = str:find(pat, last) end if last <= #str then cap = str:sub(last) local w = dxGetTextWidth(cap, scale, font) dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) end end addEventHandler ( "onClientRender", g_Root, function() -- Hideous quick fix -- for i,player in ipairs(getElementsByType ("player")) do if player ~= g_Me then setPlayerNametagShowing ( player, false ) if not nametags[player] then nametag.create ( player ) end end end if bHideNametags then return end local x,y,z = getCameraMatrix() for player in pairs(nametags) do while true do if not isPedInVehicle(player) or isPlayerDead(player) then break end local vehicle = getPedOccupiedVehicle(player) local px,py,pz = getElementPosition ( vehicle ) local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) if pdistance <= NAMETAG_DISTANCE then --Get screenposition local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) if not sx or not sy then break end --Calculate our components local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE)) local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF) alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA) scale = math.evalCurve(maxScaleCurve,scale) local textscale = math.evalCurve(textScaleCurve,scale) local textalpha = math.evalCurve(textAlphaCurve,alpha) local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale) --Draw our text local r,g,b = getPlayerNametagColor (player) local team = getPlayerTeam(player) if team then r,g,b = getTeamColor(team) end local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 dxDrawColorText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default-bold", "center", "bottom", false, false, false ) --We draw three parts to make the healthbar. First the outline/background local drawX = sx - NAMETAG_WIDTH*scale/2 drawY = sy + offset local width,height = NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) --Next the inner background local health = getElementHealth(vehicle) health = math.max(health - 250, 0)/750 local p = -510*(health^2) local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, width - outlineThickness*2, height - outlineThickness*2, tocolor(r,g,0,0.4*alpha) ) --Finally, the actual health dxDrawRectangle ( drawX + outlineThickness, drawY + outlineThickness, health*(width - outlineThickness*2), height - outlineThickness*2, tocolor(r,g,0,alpha) ) end break end end end ) Image here: Link to comment
Aibo Posted July 11, 2011 Share Posted July 11, 2011 1. this dxDrawColorText does not support text alignment (you should search, i posted a fixed version somewhere with centering etc) 2. as i recall race resource strips color tags from player names. (see _common.lua where getPlayerName is redefined to strip color codes) you can try using _getPlayerName() Link to comment
Cavorta Posted July 11, 2011 Author Share Posted July 11, 2011 Yes yes.. Sorry . I edit _common.lua. Thanks for code. Link to comment
Aibo Posted July 11, 2011 Share Posted July 11, 2011 actually i wouldnt recommend editing getPlayerName() in _common.lua (you can break something by bringing back color codes). better use _getPlayerName() when you want a name with color. 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