Part one - DRY - Don't Repeat Yourself
Often times the scripter will find that they have to rewrite the same script times after times after times. This is a bad technique because most scripting languages including lua does a more efficient job if you let it index the memory that it needs dynamically rather then creating them time after time. In this case, Refactor. Not only will it bring the number of lines of code that you need down in the long run, it also gives lua a chance to index only what it needs to. Remember, lua has extremely efficient conditionals (Ifs, Fors, and Whiles) so don't be afraid to use them in abundant numbers if you have to.
REFACTOR - Taking repetitive code out of the source and define it as it's own function/class.
For example, take the following script
1
2
3
4
5
6
7
2
3
4
5
6
7
function hook_say(p, text) 	word = {} 	for v, word_ in ipairs(text:gmatch("[^%s]+")) do 		word[v] = word_ 	end 	msg("Your Command is "..word[1]) end
It's okay to leave it like that if you don't need to have the text split into the individual words again. However, if you need to have another hook that also needs to split the text, then you're much better off using the following script.
1
2
3
4
5
6
7
2
3
4
5
6
7
function split(t) 	word = {} 	for v, word_ in ipairs(t:gmatch("[^%s]+")) do 		word[v] = word_ 	end 	return word end
By taking out a part of the logic out from the main function and putting it into a subfunction, you allow that piece of logic to be reused. This is
1) Faster and easier for the scripter
and
2) Faster for Lua and CS2D
If you're prone to be the type to write your own server scripts, you'll be amazed at how much time such a simple measure can help you.