• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Fix/Patch Parsing Storage Values Inside of Quest.xml

QuaS

Cykotitan Pwned =/
Joined
Sep 11, 2008
Messages
838
Reaction score
28
Location
Poland/ Wroclaw
Hi Otlanders. I'll give you quest system which parse storage values from players questlog.

Here We go:

Replace whole
PHP:
std::string Mission::getDescription(Player* player)
from quests.cpp to

PHP:
std::string Mission::getDescription(Player* player)
{
	std::string value;
	int32_t find_storage;
	player->getStorage(storageId, value);
	if(state.size())
	{
		std::string ret = state;
		while((find_storage=ret.find("|STORAGE:"))>-1)
		{
              int32_t parsing_storage = find_storage+9;
              std::string temp;
              while((int) ret[parsing_storage] != (int)'|')
              {
                   temp += ret[parsing_storage];
                   parsing_storage++;
              }
              parsing_storage -=find_storage-1;
              player->getStorage(atoi(temp.c_str()), temp);
              ret.replace(find_storage, parsing_storage, temp);
        }
		replaceString(ret, "|STATE|", value);
		return ret;
	}

	if(atoi(value.c_str()) >= endValue)
	{
		std::string ret = states.rbegin()->second;
		while((find_storage=ret.find("|STORAGE:"))>-1)
		{
              int32_t parsing_storage = find_storage+9;
              std::string temp;
              while((int) ret[parsing_storage] != (int)'|')
              {
                   temp += ret[parsing_storage];
                   parsing_storage++;
              }
              parsing_storage -=find_storage-1;
              player->getStorage(atoi(temp.c_str()), temp);
              ret.replace(find_storage, parsing_storage, temp);
        }
		replaceString(ret, "|STATE|", value);
		return ret;
	}

	for(int32_t i = endValue; i >= startValue; --i)
	{
		player->getStorage(storageId, value);
		if(atoi(value.c_str()) != i)
			continue;

		std::string ret = states[i - startValue];
		while((find_storage=ret.find("|STORAGE:"))>-1)
		{
              int32_t parsing_storage = find_storage+9;
              std::string temp;
              while((int) ret[parsing_storage] != (int)'|')
              {
                   temp += ret[parsing_storage];
                   parsing_storage++;
              }
              parsing_storage -=find_storage-1;
              player->getStorage(atoi(temp.c_str()), temp);
              ret.replace(find_storage, parsing_storage, temp);
        }
		replaceString(ret, "|STATE|", value);
		return ret;

	}

	return "Couldn't retrieve any mission description, please report to a gamemaster.";
}

How make it works? Write in ur quest message a "|STORAGE:NUMBER|"
For Example:
<mission name="The head of Kiper" storageid="1001" startvalue="1" endvalue="3">
<missionstate id="0" description="Kill Rotworms to summon a Kiper!! You've killed already |STORAGE:1002|/50 Rotworms and |STORAGE:1500|/2 Carrion Rotworms."/>
<missionstate id="1" description="Give his head to Talaturen!"/>
<missionstate id="2" description="Take the medal you got from Talaturen to Ruly!"/>
</mission>

Screenshot Ingame:
2zod65z.jpg


It's kinda good for such quests like "Killin in the name of.." Quest. ;)

Btw: this are my first litte steps in TFS enviroment ;)

//Tested on trunk 3660.
 
Last edited:
Nice Script!!! i will use for my achievements system, can you add the feature to use "/n" like lua scripts?
 
Replace whole
PHP:
std::string Mission::getDescription(Player* player)
from quests.cpp to

PHP:
std::string Mission::getDescription(Player* player)
{
	std::string value;
	int32_t find_storage;
	player->getStorage(storageId, value);
	if(state.size())
	{
		std::string ret = state;
		while((find_storage=ret.find("|STORAGE:"))>-1)
		{
              int32_t parsing_storage = find_storage+9;
              std::string temp;
              while((int) ret[parsing_storage] != (int)'|')
              {
                   temp += ret[parsing_storage];
                   parsing_storage++;
              }
              parsing_storage -=find_storage-1;
              player->getStorage(atoi(temp.c_str()), temp);
              ret.replace(find_storage, parsing_storage, temp);
        }
		replaceString(ret, "|STATE|", value);
		return ret;
	}

	if(atoi(value.c_str()) >= endValue)
	{
		std::string ret = states.rbegin()->second;
		while((find_storage=ret.find("|STORAGE:"))>-1)
		{
              int32_t parsing_storage = find_storage+9;
              std::string temp;
              while((int) ret[parsing_storage] != (int)'|')
              {
                   temp += ret[parsing_storage];
                   parsing_storage++;
              }
              parsing_storage -=find_storage-1;
              player->getStorage(atoi(temp.c_str()), temp);
              ret.replace(find_storage, parsing_storage, temp);
        }
		replaceString(ret, "|STATE|", value);
		return ret;
	}

	for(int32_t i = endValue; i >= startValue; --i)
	{
		player->getStorage(storageId, value);
		if(atoi(value.c_str()) != i)
			continue;

		std::string ret = states[i - startValue];
		while((find_storage=ret.find("|STORAGE:"))>-1)
		{
              int32_t parsing_storage = find_storage+9;
              std::string temp;
              while((int) ret[parsing_storage] != (int)'|')
              {
                   temp += ret[parsing_storage];
                   parsing_storage++;
              }
              parsing_storage -=find_storage-1;
              player->getStorage(atoi(temp.c_str()), temp);
              ret.replace(find_storage, parsing_storage, temp);
        }
		replaceString(ret, "|STATE|", value);
		return ret;

	}

	return "Couldn't retrieve any mission description, please report to a gamemaster.";
}

How i can set this?
 
Dude, take a look:

I have replaced the whole code:

Lua:
std::string Mission::getDescription(Player* player)
{
	std::string value;
	player->getStorage(storageId, value);
	if(state.size())
		return parseStorages(state, value);

	if(atoi(value.c_str()) >= endValue)
		return parseStorages(states.rbegin()->second, value);

	for(int32_t i = endValue; i >= startValue; --i)
	{
		player->getStorage(storageId, value);
		if(atoi(value.c_str()) == i)
			return parseStorages(states[i - startValue], value);
	}

	return "Couldn't retrieve any mission description, please report to a gamemaster.";
}

With the code you've posted, but I receive this error:

59076317.jpg


Any ideas? Using REV 3884
 
Back
Top