Admin Broadcast

Trying to make an admin broadcast, for admins to quickly get their message accross (and so every player knows an admin IS an admin) on a DarkRP server.
In the main.lua, I’ve added:


local function AdminAdvertise(ply, args)
	if args == "" then return "" end
        ***<Not sure what to add here to make only admins be able to say this>***
	local DoSay = function(text)
		if text == "" then return end
		for k,v in pairs(player.GetAll()) do
			local col = team.GetColor(ply:Team())
			GAMEMODE:TalkToPerson(v, col, "[Admin Broadcast] " ..ply:Nick(), Color(255, 0, 0,255), text, ply)
		end
	end
	return args, DoSay
end
AddChatCommand("/adminbroadcast", AdminBroadcast)

if not ply:IsAdmin() then return “” end

Didn’t work - everyone can still use /adminbroadcast.

make it run a check on the person’s steam id, if they have that steam id etc they can use it.


local function AdminAdvertise( ply )
	if args == "" then return "" end

	if !ply:IsAdmin() then 
		GAMEMODE:Notify(ply, 1, 4, "Only administrators can use this command.");
		return ""
	end

	local DoSay = function(text)
		if text == "" then return "" end
		for k,v in pairs(player.GetAll()) do
			local col = team.GetColor(ply:Team())
			GAMEMODE:TalkToPerson(v, col, "[Admin Broadcast] " ..ply:Nick(), Color(255, 0, 0,255), text, ply)
		end
	end
	return args, DoSay

end
AddChatCommand("/adminbroadcast", AdminAdvertise)

That should work.

Yes it works

Thanks man! :smiley:

Thanks buddy :slight_smile: