Chat Spammer

Alright, I was really bored and tried to make a chat spammer.

This is what I came up with


concommand.Add("spamchat", function(ply,cmd,args)
if not ply.SpamChat then
ply.SpamChat = true
spamness=tostring(args[1])
timer.Create("Spamtime", 0.1,0, RunConsoleCommand("say",spamness))
ply:ChatPrint("Spamming Enabled")
else
ply:ChatPrint("Spamming Disabled")
ply.SpamChat = false
timer.Destroy("Spamtime")
end	
	end)


The thing I can’t get to work is args[1] turns into a nil value. Can anyone help.



concommand.Add("spamchat",function(ply,cmd,args)
	if !ply.SpamChat then
		if !args[1] then return end
		ply.SpamChat = true
		local spam = args[1];
		timer.Create("spamtime_"..ply:UserID(),0.2,0,RunConsoleCommand("say",spam))
		ply:ChatPrint("Spamming Enabled")
	else
		ply:ChatPrint("Spamming Disabled")
		ply.SpamChat = nil
		timer.Destroy("spamtime_"..ply:UserID())
	end
end)


This won’t work either and why would you make it support multiple userid’s? It runs clientside anyway…

Oh fuck I wasn’t paying attention, hahahaha.



concommand.Add("spamchat",function(ply,cmd,args)
	if !SpamChat then
		if !args[1] then return end
		SpamChat = true
		local spam = table.concat(args," ")
		timer.Create("spamtime",0.05,0,function() RunConsoleCommand("say",spam) end)
		LocalPlayer():ChatPrint("Spamming Enabled")
	else
		LocalPlayer():ChatPrint("Spamming Disabled")
		SpamChat = nil
		timer.Destroy("spamtime")
	end
end)


That would actually work, would be pointless appending the user id’s but it’ll work.

It actually wouldn’t work, mainly because of the fact that I put this: RunConsoleCommand(“say”,spam), it wasn’t in a function.

-snip-

rate me bad reading.

You know that bans are there for a reason?

You should calm down, he’s trying to help.

[lua]
concommand.Add(“spamm”, function(p,c,a)
if not( a[1] ) then return end;
local String = tostring(a[1]);
if not( timer.IsTimer(“SpamChat”) ) then
timer.Create(“SpamChat”, 0.1, 0, RunConsoleCommand, “say”, String)
chat.AddText(Color(0,255,0), “Spamm Enabled”)
else
timer.Destroy(“SpamChat”)
chat.AddText(Color(255,0,0), “Spamm Disabled”)
end
end)

– spamm “You’re all cunts”
[/lua]

a[1] will only get the first word entered, refer to the copy I posted using table.concat to get the entire string.

You know some people actually like people who help them rather then people who just bitch in their thread.

@Averice, as Drew said use table.concat on your ‘arguments’ table;

[lua]
concommand.Add(“spamm”, function(p,c,a)
if not( a[1] ) then return end;
local String = table.concat(a, " ") or “”;
if not( timer.IsTimer(“SpamChat”) ) then
timer.Create(“SpamChat”, 0.1, 0, RunConsoleCommand, “say”, String)
chat.AddText(Color(0,255,0), “Spamm Enabled”)
else
timer.Destroy(“SpamChat”)
chat.AddText(Color(255,0,0), “Spamm Disabled”)
end
end)
[/lua]

You could use a for loop also, I find timers kinda slow …

“my string in quotes” But table.concat is better yes

Lol?

Someone obsiviously should go back to the wiki and read some more.

Also threads like this one should just be deleted for goods, it makes the whole lua section look like a place for skiddies… which is pretty sad because there are many good coders around here.

Why not use a while(true) do loop while you’re at it? :v:

Thanks for the help guys, now off to hl2land.

You are a troll right?