R.y.c.k Posted June 23, 2012 Share Posted June 23, 2012 Hello sou .. know what is wrong? always throwing error , even if I don't have hunter client : .... do you need also server side ? thank .. winnerText = " " winnerText2 = " " timeTimer = 6000 showWinnerText = false function showDDWinnerAndHisText (text) winnerText = text winnerText2 = winnerText:gsub("#%x%x%x%x%x%x","") showWinnerText = true setTimer(function() winnerText = " " winnerText2 = " " showWinnerText = false end, timeTimer, 1) end addEvent("showDDWinnerAndHisText", true) addEventHandler("showDDWinnerAndHisText", getRootElement(), showDDWinnerAndHisText ) font = guiCreateFont("font.ttf", 1) screenWidth, screenHeight = guiGetScreenSize ( ) function drawHunterReached() if showHunterReached then local hud1 = dxDrawText("Hunter reached", 0+2, 0+2, screenWidth+2, screenHeight+2, tocolor ( 0, 0, 0, 255 ), 2, "bankgothic","center","center") local hud1 = dxDrawText("Hunter reached", 0, 0, screenWidth, screenHeight, tocolor (math.random(255),math.random(255),math.random(255),255), 2, "bankgothic","center","center") elseif showWinnerText then dxDrawText(winnerText2, 0+2, 0+2, screenWidth+2, screenHeight/3+2, tocolor ( 0, 0, 0, 255 ), 1.3, "bankgothic","center","center") dxDrawColorText(winnerText, 0, 0, screenWidth, screenHeight/3, tocolor ( 255, 0, 0, 255 ), 1.3, "bankgothic","center","center") end end addEventHandler("onClientRender", getRootElement(), drawHunterReached) setTimer( function() hud1:setColor(tocolor(math.random(255),math.random(255),math.random(255),255)) end,2000,0) function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) if alignX then if alignX == "center" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = ax + (bx-ax)/2 - w/2 elseif alignX == "right" then local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) ax = bx - w end end if alignY then if alignY == "center" then local h = dxGetFontHeight(scale, font) ay = ay + (by-ay)/2 - h/2 elseif alignY == "bottom" then local h = dxGetFontHeight(scale, font) ay = by - h end end local pat = "(.-)#(%x%x%x%x%x%x)" local s, e, cap, col = str:find(pat, 1) local last = 1 while s do if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end 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"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(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 Link to comment
Anderl Posted June 23, 2012 Share Posted June 23, 2012 Variable hud1 is local, not global. setColor function does not exists. It isn't even a method and dxDrawText doesn't return an object so you can't use the function that way. Also, you can't have two dxDrawText functions with same variable name, it will overwrite. Example: b = 'Hey Hey Hey'; print( b ); -- Hey Hey Hey b = 'lol'; print( b ); -- lol 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