require( "mysql" )
function PlayerSpoke(ply, saywhat)
local message = {};
message[1] = tostring(ply:Nick());
message[2] = tostring(ply:SteamID());
message[3] = tostring(ply:IPAddress());
message[4] = saywhat;
message[5] = string.gsub(message[4],"'","");
message[6] = (os.date("%x"));
message[7] = (os.date("%X"));
local db, error = mysql.connect("xt","x","x", "x")
print(tostring(error) .. "\n")
print("connection opened - " .. db .. "!\n");
MySQLQuery = "INSERT INTO GLogs (Name,SteamID,IP,Text,Date,Time) VALUES('" .. message[1] .. "','" .. message[2] .. "','" .. message[3] .."','" .. message[5] .. "','" .. message[6] .. "','" .. message[7] .. "')"
test, isok, error = mysql.query(db, MySQLQuery);
if (test) then
print("");
end
if (!isok) then
print(tostring(error) .. "\n");
end
end
hook.Add("PlayerSay", 1, PlayerSpoke);
LUA file location and file name
addons/Glogs/lua/autorun/Glogs_init.lua
"AddonInfo"
{
"name" "Glogs"
"version" "0.1"
"author_name" "Pantho"
"info" "bybservers.co.uk Glogs"
"override" "0"
}
addons/glogs/info.txt
I am trying to make a quick server side script to upload the chat logs. The issue I am having is the following:
It works perfectly in single player, but im MP dedicated server I get:
03:24:46 L 12/05/2009 - 03:24:43: Lua Error: ERROR: GAMEMODE:'PlayerSay' Failed: attempt to compare string with number
03:24:46 L 12/05/2009 - 03:24:43: Lua Error: Error: hook->PlayerSay returned a non-string!
I posted this on facepunch, but here forums remind me of 4chan with less intellect. If anyone here could lend assistance it would be appreciated. Script seems simple enough, Just cannot understand why it works in single player and not on a dedicated server.