当前位置: 首页>>代码示例>>PHP>>正文


PHP is_npc函数代码示例

本文整理汇总了PHP中is_npc函数的典型用法代码示例。如果您正苦于以下问题:PHP is_npc函数的具体用法?PHP is_npc怎么用?PHP is_npc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了is_npc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: heal

function heal($healer, $patient, $cost)
{
    //$healer = preg_replace ('/[^a-z0-9_\.]/i', '', $healer);
    //$patient = preg_replace ('/[^a-z0-9_]/i', '', $patient);
    $cost = preg_replace('/[^0-9]/', '', $cost);
    $id = is_player($patient);
    $nid = is_npc($healer);
    $q = do_mysql("SELECT location, money, life, status1 FROM players WHERE id_player = '" . $id . "';");
    $p = mysql_fetch_assoc($q);
    $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $nid . "';");
    $loc = mysql_result($q, 0);
    if ($p['location'] != $loc) {
        return 0;
    }
    $p['life'] = explode('|', $p['life']);
    if ($p['life'][0] == $p['life'][1]) {
        exit_msg('целительство', 'вы итак полностью здоровы!');
    }
    $price = ceil(($p['life'][1] - $p['life'][0]) / 100) * $cost;
    if ($p['money'] < $price) {
        exit_msg('целительство', 'у вас нехватает денег, надо ' . $price . ' серебра!');
    }
    $p['money'] -= $price;
    $nlife = $p['life'][1] . '|' . $p['life'][1];
    $p['status1'][2] = 0;
    $p['status1'][3] = 0;
    $p['status1'][4] = 0;
    do_mysql("UPDATE players SET money = '" . $p['money'] . "', life = '" . $nlife . "', status1 = '" . $p['status1'] . "' WHERE id_player = '" . $id . "';");
    exit_msg('целительство', 'вы выздоровили! цена: ' . $price . ' серебра.');
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:30,代码来源:f_heal.php

示例2: healer_stop_b

function healer_stop_b($healer, $patient, $cost)
{
    //$healer = preg_replace ('/[^a-z0-9_\.]/i', '', $healer);
    //$patient = preg_replace ('/[^a-z0-9_]/i', '', $patient);
    $cost = preg_replace('/[^0-9]/', '', $cost);
    $id = is_player($patient);
    $nid = is_npc($healer);
    $q = do_mysql("SELECT location, money, status1 FROM players WHERE id_player = '" . $id . "';");
    $p = mysql_fetch_assoc($q);
    $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $nid . "';");
    $loc = mysql_result($q, 0);
    if ($p['location'] != $loc) {
        return 0;
    }
    if (!$p['status1'][2] && !$p['status1'][3] && !$p['status1'][4]) {
        exit_msg('целительство', 'вы итак полностью здоровы!');
    }
    $price = $cost;
    if ($p['money'] < $price) {
        exit_msg('целительство', 'у вас нехватает денег, надо ' . $price . ' серебра!');
    }
    $p['money'] -= $price;
    $p['status1'][2] = 0;
    $p['status1'][3] = 0;
    $p['status1'][4] = 0;
    do_mysql("UPDATE players SET money = '" . $p['money'] . "', status1 = '" . $p['status1'] . "' WHERE id_player = '" . $id . "';");
    exit_msg('целительство', 'вaши раны залечены! цена: ' . $price . ' серебра.');
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:28,代码来源:f_healer_stop_b.php

示例3: is_inloc

function is_inloc($login, $who)
{
    //$login = mysql_real_escape_string ($login);
    //$who = mysql_real_escape_string ($who);
    // lokacija igroka
    $id = is_player($login);
    if ($id) {
        $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';");
    } else {
        $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . is_npc($login) . "';");
    }
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $loc = mysql_result($q, 0);
    $id = is_player($who);
    if ($id) {
        $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';");
    } else {
        $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . is_npc($who) . "';");
    }
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $loc2 = mysql_result($q, 0);
    if ($loc == $loc2) {
        return 1;
    }
    return 0;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:30,代码来源:f_is_inloc.php

示例4: get_affected

