• ChatLog Addon - Works listen, not dedicted.
    2 replies, posted
[code]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);[/code] LUA file location and file name addons/Glogs/lua/autorun/Glogs_init.lua [code] "AddonInfo" { "name" "Glogs" "version" "0.1" "author_name" "Pantho" "info" "bybservers.co.uk Glogs" "override" "0" } [/code] 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: [quote] 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! [/quote]
seems to be something that return a number in your hook try returning what the player said, in your case: [CODE] return saywhat [/CODE] at the end of the function
Yoz can't name the hook 1 [lua]hook.Add("PlayerSay","1",PlayerSpoke) -- this is correct hook.Add("PlayerSay",1,PlayerSpoke) -- don't do this[/lua]
Sorry, you need to Log In to post a reply to this thread.