not working
can you give me a example to use on mapInfo function?
addEvent("onMapStarting",true)
addEventHandler ( 'onMapStarting', root,
function ( mapInfo )
local resource = getResourceName ( mapInfo )
local mapname = getResourceInfo(exports.mapmanager:getRunningGamemodeMap(),"name")
local author = getResourceInfo(exports.mapmanager:getRunningGamemodeMap(),"author")
local lastTimePlayed = timestampToDate(mapInfo.lastTimePlayed)
local xml = xmlLoadFile("data/ratings.xml")
if ( xml ) then
local index = findIndexByName ( mapname )
if ( index ) then
local map = xmlFindChild ( xml, "map", index )
local rating = xmlNodeGetAttribute ( map, "rating" )
local ratedBy = xmlNodeGetAttribute ( map, "ratedBy" )
local played = xmlNodeGetAttribute ( map, "played" )
triggerClientEvent(source,"INFO",getRootElement(),mapname,author,rating,ratedBy,played,lastTimePlayed)
else
outputChatBox ( "Map not found in our ratings list. " ..mapname, getRootElement(), 255, 0, 0, true )
end
else
outputChatBox ( "Unable to load map ratings XML file.", getRootElement(), 255, 0, 0, true )
end
end
)
is that right?
mapInfo isn't a function.
mapInfo is a table.
And your code is wrong, you're trying to get table resource name. You should use mapInfo.name to get map name.