<?php
include_once ('core/base.php');
$header = 'Начало пути';
include_once ('core/head.php');

trueauth();

$_GET['sex'] = fl($_GET['sex']);

if($_GET['sex'] == 1 OR $_GET['sex'] == 2){
	//Игрок выбрал пол

	if($_GET['sex'] == 1){
		$skin = 1;
		$name = 'Странник';
	}elseif($_GET['sex'] == 2){
		$skin = 14;
		$name = 'Странница';
	}

	$base -> query("INSERT INTO `users` SET
	`password` = ' ',
	`sex` = '".$_GET['sex']."',
	`skin` = '".$skin."',
	`world` = '1',
	`x` = '7',
	`y` = '-2',
	`silver` = '500',
	`gold` = '100',
	`character_points` = '5',
	`hp` = '100',
	`max_hp` = '100',
	`mp` = '100',
	`max_mp` = '100',
	`p_att` = '15',
	`p_def` = '0',
	`m_att` = '0',
	`m_def` = '0',
	`endurance` = '5',
	`intellect` = '5',
	`agility` = '5',
	`skill` = '5',
	`respawn_world` = '1',
	`respawn_x` = '7',
	`respawn_y` = '-2',
	`training_step` = '1',
	`training_location` = '1',
	`date_registr` = '".time()."',
	`date_online` = '".time()."',
	`status` = 'Статус пуст.',
	`name` = 'Не заполнено.',
	`country` = 'Не заполнено.',
	`info` = 'Не заполнено.',
	`IP` = '".$_SERVER['REMOTE_ADDR']."'");

	$id = mysqli_insert_id($base);
	$login = ''.$name.'_'.$id.'';
	$base -> query("UPDATE `users` SET `login` = '".$login."' WHERE `id` = '".$id."' LIMIT 1");

	//Даём стандартный скин
	$base -> query('INSERT INTO `users_skins` SET
	`user` = "'.$id.'",
	`skin` = "'.$_GET['sex'].'"');
	//Даём зелья здоровья
	$base -> query('INSERT INTO `users_items` SET
	`user` = "'.$id.'",
	`name` = "Малое зелье здоровья",
	`image` = "hp_100",
	`what` = "potion",
	`potion` = "hp",
	`hp_regen` = "100",
	`mark` = "0",
	`amount` = "10",
	`cost` = "100",
	`ident_id` = "24"');
	//Даём зелья маны
	$base -> query('INSERT INTO `users_items` SET
	`user` = "'.$id.'",
	`name` = "Малое зелье маны",
	`image` = "mp_100",
	`what` = "potion",
	`potion` = "mp",
	`mp_regen` = "100",
	`mark` = "0",
	`amount` = "10",
	`cost` = "100",
	`ident_id` = "25"');
	//Даём вещи
	$base -> query('INSERT INTO `users_items` SET
	`user` = "'.$id.'",
	`name` = "Рубаха Странника",
	`image` = "wanderer_shirt",
	`level` = "1",
	`p_def` = "5",
	`what` = "clothing",
	`type` = "body",
	`mark` = "0",
	`max_quality` = "5",
	`cost` = "100",
	`ident_id` = "1"');
	$base -> query('INSERT INTO `users_items` SET
	`user` = "'.$id.'",
	`name` = "Нож",
	`image` = "knife",
	`level` = "1",
	`p_att` = "15",
	`what` = "clothing",
	`type` = "right",
	`attack_type` = "p_att",
	`mark` = "0",
	`max_quality` = "5",
	`cost` = "100",
	`ident_id` = "2"');

	setcookie('login', $login, time()+86400*365, '/');
	setcookie('password', ' ', time()+86400*365, '/');
	header('location: /location/');
}

echo '<div class="b"><center>';

echo '<div class="title">Кто ты?</div>';

echo '<table style="width:100%; max-width: 300px;">
		<tr>
			<td width="50%" valign="top">
			<center><a href="/start/1/"><div class="big_btn"><img src="/images/skins/1.gif"><br/>
			<b>Парень</b></div></a></center>
			</td>
			<td width="50%" valign="top">
			<center><a href="/start/2/"><div class="big_btn"><img src="/images/skins/14.gif"><br/>
			<b>Девушка</b></div></a></center>
			</td>
		</tr>
	</table></center>
	<br/><a class="btn" href="/"><img src="/images/icons/back.png"> Назад </a>
</div>';
include_once ('core/foot.php');
?>