Guest User

LUA - Unloading/Loading Script

a guest
Apr 26th, 2013
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.17 KB | None | 0 0
  1. _setTimer = setTimer
  2. _addEventHandler = addEventHandler
  3. _removeEventHandler = removeEventHandler
  4. _createObject = createObject
  5. _createMarker = createMarker
  6. _createColSphere = createColSphere
  7. _destroyElement = destroyElement
  8. _playSound = playSound
  9. _addCommandHandler = addCommandHandler
  10. _engineImportTXD = engineImportTXD
  11. _engineReplaceModel = engineReplaceModel
  12. _removeCommandHandler = removeCommandHandler
  13. _removeEventHandler = removeEventHandler
  14. _bindKey = bindKey
  15. _unbindKey = unbindKey
  16. _stopSound = stopSound
  17. x,y = guiGetScreenSize()
  18.  
  19.  
  20. objects = {}
  21. markers = {}
  22. timers = {}
  23. colspheres = {}
  24. events = {}
  25. sounds = {}
  26. commands = {}
  27. models = {}
  28. binds = {}
  29. dlScripts = 0
  30. dlFiles = 0
  31. handleSize = false
  32. handlePercent = false
  33.  
  34. pickupID = { nitro = 2221, repair = 2222, vehiclechange = 2223 }
  35.  
  36.  
  37. function playSound( soundPath, looped )
  38.     if looped ~= true then looped = false end
  39.     local sound = _playSound( soundPath, looped)
  40.     sounds[#sounds+1] = sound
  41.     return sound
  42. end
  43.  
  44. function stopSound ( theSound )
  45.     for i,v in pairs(sounds) do
  46.         if v == theSound then
  47.             v = false
  48.         end
  49.     end
  50.     return _stopSound(theSound)
  51. end
  52.  
  53. function bindKey(key, state, func, arguments)
  54.     local number = #binds+1
  55.     binds[number] = {}
  56.     binds[number].key = key
  57.     local result
  58.     if arguments then
  59.         result = _bindKey(key, state, func, arguments)
  60.     else
  61.         result = _bindKey(key, state, func)
  62.     end
  63.     return result
  64. end
  65.  
  66. function unbindKey(key, state, func)
  67.     for i,v in pairs(binds) do
  68.         if v.key == key then
  69.             v.key = {}
  70.             v.key = false
  71.         end
  72.     end
  73.     return _unbindKey(key)
  74. end
  75.  
  76. function addEventHandler(theEvent, parent, func, propagated)
  77.     if not propagated then
  78.         propagated = true
  79.     end
  80.     local num = #events+1
  81.     events[num] = {}
  82.     events[num].event = theEvent
  83.     events[num].parent = parent
  84.     events[num].func = func
  85.     return _addEventHandler(theEvent, parent, func, propagated)
  86. end
  87.    
  88. function removeEventHandler(theEvent, parent, func)
  89.     for i, p in ipairs(events) do
  90.         if p.event == theEvent and p.parent == parent and p.func == func then
  91.             events[i] = nil
  92.             table.remove(events,i)
  93.         end
  94.     end
  95.     return _removeEventHandler(theEvent, parent, func)
  96. end
  97.    
  98.  
  99. function removeCommandHandler(command)
  100.     for i, p in ipairs(commands) do
  101.         if p == commmand then
  102.             p = false
  103.         end
  104.     end
  105.     return _removeCommandHandler(command)
  106. end
  107.  
  108. function addCommandHandler(command, func)
  109.     commands[#commands+1] = command
  110.     return _addCommandHandler(command, func)
  111. end
  112.  
  113. function setTimer(func, intervall, executes, ...)
  114.     local timer
  115.     if ... then
  116.         timer = _setTimer(func, intervall, executes, unpack(...))
  117.     else
  118.         timer = _setTimer(func, intervall, executes)
  119.     end
  120.     timers[#timers+1] = timer
  121.     return timer
  122. end
  123.  
  124. function engineImportTXD( model, id )
  125.     local search = false
  126.     for i, v in ipairs(models) do
  127.         if v == id then
  128.             search = true
  129.         end
  130.     end
  131.     if search == false then
  132.         models[#models+1] = id
  133.     end
  134.     return _engineImportTXD( model, id )
  135. end
  136.  
  137. function engineReplaceModel( model, id )
  138.     local search = false
  139.     for i, v in ipairs(models) do
  140.         if v == id then
  141.             search = true
  142.         end
  143.     end
  144.     if search == false then
  145.         models[#models+1] = id
  146.     end
  147.     return _engineReplaceModel( model, id)
  148. end
Advertisement
Add Comment
Please, Sign In to add comment