Attempting to edit some ULX commands in order to make then clear and easy to use, instead of 'ulx psay' for example.
Im trying to edit the name that appears on the menu, but also the command used in chat to perform it.
Ive so far managed to edit the name that appears, but this throws everything out and the command no longer works and throws errors.
[B]This is the original command code[/B]
[CODE]local seeasayAccess = "ulx seeasay"
if SERVER then ULib.ucl.registerAccess( seeasayAccess, ULib.ACCESS_OPERATOR, "Ability to see 'ulx asay'", "Other" ) end -- Give operators access to see asays echoes by default
function ulx.asay( calling_ply, message )
local format
local me = "/me "
if message:sub( 1, me:len() ) == me then
format = "(ADMINS) *** #P " .. message:sub( me:len() + 1 )
else
format = "#P to admins: " .. message
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 )
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 admins." )[/CODE]
This is the one I changed, I only changed the bit italicized. This renamed it on the menu, but like I mentioned, the command no longer works.
[CODE]local seeasayAccess = "ulx seeasay"
if SERVER then ULib.ucl.registerAccess( seeasayAccess, ULib.ACCESS_OPERATOR, "Ability to see 'ulx asay'", "Other" ) end -- Give operators access to see asays echoes by default
function ulx.asay( calling_ply, message )
local format
local me = "/me "
if message:sub( 1, me:len() ) == me then
format = "(ADMINS) *** #P " .. message:sub( me:len() + 1 )
else
format = "#P to admins: " .. message
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 )
end
local asay = ulx.command( CATEGORY_NAME, "[I]Admin Chat[/I]", 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 admins." )[/CODE]
If anyone can assist, and also example how I can change the actual chat command as well that would be great.
I hardly ever touched ULX but the command you have there is set to react on "@", therefore for it to work, you'd need to "@/me text" or something like that. It's not that hard to look up ulx.command on the ULX documentation and see what the arguments are named.
[url]https://github.com/Nayruden/Ulysses/blob/425ca8b6ae7ce01d3a91bcd9e4f6443819dbb54e/ulx/lua/ulx/sh_base.lua#L41[/url]
[QUOTE=khuba;41633712]I hardly ever touched ULX but the command you have there is set to react on "@", therefore for it to work, you'd need to "@/me text" or something like that. It's not that hard to look up ulx.command on the ULX documentation and see what the arguments are named.
[url]https://github.com/Nayruden/Ulysses/blob/425ca8b6ae7ce01d3a91bcd9e4f6443819dbb54e/ulx/lua/ulx/sh_base.lua#L41[/url][/QUOTE]
I understood what the arguments were but when changing them it throws everything off, this leads me to assume the old name is being used elsewhere and I need to change it there too but Im not sure exactly.
The chat command is defined by the fourth argument of the ulx.command function.
[lua]local asay = ulx.command( CATEGORY_NAME, "<i>Admin Chat</i>", ulx.asay, "@", true, true )[/lua]
should be therefore changed to
[lua]local asay = ulx.command( CATEGORY_NAME, "<i>Admin Chat</i>", ulx.asay, "/me", true, false )[/lua]
See how I changed the "@" into "/me"?
You may have noticed I also changed the last argument from "true" to "false". It's the "nospace" argument. Most ULX commands work like "!command[b]•space•[/b]argument", but the asay command is different and used like "@text", without the space separating the chat command and the argument. Setting the last argument to "true" enables the "no-space" behaviour. If you want "/metext" to work, set it back to true
Ok the issue with the command if fixed and fine.
My issues now is that changing
[CODE]local asay = ulx.command( CATEGORY_NAME, "ulx asay", ulx.asay, "@", true, true )[/CODE]
To
[CODE]local asay = ulx.command( CATEGORY_NAME, "Admin Chat", ulx.asay, "@", true, true )[/CODE]
In order to change the name of it that appears in menu, results in the command no longer working. I dont know what else Ive got to change to get it to link up.
[B]EDIT:[/B]
Ive worked it out!
[CODE]local asay = ulx.command( CATEGORY_NAME, "admin chat", ulx.asay, "@", true, true )[/CODE]
No CAPITALS. Simple really haha.
Sorry, you need to Log In to post a reply to this thread.