• Net Library Help
    13 replies, posted
[code] if SERVER then AddCSLuaFile("autorun/cscheck.lua") util.AddNetworkString("Check") print("Server") net.Receive("Check", function(len, ply) print("Hacks: ", len, ply) end) else local hax = GetConVar("sv_allowcslua"):GetInt() net.Start("Check") net.WriteString(hax) net.SendToServer() end [/code] I'm coding an extremely simple cheat notification system, and was wondering how to get this function to sync, so the client is sending and the server is receiving at the correct time, or am I just looking at it wrong?
util.AddNetworkString("Check") needs to be called a few seconds before the message would be received, not one tick before. You should also receive what the client is sending by using net.ReadString( ). [editline]25th April 2013[/editline] I would also suggest looking at another addon: [url]http://facepunch.com/showthread.php?t=1261484[/url] to see how this person does it, might be helpful.
Instead of or along with (before, after?) net.Receive?
"util.AddNetworkString("Check") needs to be called a few seconds before the message would be received" [editline]25th April 2013[/editline] You also need to run it when they join (possibly) which means you need to call a function on a hook.
My bad, meant to include that I was asking about ReadString. So far, this is what I have: [code] if SERVER then AddCSLuaFile("autorun/cscheck.lua") util.AddNetworkString("Check") print("Server") timer.Simple(2, function() net.Receive("Check", function(len, ply) print("Bits: ", len, ply) local message = net.ReadString() print(message) end) end) else timer.Simple(2, function() local hax = GetConVar("sv_allowcslua"):GetInt() net.Start("Check") net.WriteString(hax) net.SendToServer() end) end [/code] Hopefully it doesn't error, it hasn't been tested yet. Also, I was going to make it be ran on command. Edit: fixed a typo in the code
I don't use net, but that looks correct to me, you could always try it in singleplayer.
[QUOTE=Pandaman09;40424015]I don't use net, but that looks correct to me, you could always try it in singleplayer.[/QUOTE] Thanks a bunch, I'll test that now and report back. [QUOTE] Bits: 16 Player [1][Mute™] 1 [/QUOTE] Looks like it works! Also, it seems to already run when a player joins with just that code.
It's because it is in autorun... forgot about that :P
It may work, but you're still doing it wrong. The server side receive code doesn't need to be called the same time as the client sends it ( that would cause horrible lag problems ). This is what you sort of should do : [lua] if ( SERVER ) then AddCSLuaFile(); util.AddNetworkString( "Check" ); net.Receive( "Check", function( len, ply ) print( "Received packet from " .. ply:Name() .. ". len = " .. len .. " msg = " .. net.ReadString() ); end); else timer.Simple( 2, function() net.Start( "Check" ); net.WriteString( "Lua : " .. GetConVarNumber( "sv_allowcslua" ) ); net.SendToServer(); end); end [/lua] As I said, sort of. If you're making any sort of anti-cheat you should always split the receiving code and scanning code apart, having them shared means that scanning code is sent to the clients, which is bad. And just for clarification, you cannot send net messages as soon as script is loaded, scripts load before they can be sent.
[QUOTE=>>oubliette<<;40424476]-stuff-[/QUOTE] Thanks! I've implemented the changes you listed, though at this point my system is extremely easy to bypass or exploit (thus why it notifies and doesn't kick or ban). I'm eventually going to add a pixel capture function for verification once I get a bit better.
Use render.Capture not pixel, Capture is like a screenshot where with Pixel you need to go through all of the pixels on the screen.
[QUOTE=Pandaman09;40424767]Use render.Capture not pixel, Capture is like a screenshot where with Pixel you need to go through all of the pixels on the screen.[/QUOTE] Thanks. Is it resolution dependent?
nope [url]http://wiki.garrysmod.com/page/render/Capture[/url] You need to call it in a special hook of which i've been trying to figure out for over a week. @below No problem :)
Interesting. Thanks for the tips.
Sorry, you need to Log In to post a reply to this thread.