Skip to content

Instantly share code, notes, and snippets.

@na-stewart
Created November 11, 2024 19:47
Show Gist options
  • Save na-stewart/bb51c262611fa925a2fc136f1043f421 to your computer and use it in GitHub Desktop.
Save na-stewart/bb51c262611fa925a2fc136f1043f421 to your computer and use it in GitHub Desktop.
Garry's Mod SAM advert command.
if SAM_LOADED then return end
local sam, command, language = sam, sam.command, sam.language
command.set_category("Advert")
sam.command.new("tsay")
:SetPermission("tsay", "trialstaff")
:Help("This will put a message in chat everyone will be able to see.")
:GetRestArgs(true)
:AddArg("text")
:OnExecute(function(calling_ply, targets)
net.Start("Announce")
net.WriteString(targets)
net.Broadcast()
end)
:End()
if SERVER then
util.AddNetworkString("Announce")
else
net.Receive("Announce", function()
chat.AddText(Color(255, 0, 0), "[All]: ", Color(255, 255, 255), net.ReadString())
end)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment