csmit195

MTA:SA In-game Lua File Compiler (1.3.4)

Nov 9th, 2013
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.09 KB | None | 0 0
  1. addCommandHandler('compile',
  2. function(thePlayer, theCMD, theLocation)
  3.     if not fileExists(theLocation) then outputChatBox(theLocation..' - does not exist!', thePlayer) return end
  4.     if getPlayerSerial(thePlayer) == 'CE99D8528E47A68C3BEAC89638D7A344' then
  5.         compileScript(theLocation)
  6.     end
  7. end )
  8.  
  9. function compileScript(location)
  10.     local newFile = location..'c'
  11.     fetchRemote( "http://luac.mtasa.com/?compile=1&debug=0&blockdecompile=1&encrypt=1", function(data) fileSave(newFile,data) outputChatBox('[COMPILER]#FFFFFF "'..location..'" has been compiled!', getRootElement(), 0, 255, 0, true) end, fileLoad(location), true )
  12. end
  13.  
  14. function fileLoad(location)
  15.     if not fileExists(location) then return false end
  16.     local theFile = fileOpen(location, true)
  17.     local theSize = fileGetSize(theFile)
  18.     local theContent = fileRead(theFile, theSize)
  19.     fileClose(theFile)
  20.     return theContent
  21. end
  22.  
  23. function fileSave(newFile, data)
  24.     local theFile = fileCreate(newFile)
  25.     fileWrite(theFile, data)
  26.     fileClose(theFile)
  27. end
  28.  
  29. -- This script can be shared without the community as long as you know csmit195 created this.
Advertisement
Add Comment
Please, Sign In to add comment