• 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++ Function] Reset Stats

KazzXD

New Member
Joined
Aug 31, 2007
Messages
63
Reaction score
0
A function for reset all player stats to 0 (skills and ml).

-- EDIT --
Already done, thank you! ;)
 
Last edited:
I don't know exactly what you mean, but if you want to set all player skills and magic level to 0, you can do it via a SQL Query, use this for the magic level:

Code:
UPDATE `players` SET `maglevel` = 0

and this one for the skills:

Code:
UPDATE `player_skills` SET `value` = 0
 
I don't know exactly what you mean, but if you want to set all player skills and magic level to 0, you can do it via a SQL Query, use this for the magic level:

Code:
UPDATE `players` SET `maglevel` = 0

and this one for the skills:

Code:
UPDATE `player_skills` SET `value` = 0

My idea is change it ONLINE.. Querys work only with offline players..

I already make a reset function on C++.. But, thank you.. ;)
 
Just add something to player.cpp like
Code:
void Player::resetStats()
{
	experience = 0;
	level = 1;
	levelPercent = 0;
	magLevel = 0;
	magLevelPercent = 0;
	mana = 100;
	manaMax = 100;
	manaSpent = 0;
	soul = 100;
	
	//NOT SURE ABOUT THIS CODE
	for(int32_t skill = SKILL_FIST; skill < SKILL__MAGLEVEL; ++skill)
	{
		skills[skill][SKILL_TRIES] = 0;
		skills[skill][SKILL_LEVEL] = 10;
		skills[skill][SKILL_PERCENT] = 0;
	}
		
	sendStats();
}

This to player.h
Code:
void resetStats();

And then add a function to luascript.cpp (Remember to register ir at luascript.cpp/h)
Code:
int32_t LuaInterface::luaDoPlayerResetStats(lua_State* L)
{
	//doPlayerResetStats(cid)
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getEnv();

	Player* player = env->getPlayerByUID(cid);
	if(player)
	{
		player->resetStats();
		lua_pushboolean(L, true);
	}
	else
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 1;
}

And then just save the player with 'doPlayerSave(cid)'
 
Last edited:
Back
Top