If shortly, you open a text editor and write stuff that eventually does something.
If a bit more detailed, you create functions and attach hooks to them (if we're talking about CS2D), they get you information and you can use it in scripts. Finally, you add commands which make stuff you want to happen.
Pretty sure that useigor's links will come in handy.
the best way to start is probably just to look at a well-written script that's small. id probably recommend one of engineers scripts, if any of them are actually small. lol