MrXz Posted January 27, 2012 Share Posted January 27, 2012 (edited) 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 January 27, 2012 by Guest Link to comment
Kenix Posted January 27, 2012 Share Posted January 27, 2012 Learn https://wiki.multitheftauto.com/wiki/Scr ... troduction http://www.lua.org/manual/5.1/ Link to comment
Klesh Posted January 27, 2012 Share Posted January 27, 2012 You can delete maps with this resource, https://community.multitheftauto.com/index.php?p=resources&s=details&id=2091, don`t forget to add it to acl group admin. 1 Link to comment
MrXz Posted January 27, 2012 Author Share Posted January 27, 2012 I appreciate your opinions, but I only care about that script .. =/ Link to comment
BriGhtx3 Posted January 27, 2012 Share Posted January 27, 2012 https://wiki.multitheftauto.com/wiki/DeleteResource Link to comment
Castillo Posted January 27, 2012 Share Posted January 27, 2012 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
MrXz Posted January 27, 2012 Author Share Posted January 27, 2012 D: .. not work.. I tested it over 30 minutes and not work.. just get the notice that the map has been deleted, but not delete map =/ Link to comment
codeluaeveryday Posted January 28, 2012 Share Posted January 28, 2012 Guys, i have scripted with deleteResource. I have posted before with same issue. As solidsnake said. It deletes from memory, not from the server. 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