I'll give you a hint: set two variables as you can see here:
Variable[0001] = Player X
Variable[0001] -= This Event XVariable[0002] = Player Y
Variable[0002] -= This Event YVariable[0001] will be lesser than zero if the player comes from the left, greater than zero if it comes from the right;
Variable[0002] will be lesser than zero if the player comes from above, greater than zero if it comes from below;
Put it in a couple of conditional branches and here you go

I hope this can help, feel free to ask if I wasn't clear enough,
Jens