SHARE
TWEET

Untitled

a guest Sep 11th, 2019 102 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. SCRIPT ERROR: @vrp/lib/utils.lua:43: attempt to call a nil value (upvalue 'callback')
  2. > task (@vrp/lib/utils.lua:47)
  3. > cb (@vrp/modules/identity.lua:43)
  4. > handler (- begin MySQL module
  5. local MySQL = {}
  6.  
  7. MySQL.debug = false
  8. local dpaths = {}
  9.  
  10. local tasks = {}
  11.  
  12. --[[
  13. local function tick()
  14.   SetTimeout(1, function() -- protect errors from breaking the loop
  15.     SetTimeout(1000, tick)
  16.  
  17.     local rmtasks = {}
  18.     for id,cb in pairs(tasks) do
  19.       local r = exports.vrp_mysql:checkTask(id)
  20.       if r.status == 1 then
  21.         cb(r.rows,r.affected) -- rows, affected
  22.         table.insert(rmtasks, id)
  23.       elseif r.status == -1 then
  24.         print("[vRP] task "..id.." failed.")
  25.         table.insert(rmtasks, id)
  26.       end
  27.     end
  28.  
  29.     -- remove done tasks
  30.     for k,v in pairs(rmtasks) do
  31.       tasks[v] = nil
  32.     end
  33.   end)
  34. end
  35. tick()
  36. --]]
  37.  
  38. AddEvt andler("vfunction(task_id, data)adhesive_cdnKeyk",
  39. --  print("vRP:MySQL_task "..task_id)
  40.   local cb = tasks[task_id]
  41.   if data.status == 1 then
  42.     if cb then
  43.       if data.mode == 0 then
  44.         cb(data.affected or 0)
  45.       elseif data.mode == 1 then
  46.         cb(data.scalar or 0)
  47.       elseif data.mode == 2 then
  48.         cb(data.rows or {}, data.affected or 0) -- rows, affected
  49.       end
  50.     end
  51.   elseif data.status == -1 then
  52.     print("[vRP] task "..task_id.." failed.")
  53.   end
  54.  
  55.   tasks[task_id] = nil
  56.  
  57.   if MySQL.debug and dpaths[task_id] then
  58.     print("[vRP] MySQL end query "..dpaths[task_id].." ("..task_id..")")
  59.     d[ ask_id] = nil
  60.   end
  61. end)
  62.  
  63. loca            ask_id = -1nKeyl ta
  64. AddEventHandler("vRP:MySQL_taskid", function(_task_id)
  65. --  print("vRP:MySQL_taskid ".._task_id)
  66.   task_id = _task_id
  67. end)
  68.  
  69. -- host can be "host" or "host:port"
  70. function MySQL.createConnection(name,host,user,password,db,debug)
  71. --  print("[vRP] try to create connection "..name)
  72.   -- parse port in host as "ip:port"
  73.   local host_parts = splitString(host,":")
  74.   if #host_parts >= 2 then
  75.     host = host_parts[1]..";port="..host_parts[2]
  76.   end
  77.  
  78.   local config = "server="..host..";uid="..user..";pwd="..password..";database="..db..";"
  79.  
  80. --  TriggerEvent("vRP:MySQL:createConnection", name, config)
  81.   exports.vrp_mysql:createConnection(name, config)
  82. end
  83.  
  84. function MySQL.createCommand(path, query)
  85. --  print("[vRP] try to create command "..path)
  86. --  TriggerEvent("vRP:MySQL:createCommand", path, query)
  87.   exports.vrp_mysql:createCommand(path, query)
  88. end
  89.  
  90. -- generic query
  91. function MySQL._query(path, args, mode, cb)
  92.   -- TriggerEvent("vRP:MySQL:query", path, args)
  93.   if not (type(args) == "table") then
  94.     args = {}
  95.   end
  96.  
  97.   -- force args to be a C# dictionary
  98.   args._none = " "
  99.  
  100. --  exports.vrp_mysql:query(path, args)
  101. --  print("[vRP] try to query "..path.." id "..task_id)
  102.   TriggerEvent("vRP:MySQL_query", path, args, mode)
  103.   if MySQL.debug then
  104.     print("[vRP] MySQL begin query (m"..mode..") "..path.." ("..task_id..")")
  105.     dpaths[task_id] = path
  106.   end
  107.  
  108.   tasks[task_id] = cb
  109. end
  110.  
  111. -- do a query (multiple rows)
  112. --- cb(rows, affected)
  113. function MySQL.query(path, args, cb)
  114.   MySQL._query(path, args, 2, cb)
  115. end
  116.  
  117. -- do a scalar query (one row, one column)
  118. --- cb(scalar)
  119. function MySQL.scalar(path, args, cb)
  120.   MySQL._query(path, args, 1, cb)
  121. end
  122.  
  123. -- do a execute query (no results)
  124. --- cb(affected)
  125. function MySQL.execute(path, args, cb)
  126.   MySQL._query(path, args, 0, cb)
  127. end
  128.  
  129. -- return module
  130. return MySQL
  131. :45)
  132. > void vRP.MySQL.e_tick() (@vrp_mysql/mysql.net.dll:0)
  133. > fn (@vrp_mysql/init.lua:3)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top