Jump to content

getresourcename


myyusuf

Recommended Posts

server:

local lastTimePlayed 
local month = {"January","February","March","April","May","June","Juli","August","September","October","November","December"} 
  
function timestampToDate(stamp) 
    local time = getRealTime(stamp) 
    return string.format("%d %s %02d:%02d",time.monthday,month[time.month+1],time.hour,time.minute) 
end 
  
addEvent("onMapStarting",true) 
addEventHandler ( 'onMapStarting', root, 
    function ( mapInfo ) 
       local mapname = getResourceName(map) 
        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(),author,rating,ratedBy,played,lastTimePlayed) 
            else 
                outputChatBox ( "Map not found in our ratings list.", getRootElement(), 255, 0, 0, true ) 
            end 
        else 
            outputChatBox ( "Unable to load map ratings XML file.", getRootElement(), 255, 0, 0, true ) 
        end 
    end 
) 
  
function findIndexByName ( mapName ) 
    local ratingsFile = xmlLoadFile("data/ratings.xml") 
    if ( ratingsFile ) then 
        for index, map in ipairs ( xmlNodeGetChildren ( ratingsFile ) ) do 
            local name = xmlNodeGetAttribute ( map, "id" ) 
            if ( name == mapName ) then 
                return index -1 
            end 
        end 
        xmlUnloadFile(ratingsFile) 
    end 
end 
  
  

client:

local screenWidth, screenHeight = guiGetScreenSize() 
local endPosition = screenHeight-140 
local moveback = false 
 function handleMapInfo(mapInfo) 
    name            = mapInfo.name or "Unknown" 
    author          = mapInfo.author or "Unknown" 
    lastTimePlayed  = timestampToDate(mapInfo.lastTimePlayed) or "Unknown" 
    playedCount     = tostring(mapInfo.playedCount or "Unknown") 
    modename        = mapInfo.modename ~= "Destruction derby" and mapInfo.modename or "Destruction derby" 
    hunterreached   = huntersReached or "0" 
    maprate         = mapRates or "-" 
    ratedtimes      = ratedTimess or "0" 
    position        = screenHeight+90 
    movePosition    = 5 
    tickCount       = 400 
    moveback        = false 
    alpha           = 0 
end 
function getDrawText(author,rating,ratedBy,played,lastTimePlayed) 
    addEventHandler ( "onClientRender", getRootElement(), drawMapInfo) 
    if author then 
        textA = "Author: "..author 
    else 
        textA = "Unknown" 
    end 
    if rating then 
        textR = "Rate: " ..rating.. "/10 (by " ..ratedBy.. " players)" 
    else 
        textR = "Not rated yet" 
    end 
    if played then 
        textP = "Times played: "..played.." times" 
    else 
        textP = "Never played before" 
    end 
    if lastTimePlayed then 
        textPL = "Last Time Played\n"..lastTimePlayed 
    else 
        textPL = "Unknown" 
    end 
end 
addEvent( "INFO", true ) 
addEventHandler( "INFO", getRootElement(), getDrawText ) 
  
function drawMapInfo () 
    if position == endPosition then 
        if tickCount == 0 then 
            moveback = true 
        end 
        tickCount = tickCount-1 
        movePosition = 0 
    end 
    if position >= screenHeight+91 then 
        removeEventHandler("onClientRender",getRootElement(),drawMapInfo) 
    end 
    if moveback then 
        movePosition = -2.5 
        alpha = alpha - 10 
    end 
    alpha = alpha + 5 
    if alpha > 255 then 
        alpha = 255 
    elseif alpha < 0 then 
        alpha = 0 
    end 
    local heighResize = dxGetFontHeight(1.15, "default-bold") 
    local widthRezise1 = dxGetTextWidth("Map - "..name,1.15,"default-bold") 
    local widthRezise2 = dxGetTextWidth("Lasttime played - "..lastTimePlayed,1.15,"default-bold") 
    local widthRezise3 = dxGetTextWidth("By - "..author,1.15,"default-bold") 
    if widthRezise1 > widthRezise2 and widthRezise1 > widthRezise3 then 
        widthRezise = widthRezise1 
    elseif  widthRezise2 > widthRezise1 and widthRezise2 > widthRezise3 then 
        widthRezise = widthRezise2 
    elseif  widthRezise3 > widthRezise1 and widthRezise3 > widthRezise2 then 
        widthRezise = widthRezise3 
    end 
    dxDrawImage(screenWidth/2-200,screenHeight/2+185,420.0,176.0, "images/info_bgr.png",0,0,0,tocolor(200,200,200,alpha)) 
    dxDrawText ( "Name: " ..name,screenWidth/2-150,screenHeight/2+200,636.0,675.0,tocolor(255,255,255,255),1.5,"default-bold","left","top",false,false,false) 
    dxDrawText ( textA,screenWidth/2-150,screenHeight/2+225.0,636.0,619.0,tocolor(255,255,255,255),1.5,"default-bold","left","top",false,false,false) 
    dxDrawText ( textR,screenWidth/2-150,screenHeight/2+275,684.0,647.0,tocolor(255,255,255,255),1.5,"default-bold","left","top",false,false,false) 
    dxDrawText ( textP,screenWidth/2-150,screenHeight/2+250,636.0,675.0,tocolor(255,255,255,255),1.5,"default-bold","left","top",false,false,false)     
    dxDrawText ( textPL,screenWidth/2-150,screenHeight/2+300,684.0,647.0,tocolor(255,255,255,255),1.5,"default-bold","left","top",false,false,false) 
    dxDrawText ( "Mode: Destruction Derby",screenWidth/2-150,screenHeight/2+325,506.0,699.0,tocolor(255,255,255,255),1.5,"default-bold","left","top",false,false,false) 
    position = position - movePosition 
end 
  

i wanna take map folder name in server side's 12. line. but it doesnt take. can you help me please? :?

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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