Well, obviously there is no single function that would magically put distraction puzzle in your game (although that is unfortunate

).
I'll try to give some advice.
First, you should break the scene you want to implement into set of basic actions. I mean, write this on paper, like:
1. Character speaks to the old dealer;
2. If character sais the right thing, old dealer gets away.
3. Count X seconds till dealer returns.
4. When X seconds pass, make dealer come back and stand on his place.
5. If the character tries to steal something while dealer is on his place, then dealer warns him or something.
6. If character tries to steal while dealer is in the back room, he succeeds.
You see, you should think similar way when you implement puzzles.
Now, when you have a set of actions and events, think how you will make every one of them one by one.
You should perhaps learn, how to make characters move, talk, etc first; make some basic experiments.
If there's something you can't figure out, then ask again
