• Print

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

0 Members and 1 Guest 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." )


Offline Caustic Soda-Senpai

  • Sr. Member
  • ****
  • Posts: 469
  • Karma: 54
  • <Insert something clever here>
    • Steam Page
Re: Hello need some general help.
« Reply #3 on: April 28, 2016, 11:38:39 pm »
Code: Lua
  1. local tsay = ulx.command( CATEGORY_NAME, "ulx comms", ulx.comms, "!comms", true, true )
  2. tsay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  3. tsay:defaultAccess( ULib.ACCESS_ALL )
  4. tsay:help( "Send a message through comms." )

Everytime you see "tsay", change it to "comms"
Once you get to know me, you'll find you'll have never met me at all.

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Hello need some general help.
« Reply #4 on: April 29, 2016, 10:28:17 am »
Code: Lua
  1. local tsay = ulx.command( CATEGORY_NAME, "ulx comms", ulx.comms, "!comms", true, true )
  2. tsay:addParam{ type=ULib.cmds.StringArg, hint="message", ULib.cmds.takeRestOfLine }
  3. tsay:defaultAccess( ULib.ACCESS_ALL )
  4. tsay:help( "Send a message through comms." )

Everytime you see "tsay", change it to "comms"
That shouldn't matter save for readability's sake. tsay is just a local variable, confined only to the scope of the file. The real command data is (presumably) stored in some registry somewhere by ULX.

OP, what exactly do you face in terms of issues? Do you get any errors that could be relevant? Or does it just not work?
bw81@ulysses-forums ~ % whoami
Homepage

Offline tw

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: Hello need some general help.
« Reply #5 on: April 29, 2016, 01:07:34 pm »
That shouldn't matter save for readability's sake. tsay is just a local variable, confined only to the scope of the file. The real command data is (presumably) stored in some registry somewhere by ULX.

OP, what exactly do you face in terms of issues? Do you get any errors that could be relevant? Or does it just not work?

It just doesn't work at all. I'll get the errors in a sec.

  • Print