Dices Mod , Max Bet Limit (solved)

  Post new topicReply to topicPrintable Version
<< View previous topic View next topic >>
Share: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
#1   Dices Mod , Max Bet Limit (solved)
jaded
CZ Newbie
Gender: Female
Status: Offline
Joined: Nov 13, 2003
0.00 posts per day
Posts: 8
Points: 502
   
I am using the dices mod. I need to know how to set a "max bet" limit on this. People are taking advantage of the mod terribly. I have looked in the files and cannot find a function for limiting the bet. Please let me know if there is something I can do.
Thank you in advance icon_razz.gif


With the help of a friend we figured this out ourselves.
Here are the files you can use in place of your own if you dont want your members abusing your point system.


Dices.php file
<?php
/***************************************************************************
*                                dices.php
*                            -------------------
*   Version              : 0.1.0
*   began                : September 03, 2003
*   email                : Unlisted
*   forums               : http://www.vcgn.com/forum/
*
***************************************************************************/

/***************************************************************************
*
*   copyright (C) 2003  tHe_LiNk
*
*   This program is free software; you can redistribute it and/or
*   modify it under the terms of the GNU General Public License
*   as published by the Free Software Foundation; either version 2
*   of the License, or (at your option) any later version.
*
*   This program is distributed in the hope that it will be useful,
*   but WITHOUT ANY WARRANTY; without even the implied warranty of
*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
*   GNU General Public License for more details.
*
*   http://www.gnu.org/copyleft/gpl.html
*
***************************************************************************/

if (!eregi("modules.php", $_SERVER['PHP_SELF'])) {
    die ("You can't access this file directly...");
}


define('IN_PHPBB', true);
$phpbb_root_path = 'modules/Forums/';
include($phpbb_root_path.'extension.inc');
include($phpbb_root_path.'common.'.$phpEx);
require("modules/Forums/nukebb.php");

//
// Start session management
//
$userdata = session_pagestart($user_ip, PAGE_DICES, $nukeuser);
init_userprefs($userdata);

//
// End session management
//
include( 'language/lang_' . $board_config['default_lang'] . '/lang_dices.' . $phpEx);

if ( !$userdata['session_logged_in'] )
{
   $redirect = "dices.$phpEx";
   $redirect .= ( isset($user_id) ) ? '&user_id=' . $user_id : '';
   header('Location: ' . append_sid("login.$phpEx?redirect=$redirect", true));
}

// START GAME
$page_title = 'Dices';
$maxbet = 25;
if (!$_POST['bet'])
   {
      $rules = $lang['Dices_Rules'];
      $main = $rules;
      $dicechoose = $lang['Dices_Choose'];
      $diceplay = $lang['Dices_Play'];
      $dicebet = $lang['Dices_Bet'];
      $betchoose = '
      <form method="POST">
      <b>' . $dicechoose . '</b>
      <br />
      1<input type="radio" name="R1" value="1" checked> ;; ;;
      2<input type="radio" name="R1" value="2"> ;; ;;
      3<input type="radio" name="R1" value="3"> ;; ;;
      4<input type="radio" name="R1" value="4"> ;; ;;
      5<input type="radio" name="R1" value="5"> ;; ;;
      6<input type="radio" name="R1" value="6">
      <br />
      <br />
      <b>' . $dicebet . '</b><input type="text" name="bet" value="5">
      <br />
      <br />
      <input type="submit" name="play" value="' . $diceplay . '">
      </form>';
      $stats = $betchoose;
      
   }
   else
   {
   if ( !is_numeric($_POST['bet']) )
   {
      message_die(GENERAL_MESSAGE, $lang['Dices_Err_Values']);
   }
//added by sting
   if ($_POST['bet'] > $maxbet)
   {
      message_die(GENERAL_MESSAGE, $lang['Dices_Err_MaxBet']);
   }
   if ($_POST['bet'] > $userdata['user_points'])
   {
      message_die(GENERAL_MESSAGE, $lang['Dices_Err_Golds']);
   }

   $winpos = rand(1, 6);
   $betwin = round($_POST['bet'] * 6);
   $togive = $betwin + $userdata['user_points'];
   $totake = $userdata['user_points'] - round($_POST['bet']);
   $diceballot = $lang['Dices_Ballot'];
   $diceretry = $lang['Dices_Retry'];
   $stats = '<a href="' . append_sid("dices.".$phpEx) . '" class="nav">' . $diceretry . '</a>';

   if ($winpos == $_POST['R1'])
   {
      $main = $diceballot . $winpos . $lang['Dices_Win'] . $betwin . ' ' . $board_config['points_name'] . $lang['Dices_Leaves'] . $togive . '!';
      $sql = "UPDATE " . USERS_TABLE . " SET user_points='$togive' WHERE user_id='{$userdata['user_id']}'";
      if ( !($usresult = $db->sql_query($sql)) )
      {
         message_die(GENERAL_MESSAGE, $lang['Dices_Err_Points']);
      }
   }
   else
   {
      $main = $diceballot . $winpos . $lang['Dices_Lose'] . $_POST['bet'] . ' ' . $board_config['points_name'] . $lang['Dices_Leaves'] . $totake . '!';
      $sql = "UPDATE " . USERS_TABLE . " SET user_points='$totake' WHERE user_id='{$userdata['user_id']}'";
      if ( !($usresult = $db->sql_query($sql)) )
      {
         message_die(GENERAL_MESSAGE, $lang['Dices_Err_Points']);
      }
   }
}

// END GAME

// Includes

include('includes/page_header.php');

   $template->assign_vars(array(
      'L_MAIN' => $main,
      'L_MISC' => $stats,
      'L_DICES' => $lang['Dices'],

   ));
   $template->assign_block_vars('', array());
      $template->set_filenames(array(
         'body' => 'dices_body.tpl')
   );


// Generate page
$template->pparse('body');

include('includes/page_tail.php');

?>


and here is lang_dices.php

<?php

$lang['Dices_Rules'] = 'Dices! Just bet, choose a number and play! If you get the number you win your bet multiplied 6 times, otherwhise you\'ll lose the bet!<br /><br />';
$lang['Dices_Choose'] = 'Choose a number between 1 and 6:';
$lang['Dices_Play'] = '>> PLAY <<';
$lang['Dices_Bet'] = 'Your bet ';
$lang['Dices_Ballot'] = 'Number drawn ';
$lang['Dices_Win'] = '<br /><br />Congratulations, you win ';
$lang['Dices_Lose'] = '<br /><br />Aww, bad luck. You hit a bad number! You lose ';
$lang['Dices_Leaves'] = 's.<br />Now you have ';
$lang['Dices_Retry'] = 'Try again?';

$lang['Dices_Stats'] = 'Temp';
$lang['Dices_Stats'] = 'Temp';

// Errors
$lang['Dices_Err_Values'] = 'You can only bet values';
$lang['Dices_Err_Golds'] = 'You do not have that amount';
$lang['Dices_Err_Points'] = 'Fatal Error Getting Points Information!';
$lang['Dices_Err_MaxBet'] = 'Sorry, Maximum Bet is 25';

?>



Back to top Reply with quote
#2   re: Dices Mod , Max Bet Limit (solved)
Telli
Site Admin
Occupation: Self Employed
Age: 46
Gender: Male
Fav. Sports Team: Detroit Red Wings
Website:
Status: Offline
Joined: May 26, 2003
1.03 posts per day
Posts: 8089
Points: 494,430
   
Hi Jaded I never realized you could bet so much with the game till I lost 5000 points trying it earlier. Anyways thanks for the quick fix but I went ahead and made an admin panel for it so you configure the max bet points and also close the game tempararily if you wish.
[ Register or login to view links on this board. ]




_________________
The path of the righteous man is beset on all sides by the inequities of the selfish and the tyranny of evil men. Blessed is he, who in the name of charity and good will, shepherds the weak through the valley of darkness, for he is truly his brother's keeper and the finder of lost children. And I will strike down upon thee with great vengeance and furious anger those who would attempt to poison and destroy my brothers. And you will know my name is the Lord when I lay my vengeance upon thee. Ezekiel 25:17
Back to top Reply with quote
#3   re: Dices Mod , Max Bet Limit (solved)
jaded
CZ Newbie
Gender: Female
Status: Offline
Joined: Nov 13, 2003
0.00 posts per day
Posts: 8
Points: 502
   
Thank you telli. We noticed a huge problem when someone was winning 20,000 points with it at a time icon_rolleyes.gif People should know better then to take advantage. I will download your changes now too. icon_razz.gif



Back to top Reply with quote
Display posts from previous:      
Add To: Del.icio.us  Digg  Google  Spurl  Blink  Furl  Y! MyWeb  
<< View previous topic View next topic >>
Post new topicReply to topic

Jump to 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum