Ulysses

General => Developers Corner => Topic started by: StaTiiKxKALEB on May 15, 2016, 10:08:16 AM

Title: Not sure why ULib.tsayColor is not working.
Post by: StaTiiKxKALEB 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." )
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: Bytewave 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, ...) (http://ulyssesmod.net/docs/files/lua/ulib/shared/messages-lua.html#tsayColor) only takes one player as an argument, not a table of players.
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: iViscosity 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).
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: StaTiiKxKALEB 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().
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: iViscosity 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?
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: StaTiiKxKALEB 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.
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: Buzzkill 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)
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: StaTiiKxKALEB on May 16, 2016, 05:18:15 AM
Whenever I try to do it, it just gives this error. (http://puu.sh/oTRp5/9b79d4a2a3.png)
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: MrPresident on May 16, 2016, 07:27:02 AM
Let's see your updated code that is getting you that error.
Title: Re: Not sure why ULib.tsayColor is not working.
Post by: StaTiiKxKALEB 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." )