How to send ether to smart contract and then upon meeting a certain condition distribute the ether?

For instance,
Take ether means basically that
Player 1 and 2 are willing to bet and giving the smart contract their own ether from their address
To bet upon a certain condition (I am using Oraclize to fetch the result)
And then upon getting the result of the condition
Smart contract send back ether
To player 2 or player 1

If you need any more clarification feel free to message over here

Environment -> Truffle, metamask and web3 (local environment with ethereum bridge to connect with Oraclize)

I only want to know how the above thing is possible, if you can share code or how to implement this it would be very much helpful

(example: “player 1 sends ether to smart contract, later the smart contract sends ether to player2 when event X occur”. something like this)
As discussed in youtube chat section => continuing from here

Thank you

Interesting question. Giving a full implementation would be too time consuming, but here is the idea:

contract Bet {
   function createBet(uint betAmount, uint questionCount) external {
     //player 1 or 2 create bet
     //bet has an id
   function joinBet(uint id, uint questionNumber) external {
     //player 1 or 2 join a bet, and send ether. need to make sure than enough ether was sent.

   function reportResult() external {
     //the oracle report result (which answer is correct), and smart contract send ether to player 1 or player 2

You can look at Gnosis if you want something more complete. I will show how to use it in the upcoming DeFi course on EatTheBlocks youtube channel.