Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.05 KB | None | 0 0
  1. --[[
  2. Resource: OURGame v2
  3. Developers: Split <split.programista@gmail.com>
  4. You have no right to use this code without my permission.
  5. (c) 2015 <split.programista@gmail.com>. All rights reserved.
  6. ]]
  7.  
  8. -- Settings
  9. DBHandler=nil
  10. DBName="db_32343"
  11. DBUser="db_32343"
  12. DBPass="kutas123"
  13. DBHost="178.33.54.14"
  14.  
  15. -- Functions
  16. function dbSet(...)
  17. if not {...} then return end
  18. local query=dbExec(DBHandler, ...)
  19. return query
  20. end
  21.  
  22. function dbGet(...)
  23. if not {...} then return end
  24. --outputDebugString(tostring(...))
  25. local query=dbQuery(DBHandler, ...)
  26. local result=dbPoll(query, -1)
  27. return result
  28. end
  29.  
  30.  
  31. addEventHandler("onResourceStart", resourceRoot, function()
  32. DBHandler=dbConnect("mysql", "dbname="..DBName..";host="..DBHost.."", DBUser, DBPass, "share=1")
  33. if DBHandler then
  34. outputDebugString("* Connect to server MYSQL...")
  35. else
  36. outputDebugString("* No Connecting to server MYSQL..")
  37. end
  38. end)
  39.  
  40.  
  41. local SQL_LOGIN="db_24606"
  42. local SQL_PASSWD="rcu3q2of"
  43. local SQL_DB="db_24606"
  44. local SQL_HOST="137.74.0.12"
  45. local SQL_PORT=3306
  46.  
  47. local root = getRootElement()
  48.  
  49. local SQL
  50.  
  51. local function connect()
  52. SQL = mysql_connect(SQL_HOST, SQL_LOGIN, SQL_PASSWD, SQL_DB, SQL_PORT)
  53. if (not SQL) then
  54. outputServerLog("BRAK POLACZENIA Z BAZA DANYCH!")
  55. else
  56. --mysql_query(SQL,"SET NAMES utf8")
  57. --outputServerLog("Modul mysql polaczony!")
  58. end
  59.  
  60. end
  61.  
  62.  
  63. local function keepAlive()
  64. if (not mysql_ping(SQL)) then
  65. outputServerLog("Zerwane polaczenie z baza danych, nawiazywanie...")
  66. connect()
  67. end
  68. end
  69. addEventHandler("onResourceStart",getResourceRootElement(),function()
  70. connect()
  71. setTimer(keepAlive, 30000, 0)
  72. end)
  73.  
  74. function esc(value)
  75. return mysql_escape_string(SQL,value)
  76. end
  77.  
  78. function pobierzTabeleWynikow(query)
  79. outputDebugString(tostring(query))
  80. local result=mysql_query(SQL,query)
  81. if (not result) then
  82. outputDebugString("mysql_query failed: (" .. mysql_errno(SQL) .. ") " .. mysql_error(SQL))
  83. outputServerLog("mysql_query failed: (" .. mysql_errno(SQL) .. ") " .. mysql_error(SQL))
  84. return nil
  85. end
  86. local tabela={}
  87. for result,row in mysql_rows_assoc(result) do
  88. table.insert(tabela,row)
  89. end
  90. mysql_free_result(result)
  91. return tabela
  92. end
  93.  
  94. function pobierzWyniki(query)
  95. outputDebugString(tostring(query))
  96. local result=mysql_query(SQL,query)
  97. if (not result) then return nil end
  98. row = mysql_fetch_assoc(result)
  99. mysql_free_result(result)
  100. return row
  101. end
  102.  
  103.  
  104. function zapytanie(query)
  105. outputDebugString(tostring(query))
  106. local result=mysql_query(SQL,query)
  107. if (result) then mysql_free_result(result) return true end
  108. return
  109. end
  110.  
  111. function insertID()
  112. return mysql_insert_id(SQL)
  113. end
  114.  
  115. function affectedRows()
  116. return mysql_affected_rows(SQL)
  117. end
  118.  
  119.  
  120. function fetchRows(query)
  121. local result=mysql_query(SQL,query)
  122. if (not result) then return nil end
  123. local tabela={}
  124.  
  125. while true do
  126. local row = mysql_fetch_row(result)
  127. if (not row) then break end
  128. table.insert(tabela,row)
  129. end
  130. mysql_free_result(result)
  131. return tabela
  132. end
  133.  
  134.  
  135. function getSQLLink()
  136. return SQL
  137. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement