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 !