Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.90 KB | None | 0 0
  1. SCRIPT ERROR: Execution of native 000000002f7a49e6 in script host failed.
  2. > cb (@vrp_garages/server.lua:355)
  3. > handler (- begin MySQL module
  4. local MySQL = {}
  5.  
  6. MySQL.debug = false
  7. local dpaths = {}
  8.  
  9. local tasks = {}
  10.  
  11. --[[
  12. local function tick()
  13. SetTimeout(1, function() -- protect errors from breaking the loop
  14. SetTimeout(1000, tick)
  15.  
  16. local rmtasks = {}
  17. for id,cb in pairs(tasks) do
  18. local r = exports.vrp_mysql:checkTask(id)
  19. if r.status == 1 then
  20. cb(r.rows,r.affected) -- rows, affected
  21. table.insert(rmtasks, id)
  22. elseif r.status == -1 then
  23. print("[vRP] task "..id.." failed.")
  24. table.insert(rmtasks, id)
  25. end
  26. end
  27.  
  28. -- remove done tasks
  29. for k,v in pairs(rmtasks) do
  30. tasks[v] = nil
  31. end
  32. end)
  33. end
  34. tick()
  35. --]]
  36.  
  37. AddEventHandler("vRP:MySQL_task", function(task_id, data)
  38. -- print("vRP:MySQL_task "..task_id)
  39. local cb = tasks[task_id]
  40. if data.status == 1 then
  41. if cb then
  42. if data.mode == 0 then
  43. cb(data.affected or 0)
  44. elseif data.mode == 1 then
  45. cb(data.scalar or 0)
  46. elseif data.mode == 2 then
  47. cb(data.rows or {}, data.affected or 0) -- rows, affected
  48. end
  49. end
  50. elseif data.status == -1 then
  51. print("[vRP] task "..task_id.." failed.")
  52. end
  53.  
  54. tasks[task_id] = nil
  55.  
  56. if MySQL.debug and dpaths[task_id] then
  57. print("[vRP] MySQL end query "..dpaths[task_id].." ("..task_id..")")
  58. dpaths[task_id] = nil
  59. end
  60. end)
  61.  
  62. local task_id = -1
  63. AddEventHandler("vRP:MySQL_taskid", function(_task_id)
  64. -- print("vRP:MySQL_taskid ".._task_id)
  65. task_id = _task_id
  66. end)
  67.  
  68. -- host can be "host" or "host:port"
  69. function MySQL.createConnection(name,host,user,password,db,debug)
  70. -- print("[vRP] try to create connection "..name)
  71. -- parse port in host as "ip:port"
  72. local host_parts = splitString(host,":")
  73. if #host_parts >= 2 then
  74. host = host_parts[1]..";port="..host_parts[2]
  75. end
  76.  
  77. local config = "server="..host..";uid="..user..";pwd="..password..";database="..db..";"
  78.  
  79. -- TriggerEvent("vRP:MySQL:createConnection", name, config)
  80. exports.vrp_mysql:createConnection(name, config)
  81. end
  82.  
  83. function MySQL.createCommand(path, query)
  84. -- print("[vRP] try to create command "..path)
  85. -- TriggerEvent("vRP:MySQL:createCommand", path, query)
  86. exports.vrp_mysql:createCommand(path, query)
  87. end
  88.  
  89. -- generic query
  90. function MySQL._query(path, args, mode, cb)
  91. -- TriggerEvent("vRP:MySQL:query", path, args)
  92. if not (type(args) == "table") then
  93. args = {}
  94. end
  95.  
  96. -- force args to be a C# dictionary
  97. args._none = " "
  98.  
  99. -- exports.vrp_mysql:query(path, args)
  100. -- print("[vRP] try to query "..path.." id "..task_id)
  101. TriggerEvent("vRP:MySQL_query", path, args, mode)
  102. if MySQL.debug then
  103. print("[vRP] MySQL begin query (m"..mode..") "..path.." ("..task_id..")")
  104. dpaths[task_id] = path
  105. end
  106.  
  107. tasks[task_id] = cb
  108. end
  109.  
  110. -- do a query (multiple rows)
  111. --- cb(rows, affected)
  112. function MySQL.query(path, args, cb)
  113. MySQL._query(path, args, 2, cb)
  114. end
  115.  
  116. -- do a scalar query (one row, one column)
  117. --- cb(scalar)
  118. function MySQL.scalar(path, args, cb)
  119. MySQL._query(path, args, 1, cb)
  120. end
  121.  
  122. -- do a execute query (no results)
  123. --- cb(affected)
  124. function MySQL.execute(path, args, cb)
  125. MySQL._query(path, args, 0, cb)
  126. end
  127.  
  128. -- return module
  129. return MySQL
  130. :45)
  131. > void vRP.MySQL.e_tick() (@vrp_mysql/mysql.net.dll:0)
  132. > fn (@vrp_mysql/init.lua:3)
  133. SCRIPT ERROR: @vrp/lib/utils.lua:43: attempt to call a nil value (upvalue 'callback')
  134. > task (@vrp/lib/utils.lua:47)
  135. > cb (@vrp/modules/home.lua:37)
  136. > handler (- begin MySQL module
  137. local MySQL = {}
  138.  
  139. MySQL.debug = false
  140. local dpaths = {}
  141.  
  142. local tasks = {}
  143.  
  144. --[[
  145. local function tick()
  146. SetTimeout(1, function() -- protect errors from breaking the loop
  147. SetTimeout(1000, tick)
  148.  
  149. local rmtasks = {}
  150. for id,cb in pairs(tasks) do
  151. local r = exports.vrp_mysql:checkTask(id)
  152. if r.status == 1 then
  153. cb(r.rows,r.affected) -- rows, affected
  154. table.insert(rmtasks, id)
  155. elseif r.status == -1 then
  156. print("[vRP] task "..id.." failed.")
  157. table.insert(rmtasks, id)
  158. end
  159. end
  160.  
  161. -- remove done tasks
  162. for k,v in pairs(rmtasks) do
  163. tasks[v] = nil
  164. end
  165. end)
  166. end
  167. tick()
  168. --]]
  169.  
  170. AddEventHandler("vRP:MySQL_task", function(task_id, data)
  171. -- print("vRP:MySQL_task "..task_id)
  172. local cb = tasks[task_id]
  173. if data.status == 1 then
  174. if cb then
  175. if data.mode == 0 then
  176. cb(data.affected or 0)
  177. elseif data.mode == 1 then
  178. cb(data.scalar or 0)
  179. elseif data.mode == 2 then
  180. cb(data.rows or {}, data.affected or 0) -- rows, affected
  181. end
  182. end
  183. elseif data.status == -1 then
  184. print("[vRP] task "..task_id.." failed.")
  185. end
  186.  
  187. tasks[task_id] = nil
  188.  
  189. if MySQL.debug and dpaths[task_id] then
  190. print("[vRP] MySQL end query "..dpaths[task_id].." ("..task_id..")")
  191. dpaths[task_id] = nil
  192. end
  193. end)
  194.  
  195. local task_id = -1
  196. AddEventHandler("vRP:MySQL_taskid", function(_task_id)
  197. -- print("vRP:MySQL_taskid ".._task_id)
  198. task_id = _task_id
  199. end)
  200.  
  201. -- host can be "host" or "host:port"
  202. function MySQL.createConnection(name,host,user,password,db,debug)
  203. -- print("[vRP] try to create connection "..name)
  204. -- parse port in host as "ip:port"
  205. local host_parts = splitString(host,":")
  206. if #host_parts >= 2 then
  207. host = host_parts[1]..";port="..host_parts[2]
  208. end
  209.  
  210. local config = "server="..host..";uid="..user..";pwd="..password..";database="..db..";"
  211.  
  212. -- TriggerEvent("vRP:MySQL:createConnection", name, config)
  213. exports.vrp_mysql:createConnection(name, config)
  214. end
  215.  
  216. function MySQL.createCommand(path, query)
  217. -- print("[vRP] try to create command "..path)
  218. -- TriggerEvent("vRP:MySQL:createCommand", path, query)
  219. exports.vrp_mysql:createCommand(path, query)
  220. end
  221.  
  222. -- generic query
  223. function MySQL._query(path, args, mode, cb)
  224. -- TriggerEvent("vRP:MySQL:query", path, args)
  225. if not (type(args) == "table") then
  226. args = {}
  227. end
  228.  
  229. -- force args to be a C# dictionary
  230. args._none = " "
  231.  
  232. -- exports.vrp_mysql:query(path, args)
  233. -- print("[vRP] try to query "..path.." id "..task_id)
  234. TriggerEvent("vRP:MySQL_query", path, args, mode)
  235. if MySQL.debug then
  236. print("[vRP] MySQL begin query (m"..mode..") "..path.." ("..task_id..")")
  237. dpaths[task_id] = path
  238. end
  239.  
  240. tasks[task_id] = cb
  241. end
  242.  
  243. -- do a query (multiple rows)
  244. --- cb(rows, affected)
  245. function MySQL.query(path, args, cb)
  246. MySQL._query(path, args, 2, cb)
  247. end
  248.  
  249. -- do a scalar query (one row, one column)
  250. --- cb(scalar)
  251. function MySQL.scalar(path, args, cb)
  252. MySQL._query(path, args, 1, cb)
  253. end
  254.  
  255. -- do a execute query (no results)
  256. --- cb(affected)
  257. function MySQL.execute(path, args, cb)
  258. MySQL._query(path, args, 0, cb)
  259. end
  260.  
  261. -- return module
  262. return MySQL
  263. :45)
  264. > void vRP.MySQL.e_tick() (@vrp_mysql/mysql.net.dll:0)
  265. > fn (@vrp_mysql/init.lua:3)
  266. bad guy
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement