Version: 1.0.7, by Andreas
Developer Last Online: Jan 2023
Version: 3.5.3
Rating:
Released: 08-11-2005
Last Update: 02-17-2006
Installs: 633
DB Changes Uses Plugins Template Edits
Additional Files Is in Beta Stage
No support by the author.
vBookie
Introduction
This is a Port of the original vBookie Hack created by tdjrico; full credits to him for the idea and the kind permission to port his work
A t t e n t i o n
This Hack is unsopported and incompatible with vBulletin 3.6+
You are hereby advised to not use it.
Please do not ask me about support and/or updates - there will be none.
function vbookie_get_user_cash()
{
global $vbulletin;
switch ($vbulletin->options['vbookiecash'])
{
case 'vcash':
$cash = (int)$vbulletin->userinfo['vbookie_cash'];
break;
case 'ucash':
$cash = (int)$vbulletin->userinfo['ucash'];
break;
case 'ebux':
$cash = (int)$vbulletin->userinfo['vbbux'];
break;
case 'custom':
($hook = vBulletinHook::fetch_hook('vbookie_get_user_cash')) ? eval($hook) : false;
}
return $cash;
}
function vbookie_take_user_cash($amount)
{
global $vbulletin;
switch ($vbulletin->options['vbookiecash'])
{
case 'vcash':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET vbookie_cash=vbookie_cash-$amount WHERE userid=" . $vbulletin->userinfo['userid']);
break;
case 'ucash':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET ucash=ucash-$amount WHERE userid=" . $vbulletin->userinfo['userid']);
break;
case 'ebux':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET vbbux=vbbux-$amount WHERE userid=" . $vbulletin->userinfo['userid']);
$cash = (int)$vbulletin->userinfo['ebux'];
break;
case 'custom':
($hook = vBulletinHook::fetch_hook('vbookie_take_user_cash')) ? eval($hook) : false;
}
}
function vbookie_give_user_cash($userid, $amount)
{
global $vbulletin;
switch ($vbulletin->options['vbookiecash'])
{
case 'vcash':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET vbookie_cash=vbookie_cash+$amount WHERE userid=$userid");
break;
case 'ucash':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET ucash=ucash+$amount WHERE userid=$userid");
break;
case 'ebux':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET vbbux=vbbux+$amount WHERE userid=$userid");
$cash = (int)$vbulletin->userinfo['vbbux'];
break;
case 'custom':
($hook = vBulletinHook::fetch_hook('vbookie_give_user_cash')) ? eval($hook) : false;
}
}
function vbookie_abandon_event($item_id=0)
{
global $vbulletin;
if ((int)$item_id)
{
$q = "UPDATE ". TABLE_PREFIX . "vbookie_items SET item_status='ABANDONED' WHERE item_id=$item_id";
$vbulletin->db->query($q);
// update running totals
$q = "UPDATE " . TABLE_PREFIX . "vbookie_item_options SET option_amount_staked=0, option_n_bets_placed=0 WHERE item_id=$item_id";
$vbulletin->db->query($q);
// update running totals
$q = "UPDATE " . TABLE_PREFIX . "vbookie_items SET item_n_bets_placed=0, item_amount_staked=0 WHERE item_id=$item_id";
$vbulletin->db->query($q);
$result = $vbulletin->db->query_read("SELECT p.userid, p.bet_amount_placed FROM " . TABLE_PREFIX . "vbookie_bets_placed AS p LEFT JOIN " . TABLE_PREFIX . "user AS u ON(u.userid = p.userid) WHERE p.item_id=$item_id");
while ($bet = $vbulletin->db->fetch_array($result))
{
// pay the money back
vbookie_give_user_cash($bet['userid'], $bet['bet_amount_placed']);
}
}
}
function vbookie_get_richest()
{
global $vbulletin;
switch ($vbulletin->options['vbookiecash'])
{
case 'vcash':
$q = "SELECT username, vbookie_cash AS cash FROM " . TABLE_PREFIX . "user ORDER BY cash DESC LIMIT 5";
break;
case 'ucash':
$q = "SELECT username, ucash AS cash FROM " . TABLE_PREFIX . "user ORDER BY cash DESC LIMIT 5";
break;
case 'ebux':
$q = "SELECT username, vbbux AS cash FROM " . TABLE_PREFIX . "user ORDER BY cash DESC LIMIT 5";
break;
case 'custom':
($hook = vBulletinHook::fetch_hook('vbookie_get_richest')) ? eval($hook) : false;
}
return $vbulletin->db->query_read($q);
}
function vbookie_do_charity()
{
global $vbulletin;
if ($vbulletin->options['vbookiegivetopoor'])
{
switch ($vbulletin->options['vbookiecash'])
{
case 'vcash':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET vbookie_cash=" . $vbulletin->options['vbookiegivetopoor'] . " WHERE vbookie_cash < " . $vbulletin->options['vbookiegivetopoor']);
break;
case 'ucash':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET ucash=" . $vbulletin->options['vbookiegivetopoor'] . " WHERE ucash < " . $vbulletin->options['vbookiegivetopoor']);
break;
case 'ebux':
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "user SET vbbux=" . $vbulletin->options['vbookiegivetopoor'] . " WHERE vbbux < " . $vbulletin->options['vbookiegivetopoor']);
break;
case 'custom':
($hook = vBulletinHook::fetch_hook('vbookie_do_charity')) ? eval($hook) : false;
}
}
}
function vbookie_delete_event($eventinfo)
{
global $vbulletin;
// if we're deleting an event that has bets on it but hasn't yet been settled,
// we must give people their money back.
if ($eventinfo['item_status'] == 'OPEN' OR $eventinfo['item_status'] == 'CLOSED')
{
// abandon the bet
vbookie_abandon_event($eventinfo['item_id']);
}
$vbulletin->db->query_write("DELETE FROM ". TABLE_PREFIX . "vbookie_bets_placed WHERE item_id=$eventinfo[item_id]");
$vbulletin->db->query_write("DELETE FROM ". TABLE_PREFIX . "vbookie_item_options WHERE item_id=$eventinfo[item_id]");
$vbulletin->db->query_write("DELETE FROM ". TABLE_PREFIX . "vbookie_items WHERE item_id=$eventinfo[item_id]");
// update the thread this was attached to to remove the event.
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "thread SET vbookie_item_id=0 WHERE vbookie_item_id=$eventinfo[item_id]");
}
?>
this has probably been covered but in a thread with 150 pages of replies, and the terrible search engine vb has I can't find this answer.
I've got everything working, except changing the dates of the lines opening. I can't edit or set either. does this make sense? I need to stop an event on aug 1 but it stays at the date i made the event at 1am.
Any updates on the progress of the rewrite of this script. I really want to use this... but I want a stable version.
Out of curiosity.... does anyone with 3.8.3 installed have it working while using these instructions? https://vborg.vbsupport.ru/showpost....postcount=2152. If so, are these the ONLY instructions necessary needed to get this to work on 3.8.3?