General > Developers Corner
Hello need some general help.
tw:
Hi, so I was looking to create a chat command such as the ones defaulting in the DarkRP gamemode, such as /advert.
I was looking to make something similar to it but using /comms or !comms.
Like when they do the command, it'll look something like this in chat
!comms testing 123 -> [Comms] *name*: testing 123
Any help is appreciated. I've attempted to reuse the "tsay" ulx command and edit it to my likings, but no luck.
roastchicken:
Can you tell us (maybe show us the code of) what you tried and why it didn't work? We might be able to assist you with any road blocks you encountered.
tw:
--- Quote from: roastchicken on April 28, 2016, 08:11:15 PM ---Can you tell us (maybe show us the code of) what you tried and why it didn't work? We might be able to assist you with any road blocks you encountered.
--- End quote ---
I mainly copied off the command below and got this:
function ulx.comms( calling_ply, message )
ULib.comms( _, message )
if util.tobool( GetConVarNumber( "ulx_logChat" ) ) then
ulx.logString( string.format( "(comms from %s) %s", calling_ply:IsValid() and calling_ply:Nick() or "Console", message ) )
end
end
local tsay = ulx.command( CATEGORY_NAME, "ulx comms", ulx.comms, "!comms", true, true )
tsay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
tsay:defaultAccess( ULib.ACCESS_ALL )
tsay:help( "Send a message through comms." )
and used this as reference.
function ulx.tsay( calling_ply, message )
ULib.tsay( _, message )
if util.tobool( GetConVarNumber( "ulx_logChat" ) ) then
ulx.logString( string.format( "(tsay from %s) %s", calling_ply:IsValid() and calling_ply:Nick() or "Console", message ) )
end
end
local tsay = ulx.command( CATEGORY_NAME, "ulx tsay", ulx.tsay, "@@", true, true )
tsay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
tsay:defaultAccess( ULib.ACCESS_ADMIN )
tsay:help( "Send a message to everyone in the chat box." )
An Error Has Occurred!
array_keys(): Argument #1 ($array) must be of type array, null given
[0] Board index
Go to full version