• Print

Author Topic: Advert Color  (Read 8297 times)

0 Members and 1 Guest are viewing this topic.

Offline Cucuy Gaming

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Advert Color
« on: February 01, 2017, 08:49:10 pm »
I have recently made it so adverts only display to players nearby, but I don't know how to make the message display in yellow.

For an Example:  I want this to display in yellow [Advert]  also I want the message in yellow.

Plz tell how to make this thank you.

Here's the code:
Code: Lua
  1. local function playerAdvert( ply, args )
  2. local DoSay = function(text)
  3.  
  4.     if text == "" then
  5.  
  6.         DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
  7.             return ""
  8.         end
  9.                    
  10.             DarkRP.talkToRange(ply, CLASSICADVERT.chatPrefix.." "..ply:Nick(), text, 550)
  11.           end
  12.           return args, DoSay
  13. end
  14. DarkRP.defineChatCommand( CLASSICADVERT.chatCommand, playerAdvert, 1.5 )

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: Advert Color
« Reply #1 on: February 01, 2017, 08:58:20 pm »
Perhaps do this...

Code: [Select]
DarkRP.talkToRange(ply, CLASSICADVERT.chatPrefix.." "..ply:Nick(), Color(255, 255, 0), text, 550)
Just something off the top of my head.

Offline Cucuy Gaming

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Re: Advert Color
« Reply #2 on: February 02, 2017, 08:54:50 pm »
Perhaps do this...

Code: [Select]
DarkRP.talkToRange(ply, CLASSICADVERT.chatPrefix.." "..ply:Nick(), Color(255, 255, 0), text, 550)
Just something off the top of my head.

Nvm It Didn't Work I keep Getting This Error.

[DarkRP] gamemodes/darkrp/gamemode/modules/base/sv_util.lua:49: bad argument #2 to 'FindInSphere' (number expected, got string)
  1. FindInSphere - [C]:-1
   2. talkToRange - gamemodes/darkrp/gamemode/modules/base/sv_util.lua:49
    3. DoSayFunc - addons/darkrpmodification-master/lua/darkrp_modules/fp_classicadvert/sv_advert.lua:10
     4. Run - gamemodes/darkrp/gamemode/modules/chat/sv_chat.lua:150
      5. func - addons/atlaschat/lua/atlaschat/init.lua:647
       6. unknown - lua/includes/extensions/net.lua:32
 

Offline MrPresident

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 2727
  • Karma: 430
    • |G4P| Gman4President
Re: Advert Color
« Reply #3 on: February 02, 2017, 09:43:13 pm »
It doesn't look like that DarkRP function can take colors as arguments.

http://wiki.darkrp.com/index.php/Functions/DarkRP/Server/talkToRange

You might need to make your own advert command to replace the darkRP on, you could use ULib.tsayColor

http://ulyssesmod.net/docs/files/lua/ulib/shared/messages-lua.html#tsayColor

Offline Cucuy Gaming

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Re: Advert Color
« Reply #4 on: February 02, 2017, 10:09:10 pm »
It doesn't look like that DarkRP function can take colors as arguments.

http://wiki.darkrp.com/index.php/Functions/DarkRP/Server/talkToRange

You might need to make your own advert command to replace the darkRP on, you could use ULib.tsayColor

http://ulyssesmod.net/docs/files/lua/ulib/shared/messages-lua.html#tsayColor

I'm Kind of new with coding, so how would I set this up?

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: Advert Color
« Reply #5 on: February 02, 2017, 11:01:03 pm »
Gonna attempt at this, I think it's at least close so pls no judge :)

ULib.tsayColor

Code: [Select]
ULib.tsayColor( v, 1, team.GetColor(calling_ply:Team()), "[Advert] ", team.GetColor(calling_ply:Team()), calling_ply:Nick(), Color( 255, 255, 0 ), ": ", message )
I know I may have gone a bit overboard with the team.GetColor() but eh whatever

Something I did notice. Not sure if it effects anything.

In your little code square here you forget an 'else'

You go like this...
Code: [Select]
    if text == "" then
 
        DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return ""
        end
                   
            DarkRP.talkToRange(ply, CLASSICADVERT.chatPrefix.." "..ply:Nick(), text, 550)
          end
          return args, DoSay

