Ir para conteúdo

[7.6]premium Account Perfeita!


Posts Recomendados

Code feito por Dark Tico

- Editado por Cayan

- Post por Rappa Carnaúba

Otserv.cpp

Troque seu:

 

msg.AddU16(account.premDays);

 

Para:

 

g_game.countPremmy(accnumber);    Account acc = IOAccount::instance()->loadAccount(accnumber);    msg.AddU16((int)floor(double(acc.premDays)/(1.0)));

 

Abaixo:

 

// Call to WSA Startup on Windows Systems

 

Adicione:

 

std::cout << ":: Loading Premmy area...";if(!g_game.getPremmyArea()){ ErrorMessage("Could not load premmy.xml!"); return -1;}std::cout << "[done]" << std::endl;

 

Player.h

No topo de todos os outros includes:

 

#include "ioaccount.h"

 

Abaixo:

 

bool gainHealthTick();

 

Adicione:

 

bool isPremmium() const{       Account acc = IOAccount::instance()->loadAccount(getAccountNumber());       if((int)floor(double(acc.premDays)/(1.0) > 0 || acc.premDays < 0))           return true;       else           return false;   }

 

Abaixo:

 

Protocol *client;

 

Adicione:

 

virtual const int& getAccountNumber() const {return accountNumber;};

 

Game.cpp

Acima:

 

// *** Checking if the thing can be moved around

 

Adicione:

 

if(player && playerMoving && !player->isPremmium()){    if(!premmytiles.empty()){  for(int o = 0; o < premmytiles.size(); o++) {   if((premmytiles[o].second.x != 0) && (premmytiles[o].second.y != 0) && (premmytiles[o].second.z != 0)){    if(Position(to_x, to_y, to_z) == premmytiles[o].first) {     player->sendCancelWalk();     teleport(playerMoving, Position(premmytiles[o].second.x, premmytiles[o].second.y, premmytiles[o].second.z));     player->sendMagicEffect(player->pos, NM_ME_MAGIC_ENERGIE);     return;    }   }   else{    if(Position(to_x, to_y, to_z) == premmytiles[o].first) {     player->sendCancelWalk();     break;    }      }        } }}

 

Adicione no fim:

 

bool Game::countPremmy(unsigned long accno){   Account acc = IOAccount::instance()->loadAccount(accno);   if(acc.premDays < 0)       return true;   int cont;   if(acc.lastsaveday == 0){       cont = 0;   }   else{       cont = (int)floor(double(acc.lastsaveday2)/(1.0)) - (int)floor(double(acc.lastsaveday)/(1.0));   }   if(((int)floor(double(acc.premDays)/(1.0)) - cont) <= 0){       acc.premDays = 0;   }   else{       acc.premDays = ((int)floor(double(acc.premDays)/(1.0)) - cont);   }   IOAccount::instance()->saveAccount(acc);}bool Game::getPremmyArea(){std::string file = g_config.getGlobalString("datadir") + "premmy.xml";xmlDocPtr doc;doc = xmlParseFile(file.c_str());if(doc){ xmlNodePtr root, ptr;  root = xmlDocGetRootElement(doc);  ptr = root->children;  while(ptr){  std::string str = (char*)ptr->name;  if(str == "premmytile"){     int x = atoi((const char*) xmlGetProp(ptr, (xmlChar*) "x"));    int y = atoi((const char*) xmlGetProp(ptr, (xmlChar*) "y"));    int z = atoi((const char*) xmlGetProp(ptr, (xmlChar*) "z"));   int exitx = 0;   int exity = 0;   int exitz = 0;   exitx = atoi((const char*) xmlGetProp(ptr, (xmlChar*) "exitx"));    exity = atoi((const char*) xmlGetProp(ptr, (xmlChar*) "exity"));    exitz = atoi((const char*) xmlGetProp(ptr, (xmlChar*) "exitz"));   std::pair<Position, Position> premmytile;   premmytile.first = Position(x, y, z);   premmytile.second = Position(exitx, exity, exitz);   premmytiles.push_back(premmytile);  }    ptr = ptr->next; } xmlFreeDoc(doc); return true;}return false;}

 

Game.h

Abaixo (PUBLIC):

 

bool stopEvent(unsigned long eventid);

 

Adicione:

 

bool countPremmy(unsigned long accno);bool getPremmyArea();std::vector< std::pair<Position, Position> > premmytiles;

 

Account.h

Abaixo:

 

int premDays;

 

Adicione:

 

int lastsaveday; int lastsaveday2;

 

IOAccount.cpp

Adicione no fim:

 

