Spamscript help


/*
Spam Script
Coded by VenomCruster

*/

	local prefix = "[ChatSpammer]"
	
	
concommand.Add("spamchat", function(ply, args)
      local spam = args[1]
	  MsgC(Color(102, 255, 102), (prefix .. "spamming chat with: " .. spam ) )
	  timer.Create( "cool_ticktocker", 0.5, 0, function()
      LocalPlayer():ConCommand("say " .. spam)
end) 
end )
 

--This command will destroy the above timer
concommand.Add("spamchat_stop", function(ply, args)
      timer.Destroy("cool_ticktocker")
end)


	MsgC(Color( 255, 0, 255 ), ( prefix ) )
	MsgC(Color( 255, 255, 255 ,255 ), "Spamscript loaded. 
" )

Suppose to work as this:


spamchat "SPAM"

but instead, once I run the script and enter spamchat, it will spam


s

because of the args[1] bit.

How do I fix this?

Thanks!

The arguments of concommand.Add are; player ( entity ), command ( string ), and arguments ( table )

You are forgetting that your second argument is command, which returns the string of the command the player typed, and not the arguments the player typed in their console. And since you are indexing a string with 1, the first character, you get “s”. Which is the 1st character in your command, “spamchat”

In case you didn’t understand the indexing a string part, you can get a character of a string the same way you can get a value of a table;

lua[1] – returns “o”
("#nice")[3] – returns “i”
("#nice")[1] – returns “#”[/lua]

lolwut, i made that for you (except for the minor edits you made because it wasnt tested).

Anyways, what author said should work.

Right so, how do I get it to work has spamchat “Blah blah”?

If you’re referring to /*
Spam Script
Coded by VenomCruster

*/,
I didn’t post the whole script. There’s a VGUI and that stuff that I coded and implemented.

concommand has 3 arguments; ply, cmd and args
You are using cmd as args

LEL, all I had to do was look more into concommand on the wiki, fixed.

(All I had to do was replace Args with ArgStr XD)