Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local CmdID = 0
- local SqlHost = "mysql2.000webhost.com" -- Change this to your mysql host
- local SqlUser = "a4770340_mahaz" -- Change to your mysql user
- local SqlPass = "f4eclan" -- change to your mysql pass
- local SqlDataBase = "a4770340_server" -- Change to ur mysql database
- addEventHandler("onResourceStart",getRootElement(),
- function ( res )
- if(res == getThisResource()) then
- SqlCon = mysql_connect(SqlHost,SqlUser,SqlPass, SqlDataBase)
- if( not SqlCon ) then
- outputServerLog("Failed to connect via sql")
- else
- outputServerLog("connected via sql")
- end
- local result = mysql_query(SqlCon,"SELECT * FROM `irccmds`")
- CmdID = mysql_num_rows (result)
- setTimer(CheckIRCCmds,2000,0)
- end
- end
- )
- function CheckIRCCmds()
- local result = mysql_query(SqlCon,"SELECT * FROM `irccmds` WHERE `ID` > "..CmdID.."")
- if (result) then
- while true do
- local row = mysql_fetch_assoc(result)
- if (not row) then
- break
- end
- if(row["Cmd"] == "!m") then
- outputChatBox(row["Args"],getRootElement(),255,255,255)
- CmdID = tonumber(row["ID"])
- end
- end
- end
- end
- addEventHandler("onPlayerChat",getRootElement(),
- function (message)
- Echo(getPlayerName(source) ..": "..message)
- end
- )
- addEventHandler("onPlayerJoin",getRootElement(),
- function ()
- Echo(getPlayerName(source) .." has joined the server!")
- end
- )
- addEventHandler("onPlayerQuit",getRootElement(),
- function ()
- Echo(getPlayerName(source) .." has left the server!")
- end
- )
- function Echo(Message)
- mysql_query(SqlCon,"INSERT INTO `echo` (Message) VALUES ('"..Message.."')")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement