I'm trying to make a command that will, when used, send a message to a person from the Admins. I used some code from "ulx asay" but I just can't get it working.
What I mean is, I want it so that when someone responds to someone, if a person is staff they will see a message saying "x via admin chat to xx: message" but to the person who receives the message: "admins to you: message". What I'm confused about, though, is how I can do this. I thought I'd be able to use a table and if someone is a part of this table to send one message, but if they're not, send the other.
local seerespondAccess = "ulx seerespond"
if SERVER then ULib.ucl.registerAccess( seerespondAccess, ULib.ACCESS_OPERATOR, "Ability to see 'ulx respond'", "Other" ) end
function ulx.respond( calling_ply, target_ply, message )
local players = player.GetAll()
for i=#players, 1, -1 do
local v = players[ i ]
if not ULib.ucl.query( v, seerespondAccess ) and v != calling_ply then
table.remove( players, i )
end
end
ulx.fancyLog( { players }, "#P to #T: " .. message, calling_ply, target_ply )
ulx.fancyLog( { target_ply }, "Admins to #T: " .. message, target_ply )
end
local respond = ulx.command( "Chat", "ulx respond", ulx.respond, "#", true, true )
respond:addParam{ type=ULib.cmds.PlayerArg, ULib.cmds.ignoreCanTarget }
respond:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
respond:defaultAccess( ULib.ACCESS_OPERATOR )respond:help( "Sends an anonymous respond to a player from the Admins." ))
When I try to run the command, I get this in my console:
[ERROR] addons/ulib/lua/ulib/shared/sh_ucl.lua:42: attempt to call method 'IsValid' (a nil value)
1. query - addons/ulib/lua/ulib/shared/sh_ucl.lua:42
2. makePlayerList - addons/ulx/lua/ulx/log.lua:354
3. unknown - addons/ulx/lua/ulx/log.lua:471
4. gsub - [C]:-1
5. fancyLogAdmin - addons/ulx/lua/ulx/log.lua:450
6. fancyLog - addons/ulx/lua/ulx/log.lua:514
7. call - addons/customcommands/lua/ulx/modules/sh/cc_adminrespond.lua:21
8. __fn - addons/ulib/lua/ulib/shared/commands.lua:943
9. unknown - addons/ulib/lua/ulib/shared/commands.lua:1296
10. unknown - lua/includes/modules/concommand.lua:54and I honestly don't know how to fix this.
EDIT: Never mind, I've made a much easier way of doing this with just making it silent:
function ulx.respond( calling_ply, target_ply,message )
ulx.fancyLog( { target_ply }, "Admins to #P: " .. message, target_ply )
ulx.fancyLogAdmin( { calling_ply, target_ply }, true, "#P via admin respond to #P: " .. message, calling_ply, target_ply )
end
local respond = ulx.command( "Chat", "ulx respond", ulx.respond, "#", true, true )
respond:addParam{ type=ULib.cmds.PlayerArg }
respond:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
respond:defaultAccess( ULib.ACCESS_OPERATOR )
respond:help( "Send anonymous admin message." )