Ulysses

General => Developers Corner => Topic started by: Zmaster on June 18, 2014, 04:36:40 PM

Title: Don't Show Commands
Post by: Zmaster on June 18, 2014, 04:36:40 PM
I want to make it so when a player types something in chat that is a command (ex: !slay Zmaster), the command will go through and work, but that message won't appear in chat for everyone to see.

Where/how would I do that? If I'm thinking right, I would do it somewhere in the gamemode itself, but I'm not entirely sure
Title: Re: Don't Show Commands
Post by: Cobalt on June 18, 2014, 04:58:14 PM
You mean the chat command or the part that says "x kicked y" in chat?
Title: Re: Don't Show Commands
Post by: Zmaster on June 18, 2014, 05:39:41 PM
The chat command
Title: Re: Don't Show Commands
Post by: Cobalt on June 18, 2014, 06:22:37 PM
The 5th arg in ulx.command hides the chat message if set to true. Go into the lua and add it in for each command you want to hide chat messages for.
Title: Re: Don't Show Commands
Post by: Zmaster on June 18, 2014, 08:02:20 PM
So I tried what you said with the !slay command and it worked fine
Then I found my undercover command to add that 5th arg to it and I saw there was already a 5th arg in it and it was true, yet when I type !uc in chat it still shows me saying that?

Code: [Select]
// Undercover Command

function ulx.undercover( calling_ply )
 
if calling_ply:IsUserGroup("owner") then
calling_ply:SetUserGroup("ucowner")
 
elseif calling_ply:IsUserGroup("ucowner") then
calling_ply:SetUserGroup("owner")
end
 
ulx.fancyLogAdmin( calling_ply, true, "#A went undercover" )
end

local undercover = ulx.command( CATEGORY_NAME, "ulx undercover", ulx.undercover, "!uc", true )
undercover:addParam{ type=ULib.cmds.PlayerArg }
undercover:defaultAccess( ULib.ACCESS_ADMIN )
undercover:help( "Makes Mods undercover (no mod tag)" )

// Undercover Command

Here's the code for my !slay command (this one is working properly - the other isn't)
Code: [Select]
------------------------------ Slay ------------------------------
function ulx.slay( calling_ply, target_plys )
local affected_plys = {}

for i=1, #target_plys do
local v = target_plys[ i ]

if ulx.getExclusive( v, calling_ply ) then
ULib.tsayError( calling_ply, ulx.getExclusive( v, calling_ply ), true )
elseif not v:Alive() then
ULib.tsayError( calling_ply, v:Nick() .. " is already dead!", true )
elseif v:IsFrozen() then
ULib.tsayError( calling_ply, v:Nick() .. " is frozen!", true )
else
v:Kill()
table.insert( affected_plys, v )
end
end

ulx.fancyLogAdmin( calling_ply, "#A slayed #T", affected_plys )
end
local slay = ulx.command( CATEGORY_NAME, "ulx slay", ulx.slay, "!slay", true )
slay:addParam{ type=ULib.cmds.PlayersArg }
slay:defaultAccess( ULib.ACCESS_ADMIN )
slay:help( "Slays target(s)." )
Title: Re: Don't Show Commands
Post by: Zmaster on June 20, 2014, 03:52:13 PM
(Added the code to my slay command above)

Also, just noted something weird
(http://i.imgur.com/FEazWGK.jpg)
Title: Re: Don't Show Commands
Post by: Decicus on June 20, 2014, 04:09:59 PM
(Added the code to my slay command above)

Also, just noted something weird
(http://i.imgur.com/FEazWGK.jpg)

Remove this line from your code, as you never use the PlayerArg anyways:
Code: [Select]
undercover:addParam{ type=ULib.cmds.PlayerArg }
Title: Re: Don't Show Commands
Post by: Zmaster on June 20, 2014, 06:55:52 PM
Alright. Did that, now it shows the command being typed in chat in both cases

(http://i.imgur.com/ueyoL2G.jpg)
Title: Re: Don't Show Commands
Post by: Decicus on June 21, 2014, 09:54:40 AM
You don't need to use your playername and just "!uc" btw.

I don't know why it's not running silently. The 5th "true" parameter should make it not show up in chat, and I honestly have no clue why it still does.
Title: Re: Don't Show Commands
Post by: Zmaster on July 15, 2014, 02:07:42 PM
This is odd

If you read through everything before this post, the "!uc" command would always show in the chat, even though it was being told not to.

However, I recently tested the command to see if it was still working (because a few other things broke after the recent GMod update), and not only did the command work, but it didn't show up in chat.

Thanks to the people who tried to help me with this earlier. :P