bool IOAccount::saveAccount(Account acc){return false;}

 

IOAccount.h

Depois:

 

virtual bool getPassword(unsigned long accno, const std::string &name, std::string &password);

 

Adicione:

 

virtual bool saveAccount(Account acc);

 

Se você usa XML

IOAccountXML.cpp

Adicione no topo dos outros includes includes:

 

#include <math.h>

 

Abaixo:

 

nodeValue = (char*)xmlGetProp(root, (xmlChar*)"premDays"); acc.premDays  = atoi(nodeValue); xmlFreeOTSERV(nodeValue);

 

Adicione:

 

nodeValue = (char*)xmlGetProp(root, (xmlChar*)"lastsaveday");       acc.lastsaveday  = atoi(nodeValue);       xmlFreeOTSERV(nodeValue);       struct tm * timeinfo;       time_t nowTime;       time(&nowTime);       timeinfo = localtime(&nowTime);       mktime(timeinfo);       acc.lastsaveday2 = timeinfo->tm_yday;

 

Adicione no final:

 

bool IOAccountXML::saveAccount(Account acc){   std::stringstream accsstr;   std::string datadir = g_config.getGlobalString("datadir");   accsstr << datadir + "accounts/" << acc.accnumber << ".xml";;   std::string filename = accsstr.str();   std::transform(filename.begin(), filename.end(), filename.begin(), tolower);   std::stringstream sb;   xmlDocPtr doc;   xmlMutexLock(xmlmutex);   xmlNodePtr nn, sn, pn, root;   doc = xmlNewDoc((const xmlChar*)"1.0");   doc->children = xmlNewDocNode(doc, NULL, (const xmlChar*)"account", NULL);   root = doc->children;   sb << acc.password;       xmlSetProp(root, (const xmlChar*) "pass",        (const xmlChar*)sb.str().c_str());     sb.str("");   sb << acc.accType;        xmlSetProp(root, (const xmlChar*) "type",        (const xmlChar*)sb.str().c_str());     sb.str("");   sb << acc.premDays;       xmlSetProp(root, (const xmlChar*) "premDays",    (const xmlChar*)sb.str().c_str());     sb.str("");   sb << acc.lastsaveday2;    xmlSetProp(root, (const xmlChar*) "lastsaveday", (const xmlChar*)sb.str().c_str());     sb.str("");   sn = xmlNewNode(NULL,(const xmlChar*)"characters");   std::list<std::string>::iterator it;   for (it = acc.charList.begin(); it != acc.charList.end(); it++)   {       pn = xmlNewNode(NULL,(const xmlChar*)"character");       sb << (*it);       xmlSetProp(pn, (const xmlChar*) "name",     (const xmlChar*)sb.str().c_str());     sb.str("");       xmlAddChild(sn, pn);   }   xmlAddChild(root, sn);   if (xmlSaveFile(filename.c_str(), doc))   {       xmlFreeDoc(doc);       xmlMutexUnlock(xmlmutex);   }   else   {       //std::cout << "\tCouldn't save account =(\n";       xmlFreeDoc(doc);       xmlMutexUnlock(xmlmutex);       return false;   }}

 

IOAccountXML.h

Depois:

 

virtual bool getPassword(unsigned long accno, const std::string &name, std::string &password);

 

Adicione:

 

virtual bool saveAccount(Account acc);

 

Se você usa SQL

IOAccountSQL.cpp

Adicione no topo dos includes:

 

#include <math.h>

 

Depois:

 

acc.premDays = result.getDataInt("premDays");

 

Adicione:

 

acc.lastsaveday = result.getDataInt("lastsaveday"); acc.lastsaveday2 = std::time(NULL);

 

Adicione no final:

 

bool IOAccountSQL::saveAccount(Account acc){//try//{ Database mysql; DBQuery query; DBResult result; mysql.connect(m_db.c_str(), m_host.c_str(), m_user.c_str(), m_pass.c_str()); //check if the player have to be saved or not query << "SELECT save FROM accounts WHERE accno='" << acc.accnumber << "'"; if(!mysql.storeQuery(query,result) || (result.getNumRows() != 1) )  return false; if(result.getDataInt("save") != 1) // If save var is not 1 don't save the player info  return true; //Start the transaction  query << "BEGIN;"; if(!mysql.executeQuery(query))  return false; //First, an UPDATE query to write the player itself query << "UPDATE `accounts` SET "; query << "`accno`='" << acc.accnumber << "', "; query << "`password`='" << acc.password << "', "; query << "`type`='" << acc.accType << "', "; int onlineTime = (int)floor(double(acc.lastsaveday2)/(1.0)) - (int)floor(double(acc.lastsaveday)/(1.0)); if(acc.premDays > 0)  query << "`premDays`='" << (int)floor(double(acc.premDays)*(1.0) - (onlineTime)) << "', "; else if(acc.premDays < 0)  query << "`premDays`='" << -1 << "', "; else  query << "`premDays`='" << 0 << "', "; query << "`lastsaveday`='" << acc.lastsaveday2 << "' "; query << " WHERE `accno`="<< acc.accnumber <<" LIMIT 1";    if(!mysql.executeQuery(query))  return false; //End the transaction query.reset(); query << "COMMIT;"; if(!mysql.executeQuery(query))  return false;/*}catch(DBError e){ switch(e.getType()) { case DB_ERROR_QUERY: case DB_ERROR_STORE: case DB_ERROR_DATA_NOT_FOUND:  std::cout << "DB WARNING: (" << e.getType() << ") " << e.getMsg() << std::endl;  break; default:  std::cout << "DB ERROR: (" << e.getType() << ") " << e.getMsg() << std::endl;  return false; }}catch(...){ std::cout << "ERROR: Unknown exception raised.\n\tFile: " << __FILE__ << "\n\tLine: " << __LINE__ << std::endl; return false;}*/return true;}

 

IOAccountSQL.h

Abaixo:

 

virtual bool getPassword(unsigned long accno, const std::string &name, std::string &password);

 

Adicione:

 

virtual bool saveAccount(Account acc);

 

commands.cpp

no final do arquivo adicione:

 

bool Commands::premmydays(Creature* c, const std::string &cmd, const std::string &param){Player* pl = dynamic_cast<Player*>©;Account acc = IOAccount::instance()->loadAccount(pl->accountNumber);std::string tmp = param;std::string::size_type pos = tmp.find(' ', 0);if(pos == std::string::npos) return true;unsigned long days = atoi(tmp.substr(0, pos).c_str());tmp.erase(0, pos+1);std::string name = tmp.c_str();Player* player = game->getPlayerByName(name);acc.premDays += days;   if(acc.premDays >= 180){         player->sendTextMessage(MSG_SMALLINFO,"This player is already on the maximum premium days allowed.");         return false;      }return true;}

 

abaixo de:

 

{"/kick",&Commands::kickPlayer},

 

add:

 

{"/premdays",&Commands::premmydays},

 

commands.h

abaixo de:

 

bool kickPlayer(Creature* c, const std::string &cmd, const std::string &param);

 

add:

 

bool premmydays(Creature* c, const std::string &cmd, const std::string &param);

 

Premmy.xml

 

<?xml version="1.0"?><premmytiles><premmytile x="160" y="54" z="7" exitx="160" exity="43" exitz="7"/><premmytile x="130" y="33" z="7"/></premmytiles>

 

Exemplo de acc.xml

 

<?xml version="1.0"?><account pass="tibia" type="1" premDays="30" lastsaveday="0"><characters><character name="GOD Rapha"/></characters></account>

 

Agradecimentos especiais para N4ruto,Cayan, Dark Tico, SteveMagican,Rappa Carnaúba

Anteciosamente,

Heitorzin

OBS:EU SO TROUXE O CODE PARA CÁ !!!!!

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

Essa P.A é muito diferente porém pode fazer no site e nao que nem as outras dizem que vale 1 a 10 dias e termina dps de 1 mes ou 1 ano itendeu ?

E sao com Tickets,tipo do seu ot João.

Espero ter Ajudado,

Heitorzin

Link para o comentário
Compartilhar em outros sites

  • 1 month later...

OOOO todo mundo q manda esses code não me explica como q coloca direito no xml!!! Eu so meiuuuu lerdoooo! Se alguen puder me ajuda meu msn é willian_darkboy@hotmail.com

:bye: ! Parece q ficou muito bom! Que pena q eu nun consiguuuu usa! :confused:

Link para o comentário
Compartilhar em outros sites

  • 3 weeks later...
  • 1 month later...

Olá, :bye: , vc pode me ensinar como eu uso esse comando no jogo?

Pq tpw eh /premdays, ai depois eu coloco oq?

Eu to tentando de tudo aki, n to conseguino usa o comando, eu ja compilei jah e deu certim =):

Por favor me ajuda!!!

Link para o comentário
Compartilhar em outros sites

  • 2 weeks later...
  • 1 year later...

Cara parabens

 

ai pelo topico

 

deve ter dado um trabalhão

 

fico muito bom o seu trabalho, ta irado

 

fico muito bem feito o code

 

Parabens mesmo

 

flw

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...