Skip to content

Instantly share code, notes, and snippets.

@andreblue
Last active February 13, 2018 01:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save andreblue/276025e5a4c8119c8d732119475c6253 to your computer and use it in GitHub Desktop.
Save andreblue/276025e5a4c8119c8d732119475c6253 to your computer and use it in GitHub Desktop.
--Put me in darkrp_modules/advert_revert/sh_advert_revert.lua for it to work!!!!
timer.Simple( 30, function()
DarkRP.addPhrase('en', 'advert', '[Advert]')
local billboardfunction = DarkRP.getChatCommand("advert")
billboardfunction = billboardfunction['callback']
DarkRP.removeChatCommand("advert")
--From darkrp before the update to remove this. Check the commits
local function PlayerAdvertise(ply, args)
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)
--[[
LICENSE
You are free to modify and distribute this, but you must keep all names of anyone whom has done an edit.
Orignal Author: Andreblue
]]
@cj2tech
Copy link

cj2tech commented Jun 27, 2016

why 30 for timer.simple. And [Advert] before players name isn't yellow.

@NanoAi
Copy link

NanoAi commented Dec 5, 2016

Why even use a timer? I'm sure 30 seconds is more then enough time but this could still cause issues with updates, load order etc...

You can easily use the loadCustomDarkRPItems hook instead.
Maybe even throw in a 1 second timer to make sure that this gets ran last (to avoid conflicts for future proofing).

@DrGreenTea
Copy link

DrGreenTea commented Feb 13, 2018

Somehow it doesnt work on my Server.

I put the file into server/garrysmod/addons/darkrpmodification/lua/darkrp_modules/advert_revert

like it says at the top of the file. Yes, of Course I use DarkRP, and the Server is currently using pretty much the latest Version of DarkRP (https://github.com/FPtje/DarkRP).

It still puts in a billboard if you do /advert message

Can you help me with that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment