Jump to content

Number of checkpoint on not yet launched map


acp___(PL)

Recommended Posts

How to read a number of checkpoint from any not yet launched map knowing only its name?

He wants to make a script that when voting, showed number of checkpoint and average finishing time.

local nubCP = ???...#getElementsByType('checkpoint') 

...???

Average finishing time

compatibleMaps=exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource()) 
for index, map in ipairs(compatibleMaps) do 
  
local mapName = getResourceInfo(map, "name") or getResourceName(map) 
local tableName = 'race maptimes Sprint ' ..mapName 
local mapRecord = executeSQLQuery( "SELECT timeMs FROM ?", tableName ) 
local sprintMapTimes 
if not mapRecord then 
            sprintMapTimes = "n/a" 
            outputDebugString("sprintMapTimes = n/a", 3, 255, 0, 0) 
elseif type( mapRecord ) == "table" and #mapRecord > 2 then 
            numberRowsTop10 = 0 
            for top_key, top_value in pairs(mapRecord) do 
                if top_key == 11 then break end 
                sprintMapTimes = sprintMapTimes + top_value['timeMs'] 
                numberRowsTop10 = top_key 
            end 
            sprintMapTimes = sprintMapTimes / numberRowsTop10 
else 
            sprintMapTimes = "n/a" 
            outputDebugString("sprintMapTimes = n/a (else)", 3, 255, 0, 0) 
end 
  
end 

Link to comment
compatibleMaps = exports.mapmanager:getMapsCompatibleWithGamemode ( exports.mapmanager:getRunningGamemode ( ) ) 
for _, map in pairs( compatibleMaps ) do 
    nubCP = #getElementsByType( 'checkpoint',map ) 
end 

Paper, 1 argument is string :/ In function getElementsByType.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...