Advertisement
Guest User

Untitled

a guest
Oct 6th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.41 KB | None | 0 0
  1. <?php                
  2. /*      
  3.  
  4. Coinflip v1.0
  5.  
  6. Usage:
  7.     !coinflip [points]
  8.  
  9. Command:
  10.     $overwritefile("C:\xampp\htdocs\ankhbot\coinflip.txt","")
  11.     $readapi(http://localhost:8080/ankhbot/coinflip.php?input=$dummyormsg&user=$user)
  12.     $readline(C:\xampp\htdocs\ankhbot\coinflip.txt)
  13.  
  14. */
  15.  
  16. if (isset($_GET['input']) && isset($_GET['user'])) {
  17.     $input = (int) $_GET['input'];
  18.     $user  = $_GET['user'];  
  19.     $command = '';
  20.     $msg = '';                
  21.  
  22.     if ($input <= 0) {
  23.         $msg .= '/w ' . $user . ' Usage: !coinflip <points> (min: 1)';
  24.     } else {
  25.         // Remove the bet from the user.                        
  26.         $command .= '$removepoints("' . $user . '","' . $input . '","' . $input . '","","/w ' . $user . ' You do not have ' . $input . ' points. FeelsBadMan","false")';              
  27.  
  28.         if (mt_rand(0, 1) == 1) {
  29.             // Player wins.
  30.             $msg .= $user . ' won the coin flip and got ' . $input . ' points! PogChamp';
  31.            
  32.             $command .= '$addpoints("' . $user . '","' . $input*2 . '","' . $input*2 . '","","")';
  33.         } else {
  34.             // Player lose.
  35.             $msg .= $user . ' lost the coin flip and lost ' . $input . ' points! BibleThump';            
  36.         }
  37.     }
  38.  
  39.     $file = "coinflip.txt";
  40.     $fh   = fopen($file, 'w');
  41.     $fw   = fwrite($fh, $command . $msg . PHP_EOL);
  42.     fclose($fh);                
  43. }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement