• String.Find?
    9 replies, posted
I'm probably going to look like a nub for asking this, but I am using a lua module that can block ran console commands. (Making a cheat blocker on my server) The code is something like [lua] if CLIENT then hook.Add( "OnConCommand", "TestHook", function ( cmd ) if ( string.find(cmd,"gm_test") ) then Msg("Cheat detected. Blocked") return false; end end) end [/lua] cmd is (obv) the command being ran, and gm_test is the command itself. gm_test prints a message to the players chat and sets his health to 500. When I enter into the console "gm_test" it blocks it, and it works. But if I change the case in one of the letters, for example: "Gm_test" or "gM_test" or "gm_Test", the command works. And isn't blocked. Source engine will let the command run if you change the case in one or more of the letters, but the string find doesn't detect it if you do. Thus, allowing the command. :| I looked at the wiki, and trying to get it to work I (literally) Ended up not allowing (<any>) console commands to be ran and I ended up running around the map unable to disconnect >_> and had to end the hl2.exe. (Epic fail) So how can I get string find to detect the command in any case a player types? Without having to check if a player typed "Gm_test" or "GM_test" or "gM_teSt"
[lua]if ( string.find( string.lower(cmd), "gm_test" ) ) then[/lua] [b][url=http://wiki.garrysmod.com/?title=String.lower]String.lower [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[QUOTE=Entoros;25235749][lua]if ( string.find( string.lower(cmd), "gm_test" ) ) then[/lua] [b][url=http://wiki.garrysmod.com/?title=String.lower]String.lower [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b][/QUOTE] didn't work :| I entered the command how it's added, "gm_test" and it instead of blocking it, it worked. It works no matter how I type it now.
What module are you use?
[QUOTE=Cubar;25244345]What module are you use?[/QUOTE] it's 1-5 in the thing in FP
Module name?
[url]http://www.facepunch.com/showthread.php?t=994287[/url] gm_concmdhook
I don't think it blocks any concommand.Add just the default ones in the console of gmod.
[QUOTE=Cubar;25252039]I don't think it blocks any concommand.Add just the default ones in the console of gmod.[/QUOTE] [QUOTE=Brandan] gm_test prints a message to the players chat and sets his health to 500. When I enter into the console "gm_test" it blocks it, and it works. [/QUOTE] [QUOTE=Brandan] "Gm_test" or "gM_test" or "gm_Test", the command works. And isn't blocked. [/QUOTE] edit: [QUOTE=Brandan] Source engine will let the command run if you change the case in one or more of the letters, but the string find doesn't detect it if you do. Thus, allowing the command. :| [/QUOTE]
[lua] if string.lower(cmd) == "gm_test" then return false end [/lua] Should work.
Sorry, you need to Log In to post a reply to this thread.