General > Developers Corner

Advert Color

<< < (2/2)

BlueNova:
Gonna attempt at this, I think it's at least close so pls no judge :)

ULib.tsayColor


--- Code: ---ULib.tsayColor( v, 1, team.GetColor(calling_ply:Team()), "[Advert] ", team.GetColor(calling_ply:Team()), calling_ply:Nick(), Color( 255, 255, 0 ), ": ", message )
--- End code ---

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: ---    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

--- End code ---

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


--- Code: ---    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

--- End code ---

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

Cucuy Gaming:

--- Quote from: BlueNova 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: ---ULib.tsayColor( v, 1, team.GetColor(calling_ply:Team()), "[Advert] ", team.GetColor(calling_ply:Team()), calling_ply:Nick(), Color( 255, 255, 0 ), ": ", message )
--- End code ---

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: ---    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

--- End code ---

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


--- Code: ---    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

--- End code ---

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

--- End quote ---
So will this appear globally and only to players nearby?

BlueNova:
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.

Cucuy Gaming:

--- Quote from: BlueNova 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.

--- End quote ---

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

JamminR:

--- Quote from: Cucuy Gaming on February 02, 2017, 10:09:10 PM ---I'm Kind of new with coding, so how would I set this up?

--- End quote ---
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

Navigation

[0] Message Index

[*] Previous page

Go to full version