Ulysses
General => Developers Corner => Topic started by: StaTiiKxKALEB on May 15, 2016, 10:08:16 AM
-
Any idea why ULib.tsayColor() is not working?
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." )
-
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.
-
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).
-
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().
-
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 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.
-
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)
-
Whenever I try to do it, it just gives this error. (http://puu.sh/oTRp5/9b79d4a2a3.png)
-
Let's see your updated code that is getting you that error.
-
Let's see your updated code that is getting you that error.
I fixed it. 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." )