-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathattackbeat.php
126 lines (120 loc) · 4.82 KB
/
attackbeat.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
<?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']} LIMIT 1");
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
{
echo "You beat {$r['username']}!!<br />
You beat {$r['username']} severely on the ground. When there is lots of blood showing, you head up to the nearest 10-story building's roof and drop him over the edge. You run home silently and carefully.";
$hosptime = rand(50, 150) + floor($ir['level'] / 2);
$hospreason =
$db->escape(
"Hospitalized by <a href='viewuser.php?u={$userid}'>{$ir['username']}</a>");
$db->query(
"UPDATE `users` SET `hp` = 1, `hospital` = $hosptime,
`hospreason` = '{$hospreason}'
WHERE `userid` = {$r['userid']}");
event_add($r['userid'],
"<a href='viewuser.php?u=$userid'>{$ir['username']}</a> beat you up.");
$atklog = $db->escape($_SESSION['attacklog']);
$db->query(
"INSERT INTO `attacklogs` VALUES(NULL, $userid, {$_GET['ID']},
'won', " . time() . ", -1, '$atklog')");
$_SESSION['attackwon'] = 0;
if ($ir['gang'] > 0 && $r['gang'] > 0)
{
$gq =
$db->query(
"SELECT `gangRESPECT`, `gangID` FROM `gangs` WHERE `gangID` = {$r['gang']} LIMIT 1");
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` - 3 WHERE `gangID` = {$r['gang']}");
$ga['gangRESPECT'] -= 3;
$db->query(
"UPDATE `gangs` SET `gangRESPECT` = `gangRESPECT` + 3 WHERE `gangID` = {$ir['gang']}");
echo '<br />You earnt 3 respect for your gang!';
}
// 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!';
}
$h->endpage();