How to check for spell cast?

i, how do I check for a spell cast ? What I mean exactly is like in spell script check if the player has casted a certain spell like

if(playercastspell == IDofSpell)

or something along those lines

any help is appreciated

When I wanted to do something on a spell cast, I did this, which would probably work, but may not be the best way.