• Print

Author Topic: Admin respond  (Read 4310 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Admin respond
« on: June 13, 2016, 07:04:05 pm »
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.


Code: Lua
  1. local seerespondAccess = "ulx seerespond"
  2. if SERVER then ULib.ucl.registerAccess( seerespondAccess, ULib.ACCESS_OPERATOR, "Ability to see 'ulx respond'", "Other" ) end
  3.  
  4.  
  5.  
  6.  
  7. function ulx.respond( calling_ply, target_ply, message )
  8.  
  9.  
  10.    local players = player.GetAll()
  11.  
  12.  
  13.    for i=#players, 1, -1 do
  14.  
  15.  
  16.       local v = players[ i ]
  17.  
  18.  
  19.       if not ULib.ucl.query( v, seerespondAccess ) and v != calling_ply then
  20.  
  21.  
  22.          table.remove( players, i )
  23.  
  24.  
  25.       end
  26.  
  27.  
  28.    end
  29.  
  30.  
  31.    ulx.fancyLog( { players }, "#P to #T: " .. message, calling_ply, target_ply )
  32.    ulx.fancyLog( { target_ply }, "Admins to #T: " .. message, target_ply )
  33.  
  34.  
  35. end
  36. local respond = ulx.command( "Chat", "ulx respond", ulx.respond, "#", true, true )
  37. respond:addParam{ type=ULib.cmds.PlayerArg, ULib.cmds.ignoreCanTarget }
  38. respond:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  39. 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:


Code: [Select]
[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:54

and 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:


Code: Lua
  1. function ulx.respond( calling_ply, target_ply,message )
  2.  
  3.  
  4.         ulx.fancyLog( { target_ply }, "Admins to #P: " .. message, target_ply )
  5.  
  6.  
  7.         ulx.fancyLogAdmin( { calling_ply, target_ply }, true, "#P via admin respond to #P: " .. message, calling_ply, target_ply )
  8.  
  9.  
  10. end
  11.  
  12.  
  13. local respond = ulx.command( "Chat", "ulx respond", ulx.respond, "#", true, true )
  14. respond:addParam{ type=ULib.cmds.PlayerArg }
  15. respond:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  16. respond:defaultAccess( ULib.ACCESS_OPERATOR )
  17. respond:help( "Send anonymous admin message." )
« Last Edit: June 13, 2016, 08:10:16 pm by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

  • Print