Ir para conteúdo

[7.9x] !premium "showpremium"


suboras

Posts Recomendados

Hiho ^.~

Meu primeiro post de code C++ =D

 

Eu estava la relembrando, "como eu era feliz jogando ot 7.6 (antes)"... Ai me deu vontade de jogar...

E eu me lembrei do comando "!premmy"... Vendo que a função que ve premiumDays (quando aparece a lista de characters) do Evolutions era "bugada", ou seja, nao era exata..

Eu descidi fazer esse code xP... E fiz ele "PERFECT" (pelo menos pra min)...

 

OBS: EU FIZ ESSE CODE PARA EVOLUTIONS, PORTANTO SE UTILIZAR OUTRO OTSERVE, "DECLARE" O CODE, FORA DO "#ifdef __XID_PREMIUM_SYSTEM__" AO CONTRARIO DE COMO ESTA NO TUTO... ¬¬

 

Bom, Chega de papo.. xD~

 

Em Commands.cpp, procure por:

#ifdef __XID_PREMIUM_SYSTEM__

{"/premium",&Commands::addPremium},

 

Add depois disso, e ANTES do "#endif"

{"!premium",&Commands::showPremium},

 

Ainda em commands.cpp, Procure por:

#ifdef __XID_PREMIUM_SYSTEM__
bool Commands::addPremium(Creature* creature, const std::string& cmd, const std::string& param)
{
uint32_t premiumTime = 0;
std::string name;
std::istringstream in(param.c_str());

std::getline(in, name, ',');
in >> premiumTime;	

Player* player = g_game.getPlayerByName(name);
if(player){
	if(premiumTime < 0 || premiumTime > 999){
		premiumTime = 1;
	}

	if(g_game.savePremium(player, premiumTime*86400, false)){
		g_game.addMagicEffect(player->getPosition(), NM_ME_MAGIC_POISON);
		return true;
	}
}

return false;
}
#endif

 

SUBISTITUA POR:

#ifdef __XID_PREMIUM_SYSTEM__
bool Commands::addPremium(Creature* creature, const std::string& cmd, const std::string& param)
{
uint32_t premiumTime = 0;
std::string name;
std::istringstream in(param.c_str());

std::getline(in, name, ',');
in >> premiumTime;	

Player* player = g_game.getPlayerByName(name);
if(player){
	if(premiumTime < 0 || premiumTime > 999){
		premiumTime = 1;
	}

	if(g_game.savePremium(player, premiumTime*86400, false)){
		g_game.addMagicEffect(player->getPosition(), NM_ME_MAGIC_POISON);
		return true;
	}
}

return false;
}

bool Commands::showPremium(Creature* creature, const std::string& cmd, const std::string& param)
{
Player* player = dynamic_cast<Player*>(creature);


int days;					
time_t timeNow = std::time(NULL);	
if(timeNow < player->premiumTicks){
	days = player->premiumTicks - timeNow; 
	days = (days / 86400);
}
else
	days = 0;

if (player)
{
	std::ostringstream info;
	if(days == 0)
{
	info << "You do not have premium account, or your premium account has expired.";
	player->sendTextMessage(MSG_STATUS_CONSOLE_RED, info.str().c_str());
}

	else if ((player->premiumTicks - timeNow) <= 691199 && days != 0)
	{
	//info << "You have " << days << /* << days << EH A MSM COISA Q " << str((player->premiumTicks - timeNow) / 86400) << "*/ " days of premium account left.\n " << str(player->premiumTicks - timeNow) << "\n " << str(player->premiumTicks - 1) << "\n " << str(player->premiumTicks + 1) << "";
	info << "You have " << days << " days of premium account left.";
	player->sendTextMessage(MSG_STATUS_CONSOLE_RED, info.str().c_str());
}
//else if((days / 86400) >= 7,9999)
else if((player->premiumTicks - timeNow) >= 691200)
{
	info << "You have " << days << " days of premium account left.";
	player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, info.str().c_str());
}
/*else if(days == 0)
{
	info << "You do not have premium account, or your premium account has expired.";
	player->sendTextMessage(MSG_STATUS_CONSOLE_BLUE, info.str().c_str());
}*/
}

return true;
} //Fim do Comando de ver premiums, by Suboras ^^
/*
CODE By Yurez, but based soucer code:
Neverland 7.6
Version 4.0

Neverland for Tibia 7.6 based on CVS from 2005-12-28.*/
#endif

 

Em commands.h, procure por:

#ifdef __XID_PREMIUM_SYSTEM__

bool addPremium(Creature* creature, const std::string& cmd, const std::string& param);

 

Add Abaixo:

bool showPremium(Creature* creature, const std::string& cmd, const std::string& param);

 

REDBUILD ALL, Ctrl 11 =)

 

Agora, em "data/commands.xml" Add:

<command cmd="!premium" access="0" />

 

CREDITOS: CODE, 30% by Yurez, 70% ME (Suboras)

TUTORIAL: 100% ME (Suboras)

 

PS: Se você quiser, pode retirar as "Lines/tags" de comentarios ("//" & "/* */")

 

Duvidas, Criticas: A VONTADE =S

 

Meu Primeiro Tuto...

Atenciosamente,

//Suboras

Editado por suboras
Link para o comentário
Compartilhar em outros sites

  • 2 months later...

hum...

bem interessante isso ai kra,parabens...

tpw,na maioria dos ots 7.9x ja mostra na tela dos chars qtus dias d premmy restam...

mas de um jeito ou de outro,isso ai é bom pra economizar tempo,e vai q vc ta com battle e nao pod ir pra akela tela né...

bem,mas parabens

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...