csmit195

fixRespawnMaps() - MTASA

Jun 11th, 2012
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.31 KB | None | 0 0
  1. -- this script will fix all MTA:SA race maps which contain the respawn node.
  2. function fixRespawnMaps( )
  3.     local count = 0
  4.     for _, v in pairs( exports.mapmanager:getMapsCompatibleWithGamemode( exports.mapmanager:getRunningGamemode( ) ) ) do
  5.         local main = xmlLoadFile( ":"..getResourceName( v ).."/meta.xml" )
  6.         if main then
  7.             settings = xmlFindChild( main,"settings",0 )
  8.             local node = xmlFindChild( settings, "setting", 0 )
  9.             local i = 1
  10.             while node do
  11.                 if (xmlNodeGetAttribute( node, "value" ) ~= "none") then
  12.                     xmlNodeSetAttribute( node,"value","none" )
  13.                     xmlSaveFile(main)
  14.                 end
  15.             node = xmlFindChild( v, "setting", i )
  16.             i = i + 1
  17.         end
  18.         count = count + 1
  19.         xmlUnloadFile(main)
  20.     end
  21. end
  22. return count
  23. end
  24.  
  25. Example:
  26. addCommandHandler( "fixAllMaps",
  27.     function( player )
  28.         if hasObjectPermissionTo( player,"function.setServerPassword",true ) then
  29.             outputChatBox( "(MAPFIX) You have fixed #FFFFFF"..tostring( fixRespawnMaps( ) ).."#FF6464 maps!",player,255,100,100,true )
  30.         else
  31.             outputChatBox( "(MAPFIX) You don't have the required rights to perform this action!",player,255,100,100 )
  32.         end
  33.     end
  34. )
Advertisement
Add Comment
Please, Sign In to add comment