Author Topic: Not sure why ULib.tsayColor is not working.  (Read 3019 times)

0 Members and 1 Guest are viewing this topic.

Offline StaTiiKxKALEB

  • Newbie
  • *
  • Posts: 17
  • Karma: 2
Not sure why ULib.tsayColor is not working.
« on: May 15, 2016, 10:08:16 AM »
Any idea why ULib.tsayColor() is not working?

Code: [Select]
function ulx.asay( calling_ply, message )
    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

    ULib.tsayColor( players, false, Color(255,0,0), "(ADMIN CHAT) ", Color(0, 111, 255), calling_ply:Nick(), Color(255,255,255), ": ", message )

end
local asay = ulx.command( CATEGORY_NAME, "ulx asay", ulx.asay, "@", true, true )
asay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
asay:defaultAccess( ULib.ACCESS_ALL )
asay:help( "Send a message to currently connected staff memebers." )

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Not sure why ULib.tsayColor is not working.
« Reply #1 on: May 15, 2016, 10:16:52 AM »
Any idea why ULib.tsayColor() is not working?
For future reference, please explain "not working". It's very hard to fix a problem you know nothing about. Post any and all relevant errors, both client and server, as well as expected vs actual behavior.
What I can tell you is that ULib.tsayColor(Player ply, boolean wait, ...) only takes one player as an argument, not a table of players.
« Last Edit: May 15, 2016, 10:19:24 AM by Bytewave »
bw81@ulysses-forums ~ % whoami
Homepage

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Not sure why ULib.tsayColor is not working.
« Reply #2 on: May 15, 2016, 12:29:56 PM »
Also, why are you trying to make an asay command when there already is one for ULX? If you want to change it, you can just edit the code itself (which I don't really recommend).
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline StaTiiKxKALEB

  • Newbie
  • *
  • Posts: 17
  • Karma: 2
Re: Not sure why ULib.tsayColor is not working.
« Reply #3 on: May 15, 2016, 08:03:53 PM »
Also, why are you trying to make an asay command when there already is one for ULX? If you want to change it, you can just edit the code itself (which I don't really recommend).
I'm not making my own, it's an edited version of it. I want it to have set colors and for "(Staff Chat)" to be red, etc, what's in the tsayColor().

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Re: Not sure why ULib.tsayColor is not working.
« Reply #4 on: May 15, 2016, 08:15:23 PM »
I'm not making my own, it's an edited version of it. I want it to have set colors and for "(Staff Chat)" to be red, etc, what's in the tsayColor().

I see. What do you mean by "not working", though? What errors are you getting?
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline StaTiiKxKALEB

  • Newbie
  • *
  • Posts: 17
  • Karma: 2
Re: Not sure why ULib.tsayColor is not working.
« Reply #5 on: May 15, 2016, 08:40:38 PM »
I see. What do you mean by "not working", though? What errors are you getting?
I'm not getting any messages after I use the command, I think it's because of what "Bytewave" said earlier about it not accepting a table.

Offline Buzzkill

  • Respected Community Member
  • Full Member
  • *****
  • Posts: 176
  • Karma: 59
    • The Hundred Acre Bloodbath
Re: Not sure why ULib.tsayColor is not working.
« Reply #6 on: May 15, 2016, 10:00:58 PM »
Yeah, it is.   Move the tsay into the loop and change the check from negative to positive for asay privs and you should be fine.  (ie, do a tsay for each asay listener)

Offline StaTiiKxKALEB

  • Newbie
  • *
  • Posts: 17
  • Karma: 2
Re: Not sure why ULib.tsayColor is not working.
« Reply #7 on: May 16, 2016, 05:18:15 AM »
Whenever I try to do it, it just gives this error.

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2728
  • Karma: 430
    • |G4P| Gman4President
Re: Not sure why ULib.tsayColor is not working.
« Reply #8 on: May 16, 2016, 07:27:02 AM »
Let's see your updated code that is getting you that error.

Offline StaTiiKxKALEB

  • Newbie
  • *
  • Posts: 17
  • Karma: 2
Re: Not sure why ULib.tsayColor is not working.
« Reply #9 on: May 16, 2016, 07:45:28 AM »
Let's see your updated code that is getting you that error.

I fixed it.
Code: [Select]
function ulx.asay( calling_ply, message )
    local players = player.GetAll()
    for i=1, #players do
        local v = players[ i ]
        if ULib.ucl.query( v, seeasayAccess ) or v == calling_ply then -- Calling player always gets to see the echo
            ULib.tsayColor( v, false, Color(255,0,0), "(ADMIN CHAT) ", Color(0, 111, 255), calling_ply:Nick(), Color(255,255,255), ": ", message )
        end
    end               
end
local asay = ulx.command( CATEGORY_NAME, "ulx asay", ulx.asay, "@", true, true )
asay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
asay:defaultAccess( ULib.ACCESS_ALL )
asay:help( "Send a message to currently connected staff memebers." )
« Last Edit: May 16, 2016, 07:51:42 AM by StaTiiKxKALEB »