Mario222 Posted October 28, 2021 Share Posted October 28, 2021 This resource with this code not shows the points in scoreboard, i need help. g_Root = getRootElement() g_ResRoot = getResourceRootElement(getThisResource()) STAT = { --Player TIMES_DIED = 135, -- Races CHECKPOINTS_COLLECTED = 1024, TOTAL_RACES = 148, RACES_FINISHED = 1025, RACES_WON = 1026, TOPTIMES_SET = 1027, MAX_STREAKS = 1028, -- Scoring POINTS = 2010 } g_AutoPointSettings = { [121] = "ratio_kill", [1024] = "ratio_checkpoint", [148] = "ratio_racestart", [1026] = "ratio_win", [1027] = "ratio_toptime" } addEventHandler('onGamemodeStart', g_ResRoot, function() outputDebugString('Race onGamemodeStart') addRaceScoreboardColumns() if not g_GameOptions then cacheGameOptions() end end ) function addRaceScoreboardColumns() exports.scoreboard:addScoreboardColumn('Points') end -- -- SETTINGS -- function getString(var, default) local result = get(var) if not result then return default end return tostring(result) end function getNumber(var, default) local result = get(var) if not result then return default end return tonumber(result) end function getBool(var, default) local result = get(var) if not result then return default end return result or tostring(result) == 'true' end -- -- TABLES -- function table.dump(t, caption, depth) if not depth then depth = 1 end if depth == 1 and caption then outputDebugString(caption .. ':') end if not t then outputDebugString('Table is nil') elseif type(t) ~= 'table' then outputDebugString('Argument passed is of type ' .. type(t)) local str = tostring(t) if str then outputDebugString(str) end else local braceIndent = string.rep(' ', depth-1) local fieldIndent = braceIndent .. ' ' outputDebugString(braceIndent .. '{') for k,v in pairs(t) do if type(v) == 'table' and k ~= 'siblings' and k ~= 'parent' then outputDebugString(fieldIndent .. tostring(k) .. ' = ') table.dump(v, nil, depth+1) else outputDebugString(fieldIndent .. tostring(k) .. ' = ' .. tostring(v)) end end outputDebugString(braceIndent .. '}') end end function explode(div,str) if (div=='') then return false end local pos,arr = 0,{} -- for each divider found for st,sp in function() return string.find(str,div,pos,true) end do table.insert(arr,string.sub(str,pos,st-1)) -- Attach chars left of current divider pos = sp + 1 -- Jump past current divider end table.insert(arr,string.sub(str,pos)) -- Attach chars right of last divider return arr end -- -- DEBUG -- function alert(message, channel) message = g_ResName..": "..tostring(message) if channel == "console" then outputConsole(message) return end if channel == "chat" then outputChatBox(message) return end outputDebugString(message) end -- -- PLAYER -- -- remove color coding from string function removeColorCoding (name) return type(name)=="string" and string.gsub(name, "#%x%x%x%x%x%x", "") or name end -- getPlayerName with color coding removed local _getPlayerName = getPlayerName function getPlayerName(player) return removeColorCoding (_getPlayerName(player)) end -- -- MISC -- function randomize() -- set a random seed based on server tick count, wrap around each 20 days math.randomseed(getTickCount()) end function getRankText(rank) local ordinal = "th" local unit = rank % 10 if unit == 1 then ordinal = "st" elseif unit == 2 then ordinal = "nd" elseif unit == 3 then ordinal = "rd" end return string.format("%i%s", rank, ordinal) end Link to comment
The_GTA Posted October 28, 2021 Share Posted October 28, 2021 (edited) Hello Mario222, have you taken a look at the documentation of the dxscoreboard resource? You need to assign a number to the "Points" element data key for each player so that it is displayed inside of the scoreboard. For example... setElementData( thePlayer, "Points", 42 ) Also, you need to have a gamemode started in order for the points to be visible in the scoreboard. There could be a logical error in the following line... addEventHandler('onGamemodeStart', g_ResRoot, Did you really mean to put g_ResRoot? Are you aware that you have to put the script into the same map resource? You could try using g_Root instead. (the documentation is vague so I could be wrong, please try for me to be sure) Edited October 28, 2021 by The_GTA 1 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