another final version

This commit is contained in:
lopar 2019-01-16 00:15:12 +02:00
parent 5ca0b2d397
commit 99168f1eac
1 changed files with 8 additions and 6 deletions

View File

@ -18,17 +18,19 @@ $get = urldecode(filter_input(INPUT_SERVER, 'QUERY_STRING'));
function setProfession($name, $type, $needMoney, $needLevel)
{
global $user;
$profId = 0;
if (!in_array($name, ['smith', 'mercenary', 'medic'])) return 'Такой профессии не существует!';
if ($user['money'] < $needMoney) return 'Недостаточно денег!';
if ($user['level'] < $needLevel) return 'Ваш уровень ещё мал для этой профессии!';
if (!empty($user['prof1']) AND $type == 1) return 'Ошибка! У вас уже есть другая мирная профессия!';
if (!empty($user['prof2']) AND $type == 2) return 'Ошибка! У вас уже есть другая боевая профессия!';
if ($name == 'obrob') $profId = 1;
if ($name == 'pala4') $profId = 21;
if ($name == 'lekar') $profId = 22;
db::c()->query('UPDATE `users` SET ?f = ?i, `money` = `money` - ?i WHERE `id` = ?i', 'prof' . $type, $profId, $needMoney, $_SESSION['uid']);
return 'Вы получили профессию!';
if ($name == 'smith') $profId = 1;
if ($name == 'mercenary') $profId = 21;
if ($name == 'medic') $profId = 22;
if (!empty($profId)) {
db::c()->query('UPDATE `users` SET ?f = ?i, `money` = `money` - ?i WHERE `id` = ?i', 'prof' . $type, $profId, $needMoney, $_SESSION['uid']);
return 'Вы получили профессию!';
} else return 'Что-то пошло не так...';
}
if ($get == 'smith') $status = setProfession('smith', 1, 300, 3);