Now I'm still kind of a noob/novice myself so this isn't from a "mastery" perspective but you could try this...

Code: [Select]
    if text == "" then
 
        DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return ""
    else
                   
            DarkRP.talkToRange(ply, CLASSICADVERT.chatPrefix.." "..ply:Nick(), text, 550)
     end
          return args, DoSay

Just something that caught my eye. Can't say for certain if it's your issue but can't hurt to try.


Offline Cucuy Gaming

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Re: Advert Color
« Reply #6 on: February 03, 2017, 08:31:39 am »
Gonna attempt at this, I think it's at least close so pls no judge :)

ULib.tsayColor

Code: [Select]
ULib.tsayColor( v, 1, team.GetColor(calling_ply:Team()), "[Advert] ", team.GetColor(calling_ply:Team()), calling_ply:Nick(), Color( 255, 255, 0 ), ": ", message )
I know I may have gone a bit overboard with the team.GetColor() but eh whatever

Something I did notice. Not sure if it effects anything.

In your little code square here you forget an 'else'

You go like this...
Code: [Select]
    if text == "" then
 
        DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return ""
        end
                   
            DarkRP.talkToRange(ply, CLASSICADVERT.chatPrefix.." "..ply:Nick(), text, 550)
          end
          return args, DoSay

Now I'm still kind of a noob/novice myself so this isn't from a "mastery" perspective but you could try this...

Code: [Select]
    if text == "" then
 
        DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))
            return ""
    else
                   
            DarkRP.talkToRange(ply, CLASSICADVERT.chatPrefix.." "..ply:Nick(), text, 550)
     end
          return args, DoSay

Just something that caught my eye. Can't say for certain if it's your issue but can't hurt to try.
So will this appear globally and only to players nearby?

Offline BlueNova

  • Full Member
  • ***
  • Posts: 113
  • Karma: 13
  • The most powerful force in the universe.
Re: Advert Color
« Reply #7 on: February 03, 2017, 04:11:19 pm »
Well firstly I'm not sure what you mean by "globally and nearby", if it appears globally then everyone can see it. If it only appears to those nearby then it's not really global.

Anyways, I'm not entirely sure. I'm a bit inexperienced with toying with DarkRP so I can't say for sure. It was just something I noticed in your little snippet there.

Offline Cucuy Gaming

  • Newbie
  • *
  • Posts: 9
  • Karma: 0
Re: Advert Color
« Reply #8 on: February 03, 2017, 04:14:17 pm »
Well firstly I'm not sure what you mean by "globally and nearby", if it appears globally then everyone can see it. If it only appears to those nearby then it's not really global.

Anyways, I'm not entirely sure. I'm a bit inexperienced with toying with DarkRP so I can't say for sure. It was just something I noticed in your little snippet there.

Yea That's What I meant. Also The Advert Works Fine I Just Want A Way To Have Say To Only Players as if It's Just a Yell. But Have It's [Advert] Yellow
« Last Edit: February 03, 2017, 04:31:10 pm by Cucuy Gaming »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Advert Color
« Reply #9 on: February 05, 2017, 07:07:44 pm »
I'm Kind of new with coding, so how would I set this up?
As MrPresident says previously, you'll have to create your own.
I'd recommend finding the DarkRP function where ever it stores its sourcecode (there's a git site I think), find the talktoRange function, and basically copy, modify, and rename it in your own addon file to your own.
You should be able to see how it works once you look at it for range and text distance, then find a way to replace it's chattext or whatever it uses to print to players screens with the same basic idea using a colorized version, including but not limited to using the tsayColor of ULib.

EDIT - line 48 of sv_util.lua
https://github.com/FPtje/DarkRP/blob/master/gamemode/modules/base/sv_util.lua#L48
From the code, looks like you could EASILY replace the r,g,b of text 255,255,255 with whatever yellow rgb combo you wanted.
Create a function talktoRange_Yellow and go from there. (or any other function name you wanted, advert_yellow, etc).
I'd strongly recommend using whatever modules/custom addons system DarkRP recommends though, not modifying original code.
I'm not familiar with what DarkRP recommends, but, as in custom stuff for ULX, we recommend /addons/my_addon/lua/ulx/modules/...your_files_for_custom_ulxstuff
« Last Edit: February 05, 2017, 07:18:10 pm by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print