Post Your Helpful Scripts

Hello ya’ll.
This thread is a place to post all your useful code snippets. From convenience functions to libraries to full weapon bases. The point is to help people.

Try to follow a format like this:

Name: FadeTo
Description: Fades one color to another based on a percent.
Code:
[LUA]
function FadeTo(col1, col2, perc)
return Color( col1.r+(perc/100*(col2.r-col1.r)), col1.g+(perc/100*(col2.g-col1.g)), col1.b+(perc/100*(col2.b-col1.b)), col1.a+(perc/100*(col2.a-col1.a)) )
end
[/LUA]
Example:
[LUA]
ply:SetColor(FadeTo(Color(0,255,0,255), Color(255,0,0,255), ply:Health()) --Fades the player’s color from green to red based on their HP.
[/LUA]

Post away! I know you guys have made some useful stuff over the years. Make yourself useful to everyone else, too!