ULX

Author Topic: tsay  (Read 3328 times)

0 Members and 4 Guests are viewing this topic.

Offline giraff

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
tsay
« on: April 03, 2015, 10:45:16 AM »


How to make a display of the player's name?

Code: [Select]
------------------------------ Tsay ------------------------------
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 XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: tsay
« Reply #1 on: April 03, 2015, 11:17:31 AM »
Are you trying to make a whole new command? Like just a tsay name command?

Offline giraff

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: tsay
« Reply #2 on: April 03, 2015, 11:22:21 AM »
I need to add a nickname to the text

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: tsay
« Reply #3 on: April 03, 2015, 11:36:08 AM »
if you type @@<name> then it will show up in chat

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: tsay
« Reply #4 on: April 03, 2015, 11:37:52 AM »
I see what you mean.... you can replace the line at ULib.tsay() with this


ULib.tsay( _, calling_ply.." Said: "..message )

Offline giraff

  • Newbie
  • *
  • Posts: 3
  • Karma: 0
Re: tsay
« Reply #5 on: April 03, 2015, 11:50:35 AM »
In a chat, nothing appears

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: tsay
« Reply #6 on: April 03, 2015, 12:48:13 PM »
In a chat, nothing appears


whats the error

Ok so overall are you looking to just have the tsay say:

"XxLMM13xXgaming said: message"

???

Offline allofmywutsteam

  • Full Member
  • ***
  • Posts: 136
  • Karma: 3
  • MNWO Owner
    • MNWO Discord
Re: tsay
« Reply #7 on: April 03, 2015, 03:37:54 PM »

whats the error

Ok so overall are you looking to just have the tsay say:

"XxLMM13xXgaming said: message"

???

Seems so. This is actually a pretty good idea this way these anonymous messages can be quoted by a particular player despite it not being directly in chat.
"Then Jesus said to his disciples, 'Whoever wants to be my disciple must deny themselves and take up their cross and follow me.'" - Matthew 16:24



MNWO: Steam | Discord | Website | Join Server

Offline Zmaster

  • Full Member
  • ***
  • Posts: 235
  • Karma: 25
Re: tsay
« Reply #8 on: April 03, 2015, 03:41:27 PM »
Small mistake in what XxLMM13xX told you to do

calling_ply is a player and can't be printed into the chat, what you want is to grab the name of the player
ULib.tsay( calling_ply, calling_ply:Name().." Said: "..message )
I also changed the _ to calling_ply since _ is not the player variable

You could also use calling_ply:Nick() since Name() and Nick() do the exact same thing

Offline XxLMM13xX

  • Sr. Member
  • ****
  • Posts: 265
  • Karma: -51
  • New to lua development
    • Twitch
Re: tsay
« Reply #9 on: April 03, 2015, 04:23:56 PM »
Small mistake in what XxLMM13xX told you to do

calling_ply is a player and can't be printed into the chat, what you want is to grab the name of the player
ULib.tsay( calling_ply, calling_ply:Name().." Said: "..message )
I also changed the _ to calling_ply since _ is not the player variable

You could also use calling_ply:Nick() since Name() and Nick() do the exact same thing

I totaly forgot about this... Lol thanks!