-
Notifications
You must be signed in to change notification settings - Fork 8
/
attackwon.php
133 lines (128 loc) · 5.16 KB
/
attackwon.php
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<?php
declare(strict_types=1);
/**
* MCCodes v2 by Dabomstew & ColdBlooded
*
* Repository: https://github.com/davemacaulay/mccodesv2
* License: MIT License
*/
$atkpage = 1;
global $db, $ir, $userid, $h;
require_once('globals.php');
$_GET['ID'] =
(isset($_GET['ID']) && is_numeric($_GET['ID']))
? abs((int) $_GET['ID']) : 0;
$_SESSION['attacking'] = 0;
$ir['attacking'] = 0;
$db->query("UPDATE `users` SET `attacking` = 0 WHERE `userid` = $userid");
$od =
$db->query(
"SELECT * FROM `users` WHERE `userid` = {$_GET['ID']}");
if (!isset($_SESSION['attackwon']) || $_SESSION['attackwon'] != $_GET['ID'])
{
die("Cheaters don't get anywhere.");
}
if ($db->num_rows($od) > 0)
{
$r = $db->fetch_row($od);
$db->free_result($od);
if ($r['hp'] == 1)
{
echo 'What a cheater you are.';
}
else
{
$stole = (int)round($r['money'] / (rand(200, 5000) / 10));
echo "You beat {$r['username']}!!<br />
You knock {$r['username']} on the floor a few times to make sure he is unconscious, "
. 'then open his wallet, snatch ' . money_formatter($stole)
. ', and run home happily.';
$hosptime = rand(20, 40) + floor($ir['level'] / 8);
$expgain = 0;
$db->query(
"UPDATE `users` SET `exp` = `exp` + $expgain, `money` = `money` + $stole WHERE `userid` = $userid");
$hospreason =
$db->escape(
"Mugged by <a href='viewuser.php?u={$userid}'>{$ir['username']}</a>");
$db->query(
"UPDATE `users`
SET `hp` = 1, `money` = `money` - $stole, `hospital` = $hosptime,
`hospreason` = '{$hospreason}' WHERE `userid` = {$r['userid']}");
event_add($r['userid'],
"<a href='viewuser.php?u=$userid'>{$ir['username']}</a> mugged you and stole "
. money_formatter($stole) . '.');
$atklog = $db->escape($_SESSION['attacklog']);
$db->query(
"INSERT INTO `attacklogs` VALUES(NULL, $userid, {$_GET['ID']},
'won', " . time() . ", $stole, '$atklog')");
$_SESSION['attackwon'] = 0;
if ($ir['gang'] > 0 && $r['gang'] > 0)
{
$gq =
$db->query(
"SELECT `gangRESPECT`, `gangID` FROM `gangs` WHERE `gangID` = {$r['gang']}");
if ($db->num_rows($gq) > 0)
{
$ga = $db->fetch_row($gq);
$warq =
$db->query(
"SELECT COUNT(`warDECLARER`) FROM `gangwars`
WHERE (`warDECLARER` = {$ir['gang']} AND `warDECLARED` = {$r['gang']})
OR (`warDECLARED` = {$ir['gang']} AND `warDECLARER` = {$r['gang']})");
if ($db->fetch_single($warq) > 0)
{
$db->query(
"UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` - 2 WHERE `gangID` = {$r['gang']}");
$ga['gangRESPECT'] -= 2;
$db->query(
"UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` + 2 WHERE `gangID` = {$ir['gang']}");
echo '<br />You earnt 2 respect for your gang!';
}
$db->free_result($warq);
//Gang Kill
if ($ga['gangRESPECT'] <= 0 && $r['gang'])
{
$db->query(
"UPDATE `users` SET `gang` = 0 WHERE `gang` = {$r['gang']}");
$db->query('DELETE FROM `gangs` WHERE `gangRESPECT` <= 0');
$db->query(
"DELETE FROM `gangwars`
WHERE `warDECLARER` = {$ga['gangID']} OR `warDECLARED` = {$ga['gangID']}");
}
}
$db->free_result($gq);
}
if ($r['user_level'] == 0)
{
$q =
$db->query(
"SELECT `cb_money` FROM `challengebots` WHERE `cb_npcid` = {$r['userid']}");
if ($db->num_rows($q) > 0)
{
$cb = $db->fetch_row($q);
$qk =
$db->query(
"SELECT COUNT(`npcid`) FROM `challengesbeaten`
WHERE `userid` = $userid AND `npcid` = {$r['userid']}");
if ($db->fetch_single($qk) > 0)
{
$m = (int)$cb['cb_money'];
$db->query(
"UPDATE `users` SET `money` = `money` + $m WHERE `userid` = $userid");
echo '<br /> You gained ' . money_formatter($m)
. " for beating the challenge bot {$r['username']}";
$db->query(
"INSERT INTO `challengesbeaten` VALUES($userid, {$r['userid']})");
}
$db->free_result($qk);
}
$db->free_result($q);
}
}
}
else
{
$db->free_result($od);
echo 'You beat Mr. non-existent! Haha, pwned!';
}
$h->endpage();