Skip to content

Commit

Permalink
Fixed not usable console-commands like "ev map"
Browse files Browse the repository at this point in the history
The function checked only if plugin.ChatCommand was a string - changed it now to same behavior than sv_chatcommands to also check if the plugin.ChatCommand is using a table.

So this fixes for example the use of map change plugin from console.
  • Loading branch information
X-Coder authored and Xandaros committed Sep 29, 2014
1 parent 0137b45 commit f3716f9
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lua/ev_plugins/sv_consolecommands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,15 @@ function PLUGIN:CCommand( ply, com, cargs )
evolve:Log( evolve:PlayerLogStr( ply ) .. " ran command '" .. command .. "' with arguments '" .. table.concat( args, " " ) .. "' via console." )

for _, plugin in ipairs( evolve.plugins ) do
if ( plugin.ChatCommand == string.lower( command or "" ) ) then
plugin:Call( ply, args )
if ( plugin.ChatCommand == command or ( type( plugin.ChatCommand ) == "table" and table.HasValue( plugin.ChatCommand, command ) ) ) then
evolve.SilentNotify = string.Left( com, 1 ) == "@"
res, ret = pcall( plugin.Call, plugin, ply, args, string.sub( com, #command + 3 ), command )
evolve.SilentNotify = false

if ( !res ) then
evolve:Notify( evolve.colors.red, "Plugin '" .. plugin.Title .. "' failed with error:" )
evolve:Notify( evolve.colors.red, ret )
end
return ""
end
end
Expand All @@ -37,4 +44,4 @@ end
concommand.Add( "ev", function( ply, com, args ) PLUGIN:CCommand( ply, com, args ) end )
concommand.Add( "evs", function( ply, com, args ) evolve.SilentNotify = true PLUGIN:CCommand( ply, com, args ) evolve.SilentNotify = false end )

evolve:RegisterPlugin( PLUGIN )
evolve:RegisterPlugin( PLUGIN )

0 comments on commit f3716f9

Please sign in to comment.