function get_affected($name)
{
    //$name = preg_replace ('/[^a-z\._0-9]/i', '', $name);
    // pokachto tolqko chelam:
    $id = is_player($name);
    if ($id) {
        $q = do_mysql("SELECT affected FROM players WHERE id_player = '" . $id . "';");
        $a = mysql_result($q, 0);
    } else {
        $id = is_npc($name);
        if (!$id) {
            return 0;
        }
        $q = do_mysql("SELECT affected FROM npc WHERE id_npc = '" . $id . "';");
        if (!mysql_num_rows($q)) {
            return 0;
        }
        $a = mysql_result($q, 0);
    }
    if (!$a) {
        return 0;
    }
    $a = explode('|', $a);
    $c = count($a);
    for ($i = 0; $i < $c; $i++) {
        $a[$i] = explode(':', $a[$i]);
        $arr[] = $a[$i][0];
    }
    return $arr;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:30,代码来源:f_get_affected.php

示例5: teach_magic_from_sc

function teach_magic_from_sc($scroll, $npc, $login)
{
    //$scroll = preg_replace ('/[^a-z0-9_\.]/i', '', $scroll);
    //$npc = preg_replace ('/[^a-z0-9_\.]/i', '', $npc);
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    $nid = is_npc($npc);
    $id = is_player($login);
    // v odnoj li lokacii
    $q = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $nid . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $loc1 = mysql_result($q, 0);
    $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $loc2 = mysql_result($q, 0);
    if ($loc1 != $loc2) {
        return 0;
    }
    include_once 'modules/f_has_item.php';
    if (!has_item($scroll, $login)) {
        put_g_error('у вас нету свитка!');
    }
    $q = do_mysql("SELECT on_take, price FROM items WHERE fullname = '" . $scroll . "' AND type = 's';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $spell = mysql_fetch_assoc($q);
    // neumeet li on uzhe
    include_once 'modules/f_has_magic.php';
    if (has_magic($spell['on_take'], $login)) {
        put_g_error('вы уже умеете это заклинание!');
    }
    // cenu vyschitaem:
    $q = do_mysql("SELECT money FROM players WHERE id_player = '" . $id . "';");
    $money = mysql_result($q, 0);
    $cost = $spell['price'] * 10;
    if ($money < $cost) {
        put_g_error('нехватает серебра, нужно ' . $cost . ' серебреных!');
    }
    $money -= $cost;
    // dobavljaem zakl:
    $q = do_mysql("SELECT magic FROM players WHERE id_player = '" . $id . "';");
    $magic = mysql_result($q, 0);
    if (!$magic) {
        $magic = $spell['on_take'];
    } else {
        $magic .= '|' . $spell['on_take'];
    }
    // obnovim dannye:
    do_mysql("UPDATE players SET magic = '" . $magic . "', money = '" . $money . "' WHERE id_player = '" . $id . "';");
    // udaljaem svitok
    include_once 'modules/f_delete_item.php';
    delete_item($scroll);
    $q = do_mysql("SELECT name FROM magic WHERE fullname = '" . $spell['on_take'] . "';");
    $name = mysql_result($q, 0);
    exit_msg('магия', 'вы выучили заклинание ' . $name . ' за ' . $cost . ' серебреных!');
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:60,代码来源:f_teach_magic_from_sc.php

示例6: has_npc_quest

function has_npc_quest($npc)
{
    $id = is_npc($npc);
    $q = do_mysql("SELECT quest FROM npc WHERE id_npc = '" . $id . "';");
    $quest = mysql_result($q, 0);
    if ($quest) {
        return 1;
    } else {
        return 0;
    }
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:11,代码来源:f_has_npc_quest.php

示例7: end_battle

function end_battle($who)
{
    $id = is_player($who);
    if ($id) {
        do_mysql("UPDATE players SET in_battle = '0' WHERE id_player = '" . $id . "';");
    } else {
        $id = is_npc($who);
        do_mysql("UPDATE npc SET in_battle = '0' WHERE id_npc = '" . $id . "';");
    }
    return 1;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:11,代码来源:f_end_battle.php

示例8: block

function block($to)
{
    $id = is_player($to);
    if ($id) {
        $q = do_mysql("SELECT name, location FROM players WHERE id_player = '" . $id . "';");
        $p = mysql_fetch_assoc($q);
        add_journal($p['name'] . ' блокировал!', 'l.' . $p['location']);
    } else {
        $id = is_npc($to);
        $q = do_mysql("SELECT name, location FROM npc WHERE id_npc = '" . $id . "';");
        $n = mysql_fetch_assoc($q);
        add_journal($n['name'] . ' блокировал!', 'l.' . $n['location']);
    }
    return 1;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:15,代码来源:f_block.php

示例9: add_to_loc

function add_to_loc($loc, $who)
{
    // proverka dannyh
    //$who = preg_replace ('/[^a-z\._0-9]/i', '', $who);
    //$loc = preg_replace ('/[^a-z0-9\|]/i', '', $loc);
    if (is_npc($who)) {
        // vpishem npc
        $map = substr($loc, 0, 4);
        do_mysql("UPDATE npc SET location = '" . $loc . "', map = '" . $map . "' WHERE fullname = '" . $who . "';");
    } else {
        $log = substr($who, 0, 2);
        // vpishem igroka
        do_mysql("UPDATE players SET location = '" . $loc . "' WHERE login = '" . $log . "';");
    }
    return 1;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:16,代码来源:f_add_to_loc.php

示例10: get_npc_battle_har

function get_npc_battle_har($npc)
{
    //$npc = preg_replace ('/[^a-z\._0-9]/i', '', $npc);
    $id = is_npc($npc);
    $q = do_mysql("SELECT chanse FROM npc WHERE id_npc = '" . $id . "';");
    if (!mysql_num_rows($q)) {
        include 'modules/s_main.php';
    }
    $c = mysql_result($q, 0);
    $c = explode('~', $c);
    include_once 'modules/f_get_affected.php';
    $aff = get_affected($npc);
    if (is_in('osleplen', $aff)) {
        for ($i = 0; $i < 10; $i++) {
            $с[$i] = round($с[$i] / 2);
        }
    }
    return $c;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:19,代码来源:f_get_npc_battle_har.php

示例11: upd_last_attack

function upd_last_attack($pl)
{
    //$pl = preg_replace ('/[^a-z0-9_\.]/i', '', $pl);
    $now = time();
    $id = is_player($pl);
    if (!$id) {
        $id = is_npc($pl);
        // npc
        do_mysql("UPDATE npc SET lastattack = '" . $now . "' WHERE id_npc = '" . $id . "';");
        return 1;
    }
    $q = do_mysql("SELECT last FROM players WHERE id_player = '" . $id . "';");
    $last = mysql_result($q, 0);
    $last = explode('|', $last);
    $last[1] = $now;
    $nlast = $last[0] . '|' . $last[1] . '|' . $last[2] . '|' . $last[3] . '|' . $last[4] . '|' . $last[5] . '|' . $last[6] . '|' . $last[7] . '|' . $last[8];
    do_mysql("UPDATE players SET last = '" . $nlast . "' WHERE id_player = '" . $id . "';");
    return 1;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:19,代码来源:f_upd_last_attack.php

示例12: upd_affected

function upd_affected($name, $end = 0)
{
    //$name = preg_replace ('/[^a-z0-9_\.]/i', '', $name);
    $id = is_player($name);
    $n = 0;
    if ($id) {
        $q = do_mysql("SELECT affected FROM players WHERE id_player = '" . $id . "';");
    } else {
        $id = is_npc($name);
        $n = 1;
        $q = do_mysql("SELECT affected FROM npc WHERE id_npc = '" . $id . "';");
    }
    $aff = mysql_result($q, 0);
    if (!$aff) {
        return 1;
    }
    $aff = explode('|', $aff);
    $c = count($aff);
    for ($i = 0; $i < $c; $i++) {
        $aff[$i] = explode(':', $aff[$i]);
        //echo $aff[$i][0].' '.$aff[$i][1].' '.(time()).'<br/>';
        if ($aff[$i][1] <= time() || $end) {
            // dalee, esi estq takoj fail, spec izmenenija effekta ustanovim
            if (file_exists('modules/effects/e_end_' . $aff[$i][0] . '.php')) {
                include 'modules/effects/e_end_' . $aff[$i][0] . '.php';
            }
            unset($aff[$i]);
        }
        if (isset($aff[$i])) {
            $aff[$i] = implode(':', $aff[$i]);
        }
    }
    $aff = implode('|', $aff);
    if ($aff == '|') {
        $aff = '';
    }
    if (!$n) {
        do_mysql("UPDATE players SET affected = '" . $aff . "' WHERE id_player = '" . $id . "';");
    } else {
        do_mysql("UPDATE npc SET affected = '" . $aff . "' WHERE id_npc = '" . $id . "';");
    }
    return 1;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:43,代码来源:f_upd_affected.php

示例13: mag_summon

function mag_summon($spell, $login)
{
    //$spell = preg_replace ('/[^a-z0-9_]/i', '', $spell);
    //$login = preg_replace ('/[^a-z0-9_]/i', '', $login);
    $id = is_player($login);
    $q = do_mysql("SELECT cname FROM magic WHERE fullname = '" . $spell . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $fullname = mysql_result($q, 0);
    if (!$fullname) {
        return 0;
    }
    // zapros na lokaciju igroka i kolichestvo priruchennyh zhivotnyh
    $q = do_mysql("SELECT location FROM players WHERE id_player = '" . $id . "';");
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $loc = mysql_result($q, 0);
    $q = do_mysql("SELECT COUNT(*) FROM npc WHERE belongs = '" . $login . "';");
    $c = mysql_result($q, 0);
    if ($c > 0) {
        put_g_error('у вас уже есть нпц, принадлежащие вам');
    }
    // sozdaem npc:
    include_once 'modules/f_create_npc.php';
    $npc = create_npc($fullname, substr($loc, 0, 4), $loc);
    $nid = is_npc($npc);
    // izmenim imja:
    $q = do_mysql("SELECT name FROM npc WHERE id_npc = '" . $nid . "';");
    $name = mysql_result($q, 0);
    $nname = 'призванный ' . $name;
    $fullname = $npc . '.' . $login;
    // ataka:
    $q = do_mysql("SELECT in_battle FROM players WHERE id_player = '" . $id . "';");
    $inb = mysql_result($q, 0);
    do_mysql("UPDATE npc SET fullname = '" . $fullname . "', name = '" . $nname . "', belongs = '" . $login . "', move = '30', in_battle = '" . $inb . "', type = 'a' WHERE id_npc = '" . $nid . "';");
    $q = do_mysql("SELECT name FROM players WHERE id_player = '" . $id . "';");
    $pn = mysql_result($q, 0);
    add_journal($pn . ': призвал ' . $name . '!', 'l.' . $loc);
    return 1;
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:42,代码来源:f_mag_summon.php

示例14: get_npc_info

function get_npc_info($npc, $what)
{
    //$npc = preg_replace ('/[^a-z\._0-9]/i', '', $npc);
    //$what = preg_replace ('/[^a-z]/i', '', $what);
    // sbnachalo proverim chto za what
    // what == 'name' - imja
    // $what == 'all' - vse, razdroblenno otdatq
    // $what == 'location' - lokaciju
    // $what == 'is_alive' - zhiv li
    // $what == 'life' - zhiznq
    $id = is_npc($npc);
    if ($what == 'name') {
        $alo = do_mysql("SELECT name FROM npc WHERE id_npc = '" . $id . "';");
        $name = mysql_result($alo, 0);
        return $name;
    }
    if ($what == 'all') {
        $q = do_mysql("SELECT * FROM npc WHERE id_npc = '" . $id . "';");
        $all = mysql_fetch_assoc($q);
        $all['life'] = explode('|', $all['life']);
        return $all;
    }
    if ($what == 'location') {
        $alo = do_mysql("SELECT location FROM npc WHERE id_npc = '" . $id . "';");
        $loc = mysql_result($alo, 0);
        return $loc;
    }
    if ($what == 'is_alive') {
        $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . $id . "';");
        $al = mysql_result($q, 0);
        if (substr($al, 0, 1) == 0) {
            return 0;
        } else {
            return 1;
        }
    }
    if ($what == 'life') {
        $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . $id . "';");
        $al = mysql_result($q, 0);
        return $al;
    }
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:42,代码来源:f_get_npc_info.php

示例15: check_dead

function check_dead($who)
{
    //$who = preg_replace ('/[^a-z\._0-9]/i', '', $who);
    $id = is_player($who);
    if ($id) {
        $q = do_mysql("SELECT life FROM players WHERE id_player = '" . $id . "';");
    } else {
        $q = do_mysql("SELECT life FROM npc WHERE id_npc = '" . is_npc($who) . "';");
    }
    if (!mysql_num_rows($q)) {
        return 0;
    }
    $life = mysql_result($q, 0);
    $life = explode('|', $life);
    if (!$life[0]) {
        return 1;
    } else {
        return 0;
    }
}
开发者ID:nadvamir,项目名称:forgotten-story-mmorpg,代码行数:20,代码来源:f_check_dead.php


注:本文中的is_npc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。