Jump to content

Mopped

Members
  • Posts

    27
  • Joined

  • Last visited

1 Follower

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

Mopped's Achievements

Advanced Member

Advanced Member (8/54)

2

Reputation

  1. Tá na mão aí, fera. Link para baixar o marker aqui Scan
  2. São bastantes arquivos server/client que possuem esse scoreboard, então vou colocar apenas os mais relevantes... https://prnt.sc/qjd6du dxscoreboard_client: -- THESE CAN BE CHANGED triggerKey = "tab" -- default button to open/close scoreboard settingsKey = "F7" -- default button to open the settings window drawOverGUI = true -- draw scoreboard over gui? seperationSpace = 80 -- the space between top/bottom screen and scoreboard top/bottom in pixels -- BUT DON'T TOUCH THESE scoreboardToggled = false scoreboardForced = false scoreboardDrawn = false forceScoreboardUpdate = false useAnimation = true scoreboardIsToggleable = false showServerInfo = false showGamemodeInfo = false showTeams = true useColors = true drawSpeed = 1 scoreboardScale = 1 teamHeaderFont = "clear" contentFont = dxCreateFont("ITCKRIST.ttf",20) columnFont = dxCreateFont("ITCKRIST.ttf",20) serverInfoFont = dxCreateFont("ITCKRIST.ttf",20) rmbFont = "clear" cBlack = tocolor( 68,68,68 )-- 3 puta 68 cWhite = tocolor( 0, 0, 0, 150 ) cSettingsBox = tocolor( 0, 0, 0, 150 ) MAX_PRIRORITY_SLOT = 500 scoreboardColumns = {} resourceColumns = {} scoreboardDimensions = { ["width"] = 0, ["height"] = 0, ["phase"] = 1, ["lastSeconds"] = 0 } scoreboardTicks = { ["lastUpdate"] = 0, ["updateInterval"] = 500 } scoreboardContent = {} firstVisibleIndex = 1 sortBy = { ["what"] = "__NONE__", ["dir"] = -1 } -- -1 = dec, 1 = asc sbOutOffset, sbInOffset = 1, 1 sbFont = "clear" sbFontScale = 0.68 serverInfo = {} fontScale = { -- To make all fonts be equal in height ["default"] = 1.0, ["default-bold"] = 1.0, ["clear"] = 1.0, ["arial"] = 1.0, ["sans"] = 1.0, ["pricedown"] = 0.5, ["bankgothic"] = 0.5, ["diploma"] = 0.5, ["beckett"] = 0.5 } customFont = dxCreateFont("font.ttf",18) fontScaleRace = 5 colorCode = {255,255,255} selectedRows = {} addEvent( "onClientPlayerScoreboardClick" ) addEventHandler( "onClientResourceStart", getResourceRootElement( getThisResource() ), function ( resource ) cScoreboardBackground = tocolor( defaultSettings.bg_color.r, defaultSettings.bg_color.g, defaultSettings.bg_color.b, defaultSettings.bg_color.a ) cSelection = tocolor( defaultSettings.selection_color.r, defaultSettings.selection_color.g, defaultSettings.selection_color.b, defaultSettings.selection_color.a ) cHighlight = tocolor( defaultSettings.highlight_color.r, defaultSettings.highlight_color.g, defaultSettings.highlight_color.b, defaultSettings.highlight_color.a ) cHeader = tocolor( defaultSettings.header_color.r, defaultSettings.header_color.g, defaultSettings.header_color.b, defaultSettings.header_color.a ) cTeam = tocolor( defaultSettings.team_color.r, defaultSettings.team_color.g, defaultSettings.team_color.b, defaultSettings.team_color.a ) cBorder = tocolor( defaultSettings.border_color.r, defaultSettings.border_color.g, defaultSettings.border_color.b, defaultSettings.border_color.a ) cServerInfo = tocolor( defaultSettings.serverinfo_color.r, defaultSettings.serverinfo_color.g, defaultSettings.serverinfo_color.b, defaultSettings.serverinfo_color.a ) cContent = tocolor( defaultSettings.content_color.r, defaultSettings.content_color.g, defaultSettings.content_color.b, defaultSettings.content_color.a ) bindKey( triggerKey, "down", "Toggle scoreboard", "1" ) bindKey( triggerKey, "up", "Toggle scoreboard", "0" ) bindKey( settingsKey, "down", "Open scoreboard settings", "1" ) local resource = getResourceFromName("race") if resource then customFont,fontScaleRace,colorCode = call(resource,"getRaceSettings") if not customFont then customFont = dxCreateFont("ITCKRIST.ttf",20) end if not customFont then customFont = dxCreateFont("ITCKRIST.ttf",20) end if not fontScaleRace then fontScaleRace = 5 end if not colorCode then colorCode = {0,176,255} end end addEventHandler( "onClientRender", getRootElement(), drawScoreboard ) triggerServerEvent( "onClientDXScoreboardResourceStart", getRootElement() ) readScoreboardSettings() triggerServerEvent( "requestServerInfo", localPlayer ) colorPicker.constructor() end ) function updateCustomSettings(customFontRace,fontScaleRaceRace,colorCodeRace) customFont,fontScaleRace,colorCode = customFontRace,fontScaleRaceRace,colorCodeRace readScoreboardSettings() end addEvent("onRaceWantUpdateInterfaceData",true) addEventHandler("onRaceWantUpdateInterfaceData",getRootElement(),updateCustomSettings) addEventHandler( "onClientPlayerQuit", getRootElement(), function() selectedRows[source] = nil end ) function sendServerInfo( output ) serverInfo = output end addEvent( "sendServerInfo", true ) addEventHandler( "sendServerInfo", getRootElement(), sendServerInfo ) function toggleScoreboard( _, state ) state = iif( state == "1", true, false ) if scoreboardIsToggleable and state then scoreboardToggled = not scoreboardToggled elseif not scoreboardIsToggleable then scoreboardToggled = state end end addCommandHandler( "Toggle scoreboard", toggleScoreboard ) function openSettingsWindow() if scoreboardDrawn then local sX, sY = guiGetScreenSize() if not (windowSettings and isElement( windowSettings ) and guiGetVisible( windowSettings )) then --createScoreboardSettingsWindow( sX-323, sY-350 ) --showCursor( true ) elseif isElement( windowSettings ) then --destroyScoreboardSettingsWindow() end end end addCommandHandler( "Open scoreboard settings", openSettingsWindow ) addCommandHandler( "scoreboard", function () scoreboardToggled = not scoreboardToggled end ) function iif( cond, arg1, arg2 ) if cond then return arg1 end return arg2 end function doDrawScoreboard( rtPass, onlyAnim, sX, sY ) if getElementData(localPlayer,"loginState") then return end if #scoreboardColumns ~= 0 then -- -- In/out animation -- local currentSeconds = getTickCount() / 1000 local deltaSeconds = currentSeconds - scoreboardDimensions.lastSeconds scoreboardDimensions.lastSeconds = currentSeconds deltaSeconds = math.clamp( 0, deltaSeconds, 1/25 ) if scoreboardToggled or scoreboardForced then local phases = { [1] = { ["width"] = s(10), ["height"] = s(5), ["incToWidth"] = s(10), ["incToHeight"] = s(5), ["decToWidth"] = 0, ["decToHeight"] = 0 }, [2] = { ["width"] = s(40), ["height"] = s(5), ["incToWidth"] = calculateWidth(), ["incToHeight"] = s(5), ["decToWidth"] = s(10), ["decToHeight"] = s(5) }, [3] = { ["width"] = calculateWidth(), ["height"] = s(30), ["incToWidth"] = calculateWidth(), ["incToHeight"] = calculateHeight(), ["decToWidth"] = calculateWidth(), ["decToHeight"] = s(5) } } if not useAnimation then scoreboardDimensions.width = calculateWidth() scoreboardDimensions.height = calculateHeight() scoreboardDimensions.phase = #phases end local maxChange = deltaSeconds * 30*drawSpeed local maxWidthDiff = math.clamp( -maxChange, phases[scoreboardDimensions.phase].incToWidth - scoreboardDimensions.width, maxChange ) local maxHeightDiff = math.clamp( -maxChange, phases[scoreboardDimensions.phase].incToHeight - scoreboardDimensions.height, maxChange ) if scoreboardDimensions.width < phases[scoreboardDimensions.phase].incToWidth then scoreboardDimensions.width = scoreboardDimensions.width + maxWidthDiff * phases[scoreboardDimensions.phase].width if scoreboardDimensions.width > phases[scoreboardDimensions.phase].incToWidth then scoreboardDimensions.width = phases[scoreboardDimensions.phase].incToWidth end elseif scoreboardDimensions.width > phases[scoreboardDimensions.phase].incToWidth and not scoreboardDrawn then scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width if scoreboardDimensions.width < phases[scoreboardDimensions.phase].incToWidth then scoreboardDimensions.width = phases[scoreboardDimensions.phase].incToWidth end end if scoreboardDimensions.height < phases[scoreboardDimensions.phase].incToHeight then scoreboardDimensions.height = scoreboardDimensions.height + maxHeightDiff * phases[scoreboardDimensions.phase].height if scoreboardDimensions.height > phases[scoreboardDimensions.phase].incToHeight then scoreboardDimensions.height = phases[scoreboardDimensions.phase].incToHeight end elseif scoreboardDimensions.height > phases[scoreboardDimensions.phase].incToHeight and not scoreboardDrawn then scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height if scoreboardDimensions.height < phases[scoreboardDimensions.phase].incToHeight then scoreboardDimensions.height = phases[scoreboardDimensions.phase].incToHeight end end if scoreboardDimensions.width == phases[scoreboardDimensions.phase].incToWidth and scoreboardDimensions.height == phases[scoreboardDimensions.phase].incToHeight then if phases[scoreboardDimensions.phase + 1] then scoreboardDimensions.phase = scoreboardDimensions.phase + 1 else if not scoreboardDrawn then bindKey( "mouse2", "both", showTheCursor ) bindKey( "mouse_wheel_up", "down", scrollScoreboard, -1 ) bindKey( "mouse_wheel_down", "down", scrollScoreboard, 1 ) addEventHandler( "onClientClick", getRootElement(), scoreboardClickHandler ) if not (windowSettings and isElement( windowSettings )) then showCursor( false ) end --triggerServerEvent( "requestServerInfo", getRootElement() ) end scoreboardDrawn = true end end elseif scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then local phases = { [1] = { ["width"] = s(10), ["height"] = s(5), ["incToWidth"] = s(10), ["incToHeight"] = s(5), ["decToWidth"] = 0, ["decToHeight"] = 0 }, [2] = { ["width"] = s(40), ["height"] = s(5), ["incToWidth"] = calculateWidth(), ["incToHeight"] = s(5), ["decToWidth"] = s(10), ["decToHeight"] = s(5) }, [3] = { ["width"] = calculateWidth(), ["height"] = s(30), ["incToWidth"] = calculateWidth(), ["incToHeight"] = calculateHeight(), ["decToWidth"] = calculateWidth(), ["decToHeight"] = s(5) } } if scoreboardDrawn then unbindKey( "mouse2", "both", showTheCursor ) unbindKey( "mouse_wheel_up", "down", scrollScoreboard, -1 ) unbindKey( "mouse_wheel_down", "down", scrollScoreboard, 1 ) removeEventHandler( "onClientClick", getRootElement(), scoreboardClickHandler ) if not (windowSettings and isElement( windowSettings )) then showCursor( false ) end end scoreboardDrawn = false if not useAnimation then scoreboardDimensions.width = 0 scoreboardDimensions.height = 0 scoreboardDimensions.phase = 1 end local maxChange = deltaSeconds * 30*drawSpeed local maxWidthDiff = math.clamp( -maxChange, scoreboardDimensions.width - phases[scoreboardDimensions.phase].decToWidth, maxChange ) local maxHeightDiff = math.clamp( -maxChange, scoreboardDimensions.height - phases[scoreboardDimensions.phase].decToHeight, maxChange ) if scoreboardDimensions.width > phases[scoreboardDimensions.phase].decToWidth then scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width if scoreboardDimensions.width < phases[scoreboardDimensions.phase].decToWidth then scoreboardDimensions.width = phases[scoreboardDimensions.phase].decToWidth end elseif scoreboardDimensions.width < phases[scoreboardDimensions.phase].decToWidth then scoreboardDimensions.width = scoreboardDimensions.width - maxWidthDiff * phases[scoreboardDimensions.phase].width if scoreboardDimensions.width > phases[scoreboardDimensions.phase].decToWidth then scoreboardDimensions.width = phases[scoreboardDimensions.phase].decToWidth end end if scoreboardDimensions.height > phases[scoreboardDimensions.phase].decToHeight then scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height if scoreboardDimensions.height < phases[scoreboardDimensions.phase].decToHeight then scoreboardDimensions.height = phases[scoreboardDimensions.phase].decToHeight end elseif scoreboardDimensions.height < phases[scoreboardDimensions.phase].decToHeight then scoreboardDimensions.height = scoreboardDimensions.height - maxHeightDiff * phases[scoreboardDimensions.phase].height if scoreboardDimensions.height > phases[scoreboardDimensions.phase].decToHeight then scoreboardDimensions.height = phases[scoreboardDimensions.phase].decToHeight end end if scoreboardDimensions.width == phases[scoreboardDimensions.phase].decToWidth and scoreboardDimensions.height == phases[scoreboardDimensions.phase].decToHeight and scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then scoreboardDimensions.phase = scoreboardDimensions.phase - 1 if scoreboardDimensions.phase < 1 then scoreboardDimensions.phase = 1 end end end -- -- Draw scoreboard background -- if (not rtPass or onlyAnim) and scoreboardDimensions.width ~= 0 and scoreboardDimensions.height ~= 0 then dxDrawRectangle( (sX/2)-(scoreboardDimensions.width/2), (sY/2)-(scoreboardDimensions.height/2) - 25, scoreboardDimensions.width, scoreboardDimensions.height + 40 , cScoreboardBackground, drawOverGUI ) dxDrawRectangle( (sX/2)-(scoreboardDimensions.width/2), (sY/2)-(scoreboardDimensions.height/2) - 25, scoreboardDimensions.width, scoreboardDimensions.height + 5 , tocolor(0,0,0,160) ) end -- Check if anything else to do if not scoreboardDrawn or onlyAnim then return end -- -- Update the scoreboard content -- local currentTick = getTickCount() if (currentTick - scoreboardTicks.lastUpdate > scoreboardTicks.updateInterval and (scoreboardToggled or scoreboardForced)) or forceScoreboardUpdate then forceScoreboardUpdate = false scoreboardContent = {} local index = 1 local sortTableIndex = 1 local sortTable = {} local players = getElementsByType( "player" ) for key, player in ipairs( players ) do if not getPlayerTeam( player ) or not (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) or serverInfo.forcehideteams then sortTable[sortTableIndex] = {} for key, column in ipairs( scoreboardColumns ) do local content if column.name == "name" then local playerName = getPlayerName( player ) if serverInfo.allowcolorcodes then if string.find( playerName, "#%x%x%x%x%x%x" ) then local colorCodes = {} while( string.find( playerName, "#%x%x%x%x%x%x" ) ) do local startPos, endPos = string.find( playerName, "#%x%x%x%x%x%x" ) if startPos then colorCode = string.sub( playerName, startPos, endPos ) table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } ) playerName = string.gsub( playerName, "#%x%x%x%x%x%x", "", 1 ) end end content = { playerName, colorCodes } else content = playerName end else content = playerName end elseif column.name == "ping" then content = getPlayerPing( player ) else content = getElementData( player, column.name ) end content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content ) if column.textFunction then if content and column.name == "name" and type( content ) == "table" then content[1] = column.textFunction( content[1], player ) else content = column.textFunction( content, player ) end end sortTable[sortTableIndex][column.name] = content sortTable[sortTableIndex]["__SCOREBOARDELEMENT__"] = player end sortTableIndex = sortTableIndex + 1 end end if sortBy.what ~= "__NONE__" then table.sort( sortTable, scoreboardSortFunction ) end for key, value in ipairs( sortTable ) do scoreboardContent[index] = value index = index + 1 end if (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) and not serverInfo.forcehideteams then -- And then the teams local teamSortTableIndex = 1 local teamSortTable = {} sortTableIndex = 1 sortTable = {} local teams = getElementsByType( "team" ) for key, team in ipairs( teams ) do -- Add teams to sorting table first teamSortTable[teamSortTableIndex] = {} for key, column in ipairs( scoreboardColumns ) do local content if column.name == "name" then local teamName = getTeamName( team ) local teamMemberCount = #getPlayersInTeam( team ) teamName = iif( teamName, tostring( teamName ), "-" ) teamMemberCount = iif( teamMemberCount, tostring( teamMemberCount ), "0" ) teamName = teamName .. " - " .. teamMemberCount .. " Jogadores" .. iif( teamMemberCount == "1", "", "" ) .. "" if serverInfo.players then if string.find( teamName, "#%x%x%x%x%x%x" ) then local colorCodes = {} while( string.find( teamName, "#%x%x%x%x%x%x" ) ) do local startPos, endPos = string.find( teamName, "#%x%x%x%x%x%x" ) if startPos then colorCode = string.sub( teamName, startPos, endPos ) table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } ) teamName = string.gsub( teamName, "#%x%x%x%x%x%x", "", 1 ) end end content = { teamName, colorCodes } else content = teamName end else content = teamName end else content = getElementData( team, column.name ) end content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content ) if column.textFunction then if content and column.name == "name" and type( content ) == "table" then content[1] = column.textFunction( content[1], team ) else content = column.textFunction( content, team ) end end teamSortTable[teamSortTableIndex][column.name] = content teamSortTable[teamSortTableIndex]["__SCOREBOARDELEMENT__"] = team end teamSortTableIndex = teamSortTableIndex + 1 -- and then the players sortTableIndex = 1 sortTable[team] = {} local players = getPlayersInTeam( team ) for key, player in ipairs( players ) do sortTable[team][sortTableIndex] = {} for key, column in ipairs( scoreboardColumns ) do local content if column.name == "name" then local playerName = getPlayerName( player ) if serverInfo.allowcolorcodes then if string.find( playerName, "#%x%x%x%x%x%x" ) then local colorCodes = {} while( string.find( playerName, "#%x%x%x%x%x%x" ) ) do local startPos, endPos = string.find( playerName, "#%x%x%x%x%x%x" ) if startPos then colorCode = string.sub( playerName, startPos, endPos ) table.insert( colorCodes, { { getColorFromString( colorCode ) }, startPos } ) playerName = string.gsub( playerName, "#%x%x%x%x%x%x", "", 1 ) end end content = { playerName, colorCodes } else content = playerName end else content = playerName end elseif column.name == "ping" then content = getPlayerPing( player ) else content = getElementData( player, column.name ) end content = iif( content and column.name ~= "name" and type( content ) ~= "table", tostring( content ), content ) if column.textFunction then if content and column.name == "name" and type( content ) == "table" then content[1] = column.textFunction( content[1], player ) else content = column.textFunction( content, player ) end end sortTable[team][sortTableIndex][column.name] = content sortTable[team][sortTableIndex]["__SCOREBOARDELEMENT__"] = player end sortTableIndex = sortTableIndex + 1 end if sortBy.what ~= "__NONE__" then table.sort( sortTable[team], scoreboardSortFunction ) end end if sortBy.what ~= "__NONE__" then table.sort( teamSortTable, scoreboardSortFunction ) end for key, content in ipairs( teamSortTable ) do local team = content["__SCOREBOARDELEMENT__"] scoreboardContent[index] = content index = index + 1 for key, value in ipairs( sortTable[team] ) do scoreboardContent[index] = value index = index + 1 end end end scoreboardTicks.lastUpdate = currentTick end -- -- Draw scoreboard content -- if scoreboardDrawn then scoreboardDimensions.height = calculateHeight() scoreboardDimensions.width = calculateWidth() local topX, topY = (sX/1)-(calculateWidth()/1), (sY/1)-(calculateHeight()/1) local index = firstVisibleIndex local maxPerWindow = getMaxPerWindow() if firstVisibleIndex > #scoreboardContent-maxPerWindow+1 then firstVisibleIndex = 1 end if firstVisibleIndex > 1 then dxDrawImage( sX/2-8, topY-15, 17, 11, "arrow.png", 0, 0, 0, cWhite, drawOverGUI ) end if firstVisibleIndex+maxPerWindow <= #scoreboardContent and #scoreboardContent > maxPerWindow then dxDrawImage( sX/2-8, topY+scoreboardDimensions.height+4, 17, 11, "arrow.png", 180, 0, 0, cWhite, drawOverGUI ) end local topHeight = dxGetFontHeight( fontscale(serverInfoFont, s(1.25)), serverInfoFont )+dxGetFontHeight( fontscale(serverInfoFont, s(1)), serverInfoFont )+s(10) dxDrawRectangle(topX,topY + 20,topX+scoreboardDimensions.width,topHeight - 20,tocolor(30,144,255,100)) contornoRetangulo( (sX/2)-(scoreboardDimensions.width/2), (sY/2)-(scoreboardDimensions.height/2) - 25, scoreboardDimensions.width, scoreboardDimensions.height + 40, tocolor(0,0,0,120), 2) local y = topY+s(5) local ht = topY+s(5) local font = dxCreateFont("ITCKRIST.ttf", 20) local fontt = dxCreateFont("font.ttf", 15) local time = getRealTime() local hours = time.hour local minutes = time.minute local seconds = time.second if (hours >= 0 and hours < 10) then hours = "0"..time.hour end if (minutes >= 0 and minutes < 10) then minutes = "0"..time.minute end if (seconds >= 0 and seconds < 10) then seconds = "0"..time.second end local meses = {"Jan", "Fev", "Mar", "Abr", "Mai", "Jun", "Jul", "Ago", "Set", "Out", "Nov", "Dez"} local dias = {"Domingo", "Segunda Feira", "Terça Feira", "Quarta Feira", "Quinta Feira", "Sexta Feira", "Sabado"} local dia = ("%02d"):format(time.monthday) local ano = ("%02d"):format(time.year + 1900) local diaa = dias[time.weekday + 1] local mes = meses[time.month + 1] if serverInfo.server and showServerInfo then dxDrawText("Kamikaze #1E90FFRoleplay - #FFFFFFSeja bem-vindo!", topX+s(5), y - 30, topX+scoreboardDimensions.width-s(10), y, tocolor(255, 255, 255, 255), 0.6, font, "left", "top", false, false, false, true, false) dxDrawText(hours..":"..minutes, topX+s(5), ht - 30, topX+scoreboardDimensions.width-s(10), ht, tocolor(255, 255, 255, 255), 0.6, font, "right", "top", false, false, false, true, false) dxDrawText(mes..",#1E90FF"..dia.." ", topX+s(5), ht - 15, topX+scoreboardDimensions.width-s(10), ht, tocolor(255, 255, 255, 255), 0.5, fontt, "right", "top", false, false, false, true, false) --dxDrawText("BRASIL VIDA FIXA - Roleplay Server Brasil", topX+s(5), y - 20, topX+scoreboardDimensions.width-s(10), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(1.25)), serverInfoFont, "left", "top", false, false, drawOverGUI ) end if serverInfo.players and showServerInfo then local players = getElementsByType( "player" ) local text = "Cidadões ativos na cidade: #1E90FF" .. tostring( #players ) .. "#FFFFFF/#1E90FF" .. serverInfo.players local textWidth = dxGetTextWidth( text, fontscale(serverInfoFont, s(1.0)), serverInfoFont ) dxDrawText("\nhttps://discord.gg/SVVCTeK - "..text, topX+s(5), y - 24, topX+scoreboardDimensions.width-s(10), y, tocolor(255, 255, 255, 255), 0.5, fontt, "left", "top", false, false, false, true, false) --dxDrawText( text, topX+scoreboardDimensions.width-s(5)-textWidth, y, topX+scoreboardDimensions.width-s(5), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(1.0)), serverInfoFont, "left", "top", false, false, drawOverGUI ) end if (serverInfo.server or serverInfo.players) and showServerInfo then y = y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end if serverInfo.gamemode and showGamemodeInfo then --dxDrawText( "Gamemode: " .. serverInfo.gamemode, topX+s(5), y, topX+scoreboardDimensions.width-s(10), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) end if serverInfo.map and showGamemodeInfo then local text = "Map: " .. serverInfo.map local textWidth = dxGetTextWidth( text, fontscale(serverInfoFont, s(0.75)), serverInfoFont ) --dxDrawText( text, topX+scoreboardDimensions.width-s(5)-textWidth, y, topX+scoreboardDimensions.width-s(5), y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ), cServerInfo, fontscale(serverInfoFont, s(0.75)), serverInfoFont, "left", "top", false, false, drawOverGUI ) end if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then y = y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end y = y+s(5) local textLength = dxGetTextWidth( "Hold RMB to enable scrolling/sorting", fontscale(rmbFont, s(0.75)), rmbFont ) local textHeight = dxGetFontHeight( fontscale(rmbFont, s(0.75)), rmbFont ) --dxDrawText( "Hold RMB to enable scrolling/sorting", sX/2-(textLength/2), topY+scoreboardDimensions.height-textHeight-s(2), sX/2+(textLength/2), topY+scoreboardDimensions.height-s(2), cWhite, fontscale(serverInfoFont, s(0.75)), rmbFont, "left", "top", false, false, drawOverGUI ) local bottomX, bottomY = topX+scoreboardDimensions.width, topY+scoreboardDimensions.height textLength = dxGetTextWidth( "settings...", fontscale(sbFont, s(sbFontScale)), sbFont ) textHeight = dxGetFontHeight( fontscale(sbFont, s(sbFontScale)), sbFont ) --dxDrawText( "settings...", bottomX-s(sbOutOffset+1+sbInOffset)-textLength, bottomY-s(sbOutOffset+1+sbInOffset)-textHeight, bottomX-s(sbOutOffset+1+sbInOffset), bottomY-s(sbOutOffset+1+sbInOffset), cSettingsBox, fontscale(sbFont, s(sbFontScale)), sbFont, "left", "top", false, false, drawOverGUI ) --dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) --dxDrawLine( bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) --dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight, cSettingsBox, 1, drawOverGUI ) --dxDrawLine( bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength, bottomY-s(sbOutOffset+1), bottomX-s(sbOutOffset+1), bottomY-s(sbOutOffset+1), cSettingsBox, 1, drawOverGUI ) local x = s(10) for key, column in ipairs( scoreboardColumns ) do if x ~= s(10) then local height = s(5) if (serverInfo.server or serverInfo.players) and showServerInfo then height = height+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then height = height+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end height = height+s(3) --dxDrawLine( topX+x-s(5), y+s(1), topX+x-s(5), y+scoreboardDimensions.height-height-s(2)-textHeight-s(5), cBorder, s(1), drawOverGUI ) end if sortBy.what == column.name then local _, _, _, a = fromcolor( cHeader ) dxDrawText( column.friendlyName or "-", topX+x+s(1+9), y+s(1), topX+x+s(1+column.width), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), tocolor( 0, 0, 0, a ), fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) dxDrawText( column.friendlyName or "-", topX+x+s(9), y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), cHeader, fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) dxDrawRectangle( topX+x, iif( sortBy.dir == 1, y+s(8), y+s(6) ), s(5), s(1), cWhite, drawOverGUI ) dxDrawRectangle( topX+x+s(1), y+s(7), s(3), s(1), cWhite, drawOverGUI ) dxDrawRectangle( topX+x+s(2), iif( sortBy.dir == 1, y+s(6), y+s(8) ), s(1), s(1), cWhite, drawOverGUI ) else local _, _, _, a = fromcolor( cHeader ) dxDrawText( column.friendlyName or "-", topX+x+s(1), y+s(1), topX+x+s(1+column.width), y+s(1)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), tocolor( 0, 0, 0, a ), fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) dxDrawText( column.friendlyName or "-", topX+x, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ), cHeader, fontscale(columnFont, s(1)), columnFont, "left", "top", true, false, drawOverGUI ) end x = x + s(column.width + 10) end y = y+s(4)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ) while ( index < firstVisibleIndex+maxPerWindow and scoreboardContent[index] ) do local x = s(10) local element = scoreboardContent[index]["__SCOREBOARDELEMENT__"] local team, player if element and isElement( element ) and getElementType( element ) == "team" then -- dxDrawRectangle( topX, y, scoreboardDimensions.width, dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont )*1, tocolor(0,0,0,180), drawOverGUI ) for key, column in ipairs( scoreboardColumns ) do local r, g, b, a = fromcolor( cContent ) if not useColors then r, g, b = 255, 255, 255 end local theX = x local content = scoreboardContent[index][column.name] if content and column.name == "name" then if useColors then r, g, b = getTeamColor( element ) end theX = x - s(3) end if content then if serverInfo.allowcolorcodes and type( content ) == "table" and column.name == "name" then local playerName = content[1] local colorCodes = content[2] local xPos = topX+theX for k, v in ipairs( colorCodes ) do local firstCodePos = v[2] local secondCodePos = colorCodes[k+1] and colorCodes[k+1][2]-1 or #playerName if firstCodePos ~= 1 and k == 1 then local secondPos = firstCodePos-1 local firstPos = 1 local partOfName = string.sub( playerName, firstPos, secondPos ) local textLength = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width*2), y+s(11)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) dxDrawText( partOfName, xPos, y, topX+x+s(column.width*2), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) xPos = xPos + textLength end if useColors then r, g, b = v[1][1], v[1][2], v[1][3] end local partOfName = string.sub( playerName, firstCodePos, secondCodePos ) local textLength = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width*2), y+s(11)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) dxDrawText( partOfName, xPos, y, topX+x+s(column.width*2), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1)), teamHeaderFont, "left", "top", true, false, drawOverGUI ) xPos = xPos + textLength end elseif type( content ) == "table" and column.name ~= "name" then if content.type == "image" and content.src then local itemHeight = dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) content.height = content.height or itemHeight content.width = content.width or itemHeight local itemWidth = content.height/itemHeight * content.width content.color = content.color or tocolor(0, 0, 0, 150 ) content.rot = content.rot or 0 content.rotOffX = content.rotOffX or 0 content.rotOffY = content.rotOffY or 0 dxDrawImage ( topX+theX, y, itemWidth, itemHeight, content.src, content.rot, content.rotOffX, content.rotOffY, content.color, drawOverGUI ) end else dxDrawText( content, topX+theX+s(1), y+s(1), topX+x+s(1+column.width*2), y+s(1)+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont )*1.5, tocolor( 0, 0, 0, a or 255 ), fontscale(teamHeaderFont, s(1.1)), teamHeaderFont, "left", "center", true, false, drawOverGUI ) dxDrawText( content, topX+theX, y, topX+x+s(column.width*2), y+dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont )*1.5, tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(teamHeaderFont, s(1.1)), teamHeaderFont, "left", "center", true, false, drawOverGUI ) end end x = x + s(column.width + 10) end elseif element and isElement( element ) and getElementType( element ) == "player" then -- Highlight local player's name if element == getLocalPlayer() then dxDrawRectangle( topX+s(5), y+s(1), scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor(0,0,0,100), drawOverGUI ) -- predzadnje cSelection else dxDrawRectangle( topX+s(5), y+s(1), scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor(0,0,0,100), drawOverGUI ) end -- Highlight the the row on which the cursor lies on --[[if checkCursorOverRow( rtPass, topX+s(5), topX+scoreboardDimensions.width-s(5), y, y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ) ) then dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), cHighlight, drawOverGUI ) end -- Highlight selected row if selectedRows[element] then dxDrawRectangle( topX+s(5), y, scoreboardDimensions.width-s(10), dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), cHighlight, drawOverGUI ) end]] for key, column in ipairs( scoreboardColumns ) do local r, g, b, a = fromcolor( cContent ) if not useColors then r, g, b = 0, 0, 0 end local theX = x local content = scoreboardContent[index][column.name] if content and column.name == "name" then if useColors then r, g, b = getPlayerNametagColor( element ) end if getPlayerTeam( element ) and (showTeams or (serverInfo.forceshowteams and not serverInfo.forcehideteams)) and not serverInfo.forcehideteams then theX = x + s(12) end end if content then if serverInfo.allowcolorcodes and type( content ) == "table" and column.name == "name" then local playerName = content[1] local colorCodes = content[2] local xPos = topX+theX for k, v in ipairs( colorCodes ) do local firstCodePos = v[2] local secondCodePos = colorCodes[k+1] and colorCodes[k+1][2]-1 or #playerName if firstCodePos ~= 1 and k == 1 then local secondPos = firstCodePos-1 local firstPos = 1 local partOfName = string.sub( playerName, firstPos, secondPos ) local textLength = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) dxDrawText( partOfName, xPos, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) xPos = xPos + textLength end if useColors then r, g, b = v[1][1], v[1][2], v[1][3] end local partOfName = string.sub( playerName, firstCodePos, secondCodePos ) local textLength = dxGetTextWidth( partOfName, fontscale(contentFont, s(1)), contentFont ) dxDrawText( partOfName, xPos+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) dxDrawText( partOfName, xPos, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) xPos = xPos + textLength end elseif type( content ) == "table" and column.name ~= "name" then if content.type == "image" and content.src then local itemHeight = dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ) content.height = content.height or itemHeight content.width = content.width or itemHeight local itemWidth = itemHeight/content.height * content.width content.color = content.color or tocolor(0,0,0,180) content.rot = content.rot or 0 content.rotOffX = content.rotOffX or 0 content.rotOffY = content.rotOffY or 0 dxDrawImage ( topX+theX, y, itemWidth, itemHeight, content.src, content.rot, content.rotOffX, content.rotOffY, content.color, drawOverGUI ) end else if column.name == "country" and content ~= "?" then local countryName = getCountryNameFromCode(content) or content local countryString = ":admin/client/images/flags/"..content:lower()..".png" if fileExists(countryString) then local imageX = (dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont )-s(4))*1.4 dxDrawImage(topX+theX+s(1), y+s(3), imageX,dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont )-s(5),countryString,0,0,0,tocolor(255,255,255,a or 255)) dxDrawText( countryName, topX+theX+s(6)+imageX, y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) dxDrawText( countryName, topX+theX+s(5)+imageX, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) else dxDrawText( countryName, topX+theX+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) dxDrawText( countryName, topX+theX, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) end else dxDrawText( content, topX+theX+s(1), y+s(1), topX+x+s(1+column.width), y+s(11)+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( 0, 0, 0, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) dxDrawText( content, topX+theX, y, topX+x+s(column.width), y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ), tocolor( r or 255, g or 255, b or 255, a or 255 ), fontscale(contentFont, s(1)), contentFont, "left", "top", true, false, drawOverGUI ) end end end x = x + s(column.width + 10) end end local font = iif( element and isElement( element ) and getElementType( element ) == "team", teamHeaderFont, contentFont ) if getElementType( element ) ~= "team" then y = y + dxGetFontHeight( fontscale(font, scoreboardScale), font )+s(2) else y = y + dxGetFontHeight( fontscale(font, scoreboardScale), font )*1.5 end index = index + 1 end index = 1 dxDrawRectangle(topX,y,scoreboardDimensions.width,s(20),tocolor(0,0,0,0)) --dxDrawText("VIDA FIXA",topX+s(10),y,topX+scoreboardDimensions.width-(10),y+s(20),tocolor ( math.random(255), math.random(255), math.random(255)),fontscale(contentFont, s(0.8)), contentFont,"right","center",true) end end end -- FUNCTIONS -- addColumn function scoreboardAddColumn( name, width, friendlyName, priority, textFunction, fromResource ) if type( name ) == "string" then width = width or 70 friendlyName = friendlyName or name priority = tonumber( priority ) or getNextFreePrioritySlot( scoreboardGetColumnPriority( "name" ) ) fixPrioritySlot( priority ) textFunction = textFunction or nil fromResource = sourceResource or fromResource or nil if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then for key, value in ipairs( scoreboardColumns ) do if name == value.name then return false end end table.insert( scoreboardColumns, { ["name"] = name, ["width"] = width, ["friendlyName"] = friendlyName, ["priority"] = priority, ["textFunction"] = textFunction } ) table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end ) if fromResource then if not resourceColumns[fromResource] then resourceColumns[fromResource] = {} end table.insert ( resourceColumns[fromResource], name ) end return true end end return false end addEvent( "doScoreboardAddColumn", true ) addEventHandler( "doScoreboardAddColumn", getResourceRootElement(), function ( name, width, friendlyName, priority, fromResource ) scoreboardAddColumn( name, width, friendlyName, priority, nil, fromResource ) end ) -- removeColumn function scoreboardRemoveColumn( name ) if type( name ) == "string" then for key, value in ipairs( scoreboardColumns ) do if name == value.name then table.remove( scoreboardColumns, key ) for resource, content in pairs( resourceColumns ) do table.removevalue( content, name ) end return true end end end return false end addEvent( "doScoreboardRemoveColumn", true ) addEventHandler( "doScoreboardRemoveColumn", getResourceRootElement(), function ( name ) scoreboardRemoveColumn( name ) end ) -- clearColumns function scoreboardClearColumns() while ( scoreboardColumns[1] ) do table.remove( scoreboardColumns, 1 ) resourceColumns = {} end return true end addEvent( "doScoreboardClearColumns", true ) addEventHandler( "doScoreboardClearColumns", getResourceRootElement(), function () scoreboardClearColumns() end ) -- resetColumns function scoreboardResetColumns( fromServer ) while ( scoreboardColumns[1] ) do table.remove( scoreboardColumns, 1 ) resourceColumns = {} end if not fromServer then scoreboardAddColumn( "emprego", 40, "Emprego" ) scoreboardAddColumn( "name", 200, "Name" ) scoreboardAddColumn( "ping", 40, "Ping" ) end return true end addEvent( "doScoreboardResetColumns", true ) addEventHandler( "doScoreboardResetColumns", getResourceRootElement(), function ( fromServer ) scoreboardResetColumns( iif( fromServer == nil, true, fromServer ) ) end ) -- setForced function scoreboardSetForced( forced ) scoreboardForced = forced end addEvent( "doScoreboardSetForced", true ) addEventHandler( "doScoreboardSetForced", getResourceRootElement(), function ( forced ) scoreboardSetForced( forced ) end ) --Compability setScoreboardForced = scoreboardSetForced --setSortBy function scoreboardSetSortBy( name, desc ) if name then if type( name ) == "string" then local exists = false for key, value in ipairs( scoreboardColumns ) do if name == value.name then exists = true end end if exists then desc = iif( type( desc ) == "boolean" and not desc, 1, -1 ) sortBy.what = name sortBy.dir = desc end end return false else sortBy.what = "__NONE__" sortBy.dir = -1 return true end end addEvent( "doScoreboardSetSortBy", true ) addEventHandler( "doScoreboardSetSortBy", getResourceRootElement(), function ( name, desc ) scoreboardSetSortBy( name, desc ) end ) --getColumnPriority function scoreboardGetColumnPriority( name ) if type( name ) == "string" then for key, value in ipairs( scoreboardColumns ) do if name == value.name then return value.priority end end end return false end --setColumnPriority function scoreboardSetColumnPriority( name, priority ) if type( name ) == "string" and type( priority ) == "number" then if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then local columnIndex = false for key, value in ipairs( scoreboardColumns ) do if name == value.name then columnIndex = key end end if columnIndex then scoreboardColumns[columnIndex].priority = -1 -- To empty out the current priority fixPrioritySlot( priority ) scoreboardColumns[columnIndex].priority = priority table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end ) return true end end end return false end addEvent( "doScoreboardSetColumnPriority", true ) addEventHandler( "doScoreboardSetColumnPriority", getResourceRootElement(), function ( name, priority ) scoreboardSetColumnPriority( name, priority ) end ) --getColumnCount function scoreboardGetColumnCount() return #scoreboardColumns end --setColumnTextFunction function scoreboardSetColumnTextFunction( name, func ) if type( name ) == "string" then for key, value in ipairs( scoreboardColumns ) do if name == value.name then scoreboardColumns[key].textFunction = func return true end end end return false end function scoreboardGetTopCornerPosition() if scoreboardDrawn then local sX, sY = guiGetScreenSize() local topX, topY = (sX/2)-(calculateWidth()/2), (sY/2)-(calculateHeight()/2) topY = topY - 15 -- Extra 15 pixels for the scroll up button return math.floor(topX), math.floor(topY+1) end return false end function scoreboardGetSize() if scoreboardDrawn then local width, height = calculateWidth(), calculateHeight() return width, height end return false end function scoreboardGetSelectedRows() local rows = {} for k, v in pairs( selectedRows ) do table.insert( rows, k ) end return rows end -- Other function calculateWidth() local width = 0 for key, value in ipairs( scoreboardColumns ) do width = width + s(value.width + 10) end return width + s(10) end function calculateHeight() local sX, sY = guiGetScreenSize() local maxPerWindow = getMaxPerWindow() local index = firstVisibleIndex local height = s(5) if (serverInfo.server or serverInfo.players) and showServerInfo then height = height+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then height = height+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end height = height+s(3) height = height+s(5)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ) height = height+s(5)+dxGetFontHeight( fontscale(rmbFont, s(0.75)), rmbFont ) height = height+s(2) while ( index < firstVisibleIndex+maxPerWindow and scoreboardContent[index] ) do local element = scoreboardContent[index]["__SCOREBOARDELEMENT__"] if element and isElement( element ) and getElementType( element ) == "team" then height = height + dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont )*1.5 else height = height + dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont )+s(2) end index = index + 1 end return height end function showTheCursor( _, state ) if state == "down" then showCursor( true ) else if not (windowSettings and isElement( windowSettings )) then showCursor( false ) end end end function scrollScoreboard( _, _, upOrDown ) if isCursorShowing() then local index = firstVisibleIndex local maxPerWindow = getMaxPerWindow() local highestIndex = #scoreboardContent - maxPerWindow + 1 if index >= 1 and index <= highestIndex then local newIndex = math.max(1,math.min(index + upOrDown * serverInfo.scrollStep,highestIndex)) if index ~= newIndex then firstVisibleIndex = newIndex bForceUpdate = true end end end end function math.clamp( low, value, high ) return math.max( low, math.min( value, high ) ) end function fromcolor( color ) -- Propably not the most efficient way, but only way it works local colorCode = string.format( "%x", color ) local a = string.sub( colorCode, 1, 2 ) or "FF" local r = string.sub( colorCode, 3, 4 ) or "FF" local g = string.sub( colorCode, 5, 6 ) or "FF" local b = string.sub( colorCode, 7, 8 ) or "FF" a = tonumber( "0x" .. a ) r = tonumber( "0x" .. r ) g = tonumber( "0x" .. g ) b = tonumber( "0x" .. b ) return r, g, b, a end function scale( value ) return value*scoreboardScale end s = scale function fontscale( font, value ) if fontScale[font] then return value*fontScale[font] else return value*fontScaleRace*0.1 end end function scoreboardSortFunction( a, b ) local firstContent, secondContent local sortByA if a[sortBy.what] and type( a[sortBy.what] ) == "table" and sortBy.what == "name" then sortByA = a[sortBy.what][1] else sortByA = a[sortBy.what] end local sortByB if b[sortBy.what] and type( b[sortBy.what] ) == "table" and sortBy.what == "name" then sortByB = b[sortBy.what][1] else sortByB = b[sortBy.what] end if tonumber( sortByA ) then firstContent = tonumber( sortByA ) else if sortByA then firstContent = string.lower( tostring( sortByA ) ) else firstContent = "" end end if tonumber( sortByB ) then secondContent = tonumber( sortByB ) else if sortByB then secondContent = string.lower( tostring( sortByB ) ) else secondContent = "" end end if type( sortBy.dir ) == "number" then if type( firstContent ) == type( secondContent ) then else firstContent = string.lower( tostring( firstContent ) ) secondContent = string.lower( tostring( secondContent ) ) end return iif( sortBy.dir == 1, firstContent > secondContent, firstContent < secondContent ) end return false end function getMaxPerWindow() local sX, sY = guiGetScreenSize() local availableHeight = sY-(seperationSpace*2)-s(5) if (serverInfo.server or serverInfo.players) and showServerInfo then availableHeight = availableHeight-dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then availableHeight = availableHeight-dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end availableHeight = availableHeight-s(3) availableHeight = availableHeight-s(5)-dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ) availableHeight = availableHeight-s(5)-dxGetFontHeight( fontscale(rmbFont, s(0.75)), rmbFont ) availableHeight = availableHeight-s(2) local index = firstVisibleIndex local count = 0 local height = 0 while ( scoreboardContent[index] ) do local element = scoreboardContent[index]["__SCOREBOARDELEMENT__"] if element and isElement( element ) and getElementType( element ) == "team" then height = height + dxGetFontHeight( fontscale(teamHeaderFont, scoreboardScale), teamHeaderFont ) else height = height + dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ) end if height >= availableHeight then return count end index = index + 1 count = count + 1 end return count end function scoreboardClickHandler( button, state, cX, cY ) if scoreboardDrawn and button == "left" and state == "down" then local sX, sY = guiGetScreenSize() local topX, topY = (sX/2)-(calculateWidth()/2), (sY/2)-(calculateHeight()/2) local xMin, xMax, yMin, yMax = topX, topX+calculateWidth(), topY, topY+calculateHeight() local maxPerWindow = getMaxPerWindow() local clickedColumn = false --This var is used if we clicked *anywhere* in the column if cX >= xMin and cX <= xMax and cY >= yMin and cY <= yMax then local clickedOnColumnHeader = false --This var is used if we clicked on the column header itself local x = s(10) local y = s(5)+s(3) if (serverInfo.server or serverInfo.players) and showServerInfo then y = y + dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then y = y + dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end for key, column in ipairs( scoreboardColumns ) do if cX >= topX+x and cX <= topX+x+s(column.width) then clickedColumn = column.name if cY >= topY+y and cY <= topY+y+dxGetFontHeight( fontscale(contentFont, scoreboardScale), contentFont ) then clickedOnColumnHeader = column.name end end x = x + s(column.width + 10) end if clickedOnColumnHeader then if sortBy.what == clickedOnColumnHeader then -- last click was this column sortBy.dir = sortBy.dir + 2 if sortBy.dir > 1 then sortBy.what = "__NONE__" sortBy.dir = -1 end else sortBy.what = clickedOnColumnHeader sortBy.dir = -1 end forceScoreboardUpdate = true end -- Settings button local bottomX, bottomY = topX+calculateWidth(), topY+calculateHeight() textLength = dxGetTextWidth( "settings...", fontscale(sbFont, s(sbFontScale)), sbFont ) textHeight = dxGetFontHeight( fontscale(sbFont, s(sbFontScale)), sbFont ) if cX >= bottomX-s(sbOutOffset+2*sbInOffset+2)-textLength and cX <= bottomX-s(sbOutOffset+1) and cY >= bottomY-s(sbOutOffset+2*sbInOffset+1)-textHeight and cY <= bottomY-s(sbOutOffset+1) then if not (windowSettings and isElement( windowSettings ) and guiGetVisible( windowSettings )) then --createScoreboardSettingsWindow( sX-323, sY-350 ) elseif isElement( windowSettings ) then --destroyScoreboardSettingsWindow() end end end -- Scroll buttons if firstVisibleIndex > 1 then if cX >= sX/2-8 and cX <= sX/2-8+17 and cY >= topY-15 and cY <= topY-15+11 then scrollScoreboard( nil, nil, -1 ) end end if firstVisibleIndex+maxPerWindow <= #scoreboardContent and #scoreboardContent > maxPerWindow then if cX >= sX/2-8 and cX <= sX/2-8+17 and cY >= topY+calculateHeight()+4 and cY <= topY+calculateHeight()+4+11 then scrollScoreboard( nil, nil, 1 ) end end -- Player/team click local y = topY+s(5) if (serverInfo.server or serverInfo.players) and showServerInfo then y = y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end if (serverInfo.gamemode or serverInfo.map) and showGamemodeInfo then y = y+dxGetFontHeight( fontscale(serverInfoFont, scoreboardScale), serverInfoFont ) end y = y+s(3) y = y+s(5)+dxGetFontHeight( fontscale(columnFont, scoreboardScale), columnFont ) if cY >= y and cX then local index = firstVisibleIndex local maxPerWindow = getMaxPerWindow() local topX, topY = (sX/2)-(calculateWidth()/2), (sY/2)-(calculateHeight()/2) local width = calculateWidth() while ( index < firstVisibleIndex+maxPerWindow and scoreboardContent[index] ) do local element = scoreboardContent[index]["__SCOREBOARDELEMENT__"] local font = iif( element and isElement( element ) and getElementType( element ) == "team", teamHeaderFont, contentFont ) if cX >= topX+s(5) and cX <= topX+width-s(5) and cY >= y and cY <= y+dxGetFontHeight( fontscale(font, scoreboardScale), font ) then local selected = (not selectedRows[element]) == true local triggered = triggerEvent( "onClientPlayerScoreboardClick", element, selected, cX, cY, clickedColumn ) if triggered then selectedRows[element] = not selectedRows[element] end end y = y + dxGetFontHeight( fontscale(font, scoreboardScale), font ) index = index + 1 end end end end function removeResourceScoreboardColumns( resource ) if resourceColumns[resource] then while resourceColumns[resource][1] do local success = scoreboardRemoveColumn( resourceColumns[resource][1] ) if not success then break end end resourceColumns[resource] = nil end end addEventHandler( "onClientResourceStop", getRootElement(), removeResourceScoreboardColumns ) function scoreboardForceUpdate () bForceUpdate = true return true end local fpsTick = getTickCount() local fps = 1 function getFPSForPlayer() fps = fps + 1 if getTickCount()-fpsTick>=1000 then fpsTick = getTickCount() setElementData(localPlayer,"fps",fps) fps = 1 end end addEventHandler("onClientRender",getRootElement(),getFPSForPlayer) function contornoRetangulo(absX, absY, sizeX, sizeY, color, ancho) dxDrawRectangle(absX, absY, sizeX, ancho, color) dxDrawRectangle(absX, absY + ancho, ancho, sizeY - ancho, color) dxDrawRectangle(absX + ancho, absY + sizeY - ancho, sizeX - ancho, ancho, color) dxDrawRectangle(absX + sizeX - ancho, absY + ancho, ancho, sizeY - ancho*2, color) end dxscoreboard_exports (Esse contém algo relacionado a Widht ao código) MAX_PRIRORITY_SLOT = 500 scoreboardColumns = { { ["name"] = "ID", ["width"] = 20, ["friendlyName"] = "ID", ["priority"] = 1 }, { ["name"] = "name", ["width"] = 200, ["friendlyName"] = "Nick", ["priority"] = 2 }, { ["name"] = "fps", ["width"] = 50, ["friendlyName"] = "FPS", ["priority"] = 3 }, { ["name"] = "ping", ["width"] = 30, ["friendlyName"] = "Ping", ["priority"] = 9 }, } resourceColumns = {} function toboolean( bool ) bool = tostring( bool ) if bool == "true" then return true elseif bool == "false" then return false else return nil end end forceShowTeams = toboolean( get( "forceShowTeams" ) ) or false forceHideTeams = toboolean( get( "forceHideTeams" ) ) or false allowColorcodedNames = toboolean( get( "allowColorcodedNames" ) ) or false scrollStep = tonumber( get( "scrollStep" ) ) or 1 local function iif( cond, arg1, arg2 ) if cond then return arg1 end return arg2 end function scoreboardAddColumn( name, forElement, width, friendlyName, priority ) if type( name ) == "string" then width = tonumber( width ) or 70 friendlyName = friendlyName or name priority = tonumber( priority ) or getNextFreePrioritySlot( scoreboardGetColumnPriority( "name" ) ) fixPrioritySlot( priority ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then for key, value in ipairs( scoreboardColumns ) do if name == value.name then return false end end table.insert( scoreboardColumns, { ["name"] = name, ["width"] = width, ["friendlyName"] = friendlyName, ["priority"] = priority } ) table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end ) if sourceResource then if not resourceColumns[sourceResource] then resourceColumns[sourceResource] = {} end table.insert ( resourceColumns[sourceResource], name ) end return triggerClientEvent( getRootElement(), "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource ) end else return triggerClientEvent( forElement, "doScoreboardAddColumn", getRootElement(), name, width, friendlyName, priority, sourceResource ) end end return false end function scoreboardRemoveColumn( name, forElement ) if type( name ) == "string" then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then for key, value in ipairs( scoreboardColumns ) do if name == value.name then table.remove( scoreboardColumns, key ) for resource, content in pairs( resourceColumns ) do table.removevalue( content, name ) end return triggerClientEvent( getRootElement(), "doScoreboardRemoveColumn", getRootElement(), name ) end end else return triggerClientEvent( forElement, "doScoreboardRemoveColumn", getRootElement(), name ) end end return false end function scoreboardClearColumns( forElement ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then while ( scoreboardColumns[1] ) do table.remove( scoreboardColumns, 1 ) resourceColumns = {} end return triggerClientEvent( getRootElement(), "doScoreboardClearColumns", getRootElement() ) else return triggerClientEvent( forElement, "doScoreboardClearColumns", getRootElement() ) end end function scoreboardResetColumns( forElement ) forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then while ( scoreboardColumns[1] ) do table.remove( scoreboardColumns, 1 ) resourceColumns = {} end local result = triggerClientEvent( getRootElement(), "doScoreboardResetColumns", getRootElement() ) if result then scoreboardAddColumn( "name", 200, "Name" ) scoreboardAddColumn( "ping", 40, "Ping" ) end return result else return triggerClientEvent( forElement, "doScoreboardResetColumns", getRootElement(), false ) end end function scoreboardSetForced( forced, forElement ) if type( forced ) == "boolean" then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) return triggerClientEvent( forElement, "doScoreboardSetForced", getRootElement(), forced ) else return false end end function scoreboardSetSortBy( name, desc, forElement ) if type( name ) == "string" or name == nil then if name == nil then forElement = iif( type( desc ) == "userdata" and isElement( desc ), desc, getRootElement() ) else forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) end desc = iif( type( desc ) == "boolean", desc, true ) return triggerClientEvent( forElement, "doScoreboardSetSortBy", getRootElement(), name, desc ) else return false end end function scoreboardGetColumnPriority( name ) if type( name ) == "string" then for key, value in ipairs( scoreboardColumns ) do if name == value.name then return value.priority end end end return false end function scoreboardSetColumnPriority( name, priority, forElement ) if type( name ) == "string" and type( priority ) == "number" then if not (priority > MAX_PRIRORITY_SLOT or priority < 1) then forElement = iif( type( forElement ) == "userdata" and isElement( forElement ), forElement, getRootElement() ) if forElement == getRootElement() then local columnIndex = false for key, value in ipairs( scoreboardColumns ) do if name == value.name then columnIndex = key end end if columnIndex then scoreboardColumns[columnIndex].priority = -1 -- To empty out the current priority fixPrioritySlot( priority ) scoreboardColumns[columnIndex].priority = priority table.sort( scoreboardColumns, function ( a, b ) return a.priority < b.priority end ) return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority ) end else return triggerClientEvent( forElement, "doScoreboardSetColumnPriority", getRootElement(), name, priority ) end end end return false end function scoreboardForceTeamsVisible( enabled ) if type( enabled ) == "boolean" then forceShowTeams = enabled return true end return false end function scoreboardForceTeamsHidden( enabled ) if type( enabled ) == "boolean" then forceHideTeams = enabled return true end return false end function scoreboardGetColumnCount() return #scoreboardColumns end function onClientDXScoreboardResourceStart() for key, column in ipairs( scoreboardColumns ) do triggerClientEvent( client, "doScoreboardAddColumn", getRootElement(), column.name, column.width, column.friendlyName, column.priority ) end end addEvent( "onClientDXScoreboardResourceStart", true ) addEventHandler( "onClientDXScoreboardResourceStart", getResourceRootElement( getThisResource() ), onClientDXScoreboardResourceStart ) function requestServerInfoHandler() local mapmanager = getResourceFromName( "mapmanager" ) local output = {} output.forceshowteams = forceShowTeams output.forcehideteams = forceHideTeams output.allowcolorcodes = allowColorcodedNames output.scrollStep = scrollStep output.server = getServerName() output.players = getMaxPlayers() output.gamemode = false output.map = false if mapmanager and getResourceState( mapmanager ) == "running" then local gamemode = exports.mapmanager:getRunningGamemode() if gamemode then output.gamemode = getResourceInfo( gamemode, "name" ) or getResourceName( gamemode ) end local map = exports.mapmanager:getRunningGamemodeMap() if map then output.map = getResourceInfo( map, "name" ) or getResourceName( map ) end end triggerClientEvent( source, "sendServerInfo", getRootElement(), output ) end addEvent( "requestServerInfo", true ) addEventHandler( "requestServerInfo", getRootElement(), requestServerInfoHandler ) function removeResourceScoreboardColumns( resource ) if resourceColumns[resource] then while resourceColumns[resource][1] do local success = scoreboardRemoveColumn( resourceColumns[resource][1], getRootElement() ) if not success then break end end resourceColumns[resource] = nil end end addEventHandler( "onResourceStop", getRootElement(), removeResourceScoreboardColumns ) -- Compability addScoreboardColumn = function( name, forElement, position, size ) if type( size ) == "number" and size >= 0 and size <= 1.0 then size = size*700 end return scoreboardAddColumn( name, forElement, size, name, position ) end removeScoreboardColumn = scoreboardRemoveColumn resetScoreboardColumns = scoreboardResetColumns setPlayerScoreboardForced = function( forElement, forced ) return scoreboardSetForced( forced, forElement ) end --[[function onPlayerJoinToServer() if source then findIDForPlayer(source) local country = call(getResourceFromName("admin"),"getPlayerCountry",source) if country then setElementData(source,"country",country) else setElementData(source,"country","?") end end end addEventHandler("onPlayerJoin",getRootElement(),onPlayerJoinToServer)]]-- function findIDForPlayer(thePlayer) if thePlayer and not getElementData(thePlayer,"ID") then local i = 0 local players = getElementsByType("player") repeat local foundID = false i = i + 1 for _,player in pairs(players) do if player ~= thePlayer then local playerID = tonumber(getElementData(player,"ID")) if playerID == i then foundID = true break end end end until not foundID setElementData(thePlayer,"ID",i) end end --[[function onServerIDStart() for i,thePlayer in pairs(getElementsByType("player")) do findIDForPlayer(thePlayer) local country = call(getResourceFromName("admin"),"getPlayerCountry",source) if country then setElementData(source,"country",country) else setElementData(source,"country","?") end end end addEventHandler("onResourceStart",resourceRoot,onServerIDStart) ]]---
  3. Eu fiz um script no qual adiciona a tabela emprego/profissão ao scoreboard, porém possui alguns empregos com nome até que grande para se caber no score, eu precisava de ajuda para aumentar um pouco esse tamanho, algm da uma forcinha aí Exemplo do nome do emprego não sendo completo, cortando-o por causa do espaço no scoreboard: Script que desenvolvi para que adicionasse a tabela ao scoreboard: function VerificarEmprego(player) if player then acc = getPlayerAccount ( player ) if isGuestAccount ( acc ) then return end EmpregoAtual = getElementData ( player, "Emprego" ) or false if EmpregoAtual == "Presidente" then setElementData ( player, "Profissão", "Presidente") elseif EmpregoAtual == "Vereador" then setElementData ( player, "Profissão", "Vereador") elseif EmpregoAtual == "Vice-Presidente" then setElementData ( player, "Profissão", "Vice-Presidente") elseif EmpregoAtual == "Ajudante" then setElementData ( player, "Profissão", "Ajudante") elseif EmpregoAtual == "Ajudante de Pedreiro" then setElementData ( player, "Profissão", "Ajudante de Pedreiro") elseif EmpregoAtual == "Policial" then setElementData ( player, "Profissão", "Policial") elseif EmpregoAtual == "Pizzaboy" then setElementData ( player, "Profissão", "Pizzaboy") elseif EmpregoAtual == "Lenhador" then setElementData ( player, "Profissão", "Lenhador") elseif EmpregoAtual == "Carregador" then setElementData ( player, "Profissão", "Carregador" ) elseif EmpregoAtual == "Lixeiro" then setElementData ( player, "Profissão", "Lixeiro") elseif EmpregoAtual == "Limpador de Entulhos" then setElementData ( player, "Profissão", "Limpador de Entulhos") elseif EmpregoAtual == "Sedex" then setElementData ( player, "Profissão", "Sedex") elseif EmpregoAtual == "Mecanico" then setElementData ( player, "Profissão", "Mecanico") elseif EmpregoAtual == "Entregador de Gas" then setElementData ( player, "Profissão", "Entregador de Gás") elseif EmpregoAtual == "Açougueiro" then setElementData ( player, "Profissão", "Açougueiro") elseif EmpregoAtual == "Pescaria" then setElementData ( player, "Profissão", "Pescador") elseif EmpregoAtual == "Mineirador" then setElementData ( player, "Profissão", "Mineirador") elseif EmpregoAtual == "Desempregado" then setElementData ( player, "Profissão", "Desempregado") end end end addEventHandler( "onResourceStart",resourceRoot, function( ) exports [ "kmkscoreboard" ]:addScoreboardColumn ( "Profissão") end ) setTimer( function() for i, pl in pairs(getElementsByType("player")) do if pl ~= (false or nil) then VerificarEmprego(pl) end end end, 3000,0) -------------------------------------------------------------------------------- function SalvarEmpregoAtual(conta) if conta then local source = getAccountPlayer(conta) local emp = getElementData ( source, "Emprego" ) or false setAccountData ( conta, "Emprego", emp ) end end function CarregarEmpregoAtual(conta) if not (isGuestAccount (conta)) then if (conta) then local source = getAccountPlayer(conta) local emp = getAccountData ( conta, "Emprego" ) or false setElementData ( source, "Emprego", emp ) end end end addEventHandler("onPlayerLogin", root, function( _, acc ) setTimer(CarregarEmpregoAtual,50,1,acc) end ) function startScript ( res ) if res == getThisResource() then for i, player in ipairs(getElementsByType("player")) do local acc = getPlayerAccount(player) if not isGuestAccount(acc) then CarregarEmpregoAtual(acc) end end end end addEventHandler ( "onResourceStart", getRootElement(), startScript ) function stopScript( res ) if res == getThisResource() then for i, player in ipairs(getElementsByType("player")) do local acc = getPlayerAccount(player) if not isGuestAccount(acc) then SalvarEmpregoAtual(acc) end end end end addEventHandler ( "onResourceStop", getRootElement(), stopScript ) function sair ( quitType ) local acc = getPlayerAccount(source) if not (isGuestAccount (acc)) then if acc then SalvarEmpregoAtual(acc) end end end addEventHandler ( "onPlayerQuit", getRootElement(), sair )
  4. Cara, vc me ajudou muito... se me permite, uma última pergunta: Caso eu queira adicionar uma interface (no caso um background para esse painel de fome/sede/sono), onde eu devo mudar no código para que ele faça a animação junto com os rectangles e os drawimage?? O código que eu queria colocar para que faça a animação junto é esse: dxDrawImage(x*48, y*565, x*210, y*134, "files/images/interface.png", 0, 0, 0, tocolor(255, 255, 255, 255), false)
  5. Agora ele está mostrando apenas o ícone da fome (que no caso acredito que está mostrando esse pq seja o primeiro) E a Rectangle que indica a fome/sede do jogador: local fome = getElementData(getLocalPlayer(), "AirNewSCR_Fome") local sede = getElementData(getLocalPlayer(), "AirNewSCR_Sede") não está contando, apenas é um quadrado sem nada, sem função. Não é problema com as imagens, eu já verifiquei... porém antes desse código as imagens estavam funcionando normalmente, nada na pasta das imagens foi mexido...
  6. Oi, Eder, boa tarde. O painel está se multiplicando assim que se entra/sai do carro, e está com alguns problemas... Aqui está o código do script, (eu tirei a parte que tem esse painel para colocar a desse código que vc mandou) local screenW,screenH = guiGetScreenSize() local resW, resH = 1366,768 local x, y = (screenW/resW), (screenH/resH) local components = { "area_name", "radio", "vehicle_name" } local font1 = dxCreateFont('files/fonts/font.ttf', 37, false); local font2 = dxCreateFont('files/fonts/font.ttf', 25, false); local font3 = dxCreateFont('files/fonts/font3.ttf', 20, false); local font4 = dxCreateFont('files/fonts/font3.ttf', 25, false); local font5 = dxCreateFont('files/fonts/font.ttf', 25, false); local fontprice = dxCreateFont('files/fonts/pricedownbl.ttf', 25, false); local font10 = dxCreateFont('files/fonts/font10.ttf', 25, false); local font11 = dxCreateFont('files/fonts/font11.ttf', 25, false); function kyubo() if (not isPlayerMapVisible()) then local money = ("%008d"):format(getPlayerMoney(getLocalPlayer())) local job = getElementData(getLocalPlayer(), "Emprego") or "Desempregado" local cargo = getElementData(localPlayer, "DNL:Cargo") or "Civil" local level = getElementData(getLocalPlayer(), "Level") or 0 local banco = ("%008d"):format(getElementData(getLocalPlayer(), "Bank:Royal")) or 0 local xp = getElementData(getLocalPlayer(), "LSys:EXP") or 0 local fome = getElementData(getLocalPlayer(), "AirNewSCR_Fome") local sede = getElementData(getLocalPlayer(), "AirNewSCR_Sede") local showammo1 = getPedAmmoInClip (localPlayer,getPedWeaponSlot(localPlayer)) local showammo2 = getPedTotalAmmo(localPlayer)-getPedAmmoInClip(localPlayer) local showammo3 = getPedTotalAmmo(getLocalPlayer()) local clip = getPedAmmoInClip (getLocalPlayer()) local weapon = getPedWeapon ( getLocalPlayer() ) local arma = getWeaponNameFromID ( weapon ) local color1 = tocolor(0,255,0,90) local Sono = getElementData(getLocalPlayer(), "sono") local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) local time = getRealTime() local hours = time.hour local minutes = time.minute local seconds = time.second local years = time.year + 1900 local month = time.month + 1 local day = time.monthday if (hours >= 0 and hours < 10) then hours = "0"..time.hour end if (minutes >= 0 and minutes < 10) then minutes = "0"..time.minute end if (seconds >= 0 and seconds < 10) then seconds = "0"..time.second end dxDrawText(job, x*1495, y*110, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.60, fontprice, "center", "center", false, false, false, false, false) dxDrawText('Level: '..level, x*1490, y*185, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.60, fontprice,"center", "center", false, false, false, false, false) dxDrawText('EXP: '..xp, x*1490, y*220, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.60, fontprice,"center", "center", false, false, false, false, false) dxDrawText(''..money, x*1505, y*275, x*1026, y*90, tocolor(144,238,144), x*0.70, fontprice, "center", "center", false, false, false, false, false) dxDrawText(''..banco, x*1505, y*325, x*1026, y*90, tocolor(30, 144, 255, 255), x*0.70, fontprice, "center", "center", false, false, false, false, false) dxDrawText(""..hours..":"..minutes..":"..seconds.."", x*1498, y*380, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.45, font10, "center", "center", false, false, false, false, false) dxDrawText(""..day.."/"..month.."/"..years.."", x*1498, y*420, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.40, font10, "center", "center", false, false, false, false, false) dxDrawText('KMKRP', x*1445, y*-10, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.70, font3, "center", "center", false, false, false, false, false) dxDrawText('#', x*1360, y*-10, x*1026, y*90, tocolor(255, 255, 255, 255), x*0.70, font10, "center", "center", false, false, false, false, false) dxDrawImage(x*1153, y*597, x*210, y*134, "files/images/interface.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1275, y*-4, x*80, y*85, "files/images/logo.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1185, y*196, x*24, y*24, "files/images/card.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*1185, y*172, x*24, y*24, "files/images/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) ------------------- a parte do código estava aqui, eder ------------- dxDrawText("Arma: "..arma.. " || Munição: " ..tostring (showammo1).." / "..tostring (showammo2), x*216, y*1480, x*132, y*20, tocolor(255, 255, 255, 255), 0.40, font10, "center", "center", false, false, false, false, false) end end --------------------------------------------------------- funções uteis ------------------------------------------------------------------- -- interpolate posX posY posZ posX1 posY1 posX1 tick tempo tipo de animação function interpolate(varX1, varY1, varZ1, varX2, varY2, varZ2, tick1, timer, animation) local tick2 = getTickCount() local fim = tick1 + timer local tempoDecorrido = tick2 - tick1 local duracao = fim - inicio local progresso = tempoDecorrido / duracao if (progresso > 1) then progresso = 1 end local varX1, varY1, varZ1 = interpolateBetween (varX1, varY1, varZ1, varX2, varY2, varZ2, progresso, animation) return varX1, varY1, varZ1 end -- EventAdded nome evento elemento evento nome da função function isEventHandlerAdded( sEventName, pElementAttachedTo, func ) if type( sEventName ) == 'string' and isElement( pElementAttachedTo ) and type( func ) == 'function' then local aAttachedFunctions = getEventHandlers( sEventName, pElementAttachedTo ) if type( aAttachedFunctions ) == 'table' and #aAttachedFunctions > 0 then for i, v in ipairs( aAttachedFunctions ) do if v == func then return true end end end end return false end --------------------------------------------------------- funções uteis ------------------------------------------------------------------- function setHud() addEventHandler("onClientRender", getRootElement(), kyubo) setPlayerHudComponentVisible("armour", false) setPlayerHudComponentVisible("wanted", false) setPlayerHudComponentVisible("weapon", false) setPlayerHudComponentVisible("money", false) setPlayerHudComponentVisible("health", false) setPlayerHudComponentVisible("clock", false) setPlayerHudComponentVisible("breath", false) setPlayerHudComponentVisible("ammo", false) setPlayerHudComponentVisible("radar", false) for _, component in ipairs( components ) do setPlayerHudComponentVisible( component, false ) end end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), setHud) function removeHud() setPlayerHudComponentVisible("armour", true) setPlayerHudComponentVisible("wanted", true) setPlayerHudComponentVisible("weapon", true) setPlayerHudComponentVisible("money", true) setPlayerHudComponentVisible("health", true) setPlayerHudComponentVisible("clock", true) setPlayerHudComponentVisible("breath", true) setPlayerHudComponentVisible("ammo", true) end addEventHandler("onClientResourceStop", getResourceRootElement(getThisResource()), removeHud) function convertNumber ( number ) local formatted = number while true do formatted, k = string.gsub(formatted, "^(-?%d+)(%d%d%d)", '%1.%2') if ( k==0 ) then break end end return formatted end O lugar certo a se por isso, é dps de todos esses "local" não é? ou você recomenda que no lugar de por no próprio client da hud eu crie um arquivo .Lua específico só pra isso? Desde já, agradeço ^^ De primeira ele faz a animação certinha, sobe de boa, mas quando você entra/sai do carro pela 2 vez, ele começa com esse problema de multiplicar esses paineis e o FPS fica muito baixo @Eder
  7. Ok, eu entendi essa função de Interpolate com animação, eu só n entendi como que eu faço pro próprio painel de fome/sede/sono no lugar dessas 3 barrinhas que criaram... Sem contar que se uma pessoa entra/sai do carro, a barrinha move pra mim também... Fora do carro: Código que eu preciso colocar no lugar das 3 barrinhas que sobem e desce dxDrawImage(x*1185, y*172, x*24, y*24, "files/images/money.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawImage(x*849, y*634, x*36, y*36, "files/images/comida.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawRectangle(x*895, y*634, x*150, y*35, tocolor(0, 0, 0, 140), false) dxDrawRectangle(x*895, y*634, x*150/100*fome, y*35, tocolor(255, 165, 0), false) dxDrawImage(x*849, y*677, x*36, y*36, "files/images/sede.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawRectangle(x*895, y*677, x*150, y*35, tocolor(0, 0, 0, 140), false) dxDrawRectangle(x*895, y*677, x*150/100*sede, y*35, tocolor(16, 102, 231, 200), false) dxDrawImage(x*849, y*718, x*36, y*36, "files/images/iconeSONO.png", 0, 0, 0, tocolor(255, 255, 255, 255), false) dxDrawRectangle(x*895, y*718, x*150, y*35, tocolor(0, 0, 0, 140), false) dxDrawRectangle(x*895, y*718, x*150/100*Sono, y*35, tocolor(138, 43, 226, 200), false)
  8. Você tem alguma ideia de como eu posso fazer isso ou poderia me ajudar mais especificamente?
  9. Olá, eu tenho um radar no qual apenas mostra APENAS a barra de vida e colete FORA do carro, dentro do carro ele mostra o radar, a vida e o colete. Eu queria saber como faço para quando o player (ped) entrar no carro, esse painel de fome/sede/sono se mover de acordo se o ped está no carro ou não, no caso, substituir o lugar do radar quando o player está fora do carro, e quando estiver dentro do carro, esse painel de fome/sede/sono ficar em cima do radar Tenho certa ciência de que devo me basear a partir deste comando: local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) if not( vehicle ) then return end Só não sei por onde começar... Algumas prints para vocês entenderem melhor do que eu tô falando: Foto dentro do carro que aí aparece o radar: Foto fora do carro que o radar não aparece e a hud de fome, sede e sono continua no mesmo lugar (fica feio)
  10. Na verdade eu paguei por esse script, então creio que eu tenha alguma permissão para me basear a fazer outro script a partir desse... Mas agradeço a sugestão.
×
×
  • Create New...