turn OnMouseDrag on and off

another beginner question. I have an object that i'm dragging with the mouse pointer.. I want it so that after a while if a certain variable is true, the object cannot be dragged again by the player.. It seems easy but for some reason I can't get it to work.. I basically want to turn off the OnMouseDrag function after a certain time but I'm not exactly sure how to do that... any help would be greatly appreciated..

You can use an "If" condition inside.

var IcanDrag : boolean;
function yourFunction (){
if(IcanDrag)
{
...
}
}

funcion SomeOtherFunction()
{
Condition changes;
IcanDrag = false;
}

Post the code to get a better answer.