Jump to content
  • 0

Quest Function: pc.get_cash


Dennis

Question

Hey Guys

 

I want to add a new quest function

pc.get_coins()

If, for example, the coins in quests show that you own

 

I have tried it with this but that does not work

    int pc_get_coins(lua_State * L)
    {
        if (!lua_isnumber(L, 1))
        {
            sys_err("invalid argument");
            return 0;
        }

        LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();
        long val = (long)lua_tonumber(L, 1);
        SQLMsg *msg;

        msg = DBManager::instance().DirectQuery("SELECT * FROM account.account WHERE id = '%d' LIMIT 1", ch->GetAID());
        
        if (msg->uiSQLErrno != 0)
        {
            sys_err("pc.get_coins query failed");
            return 0;
        }

        return msg.coins[1];
    }

Can anyone help me?

 

 

Link to comment

5 answers to this question

Recommended Posts

  • 0
  • VIP
	int pc_get_coins(lua_State* L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

		if (ch == NULL) 
			return 0;

		SQLMsg *msg = DBManager::instance().DirectQuery("SELECT coins FROM account.account WHERE id = '%d'", ch->GetAID());

		if (msg->uiSQLErrno != 0)
			return 0;

		MYSQL_RES *res = msg->Get()->pSQLResult;

		MYSQL_ROW row = mysql_fetch_row(res);

		if (!row[0])
			return 0;

		lua_pushnumber(L, atoi(row[0]));
		return 1;
	}
  • Love 2
Link to comment
  • 0
	int pc_get_coins(lua_State* L)
	{
		LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

		if (ch == NULL) 
			return 0;

		SQLMsg *msg = DBManager::instance().DirectQuery("SELECT coins FROM account.account WHERE id = '%d'", ch->GetAID());

		if (msg->uiSQLErrno != 0)
			return 0;

		MYSQL_RES *res = msg->Get()->pSQLResult;

		MYSQL_ROW row = mysql_fetch_row(res);

		if (!row[0])
			return 0;

		lua_pushnumber(L, atoi(row[0]));
		return 1;
	}

 

 

quest ep_kupon begin
    state start begin
        when 80014.use begin
pc_get_coins("100")
syschat("100 EP you won..")
pc.remove_item("80014",1)
end
end
 
 
Error?
 
RunState: LUA_ERROR: [string "ep_kupon"]:1: attempt to call global `pc_get_coins' (a nil value)
WriteRunningStateToSyserr: LUA_ERROR: quest ep_kupon.start click
Link to comment
  • 0

 

pc_get_coins("100")

o.O this function doesn't take a parameter.

 

if you want the one that sets the cash .. you have to use the existing one.

local charge_type = "cash"			
-- syntax : pc.charge_cash(amount, charge_type)
-- warning: 	1. 'charge_type' : "cash"(default) | "mileage"
-- 	   	2. 'amount' must be positive number.
pc.charge_cash(amount, charge_type)
Link to comment
  • 0

int pc_get_coins(lua_State* L)
{
LPCHARACTER ch = CQuestManager::instance().GetCurrentCharacterPtr();

if (ch == NULL)
return 0;

SQLMsg *msg = DBManager::instance().DirectQuery("SELECT coins FROM account.account WHERE id = '%d'", ch->GetAID());

if (msg->uiSQLErrno != 0)
return 0;

MYSQL_RES *res = msg->Get()->pSQLResult;

MYSQL_ROW row = mysql_fetch_row(res);

if (!row[0])
return 0;

lua_pushnumber(L, atoi(row[0]));
return 1;
}

 

 

quest ep_kupon begin

    state start begin

        when 80014.use begin

pc_get_coins("100")

syschat("100 EP you won..")

pc.remove_item("80014",1)

end

end

 

 

Error?

 

RunState: LUA_ERROR: [string "ep_kupon"]:1: attempt to call global `pc_get_coins' (a nil value)

WriteRunningStateToSyserr: LUA_ERROR: quest ep_kupon.start click

quest ep_kupon begin
    state start begin
        when 80014.use begin
            syschat("You have "..pc.get_coins().." EP.")
        end
    end
end
PS.

GET != SET

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Read our Rules
  • Activity

    1. 2

      [Python] Code Translator 2 to 3

    2. 0

      bug gaya

    3. 5

      Fix Core Crash (unused serverside packet)

    4. 45

      Chest Drop View

    5. 0

      How to add Python 3.9 script?

    6. 15

      Metin2 Download Center - Specifications & Documentation

    7. 5

      Fix Core Crash (unused serverside packet)

    8. 45

      Chest Drop View

    9. 5

      Fix Core Crash (unused serverside packet)

  • Recently Browsing

    No registered users viewing this page.

×
×
  • 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.