BE

[Função] Quests.xml

Por Beeki, 25 de fev. de 2012 em Linguagens de Programação

script
otserv
9
2.3k
BeekiB
25 de fevereiro de 2012 às 00:18

Bem vim trazer essa função aqui pra vocês é bem util pra quem está afim de criar um otserver completo!

 

Vá até quests.cpp e procure por.

 

std::string Mission::getDescription(Player* player)

 

Depois de achar, substitua por isso.

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.";
}

 

Pronto depois só compilar.

 

Aqui está um exemplo de como adicionar novas quests no arquivo.xml

 

<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>

 

Creditos:

 

Beeki ( por trazer )

QuaS ( OTland )

 

@Edit

 

testei somente no tfs 0.4 e no 0.3.6 pl1

Editado Março 25 por Beeki

1 mês depois...
VincV
25 de março de 2012 às 11:31

isso vai aparece naquele janelinha que abre no cliente quando clica em quests?

BeekiB
25 de março de 2012 às 11:46

Isso mesmo.

VincV
25 de março de 2012 às 13:03

muito bom rep+,isso pode ajudar muito os players

BeekiB
25 de março de 2012 às 13:05

Obrigado ai, qualquer dúvida só postar.

VincV
25 de março de 2012 às 13:33

n é relacionado ao topico

mas vc conseguiria fase uma lua function para dar reload num player(reload na sql ou mysql)?tipo o load que da quando o player loga mas que de reload em uma table especifica,coluna ou todas,isso seria muito util, daria pra fsaer varios sistemas sem muda te que mexe nas sourcers

kriller12K
31 de março de 2012 às 21:00

cara ajuda,eu não entendi a ultima parte que:

<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>

 

 

onde eu coloco isso?

BeekiB
02 de abril de 2012 às 11:11

@Kriller

 

Cara isso ai é só um exemplo de como adicionar uma quest no quests.xml apos ser feito a introdução do código acima em sua source.

 

@Lordbug

 

um exemplo para o que você quer é isso aqui.

 

db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")

 

função db.executeQuery

Editado Abril 6 por Beeki

9 meses depois...
claudio17C
21 de janeiro de 2013 às 22:42

aeew cara os primeiros player funcionou normal mais depois ele não aparece mais no quest log ...