Rafael Hamdan
OT Developer
Hello boys!
I'm using Trunk Revision 906 (latest revision), and today, I created an event on my PVP-ENFORCED ACCOUNT server: the player who gets more frags in 1 month will gain a SPECIAL WEAPON.
So I decided to create a page on my website which shows the ranking, but it works like that:
mysql_query("SELECT * FROM playersfrags ORDER BY 'frags' DESC LIMIT 10")
It shows 10 players who got more frags. All right, but I edited at sources (I don't like creaturescripts), to insert in the table "playersfrags":
I MADE THIS WAY:
At iologindata.cpp
at iologindata.h
and at player.cpp (all getCorpse function):
But I get an error saying: Error during getDataInt(frags)
What's wrong?
Yours,
Rafael Hamdan;
I'm using Trunk Revision 906 (latest revision), and today, I created an event on my PVP-ENFORCED ACCOUNT server: the player who gets more frags in 1 month will gain a SPECIAL WEAPON.
So I decided to create a page on my website which shows the ranking, but it works like that:
mysql_query("SELECT * FROM playersfrags ORDER BY 'frags' DESC LIMIT 10")
It shows 10 players who got more frags. All right, but I edited at sources (I don't like creaturescripts), to insert in the table "playersfrags":
I MADE THIS WAY:
At iologindata.cpp
Code:
bool IOLoginData::addDeathToRanking(std::string name)
{
Database* db = Database::getInstance();
DBQuery query;
DBResult* result;
query << "SELECT `name` FROM `playersfrags` WHERE `name` = " << db->escapeString(name);
if(!(result = db->storeQuery(query.str()))){
query.str("");
query << "INSERT INTO `playersfrags` (`name`, `frags`) VALUES (" << db->escapeString(name) << ", '1')";
return db->executeQuery(query.str());
}
do
{
uint32_t frags = result->getDataInt("frags");
uint32_t newfrags;
newfrags = frags + 1;
query.str("");
query << "UPDATE `playersfrags` SET `frags` = " << newfrags << " WHERE `name` = " << db->escapeString(name);
return db->executeQuery(query.str());
}
while(result->next());
db->freeResult(result);
}
at iologindata.h
Code:
//DeathRanking System
bool addDeathToRanking(std::string name);
and at player.cpp (all getCorpse function):
Code:
Item* Player::getCorpse()
{
Item* corpse = Creature::getCorpse();
if(corpse && corpse->getContainer())
{
Creature* lastHitCreature = NULL;
Creature* mostDamageCreature = NULL;
char buffer[165];
if(getKillers(&lastHitCreature, &mostDamageCreature) && lastHitCreature)
sprintf(buffer, "You recognize %s. %s was killed by %s.", getNameDescription().c_str(), (getSex() == PLAYERSEX_FEMALE ? "She" : "He"), lastHitCreature->getNameDescription().c_str());
else
sprintf(buffer, "You recognize %s.", getNameDescription().c_str());
corpse->setSpecialDescription(buffer);
//DeathRanking by Rafael Hamdan
std::string playerNameToRank = lastHitCreature->getNameDescription().c_str();
if(!IOLoginData::getInstance()->addDeathToRanking(playerNameToRank))
std::cout << "Could not add " << getName() << "'s death to death ranking." << std::endl;
}
//End of DeathRanking
return corpse;
}
But I get an error saying: Error during getDataInt(frags)
What's wrong?
Yours,
Rafael Hamdan;