Advert addon?

Hi there, Im looking for an Advert addon, like in ulx one after some seconds it showing up a message to all players.
Searched already garrysmod.org, facepunch trough, (even if the search function is disabled now)
If someone know or can code a standalone simple advertising addon, would be pretty awesome.
I need it for the server to advert tutorials / forum of the server.
Thanks :smiley:

Why dont you look at either ULX or ASSMod’s code?

Let me get you a script to do this. Just a second.

been 40 minutes now, so I’ll reply.

Taken directly from DarkRP “hints.lua”



local hints = {}
table.insert(hints, "You can be arrested for buying or owning an illegal weapon!")
table.insert(hints, "Type /sleep to fall asleep.")
table.insert(hints, "You may own a handgun, but use it only in self defence.")
table.insert(hints, "All weapons can NOT shoot unless you see through the sight post!")
table.insert(hints, "If you are a cop, do your job properly or you could get demoted.")
table.insert(hints, "Type /buyshipment <Weapon name> to buy a shipment of weapons (e.g: /buyshipment ak47).")
table.insert(hints, "Type /buy <Pistol name/item name> to buy a pistol, e.g: /buy glock.")
table.insert(hints, "Type /buyammo <Ammo type> to buy ammo. Ammo types are: [rifle | shotgun | pistol]")
table.insert(hints, "Type /buyhealth to refill your health to 100%")
table.insert(hints, "Press F1 to see RP help.")
table.insert(hints, "If you get arrested, don't worry - you will be auto unarrested in 120 seconds.")
table.insert(hints, "If you are a chief or admin, type /jailpos or /addjail to set the positions of the first (and extra) jails.")
table.insert(hints, "You will be teleported to jail if you get arrested!")
table.insert(hints, "If you're a cop and see someone with an illegal weapon, arrest them.")
table.insert(hints, "Type /sleep to fall asleep.")
table.insert(hints, "Your money and RP name are saved by the server.")
table.insert(hints, "Type /buyhealth to refil your health to 100%")
table.insert(hints, "Type /buydruglab to buy a druglab. be sure you sell your drugs!")
table.insert(hints, "Press F2 or reload with keys to open the keys menu")
table.insert(hints, "You will be teleported to a jail if you get arrested!")
table.insert(hints, "Type /price <Price> while looking at a druglab,  Gun Lab or a Microwave to set the customer purchase price.")
table.insert(hints, "Type /warrant [Nick|SteamID|UserID] to get a search warrant for a player.")
table.insert(hints, "Type /wanted or /unwanted [Nick|SteamID|UserID] to set a player as wanted/unwanted by the Police.")
table.insert(hints, "Type /drop to drop the weapon you are holding.")
table.insert(hints, "Type /gangster to become a Gangster.")
table.insert(hints, "Type /mobboss to become a mob boss.")
table.insert(hints, "Type /buymicrowave to buy a Microwave Oven that spawns food.")
table.insert(hints, "Type /dropmoney <Amount> to drop a money amount.")
table.insert(hints, "Type /buymoneyprinter to buy a Money Printer. Costs " .. CUR .. GetGlobalInt("mprintercost"))
table.insert(hints, "Type /medic - To become a Medic.")
table.insert(hints, "Type /gundealer - To become a Gun Dealer.")
table.insert(hints, "Type /buygunlab - to buy a Gun Lab.")
table.insert(hints, "Type /cook - to become a Cook.")
table.insert(hints, "Type /cophelp to see what you need to do as a cop.")
table.insert(hints, "Type /buyfood <Type> (e.g: /buyfood melon)")
table.insert(hints, "Type /rpname <Name> to choose your roleplay name.")

local function GiveHint()
	if CfgVars["advertisements"] ~= 1 then return end
	local text = hints[math.random(1, #hints)]

	for k,v in pairs(player.GetAll()) do
		TalkToPerson(v, Color(150,150,150,150), text)
	end
end

timer.Create("hints", 60, 0, GiveHint)


Modify it to your likings.

TalkToPerson is defined in DarkRP.

[editline]11:49AM[/editline]

http://www.garrysmod.org/img/?t=dll&id=86780


function TalkToPerson(receiver, col1, text1, col2, text2, sender)
	umsg.Start("DarkRP_Chat", receiver)
		umsg.Short(col1.r)
		umsg.Short(col1.g)
		umsg.Short(col1.b)
		umsg.String(text1)
		if sender then
			umsg.Entity(sender)
		end
		if col2 and text2 then
			umsg.Short(col2.r)
			umsg.Short(col2.g)
			umsg.Short(col2.b)
			umsg.String(text2)
		end
	umsg.End()
end


The usermessage hook is still missing. It generally isn’t a good idea to cut little bits out of a gamemode, normally you have to cut out more than you actually need to get it to work.

:psyberger:

[lua]
timer.Create(“chat”, 30, 0, function()
for k,v in pairs(player.GetAll()) do
v:ChatPrint(“YOUR ADVERT HERE”)
end
end)
[/lua]

This is simple, but you can easily change it :D.

Oh, and it won’t work.

[editline]04:34PM[/editline]

Fixed:

[lua]
timer.Create(“chat”, 30, 0, function()
for k,v in pairs( player.GetAll() ) do
v:ChatPrint(“YOUR ADVERT HERE”)
end
end )
[/lua]

Woops. :slight_smile:

Thanks, It could not be simpler! :smiley: