Loading...
Помощь по скриптам | Прошу помощи. Скрипт игры Противостояние.
Всем доброго, подскажите пожалуйста, у меня проблема в коде ниже,.. золото и серебро даже если не хватает золота и серебра то ресурсы все равно
уходят в минус. Игра Противостояние сприпт от сюда, помогите прошу.


0: <?php ¶
1: $root = $_SERVER['DOCUMENT_ROOT']; ¶
2: include_once ($root.'/core/base.php'); ¶
3: falseauth(); ¶
4: $header = "Тренировка"; ¶
5: include_once ($root.'/core/head.php'); ¶
6: if(isset($_GET['train'])) ¶
7: { ¶
8: $type = fl($_GET['type']); ¶
9: if(!in_array($type,[1,2,3])) redirect('/train'); ¶
10: $types = [null, 'power_train', 'health_train', 'block_train']; ¶
11: if($u[$types[$type]] >= 100) redirect('/train', 'Максимальное улучшение!'); ¶
13: $cost = getTrainCost($u[$types[$type]]+1); ¶
14: if(($u[$types[$type]]+1) % 10 == 0) $curr = 'gold'; ¶
15: else $curr = 'silver'; ¶
16: $db->query("UPDATE `users` SET `".$curr."` = `".$curr."` - '".$cost."', `".$types[$type]."` = `".$types[$type]."` + '1' WHERE `id` = '".$u['id']."'"); ¶
17: redirect('/train', 'Улучшение успешно!'); ¶
18: } ¶
19: echo '<div class = "notice_container"><div class = "gborder notice_alert alert-success"> ¶
20: Сила ('.$u['power_train'].' ур. из 100 ур.)</div></div><div class = "b"> ¶
21: <table width="100%"> ¶
22: <tbody><tr> ¶
23: <td width="50px" valign="top"> ¶
24: <img width="40px" src="/images/train/str.png"> ¶
25: </td> ¶
26: <td valign="top"> ¶
27: <font color="white"><big>Бонус к силе: '.(5*$u['power_train']).' <font color="lime"> +5</font></font></big> ¶
28: <div class="txt"> ¶
29: Даёт дополнительные параметры к силе ¶
30: </div></br> ¶
31: <div class="txt"> ¶
32: '.($u['power_train'] < 100 ? '<a href="/train/1"><input type="submit" value="Улучшить за '.getTrainCost($u['power_train']).' '.(($u['power_train']+1) % 10 == 0 ? 'гемов' : 'серебра').'"></a>' : 'Максимальное улучшение').' ¶
33: </div> ¶
34: </td> ¶
35: </tr> ¶
36: </tbody></table><br> ¶
37: </div>'; ¶
38: echo '<div class = "notice_container"><div class = "gborder notice_alert alert-success"> ¶
39: Здоровье ('.$u['health_train'].' ур. из 100 ур.)</div></div><div class = "b"> ¶
40: <table width="100%"> ¶
41: <tbody><tr> ¶
42: <td width="50px" valign="top"> ¶
43: <img width="40px" src="/images/train/health.png"> ¶
44: </td> ¶
45: <td valign="top"> ¶
46: <big><font color="white">Бонус к здоровью: '.(5*$u['health_train']).' <font color="lime"> +5</font></font></big> ¶
47: <div class="txt"> ¶
48: Даёт дополнительные параметры к здоровью ¶
49: </div></br> ¶
50: <div class="txt"> ¶
51: '.($u['health_train'] < 100 ? '<a href="/train/2"><input type="submit" value="Улучшить за '.getTrainCost($u['health_train']).' '.(($u['health_train']+1) % 10 == 0 ? 'гемов' : 'серебра').'"></a>' : 'Максимальное улучшение').' ¶
52: </div> ¶
53: </td> ¶
54: </tr> ¶
55: </tbody></table><br> ¶
56: </div>'; ¶
57: echo '<div class = "notice_container"><div class = "gborder notice_alert alert-success"> ¶
58: Защита ('.$u['block_train'].' ур. из 100 ур.)</div></div><div class = "b"> ¶
59: <table width="100%"> ¶
60: <tbody><tr> ¶
61: <td width="50px" valign="top"> ¶
62: <img width="40px" src="/images/train/def.png"> ¶
63: </td> ¶
64: <td valign="top"> ¶
65: <big> <font color="white">Бонус к защите: '.(5*$u['block_train']).' <font color="lime"> +5</font></font></big> ¶
66: <div class="txt"> ¶
67: Даёт дополнительные параметры к защите ¶
68: </div></br> ¶
69: <div class="txt"> ¶
70: '.($u['block_train'] < 100 ? '<a href="/train/3"><input type="submit" value="Улучшить за '.getTrainCost($u['block_train']).' '.(($u['block_train']+1) % 10 == 0 ? 'гемов' : 'серебра').'"></a>' : 'Максимальное улучшение').' ¶
71: </div> ¶
72: </td> ¶
73: </tr> ¶
74: </tbody></table><br> ¶
75: </div>'; ¶
76: include_once ($root.'/core/foot.php'); ¶
________
посл. ред. 23.06.2018 в 21:49; всего 4 раз(а); by 471470337
XxxDIABLOxxX (23.06.2018 в 21:55)

<?php

if(isset($_GET['train'])) {

$type = fl($_GET['type']);
if(!in_array($type,[1,2,3])) redirect('/train');
$types = [null, 'power_train', 'health_train', 'block_train'];
if($u[$types[$type]] >= 100) redirect('/train', 'Максимальное улучшение!');
$cost = getTrainCost($u[$types[$type]]+1);
if(($u[$types[$type]]+1) % 10 == 0) $curr = 'gold'; else $curr = 'silver';

if($u[$curr] > 0) {

$db->query("UPDATE `users` SET `".$curr."` = `".$curr."` - '".$cost."', `".$types[$type]."` = `".$types[$type]."` + '1' WHERE `id` = '".$u['id']."'"); ¶
redirect('/train', 'Улучшение успешно!');

}else redirect('/train', 'Ошибка');

}
?>




Огромное спасибо все работает)))))
Онлайн: 5
Время:
Gen. 0.0738
(c) Bym.Guru 2010-2026