Jump to content

Elzza

Inactive Member
  • Posts

    19
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Elzza

  1. Just, implement the constructor inside smth.cpp and also give a DEFAULT value to smth[3]; (or maybe include the array inside the class)

    In my full code, I've done it earlier, but error is still.

    edited code:

     

    test.h

    class test
    {
    public:
       int global_var[3];  // Global Variable
    
       test();
       void write(int nmb);
       int read();
    };
     
    extern test testt;

    test.cpp

    #include "test.h"
     
    ...
    test::test()
    {
       global_var[0] = 0;
       global_var[1] = 0;
       global_var[2] = 0;
    } 
    void test::write(int nmb)
    {
       global_var[0] = nmb;
    }
    int test::read()
    {
       return global_var[0];
    }

    smth.h

    extern int smth[3];
    smth.cpp

    int smth[3] = {1,2,3};
    I don't like such awful thing:

    extern test testt;

     

     

    I did it because I want to use only one class object in different functions.

    How can I do it differently?

     

  2. I wrote a function that uses a global variable, but this variable isn't working properly.

     

     

    A function that reads / records the number to this variable, not always doing it properly, why?

     

    test.h

    int global_var[3];  // Global Variable
    
    class test
    {
    public:
       void write(int nmb);
       int read();
    };
    
    extern test testt;

    test.cpp

    #include "test.h"
    
    ...
    
    void test::write(int nmb)
    {
       global_var[0] = nmb;
    }
    int test::read()
    {
       return global_var[0];
    }

    questlua_pc.cpp

    ...
    #include "test.h"
    ...
    
    test testt;
    
    int pc_test_func_write(lua_State* L)
    {
       testt.write(lua_tonumber(L,1));
       return 1;
    }
    
    int pc_test_func_read(lua_State* L)
    {
       lua_pushnumber(L, testt.read());
       return 1;
    }
    
    ...
    
    {"test_func_write",		pc_test_func_write	},
    {"test_func_read",		pc_test_func_read	},

    This is a sample code.

     

    How can I fix it?

  3. I wrote a code which should send the number to lua (quest), but something is wrong.

     

     

    This code isn't sending number to lua, why?

     

    Plik questlua_pc.cpp:

    ...
    int pc_my_func(lua_State* L)
    {
    ...
    			lua_pushnumber(L, 0);
    			return 0;
    ...
    }
    ...

    and quest test.quest:

    quest test begin
    	state start begin
    		when blacksmith.chat."test" begin
    			say("test")
    			local var = pc.my_func()
                            say(var)
    		end
    	end
    end
  4. I have problem, my code isn't reading properly data from MySQL, type: smallint.

    There is number: 64, but this function show me number: 54.

    I don't know what is wrong.

     

    My code:

    short MyFunction()
    {
    ...
    	std::auto_ptr<SQLMsg> msg(DBManager::instance().DirectQuery("SELECT coins FROM player.itemshop WHERE name='%s';", pCharName));
    	MYSQL_ROW row_coins = mysql_fetch_row(msg->Get()->pSQLResult);
    
    	return row_coints[0][0];
    }
  5. It's not work.

     

     

    #edit

    I have to do somewere mistake, because my code looks like this:

    	int pc_start_pvp(lua_State* L)
    	{
    		LPCHARACTER pChar1 = CQuestManager::instance().GetCurrentCharacterPtr();
    		//DWORD pid1 = pChar1->GetPlayerID();
    
    		LPCHARACTER pChar2 = CHARACTER_MANAGER::instance().FindPC(lua_tostring(L,1));
    		//DWORD pid2 = pChar2->GetPlayerID;
    		if ( pChar1 == NULL || pChar2 == NULL )
    		{
    			//lua_pushnumber(L, 0);
    			return 0;
    		}
    		CPVPManager::instance().Insert(pChar1, pChar2);
    		pChar1->ChatPacket(CHAT_TYPE_INFO, "It's not work1!");
    		pChar2->ChatPacket(CHAT_TYPE_INFO, "It's not work2!");
    		return 1;
    	}

    1. I include: "#include "pvp.h" and add: "{ "start_pvp", pc_start_pvp }," to "void RegisterPCFunctionTable()".

    2. I was add this: "start_pvp()" in "quest_funcitons" and I was create quest:

    quest pvp begin
    	state start begin
    		when blacksmith.chat."test_pvp" begin
    			say("Nick")
    			local nick= input()
    			start_pvp(nick)
    			say("done!")
    		end
    	end
    end

    But when I wirte nick, nothing happened.

  6. I want to make a new quest function, which will start pvp between 2 players.

    I don't know how I can do it.

     

    Could You give me an example how to make this function? 

     

    Now, I have this code:

    	int pc_start_pvp(lua_State* L)
    	{
    		LPCHARACTER pChar1 = CQuestManager::instance().GetCurrentCharacterPtr();
    		DWORD pid1 = pChar1->GetPlayerID();
    
    		LPCHARACTER pChar2 = CHARACTER_MANAGER::instance().FindPC(lua_tostring(L,1));
    		DWORD pid2 = pChar2->GetPlayerID;
    		if ( pChar1 == NULL || pChar2 == NULL )
    		{
    			lua_pushnumber(L, 0);
    			return 0;
    		}
    		lua_pushnumber(L, 0);
    		return 1;
    	}

    Pls, 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.