ULX

Author Topic: ULX Admin Chat  (Read 6672 times)

0 Members and 1 Guest are viewing this topic.

Offline Darkblizzard

  • Newbie
  • *
  • Posts: 39
  • Karma: 1
ULX Admin Chat
« on: July 15, 2017, 12:46:40 AM »
Hello!
I'm currently trying to edit a small portion of the admin chat though unsure the correct way of editing a line of code. The code with format =  "[Admin Request] #P: #s" is what I'm trying to edit. I'm trying to make the part the says "[Admin Request]" have a specific color to it while the rest stays the same.
 
Code: [Select]
function ulx.asay( 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 =  "[Admin Request] #P: #s"
    end

    local players = player.GetAll()
    for i=#players, 1, -1 do
        local v = players[ i ]
        if not ULib.ucl.query( v, seeasayAccess ) 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

I've attempted of doing this, but of course it doesn't work. Would anyone have the solution of getting what I want to work?
Thanks

Code: [Select]
format =  Color( 0, 255, 0, 255 ), "[Admin Request] ", .. "#P: #s"

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: ULX Admin Chat
« Reply #1 on: July 15, 2017, 01:05:33 AM »
I do not believe fancyLogAdmin accepts colours as an argument, so if anything you'd need to use ULib.tsayColor in order to send it to the players.

As a side note, it's never really a good idea to edit core files of any addon, because you might screw something up and then the whole addon breaks, and even if you don't you'll have to edit it the next time an update comes out as your files will be overwritten.

With that being said, you could always use the ULibCommandCalled hook to stop the default action from being taken and to execute your own code.
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline Darkblizzard

  • Newbie
  • *
  • Posts: 39
  • Karma: 1
Re: ULX Admin Chat
« Reply #2 on: July 15, 2017, 10:05:38 AM »
I may need some help finishing this code. I'm not quite sure how to grab the message once it found that command is used.

Code: [Select]
hook.Add( ULibCommandCalled, admin chat replace, function( ply, commandName, args)
local col = Color(255, 255, 255, 255), "[Admin Request] "
if commandName == "ulx asay" then

return col .. ply .. " "

end
end )
« Last Edit: July 15, 2017, 10:09:28 AM by Darkblizzard »

Offline monkeymacman

  • Newbie
  • *
  • Posts: 44
  • Karma: 13
Re: ULX Admin Chat
« Reply #3 on: July 15, 2017, 11:44:08 AM »
I may need some help finishing this code. I'm not quite sure how to grab the message once it found that command is used.

Code: [Select]
hook.Add( ULibCommandCalled, admin chat replace, function( ply, commandName, args)
   local col = Color(255, 255, 255, 255), "[Admin Request] "
   if commandName == "ulx asay" then
   
   return col .. ply .. " "

   end
end )
You did the hook.Add wrong, look more into it on the wiki. As for for the actual command, message = args[1] (probably), and mostly just follow the actual code that ULX has for the command, but replace the fancylog with whatever you want to use to send it, and add whatever thing

Offline Darkblizzard

  • Newbie
  • *
  • Posts: 39
  • Karma: 1
Re: ULX Admin Chat
« Reply #4 on: July 15, 2017, 06:15:52 PM »
Sorry, slightly new to lua so still learning. I fixed the hook finding the problem already. Now as for the "message = args[1]", I'd assume that's a global variable, but not quite sure what the "args[1]" would define? I'm also thinking ahead to wondering how I could send the message to only those with the permission to see asay.
« Last Edit: July 15, 2017, 06:33:57 PM by Darkblizzard »

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given