I choose to start learning Lua... and I started working on this myself. It's quite hard, and I actually don't think it's possible. (I've seen one other server with it but still don't know how he did it.)
I then stopped working on it, but if anyone is interested at taking a look at the code here you go (but it's unfinished and won't ever be finished.)
if (SERVER) then
local tmp = 0
AddCSLuaFile("autorun/tags.lua")
/*--------------------------------------------------------------------------
Start Config
*/--------------------------------------------------------------------------
local DATABASE_HOST = "*****" --Host
local DATABASE_PORT = 3306 --Port
local DATABASE_NAME = "*****" --Database
local DATABASE_USERNAME = "*****" --Username
local DATABASE_PASSWORD = "*****" --Password
/*--------------------------------------------------------------------------
End Config - Do not edit below this unless you know what you're doing!
*/------------------------------------------------ -------------------------
/*--------------------------------------------------------------------------
Server Logging V2 - By Trivkz
*/------------------------------------------------ -------------------------
require("mysqloo")
local db = mysqloo.connect(DATABASE_HOST, DATABASE_USERNAME, DATABASE_PASSWORD, DATABASE_NAME, DATABASE_PORT)
db.onConnectionFailed = function() print("++++++++++++++++Failed Connection+++++++++++++++++++++++") end
db.onConnected = function() print(" ++++++++++++++++++Successfully Connected to DB+++++++++++++++++++++++") ScanForChanges() end
db:connect()
function Querys()
local query1 = db:query("CREATE TABLE mChat (server INTEGER UNSIGNED NOT NULL ,player INTEGER UNSIGNED NOT NULL,said VARCHAR(255) NULL,PRIMARY KEY (server));");
query1.onData = function() print("Anything at all") end
query1.onSuccess = function() print("++++++++++++++++++Successfull Query+++++++++++++++++++++++") Query2() end
query1.onFailure = function() print("Error Printing Query!") end
query1.onError = function(error_message) print(error_message) print("ERROR YOU STUPID MOTHERFUCKER JESUS H CHRIST") end
query1:start()
end
function Query2()
local sid = db:escape("Boo")
local query1 = db:query("INSERT into mChat ( server, player,said) VALUES ( 2, 0,'" .. sid .. "');")
--local query1 = db:query("SELECT * FROM mChat WHERE server = 1;")
-- query1.onData = function(Q,D) print("Q1") PrintTable(D) end
query1.onSuccess = function() print("++++++++++++++++++Successfull Query2+++++++++++++++++++++++") PrintTable(query1:getData())
local Table = query1:getData()
local servernum = Table[1].server
servertxt = Table[1].said
print("This value is what your looking for "..tostring(servernum))
end
query1.onFailure = function() print("Error Printing Query!") end
query1.onError = function(error_message) print(error_message) print("ERROR DURING QUERY") end
query1:start()
end
function playerSaid( ply, saywhat )
servertxt = saywhat
if (tmp == 0) then
ScanForChanges()
tmp = 1
end
end
hook.Add ( "PlayerSay", "playerSaid", playerSaid )
-- function QueryRepeat(ply)
-- local query1 = db:query("INSERT into mChat ( server, player,said) VALUES ( 1, 0,'" .. sid .. "');")
-- local query1 = db:query("SELECT * FROM mChat WHERE server = 1;")
-- query1.onData = function(Q,D) print("Q1") PrintTable(D) end
-- query1.onSuccess = function() print("Success")
-- local Table = query1:getData()
-- local servernum = Table[1].server
-- dbtxt = Table[1].said
-- if ((dbtxt ~= servertxt) and (servertxt ~= nil)) then
-- local update = db:query("UPDATE mChat SET said = '" .. servertxt .. "' WHERE server = 1;")
-- update.onSuccess = function()
-- ply:SendLua(string.format("chat.AddText( %q );", servertxt))
-- end
-- update:start()
-- timer.Create("query", 0.1, 0, function()
-- QueryRepeat(ply)
-- end)
-- else
-- timer.Create("query", 0.1, 0, function()
-- QueryRepeat(ply)
-- end)
-- end
-- end
-- query1.onFailure = function() print("Error Printing Query!") end
-- query1.onError = function(error_message) print(error_message) print("ERROR DURING QUERY") end
-- query1:start()
-- end
function ScanForChanges()
--local query1 = db:query("INSERT into mChat ( server, player,said) VALUES ( 1, 0,'" .. sid .. "');")
local query1 = db:query("SELECT * FROM mChat WHERE server = 2;")
--query1.onData = function(Q,D) print("Q1") PrintTable(D) end
query1.onSuccess = function() print("Success")
local Table = query1:getData()
--local servernum = Table[2].server
local dbtxt = Table[1].said
if ((dbtxt ~= servertxt) and (servertxt ~= nil)) then
local update = db:query("UPDATE mChat SET said = '" .. servertxt .. "' WHERE server = 2;")
update.onSuccess = function()
local Players = player.GetAll()
for i = 1, table.Count(Players) do
local ply = Players[i]
ply:SendLua(string.format("chat.AddText( %q );", servertxt))
end
timer.Create("queryrepeat", 0.1, 0, function()
ScanForChanges()
end)
end
update:start()
elseif (dbtxt == servertxt) then
timer.Create("queryrepeat", 0.1, 0, function()
ScanForChanges()
end)
end
end
query1.onFailure = function() print("Error Printing Query!") end
query1.onError = function(error_message) print(error_message) print("ERROR DURING QUERY") end
query1:start()
end
end
if (CLIENT) then
local servertxt
local function RecvMyUmsg( data )
servertxt = data:ReadString();
print (servertxt)
end
usermessage.Hook( "MyUsermessage", RecvMyUmsg );
function Insert( pl, msg )
local ServerNum = "#1 "
local tab = {}
table.insert( tab, Color( 62, 165, 255, 255 ) )
table.insert( tab, "1 " )
table.insert( tab, team.GetColor( pl:Team() ) )
table.insert( tab, pl:Nick() )
table.insert( tab, Color( 255, 255, 255, 255 ) )
table.insert( tab, ": " )
table.insert( tab, msg )
chat.AddText( unpack(tab) )
return true
end
end
hook.Add("OnPlayerChat", "InsertTags", Insert)
*edit by MrP: Put the code in code tags*