ULX

Author Topic: Hello need some general help.  (Read 2704 times)

0 Members and 2 Guests are viewing this topic.

Offline tw

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Hello need some general help.
« on: April 28, 2016, 06:21:46 PM »
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.

Offline roastchicken

  • Respected Community Member
  • Sr. Member
  • *****
  • Posts: 476
  • Karma: 84
  • I write code
Re: Hello need some general help.
« Reply #1 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.
Give a man some code and you help him for a day; teach a man to code and you help him for a lifetime.

Offline tw

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Hello need some general help.
« Reply #2 on: April 28, 2016, 08:42:19 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.
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