• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

[SOLVED] Add custom required currency to complete a quesst..

Status
Not open for further replies.

Reloac

BETA Tester
Add custom required currency to complete a quest..

Hey

I was checking over http://emudevs.com/showthread.php/2139-C-Script-On-kill-script?p=14684&viewfull=1#post14684 that someone else posted about, and was trying to modify it, as it requires the currency to accept the quest (if i see correct) instead of when you try to hand it in, i've been adding it to 4.3.4 TC, was wondering how to modify it for 4.3.4 TC and so that it requires the MG when you try to hand in the quest...

Thanks
 
Last edited:

Tommy

Founder
Well you would call it in 'CompleteQuest' or 'CanCompleteQuest' functions. Lemme take a look for you.
 
Last edited:

Reloac

BETA Tester
Well, I added yours and ingame (unless i added something to the wrong place, or its diff on 4.3.4) you can pickup the quest without any MG, but it doesnt go into your quest log, the quest still shows a "!" above their name in yellow, but the quest is showing as picked up, so no idea if i managed to mess up something.

EDIT : ahaha, you changed your reply as i did.. quote took to long to show :(
 

Tommy

Founder
Well, I added yours and ingame (unless i added something to the wrong place, or its diff on 4.3.4) you can pickup the quest without any MG, but it doesnt go into your quest log, the quest still shows a "!" above their name in yellow, but the quest is showing as picked up, so no idea if i managed to mess up something.

EDIT : ahaha, you changed your reply as i did.. quote took to long to show :(

I thought you meant to do it the same way like I had it and it wasn't working in 4.3.4, but I didn't catch the 'hand in quest' part of your post.

Anyway:

Inside of void Player::CompleteQuest(uint32 quest_id) above: SetQuestStatus(quest_id, QUEST_STATUS_COMPLETE);, add the following:

Code:
    QueryResult result = LoginDatabase.PQuery("SELECT magic_gold FROM account WHERE id='%u'", GetSession()->GetAccountId());
    if (!result)
        return;

    Field* fields = result->Fetch();
    uint32 currentMagicGold = fields[0].GetUInt32();

    if (currentMagicGold < quest->GetRequiredMagicGold())
    {
        GetSession()->SendAreaTriggerMessage("You don't have enough magic gold!");
        return;
    }
    else
    {
        currentMagicGold -= quest->GetRequiredMagicGold();
        LoginDatabase.PExecute("UPDATE account SET magic_gold='%u' WHERE id='%u'", currentMagicGold, GetSession()->GetAccountId());
    }

So now the void Player::CompleteQuest(uint32 quest_id) function should look like:

Code:
void Player::CompleteQuest(uint32 quest_id)
{
    if (quest_id)
    {
        QueryResult result = LoginDatabase.PQuery("SELECT magic_gold FROM account WHERE id='%u'", GetSession()->GetAccountId());
        if (!result)
            return;

        Field* fields = result->Fetch();
        uint32 currentMagicGold = fields[0].GetUInt32();

        if (currentMagicGold < quest->GetRequiredMagicGold())
        {
            GetSession()->SendAreaTriggerMessage("You don't have enough magic gold!");
            return;
        }
        else
        {
            currentMagicGold -= quest->GetRequiredMagicGold();
            LoginDatabase.PExecute("UPDATE account SET magic_gold='%u' WHERE id='%u'", currentMagicGold, GetSession()->GetAccountId());
        }

        SetQuestStatus(quest_id, QUEST_STATUS_COMPLETE);

        uint16 log_slot = FindQuestSlot(quest_id);
        if (log_slot < MAX_QUEST_LOG_SIZE)
            SetQuestSlotState(log_slot, QUEST_STATE_COMPLETE);

        if (Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id))
        {
            if (qInfo->HasFlag(QUEST_FLAGS_TRACKING))
                RewardQuest(qInfo, 0, this, false);
            else
                SendQuestComplete(qInfo);
        }
    }
}
 

Reloac

BETA Tester
Added that and get the following errors :

Code:
	5	IntelliSense: identifier "quest" is undefined	c:\Users\Chris\Desktop\Fun\src\server\game\Entities\Player\Player.cpp	15324	26	game
Error	2	error C2227: left of '->GetRequiredMagicGold' must point to class/struct/union/generic type	C:\Users\Chris\Desktop\Fun\src\server\game\Entities\Player\Player.cpp	15324	1	game
Error	4	error C2227: left of '->GetRequiredMagicGold' must point to class/struct/union/generic type	C:\Users\Chris\Desktop\Fun\src\server\game\Entities\Player\Player.cpp	15331	1	game
Error	1	error C2065: 'quest' : undeclared identifier	C:\Users\Chris\Desktop\Fun\src\server\game\Entities\Player\Player.cpp	15324	1	game
Error	3	error C2065: 'quest' : undeclared identifier	C:\Users\Chris\Desktop\Fun\src\server\game\Entities\Player\Player.cpp	15331	1	game

EDIT : Yeah, still no idea what is wrong with it :/
 
Last edited:

Reloac

BETA Tester
Nevermind, commented it out for now till i finish other things then can come back to this, more head>desk with making items require Magic Gold to buy from vendors! ^^
 

Tommy

Founder
Show me the code you have, it seems you didn't follow my guide on the other thread after you put the code where I told you to put it.
 

Reloac

BETA Tester
What part of the code did you want to see? i copy and pasted the full version and even tried just adding what you said, though the source is different (table numbers wise) in 4.0 over 3.3.5
 

Reloac

BETA Tester
Still no idea what is causing the error, as far as i can see, I've added everything to the correct place (or around that, because of the changes) from your previous post.
 

Reloac

BETA Tester
haha can close this gave up and made a currency to add to the quests, no idea why it wouldn't work in the end so.
 

Tommy

Founder
Sorry, been busy.

You have your column loading in the wrong place. It has to be loading from the count in the quest_template table, not where ever you want it to load. :p

It should be:

Code:
    for (int i = 0; i < QUEST_EMOTE_COUNT; ++i)
        OfferRewardEmoteDelay[i] = questRecord[164+i].GetInt32();

    RequiredMagicGold = questRecord[168].GetUInt16();
    // int32 WDBVerified = questRecord[169].GetInt32();

So right now it isn't loading the correct column data for RequiredMagicGold. If you changed it to how you have it in the database (like I have it above), it will load the correct RequiredMagicGold column value.
 

Tommy

Founder
http://puu.sh/6lZBf.png

I guess you wanted one of the place where i added it? included the error window also.

Oh, I thought you meant the quest in game was showing as undefined. :3

The reason why it is showing as undefined is because it isn't defined in that function, lol. If you look how it is calling quest at the end of that function, you can copy it and go with that. So it would look like:

Code:
        if (Quest const* quest = sObjectMgr->GetQuestTemplate(quest_id))
        {
             // Put your required magic gold code in here
        }
 

Tommy

Founder
If you did what I said above, it should work. Did you add required magic gold cost to the quest in the table? Did you restart the server afterwards? Double check the code and make sure it's loading the right column.
 
Status
Not open for further replies.
Top