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

C++ Quest Script?

Status
Not open for further replies.

Portals

Banned
So I am still learning C++ and I am trying to make a quest script that will give you an item, spell, and say something at the end.

Here is the script: http://pastebin.com/9YwT2cfP

I am getting some errors with it though and not entirely sure why

3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(22): error C2059: syntax error : '{'
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(22): error C2334: unexpected token(s) preceding '{'; skipping apparent function body

Any help would be much appreciated.
 

Hamar

BETA Tester
You have error on line 21,
Code:
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest);

Should be
Code:
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
 

Portals

Banned
You have error on line 21,
Code:
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest);

Should be
Code:
bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)

Going to test now, thanks for such a fast reply!

Ok now theres a couple erros.

3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(23): error C2297: '|=' : illegal, right operand has type 'const char [7]'
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(26): error C2065: 'pPlayer' : undeclared identifier
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(26): error C2227: left of '->AddItem' must point to class/struct/union/generic type
3> type is ''unknown-type''
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(27): error C2065: 'pPlayer' : undeclared identifier
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(27): error C2227: left of '->AddSpell' must point to class/struct/union/generic type
3> type is ''unknown-type''
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(28): error C2146: syntax error : missing ';' before identifier '_SendSysMessage'
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(28): error C3861: 'ChatHandgler': identifier not found
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(29): error C2143: syntax error : missing ';' before 'return'
3>..\..\..\..\Source\src\server\scripts\Custom\Quest.cpp(28): error C3861: '_SendSysMessage': identifier not found
 
Last edited:

Hamar

BETA Tester
Code:
/*╔═══╦═╗╔═╦╗─╔╦═══╦═══╦╗──╔╦═══╗
*║╔══╣║╚╝║║║─║╠╗╔╗║╔══╣╚╗╔╝║╔═╗║
*║╚══╣╔╗╔╗║║─║║║║║║╚══╬╗║║╔╣╚══╗
*║╔══╣║║║║║║─║║║║║║╔══╝║╚╝║╚══╗║
*║╚══╣║║║║║╚═╝╠╝╚╝║╚══╗╚╗╔╝║╚═╝║
*╚═══╩╝╚╝╚╩═══╩═══╩═══╝─╚╝─╚═══╝
* Made By: Portals // Easily Customized Quest
*/
 
#include "ScriptPCH.h"
 
#define ITEM_ID         "6256"
#define QUEST_ID        "190000"
#define SPELL_ID        "7620"
 
class tutorial_quest : public CreatureScript
{
public:
        tutorial_quest() : CreatureScript("tutorial_quest") { }
 
        bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest);
        {
                if (quest->GetQuestId() != QUEST_ID) // The Quest ID is defined at the top of the script.
                        return false;
       
                player->AddItem(ITEM_ID, 1); // The Item ID is defined at the top of the script.
                player->learnSpell(SPELL_ID, false); //Gives Fishing
                ChatHandler(player->GetSession()).SendSysMessage("You're on your way to being a great fisherman, check your spellbook for the Fishing spell and your bags for your pole. You might wanna use the Shiney Bauble to increase your chances of getting catfish!") // When you accept the quest the creature will send this message, you can change it.
                        return true;
        }
};
 
void AddSC_tutorial_quest()
{
        new tutorial_quest;
}

Found some errors and decided to fix them for instead of trying to explain what you need to edit in order to get it working..
 

Portals

Banned
Code:
/*╔═══╦═╗╔═╦╗─╔╦═══╦═══╦╗──╔╦═══╗
*║╔══╣║╚╝║║║─║╠╗╔╗║╔══╣╚╗╔╝║╔═╗║
*║╚══╣╔╗╔╗║║─║║║║║║╚══╬╗║║╔╣╚══╗
*║╔══╣║║║║║║─║║║║║║╔══╝║╚╝║╚══╗║
*║╚══╣║║║║║╚═╝╠╝╚╝║╚══╗╚╗╔╝║╚═╝║
*╚═══╩╝╚╝╚╩═══╩═══╩═══╝─╚╝─╚═══╝
* Made By: Portals // Easily Customized Quest
*/
 
#include "ScriptPCH.h"
 
#define ITEM_ID         "6256"
#define QUEST_ID        "190000"
#define SPELL_ID        "7620"
 
class tutorial_quest : public CreatureScript
{
public:
        tutorial_quest() : CreatureScript("tutorial_quest") { }
 
        bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest);
        {
                if (quest->GetQuestId() != QUEST_ID) // The Quest ID is defined at the top of the script.
                        return false;
       
                player->AddItem(ITEM_ID, 1); // The Item ID is defined at the top of the script.
                player->learnSpell(SPELL_ID, false); //Gives Fishing
                ChatHandler(player->GetSession()).SendSysMessage("You're on your way to being a great fisherman, check your spellbook for the Fishing spell and your bags for your pole. You might wanna use the Shiney Bauble to increase your chances of getting catfish!") // When you accept the quest the creature will send this message, you can change it.
                        return true;
        }
};
 
void AddSC_tutorial_quest()
{
        new tutorial_quest;
}

Found some errors and decided to fix them for instead of trying to explain what you need to edit in order to get it working..

I was actually still getting errors with this but I figured it out and made it like this.

Code:
/*╔═══╦═╗╔═╦╗─╔╦═══╦═══╦╗──╔╦═══╗
*║╔══╣║╚╝║║║─║╠╗╔╗║╔══╣╚╗╔╝║╔═╗║
*║╚══╣╔╗╔╗║║─║║║║║║╚══╬╗║║╔╣╚══╗
*║╔══╣║║║║║║─║║║║║║╔══╝║╚╝║╚══╗║
*║╚══╣║║║║║╚═╝╠╝╚╝║╚══╗╚╗╔╝║╚═╝║
*╚═══╩╝╚╝╚╩═══╩═══╩═══╝─╚╝─╚═══╝
* Made By: Portals // Easily Customized Quest
*/

#include "ScriptPCH.h"

class tutorial_quest : public CreatureScript
{
public:
	tutorial_quest() : CreatureScript("tutorial_quest") { }

	bool OnQuestAccept(Player* player, Creature* creature, Quest const* quest)
	{
		if (quest->GetQuestId() != 190000)
			return false;

		player->AddItem(6256, 1);
		player->learnSpell(7620, false);
		ChatHandler(player->GetSession()).SendSysMessage("You're on your way to being a great fisherman!");
			return true;
	}
};

void AddSC_tutorial_quest()
{
	new tutorial_quest;
}

So yet I fixed the errors in the compile but when I launch worldserver.exe it crashes.

36d8566599326a0ef2026921d390af53.png
 
Last edited:

Tommy

Founder
That error you're receiving is towards another script that has the same script name.

Code:
                        // If the script is already assigned -> delete it!
                        sLog->outError(LOG_FILTER_TSCR, "Script '%s' already assigned with the same script name, so the script can't work.",
                            script->GetName().c_str());

                        ASSERT(false); // Error that should be fixed ASAP.

Change your script name and it should work.
 

Portals

Banned
That error you're receiving is towards another script that has the same script name.

Code:
                        // If the script is already assigned -> delete it!
                        sLog->outError(LOG_FILTER_TSCR, "Script '%s' already assigned with the same script name, so the script can't work.",
                            script->GetName().c_str());

                        ASSERT(false); // Error that should be fixed ASAP.

Change your script name and it should work.

Works perfect now, thank you!
 
Status
Not open for further replies.
Top