Jump to content

Command Delete Map Help X2


MrXz

Recommended Posts

function DeleteCurrentMap(player) 
    if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))) then 
        local currentGamemodeMap = exports.mapmanager:getRunningGamemodeMap() 
        local metaNode = xmlCreateFile ( ':' .. getResourceName(currentGamemodeMap) .. '/' .. "meta.xml", "nada" ) 
  
    xmlSaveFile ( metaNode ) 
    xmlUnloadFile ( metaNode ) 
  
        else 
            outputRace("You arent an Admin", player) 
        end 
         
        addCommandHandler("deletemap",DeleteCurrentMap) 
end 

hi all ..

I look at this script .. delete map .. It does not work .. help me =/

Edited by Guest
Link to comment

That function doesn't work, it'll just remove it from memory (I think), but the resource is still there.

function getResourceFiles(resource) 
    local resource = getResourceName(resource) 
    local filesTable = {} 
    local metaNode = xmlLoadFile ( ':' .. resource .. '/' .. "meta.xml" ) 
    if metaNode then 
        local i = 0  
        while xmlNodeGetChildren ( metaNode, i ) ~= false do 
            local node = xmlNodeGetChildren ( metaNode, i ) 
            local src = xmlNodeGetAttribute ( node, "src" ) 
            if src then 
                table.insert( filesTable, src ) 
            end 
            i = i + 1 
        end      
    xmlUnloadFile ( metaNode ) 
    end 
    return filesTable 
end 
  
function removeResource ( resource ) 
    local filestb = getResourceFiles(resource) 
    local delcount = 0 
    local filecount = 0 
    for i=1,#filestb do 
        if fileDelete(':' ..getResourceName(resource).. '/' .. filestb[i]) then 
            delcount = delcount+1 
        end 
    end 
    if fileDelete(':' .. getResourceName(resource).. '/meta.xml') then 
        delcount = delcount+1 
    end 
    if (delcount > 0) then 
        return true 
    else  
        return false 
    end 
end 
  
function DeleteCurrentMap(player) 
    if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(player)),aclGetGroup("Admin"))) then 
        local currentGamemodeMap = exports.mapmanager:getRunningGamemodeMap() 
        if removeResource(currentGamemodeMap) then 
            outputChatBox("The map: ".. getResourceName(currentGamemodeMap) .." was successfully removed.",player,0,255,0) 
        end 
    else 
        outputRace("You arent an Admin", player) 
    end 
end 
addCommandHandler("deletemap",DeleteCurrentMap) 

That'll remove the script files and the meta.xml, but not the resource folder.

P.S: I didn't made it, samt2497 made these functions.

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...