ULX

Author Topic: Don't Show Commands  (Read 6216 times)

0 Members and 1 Guest are viewing this topic.

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Don't Show Commands
« 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

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Don't Show Commands
« Reply #1 on: June 18, 2014, 04:58:14 PM »
You mean the chat command or the part that says "x kicked y" in chat?

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Don't Show Commands
« Reply #2 on: June 18, 2014, 05:39:41 PM »
The chat command

Offline Cobalt

  • Full Member
  • ***
  • Posts: 216
  • Karma: 44
  • http://steamcommunity.com/id/__yvl/
Re: Don't Show Commands
« Reply #3 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.

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Don't Show Commands
« Reply #4 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)." )
« Last Edit: June 20, 2014, 03:52:41 PM by Zmaster »

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Don't Show Commands
« Reply #5 on: June 20, 2014, 03:52:13 PM »
(Added the code to my slay command above)

Also, just noted something weird
« Last Edit: June 20, 2014, 04:09:15 PM by Zmaster »

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Don't Show Commands
« Reply #6 on: June 20, 2014, 04:09:59 PM »
(Added the code to my slay command above)

Also, just noted something weird


Remove this line from your code, as you never use the PlayerArg anyways:
Code: [Select]
undercover:addParam{ type=ULib.cmds.PlayerArg }
« Last Edit: June 20, 2014, 04:13:00 PM by Decicus »
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Don't Show Commands
« Reply #7 on: June 20, 2014, 06:55:52 PM »
Alright. Did that, now it shows the command being typed in chat in both cases


Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: Don't Show Commands
« Reply #8 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.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: Don't Show Commands
« Reply #9 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