コード例 #1
0
ファイル: users.php プロジェクト: niemoralny/ZnoteAAC
function user_create_character($character_data)
{
    array_walk($character_data, 'array_sanitize');
    $cnf = fullConfig();
    if ($character_data['sex'] == 1) {
        $outfit_type = $cnf['maleOutfitId'];
    } else {
        $outfit_type = $cnf['femaleOutfitId'];
    }
    // This is TFS 0.2 compatible import data with Znote AAC mysql schema
    $import_data = array('name' => $character_data['name'], 'group_id' => 1, 'account_id' => $character_data['account_id'], 'level' => $cnf['level'], 'vocation' => $character_data['vocation'], 'health' => $cnf['health'], 'healthmax' => $cnf['health'], 'experience' => 0, 'lookbody' => $cnf['lookBody'], 'lookfeet' => $cnf['lookFeet'], 'lookhead' => $cnf['lookHead'], 'looklegs' => $cnf['lookLegs'], 'looktype' => $outfit_type, 'lookaddons' => 0, 'maglevel' => 0, 'mana' => $cnf['mana'], 'manamax' => $cnf['mana'], 'manaspent' => 0, 'soul' => $cnf['soul'], 'town_id' => $character_data['town_id'], 'posx' => $cnf['default_pos']['x'], 'posy' => $cnf['default_pos']['y'], 'posz' => $cnf['default_pos']['z'], 'conditions' => '', 'cap' => $cnf['cap'], 'sex' => $character_data['sex'], 'lastlogin' => 0, 'lastip' => $character_data['lastip'], 'save' => 1, 'skull' => 0, 'skulltime' => 0, 'rank_id' => 0, 'guildnick' => '', 'lastlogout' => 0, 'blessings' => 0, 'direction' => 0, 'loss_experience' => 10, 'loss_mana' => 10, 'loss_skills' => 10, 'premend' => 0, 'online' => 0, 'balance' => 0);
    // TFS 1.0 rules
    if (Config('TFSVersion') === 'TFS_10') {
        unset($import_data['rank_id']);
        unset($import_data['guildnick']);
        unset($import_data['direction']);
        unset($import_data['loss_experience']);
        unset($import_data['loss_mana']);
        unset($import_data['loss_skills']);
        unset($import_data['loss_mana']);
        unset($import_data['premend']);
        unset($import_data['online']);
    }
    // Set correct experience for level
    $import_data['experience'] = level_to_experience($import_data['level']);
    // If you are no vocation (id 0), use these details instead:
    if ($character_data['vocation'] === '0') {
        $import_data['level'] = $cnf['nvlevel'];
        $import_data['experience'] = level_to_experience($cnf['nvlevel']);
        $import_data['health'] = $cnf['nvHealth'];
        $import_data['healthmax'] = $cnf['nvHealth'];
        $import_data['cap'] = $cnf['nvCap'];
        $import_data['mana'] = $cnf['nvMana'];
        $import_data['manamax'] = $cnf['nvMana'];
        $import_data['soul'] = $cnf['nvSoul'];
        if ($cnf['nvForceTown'] == 1) {
            $import_data['town_id'] = $cnf['nvTown'];
        }
    }
    $fields = array_keys($import_data);
    // Fetch select fields
    $data = array_values($import_data);
    // Fetch insert data
    $fields_sql = implode("`, `", $fields);
    // Convert array into SQL compatible string
    $data_sql = implode("', '", $data);
    // Convert array into SQL compatible string
    echo 1;
    mysql_insert("INSERT INTO `players`(`{$fields_sql}`) VALUES ('{$data_sql}');");
    $created = time();
    $charid = user_character_id($import_data['name']);
    echo 2;
    mysql_insert("INSERT INTO `znote_players`(`player_id`, `created`, `hide_char`, `comment`) VALUES ('{$charid}', '{$created}', '0', '');");
}
コード例 #2
0
ファイル: admin_skills.php プロジェクト: l04d/ZnoteAAC
        if ($config['TFSVersion'] != 'TFS_10') {
            mysql_update("UPDATE `player_skills` SET `value`='" . (int) $_POST['fist'] . "' WHERE `player_id`='{$pid}' AND `skillid`='0' LIMIT 1;");
            mysql_update("UPDATE `player_skills` SET `value`='" . (int) $_POST['club'] . "' WHERE `player_id`='{$pid}' AND `skillid`='1' LIMIT 1;");
            mysql_update("UPDATE `player_skills` SET `value`='" . (int) $_POST['sword'] . "' WHERE `player_id`='{$pid}' AND `skillid`='2' LIMIT 1;");
            mysql_update("UPDATE `player_skills` SET `value`='" . (int) $_POST['axe'] . "' WHERE `player_id`='{$pid}' AND `skillid`='3' LIMIT 1;");
            mysql_update("UPDATE `player_skills` SET `value`='" . (int) $_POST['dist'] . "' WHERE `player_id`='{$pid}' AND `skillid`='4' LIMIT 1;");
            mysql_update("UPDATE `player_skills` SET `value`='" . (int) $_POST['shield'] . "' WHERE `player_id`='{$pid}' AND `skillid`='5' LIMIT 1;");
            mysql_update("UPDATE `player_skills` SET `value`='" . (int) $_POST['fish'] . "' WHERE `player_id`='{$pid}' AND `skillid`='6' LIMIT 1;");
            mysql_update("UPDATE `players` SET `maglevel`='" . (int) $_POST['magic'] . "' WHERE `id`='{$pid}' LIMIT 1;");
            mysql_update("UPDATE `players` SET `vocation`='" . (int) $_POST['vocation'] . "' WHERE `id`='{$pid}' LIMIT 1;");
            mysql_update("UPDATE `players` SET `level`='" . $level . "' WHERE `id`='{$pid}' LIMIT 1;");
            mysql_update("UPDATE `players` SET `experience`='" . level_to_experience($level) . "' WHERE `id`='{$pid}' LIMIT 1;");
            // Update HP/mana/cap accordingly to level & vocation
            mysql_update("UPDATE `players` SET `health`='" . $newhp . "', `healthmax`='" . $newhp . "', `mana`='" . $newmp . "', `manamax`='" . $newmp . "', `cap`='" . $newcap . "' WHERE `id`='{$pid}' LIMIT 1;");
        } else {
            mysql_update("UPDATE `players` SET `health`='" . $newhp . "', `healthmax`='" . $newhp . "', `mana`='" . $newmp . "', `manamax`='" . $newmp . "', `cap`='" . $newcap . "', `vocation`='" . (int) $_POST['vocation'] . "', `skill_fist`='" . (int) $_POST['fist'] . "', `skill_club`='" . (int) $_POST['club'] . "', `skill_sword`='" . (int) $_POST['sword'] . "', `skill_axe`='" . (int) $_POST['axe'] . "', `skill_dist`='" . (int) $_POST['dist'] . "', `skill_shielding`='" . (int) $_POST['shield'] . "', `skill_fishing`='" . (int) $_POST['fish'] . "', `maglevel`='" . (int) $_POST['magic'] . "', `level`='" . $level . "', `experience`='" . level_to_experience($level) . "' WHERE `id`='{$pid}' LIMIT 1;");
        }
        ?>
<h1>Player skills updated!</h1>
<?php 
    } else {
        ?>
		<font color="red" size="7">Player must be offline!</font>
		<?php 
    }
}
// Stage 1: Fetch name
if (isset($_GET['name'])) {
    $name = getValue($_GET['name']);
} else {
    $name = false;