It worked

thnx
Happens to me too.Sometimes bet stop working.u can see bet panel but it dont wok.Needs aseco restart.Happens daily.
thats just normal, for each transfer the server does, the receipient gets the full amount but the server pays the taxes.david_jumper wrote: and another question:
Does the Server pay nadeo taxes? Since I have this plugin, ther server coppers are getting lost very fast......
Code: Select all
<?php
/********************************************************************************************************
* Betting plugin for XAseco *
* Made by Vineeth *
* Version: v0.3.5 *
* Thanks to Xymph for answering my questions :) and racers on my server for helping me test the plugin *
* Server url : tmtp://#join=vineeth_server *
* Styled by Nouseforname aka RookieNouse *
********************************************************************************************************/
//Aseco::addChatCommand('bet', 'Bet coppers on the map'); //place the bet and start accepting others for the bet
//Aseco::registerEvent('onEndRace','paywinner'); //pay the winner,if there is one
Aseco::addChatCommand('betcan', 'Cancel Bet'); //Only Masteradmin can do this,Just added it,might be helpful sometime
Aseco::registerEvent('onBillUpdated', 'checktransaction');
Aseco::addChatCommand('beton', 'Enable betting'); //only masteradmin
Aseco::addChatCommand('betoff', 'Disable betting'); //only masteradmin
Aseco::registerEvent('onPlayerManialinkPageAnswer','bet_manialink');
Aseco::addChatCommand('topbets','Top betters');
Aseco::registerEvent('onNewChallenge','betting_manialink');
Aseco::registerEvent('onEndRace','paywin');
global $bcoppers; //coppers bet by the person placing bet-henceforth called the "bet-ter" xD
global $minbet;
global $maxbet;
global $total_win; //total coppers in the jackpot
global $bills;
global $i; //no. of people who have accepted the bet so far
global $bplayer; //the id of the player placing the bet
global $bet_placed; //to check wheter a bet has been placed or not
global $acceptor,$accept; //list of all players who have accepted the bet and contributed to jackpot
global $bills;
global $same_acceptor; // To check is same login is trying to accept again
global $mybillupdated;
global $checkdisable;
global $mybill;
global $disabled;
global $timout;
global $tiout;
global $bet1,$bet2,$bet3,$bet4,$bet5;
global $aclick,$bclick;
////CHANGE VALUES FOR YOUR SERVER ONLY HERE
$bet1 = 20; // betting values to appear on the panels
$bet2 = 50;
$bet3 = 100;
$bet4 = 200;
$bet5 = 500;
$minbet = 5; // change these values for minbet
$maxbet = 500; // and maximum bettable amount
$timout = 45000; //Timeout for the accepting manialink (currently set to 45 secs) ie, like a TIME LIMIT for placing a bet
$tiout = 45000; //timeout for betting manialink (currently set to 30 secs) ie, like a TIME LIMIT for accepting a bet
//// DO NOT CHANGE ANY OTHER VALUE BELOW THIS!!!!!
$bclick = 0;
$aclick = 0;
$bills = array();
$acceptor = array();
$mybillupdated = 0;
$mybill = 0;
$i=0;
$checkdisable = 0;
$accept = 0;
$bill_message=0;
$total_win =0;
$bet_placed=0;
$disabled = 0;
function dis_bet($aseco,$command) {
global $bet_placed,$accept,$disabled;
$disabled = 1;
$bet_placed = 1;
$accept = 1;
}
function ena_bet($aseco,$command) {
global $bet_placed,$accept,$disabled;
$disabled = 0;
$bet_placed = 0;
$accept = 0;
}
function chat_beton($aseco,$command) {
global $bet_placed,$bplayer,$bcoppers,$checkdisable;
global $acceptor,$i,$same_acceptor,$accept,$total_win;
$admin = $command['author'];
if($checkdisable == 1) {
if ($aseco->server->getGame() == 'TMF') {
if ($aseco->server->rights) {
if($aseco->isMasterAdmin($admin)) {
$bet_placed = 0;
$accept = 0;
$msg = "Betting has been enabled by ".$admin->nickname;
$aseco->client->query('ChatSendServerMessage',$msg);
$acceptor = NULL;
$bplayer = NULL;
$bcoppers = NULL;
$i=0;
$total_win = 0;
$same_acceptor = NULL;
$checkdisable = 0;
}
}
}
}
else {
$msg = "Betting is already enabled";
$aseco->client->query('ChatSendServerMessageToLogin',$msg,$admin->login);
}
}
function chat_betoff($aseco,$command) {
global $bet_placed,$bplayer,$bcoppers,$checkdisable;
global $acceptor,$i,$same_acceptor,$accept,$total_win;
$admin = $command['author'];
if ($aseco->server->getGame() == 'TMF') {
if ($aseco->server->rights) {
if($aseco->isMasterAdmin($admin)) {
$bet_placed = 1;
$accept = 1;
$msg = "Betting has been disabled by ".stripColors($admin->nickname) .".Any ongoing bet will be cancelled";
$aseco->client->query('ChatSendServerMessage',$msg);
$acceptor = NULL;
$bplayer = NULL;
$bcoppers = NULL;
$i=0;
$total_win = 0;
$same_acceptor = NULL;
$checkdisable = 1;
}
}
}
}
// betting panel
function betting_manialink($aseco,$command) {
global $timout;
global $bet1,$bet2,$bet3,$bet4,$bet5;
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml.= '<manialinks><manialink id ="1233122"><frame posn="0 36.9 0">';
$xml.= '<quad posn="0 1 0" sizen="21 5." halign="center" valign="center" style="Bgs1InRace" substyle="NavButton" />';
$xml.= '<format textsize="1" style="TextCardSmallScores2" />';
$xml.= '<label posn="0 2.4 0" sizen="18 2" halign="center" valign="center" text="$i$o$F00B$C00e$900t$600 $300C$000o$000p$013p$026e$029r$03Cs"/>';
$xml.= '<label posn="-8.2 0 0" sizen="4 2" halign="center" valign="center" text="$03f$i'.$bet1.'" action="50300"/>';
$xml.= '<label posn="-4.1 0 0" sizen="4 2" halign="center" valign="center" text="$f00$i'.$bet2.'" action="50301"/>';
$xml.= '<label posn="0 0 0" sizen="4 2" halign="center" valign="center" text="$03f$i'.$bet3.'" action="50302"/>';
$xml.= '<label posn="4.1 0 0" sizen="4 2" halign="center" valign="center" text="$f00$i'.$bet4.'" action="50303"/>';
$xml.= '<label posn="8.2 0 0" sizen="4 2" halign="center" valign="center" text="$03f$i'.$bet5.'" action="50304"/>';
$xml.= '<label posn="-6.2 -2.0 0" sizen="8 2." textsize="1" halign="center" valign="center" text="$i$n$s$000S$002t$013y$015l$016e$028d$029 $02Bb$02Cy$03E $03FR$03Fo$24Fo$36Fk$57Fi$78Fe$8AFN$ABFo$CCFu$DEFs$FFFe"/>';
$xml.= '</frame>';
$xml.= '</manialink></manialinks>';
$aseco->client->addCall('SendDisplayManialinkPage', array( $xml, $timout, false));
}
function bet_manialink($aseco,$answer) {
global $acceptor,$i,$aclick,$bclick;
global $bet1,$bet2,$bet3,$bet4,$bet5;
$command = array();
$player = $aseco->server->players->getPlayer($answer[1]);
$command['author'] = $player;
if($player->rights) {
if($answer[2] == 50299) {
if($aclick == 0) {
$xml = '<manialink id="1233120"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPageToLogin', array($player->login,$xml, 0, false));
$xml = '<manialink id="1233121"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPageToLogin', array($player->login,$xml, 0, false));
echo "Accepting manialink Clicked by-> ".$answer[1]."\n";
$aclick = 1;
$same = 0;
for($z=0;$z<$i;$z++) {
if($player->login == $acceptor[$i]->login) {
$same = 1;
}
}
if($same == 0) {
baccept($aseco,$command);
}
else {
$message = "{#error}YOU HAVE ALREADY ACCEPTED THE BET";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $acceptor[$i]->login);
}
}
}
if($bclick == 0) {
if($answer[2] == 50300) {
$bclick = 1;
echo "Betting manialink ".$bet1." clicked-> ".$answer[1]."\n";
$command['params'] = $bet1;
bbet($aseco,$command);
}
if($answer[2] == 50301) {
$bclick = 1;
echo "Betting manialink ".$bet2." clicked-> ".$answer[1]."\n";
$command['params'] = $bet2;
bbet($aseco,$command);
}
if($answer[2] == 50302) {
$bclick = 1;
echo "Betting manialink ".$bet3." clicked-> ".$answer[1]."\n";
$command['params'] = $bet3;
bbet($aseco,$command);
}
if($answer[2] == 50303) {
$bclick = 1;
echo "Betting manialink ".$bet4." clicked-> ".$answer[1]."\n";
$command['params'] = $bet4;
bbet($aseco,$command);
}
if($answer[2] == 50304) {
$bclick = 1;
echo "Betting manialink ".$bet5." clicked-> ".$answer[1]."\n";
$command['params'] = $bet5;
bbet($aseco,$command);
}
}
}
else {
$message = "{#error}You need to own a TMUF account,so buzz off till then! :)";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $acceptor[$i]->login);
}
}
function bbet($aseco,$command){
global $bills, $maxbet,$minbet;
global $bcoppers,$bplayer,$bet_placed;
global $total_win,$mybill,$disabled,$checkdisable;
$bplayer = $command['author'];
$login = $bplayer->login;
if($bet_placed == 0) {
$bcoppers = $command['params'];
if ($aseco->server->getGame() == 'TMF') {
if ($aseco->server->rights) {
if ($bplayer->rights) {
if ($bcoppers != '' && is_numeric($bcoppers)) {
if ($bcoppers >= $minbet && $bcoppers<=$maxbet) {
$total_win = NULL;
$total_win = $bcoppers; //updating total jackpot
$message = "You have placed a bet for ". $bcoppers ." coppers";
$mybill = 1;
$aseco->client->query('SendBill', $login, (int) $bcoppers,$aseco->formatColors($message), '');
$billid = $aseco->client->getResponse();
$bills[$billid] = array($bplayer->login, $bplayer->nickname, $bcoppers);
}
else {
$message = "Minimum amount for placing bet is 5 coppers,Max amount is 250";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
}
}
else {
$message = "Click on one of the betting numbers";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
}
} else
{
$message = formatText($aseco->getChatMessage('UNITED_ONLY'), 'account');
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
}
} else
{
$message = formatText($aseco->getChatMessage('UNITED_ONLY'), 'server');
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
}
} else
{
$message = $aseco->getChatMessage('FOREVER_ONLY');
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
}
}
if($disabled == 1){
$message = "{#error} You cannot bet once the race has begun.Wait for next track to start.";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message),$login);
}
if($checkdisable == 1) {
$message = "{#error} Betting has been disabled by the MasterAdmin/Admin";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message),$login);
}
if($bet_placed == 1) {
if($disabled == 0) {
$message = "{#error} There is already a bet for ".$bcoppers." coppers. Type '/accept' to join in";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message),$login);
}
}
}
function baccept($aseco,$command) {
global $i,$total_win,$mybill,$disabled,$aclick;
global $bcoppers,$bplayer,$bet_placed;
global $acceptor,$accept,$bills,$same_acceptor;
$same_acceptor =0;
if($disabled == 0) {
if($bet_placed == 1) {
if($command['author']->login != $bplayer->login) //checking that the "bet-ter" is not accepting his/her own bet
{
$acceptor[$i] = $command['author'];
$same_acceptor = 0; //variable to check if the person has already accepted the bet before
if($i>0)
{
for($z=0;$z<$i;$z++)
{
if($acceptor[$z]->login == $acceptor[$i]->login) //checking if same person is accepting bet twice
{
$same_acceptor = 1; //setting =1 if same person is accepting again
break;
}
}
}
echo "same_acceptor-> ".$same_acceptor."\n";
if($same_acceptor == 0)
{
if ($aseco->server->getGame() == 'TMF')
{
if ($aseco->server->rights)
{
if ($acceptor[$i]->rights )
{
$accept = 1;
$message = "Do you want to accept ". stripColors($bplayer->nickname) ."'s bet for ". $bcoppers ." coppers";
$mybill = 1;
$aseco->client->query('SendBill', $acceptor[$i]->login, (int) $bcoppers,$aseco->formatColors($message), '');
$billid = $aseco->client->getResponse();
$bills[$billid] = array($bplayer->login, $bplayer->nickname, $bcoppers);
}else
{
$message = formatText($aseco->getChatMessage('UNITED_ONLY'), 'account');
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $acceptor[$i]->login);
$acceptor[$i]= NULL;
}
}else
{
$message = formatText($aseco->getChatMessage('UNITED_ONLY'), 'server');
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $acceptor[$i]->login);
$acceptor[$i]= NULL;
}
} else
{
$message = $aseco->getChatMessage('FOREVER_ONLY');
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $acceptor[$i]->login);
$acceptor[$i]= NULL;
}
}else
{
$message = "{#error}YOU HAVE ALREADY ACCEPTED THE BET";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $acceptor[$i]->login);
$acceptor[$i]= NULL;
}
}else
{
$message = "{#error}You cannot accept your own bet";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $command['author']->login);
}
}
}
if($disabled == 1)
{
$message = "{#error} You cannot accept a bet once the race is over.";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message),$login);
}
if($checkdisable == 1)
{
$message = "{#error} Betting has been disabled by the MasterAdmin/Admin";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message),$login);
}
if($bet_placed == 0)
{
$message = "{#error} There is currently no bet. Type '/bet <amount>' to place a bet";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message),$login);
}
$accept = 0;
$aclick = 0;
}
function chat_betcan($aseco,$command)
{
$xml = '<manialink id="1233120"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
$xml = '<manialink id="1233121"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
$xml = '<manialink id="1233122"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
global $bet_placed,$bplayer,$bcoppers;
global $acceptor,$i;
$admin = $command['author'];
if ($aseco->server->getGame() == 'TMF')
{
if ($aseco->server->rights)
{
if($aseco->isMasterAdmin($admin))
{
if($bet_placed == 1)
{
$data = "The Bet has been cancelled by " . stripColors($admin->nickname) .".All coppers will be refunded";
$aseco->client->query('ChatSendServerMessage', $data);
//re-paying the "better"
$aseco->client->query('Pay', $bplayer->login, $bcoppers,"The Bet was cancelled. Your coppers have been refunded");
$query = "INSERT INTO bet VALUE ('$bplayer->nickname','$bcoppers','','') ON DUPLICATE KEY UPDATE Totalbetmade= Totalbetmade - '$bcoppers'";
mysql_query($query);
//re-paying the acceptors
if($i>0)
{
for($z=0;$z<$i;$z++)
{
$aseco->client->query('Pay', $acceptor[$z]->login, $bcoppers,"The Bet was cancelled. Your coppers have been refunded");
$query = "INSERT INTO bet VALUE ('$acceptor[$z]->nickname','$bcoppers','','') ON DUPLICATE KEY UPDATE Totalbetmade= Totalbetmade - '$bcoppers'";
mysql_query($query);
}
}
else
{
if($i== 0 )
{
if(isset($acceptor[0]->login))
{
$aseco->client->query('Pay',$acceptor[0]->login,$bcoppers,"The Bet was cancelled.Your coppers have been refunded");
}
}
}
}
else
{
$msg = "No bet to cancel";
$aseco->client->query('ChatSendServerMessageToLogin',$msg,$admin->login);
}
}else
{
$data = "{#warning}You do not have required permission to cancel Bets";
$aseco->client->query('ChatSendServerMessageToLogin', $data, $admin->login);
}
}else
{
$data = "{#warning}You do not have required permission to cancel Bets";
$aseco->client->query('ChatSendServerMessageToLogin', $data, $admin->login);
}
}else
{
$data = "{#warning}You do not have required permission to cancel Bets";
$aseco->client->query('ChatSendServerMessageToLogin', $data, $admin->login);
}
echo "BetCan Acceptor Before erasing-> ".$acceptor[0]->login."\n";
echo "BetCan Better Before erasing-> ".$bplayer->login."\n";
$acceptor = NULL;
$bplayer = NULL;
echo "BetCan Better After erasing-> ".$bplayer->login."\n";
echo "BetCan Acceptor After erasing-> ".$acceptor[0]->login."\n";
$bet_placed=0; //resetting bet_placed variable to 0 to cancel bet
$i=0;
}
function paywin($aseco,$data)
{
$xml = '<manialink id="1233120"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
$xml = '<manialink id="1233121"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
$xml = '<manialink id="1233122"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
global $bet_placed,$acceptor,$total_win,$bplayer,$i;
global $bcoppers,$accept,$tiout;
$bplayers = array();
$bplayers = $data[0];
$win = 0; //Variable To check if anyone won the bet
$playe = $bplayers[0];
$payback = floor($bcoppers/2);
$pla = $aseco->server->players->getPlayer($playe["Login"]);
echo "Better login-> ".$bplayer->login."\n";
echo "Race Winner -> ".$playe["Login"]. "\n"; //just checking it in the log if its actually the winner's id
$z = 0;
if($bet_placed == 1)
{
if($i>0)
{
do
{
$playe = $bplayers[$z];
$pla = $aseco->server->players->getPlayer($playe["Login"]);
if($bplayer->login == $pla->login)
{
// win panel
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml.= '<manialinks><manialink id ="1233125"><frame posn="30 -38 0">';
//$xml.= '<quad posn="0 0 0" sizen="20 9." halign="center" valign="center" style="Bgs1InRace" substyle="NavButton" />';
$xml.= '<format textsize="1" style="TextCardSmallScores2" />';
$xml.= '<label posn="0 2.4 0" sizen="20 2" halign="center" valign="center" text="$i$s$o$CC0B$DD3e$DD6t$EE9 $EECW$FFFi$FFFn$CFBn$9F8e$6F4r$3F0 :"/>'; //'.stripColors($pla->nickname).'
$xml.= '<label posn="0 0 0" sizen="20 2" halign="center" valign="center" text="$i$s$o$fff'.stripColors($pla->nickname).'"/>';
$xml.= '<label posn="0 -2.4 0" sizen="20 2" halign="center" valign="center" text="$i$s$o$0F0T$4F4o$8F8t$BFBa$FFFl$FFF $FFBw$FF8i$FF4n$FF0 : $fff$o'.$total_win.' C"/>'; //'.$total_win.'
$xml.= '</frame>';
$xml.= '</manialink></manialinks>';
$aseco->client->addCall('SendDisplayManialinkPage', array( $xml, $tiout, false));
$win = 1;
$data = "$0ffPlayer $868" . stripColors($pla->nickname)." $0ffwon bet $00fwith a total win of $999".$total_win." $0ffcoppers! Congrats!";
$aseco->client->query('ChatSendServerMessage', $data);
$aseco->client->query('Pay',$pla->login,$total_win,"You Won the bet with a total win of ".$total_win." coppers");
echo "Better wins the bet. login".$pla->login."\n";
$query = "INSERT INTO bet VALUE ('$pla->nickname','','$total_win','') ON DUPLICATE KEY UPDATE Totalbetwin = Totalbetwin + '$total_win'";
mysql_query($query);
}
for($k=0;$k<$i;$k++) //checking if the winner was one of the acceptor's
{
if($acceptor[$k]->login == $pla->login) //going through with payment if winner is one of the acceptor's
{
$win = 1;
// winpanel for acceptors
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml.= '<manialinks><manialink id ="1233125"><frame posn="30 -38 0">';
//$xml.= '<quad posn="0 0 0" sizen="20 9." halign="center" valign="center" style="Bgs1InRace" substyle="NavButton" />';
$xml.= '<format textsize="1" style="TextCardSmallScores2" />';
$xml.= '<label posn="0 2.4 0" sizen="20 2" halign="center" valign="center" text="$i$s$o$CC0B$DD3e$DD6t$EE9 $EECW$FFFi$FFFn$CFBn$9F8e$6F4r$3F0 :"/>'; //'.stripColors($pla->nickname).'
$xml.= '<label posn="0 0 0" sizen="20 2" halign="center" valign="center" text="$i$s$o$fff'.stripColors($pla->nickname).'"/>';
$xml.= '<label posn="0 -2.4 0" sizen="20 2" halign="center" valign="center" text="$i$s$o$0F0T$4F4o$8F8t$BFBa$FFFl$FFF $FFBw$FF8i$FF4n$FF0 : $fff$o'.$total_win.' C"/>'; //'.$total_win.'
$xml.= '</frame>';
$xml.= '</manialink></manialinks>';
$aseco->client->addCall('SendDisplayManialinkPage', array( $xml, $tiout, false));
$data = "$0ffPlayer $597" . stripColors($pla->nickname)." $0ffwon bet $00fwith a total win of $999".$total_win." $0ffcoppers! Congrats!";
$aseco->client->query('ChatSendServerMessage', $data);
echo $z.".Acceptor Wins Bet .Login-> ".$pla->login."\n";
$aseco->client->query('Pay',$pla->login,$total_win,"You won the bet with a total win of ".$total_win." coppers");
$query = "INSERT INTO bet VALUE ('$pla->nickname','','$total_win','') ON DUPLICATE KEY UPDATE Totalbetwin = Totalbetwin + '$total_win'";
mysql_query($query);
}
}
$z++;
}while($z<16 && $win == 0);
if($win == 0)
{
echo "NoWinner Payback Acceptor Coppers-> ".$payback."\n";
for($z=0;$z<$i;$z++)
{
$aseco->client->query('Pay', $acceptor[$z]->login, $payback,"No winner in the bet. 50% Copper Refund");
$query = "INSERT INTO bet VALUE ('$acceptor[$z]->nickname','','','$payback') ON DUPLICATE KEY UPDATE Totalbetloss = Totalbetloss + '$payback'";
mysql_query($query);
}
echo "NoWinner Payback Better Coppers-> ".$payback."\n";
echo "Better login".$bplayer->login."\n";
$aseco->client->query('Pay', $bplayer->login, $payback,"No winner in the bet.50% Copper Refund");
$msg ="No one won the bet.50% of the coppers have been refunded";
$aseco->client->query('ChatSendServerMessage', $msg);
$query = "INSERT INTO bet VALUE ('$bplayer->nickname','','','$payback') ON DUPLICATE KEY UPDATE Totalbetloss = Totalbetloss + '$payback'";
mysql_query($query);
// no winner panel
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml.= '<manialinks><manialink id ="1233125"><frame posn="30 -38 0">';
//$xml.= '<quad sizen="15 10" posn="0 0 0" halign="center" valign="center" style="Bgs1InRace" substyle="NavButton"/>';
$xml.= '<format textsize="1" style="TextCardSmallScores2" />';
$xml.= '<label posn="0 1.2 0" sizen="10 2" halign="center" valign="center" text="$i$s$o$FF0B$FF3e$FF6t$FF9 $FFCr$FFFe$FFFs$BFBu$8F8l$4F4t$0F0s"/>';
$xml.= '<label posn="0 -1.2 0" sizen="10 2" halign="center" valign="center" text="$i$s$o$0F0n$4F4o$8F8 $BFBW$FFFi$FFFn$FFAn$FF5e$FF0r"/>';
$xml.= '</frame>';
$xml.= '</manialink></manialinks>';
$aseco->client->addCall('SendDisplayManialinkPage', array( $xml, $tiout, false));
}
}
if($i == 0)
{
if($win == 0)
{
echo "Nobody accepted bet. Payback Better Coppers-> ".$bcoppers."\n";
echo "Better login".$bplayer->login."\n";
$aseco->client->query('Pay', $bplayer->login, $bcoppers,"Nobody accepted your bet.Full Copper Refund");
$query = "INSERT INTO bet VALUE ('$bplayer->nickname','$bcoppers','','') ON DUPLICATE KEY UPDATE Totalbetmade= Totalbetmade - '$bcoppers'";
mysql_query($query);
$data = "Nobody accepted ".stripColors($bplayer->nickname)."'s bet. No winner.";
$aseco->client->query('ChatSendServerMessage', $data);
// no acceptors panel
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml.= '<manialinks><manialink id ="1233125"><frame posn="30 -38 0">';
//$xml.= '<quad posn="0 1 0" sizen="21 5." halign="center" valign="center" style="Bgs1InRace" substyle="NavButton" />';
$xml.= '<format textsize="1" style="TextCardSmallScores2" />';
$xml.= '<label posn="0 1.2 0" sizen="20 2" halign="center" valign="center" text="$i$o$s$FC0B$FC2e$FD3t$FD5 $FD7n$FE8o$FEAt$FEC $FFDa$FFFc$FFFc$DFDe$BFBp$9F9t$8F8e$6F6d$4F4!$2F2!$0F0!"/>';
//$xml.= '<label posn="-6.2 -2.0 0" sizen="8 2." textsize="1" halign="center" valign="center" text="$i$n$s$000S$002t$013y$015l$016e$028d$029 $02Bb$02Cy$03E $03FR$03Fo$24Fo$36Fk$57Fi$78Fe$8AFN$ABFo$CCFu$DEFs$FFFe"/>';
$xml.= '</frame>';
$xml.= '</manialink></manialinks>';
$aseco->client->addCall('SendDisplayManialinkPage', array( $xml, $tiout, false));
}
}
}
else
{
$msg = "$964No $999BET $999was placed ";
$aseco->client->query('ChatSendServerMessage',$msg);
echo "NO BET WAS PLACED"."\n";
// no bet panel
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml.= '<manialinks><manialink id ="1233125"><frame posn="30 -38 0">';
//$xml.= '<quad posn="0 1 0" sizen="21 5." halign="center" valign="center" style="Bgs1InRace" substyle="NavButton" />';
$xml.= '<format textsize="1" style="TextCardSmallScores2" />';
$xml.= '<label posn="0 1.2 0" sizen="20 2" halign="center" valign="center" text="$i$o$s$FC0N$FC2o$FD4 $FD6b$FE9e$FEBt$FFD $FFFp$FFFl$DFDa$BFBc$9F9e$6F6d$4F4!$2F2!$0F0!"/>';
//$xml.= '<label posn="-6.2 -2.0 0" sizen="8 2." textsize="1" halign="center" valign="center" text="$i$n$s$000S$002t$013y$015l$016e$028d$029 $02Bb$02Cy$03E $03FR$03Fo$24Fo$36Fk$57Fi$78Fe$8AFN$ABFo$CCFu$DEFs$FFFe"/>';
$xml.= '</frame>';
$xml.= '</manialink></manialinks>';
$aseco->client->addCall('SendDisplayManialinkPage', array( $xml, $tiout, false));
}
$bet_placed = 0; //resetting the $bet_placed so that next race ,betting is enabled again
$i=0;
$acceptor = NULL;
$bplayer = NULL;
echo "PayWinner Win ->".$win. "\n";
$accept = 0;
$win = 0;
}
function paywinner($aseco, $data)
{
$xml = '<manialink id="1233120"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
$xml = '<manialink id="1233121"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
$xml = '<manialink id="1233122"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
global $bet_placed,$acceptor,$total_win,$bplayer,$i;
global $bcoppers,$accept;
$bplayers = $data[0];
$playe=$bplayers[0]; //assigning the winner id
$win = 0; //Variable To check if anyone won the bet
$payback = floor($bcoppers/2);
$pla = $aseco->server->players->getPlayer($playe["Login"]);
echo "Better login-> ".$bplayer->login."\n";
echo "Race Winner -> ".$playe["Login"]. "\n"; //just checking it in the log if its actually the winner's id
if($bet_placed == 1)
{
if($i>0)
{
if($bplayer->login == $playe["Login"]) //checking if the winner was the person who placed bet
{
$win = 1;
$data = "$0ffPlayer $868" . stripColors($pla->nickname)." $0ffwon bet $00fwith a total win of $999".$total_win." $0ffcoppers! Congrats!";
$aseco->client->query('ChatSendServerMessage', $data);
$aseco->client->query('Pay',$playe["Login"],$total_win,"You won the bet with a total win of ".$total_win." coppers");
echo "Better wins the bet. login".$playe["Login"]."\n";
$query = "INSERT INTO bet VALUE ('$pla->nickname','','$total_win','') ON DUPLICATE KEY UPDATE Totalbetwin = Totalbetwin + '$total_win'";
mysql_query($query);
}
for($z=0;$z<$i;$z++) //checking if the winner was one of the acceptor's
{
if($acceptor[$z]->login == $playe["Login"]) //going through with payment if winner is one of the acceptor's
{
$data = "$0ffPlayer $597" . stripColors($pla->nickname)." $0ffwon bet $00fwith a total win of $999".$total_win." $0ffcoppers! Congrats!";
$aseco->client->query('ChatSendServerMessage', $data);
echo $z.".Acceptor Wins Bet .Login-> ".$playe["Login"]."\n";
$aseco->client->query('Pay',$playe["Login"],$total_win,"You Won the bet with a total win of ".$total_win." coppers");
$win=1;
$query = "INSERT INTO bet VALUE ('$pla->nickname','','$total_win','') ON DUPLICATE KEY UPDATE Totalbetwin = Totalbetwin + '$total_win'";
mysql_query($query);
}
}
if($win == 0)
{
echo "NoWinner Payback Acceptor Coppers-> ".$payback."\n";
for($z=0;$z<$i;$z++)
{
$aseco->client->query('Pay', $acceptor[$z]->login, $payback,"No winner in the bet. 50% Copper Refund");
$query = "INSERT INTO bet VALUE ('$acceptor[$z]->nickname','','','$payback') ON DUPLICATE KEY UPDATE Totalbetloss = Totalbetloss + '$payback'";
mysql_query($query);
}
echo "NoWinner Payback Better Coppers-> ".$payback."\n";
echo "Better login".$bplayer->login."\n";
$aseco->client->query('Pay', $bplayer->login, $payback,"No winner in the bet.50% Copper Refund");
$msg ="No one won the bet.50% of the coppers have been refunded";
$aseco->client->query('ChatSendServerMessage', $msg);
$query = "INSERT INTO bet VALUE ('$bplayer->nickname','','','$payback') ON DUPLICATE KEY UPDATE Totalbetloss = Totalbetloss + '$payback'";
mysql_query($query);
}
}
if($i == 0)
{
if($win == 0)
{
$win = 1;
echo "Nobody accepted bet. Payback Better Coppers-> ".$bcoppers."\n";
echo "Better login".$bplayer->login."\n";
$aseco->client->query('Pay', $bplayer->login, $bcoppers,"Nobody accepted your bet. Full Copper Refund");
$query = "INSERT INTO bet VALUE ('$bplayer->nickname','$bcoppers','','') ON DUPLICATE KEY UPDATE Totalbetmade= Totalbetmade - '$bcoppers'";
mysql_query($query);
$data = "Nobody accepted ".stripColors($bplayer->nickname)."'s bet.No winner for the bet";
$aseco->client->query('ChatSendServerMessage', $data);
}
}
}
else
{
$msg = "$964No $999BET $999was placed ";
$aseco->client->query('ChatSendServerMessage',$msg);
echo "No BET WAS PLACED"."\n";
}
$bet_placed = 0; //resetting the $bet_placed so that next race ,betting is enabled again
$i=0;
$acceptor = NULL;
$bplayer = NULL;
echo "PayWinner Win ->".$win. "\n";
$accept = 0;
$win = 0;
}
function chat_topbets($aseco,$command)
{
$player = $command['author'];
if($aseco->server->getGame() == 'TMF')
{
$head = "PLAYER NICK - TotalBetsMade - TotalBetWin - TotalBetLoss";
$query = 'SELECT Nickname,Totalbetmade,Totalbetwin,Totalbetloss from bet ORDER BY Totalbetwin DESC';
$list = mysql_query($query);
$player->msgs = array();
$lines = 0;
$listofbets = array();
$player->msgs[0] = array(1, $head, array(1.5, 1.5, 1.5, 1.5), array('BgRaceScore2', 'Bets'));
$i = 1;
while ($row = mysql_fetch_object($list))
{
$listofbets[] = array($i.".".stripColors($row->Nickname)." | ".$row->Totalbetmade." | ".$row->Totalbetwin." | ".$row->Totalbetloss);
$i++;
$lines++;
if($lines>9)
{
$player->msgs[] = $listofbets;
$lines = 0;
$listofbets = array();
}
}
if($lines<=9)
{
$player->msgs[] = $listofbets;
$listofbets = array();
}
display_manialink_multi($player);
}
}
function checktransaction($aseco,$bill)
{
global $mybill;
if($mybill == 1 )
{
global $bills,$timout,$tiout;
global $i,$total_win,$aclick,$bclick;
global $bcoppers,$bplayer,$bet_placed;
global $acceptor,$accept,$same_acceptor;
$billid = $bill[0];
$bett = 0;
// check for known bill ID
if (array_key_exists($billid, $bills)) {
// get bill info
$log = $bills[$billid][0];
$nick = $bills[$billid][1];
$copper = $bills[$billid][2];
// check bill state
switch($bill[1]) {
case 4: // Paid
// check for payment
if ($copper >= 5) {
if($bet_placed == 0)
{
$xml = '<manialink id="1233122"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPage', array($xml, 0, false));
$message = "Player ".stripColors($bplayer->nickname)." has placed a bet for ".$bcoppers." coppers.Click on ACCEPT to accept it";
$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
echo "Transaction Better player login -> ".$bplayer->login."\n";
$bett = 1;
foreach ($aseco->server->players->player_list as $play)
{
if($play->login != $bplayer->login)
{
// bet placed panel
$xml = '<?xml version="1.0" encoding="UTF-8"?>';
$xml.= '<manialinks><manialink id ="1233120"><frame posn="0 36.9 0">';
$xml.= '<quad posn="0 1 0" sizen="22 5." halign="center" valign="center" style="Bgs1InRace" substyle="NavButton" />';
$xml.= '<format textsize="1" style="TextCardSmallScores2" />';
$xml.= '<label posn="0 2.4 0" sizen="20 2" halign="center" valign="center" text="$i$o$s$F00B$D00e$B00t$900 $600p$400l$200a$000c$000e$012d$014 $026w$028i$03At$03Ch $000'.$bcoppers.' C"/>';
$xml.= '<label posn="-6.2 -2.0 0" sizen="8 2." textsize="1" halign="center" valign="center" text="$i$n$s$000S$002t$013y$015l$016e$028d$029 $02Bb$02Cy$03E $03FR$03Fo$24Fo$36Fk$57Fi$78Fe$8AFN$ABFo$CCFu$DEFs$FFFe"/>';
$xml.= '</frame>';
$xml.= '</manialink></manialinks>';
$aseco->client->addCall('SendDisplayManialinkPageToLogin', array( $play->login,$xml, $tiout, false));
// accept panel
$xxml = '<?xml version="1.0" encoding="UTF-8"?>';
$xxml.= '<manialinks><manialink id ="1233121"><frame posn="0 36.9 0">';
//$xxml.= '<quad sizen="7 3.5" posn="0 1 0" halign="center" valign="center" style="Bgs1InRace" substyle="NavButton"/>';
$xxml.= '<format textsize="1" style="TextCardSmallScores2" />';
$xxml.= '<label posn="0 0.2 0" sizen="20 2" halign="center" valign="center" text="$i$o$s$03CA$029c$026c$013e$000p$000t$400 $800b$B00e$F00t" action="50299"/>';
$xxml.= '</frame>';
$xxml.= '</manialink></manialinks>';
$aseco->client->addCall('SendDisplayManialinkPageToLogin', array($play->login, $xxml, $tiout, false));
}
}
$query = "INSERT INTO bet VALUE ('$bplayer->nickname','$bcoppers','','') ON DUPLICATE KEY UPDATE Totalbetmade = Totalbetmade + '$bcoppers'";
mysql_query($query);
$bclick = 0;
}
else
{
echo $i.".Transaction Acceptor -> ".$acceptor[$i]->login."\n";
$total_win=$total_win+$bcoppers; //incrementing total jackpot with every new acceptor
$data = stripColors($acceptor[$i]->nickname). " has accepted the bet. Total amount to be won -> ".$total_win;
$aseco->client->query('ChatSendServerMessage', $data);
$accept = 0;
echo $i.".Transaction Total win -> ".$total_win."\n";
$xml = '<manialink id="1233120"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPageToLogin', array($acceptor[$i]->login,$xml, 0, false));
$xml = '<manialink id="1233121"></manialink>';
$aseco->client->addCall('SendDisplayManialinkPageToLogin', array($acceptor[$i]->login,$xml, 0, false));
$query = "INSERT INTO bet VALUE ('$acceptor[$i]->nickname','$bcoppers','','') ON DUPLICATE KEY UPDATE Totalbetmade= Totalbetmade + '$bcoppers'";
mysql_query($query);
$i++;
$aclick = 0;
}
if($bett == 1)
$bet_placed=1; //setting bet_placed to 1 so that no further bets can be accepted until next race or this is cancelled
} else { // $bcoppers < 5
$message = "Minimum bet is 5 coppers and maximum is 250";
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message),$bplayer->login);
}
unset($bills[$billid]);
break;
case 5: // Refused
if($accept == 1 && $bet_placed == 1)
{
$message = '{#server}> {#error}Transaction refused!';
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $acceptor[$i]->login);
echo "Transaction refused Acceptor b-erase-> ".$acceptor[$i]->login."\n";
$acceptor[$i] = NULL;
echo "Transaction refused Acceptor a-erase-> ".$acceptor[$i]->login."\n";
$aclick = 0;
}
if($accept == 0 && $bet_placed == 0)
{
$message = '{#server}> {#error}Transaction refused!';
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $bplayer->login);
echo "Transaction refused Better b-erase-> ".$bplayer->login."\n";
$bplayer = NULL;
echo "Transaction refused Better a-erase-> ".$bplayer->login."\n";
$bclick = 0;
}
$accept = 0;
unset($bills[$billid]);
break;
case 6: // Error
$message = '{#server}> {#error}Transaction failed: {#highlite}$i ' . $bill[2];
if ($login != '')
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
else
$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
unset($bills[$billid]);
break;
default:
break;
}
}
}
else
{
global $bills, $publicappr,$mybillupdated;
if($mybillupdated == 0)
{
$billid = $bill[0];
// check for known bill ID
if (array_key_exists($billid, $bills)) {
// get bill info
$login = $bills[$billid][0];
$nickname = $bills[$billid][1];
$coppers = $bills[$billid][2];
// check bill state
switch($bill[1]) {
case 4: // Payed (Paid)
// check for donation or payment
if ($coppers > 0) {
// check for public appreciation threshold
if ($coppers >= $publicappr) {
$message = formatText($aseco->getChatMessage('THANKS_ALL'),
$nickname, $coppers);
$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
} else {
$message = formatText($aseco->getChatMessage('THANKS_YOU'),
$coppers);
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
}
$aseco->console('player {1} donated {2} coppers to this server', $login, $coppers);
if (function_exists('ldb_updateDonations'))
ldb_updateDonations($aseco, $login, $coppers);
} else { // $coppers < 0
// get new server coppers
$aseco->client->query('GetServerCoppers');
$newcoppers = $aseco->client->getResponse();
$message = formatText($aseco->getChatMessage('PAY_CONFIRM'),
abs($coppers), $nickname, $newcoppers);
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
$aseco->console('Server paid {1} coppers to login "{2}"', abs($coppers), $login);
}
unset($bills[$billid]);
break;
case 5: // Refused
$message = '{#server}> {#error}Transaction refused!';
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
unset($bills[$billid]);
break;
case 6: // Error
$message = '{#server}> {#error}Transaction failed: {#highlite}$i ' . $bill[2];
if ($login != '')
$aseco->client->query('ChatSendServerMessageToLogin', $aseco->formatColors($message), $login);
else
$aseco->client->query('ChatSendServerMessage', $aseco->formatColors($message));
unset($bills[$billid]);
break;
default: // CreatingTransaction/Issued/ValidatingPay(e)ment
break;
}
}
}
}
}
?>
check it here:jeffroselier wrote:Screenshoot of change please
Yes that is what i think. And it is really bad that the Serveracc must pay all fee.jouko100 wrote:it is not wise to have high bets.someone can click bet and then skip then bet and skip.......... server lose coppers