Description: A simple module which allows a coder to see all console commands being run and choose to disable them from running.
**Example Code:
**[lua] require( “concmdhook” )
local function PlayerFromAddress(address)
for k, v in ipairs(player.GetAll()) do
if (v:IPAddress() == address) then
return v
end
end
end
if CLIENT then
hook.Add( “OnConCommand”, “TestHook”, function ( cmd )
Msg( "Command was run: " … cmd … "
" )
if ( string.find(cmd, “disconnect”) ) then
Msg(“Now you can never leave me!”)
return false;
end
end )
else
hook.Add( “OnConCommand”, “TestHook”, function ( cmd, addr )
local ply = PlayerFromAddress( addr )
if ply == nil then
Msg("Server command ran: " … cmd … "
")
return;
end
Msg("Player " … ply:Name() … " ran " … cmd … "
");
if ( string.find(cmd, “npc_thinknow”) ) then
ply:ChatPrint(“Please don’t crash us :)”)
return false
end
end )
end
[/lua]
Other Info: This module is statesafe, meaning the client, server, and menu can all use this module without interfering. The order by which the module asks for input is Menu, Server, Client.
More Info: The addr argument is the IP address of the player running the command. Bare with me on this, but please use the supplied function to find the player with the given IP address.
Download: v1.1
Source: SVN