Jump to content

Quest Function: pc.get_cash


Go to solution Solved by Sanchez,

Recommended Posts

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
Share on other sites

  • Premium
  • Solution
	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
Share on other sites

  • 8 months later...
	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
Share on other sites

 

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
Share on other sites

  • Active Member

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
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



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