acp___(PL) Posted February 25, 2012 Share Posted February 25, 2012 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
Paper Posted February 28, 2012 Share Posted February 28, 2012 Simply: compatibleMaps=exports.mapmanager:getMapsCompatibleWithGamemode(getThisResource()) for index, map in ipairs(compatibleMaps) do nubCP = #getElementsByType(map, 'checkpoint') end Link to comment
acp___(PL) Posted March 3, 2012 Author Share Posted March 3, 2012 WARNING: race\_joiner.lua:95: Bad argument @ 'getElementsByType' ERROR: race\racevoting.lua:3: attempt to get length of a boolean value Link to comment
Kenix Posted March 3, 2012 Share Posted March 3, 2012 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
Paper Posted March 3, 2012 Share Posted March 3, 2012 Oh, my bad... i wrote this fast so i could not review it 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