Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. function runString (commandstring, outputTo, source)
  2. local sourceName
  3. if source then
  4. sourceName = getPlayerName(source)
  5. else
  6. sourceName = "Console"
  7. end
  8.  
  9. function getLocalPlayer( )
  10. return source
  11. end
  12. _G['source'] = source
  13. if getElementType(source) == 'player' then
  14. vehicle = getPedOccupiedVehicle(source) or getPedContactElement(source)
  15. car = vehicle
  16. end
  17.  
  18. local notReturned
  19. local commandFunction,errorMsg = loadstring("return "..commandstring)
  20. if errorMsg then
  21. notReturned = true
  22. commandFunction, errorMsg = loadstring(commandstring)
  23. end
  24. if errorMsg then
  25. outputChatBoxR("Hiba: "..errorMsg, outputTo)
  26. return
  27. end
  28. results = { pcall(commandFunction) }
  29. if not results[1] then
  30. outputChatBoxR("Hiba: "..results[2], outputTo)
  31. return
  32. end
  33. if not notReturned then
  34. local resultsString = ""
  35. local first = true
  36. for i = 2, #results do
  37. if first then
  38. first = false
  39. else
  40. resultsString = resultsString..", "
  41. end
  42. local resultType = type(results[i])
  43. if isElement(results[i]) then
  44. resultType = "element:"..getElementType(results[i])
  45. end
  46. resultsString = resultsString..tostring(results[i]).." ["..resultType.."]"
  47. end
  48. outputChatBoxR("Eredmény: "..resultsString, outputTo)
  49. elseif not errorMsg then
  50. outputChatBoxR("Parancs lefuttatva!", outputTo)
  51. end
  52. end
  53.  
  54. addCommandHandler("run123", function (player, command, ...)
  55. if not exports.ex_admin:isScripter(player) then return end
  56. local commandstring = table.concat({...}, " ")
  57. return runString(commandstring, rootElement, player)
  58. end)
  59.  
  60.  
  61. addCommandHandler("srun123", function (player, command, ...)
  62. if not exports.ex_admin:isScripter(player) then return end
  63. local commandstring = table.concat({...}, " ")
  64. return runString(commandstring, player, player)
  65. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement