• Print

Author Topic: Achatter admin chat *FIX*  (Read 5216 times)

0 Members and 1 Guest are viewing this topic.

Offline BobTheDuck69

  • Newbie
  • *
  • Posts: 33
  • Karma: 1
Achatter admin chat *FIX*
« on: March 13, 2015, 05:01:05 pm »
First of all i need an admin to remove my old post second i dont know where to add the category for the command thats broken in startup
Code: [Select]
local seeachatterAccess = "ulx seeachatter"
if SERVER then ULib.ucl.registerAccess( seeachatterAccess, ULib.ACCESS_OPERATOR, "Ability to see 'ulx achatter'", "Other" ) end -- Give operators access to see achatters echoes by default

function ulx.achatter( calling_ply, message )
local format
local me = "/me "
if message:sub( 1, me:len() ) == me then
format = "(ADMINS) *** #P #s"
message = message:sub( me:len() + 1 )
else
format = " <Achatter> #P #s"
end

local players = player.GetAll()
for i=#players, 1, -1 do
local v = players[ i ]
if not ULib.ucl.query( v, seeachatterAccess ) and v ~= calling_ply then -- Calling player always gets to see the echo
table.remove( players, i )
end
end

ulx.fancyLog( players, format, calling_ply, message )
end
local achatter = ulx.command( CATEGORY_NAME, "ulx achatter", ulx.achatter, "!achatter", true, true )
achatter:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
achatter:defaultAccess( ULib.ACCESS_ALL )
achatter:help( "Send a message to admins in the chat." )
~The friendly neighborhood duckie~

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Achatter admin chat *FIX*
« Reply #1 on: March 13, 2015, 10:19:49 pm »
Either define CATEGORY_NAME somewhere before it's called in command setup, or change it from a var to a string.
The error (which you didn't post) is pretty clear about that (nil)


"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Livaco

  • Full Member
  • ***
  • Posts: 133
  • Karma: -37
    • Livaco
Re: Achatter admin chat *FIX*
« Reply #2 on: March 27, 2015, 03:01:08 pm »
It Doesent Appear And I Did The Code
Code: Lua
  1. local CATEGORY_NAME = "Livaco"
Heres The Entire Code Can Someone Fix It Plz
Code: Lua
  1. local CATEGORY_NAME = "Livaco"
  2. function ulx.achatter( calling_ply, message )
  3.         local format
  4.         local me = "/me "
  5.         if message:sub( 1, me:len() ) == me then
  6.                 format = "(ADMINS) *** #P #s"
  7.                 message = message:sub( me:len() + 1 )
  8.         else
  9.                 format = " <Achatter> #P #s"
  10.         end
  11.  
  12.         local players = player.GetAll()
  13.         for i=#players, 1, -1 do
  14.                 local v = players[ i ]
  15.                 if not ULib.ucl.query( v, seeachatterAccess ) and v ~= calling_ply then -- Calling player always gets to see the echo
  16.                         table.remove( players, i )
  17.                 end
  18.         end
  19.  
  20.         ulx.fancyLog( players, format, calling_ply, message )
  21. end
  22. local achatter = ulx.command( CATEGORY_NAME, "ulx achatter", ulx.achatter, "!achatter", true, true )
  23. achatter:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  24. achatter:defaultAccess( ULib.ACCESS_ALL )
  25. achatter:help( "Send a message to admins in the chat." )
The Entire File Its In
Code: Lua
  1. local CATEGORY_NAME = "Livaco"
  2. local waittime = 5 --Change this value for a differ in wait time after !cookie has been executed
  3.  
  4. local lastusecookie = -waittime
  5.  
  6. function ulx.cookie(calling_ply, target_plys, times)
  7.  
  8.         if waittime + lastusecookie > CurTime() then
  9.  
  10.                 ULib.tsayError(calling_ply, "Sorry, the cookie jar is empty! Please wait " .. waittime .. " seconds for it to fill up")
  11.  
  12.         else   
  13.  
  14.                 ulx.fancyLogAdmin( calling_ply, "#A gave #T #i cookies!", target_plys, times )
  15.  
  16.                 lastusecookie = CurTime()
  17.  
  18.         end
  19.  
  20. end
  21.  
  22. local cookie = ulx.command( CATEGORY_NAME, "ulx cookie", ulx.cookie, "!cookie" )
  23.  
  24. cookie:addParam{ type=ULib.cmds.PlayersArg }
  25.  
  26. cookie:addParam{ type=ULib.cmds.NumArg, min=1, default=1, hint="times", ULib.cmds.optional, ULib.cmds.round }
  27.  
  28. cookie:defaultAccess( ULib.ACCESS_ADMIN )
  29.  
  30. cookie.help( "spread the love with cookies!" )
  31.  
  32.  
  33. local seeachatterAccess = "ulx seeachatter"
  34. if SERVER then ULib.ucl.registerAccess( seeachatterAccess, ULib.ACCESS_OPERATOR, "Ability to see 'ulx achatter'", "Other" ) end -- Give operators access to see achatters echoes by default
  35.  
  36. local CATEGORY_NAME = "Livaco"
  37. function ulx.achatter( calling_ply, message )
  38.         local format
  39.         local me = "/me "
  40.         if message:sub( 1, me:len() ) == me then
  41.                 format = "(ADMINS) *** #P #s"
  42.                 message = message:sub( me:len() + 1 )
  43.         else
  44.                 format = " <Achatter> #P #s"
  45.         end
  46.  
  47.         local players = player.GetAll()
  48.         for i=#players, 1, -1 do
  49.                 local v = players[ i ]
  50.                 if not ULib.ucl.query( v, seeachatterAccess ) and v ~= calling_ply then -- Calling player always gets to see the echo
  51.                         table.remove( players, i )
  52.                 end
  53.         end
  54.  
  55.         ulx.fancyLog( players, format, calling_ply, message )
  56. end
  57. local achatter = ulx.command( CATEGORY_NAME, "ulx achatter", ulx.achatter, "!achatter", true, true )
  58. achatter:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  59. achatter:defaultAccess( ULib.ACCESS_ALL )
  60. achatter:help( "Send a message to admins in the chat." )
(ulx cookie not related)
« Last Edit: March 27, 2015, 03:03:38 pm by Livaco »
Here To Help And Be Happy And Help :)

My Website
My Addons
PermaBanV1.0

Quote from:  Livaco on April 12 at 9:10:20 PM
I May Be Dum But Am Still Better Then The Rest

Livaco Products©

Offline PwndKilled

  • Newbie
  • *
  • Posts: 19
  • Karma: -1
Re: Achatter admin chat *FIX*
« Reply #3 on: March 29, 2015, 07:46:46 am »
What are actually doing both

Code: [Select]
, true, true )

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Achatter admin chat *FIX*
« Reply #4 on: March 30, 2015, 07:45:50 am »
It Doesent Appear And I Did The Code
Code: Lua
  1. local CATEGORY_NAME = "Livaco"
Heres The Entire Code Can Someone Fix It Plz


What doesn't appear, an error message? Might want to let the OP respond instead of jumping in and taking things potentially off course.  Alternatively, post a clear statement about the issue, any error messages and steps to reproduce.

FWIW, it looks very much like he copied your function call, but failed to include the CATEGORY_NAME var, which would of course throw a nil error.


Nvm -- I see now that you're responding to him with the solution (14 days later.....)

« Last Edit: March 30, 2015, 07:53:30 am by Buzzkill-THABB »

  • Print