-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathjailbust.php
More file actions
80 lines (79 loc) · 2.26 KB
/
jailbust.php
File metadata and controls
80 lines (79 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
declare(strict_types=1);
/**
* MCCodes v2 by Dabomstew & ColdBlooded
*
* Repository: https://github.com/davemacaulay/mccodesv2
* License: MIT License
*/
global $db, $ir, $userid, $h;
require_once('globals.php');
if ($ir['energy'] < 10)
{
echo 'Sorry, it costs 10 energy to bust someone. '
. "You only have {$ir['energy']} energy. " . 'Come back later.';
$h->endpage();
exit;
}
if ($ir['jail'])
{
echo 'You cannot bust out people while in jail.';
$h->endpage();
exit;
}
$_GET['ID'] =
(isset($_GET['ID']) && is_numeric($_GET['ID']))
? abs(intval($_GET['ID'])) : 0;
$jail_q =
$db->query(
"SELECT `userid`, `jail`, `level`, `username`
FROM `users`
WHERE `userid` = {$_GET['ID']}");
if ($db->num_rows($jail_q) == 0)
{
$db->free_result($jail_q);
echo 'Invalid user';
$h->endpage();
exit;
}
$r = $db->fetch_row($jail_q);
$db->free_result($jail_q);
if (!$r['jail'])
{
echo 'That user is not in jail!';
$h->endpage();
exit;
}
$mult = $r['level'] * $r['level'];
$chance = min(($ir['crimexp'] / $mult) * 50 + 1, 95);
if (rand(1, 100) < $chance)
{
$gain = $r['level'] * 5;
echo "You successfully busted {$r['username']} out of jail.<br />
> <a href='jail.php'>Back</a>";
$db->query(
"UPDATE `users`
SET `crimexp` = `crimexp` + {$gain}, `energy` = `energy` - 10
WHERE `userid` = $userid");
$db->query(
"UPDATE `users`
SET `jail` = 0
WHERE `userid` = {$r['userid']}");
event_add($r['userid'],
"<a href='viewuser.php?u={$ir['userid']}'>{$ir['username']}</a> busted you out of jail.");
}
else
{
echo "While trying to bust out your friend, a guard spotted you and dragged you into jail yourself. Unlucky!<br />
> <a href='jail.php'>Back</a>";
$time = min($mult, 100);
$jail_reason = $db->escape("Caught trying to bust out {$r['username']}");
$db->query(
"UPDATE `users`
SET `jail` = $time, `jail_reason` = '{$jail_reason}',
`energy` = `energy` - 10
WHERE `userid` = $userid");
event_add($r['userid'],
"<a href='viewuser.php?u={$ir['userid']}'>{$ir['username']}</a> was caught trying to bust you out of jail.");
}
$h->endpage();