$vad['test1']=mysql_fetch_array(mysql_query('SELECT COUNT(*) FROM `dungeon_actions` WHERE `dn` = "'.$u->info['dnow'].'" AND `vars` = "obj_act'.$obj['id'].'" LIMIT 1'));
$vad['sp']=mysql_query('SELECT `id` FROM `items_main` WHERE `type` >= 1 AND `type` <= 22 AND `id` IN (SELECT `item_id` FROM `items_shop` WHERE `sid` = 1 AND `kolvo` > 0) AND `id` IN (SELECT `items_id` FROM `items_main_data` WHERE `data` NOT LIKE "%tr_lvl=1%" AND `data` NOT LIKE "%tr_lvl=2%" AND `data` NOT LIKE "%tr_lvl=3%")');
while($vad['pl']=mysql_fetch_array($vad['sp'])){
$vad['items'][]=$vad['pl']['id'];
}
$vad['items']=mysql_fetch_array(mysql_query('SELECT * FROM `items_main` WHERE `id` = "'.mysql_real_escape_string($vad['items'][rand(0,count($vad['items'])-1)]).'" LIMIT 1'));