I never thought this would be my first blog post but here we go. It’s difficult to pinpoint exactly when Aviator gained popularity in Kenya, but what is clear is the effect it has had on Kenyans. My interest was piqued following a troubling story of a young man entrusted with his brother’s shop who sold off the entire inventory to fund his Aviator gambling habit, betting everything on the virtual plane’s ascent. There was also an interview by Lynn Ngugi in which a lady lost a staggering 4.6M.
Despite these cautionary tales, many Kenyans continue to believe they’ll be the exception. The lucky ones who beat the odds and strikes it rich. This persistent hope keeps players returning despite mounting losses. I stumbled on some codebase on the internet that seemingly is used by the Aviator game(there’re many renditions but I would suspect the concept is the same). Of importance is how the House Always Wins mantra is enforced making sure that all players contribute to the pot with few of them receiving little tokens, just enough “success stories” to perpetuate the myth that anyone can win big.
How Does Aviator Work
The Aviator game starts by prompting the players to either place one or two bets. Once this is done, the plane starts to take ascent, and the multiplier value gets activated. The idea is that the player would cash out before the plane moves outside the view lest they lose everything they had staked.
The multiplier is what is used to calculate the winnings i.e. if the multiplier was 2x and the player had staked 1,000 KES and cashed out before the plane took off. The player would win 2,000 KES (1,000 KES x 2). You can start to see why this value is important and why the house would like to control it.
Lets get to the code, the project was implemented using the following stack:
JavaScript Code
$.ajax({
url: '/game/increamentor', //The program invokes a function resident on the server to return the value that determine when the plane will crash. An event that is hidden from the player allowing the house to determine who wins or losses.
type: "POST",
data: {
_token: hash_id
},
dataType: "json",
success: function (data) {
currentbet = data.result;
$.ajax({
url: '/game/currentlybet',
type: "POST",
data: {
_token: hash_id
},
dataType: "json",
success: function (intialData) {
info_data(intialData);
}
});
let increamtsappgame = setInterval(() => {
if ( a >= currentbet ) { //This is when the plane stops, it doesn't matter what the player does or selects. The outcome is predetermined. The unfortunate players who never cashed-out before this event loose. To reduce the amount of money paid out, the house could decide to set low multiplier values.
let res = parseFloat(a).toFixed(2);
let result = res;
crash_plane(result);
incrementor(res);
gameover(result);
$("#all_bets .mCSB_container").empty();
$.ajax({
url: '/game/my_bets_history',
type: "POST",
data: {
_token: hash_id
},
dataType: "json",
success: function (data) {
$("#my_bet_list").empty();
for (let $i = 0; $i < data.length; $i++) {
let date = new Date(data[$i].created_at);
$("#my_bet_list").append(`
<div class="list-items">
<div class="column-1 users fw-normal">
`+date.getHours()+`:`+date.getMinutes()+`
</div>
<div class="column-2">
<button
class="btn btn-transparent previous-history d-flex align-items-center mx-auto fw-normal">
`+data[$i].amount+`₹
</button>
</div>
<div class="column-3">
<div class="bg3 custom-badge mx-auto">
`+data[$i].cashout_multiplier+`x</div>
</div>
<div class="column-4 fw-normal">
`+Math.round(data[$i].cashout_multiplier*data[$i].amount)+`₹
</div>
</div>
`);
}
}
});
clearInterval(increamtsappgame);
gamegenerate();
} else {
a = parseFloat(a) + 0.01;
incrementor(parseFloat(a).toFixed(2));
}
}, 100);
}
})
PHP Code
This is the function called by the JavaScript script above.
public function increamentor(Request $r)
{
$gamestatusdata = Setting::where('category', 'game_status')->first();
$res = 0;
if($gamestatusdata){
$totalbet = Userbit::where('gameid',currentid())->count();
$totalamount = Userbit::where('gameid',currentid())->sum('amount');
if ($totalbet == 0) { //If there are no bets placed by any of the players, the house displays fake high multipliers on the frontend to entice the unsuspecting players.
$res = rand(8,11);
}else{
// $randomresult = array(1.1,1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9);
$emailvalue = Setting::where('id', '14')->sum('value');//This is the predetermined low multiplier value saved in the database and used on the line below. You will notice that the line above that has the $randomresult variable was commented out such that the Admin can control what is random.
$res =$emailvalue; //If there are bets placed by the users, the multiplier value is reduced to make sure the payouts are not as large as they would "eat into" the possible profits to be accrued
// // $gamestatusdataend = Setting::where('category', 'game_between_time_end')->first();
// $res = $randomresult[rand(0,2)]; //$emailvalue;
}
$status = true;
$result = $res;
$response = array('status'=>$status,'result'=>$result);
return response()->json($response);
}
}
SQL Code
Remember the $emailvalue (holds the multiplier value) variable above, well, it is predetermined and could be changed by the Admin to give the false impression of it being random when it is not. The value is set and found on the row with the ID of 14: (14, ‘game_between_time_end’, ‘1.56‘, ‘1’, ‘2023-01-11 20:09:57’, ‘2023-07-26 11:13:07’); In this instance, it was 1.56 but that changes depending on the outcome the house wants to have.
CREATE TABLE `settings` (
`id` bigint(20) UNSIGNED NOT NULL,
`category` varchar(255) NOT NULL,
`value` varchar(255) NOT NULL,
`status` varchar(255) NOT NULL,
`created_at` timestamp NULL DEFAULT NULL,
`updated_at` timestamp NULL DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
--
-- Dumping data for table `settings`
--
INSERT INTO `settings` (`id`, `category`, `value`, `status`, `created_at`, `updated_at`) VALUES
(1, 'game_status', '0', '1', NULL, '2023-07-31 17:59:40'),
(2, 'min_bet_amount', '10', '1', NULL, '2023-02-17 15:11:57'),
(3, 'max_bet_amount', '5000', '1', NULL, '2023-07-25 13:25:01'),
(4, 'initial_bonus', '50', '1', NULL, '2023-07-24 12:47:23'),
(5, 'min_withdrawal', '2000', '1', NULL, NULL),
(6, 'min_recharge', '100', '1', '2022-12-10 12:56:27', '2022-12-29 10:32:23'),
(7, 'start_range_game_timer', '10', '1', '2022-12-10 12:56:27', '2023-07-24 12:42:14'),
(8, 'end_range_game_timer', '32', '1', '2022-12-10 12:56:27', '2023-01-03 13:18:43'),
(9, 'level1commission', '1', '1', '2022-12-10 12:56:27', '2022-12-10 12:56:27'),
(10, 'level2commission', '1', '1', '2022-12-10 12:56:27', '2022-12-10 12:56:27'),
(11, 'level3commission', '1', '1', '2022-12-10 12:56:27', '2022-12-10 12:56:27'),
(12, 'game_start_time', '2023-07-26 04:28:33', '1', '2023-01-11 20:09:57', '2023-07-26 10:58:33'),
(13, 'game_between_time', '5000', '1', '2023-01-11 20:09:57', '2023-07-26 10:58:33'),
(14, 'game_between_time_end', '1.56', '1', '2023-01-11 20:09:57', '2023-07-26 11:13:07');
Conclusion
- The multiplier value is made to look big when there are no players in session. This is to encourage players to place bets.
- The game has its multiplier value reduced if there are many players in session to reduce the amount the house has to pay out.
- The house decides when the game should stop as opposed to it being a random event.
- The few wins are to entice and maintain the player’s hopes of striking it big. Their endorsement goes a long way as the best form of marketing is when the customers are the ones spreading the message.
April 23, 2025 -
Congratulations on your first blog. 🥂
This form of online gambling is never designed to favor the use but rather the house. Such a disaster, socially and economically.