Jump to content
MakeWebGames

50/50 help please


Newbie
 Share

Recommended Posts

Ok iam having trouble with this one its been converted from redux everything is showing up fine but when i enter my bet it says You are trying to bet more than you have iam not to sure but i think theres a line of code missing to check your crystals but cant seem to figure it out really ennoying me now any help would be good

 

<?php

include "globals.php";
global $h,$ir;
//original mod by mark mascola August 11, 2011
if(isset($_POST['match']) && is_numeric($_POST['match'])){

$q=$db->query("SELECT * FROM fifty WHERE bet_id = {$_POST['match']}");
$r = $db->fetch_row($q);
$win = floor($r['wager']*(1.8));
  if($ir['second'] < $r['wager']){
     echo"<br />You are trying to bet more than you have";
     $h->endpage();
     exit;
  }elseif($ir['userid'] == $r['bettor']){
     echo"<br />You cannot match your own bets";
     $h->endpage();
     exit;
  }else{
     $db->query("UPDATE users SET second = second - {$r['wager']} WHERE userid={$ir['userid']}");
     $j=rand(1,2);
     if($j==1){//the winner is the original bettor
     $db->query("UPDATE users SET second = second + ".$win." WHERE userid = {$r['bettor']}");
     event_add($r['bettor'], "You won your 50/50 bet of ".$r['wager']." points and earned ".floor($r['wager']*(1.8))." points!");
     event_add($ir['userid'], "You lost your 50/50 bet of ".$r['wager']." points.");
     }
     if($j==2){//the winner is the matcher
     $db->query("UPDATE users SET second = second + ".$win." WHERE userid = {$ir['userid']}");
     event_add($r['bettor'], "You lost your 50/50 bet of ".$r['wager']." points.");
     event_add($ir['userid'], "You won your 50/50 bet of ".$r['wager']." points and earned ".floor($r['wager']*(1.8))." points");
     }
  //need to add events to both the bettor and the taker.. need to delete the bet and update  players with points
  $db->query("DELETE FROM fifty WHERE bet_id = {$r['bet_id']}");
  }
}
if(isset($_POST['points']) && is_numeric($_POST['points'])){
  if($_POST['points'] < 10){
  echo "<br />You are not betting enough";
  $h->endpage();
  exit;
  }
  elseif($_POST['points'] > 5000){
  echo "<br />You are trying to bet too much";
  $h->endpage();
  exit;
  }
  elseif($ir['second'] < $_POST['points']){
     echo "<br />You are trying to bet more than you have";
     $h->endpage();
     exit;
  }
  else{
     $db->query("UPDATE users SET `second` = `second` - {$_POST['points']} where userid={$userid}");
     $db->query("INSERT INTO fifty VALUES('',{$ir['userid']},{$_POST['points']},unix_timestamp())");
  }
}
echo"<h2>50/50 Points Game</h2>";
echo"<p>The rules are simple.<br /> 2 players wager the same bet, the winner gets 90% of the pot. The house keeps 10%</p>";
echo"<p>The maximum bet is 5000 points but you may wager more than once.</p>";
echo "<p>
     <form method='post'>
        <input type='text' name='points' size='8' maxlength='7'> points (10-5000)<br /><br />
        <input type='submit' name='bet' value='Place Bet'>
     </form>
    </p>
    <h3>Awaiting Bets</h3>
  <p>
   <table width='90%'>
    <tr>
     <th><b>Mobster</b></td>
     <th><b>Points</b></td>
     <th><b>Bet Age</b></td>
     <th align='center'><b>Bet</b></td>
    </tr>";
  $q = $db->query("SELECT f.*,u.username FROM fifty f LEFT JOIN users u ON f.bettor = u.userid ORDER BY bet_id ASC");
  while($r = $db->fetch_row($q)) {
  echo"<tr>";
  echo"<td>".$r['username']."</td>";
  echo"<td>".$r['wager']."</td>";
  echo"<td>".DateTime_Parse($r['bet_time'])."</td>";
  echo "<td><form method='post'>";
  echo"<input type='hidden' name='match' value='".$r['bet_id']."' /><input type='submit' value='Match Bet'></form></td>";
  echo"</tr>";
  }   
  echo"</table></p>";   

?>
Link to comment
Share on other sites

It seems like the mod is not checking the crystals.. Instead of crystals the author has written the word second..

Like this:

if($ir['second'] < $r['wager']){

echo"You are trying to bet more than you have";

$h->endpage();

exit;

Line 11, 12, 13 and 14

That thing says if second is less than the bet the message you are shown will be shown.. Download the file, then in your editor panel edit all places it says second to saying crystals..

Link to comment
Share on other sites

It seems like the mod is not checking the crystals.. Instead of crystals the author has written the word second..

Like this:

if($ir['second'] < $r['wager']){

echo"You are trying to bet more than you have";

$h->endpage();

exit;

Line 11, 12, 13 and 14

That thing says if second is less than the bet the message you are shown will be shown.. Download the file, then in your editor panel edit all places it says second to saying crystals..

Thanks all this time i been trying to select it from db and it was simple as that oh ended up with another error on like 80 but i just removed the date from it

I think it said second because the mod was from redux but i converted it to v2 just need to remeber that for next time i see a redux mod :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...