Jump to content

xmosterx

Inactive Member
  • Posts

    25
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by xmosterx

  1. 8 minutes ago, TMP4 said:

    Use FreeBSD de 32 bits o cree una cárcel de 32 bits en su FreeBSD de 64 bits y compile allí.

    O mueva su src a la plataforma x64 si tiene las habilidades necesarias.

    I'm going to install on a 32-bit machine because I've spent hours trying to make the libraries compatible. Thanks!! I will post if it gives me optimal results.

  2. Spoiler
     [linking]   ../game_r43813_64....
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(socket.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(fdwatch.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(buffer.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(signal.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(log.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(utils.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(hangul.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(main.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libthecore/lib/libthecore.a(memcpy.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../libpoly/libpoly.a(Poly.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblua.a(lapi.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblua.a(ldo.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblua.a(lstate.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblualib.a(lauxlib.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblualib.a(lbaselib.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblualib.a(ldblib.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblualib.a(liolib.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblualib.a(lmathlib.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblualib.a(ltablib.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: ../../liblua/lib/liblualib.a(lstrlib.o) is incompatible with elf_i386_fbsd
    /usr/bin/ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
    clang-10: error: linker command failed with exit code 1 (use -v to see invocation)
    gmake[1]: *** [Makefile:133: ../game_r43813_64] Error 1
    gmake[1]: Leaving directory '/usr/src/Srcs/Server/game/src'
    gmake: *** [Makefile:93: all] Error 2

     

    Hello.

    I have this error when compiling the game/src. The db/src compiles and builds without issue.

    How do I fix library compatibility in this version of FreeBSD.

    I use this version of FreeBSD: 12.0-RELEASE FreeBSD 12.0-RELEASE r341666 GENERIC  amd64

  3. Hello a greeting!

    As the main theme says, I am looking for staff for a long-term project, one of which will be based on the Official (Global Multi Language) and the other (Hispanic, with the possibility of globalizing it), as well as some modifications which have excellent gameplay. , for which they will have the Player entertained. and they will bear fruit.

    The resources of administration payments and expenses, purchase of systems, etc., as well as VPS & others, will be paid by me, I do not want there to be extra income from the team, and if a member of the same wants to contribute for any totally different expenses. I am currently working locally on both servers, which are progressing 70%, which is a potential advance and I have good bases which have stability and that the errors that arise along the way are solved as a group and we can have quality services.

    Currently I'm looking for (take some descriptions, for those who don't know what it means):

    Trial Game Master (TGM): He is the Game Master in the training phase, however, this does not mean he does not have authority in the game, since he has the same functions and responsibilities as a full GM.
    Game Master (GM): He is in charge of the servers and the first contact of the players with questions regarding the game, technical problems, bans, complaints and other situations related to it, they are also in charge of guaranteeing that everything goes according to what set on the servers.
    Super Game Master (SGM): He is the person in charge of training and supervising the GMs, this refers to them efficiently carrying out their work and solving problems properly. They are also responsible for attending users with problems, complaints, doubts or bans that users have not been able to solve with the GMs.
    Game Admin (GA): Coordinates and trains the Game team, as well as their work and responsibilities. Its functions are to offer up-to-date information to the community, report problems that arise and ensure that the administration at stake is correct, assist users with problems that the SGMs cannot resolve.
    Board Admin (BA): Is the person in charge of all the information and help in the forum, which must be aware of everything pertinent that is presented in it and keep up to date with updates.
    Moderator (MOD): Person in charge together with (BA), for the help that is pertinent at the time it is needed, will also have an important role together with (DES) & (NM); which will be pending that the work of these two positions comply with his work.
    Designer (DES): He is the main person in charge of the graphic aspect of the servers, for which he will maintain the constant design in what is necessary.
    Newtwork Manager (NH): Person who is in charge of all the management of the web page and that the connections are working correctly, solves doubts about the state of the server among others.
    I am not looking for people who have a full time job, but who dedicate at least a maximum of 6 hours a day in the position that is designated later, this schedule can change depending on the course that the server takes, it may be that one day you have to be all the day and another day that you only last an hour in your position.

    For the role of Designer (DES), I already have all the graphical part of the server, I only need him to know about the subject and to modify it since everything is in .PSD.

    I am currently alone in the project and I would like to see what people are interested in these areas, except if you know something about Programming that is not included in it, you could show me your skills and thus work in that role.

    I am attentive to what information you can write to me on Discord: JohnTonS#5383

  4.   

    0518 09:11:24555 :: Traceback (most recent call last):
    
    0518 09:11:24555 ::   File "game.py", line 2914, in BINARY_ServerCommand_Run
    
    0518 09:11:24555 ::   File "stringCommander.py", line 63, in Run
    
    0518 09:11:24555 ::   File "stringCommander.py", line 31, in __call__
    
    0518 09:11:24555 ::   File "stringCommander.py", line 20, in __call__
    
    0518 09:11:24556 ::   File "game.py", line 3443, in ManagerItemshop
    
    0518 09:11:24556 :: ValueError
    0518 09:11:24556 :: : 
    0518 09:11:24556 :: invalid literal for int() with base 10: '0.4'
    0518 09:11:24556 :: 
    
    0518 09:11:24556 :: Unknown Server Command ITEMSHOP SET_LOG#25041#1#0.4#2022-05-18[_]04:41:24#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 | ITEMSHOP

    https://paste2.org/ka4F0CjF ------- game.py

    other error: https://metin2.download/picture/r3F9504x09DVmF8K988YXgTtGTP6KMUj/.gif

    Hello, I have this error, when making the purchase in the ItemShop.

  5. 0518 09:11:24555 :: Traceback (most recent call last):
    
    0518 09:11:24555 ::   File "game.py", line 2914, in BINARY_ServerCommand_Run
    
    0518 09:11:24555 ::   File "stringCommander.py", line 63, in Run
    
    0518 09:11:24555 ::   File "stringCommander.py", line 31, in __call__
    
    0518 09:11:24555 ::   File "stringCommander.py", line 20, in __call__
    
    0518 09:11:24556 ::   File "game.py", line 3443, in ManagerItemshop
    
    0518 09:11:24556 :: ValueError
    0518 09:11:24556 :: : 
    0518 09:11:24556 :: invalid literal for int() with base 10: '0.4'
    0518 09:11:24556 :: 
    
    0518 09:11:24556 :: Unknown Server Command ITEMSHOP SET_LOG#25041#1#0.4#2022-05-18[_]04:41:24#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0#0 | ITEMSHOP

    https://paste2.org/3dNWHJIN ------- game.py

     

    Hello, I have this error, when making the purchase in the ItemShop.

  6. Spoiler
    (gdb) file game
    Reading symbols from game...done.
    (gdb) core game.core
    [New LWP 100208]
    Core was generated by `game'.
    Program terminated with signal SIGSEGV, Segmentation fault.
    #0  0x2906f4f4 in vtable for __cxxabiv1::__si_class_type_info ()
       from /lib/libcxxrt.so.1
    (gdb) bt full
    #0  0x2906f4f4 in vtable for __cxxabiv1::__si_class_type_info ()
       from /lib/libcxxrt.so.1
    No symbol table info available.
    #1  0x289de0b4 in __cxxabiv1::__dynamic_cast (
        src_ptr=0x28a90940 <(anonymous namespace)::ctype_c>,
        src_type=0x28a864bc <typeinfo for std::locale::facet>,
        dst_type=0x28a86380 <typeinfo for std::ctype<char>>, src2dst=0)
        at ../../.././../gcc-4.9-20140119/libstdc++-v3/libsupc++/dyncast.cc:60
            vtable = <optimized out>
            prefix = <optimized out>
            whole_type = <optimized out>
            whole_ptr = <optimized out>
            result = {dst_ptr = 0x0,
              whole2dst = __cxxabiv1::__class_type_info::__unknown,
              whole2src = __cxxabiv1::__class_type_info::__unknown,
              dst2src = __cxxabiv1::__class_type_info::__unknown,
              whole_details = 16}
    #2  0x28a135cb in std::has_facet<std::ctype<char> > (__loc=...)
        at /usr/ports/lang/gcc49/work/build/i386-portbld-freebsd9.2/libstdc++-v3/inc                                                                                        lude/bits/locale_classes.tcc:110
            __i = <optimized out>
            __facets = 0x28a90c00 <(anonymous namespace)::facet_vec>
    #3  0x28a06541 in std::basic_ios<char, std::char_traits<char> >::_M_cache_locale                                                                                        --Type <RET> for more, q to quit, c to continue without paging--
     (this=this@entry=0x28a8fb44 <std::cout+4>, __loc=...) at /usr/ports/lang/gcc49/work/build/i386-portbld-freebsd9.2/libstdc++-v3/include/bits/basic_ios.tcc:159
    No locals.
    #4  0x28a066e0 in std::basic_ios<char, std::char_traits<char> >::init (this=this@entry=0x28a8fb44 <std::cout+4>, __sb=__sb@entry=
        0x28a8f660 <__gnu_internal::buf_cout_sync>) at /usr/ports/lang/gcc49/work/build/i386-portbld-freebsd9.2/libstdc++-v3/include/bits/basic_ios.tcc:132
    No locals.
    #5  0x289f7bf4 in std::basic_ostream<char, std::char_traits<char> >::basic_ostream (__sb=<optimized out>, this=<optimized out>, __in_chrg=<optimized out>,
        __vtt_parm=<optimized out>) at /usr/ports/lang/gcc49/work/build/i386-portbld-freebsd9.2/libstdc++-v3/include/ostream:85
    No locals.
    #6  std::ios_base::Init::Init (this=0x86ca06b <std::__ioinit>) at ../../../.././../gcc-4.9-20140119/libstdc++-v3/src/c++98/ios_init.cc:91
    No locals.
    #7  0x0805440c in __static_initialization_and_destruction_0 (__initialize_p=1, __priority=65535) at /usr/local/lib/gcc49/include/c++/iostream:74
    No locals.
    #8  _GLOBAL__sub_I__ZN16CDungeonTurnBackC2Ev () at dungeon_turn_back.cpp:182
    No locals.
    #9  0x285ba424 in ?? () from /libexec/ld-elf.so.1
    No symbol table info available.
    #10 0x285b9667 in ?? () from /libexec/ld-elf.so.1
    No symbol table info available.
    #11 0x285b701e in ?? () from /libexec/ld-elf.so.1
    No symbol table info available.

     

     

    I have this problem the game does not start.

  7. Error intro rulete:

    Spoiler
    0515 16:29:32215 :: Traceback (most recent call last):
    
    0515 16:29:32215 ::   File "game.py", line 2625, in BINARY_ServerCommand_Run
    
    0515 16:29:32216 ::   File "stringCommander.py", line 63, in Run
    
    0515 16:29:32216 ::   File "stringCommander.py", line 31, in __call__
    
    0515 16:29:32216 ::   File "stringCommander.py", line 20, in __call__
    
    0515 16:29:32216 ::   File "game.py", line 3077, in ManagerItemshop
    
    0515 16:29:32217 ::   File "uiItemShop.py", line 1101, in SpinWheel
    
    0515 16:29:32217 ::   File "uiToolTip.py", line 1827, in AddItemData
    
    0515 16:29:32217 :: IndexError
    0515 16:29:32217 :: : 
    0515 16:29:32217 :: list index out of range
    0515 16:29:32217 :: 
    
    0515 16:29:32217 :: Unknown Server Command ITEMSHOP ALLOW_SPIN_WHEEL# | ITEMSHOP

     

     

  8. Hi, I installed Shang's itemshop which works perfectly, but I don't know why the GM ZONE tab doesn't appear, which is where items are added e.t.c.

    Everything is configured name of the PJ GM, but this session does not appear.

    LINKPaste itemshop_lib.lua

    LINK QUESTPaste itemshop_manager.quest

    URL IMG ERROR: https://metin2.download/picture/C4R9k3Gl737Dr9rYf2WwXk5518Yk3Gp3/.png

     

    ITEMSHOP_CONFIG:

    Spoiler
    ACCOUNT_TABLE: account.account
    COINS_COLUMN: coins
    DRS_COLUMN: drs
    OTHER_SHOP_TABLE: player.player
    OTHER_COLUMN: pz
    ITEMSHOP_ITEMS_TABLE: account.itemshop_items
    DRSSHOP_ITEMS_TABLE: account.drsshop_items
    OTHERSHOP_ITEMS_TABLE: account.3rdshop_items
    ITEMSHOP_LOGS_TABLE: account.itemshop_logs
    ITEMSHOP_CATEGORY_COUNT: 15
    DRSSHOP_CATEGORY_COUNT: 15
    OTHERSHOP_CATEGORY_COUNT: 15
    ENABLE_ADMIN_PANEL: 1
    ADMIN_PANEL_MEMBERS: John
    WHEEL_LIMIT_TIME_SPINS_MINUTES: 5
    WHEEL_LIMIT_SPINS_TIME: 2
    WHEEL_COST_DRS: 0
    WHEEL_COST: 10
    WHEEL_BAD_ITEMS: 41003,41004,41117,41118,41119,41120,41121,41122,41328,41329,41330,41331,41332,41333,41334,41335,41336,41337,41338,41339,41340,41341,41342,41343,41344,41345,41346,41347,41348,41349,41350,41351,41352,41353,41354,41355,41356,41357,41358,41359,41360,41361,41362,41363,41364,41365,41366,41367,41368,41369,41370,41371,41372,41373,41374,41375,41376,41377,41378,41379,41380,41381,41382,41383,41384,41385,41386,41387,41388,41389,41390,41391,41307,41308,41315,41316,45003,45004,45005,45006,45007,45008,45009,45010,45053,45054,45055,45056,45057,45058,45164,45165,45166,27001,27002,27003,27004,27005,27006,27001,27002,27003,27004,27005,27006,27001,27002,27003,27004,27005,27006,27001,27002,27003,27004,27005,27006,18049,18059,18069,18079
    WHEEL_GOOD_ITEMS: 25041,53002,72702,27992,27993,27994,71124,71125,50107,71015
    TXT_NO_COINS_BUY_ITEM: No tienes suficientes coins para comprar este item.
    TXT_NO_DRS_BUY_ITEM: No tienes suficientes drs para comprar este item.
    TXT_NO_3RD_BUY_ITEM: No tienes suficientes pz para comprar este item.
    TXT_NO_COINS_SPIN_WHEEL: No tienes suficientes coins para hacer girar la ruleta.
    TXT_BOUGHT_ITEM_W_AMOUNT: Usted ha comprado x%d %s por %d %s!
    TXT_BOUGHT_ITEM_WO_AMOUNT: Usted ha comprado %s por %d %s!
    TXT_SUCCESS_ADDED_ITEM: ¡Has añadido el item con éxito!
    TXT_SUCCESS_TIME_CATEGORY: ¡Ha agregado un descuento de %d%% durante %d segundos a la categoría %d!
    TXT_SUCCESS_TIME_ITEM: Has añadido un descuento de %d%% durante %d segundos para el item!
    TXT_COIN_NAME: MD's
    TXT_DRS_NAME: DR's
    TXT_3RD_NAME: AP's
    TXT_NO_MORE_SPINS: Has alcanzado el límite de giros de la ruleta.
    TXT_WHEEL_WAIT_TIME_W_HOURS: Tienes que esperar a que %dh y %dm vuelvan a girar la ruleta.
    TXT_WHEEL_WAIT_TIME_WO_HOURS: Tienes que esperar %dm para volver a girar la ruleta.
    TXT_WHEEL_WAIT_TIME_W_SEC: Tienes que esperar %ds para volver a girar la ruleta.
    TXT_SUCCESS_DELETED_ITEM: ¡Has eliminado el item con éxito!
    TXT_SUCCESS_CHANGED_ITEM_PRICE: ¡Has cambiado el precio del item con éxito!
    TXT_GLOBAL_NEW_ITEM: ¡Hay nuevos items disponibles en la ItemShop!
    TXT_GLOBAL_DISCOUNT: ¡No hay descuentos en algunos items en la ItemShop!
    TXT_GLOBAL_EDITED_PRICE: ¡Se han cambiado los precios de algunos items desde la ItemShop!
    TXT_NOT_ENOUGH_INVENTORY: ¡No tienes suficiente inventario para comprar el item!

     

     

  9. Hello, I try to open a system from the F5 key, but it does not do anything and there is no syserr. What could it be?

    game.py:

    Spoiler
    Called from F5:
    		onPressKeyDict[app.DIK_F5] = lambda : self.OpenTicketWindow()
    
    
    Function:
    	def OpenTicketWindow(self):
    		constInfo.Tickets['QCMD'] = 'OPEN#'
    		event.QuestButtonClick(constInfo.Tickets['QID'])

     

     

  10. Hello, any help, I try to add the function: mysql_direct_query and I have this novelty when compiling.

    Error:

    Spoiler
    questlua_global.cpp:1621:8: error: no member named 'auto_ptr' in namespace 'std'
                    std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery(lua_tostring(L, 1)));
                    ~~~~~^
    questlua_global.cpp:1621:17: error: unexpected type name 'SQLMsg': expected expression
                    std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery(lua_tostring(L, 1)));
                                  ^
    questlua_global.cpp:1621:30: error: use of undeclared identifier 'DBManager'; did you mean 'LogManager'?
                    std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery(lua_tostring(L, 1)));
                                               ^~~~~~~~~
                                               LogManager
    ./log.h:18:7: note: 'LogManager' declared here
    class LogManager : public singleton<LogManager>
          ^
    questlua_global.cpp:1621:52: error: no member named 'DirectQuery' in 'LogManager'
                    std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery(lua_tostring(L, 1)));
                                               ~~~~~~~~~~~~~~~~~~~~~ ^
    questlua_global.cpp:1622:7: error: use of undeclared identifier 'pMsg'
                    if (pMsg.get())
                        ^
    questlua_global.cpp:1625:22: error: use of undeclared identifier 'pMsg'
                            lua_pushnumber(L, pMsg->Get()->uiAffectedRows);
                                              ^
    questlua_global.cpp:1631:8: error: use of undeclared identifier 'pMsg'
                                            !(pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == (uint32_t)-1))
                                              ^
    questlua_global.cpp:1631:44: error: use of undeclared identifier 'pMsg'
                                            !(pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == (uint32_t)-1))
                                                                                  ^
    questlua_global.cpp:1630:18: error: use of undeclared identifier 'pMsg'
                            if ((result = pMsg->Get()->pSQLResult) &&
                                          ^
    9 errors generated.
    gmake: *** [Makefile:126: .obj/questlua_global.o] Error 1

     

    My questlua_global.cpp

     

    Spoiler
    #include "stdafx.h"
    #include <sstream>
    #include "constants.h"
    #include "char.h"
    #include "char_manager.h"
    #include "log.h"
    #include "questmanager.h"
    #include "questlua.h"
    #include "questevent.h"
    #include "config.h"
    #include "mining.h"
    #include "fishing.h"
    #include "priv_manager.h"
    #include "utils.h"
    #include "p2p.h"
    #include "item_manager.h"
    #include "mob_manager.h"
    #include "start_position.h"
    #include "over9refine.h"
    #include "OXEvent.h"
    #include "regen.h"
    #include "cmd.h"
    #include "guild.h"
    #include "guild_manager.h"
    #include "sectree_manager.h"
    #include "desc.h"
    
    #undef sys_err
    #ifndef __WIN32__
    #	define sys_err(fmt, args...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, ##args)
    #else
    #	define sys_err(fmt, ...) quest::CQuestManager::instance().QuestError(__FUNCTION__, __LINE__, fmt, __VA_ARGS__)
    #endif
    
    extern ACMD(do_block_chat);
    
    namespace quest
    {
    	int _get_locale(lua_State* L)
    	{
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    		lua_pushstring(L, ch ? get_locale(ch->GetLanguage()) : get_locale(LOCALE_DEFAULT));
    		return 1;
    	}
    
    	int _locale_quest(lua_State* L)
    	{
    		if (lua_isnumber(L, 1))
    		{
    			LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    			if (ch)
    			{
    				const char* c_szBuff = LC_LOCALE_QUEST_TEXT(lua_tonumber(L, 1), ch->GetLanguage());
    				lua_pushstring(L, c_szBuff);
    			}
    			else
    				lua_pushstring(L, "");
    		}
    		else
    			lua_pushstring(L, "");
    
    		return 1;
    	}
    
    	int _number(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2))
    			lua_pushnumber(L, 0);
    		else
    			lua_pushnumber(L, number((int)lua_tonumber(L, 1), (int)lua_tonumber(L, 2)));
    		return 1;
    	}
    
    	int _time_to_str(lua_State* L)
    	{
    		time_t curTime = (time_t)lua_tonumber(L, -1);
    		lua_pushstring(L, asctime(gmtime(&curTime)));
    		return 1;
    	}
    
    	int _say(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    		CQuestManager::Instance().AddScript(s.str() + "[ENTER]");
    		return 0;
    	}
    
    	int _chat(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    		CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_TALKING, "%s", s.str().c_str());
    		return 0;
    	}
    
    	int _cmdchat(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    		CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_COMMAND, "%s", s.str().c_str());
    		return 0;
    	}
    
    	int _syschat(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    		CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_INFO, "%s", s.str().c_str());
    		return 0;
    	}
    
    	int _notice(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    		CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_NOTICE, "%s", s.str().c_str());
    		return 0;
    	}
    
    	int _big_notice(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    		CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_BIG_NOTICE, "%s", s.str().c_str());
    		return 0;
    	}
    
    	int _left_image(lua_State* L)
    	{
    		if (lua_isstring(L, -1))
    		{
    			string s = lua_tostring(L, -1);
    			CQuestManager::Instance().AddScript("[LEFTIMAGE src;" + s + "]");
    		}
    		return 0;
    	}
    
    	int _top_image(lua_State* L)
    	{
    		if (lua_isstring(L, -1))
    		{
    			string s = lua_tostring(L, -1);
    			CQuestManager::Instance().AddScript("[TOPIMAGE src;" + s + "]");
    		}
    		return 0;
    	}
    
    	int _set_skin(lua_State* L) // Quest UI style
    	{
    		if (lua_isnumber(L, -1))
    		{
    			CQuestManager::Instance().SetSkinStyle((int)rint(lua_tonumber(L, -1)));
    		}
    		else
    		{
    			sys_err("QUEST wrong skin index");
    		}
    		return 0;
    	}
    
    	int _set_server_timer(lua_State* L)
    	{
    		int n = lua_gettop(L);
    		if ((n != 2 || !lua_isnumber(L, 2) || !lua_isstring(L, 1)) &&
    			(n != 3 || !lua_isstring(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3)))
    		{
    			sys_err("QUEST set_server_timer argument count wrong.");
    			return 0;
    		}
    
    		const char* name = lua_tostring(L, 1);
    		double t = lua_tonumber(L, 2);
    		DWORD arg = 0;
    
    		CQuestManager& q = CQuestManager::instance();
    
    		if (lua_isnumber(L, 3))
    			arg = (DWORD)lua_tonumber(L, 3);
    
    		int timernpc = q.LoadTimerScript(name);
    
    		LPEVENT event = quest_create_server_timer_event(name, t, timernpc, false, arg);
    		q.AddServerTimer(name, arg, event);
    		return 0;
    	}
    
    	int _set_server_loop_timer(lua_State* L)
    	{
    		int n = lua_gettop(L);
    		if ((n != 2 || !lua_isnumber(L, 2) || !lua_isstring(L, 1)) &&
    			(n != 3 || !lua_isstring(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3)))
    		{
    			sys_err("QUEST set_server_timer argument count wrong.");
    			return 0;
    		}
    
    		const char* name = lua_tostring(L, 1);
    		double t = lua_tonumber(L, 2);
    		DWORD arg = 0;
    		CQuestManager& q = CQuestManager::instance();
    
    		if (lua_isnumber(L, 3))
    			arg = (DWORD)lua_tonumber(L, 3);
    
    		int timernpc = q.LoadTimerScript(name);
    
    		LPEVENT event = quest_create_server_timer_event(name, t, timernpc, true, arg);
    		q.AddServerTimer(name, arg, event);
    		return 0;
    	}
    
    	int _clear_server_timer(lua_State* L)
    	{
    		CQuestManager& q = CQuestManager::instance();
    		const char* name = lua_tostring(L, 1);
    		DWORD arg = (DWORD)lua_tonumber(L, 2);
    		q.ClearServerTimer(name, arg);
    		return 0;
    	}
    
    	int _set_named_loop_timer(lua_State* L)
    	{
    		int n = lua_gettop(L);
    
    		if (n != 2 || !lua_isnumber(L, -1) || !lua_isstring(L, -2))
    			sys_err("QUEST set_timer argument count wrong.");
    		else
    		{
    			const char* name = lua_tostring(L, -2);
    			double t = lua_tonumber(L, -1);
    
    			CQuestManager& q = CQuestManager::instance();
    			int timernpc = q.LoadTimerScript(name);
    			q.GetCurrentPC()->AddTimer(name, quest_create_timer_event(name, q.GetCurrentCharacterPtr()->GetPlayerID(), t, timernpc, true));
    		}
    
    		return 0;
    	}
    
    	int _get_server_timer_arg(lua_State* L)
    	{
    		lua_pushnumber(L, CQuestManager::instance().GetServerTimerArg());
    		return 1;
    	}
    
    	int _set_timer(lua_State* L)
    	{
    		if (lua_gettop(L) != 1 || !lua_isnumber(L, -1))
    			sys_err("QUEST invalid argument.");
    		else
    		{
    			double t = lua_tonumber(L, -1);
    
    			CQuestManager& q = CQuestManager::instance();
    			quest_create_timer_event("", q.GetCurrentCharacterPtr()->GetPlayerID(), t);
    		}
    
    		return 0;
    	}
    
    	int _set_named_timer(lua_State* L)
    	{
    		int n = lua_gettop(L);
    
    		if (n != 2 || !lua_isnumber(L, -1) || !lua_isstring(L, -2))
    		{
    			sys_err("QUEST set_timer argument count wrong.");
    		}
    		else
    		{
    			const char* name = lua_tostring(L, -2);
    			double t = lua_tonumber(L, -1);
    
    			CQuestManager& q = CQuestManager::instance();
    			int timernpc = q.LoadTimerScript(name);
    			q.GetCurrentPC()->AddTimer(name, quest_create_timer_event(name, q.GetCurrentCharacterPtr()->GetPlayerID(), t, timernpc));
    		}
    
    		return 0;
    	}
    
    	int _timer(lua_State* L)
    	{
    		if (lua_gettop(L) == 1)
    			return _set_timer(L);
    		else
    			return _set_named_timer(L);
    	}
    
    	int _clear_named_timer(lua_State* L)
    	{
    		int n = lua_gettop(L);
    
    		if (n != 1 || !lua_isstring(L, -1))
    			sys_err("QUEST set_timer argument count wrong.");
    		else
    		{
    			CQuestManager& q = CQuestManager::instance();
    			q.GetCurrentPC()->RemoveTimer(lua_tostring(L, -1));
    		}
    
    		return 0;
    	}
    
    	int _getnpcid(lua_State* L)
    	{
    		const char* name = lua_tostring(L, -1);
    		CQuestManager& q = CQuestManager::instance();
    		lua_pushnumber(L, q.FindNPCIDByName(name));
    		return 1;
    	}
    
    	int _is_test_server(lua_State* L)
    	{
    		lua_pushboolean(L, test_server);
    		return 1;
    	}
    
    	int _is_speed_server(lua_State* L)
    	{
    		lua_pushboolean(L, speed_server);
    		return 1;
    	}
    
    	int _raw_script(lua_State* L)
    	{
    		if (test_server)
    			sys_log(0, "_raw_script : %s ", lua_tostring(L, -1));
    
    		if (lua_isstring(L, -1))
    			CQuestManager::Instance().AddScript(lua_tostring(L, -1));
    		else
    			sys_err("QUEST wrong argument: questname: %s", CQuestManager::instance().GetCurrentQuestName().c_str());
    
    		return 0;
    	}
    
    	int _char_log(lua_State* L)
    	{
    		CQuestManager& q = CQuestManager::instance();
    		LPCHARACTER ch = q.GetCurrentCharacterPtr();
    
    		DWORD what = 0;
    		const char* how = "";
    		const char* hint = "";
    
    		if (lua_isnumber(L, 1)) what = (DWORD)lua_tonumber(L, 1);
    		if (lua_isstring(L, 2)) how = lua_tostring(L, 2);
    		if (lua_tostring(L, 3)) hint = lua_tostring(L, 3);
    
    		LogManager::instance().CharLog(ch, what, how, hint);
    		return 0;
    	}
    
    	int _item_log(lua_State* L)
    	{
    		CQuestManager& q = CQuestManager::instance();
    		LPCHARACTER ch = q.GetCurrentCharacterPtr();
    
    		DWORD dwItemID = 0;
    		const char* how = "";
    		const char* hint = "";
    
    		if (lua_isnumber(L, 1)) dwItemID = (DWORD)lua_tonumber(L, 1);
    		if (lua_isstring(L, 2)) how = lua_tostring(L, 2);
    		if (lua_tostring(L, 3)) hint = lua_tostring(L, 3);
    
    		LPITEM item = ITEM_MANAGER::instance().Find(dwItemID);
    
    		if (item)
    			LogManager::instance().ItemLog(ch, item, how, hint);
    
    		return 0;
    	}
    
    	int _syslog(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1) || !lua_isstring(L, 2))
    			return 0;
    
    		if (lua_tonumber(L, 1) >= 1)
    		{
    			if (!test_server)
    				return 0;
    		}
    
    		PC* pc = CQuestManager::instance().GetCurrentPC();
    
    		if (!pc)
    			return 0;
    
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    
    		if (!ch)
    			return 0;
    
    		sys_log(0, "QUEST: quest: %s player: %s : %s", pc->GetCurrentQuestName().c_str(), ch->GetName(), lua_tostring(L, 2));
    
    		if (TRUE == test_server)
    		{
    			ch->ChatPacket(CHAT_TYPE_INFO, "QUEST_SYSLOG %s", lua_tostring(L, 2));
    		}
    
    		return 0;
    	}
    
    	int _syserr(lua_State* L)
    	{
    		if (!lua_isstring(L, 1))
    			return 0;
    
    		PC* pc = CQuestManager::instance().GetCurrentPC();
    
    		if (!pc)
    			return 0;
    
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    
    		if (!ch)
    			return 0;
    
    		sys_err("QUEST: quest: %s player: %s : %s", pc->GetCurrentQuestName().c_str(), ch->GetName(), lua_tostring(L, 1));
    		ch->ChatPacket(CHAT_TYPE_INFO, "QUEST_SYSERR %s", lua_tostring(L, 1));
    		return 0;
    	}
    
    	// LUA_ADD_BGM_INFO
    	int _set_bgm_volume_enable(lua_State* L)
    	{
    		CHARACTER_SetBGMVolumeEnable();
    
    		return 0;
    	}
    
    	int _add_bgm_info(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1) || !lua_isstring(L, 2))
    			return 0;
    
    		int mapIndex = (int)lua_tonumber(L, 1);
    
    		const char* bgmName = lua_tostring(L, 2);
    		if (!bgmName)
    			return 0;
    
    		float bgmVol = lua_isnumber(L, 3) ? lua_tonumber(L, 3) : (1.0f / 5.0f) * 0.1f;
    
    		CHARACTER_AddBGMInfo(mapIndex, bgmName, bgmVol);
    
    		return 0;
    	}
    	// END_OF_LUA_ADD_BGM_INFO
    
    	// LUA_ADD_GOTO_INFO
    	int _add_goto_info(lua_State* L)
    	{
    		const char* name = lua_tostring(L, 1);
    
    		int empire = (int)lua_tonumber(L, 2);
    		int mapIndex = (int)lua_tonumber(L, 3);
    		int x = (int)lua_tonumber(L, 4);
    		int y = (int)lua_tonumber(L, 5);
    
    		if (!name)
    			return 0;
    
    		CHARACTER_AddGotoInfo(name, empire, mapIndex, x, y);
    		return 0;
    	}
    	// END_OF_LUA_ADD_GOTO_INFO
    
    	// REFINE_PICK
    	int _refine_pick(lua_State* L)
    	{
    		BYTE bCell = (BYTE)lua_tonumber(L, -1);
    
    		CQuestManager& q = CQuestManager::instance();
    
    		LPCHARACTER ch = q.GetCurrentCharacterPtr();
    
    		LPITEM item = ch->GetInventoryItem(bCell);
    
    		int ret = mining::RealRefinePick(ch, item);
    		lua_pushnumber(L, ret);
    		return 1;
    	}
    	// END_OF_REFINE_PICK
    
    	int _fish_real_refine_rod(lua_State* L)
    	{
    		BYTE bCell = (BYTE)lua_tonumber(L, -1);
    
    		CQuestManager& q = CQuestManager::instance();
    
    		LPCHARACTER ch = q.GetCurrentCharacterPtr();
    
    		LPITEM item = ch->GetInventoryItem(bCell);
    
    		int ret = fishing::RealRefineRod(ch, item);
    		lua_pushnumber(L, ret);
    		return 1;
    	}
    
    	int _give_char_privilege(lua_State* L)
    	{
    		int pid = CQuestManager::instance().GetCurrentCharacterPtr()->GetPlayerID();
    		int type = (int)lua_tonumber(L, 1);
    		int value = (int)lua_tonumber(L, 2);
    
    		if (MAX_PRIV_NUM <= type)
    		{
    			sys_err("PRIV_MANAGER: _give_char_privilege: wrong empire priv type(%u)", type);
    			return 0;
    		}
    
    		CPrivManager::instance().RequestGiveCharacterPriv(pid, type, value);
    
    		return 0;
    	}
    
    	int _give_empire_privilege(lua_State* L)
    	{
    		int empire = (int)lua_tonumber(L, 1);
    		int type = (int)lua_tonumber(L, 2);
    		int value = (int)lua_tonumber(L, 3);
    		int time = (int)lua_tonumber(L, 4);
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    
    		if (MAX_PRIV_NUM <= type)
    		{
    			sys_err("PRIV_MANAGER: _give_empire_privilege: wrong empire priv type(%u)", type);
    			return 0;
    		}
    
    		if (ch)
    			sys_log(0, "_give_empire_privileage(empire=%d, type=%d, value=%d, time=%d), by quest, %s",
    				empire, type, value, time, ch->GetName());
    		else
    			sys_log(0, "_give_empire_privileage(empire=%d, type=%d, value=%d, time=%d), by quest, NULL",
    				empire, type, value, time);
    
    		CPrivManager::instance().RequestGiveEmpirePriv(empire, type, value, time);
    		return 0;
    	}
    
    	int _give_guild_privilege(lua_State* L)
    	{
    		int guild_id = (int)lua_tonumber(L, 1);
    		int type = (int)lua_tonumber(L, 2);
    		int value = (int)lua_tonumber(L, 3);
    		int time = (int)lua_tonumber(L, 4);
    
    		if (MAX_PRIV_NUM <= type)
    		{
    			sys_err("PRIV_MANAGER: _give_guild_privilege: wrong empire priv type(%u)", type);
    			return 0;
    		}
    
    		sys_log(0, "_give_guild_privileage(empire=%d, type=%d, value=%d, time=%d)",
    			guild_id, type, value, time);
    
    		CPrivManager::instance().RequestGiveGuildPriv(guild_id, type, value, time);
    
    		return 0;
    	}
    
    	int _get_empire_privilege_string(lua_State* L)
    	{
    		int empire = (int)lua_tonumber(L, 1);
    		ostringstream os;
    		bool found = false;
    
    		for (int type = PRIV_NONE + 1; type < MAX_PRIV_NUM; ++type)
    		{
    			CPrivManager::SPrivEmpireData* pkPrivEmpireData = CPrivManager::instance().GetPrivByEmpireEx(empire, type);
    
    			if (pkPrivEmpireData && pkPrivEmpireData->m_value)
    			{
    				if (found)
    					os << ", ";
    
    				os << LC_TEXT(c_apszPrivNames[type]) << " : " <<
    					pkPrivEmpireData->m_value << "%" << " (" <<
    					((pkPrivEmpireData->m_end_time_sec - get_global_time()) / 3600.0f) << " hours)" << endl;
    				found = true;
    			}
    		}
    
    		if (!found)
    			os << "None!" << endl;
    
    		lua_pushstring(L, os.str().c_str());
    		return 1;
    	}
    
    	int _get_empire_privilege(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2))
    		{
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    		int empire = (int)lua_tonumber(L, 1);
    		int type = (int)lua_tonumber(L, 2);
    		int value = CPrivManager::instance().GetPrivByEmpire(empire, type);
    		lua_pushnumber(L, value);
    		return 1;
    	}
    
    	int _get_guild_privilege_string(lua_State* L)
    	{
    		int guild = (int)lua_tonumber(L, 1);
    		ostringstream os;
    		bool found = false;
    
    		for (int type = PRIV_NONE + 1; type < MAX_PRIV_NUM; ++type)
    		{
    			const SPrivGuildData* pPrivGuildData = CPrivManager::instance().GetPrivByGuildEx(guild, type);
    
    			if (pPrivGuildData && pPrivGuildData->value)
    			{
    				if (found)
    					os << ", ";
    
    				os << LC_TEXT(c_apszPrivNames[type]) << " : " << pPrivGuildData->value << "%"
    					<< " (" << ((pPrivGuildData->end_time_sec - get_global_time()) / 3600.0f) << " hours)" << endl;
    				found = true;
    			}
    		}
    
    		if (!found)
    			os << "None!" << endl;
    
    		lua_pushstring(L, os.str().c_str());
    		return 1;
    	}
    
    	int _get_guildid_byname(lua_State* L)
    	{
    		if (!lua_isstring(L, 1))
    		{
    			sys_err("_get_guildid_byname() - invalud argument");
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    
    		const char* pszGuildName = lua_tostring(L, 1);
    		CGuild* pFindGuild = CGuildManager::instance().FindGuildByName(pszGuildName);
    		if (pFindGuild)
    			lua_pushnumber(L, pFindGuild->GetID());
    		else
    			lua_pushnumber(L, 0);
    
    		return 1;
    	}
    
    	int _get_guild_privilege(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2))
    		{
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    		int guild = (int)lua_tonumber(L, 1);
    		int type = (int)lua_tonumber(L, 2);
    		int value = CPrivManager::instance().GetPrivByGuild(guild, type);
    		lua_pushnumber(L, value);
    		return 1;
    	}
    
    	int _item_name(lua_State* L)
    	{
    		if (lua_isnumber(L, 1))
    		{
    			DWORD dwVnum = (DWORD)lua_tonumber(L, 1);
    			TItemTable* pTable = ITEM_MANAGER::instance().GetTable(dwVnum);
    
    			if (pTable)
    			{
    				LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    				lua_pushstring(L, LC_LOCALE_ITEM_TEXT(dwVnum, ch ? ch->GetLanguage() : LOCALE_DEFAULT));
    			}
    			else
    				lua_pushstring(L, "");
    		}
    		else
    			lua_pushstring(L, "");
    
    		return 1;
    	}
    
    	int _mob_name(lua_State* L)
    	{
    		if (lua_isnumber(L, 1))
    		{
    			DWORD dwVnum = (DWORD)lua_tonumber(L, 1);
    			const CMob* pkMob = CMobManager::instance().Get(dwVnum);
    
    			if (pkMob)
    			{
    				LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    				lua_pushstring(L, LC_LOCALE_MOB_TEXT(dwVnum, ch ? ch->GetLanguage() : LOCALE_DEFAULT));
    			}
    			else
    				lua_pushstring(L, "");
    		}
    		else
    			lua_pushstring(L, "");
    
    		return 1;
    	}
    
    	int _mob_vnum(lua_State* L)
    	{
    		if (lua_isstring(L, 1))
    		{
    			const char* str = lua_tostring(L, 1);
    			const CMob* pkMob = CMobManager::instance().Get(str, false);
    			if (pkMob)
    				lua_pushnumber(L, pkMob->m_table.dwVnum);
    			else
    				lua_pushnumber(L, 0);
    		}
    		else
    			lua_pushnumber(L, 0);
    
    		return 1;
    	}
    
    	int _skill_name(lua_State* L)
    	{
    		if (lua_isnumber(L, 1))
    		{
    			DWORD dwVnum = (DWORD)lua_tonumber(L, 1);
    
    			LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    			lua_pushstring(L, LC_LOCALE_SKILL_TEXT(dwVnum, ch ? ch->GetLanguage() : LOCALE_DEFAULT));
    		}
    		else
    			lua_pushstring(L, "");
    
    		return 1;
    	}
    
    	int _get_global_time(lua_State* L)
    	{
    		lua_pushnumber(L, get_global_time());
    		return 1;
    	}
    
    	int _get_channel_id(lua_State* L)
    	{
    		lua_pushnumber(L, g_bChannel);
    
    		return 1;
    	}
    
    	int _do_command(lua_State* L)
    	{
    		if (!lua_isstring(L, 1))
    			return 0;
    
    		const char* str = lua_tostring(L, 1);
    		size_t len = strlen(str);
    
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    		::interpret_command(ch, str, len);
    		return 0;
    	}
    
    	int _find_pc(lua_State* L)
    	{
    		if (!lua_isstring(L, 1))
    		{
    			sys_err("invalid argument");
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    
    		const char* name = lua_tostring(L, 1);
    		LPCHARACTER tch = CHARACTER_MANAGER::instance().FindPC(name);
    		lua_pushnumber(L, tch ? tch->GetVID() : 0);
    		return 1;
    	}
    
    	int _find_pc_cond(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1) || !lua_isnumber(L, 2) || !lua_isnumber(L, 3))
    		{
    			sys_err("invalid argument");
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    
    		int iMinLev = (int)lua_tonumber(L, 1);
    		int iMaxLev = (int)lua_tonumber(L, 2);
    		unsigned int uiJobFlag = (unsigned int)lua_tonumber(L, 3);
    
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    		LPCHARACTER tch;
    
    		if (test_server)
    		{
    			sys_log(0, "find_pc_cond map=%d, job=%d, level=%d~%d",
    				ch->GetMapIndex(),
    				uiJobFlag,
    				iMinLev, iMaxLev);
    		}
    
    		tch = CHARACTER_MANAGER::instance().FindSpecifyPC(uiJobFlag,
    			ch->GetMapIndex(),
    			ch,
    			iMinLev,
    			iMaxLev);
    
    		lua_pushnumber(L, tch ? tch->GetVID() : 0);
    		return 1;
    	}
    
    	int _find_npc_by_vnum(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1))
    		{
    			sys_err("invalid argument");
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    
    		DWORD race = (DWORD)lua_tonumber(L, 1);
    
    		CharacterVectorInteractor i;
    
    		if (CHARACTER_MANAGER::instance().GetCharactersByRaceNum(race, i))
    		{
    			CharacterVectorInteractor::iterator it = i.begin();
    
    			while (it != i.end())
    			{
    				LPCHARACTER tch = *(it++);
    
    				if (tch->GetMapIndex() == CQuestManager::instance().GetCurrentCharacterPtr()->GetMapIndex())
    				{
    					lua_pushnumber(L, tch->GetVID());
    					return 1;
    				}
    			}
    		}
    
    		//sys_err("not find(race=%d)", race);
    
    		lua_pushnumber(L, 0);
    		return 1;
    	}
    
    	// 새로운 state를 만든다.
    	int _set_quest_state(lua_State* L)
    	{
    		if (!lua_isstring(L, 1) || !lua_isstring(L, 2))
    			return 0;
    
    		CQuestManager& q = CQuestManager::instance();
    		QuestState* pqs = q.GetCurrentState();
    		PC* pPC = q.GetCurrentPC();
    		//assert(L == pqs->co);
    		if (L != pqs->co)
    		{
    			luaL_error(L, "running thread != current thread???");
    			sys_log(0, "running thread != current thread???");
    			return -1;
    		}
    		if (pPC)
    		{
    			//const char* szQuestName = lua_tostring(L, 1);
    			//const char* szStateName = lua_tostring(L, 2);
    			const string stQuestName(lua_tostring(L, 1));
    			const string stStateName(lua_tostring(L, 2));
    			if (test_server)
    				sys_log(0, "set_state %s %s ", stQuestName.c_str(), stStateName.c_str());
    			if (pPC->GetCurrentQuestName() == stQuestName)
    			{
    				pqs->st = q.GetQuestStateIndex(pPC->GetCurrentQuestName(), lua_tostring(L, -1));
    				pPC->SetCurrentQuestStateName(lua_tostring(L, -1));
    			}
    			else
    			{
    				pPC->SetQuestState(stQuestName, stStateName);
    			}
    		}
    		return 0;
    	}
    
    	int _get_quest_state(lua_State* L)
    	{
    		if (!lua_isstring(L, 1))
    			return 0;
    
    		CQuestManager& q = CQuestManager::instance();
    		PC* pPC = q.GetCurrentPC();
    
    		if (pPC)
    		{
    			std::string stQuestName = lua_tostring(L, 1);
    			stQuestName += ".__status";
    
    			int nRet = pPC->GetFlag(stQuestName.c_str());
    
    			lua_pushnumber(L, nRet);
    
    			if (test_server)
    				sys_log(0, "Get_quest_state name %s value %d", stQuestName.c_str(), nRet);
    		}
    		else
    		{
    			if (test_server)
    				sys_log(0, "PC == 0 ");
    
    			lua_pushnumber(L, 0);
    		}
    		return 1;
    	}
    
    	int _under_han(lua_State* L)
    	{
    		if (!lua_isstring(L, 1))
    			lua_pushboolean(L, 0);
    		else
    			lua_pushboolean(L, under_han(lua_tostring(L, 1)));
    		return 1;
    	}
    
    	int _notice_all(lua_State* L)
    	{
    		if (lua_gettop(L) > MAX_QUEST_NOTICE_ARGS + 1)
    		{
    			sys_err("QUEST invalid argument.");
    			return 0;
    		}
    
    		char szNoticeBuf[MAX_QUEST_NOTICE_ARGS + 1][CHAT_MAX_LEN + 1];
    		int iLen;
    		for (int i = 0; i < (MAX_QUEST_NOTICE_ARGS + 1); i++)
    		{
    			iLen = snprintf(szNoticeBuf[i], sizeof(szNoticeBuf[i]), "%s", lua_tostring(L, 1 + i));
    
    			if (iLen < 0 || iLen >= (int)sizeof(szNoticeBuf[i]))
    				iLen = sizeof(szNoticeBuf[i]) - 1;
    		}
    
    		TPacketGGLocaleNotice GGPacket;
    		GGPacket.bHeader = HEADER_GG_LOCALE_NOTICE;
    		GGPacket.bBigFont = false;
    		for (int i = 0; i < (MAX_QUEST_NOTICE_ARGS + 1); i++)
    			strlcpy(GGPacket.szNotice[i], szNoticeBuf[i], sizeof(GGPacket.szNotice[i]));
    		P2P_MANAGER::instance().Send(&GGPacket, sizeof(TPacketGGLocaleNotice));
    
    		SendLocaleNotice(szNoticeBuf[0], false, szNoticeBuf[1], szNoticeBuf[2], szNoticeBuf[3], szNoticeBuf[4], szNoticeBuf[5]);
    
    		return 1;
    	}
    
    	int _big_notice_all(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    
    		TPacketGGBigNotice p;
    		p.bHeader = HEADER_GG_BIG_NOTICE;
    		p.lSize = strlen(s.str().c_str()) + 1;
    
    		TEMP_BUFFER buf;
    		buf.write(&p, sizeof(p));
    		buf.write(s.str().c_str(), p.lSize);
    
    		P2P_MANAGER::instance().Send(buf.read_peek(), buf.size()); // HEADER_GG_BIG_NOTICE
    
    		SendBigNotice(s.str().c_str());
    		return 1;
    	}
    
    	EVENTINFO(warp_all_to_village_event_info)
    	{
    		DWORD dwWarpMapIndex;
    
    		warp_all_to_village_event_info()
    			: dwWarpMapIndex(0)
    		{
    		}
    	};
    
    	struct FWarpAllToVillage
    	{
    		FWarpAllToVillage() {};
    		void operator()(LPENTITY ent)
    		{
    			if (ent->IsType(ENTITY_CHARACTER))
    			{
    				LPCHARACTER ch = (LPCHARACTER)ent;
    				if (ch->IsPC())
    				{
    					BYTE bEmpire = ch->GetEmpire();
    					if (bEmpire == 0)
    					{
    						sys_err("Unkonwn Empire %s %d ", ch->GetName(), ch->GetPlayerID());
    						return;
    					}
    
    					ch->WarpSet(g_start_position[bEmpire][0], g_start_position[bEmpire][1]);
    				}
    			}
    		}
    	};
    
    	EVENTFUNC(warp_all_to_village_event)
    	{
    		warp_all_to_village_event_info* info = dynamic_cast<warp_all_to_village_event_info*>(event->info);
    
    		if (info == NULL)
    		{
    			sys_err("warp_all_to_village_event> <Factor> Null pointer");
    			return 0;
    		}
    
    		LPSECTREE_MAP pSecMap = SECTREE_MANAGER::instance().GetMap(info->dwWarpMapIndex);
    
    		if (NULL != pSecMap)
    		{
    			FWarpAllToVillage f;
    			pSecMap->for_each(f);
    		}
    
    		return 0;
    	}
    
    	int _warp_all_to_village(lua_State* L)
    	{
    		int iMapIndex = static_cast<int>(lua_tonumber(L, 1));
    		int iSec = static_cast<int>(lua_tonumber(L, 2));
    
    		warp_all_to_village_event_info* info = AllocEventInfo<warp_all_to_village_event_info>();
    
    		info->dwWarpMapIndex = iMapIndex;
    
    		event_create(warp_all_to_village_event, info, PASSES_PER_SEC(iSec));
    
    		SendNoticeMap(LC_TEXT("잠시후 모두 마을로 이동됩니다."), iMapIndex, false);
    
    		return 0;
    	}
    
    	int _warp_to_village(lua_State* L)
    	{
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    
    		if (NULL != ch)
    		{
    			BYTE bEmpire = ch->GetEmpire();
    			ch->WarpSet(g_start_position[bEmpire][0], g_start_position[bEmpire][1]);
    		}
    
    		return 0;
    	}
    
    	int _say_in_map(lua_State* L)
    	{
    		int iMapIndex = static_cast<int>(lua_tonumber(L, 1));
    		std::string Script(lua_tostring(L, 2));
    
    		Script += "[ENTER]";
    		Script += "[DONE]";
    
    		struct ::packet_script packet_script;
    
    		packet_script.header = HEADER_GC_SCRIPT;
    		packet_script.skin = CQuestManager::QUEST_SKIN_NORMAL;
    		packet_script.src_size = Script.size();
    		packet_script.size = packet_script.src_size + sizeof(struct packet_script);
    
    		FSendPacket f;
    		f.buf.write(&packet_script, sizeof(struct packet_script));
    		f.buf.write(&Script[0], Script.size());
    
    		LPSECTREE_MAP pSecMap = SECTREE_MANAGER::instance().GetMap(iMapIndex);
    
    		if (pSecMap)
    		{
    			pSecMap->for_each(f);
    		}
    
    		return 0;
    	}
    
    	struct FKillSectree2
    	{
    		void operator () (LPENTITY ent)
    		{
    			if (ent->IsType(ENTITY_CHARACTER))
    			{
    				LPCHARACTER ch = (LPCHARACTER)ent;
    
    				if (!ch->IsPC() && !ch->IsPet())
    					ch->Dead();
    			}
    		}
    	};
    
    	int _kill_all_in_map(lua_State* L)
    	{
    		LPSECTREE_MAP pSecMap = SECTREE_MANAGER::instance().GetMap(lua_tonumber(L, 1));
    
    		if (NULL != pSecMap)
    		{
    			FKillSectree2 f;
    			pSecMap->for_each(f);
    		}
    
    		return 0;
    	}
    
    	// 주의: 몹 리젠이 안되는 맵에서만 사용
    	int _regen_in_map(lua_State* L)
    	{
    		int iMapIndex = static_cast<int>(lua_tonumber(L, 1));
    		std::string szFilename(lua_tostring(L, 2));
    
    		LPSECTREE_MAP pkMap = SECTREE_MANAGER::instance().GetMap(iMapIndex);
    
    		if (pkMap != NULL)
    		{
    			regen_load_in_file(szFilename.c_str(), iMapIndex, pkMap->m_setting.iBaseX, pkMap->m_setting.iBaseY);
    		}
    
    		return 0;
    	}
    
    	int _enable_over9refine(lua_State* L)
    	{
    		if (lua_isnumber(L, 1) == TRUE && lua_isnumber(L, 2) == TRUE)
    		{
    			DWORD dwVnumFrom = (DWORD)lua_tonumber(L, 1);
    			DWORD dwVnumTo = (DWORD)lua_tonumber(L, 2);
    
    			COver9RefineManager::instance().enableOver9Refine(dwVnumFrom, dwVnumTo);
    		}
    
    		return 0;
    	}
    
    	int _add_ox_quiz(lua_State* L)
    	{
    		int level = (int)lua_tonumber(L, 1);
    		const char* quiz = lua_tostring(L, 2);
    		bool answer = lua_toboolean(L, 3);
    
    		if (COXEventManager::instance().AddQuiz(level, quiz, answer) == false)
    		{
    			sys_log(0, "OXEVENT : Cannot add quiz. %d %s %d", level, quiz, answer);
    		}
    
    		return 1;
    	}
    
    	EVENTFUNC(warp_all_to_map_my_empire_event)
    	{
    		warp_all_to_map_my_empire_event_info* info = dynamic_cast<warp_all_to_map_my_empire_event_info*>(event->info);
    
    		if (info == NULL)
    		{
    			sys_err("warp_all_to_map_my_empire_event> <Factor> Null pointer");
    			return 0;
    		}
    
    		LPSECTREE_MAP pSecMap = SECTREE_MANAGER::instance().GetMap(info->m_lMapIndexFrom);
    
    		if (pSecMap)
    		{
    			FWarpEmpire f;
    
    			f.m_lMapIndexTo = info->m_lMapIndexTo;
    			f.m_x = info->m_x;
    			f.m_y = info->m_y;
    			f.m_bEmpire = info->m_bEmpire;
    
    			pSecMap->for_each(f);
    		}
    
    		return 0;
    	}
    
    	int _block_chat(lua_State* L)
    	{
    		LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
    
    		if (pChar != NULL)
    		{
    			if (lua_isstring(L, 1) != TRUE && lua_isstring(L, 2) != TRUE)
    			{
    				lua_pushboolean(L, false);
    				return 1;
    			}
    
    			std::string strName(lua_tostring(L, 1));
    			std::string strTime(lua_tostring(L, 2));
    
    			std::string strArg = strName + " " + strTime;
    
    			do_block_chat(pChar, const_cast<char*>(strArg.c_str()), 0, 0);
    
    			lua_pushboolean(L, true);
    			return 1;
    		}
    
    		lua_pushboolean(L, false);
    		return 1;
    	}
    
    	int _spawn_mob(lua_State* L)
    	{
    		if (false == lua_isnumber(L, 1) || false == lua_isnumber(L, 2) || false == lua_isboolean(L, 3))
    		{
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    
    		const DWORD dwVnum = static_cast<DWORD>(lua_tonumber(L, 1));
    		const size_t count = MINMAX(1, static_cast<size_t>(lua_tonumber(L, 2)), 10);
    		const bool isAggresive = static_cast<bool>(lua_toboolean(L, 3));
    		size_t SpawnCount = 0;
    
    		const CMob* pMonster = CMobManager::instance().Get(dwVnum);
    
    		if (NULL != pMonster)
    		{
    			const LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
    
    			for (size_t i = 0; i < count; ++i)
    			{
    				const LPCHARACTER pSpawnMonster = CHARACTER_MANAGER::instance().SpawnMobRange(dwVnum,
    					pChar->GetMapIndex(),
    					pChar->GetX() - number(200, 750),
    					pChar->GetY() - number(200, 750),
    					pChar->GetX() + number(200, 750),
    					pChar->GetY() + number(200, 750),
    					true,
    					pMonster->m_table.bType == CHAR_TYPE_STONE,
    					isAggresive);
    
    				if (NULL != pSpawnMonster)
    				{
    					++SpawnCount;
    				}
    			}
    
    			sys_log(0, "QUEST Spawn Monstster: VNUM(%u) COUNT(%u) isAggresive(%b)", dwVnum, SpawnCount, isAggresive);
    		}
    
    		lua_pushnumber(L, SpawnCount);
    
    		return 1;
    	}
    
    	int _notice_in_map(lua_State* L)
    	{
    		const LPCHARACTER pChar = CQuestManager::instance().GetCurrentCharacterPtr();
    
    		if (NULL != pChar)
    		{
    			SendNoticeMap(
    				lua_tostring(L, 1), // c_pszNotice
    				pChar->GetMapIndex(), // iMapIndex
    				lua_toboolean(L, 2), // bBigFont
    				lua_tostring(L, 3), // 1 ...
    				lua_tostring(L, 4), // 2 ...
    				lua_tostring(L, 5), // 3 ...
    				lua_tostring(L, 6), // 4 ...
    				lua_tostring(L, 7), // 5 ...
    				lua_tostring(L, 8), // 6 ...
    				lua_tostring(L, 9), // 7 ...
    				lua_tostring(L, 10), // 8 ...
    				lua_tostring(L, 11), // 9 ...
    				lua_tostring(L, 12) // 10 ...
    			);
    		}
    
    		return 0;
    	}
    
    	int _get_locale_base_path(lua_State* L)
    	{
    		lua_pushstring(L, LocaleService_GetBasePath().c_str());
    
    		return 1;
    	}
    
    	struct FPurgeArea
    	{
    		int x1, y1, x2, y2;
    		LPCHARACTER ExceptChar;
    
    		FPurgeArea(int a, int b, int c, int d, LPCHARACTER p)
    			: x1(a), y1(b), x2(c), y2(d),
    			ExceptChar(p)
    		{}
    
    		void operator () (LPENTITY ent)
    		{
    			if (true == ent->IsType(ENTITY_CHARACTER))
    			{
    				LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);
    
    				if (pChar == ExceptChar)
    					return;
    
    				if (!pChar->IsPet() && (true == pChar->IsMonster() || true == pChar->IsStone()))
    				{
    					if (x1 <= pChar->GetX() && pChar->GetX() <= x2 && y1 <= pChar->GetY() && pChar->GetY() <= y2)
    					{
    						M2_DESTROY_CHARACTER(pChar);
    					}
    				}
    			}
    		}
    	};
    
    	int _purge_area(lua_State* L)
    	{
    		int x1 = lua_tonumber(L, 1);
    		int y1 = lua_tonumber(L, 2);
    		int x2 = lua_tonumber(L, 3);
    		int y2 = lua_tonumber(L, 4);
    
    		const int mapIndex = SECTREE_MANAGER::instance().GetMapIndex(x1, y1);
    
    		if (0 == mapIndex)
    		{
    			sys_err("_purge_area: cannot get a map index with (%u, %u)", x1, y1);
    			return 0;
    		}
    
    		LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(mapIndex);
    
    		if (NULL != pSectree)
    		{
    			FPurgeArea func(x1, y1, x2, y2, CQuestManager::instance().GetCurrentNPCCharacterPtr());
    			pSectree->for_each(func);
    		}
    
    		return 0;
    	}
    
    	struct FWarpAllInAreaToArea
    	{
    		int from_x1, from_y1, from_x2, from_y2;
    		int to_x1, to_y1, to_x2, to_y2;
    		size_t warpCount;
    
    		FWarpAllInAreaToArea(int a, int b, int c, int d, int e, int f, int g, int h)
    			: from_x1(a), from_y1(b), from_x2(c), from_y2(d),
    			to_x1(e), to_y1(f), to_x2(g), to_y2(h),
    			warpCount(0)
    		{}
    
    		void operator () (LPENTITY ent)
    		{
    			if (true == ent->IsType(ENTITY_CHARACTER))
    			{
    				LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);
    
    				if (true == pChar->IsPC())
    				{
    					if (from_x1 <= pChar->GetX() && pChar->GetX() <= from_x2 && from_y1 <= pChar->GetY() && pChar->GetY() <= from_y2)
    					{
    						++warpCount;
    
    						pChar->WarpSet(number(to_x1, to_x2), number(to_y1, to_y2));
    					}
    				}
    			}
    		}
    	};
    
    	int _warp_all_in_area_to_area(lua_State* L)
    	{
    		int from_x1 = lua_tonumber(L, 1);
    		int from_y1 = lua_tonumber(L, 2);
    		int from_x2 = lua_tonumber(L, 3);
    		int from_y2 = lua_tonumber(L, 4);
    
    		int to_x1 = lua_tonumber(L, 5);
    		int to_y1 = lua_tonumber(L, 6);
    		int to_x2 = lua_tonumber(L, 7);
    		int to_y2 = lua_tonumber(L, 8);
    
    		const int mapIndex = SECTREE_MANAGER::instance().GetMapIndex(from_x1, from_y1);
    
    		if (0 == mapIndex)
    		{
    			sys_err("_warp_all_in_area_to_area: cannot get a map index with (%u, %u)", from_x1, from_y1);
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    
    		LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(mapIndex);
    
    		if (NULL != pSectree)
    		{
    			FWarpAllInAreaToArea func(from_x1, from_y1, from_x2, from_y2, to_x1, to_y1, to_x2, to_y2);
    
    			pSectree->for_each(func);
    
    			lua_pushnumber(L, func.warpCount);
    			sys_log(0, "_warp_all_in_area_to_area: %u character warp", func.warpCount);
    			return 1;
    		}
    		else
    		{
    			lua_pushnumber(L, 0);
    			sys_err("_warp_all_in_area_to_area: no sectree");
    			return 1;
    		}
    	}
    
    	int _get_special_item_group(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1))
    		{
    			sys_err("invalid argument");
    			return 0;
    		}
    
    		const CSpecialItemGroup* pItemGroup = ITEM_MANAGER::instance().GetSpecialItemGroup((DWORD)lua_tonumber(L, 1));
    
    		if (!pItemGroup)
    		{
    			sys_err("cannot find special item group %d", (DWORD)lua_tonumber(L, 1));
    			return 0;
    		}
    
    		int count = pItemGroup->GetGroupSize();
    
    		for (int i = 0; i < count; i++)
    		{
    			lua_pushnumber(L, (int)pItemGroup->GetVnum(i));
    			lua_pushnumber(L, (int)pItemGroup->GetCount(i));
    		}
    
    		return count * 2;
    	}
    
    	int _add_restart_city_pos(lua_State* L)
    	{
    		int iMapIndex = (int)lua_tonumber(L, 1);
    		int iEmpire = (int)lua_tonumber(L, 2);
    		int iX = (int)lua_tonumber(L, 3);
    		int iY = (int)lua_tonumber(L, 4);
    		int iZ = (int)lua_tonumber(L, 5);
    		SECTREE_MANAGER::instance().AddRestartCityPos(iMapIndex, iEmpire, iX, iY, iZ);
    		return 0;
    	}
    
    	struct FQuestFlagArea
    	{
    		int x1, y1, x2, y2;
    		const char* sz;
    		int val;
    
    		FQuestFlagArea(int a, int b, int c, int d, const char* p, int value)
    			: x1(a), y1(b), x2(c), y2(d), sz(p), val(value)
    		{}
    
    		void operator () (LPENTITY ent)
    		{
    			if (true == ent->IsType(ENTITY_CHARACTER))
    			{
    				LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);
    
    				if (pChar->IsPC())
    				{
    					if (x1 <= pChar->GetX() && pChar->GetX() <= x2 && y1 <= pChar->GetY() && pChar->GetY() <= y2)
    					{
    						CQuestManager& q = CQuestManager::Instance();
    						PC* pPC = q.GetPC(pChar->GetPlayerID());
    						if (pPC)
    						{
    							pPC->SetFlag(sz, val);
    						}
    					}
    				}
    			}
    		}
    	};
    
    	int _set_quest_flag_in_area(lua_State* L)
    	{
    		int x1 = (int)lua_tonumber(L, 3);
    		int y1 = (int)lua_tonumber(L, 4);
    		int x2 = (int)lua_tonumber(L, 5);
    		int y2 = (int)lua_tonumber(L, 6);
    		const char* sz = (const char*)lua_tostring(L, 1);
    		int value = (int)lua_tonumber(L, 2);
    
    		const int mapIndex = SECTREE_MANAGER::instance().GetMapIndex(x1, y1);
    
    		if (0 == mapIndex)
    		{
    			sys_err("_set_quest_flag_in_area: cannot get a map index with (%u, %u)", x1, y1);
    			return 0;
    		}
    
    		LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(mapIndex);
    
    		if (NULL != pSectree)
    		{
    			FQuestFlagArea func(x1, y1, x2, y2, sz, value);
    			pSectree->for_each(func);
    		}
    
    		return 0;
    	}
    
    	// #if defined(__TEMPLE_OCHAO__)
    	struct FMobCounter
    	{
    		int nCount;
    		DWORD iSpecificVnum;
    
    		FMobCounter(DWORD specificVnum)
    		{
    			iSpecificVnum = specificVnum;
    			nCount = 0;
    		}
    
    		void operator () (LPENTITY ent)
    		{
    			if (ent->IsType(ENTITY_CHARACTER))
    			{
    				LPCHARACTER pChar = static_cast<LPCHARACTER>(ent);
    
    				if (iSpecificVnum)
    				{
    					if (pChar->GetRaceNum() == iSpecificVnum)
    						nCount++;
    
    					return;
    				}
    			}
    		}
    	};
    
    	int _find_boss_by_vnum(lua_State* L)
    	{
    		if (!lua_isnumber(L, 1))
    		{
    			sys_err("invalid argument");
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    
    		DWORD boss = (DWORD)lua_tonumber(L, 1);
    
    		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    		LPSECTREE_MAP pSectree = SECTREE_MANAGER::instance().GetMap(ch->GetMapIndex());
    
    		if (pSectree == NULL)
    		{
    			lua_pushnumber(L, 0);
    			return 1;
    		}
    
    		FMobCounter f(boss);
    		pSectree->for_each(f);
    
    		if (boss)
    		{
    			lua_pushnumber(L, f.nCount);
    			return 1;
    		}
    
    		lua_pushnumber(L, 0);
    		return 1;
    	}
    	// #endif
    
    #if defined(__12ZI_NOTICE__)
    	int _notice_mission(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    		CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_MISSION, "%s", s.str().c_str());
    		return 0;
    	}
    
    	int _notice_sub_mission(lua_State* L)
    	{
    		ostringstream s;
    		combine_lua_string(L, s);
    		CQuestManager::Instance().GetCurrentCharacterPtr()->ChatPacket(CHAT_TYPE_SUB_MISSION, "%s", s.str().c_str());
    		return 0;
    	}
    #endif
    
    #ifdef _MSC_VER
    #define INFINITY (DBL_MAX+DBL_MAX)
    #define NAN (INFINITY-INFINITY)
    #endif
    
    	int _mysql_direct_query(lua_State* L)
    	{
    		// char szQuery[1024];
    
    		if (!lua_isstring(L, 1))
    			return 0;
    		// strncpy(szQuery, lua_tostring(L, 1), sizeof(szQuery));
    
    		int i=0, m=1;
    		MYSQL_ROW row;
    		MYSQL_FIELD * field;
    		MYSQL_RES * result;
    		// SQLMsg * pMsg = DBManager::instance().DirectQuery(szQuery);
    		std::auto_ptr<SQLMsg> pMsg(DBManager::instance().DirectQuery(lua_tostring(L, 1)));
    		if (pMsg.get())
    		{
    			// ret1 (number of affected rows)
    			lua_pushnumber(L, pMsg->Get()->uiAffectedRows);
    			//-1 if error such as duplicate occurs (-2147483648 via lua)
    			//   if wrong syntax error occurs (4294967295 via lua)
    			// ret2 (table of affected rows)
    			lua_newtable(L);
    			if ((result = pMsg->Get()->pSQLResult) &&
    					!(pMsg->Get()->uiAffectedRows == 0 || pMsg->Get()->uiAffectedRows == (uint32_t)-1))
    			{
    				// LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    				// ch->ChatPacket(CHAT_TYPE_INFO, "<%s> Retrieved %u fields\n", __FUNCTION__, mysql_num_fields(result));
    				// ch->ChatPacket(CHAT_TYPE_INFO, "<%s> Retrieved %u rows\n", __FUNCTION__, mysql_num_rows(result));
    				// ch->ChatPacket(CHAT_TYPE_INFO, "<%s> Affected %u rows\n", __FUNCTION__, pMsg->Get()->uiAffectedRows);
    				// ch->ChatPacket(CHAT_TYPE_INFO, "<%s> Num %u rows\n", __FUNCTION__, pMsg->Get()->uiNumRows);
    
    				while((row = mysql_fetch_row(result)))
    				{
    					lua_pushnumber(L, m);
    					lua_newtable(L);
    					while((field = mysql_fetch_field(result)))
    					{
    						lua_pushstring(L, field->name);
    						if (!(field->flags & NOT_NULL_FLAG) && (row[i]==NULL))
    						{
    							// lua_pushstring(L, "NULL");
    							lua_pushnil(L);
    						}
    						else if (IS_NUM(field->type))
    						{
    							double val = NAN;
    							lua_pushnumber(L, (sscanf(row[i],"%lf",&val)==1)?val:NAN);
    						}
    						else if (field->type == MYSQL_TYPE_BLOB)
    						{
    							lua_newtable(L);
    							for (DWORD iBlob=0; iBlob < field->max_length; iBlob++)
    							{
    								lua_pushnumber(L, row[i][iBlob]);
    								lua_rawseti(L, -2, iBlob+1);
    							}
    						}
    						else
    							lua_pushstring(L, row[i]);
    						// LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
    						// ch->ChatPacket(CHAT_TYPE_INFO, "<%s> Retrieved %d flag %s for %s\n", __FUNCTION__, field->type, field->name, row[i]?row[i]:"NULL");
    						lua_rawset(L, -3);
    						i++;
    					}
    					mysql_field_seek(result, 0);
    					i=0;
    
    					lua_rawset(L, -3);
    					m++;
    				}
    			}
    		}
    		else {lua_pushnumber(L, 0); lua_newtable(L);}
    
    		// delete pMsg;
    		return 2;
    	}
    
    	void RegisterGlobalFunctionTable(lua_State* L)
    	{
    		extern int quest_setstate(lua_State * L);
    
    		luaL_reg global_functions[] =
    		{
    			{ "sys_err", _syserr },
    			{ "sys_log", _syslog },
    			{ "char_log", _char_log },
    			{ "item_log", _item_log },
    			{ "set_state", quest_setstate },
    			{ "set_skin", _set_skin },
    			{ "setskin", _set_skin },
    			{ "time_to_str", _time_to_str },
    			{ "say", _say },
    			{ "chat", _chat },
    			{ "cmdchat", _cmdchat },
    			{ "syschat", _syschat },
    			{ "get_locale", _get_locale },
    			{ "setleftimage", _left_image },
    			{ "settopimage", _top_image },
    			{ "server_timer", _set_server_timer },
    			{ "clear_server_timer", _clear_server_timer },
    			{ "server_loop_timer", _set_server_loop_timer },
    			{ "get_server_timer_arg", _get_server_timer_arg },
    			{ "timer", _timer },
    			{ "loop_timer", _set_named_loop_timer },
    			{ "cleartimer", _clear_named_timer },
    			{ "getnpcid", _getnpcid },
    			{ "is_test_server", _is_test_server },
    			{ "is_speed_server", _is_speed_server },
    			{ "raw_script", _raw_script },
    			{ "number", _number },
    
    			// LUA_ADD_BGM_INFO
    			{ "set_bgm_volume_enable", _set_bgm_volume_enable },
    			{ "add_bgm_info", _add_bgm_info },
    			// END_OF_LUA_ADD_BGM_INFO
    
    			// LUA_ADD_GOTO_INFO
    			{ "add_goto_info", _add_goto_info },
    			// END_OF_LUA_ADD_GOTO_INFO
    
    			// REFINE_PICK
    			{ "__refine_pick", _refine_pick },
    			// END_OF_REFINE_PICK
    
    			{ "add_ox_quiz", _add_ox_quiz },
    			{ "__fish_real_refine_rod", _fish_real_refine_rod }, // XXX
    			{ "__give_char_priv", _give_char_privilege },
    			{ "__give_empire_priv", _give_empire_privilege },
    			{ "__give_guild_priv", _give_guild_privilege },
    			{ "__get_empire_priv_string", _get_empire_privilege_string },
    			{ "__get_empire_priv", _get_empire_privilege },
    			{ "__get_guild_priv_string", _get_guild_privilege_string },
    			{ "__get_guildid_byname", _get_guildid_byname },
    			{ "__get_guild_priv", _get_guild_privilege },
    			{ "item_name", _item_name },
    			{ "mob_name", _mob_name },
    			{ "mob_vnum", _mob_vnum },
    			{ "get_time", _get_global_time },
    			{ "get_global_time", _get_global_time },
    			{ "get_channel_id", _get_channel_id },
    			{ "command", _do_command },
    			{ "find_pc_cond", _find_pc_cond },
    			{ "find_pc_by_name", _find_pc },
    			{ "find_npc_by_vnum", _find_npc_by_vnum },
    			{ "set_quest_state", _set_quest_state },
    			{ "get_quest_state", _get_quest_state },
    			{ "under_han", _under_han },
    			{ "notice", _notice },
    			{ "big_notice", _big_notice },
    			{ "notice_all", _notice_all },
    			{ "big_notice_all", _big_notice_all },
    			{ "notice_in_map", _notice_in_map },
    			{ "warp_all_to_village", _warp_all_to_village },
    			{ "warp_to_village", _warp_to_village },
    			{ "say_in_map", _say_in_map },
    			{ "kill_all_in_map", _kill_all_in_map },
    			{ "regen_in_map", _regen_in_map },
    			{ "enable_over9refine", _enable_over9refine },
    			{ "block_chat", _block_chat },
    			{ "spawn_mob", _spawn_mob },
    			{ "get_locale_base_path", _get_locale_base_path },
    			{ "purge_area", _purge_area },
    			{ "warp_all_in_area_to_area", _warp_all_in_area_to_area },
    			{ "get_special_item_group", _get_special_item_group },
    			{ "add_restart_city_pos", _add_restart_city_pos },
    			{ "set_quest_flag_in_area", _set_quest_flag_in_area },
    			{ "find_boss_by_vnum", _find_boss_by_vnum },
    
    #if defined(__12ZI_NOTICE__)
    			{ "notice_mission", _notice_mission },
    			{ "notice_sub_mission", _notice_sub_mission },
    #endif
    
    			{ "LC", _get_locale },
    			{ "locale_quest", _locale_quest },
    			{ "skill_name", _skill_name },
    			{ "mysql_direct_query",	_mysql_direct_query	},
    
    			{ NULL, NULL }
    		};
    
    		int i = 0;
    
    		while (global_functions[i].name != NULL)
    		{
    			lua_register(L, global_functions[i].name, global_functions[i].func);
    			++i;
    		}
    	}
    }

     

     

    SOLUTION:   CXXFLAGS = -std=c++14 in all Makefiles

  11. 22 minutes ago, Amun said:

    I think it may be because of this:

    local shop = split(input(cmdchat('ITEMSHOP SEND#')), '#')

    It's asking for input there, add an option to not show the input if it's a command

     

    Edit: You can find basically anything if you look well enough:

     

    Solution:

     

    Search: in constinfo.py
    
    IN_GAME_SHOP_ENABLE = 1
    
    Add: INPUT IGNORE = 0
    
    Find: in game.py
    
    	def OpenQuestWindow(self, skin, idx):
    	self.interface.OpenQuestWindow(skin, idx)
    
    Replace:
    	def OpenQuestWindow(self, skin, idx):
    		if not int(constInfo.INPUT_IGNORE) == 1:
    			self.interface.OpenQuestWindow(skin, idx)

    Thank you, ready: https://metin2.download/picture/uyPGUtn37mXlMbR8pE4GNslGda2xQ4Jq/.gif

    Quote

    Unknown Server Command ITEMSHOP OPEN#1 | ITEMSHOP

     

    I have not been able to solve this error colleague

  12. 54 minutes ago, Amun said:

    Look inside game.py

    	def __InGameShop_Show(self, url):
    		if constInfo.IN_GAME_SHOP_ENABLE:
    			self.interface.OpenWebWindow(url)

    Just change self.interface.OpenWebWindow with whatever you want it to do

    https://metin2.download/picture/uyPGUtn37mXlMbR8pE4GNslGda2xQ4Jq/.gif

    It works, that input problem is not removed:

     

    Errorr: Input: no quest running for pc, cannot process input : 1

  13. 9 minutes ago, Amun said:

    Mate, I'm just telling you what the errors mean and where they're coming from. I've never used this, so I can't say anything for sure. Yet, if you're sending a command to the client, I would assume that the client has to know what that command means, right?

     

    No, it isn't case sensitive(unless you use Cython). If it was case sensitive, you wouldn't be able to enter the game.

    Do you know how it would be to open the itemshop from the coin?

  14. On 4/15/2022 at 11:35 AM, Amun said:

    Does this only happen when you are a GM or for all players?

    You said you'll add images, I don't see any of them.

     

    That syserr is coming from questmanager

    void CQuestManager::Input(unsigned int pc, const char* msg)

    and it means that the quest isn't running(for that player, from what I see). Maybe something's cleaning it up?

     

    4 minutes ago, Amun said:

    You're basically sending that ITEMSHOP command from the server and the client has no idea about what the fuck that means.

    Take a look in 

    UserInterface/PythonNetworkStreamCommand.cpp

    void CPythonNetworkStream::ServerCommand(char * c_szCommand)

    Colleague the itemshop that I try to install, does not require files in source client.

    Only in questlua_global.cpp that adds "mysql_direct_query".

    Does it have to do with some cases of serverfiles that instead of being "uiScriptLocale" it is "uiscriptlocale", it is case sensitive?

  15. 19 hours ago, Amun said:

    Just add say("whatever") in lua and print("whatever") in python..

    Look inside questlua_global.cpp..

                {    "sys_err",                    _syserr                    },
                {    "sys_log",                    _syslog                    },
                {    "char_log",                    _char_log                },
                {    "item_log",                    _item_log                },
                {    "say",                        _say                    },
                {    "chat",                        _chat                    },
                {    "cmdchat",                    _cmdchat                },
                {    "syschat",                    _syschat                },
                {    "notice",                        _notice                            },
                {    "notice_all",                    _notice_all                        },
                {    "notice_in_map",                _notice_in_map                    },
                {    "say_in_map",                    _say_in_map                        },    
     

    Use whatever you want, just make sure you can see the output if it's crashing.

     

    Good luck

    I couldn't do anything mate, I have this problem with other files.

     

    Unknown Server Command ITEMSHOP OPEN#1 | ITEMSHOP

  16. 11 minutes ago, Amun said:

    I really can not say anything for sure. My advice is to add logs in both the quest and the client. It won't solve anything, but at least it would give you an idea about why it's crashing.

     

    What about the client? Do you get any errors in there?

    No colleague in client does not register anything, each function that the itemshop does will open as if it were a quest, how would it be corrected?

  17. On 4/15/2022 at 11:35 AM, Amun said:

    Does this only happen when you are a GM or for all players?

    You said you'll add images, I don't see any of them.

     

    That syserr is coming from questmanager

    void CQuestManager::Input(unsigned int pc, const char* msg)

    and it means that the quest isn't running(for that player, from what I see). Maybe something's cleaning it up?

    Image: https://metin2.download/picture/B4fPgshw12drsQLBO7g7Erdr5x67Bb27/.gif

    When opening with the designated F5 button it appears like this and the client closes. And it happens being GM and those who are not GM.

  18. Hello, I would like to receive tImaghe help of someone.

    I am trying to install this ItemShop. It works normally but it closes continuously and when doing a function an input quest appears (I attach images).

     

    URL IMAGES : https://metin2.download/picture/B4fPgshw12drsQLBO7g7Erdr5x67Bb27/.gif

    quest itemshop_manager begin
    	state start begin
    		
    		when login begin
    			cmdchat('ITEMSHOP QID#'..q.getcurrentquestindex())
    			cmdchat('ITEMSHOP CLEAR_WHEEL_CONTENT#')
    			itemshop.load_wheel_items()
    			itemshop.load_logs('all')
    		end
    		
    		when button begin
    			cmdchat('ITEMSHOP INPUT#1')
    			local shop = split(input(cmdchat('ITEMSHOP SEND#')), '#')
    			cmdchat('ITEMSHOP INPUT#0')
    			
    			if pc.is_gm() then
    				if shop[1] == 'ADD_ITEM_TIME' then
    					itemshop.admin_add_item_time(tonumber(shop[2]), tonumber(shop[3]), tonumber(shop[4]), tonumber(shop[5]))
    				elseif shop[1] == 'ADD_CATEGORY_TIME' then
    					itemshop.admin_add_category_time(tonumber(shop[2]), tonumber(shop[3]), tonumber(shop[4]), tonumber(shop[5]))
    				elseif shop[1] == 'ADD_ITEM' then
    					local attrs = {{tonumber(shop[4]),tonumber(shop[5])},{tonumber(shop[6]),tonumber(shop[7])},{tonumber(shop[8]),tonumber(shop[9])},{tonumber(shop[10]),tonumber(shop[11])},{tonumber(shop[12]),tonumber(shop[13])},{tonumber(shop[14]),tonumber(shop[15])},{tonumber(shop[16]),tonumber(shop[17])}}
    					local sockets = {tonumber(shop[18]),tonumber(shop[19]),tonumber(shop[20])}
    					itemshop.admin_add_item(tonumber(shop[2]), tonumber(shop[3]), tonumber(shop[21]), attrs, sockets, tonumber(shop[22]))
    				elseif shop[1] == 'DELETE_ITEM' then
    					itemshop.admin_delete_item(shop[2], tonumber(shop[3]))
    				elseif shop[1] == 'CHANGE_PRICE' then
    					itemshop.admin_edit_item_price(shop[2], tonumber(shop[3]), tonumber(shop[4]))
    				end
    			end
    			if shop[1] == 'REQUEST_SPIN_WHEEL' then
    				if pc.getqf('enable_wheel') == 1 then return end
    				itemshop.request_spin_wheel()
    			elseif shop[1] == 'REQUEST_PRIZE_WHEEL' then
    				if pc.getqf('enable_wheel') < 1 then
    					return
    				end
    				pc.give_item2(tonumber(shop[2]), 1)
    				pc.setqf('enable_wheel', 0)
    			elseif shop[1] == 'OPEN_SHOP' then
    				cmdchat('ITEMSHOP CLEAR_CONTENT#')
    				itemshop.get_coins()
    				itemshop.get_3rd()
    				itemshop.create_categorys()
    				itemshop.load_items()
    				itemshop.load_hotoffers()
    				itemshop.load_mostbought()
    				itemshop.open_shop()
    			elseif shop[1] == 'CLOSE_SHOP' then
    				itemshop.close_shop()
    			elseif shop[1] == 'BUY_ITEM' then
    				itemshop.buy_item(shop[2], tonumber(shop[3]), tonumber(shop[4]))
    			elseif shop[1] == 'UPDATE_COINS' then
    				if pc.getqf('update_coins') > get_time() then
    					syschat("Debes esperar "..(pc.getqf('update_coins')-get_time()).."s para volver a recargar las coins.")
    					return
    				end
    				itemshop.get_coins()
    				itemshop.get_3rd()
    				pc.setqf('update_coins', get_time() + 10)
    			end
    		end
    		
    	end
    end

     

    In channel syserr I have this error:

    SYSERR: Apr 14 04:56:45 :: Input: no quest running for pc, cannot process input : 1

    Help me?

×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.