Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.17 KB | None | 0 0
  1. SCRIPT ERROR: @vrp/modules/item_transformer.lua:289: attempt to index a nil value (upvalue 'cfg')
  2. > finish (@vrp/lib/utils.lua:43)
  3. > task (@vrp/lib/utils.lua:47)
  4. > cb (@vrp/base.lua:246)
  5. > handler (- begin MySQL module
  6. local MySQL = {}
  7. MySQL.debug = false
  8. local dpaths = {}
  9. local tasks = {}
  10. --[[
  11. local function tick()
  12. SetTimeout(1, function() -- protect errors from breaking the loop
  13. SetTimeout(1000, tick)
  14. local rmtasks = {}
  15. for id,cb in pairs(tasks) do
  16. local r = exports.vrp_mysql:checkTask(id)
  17. if r.status == 1 then
  18. cb(r.rows,r.affected) -- rows, affected
  19. table.insert(rmtasks, id)
  20. elseif r.status == -1 then
  21. print("[vRP] task "..id.." failed.")
  22. table.insert(rmtasks, id)
  23. end
  24. end
  25. -- remove done tasks
  26. for k,v in pairs(rmtasks) do
  27. tasks[v] = nil
  28. end
  29. end)
  30. end
  31. tick()
  32. --]]
  33. AddEventHandler("vRP:MySQL_task", function(task_id, data)
  34. -- print("vRP:MySQL_task "..task_id)
  35. local cb = tasks[task_id]
  36. if data.status == 1 then
  37. if cb then
  38. if data.mode == 0 then
  39. cb(data.affected or 0)
  40. elseif data.mode == 1 then
  41. cb(data.scalar or 0)
  42. elseif data.mode == 2 then
  43. cb(data.rows or {}, data.affected or 0) -- rows, affected
  44. end
  45. end
  46. elseif data.status == -1 then
  47. print("[vRP] task "..task_id.." failed.")
  48. end
  49. tasks[task_id] = nil
  50. if MySQL.debug and dpaths[task_id] then
  51. print("[vRP] MySQL end query "..dpaths[task_id].." ("..task_id..")")
  52. dpaths[task_id] = nil
  53. end
  54. end)
  55. local task_id = -1
  56. AddEventHandler("vRP:MySQL_taskid", function(_task_id)
  57. -- print("vRP:MySQL_taskid ".._task_id)
  58. task_id = _task_id
  59. end)
  60. -- host can be "host" or "host:port"
  61. function MySQL.createConnection(name,host,user,password,db,debug)
  62. -- print("[vRP] try to create connection "..name)
  63. -- parse port in host as "ip:port"
  64. local host_parts = splitString(host,":")
  65. if #host_parts >= 2 then
  66. host = host_parts[1]..";port="..host_parts[2]
  67. end
  68. local config = "server="..host..";uid="..user..";pwd="..password..";database="..db..";"
  69. -- TriggerEvent("vRP:MySQL:createConnection", name, config)
  70. exports.vrp_mysql:createConnection(name, config)
  71. end
  72. function MySQL.createCommand(path, query)
  73. -- print("[vRP] try to create command "..path)
  74. -- TriggerEvent("vRP:MySQL:createCommand", path, query)
  75. exports.vrp_mysql:createCommand(path, query)
  76. end
  77. -- generic query
  78. function MySQL._query(path, args, mode, cb)
  79. -- TriggerEvent("vRP:MySQL:query", path, args)
  80. if not (type(args) == "table") then
  81. args = {}
  82. end
  83. -- force args to be a C# dictionary
  84. args._none = " "
  85. -- exports.vrp_mysql:query(path, args)
  86. -- print("[vRP] try to query "..path.." id "..task_id)
  87. TriggerEvent("vRP:MySQL_query", path, args, mode)
  88. if MySQL.debug then
  89. print("[vRP] MySQL begin query (m"..mode..") "..path.." ("..task_id..")")
  90. dpaths[task_id] = path
  91. end
  92. tasks[task_id] = cb
  93. end
  94. -- do a query (multiple rows)
  95. --- cb(rows, affected)
  96. function MySQL.query(path, args, cb)
  97. MySQL._query(path, args, 2, cb)
  98. end
  99. -- do a scalar query (one row, one column)
  100. --- cb(scalar)
  101. function MySQL.scalar(path, args, cb)
  102. MySQL._query(path, args, 1, cb)
  103. end
  104. -- do a execute query (no results)
  105. --- cb(affected)
  106. function MySQL.execute(path, args, cb)
  107. MySQL._query(path, args, 0, cb)
  108. end
  109. -- return module
  110. return MySQL
  111. :45)
  112. > fn (@vrp_mysql/init.lua:3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement