|
|
 |
 |
 |
 |
|
 |
 |
|
 |
 |
|
 |
|
Development::Feature Requests Post suggestions/feature requests here. |

09-15-2005, 12:27 PM
|
 |
I know how to fix that!
|
|
Join Date: May 2005
Posts: 447
|
|
"I've learned c++ and coded it, so I don't need it anymore."
Well Hello Albert Einstein! That was quick learning!
__________________
Server_Op: ForbiddenZone
|

09-15-2005, 08:29 PM
|
Discordant
|
|
Join Date: Jun 2003
Posts: 345
|
|
Quote:
Originally Posted by Dr Zauis
"I've learned c++ and coded it, so I don't need it anymore."
Well Hello Albert Einstein! That was quick learning!
|
Quick yeah, but i dunno about how good is the code
Vrandom, once a player kills an other player , it add an entrie in the pvpstats table, in that way:
killID|Killername|killerlevel|killerguild|Looserna me|Looserlevel|Looserguild|PvPpoints|Timestamp
So you can see (using php by example):
- Daily, Weekly, Monthly: who is the best killer, which's the best guild, how many kills does have a player, who is the best target of a player, etc...
Also pvppoints are calculated depending of the levels and it also works for group kills.
Once I'll get to home, I'll show the code i've made.
Mag
Last edited by Magoth78; 09-16-2005 at 04:50 AM..
|
 |
|
 |

09-15-2005, 11:06 PM
|
Discordant
|
|
Join Date: Jun 2003
Posts: 345
|
|
Last line of database.cpp
Code:
bool Database::UpdatePVPPoints(const char* killername, int klevel, int kguildid, const char* loosername, int llevel, int lguildid, int pvppoints)
{
// debug
printf("Starting the update...\n");
// end debug
char errbuf[MYSQL_ERRMSG_SIZE];
char *query = 0;
int32 affected_rows = 0;
//printf("Variables ok...\n");
if (!RunQuery(query, MakeAnyLenString(&query,
"INSERT INTO pvpstats (killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints) VALUES ('%s','%i','%i','%s','%i','%i','%i')",killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints),
errbuf, 0, &affected_rows)); {
//printf("Error Updating the points......\n");
safe_delete_array(query);
return false;
}
//printf("UpdatePVPPoints: %s,%i,%i,%s,%i,%i,%i\n",killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints);
safe_delete_array(query);
return true;
}
add this in database.h:
Code:
bool UpdatePVPPoints(const char* killername, int klevel, int kguildid, const char* loosername, int llevel, int lguildid, int pvppoints);
and in attack.cpp just after the lines:
Code:
// if(!IsLD())//Todo: make it so an LDed client leaves corpse if its enabled
// MakeCorpse(exploss);
add this:
Code:
if(GetGM() || !IsBecomeNPC() && other != NULL && other->IsClient())
// added GetGM() for debug purposes
{
const char* killername = other->GetName();
int klevel = other->GetLevel();
int kguildid = other->CastToClient()->GuildDBID();
const char* loosername = this->GetName();
int llevel = this->GetLevel();
int lguildid = this->CastToClient()->GuildDBID();
int pvppoints;
int diflevel = klevel - llevel;
if(diflevel >= 10)
pvppoints = 10;
if(diflevel < 10 && diflevel >= 7)
pvppoints = 25;
if(diflevel < 7 && diflevel >= 4)
pvppoints = 40;
if(diflevel < 4 && diflevel >= 1)
pvppoints = 50;
if(diflevel == 0)
pvppoints = 60;
if(diflevel <= -1 && diflevel > -4 )
pvppoints = 80;
if(diflevel <= -4 && diflevel > -7)
pvppoints = 100;
if(diflevel < -7)
pvppoints = 120;
if(kguildid == NULL){
kguildid = 0;
}
if(lguildid == NULL){
lguildid = 0;
}
//// let's calcul points of the group
if(other->CastToClient()->IsGrouped()) {
Group* group = entity_list.GetGroupByClient(other->CastToClient());
for(int i=0;i<MAX_GROUP_MEMBERS;i++) {
if(group->members[i] != NULL) {
Client* c = group->members[i]->CastToClient();
pvppoints = llevel / 4;
c->Message(0,"You have gained %i points in this fight!",pvppoints);
database.UpdatePVPPoints(c->GetName(),c->GetLevel(),c->GuildDBID(),loosername,llevel,lguildid,pvppoints);
}
}
}
else{
printf("Variables: killername = %s, klevel = %i, kguildid = %i, loosername = %s, llevel = %i, lguildid = %i, pvppoints = %i\n",
killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints);
database.UpdatePVPPoints(killername,klevel,kguildid,loosername,llevel,lguildid,pvppoints);
//LogFile->write(EQEMuLog::Error, "%i,%i,%i,%s,%i,%i,%i"), killerid,klevel,kguildid,looserid,llevel,lguildid,pvppoints;
other->CastToClient()->Message(0,"You have gained %i points in this fight!",pvppoints);
printf("PVP: %s has been killed by %s\n",loosername,killername);
//this->CastToClient()->Message(0,"You have been killed by an enemy. Xp lost!");
}
}
yes I know that the code is ugly, but my skills in c++ are still low
You will can notice that all pvppoints are previously declared. (it's what i wanted to do on empire). You can change them, or add a formula for the points check.
You will have to create a new table in your db called "pvpstats" with the columns: id(int(11)auto_increment), killername(varchar(64)),klevel(int(11)),kguilid(in t(11)),loosername(varchar(64)),llevel(int(11)),lgu ildid(int(11)),pvppoints(int(11)),date(timestamp(C URRENT_TIMESTAMP on update CURRENT_TIMESTAMP)).
Mag
Last edited by Magoth78; 09-16-2005 at 07:09 AM..
|
 |
|
 |

09-16-2005, 04:00 AM
|
Sarnak
|
|
Join Date: Jun 2005
Posts: 91
|
|
Quote:
Originally Posted by Magoth78
Last line of database.cpp
yes I know that the code is ugly, but my skills in c++ are still low
Mag
|
np, my c++ skills are, humm, below that low you used, i just have a nack in figuring things out
Thanks for sharing, I'll see what I come up with later, got called to the office :( I hate the office....
Good job on the code Mag.
vRandom
|

09-16-2005, 05:31 AM
|
 |
The PEQ Dude
|
|
Join Date: Apr 2003
Location: -
Posts: 1,988
|
|
OT but I bet my office is worse than yours :P One of my users somehow removed the root user from their Linux server. I told them not use root. I told them they would break it.... LOL
|

09-16-2005, 05:43 AM
|
Sarnak
|
|
Join Date: Jun 2005
Posts: 91
|
|
Quote:
Originally Posted by cavedude
OT but I bet my office is worse than yours :P One of my users somehow removed the root user from their Linux server. I told them not use root. I told them they would break it.... LOL
|
LMAO, I totaly understand that one... my user did rm -fr in the root dir because it had to much stuff in it..... /sigh
vRandom
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -4. The time now is 07:13 PM.
|
|
 |
|
 |
|
|
|
 |
|
 |
|
 |