Zekrom= Posted October 2, 2011 Share Posted October 2, 2011 I want to do borders for a spectators script, but i failed , can someone help me with this ? local x, y = guiGetScreenSize () local localPlayer = getLocalPlayer() local spectatorSettings = { count = 7, -- how many player names to show, before showing "and x more" charLimit = 19, -- max limit of characters in player name xOffset = 200, -- how far to the left this should be yOffset = (y / 2) - 10, -- how far down the screen this should be ~ currently it is almost half way down alwaysShow = true -- whether to show anything if there aren't any players spectating you } local spectators = {} addEvent('addSpectator', true) addEvent('removeSpectator', true) addEventHandler('onClientResourceStart', root, function() triggerServerEvent ('addClient', localPlayer) end ) addEventHandler('addSpectator', root, function(spectator) table.insert(spectators, spectator) end ) addEventHandler('removeSpectator', root, function(spectator) for i, val in ipairs(spectators) do if (val == spectator) then table.remove(spectators, i) end end end ) function elementCheck (elem) if elem then if isElement (elem) then if (getElementType (elem) == 'player') then return true end end end return false end function drawSpectators() local textX = x - spectatorSettings.xOffset local textY = spectatorSettings.yOffset if (not isPlayerDead(localPlayer)) then local s_Spectators = 'Spectadores ['.. tostring(#spectators) ..']\n' if (#spectators > 0) then for i, v in ipairs(spectators) do if elementCheck (v) then local name = getPlayerName(v):gsub("#%x%x%x%x%x%x","") if (string.len(getPlayerName(v)) > spectatorSettings.charLimit) then name = string.sub(name, 0, spectatorSettings.charLimit)..'..' end if (i > spectatorSettings.count) then s_Spectators = s_Spectators..tostring(#spectators - spectatorSettings.count)..' more' break else s_Spectators = s_Spectators..name..'\n' end else table.remove (spectators, k) end end else if (spectatorSettings.alwaysShow) then s_Spectators = s_Spectators..'None' else s_Spectators = '/' end end dxDrawText (s_Spectators, textX, textY, x, y, tocolor(255, 225, 255, 255, true ), 0.5, 'Bankgothic') dxDrawText (s_Spectators, textX, textY, x, y, tocolor(0, 0, 0, 0), 0.5, 'Bankgothic') --dxDrawText("Spectating [".. tostring(#spectators) .."]", 825, y-410, x, y, tocolor ( 255, 255, 255, 255, true ), 0.5, "bankgothic" ) end end addEventHandler('onClientRender', root, drawSpectators) Thank You ! Link to comment
Castillo Posted October 3, 2011 Share Posted October 3, 2011 Qwert, what he want's is add borders to the DX text. Link to comment
karlis Posted October 6, 2011 Share Posted October 6, 2011 local black=tocolor(0,0,0,255) function dxDrawTextBordered(text,x1,y1,x2,y2,color,thickness,scale,font,alignX,alignY,textclip,wordbreak,postgui) for w=-thickness,thickness,thickness do for h=-thickness,thickness,thickness do if not(w==0 and h==0) then dxDrawText(text,x1+w,y1+h,x2+w,y2+h,black,scale,font,alignX,alignY,textclip,wordbreak,postgui) end end end dxDrawText(text,x1,y1,x2,y2,color,scale,font,alignX,alignY,textclip,wordbreak,postgui) end Link to comment
Zekrom= Posted October 8, 2011 Author Share Posted October 8, 2011 Thank you Karlis ! 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