• Chat Spammer
    17 replies, posted
Alright, I was really bored and tried to make a chat spammer. This is what I came up with [code]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) [/code] The thing I can't get to work is args[1] turns into a nil value. Can anyone help.
[code] 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) [/code]
[QUOTE=Drew P. Richard;25460714][code] 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) [/code][/QUOTE] 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. [code] 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) [/code]
[QUOTE=Wizard of Ass;25464601]This won't work either and why would you make it support multiple userid's? It runs clientside anyway...[/QUOTE] 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.
[QUOTE=notRzilla;25468192]That would actually work, would be pointless appending the user id's but it'll work.[/QUOTE] 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.
[QUOTE=Wizard of Ass;25475744]You know that bans are there for a reason?[/QUOTE] 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]
[QUOTE=notRzilla;25485545]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][/QUOTE] You could use a for loop also, I find timers kinda slow ...
[QUOTE=Drew P. Richard;25479698]a[1] will only get the first word entered, refer to the copy I posted using table.concat to get the entire string.[/QUOTE] "my string in quotes" But table.concat is better yes [QUOTE=dingusnin;25503979]You could use a for loop also, I find timers kinda slow ...[/QUOTE] Lol?
[QUOTE=dingusnin;25503979]You could use a for loop also, I find timers kinda slow ...[/QUOTE] 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.
[QUOTE=dingusnin;25503979]You could use a for loop also, I find timers kinda slow ...[/QUOTE] Why not use a while(true) do loop while you're at it? :v:
Thanks for the help guys, now off to hl2land.
[QUOTE=dingusnin;25503979]You could use a for loop also, I find timers kinda slow ...[/QUOTE] You are a troll right?
Sorry, you need to Log In to post a reply to this thread.