Hey, I'm trying to link my chatbox on my website so it prints into the server's chat, and vice versa soon , can someone help me link the 2? BTW : My chatbox on my website is fully functional and doesnt have any bugs i know of :).
I'm not sure but doesn't php has a source rcon library?
Or use sockets to connect the server with the chat.
In case you don't know how to do that, try to use http.Get or so.
Well, the way it works is in MySQL so i was wondering, instead of checking for anything new every so often, why not just send the new things while they are new. Using commands would be obvious , so would you have a link to the source rcon library? Or some sort of an alternative?
I just know there is a library just look for it.
[url]http://developer.valvesoftware.com/wiki/Source_RCON_Protocol[/url]
And on the bottom of that page: [url]http://fremnet.net/article/199/source-rcon-class[/url]
Thanks, I'm linking it up now :)
I will post updates soon if you want them?
[editline]19th October 2010[/editline]
[LUA]
/*-------------------------------------------
/ Lua Based PHP Chatbox : Part2
/-------------------------------------------*/
// //
// Server Side //
// //
if SERVER then
AddCSLuaFile( "server.lua" );
concommand.Add( "CG_Post" , function( _1 , _2 , Arguments )
if ( Arguments[1] and Arguments[2] ) then
umsg.Start( 'CG_Post' );
local Name = Arguments[1];
Arguments = table.remove( Arguments , 1 );
//local Message = table.concat( Arguments, " " )
local Message = "";
for i=1, #Arguments do
Message = Message .. " " .. Arguments[i];
end
umsg.String( Name ); -- Name
umsg.String( Message ); -- Message
umsg.End();
PrintTable( Arguments );
end
end)
end
// //
// Client Side //
// //
if CLIENT then
usermessage.Hook( "CG_Post" , function( um )
local Name = um:ReadString();
local Message = um:ReadString();
chat.AddText(
Color(0,0,255), "(WEB) ",
Color(255,0,0), Name,
Color(255,255,255), " : " .. Message);
chat.PlaySound();
end)
end
// //
// End of script! //
// //
[/LUA]
I'm getting errors on line 25 for some reason :
[CODE]
13:42:56: Lua Error: [lua\autorun\server.lua:25] attempt to concatenate field '?' (a nil value)
13:42:56: rcon from "89.238.178.98:2249": command ""CG_Post" "Meisno" "Test001""
[/CODE]
Your use of table.Remove is a bit awkward; What exactly are you trying to do on line 21? If you simply want to remove the first argument from the table, use:
[lua]
table.Remove(Arguments, 1)
[/lua]
table.Remove returns a table ...
[QUOTE=dingusnin;25507551]table.Remove returns a table ...[/QUOTE]
No it doesn't, it returns the removed object.
Ok , here is the new code :
[LUA]
if SERVER then
AddCSLuaFile( "server.lua" );
Msg( "-----------------------------\n" );
Msg( "------- Loading ChatBox -----\n" );
Msg( "-----------------------------\n" );
Msg( "---------- Loaded! -------\n" );
Msg( "-----------------------------\n" );
concommand.Add( "CG_Post" , function( _1 , _2 , Arguments )
if ( Arguments[1] and Arguments[2] ) then
local Name = Arguments[1];
table.remove( Arguments , 1 );
local Message = table.concat( Arguments, " " )
print( "Incomming : [ ".. Name .." ] : "..Message )
umsg.Start( 'CG_Post' )
umsg.String( Name )
umsg.String( Message )
umsg.End()
end
end)
end
if CLIENT then
local function Handle( um )
local Name = um:ReadString()
local Message = um:ReadString()
//chat.AddText( Color(0,0,255), "(WEB) ", Color(255,0,0), Name, Color(255,255,255), " : ", Message );
//chat.PlaySound()
Msg( Name .. " : " .. Message .. "\n" )
end
usermessage.Hook( "CG_Post" , Handle)
end
[/LUA]
I used the console command to speed things up and i got this :
[CODE]
] lua_openscript autorun/server.lua
Running script autorun/server.lua...
-----------------------------
------- Loading ChatBox -----
-----------------------------
---------- Loaded! -------
-----------------------------
] CG_Post Meisno Hey Ho This works
Incomming : [ Meisno ] : Hey Ho This works
Warning: Unhandled usermessage 'CG_Post'
[/CODE]
And idea what's wrong?
You didn't load it client-side (lua_openscript_cl)
[editline]19th October 2010[/editline]
AddCSLuaFile only works in the autorun phase (when the datapack is built)
Sorry, you need to Log In to post a reply to this thread.