1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Sign up for news, events and more!

    You're currently visiting the official DarkRP Forums as a guest. Sign up now to participate in our community and we'll let you know when we have news.

Release Classic Advert

Discussion in 'DarkRP Addon & Plugin Releases' started by Fillipuster, Jun 23, 2016.

  1. Sir Klutch

    Sir Klutch Active Member

  2. UniquePumpkin

    UniquePumpkin New Member

    Oh my GOD ive been looking all over the internet and this one fucking works. Thank jesus. Thanks a lot man!!
     
  3. Fetty Awp

    Fetty Awp New Member

  4. Sir Klutch

    Sir Klutch Active Member

    lua/autorun
    Code (Lua):

    timer.Simple(2, function()
        if not DarkRP then
            return
        end

        local billboardfunction
        DarkRP.addPhrase('en', 'advert', '[Advert]')
        DarkRP.removeChatCommand("advert")

        local function PlayerAdvertise(ply, args)
            billboardfunction = DarkRP.getChatCommand("advert")
            billboardfunction = billboardfunction['callback']

            if args == "" then
                DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))

                return ""
            end

            local DoSay = function(text)
                if text == "" then
                    DarkRP.notify(ply, 1, 4, DarkRP.getPhrase("invalid_x", "argument", ""))

                    return
                end

                for k, v in pairs(player.GetAll()) do
                    local col = team.GetColor(ply:Team())
                    DarkRP.talkToPerson(v, col, DarkRP.getPhrase("advert") .. " " .. ply:Nick(), Color(255, 255, 0, 255), text, ply)
                end
            end

            return args, DoSay
        end

        DarkRP.declareChatCommand{
            command = "billboard",
            description = "Create a billboard holding an advertisement.",
            delay = 1.5
        }

        DarkRP.declareChatCommand{
            command = "advert",
            description = "Advertise something to everyone in the server.",
            delay = 1.5
        }

        if SERVER then
            DarkRP.defineChatCommand("advert", PlayerAdvertise, 1.5)
            DarkRP.defineChatCommand("billboard", billboardfunction)
        end
    end)
     
     
  5. Claims

    Claims New Member

    Yep I wanted that from the start, but never had time to demand that :eek: I'm sorry for taking the freedom but you said in file we can change it as we liked :D

    For everyone else that dont have time to demand, I can upload the modify here. You can also just coping this code into "sv_advert.lua" Or download the attached rar files.

    PHP:
    function playerAdvert( ply, args )
        if args == "" then
            ply:SendLua( string.format( [[notification.AddLegacy( "%s", 1, 5 )
                surface.PlaySound( "buttons/button15.wav" )]], CLASSICADVERT.failMessage ) )
        else
            if ply:canAfford(CLASSICADVERT.Cost) then
                ply:addMoney(-CLASSICADVERT.Cost)
                ply:SendLua( string.format( [[notification.AddLegacy( "This advert costed you %s.", 1, 5 )]], DarkRP.formatMoney(CLASSICADVERT.Cost) ))
                for k,pl in pairs( player.GetAll() ) do
                    local senderColor = team.GetColor( ply:Team() )
                    DarkRP.talkToPerson( pl, senderColor, CLASSICADVERT.chatPrefix.." "..ply:Nick(), CLASSICADVERT.advertTextColor, args, ply )
                end
            else
                ply:SendLua( string.format( [[notification.AddLegacy( "You need at least %s to make an advert.", 1, 5 )
                surface.PlaySound( "buttons/button15.wav" )]], DarkRP.formatMoney(CLASSICADVERT.Cost) ))
            end
            return ""
        end
    end
    DarkRP.defineChatCommand( CLASSICADVERT.chatCommand, playerAdvert )
    And this code in "sh_config.lua"


    PHP:

    --[[-------------------------------------------------------------------------
    You are free to use, distribute and change this module, as long as you keep
    this text here - and/or credit me:
    Made by Fillipuster :D
    ---------------------------------------------------------------------------]]
    CLASSICADVERT = CLASSICADVERT or {}
    --[[-------------------------------------------------------------------------
                        CLASSIC ADVERT CONFIG
    ---------------------------------------------------------------------------]]
    -- The prefix before the adverted text (but after the sending player's name).
    CLASSICADVERT.chatPrefix = "[Advert]"
    -- The color of the text in the advert (Originally yellow).
    CLASSICADVERT.advertTextColor = Color( 255, 255, 0, 255 )
    -- The failure message id the players fails to provide text for the advert.
    CLASSICADVERT.failMessage = "You need to provide text for your advert."
    -- The chat command for adverts. (A "/" is added at the front automatically.)
    CLASSICADVERT.chatCommand = "advert" -- Please, do not use "/advert" as it is used for the new advert system in DarkRP.
    -- The F1 (help menu) description of the advert command.
    CLASSICADVERT.commandDescription = "Message all players on the server."
    -- The delay (in seconds) between players being able to advert.
    CLASSICADVERT.commandDelay = 3
    -- How much it should cost to make an advert.
    CLASSICADVERT.Cost = 1500
    --[[-------------------------------------------------------------------------
                        END OF CONFIG
    ---------------------------------------------------------------------------]]
    DarkRP.declareChatCommand{
        command = CLASSICADVERT.chatCommand,
        description = CLASSICADVERT.commandDescription,
        delay = CLASSICADVERT.commandDelay
    }
    Also created this into admin advert, just download the attached and use /aadvert, this will only target admin.
     

    Attached Files:

  6. Sane4K

    Sane4K New Member

    thanks
     

Share This Page