• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[C++] Help me with player kills

prod1gy

New Member
Joined
Feb 1, 2009
Messages
3
Reaction score
0
Hi, i`m trying to make it so players get "reputation points" when they kill someone and lose reputation points when they die, i don`t want to use lua functions and storage values, I prefer doing it on sources because it will be faster to edit on sql and many functions will use it for multipliers, the dying and losing "rep points" is done:


Code:
bool Player::onDeath()
{
	removeConditions(CONDITIONEND_DEATH);

		//fame lost.
	std::stringstream msg;
	int32_t famelost;
	if(fame > 0){
	famelost = (int32_t) fame * 0.025;
	}
	else 
		famelost = 0;

	fame = fame - famelost;
	msg << "Current fame: " << fame << ". Current medals: 0. Current rank: 0. Class rank: 0.";
	sendTextMessage(MSG_STATUS_CONSOLE_RED, msg.str());

[...]

but I can`t find the function to add fame, i can`t use addUnjustifiedKill() because it will be pvp-enforced, tried creature::onKilledCreature and it didn`t work, tried Creature::onDeath() and it also didn`t work, help, where should I add it ?

here is what i`m trying to add ( when it`s on players.cpp obv)

Code:
std::stringstream msg;
	int32_t famegain;
	if(attacked->fame >= 20){
	famegain = (int32_t) attacked->fame * 0.03;
	}
	else 
		famegain = 20;
	
	fame = fame + famegain;

	msg << "Current fame: " << fame << ". Current medals: 0. Current rank: 0. Class rank: 0.";
	sendTextMessage(MSG_STATUS_CONSOLE_RED, msg.str());
 
anyway use storages, its easier than adding extra variable that need to be saved
And storages execute queries only on player load(startup or first login, I'm not sure) and on player save(serv save or logout or forced player save by some script I guess)
 
in cases like this it is REALLY better to use storages cause they are designed to be extra variables just for cases like this(and quests of course, but quests can be done using only bool and newer revs use string storages)

Of course its faster to just variable=something than call function that do few things BUT do you really want to write your own code for saving that variable? also you need to put it in player class, not just some random int thrown in the code
 
I already created the variable, made it save, everything is working, I just coudln`t find where to add a value to the variable I created when a player kill another, but nevermind, just removed the pvp enforced check on unjustkill and it worked, thank you for trying to make me change my mind
 

Similar threads

Back
Top