Last active
February 13, 2018 01:45
-
-
Save andreblue/276025e5a4c8119c8d732119475c6253 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--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 | |
]] |
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).
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
why 30 for timer.simple. And [Advert] before players name isn't yellow.