Bc# Posted November 10, 2012 Share Posted November 10, 2012 Quiero editar una función a el espectador del race (que viene por defecto) quiero crear un dxtext para lo que ya esta pero no se si sufriría consecuencias si lo llegase a hacer bueno les dejo la función que quiero editar: function Spectate.setTarget( player ) if Spectate.hasDroppedCamera() then return end Spectate.active = true Spectate.target = player if Spectate.target then if Spectate.getCameraTargetPlayer() ~= Spectate.target then setCameraTarget(Spectate.target) end guiSetText(g_GUI.speclabel, 'Currently spectating:\n' .. getPlayerName(Spectate.target)) else local x,y,z = getElementPosition(g_Me) x = x - ( x % 32 ) y = y - ( y % 32 ) z = getGroundPosition ( x, y, 5000 ) or 40 setCameraTarget( g_Me ) setCameraMatrix( x,y,z+10,x,y+50,z+60) guiSetText(g_GUI.speclabel, 'Currently spectating:\n No one to spectate') end if Spectate.active and Spectate.savePos then guiSetText(g_GUI.speclabel, guiGetText(g_GUI.speclabel) .. "\n\nPress 'B' to join") end end La parte que dice: guiSetText(g_GUI.speclabel, 'Currently spectating:\n' .. getPlayerName(Spectate.target)) Lo podria reemplazar por: dxText:create("#FFFFFFMirando a:\n"..getPlayerNametagText(Spectate.target).."", x / 2, y / 2 - 10 + 75 - 41, false, "bankgothic", 1, "center") Al final con la funcion de dxtext incluida me quedaria algo asi: function dxDrawColorText(str, ax, ay, bx, by, color, scale, font) evofont = dxCreateFont("evo.ttf", 12) 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) dxDrawColorText(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) dxDrawColorText(cap, ax, ay, ax + w, by, color, scale, font) end end function Spectate.setTarget( player ) if Spectate.hasDroppedCamera() then return end Spectate.active = true Spectate.target = player if Spectate.target then if Spectate.getCameraTargetPlayer() ~= Spectate.target then setCameraTarget(Spectate.target) end dxText:create("#FFFFFFMirando a:\n"..getPlayerNametagText(Spectate.target).."", x / 2, y / 2 - 10 + 75 - 41, false, "bankgothic", 1, "center") local x,y,z = getElementPosition(g_Me) x = x - ( x % 32 ) y = y - ( y % 32 ) z = getGroundPosition ( x, y, 5000 ) or 40 setCameraTarget( g_Me ) setCameraMatrix( x,y,z+10,x,y+50,z+60) guiSetText(g_GUI.speclabel, 'Currently spectating:\n No one to spectate') end if Spectate.active and Spectate.savePos then guiSetText(g_GUI.speclabel, guiGetText(g_GUI.speclabel) .. "\n\nPress 'B' to join") end end Link to comment
Recommended Posts