Advertisement
Guest User

Untitled

a guest
May 22nd, 2017
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1.  
  2. local CmdID = 0
  3.  
  4. local SqlHost = "mysql2.000webhost.com" -- Change this to your mysql host
  5. local SqlUser = "a4770340_mahaz" -- Change to your mysql user
  6. local SqlPass = "f4eclan" -- change to your mysql pass
  7. local SqlDataBase = "a4770340_server" -- Change to ur mysql database
  8.  
  9.  
  10. addEventHandler("onResourceStart",getRootElement(),
  11. function ( res )
  12. if(res == getThisResource()) then
  13. SqlCon = mysql_connect(SqlHost,SqlUser,SqlPass, SqlDataBase)
  14. if( not SqlCon ) then
  15. outputServerLog("Failed to connect via sql")
  16. else
  17. outputServerLog("connected via sql")
  18. end
  19. local result = mysql_query(SqlCon,"SELECT * FROM `irccmds`")
  20. CmdID = mysql_num_rows (result)
  21. setTimer(CheckIRCCmds,2000,0)
  22. end
  23. end
  24. )
  25.  
  26. function CheckIRCCmds()
  27. local result = mysql_query(SqlCon,"SELECT * FROM `irccmds` WHERE `ID` > "..CmdID.."")
  28. if (result) then
  29. while true do
  30. local row = mysql_fetch_assoc(result)
  31. if (not row) then
  32. break
  33. end
  34. if(row["Cmd"] == "!m") then
  35. outputChatBox(row["Args"],getRootElement(),255,255,255)
  36. CmdID = tonumber(row["ID"])
  37. end
  38. end
  39. end
  40. end
  41.  
  42. addEventHandler("onPlayerChat",getRootElement(),
  43. function (message)
  44. Echo(getPlayerName(source) ..": "..message)
  45. end
  46. )
  47.  
  48.  
  49.  
  50. addEventHandler("onPlayerJoin",getRootElement(),
  51. function ()
  52. Echo(getPlayerName(source) .." has joined the server!")
  53. end
  54. )
  55.  
  56.  
  57. addEventHandler("onPlayerQuit",getRootElement(),
  58. function ()
  59. Echo(getPlayerName(source) .." has left the server!")
  60. end
  61. )
  62.  
  63. function Echo(Message)
  64. mysql_query(SqlCon,"INSERT INTO `echo` (Message) VALUES ('"..Message.."')")
  65. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement