function exit_from_craft($add_query = '', $exit = 1, $userid = 0, $block = 0) { global $user_id; if ($userid == 0) { $userid = $user_id; } if ($exit == 1) { craft_DelFunc($userid); myquery("delete from craft_build_rab where user_id={$userid}"); myquery("delete from craft_user_func where user_id={$userid}"); } else { myquery("update craft_build_rab set date_rab=0,dlit=0,eliksir=0,`add`=0 where user_id={$userid}"); } /*myquery("update craft_build_lumberjack set user_id=0, end_time=0 where user_id=$userid"); myquery("update craft_build_stonemason set user_id=0, end_time=0 where user_id=$userid"); myquery("update craft_build_lumberjack set reserve_user_id=0, reserve_time=0 where reserve_user_id=$userid"); myquery("update craft_build_stonemason set reserve_user_id=0, reserve_time=0 where reserve_user_id=$userid");*/ myquery("update craft_build_mining set user_id=0, end_time=0 where user_id={$userid}"); if ($add_query != '') { $str_query = "update game_users set user_id={$userid}"; $str_query .= $add_query; $str_query .= ' where user_id=' . $userid; myquery($str_query); } if ($exit == 1) { set_craft_delay($userid, $block); ForceFunc($userid, 5); } }
function check_obval($tree) { global $char; $rand = obval_chance($tree); mt_srand(make_seed()); $ch = mt_rand(0, 100); if ($ch <= $rand) { //обвал craft_DelFunc($char['user_id']); myquery("DELETE FROM craft_build_rab WHERE user_id=" . $char['user_id'] . ""); myquery("UPDATE craft_build_stonemason SET klin=0,state=0,user_id=0,end_time=0,chance=0,reserve_time=0,reserve_user_id=0 WHERE id=" . $tree['id'] . ""); set_craft_delay($char['user_id'], 1); echo '<b>Произошел обвал! Работа прекращена!</b><br><br>'; return 1; } else { myquery("UPDATE craft_build_stonemason SET chance=chance+5 WHERE id=" . $tree['id'] . ""); } return 0; }