• 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!

Removing levels?

Joined
Sep 6, 2007
Messages
362
Reaction score
3
Is it possible to remove levels from a player as well as the HP/Mana?

For example, in my server at level 200, you can get 2nd promotion, but it requires level sacrifice. If you agree to sacrifice 100 levels, you will go back to level 100 and have the same HP/mana as a level 100.
 
Nope wont work.

You would have to make a new function in the sources therefore.


kind regards, Evil Hero

Removing exp is already in sources.

Code:
int32_t LuaScriptInterface::luaDoPlayerAddExp(lua_State* L)
{
	//doPlayerAddExp(cid, exp)
	int64_t exp = popNumber(L);
	uint32_t cid = popNumber(L);

	ScriptEnviroment* env = getScriptEnv();
	if(Player* player = env->getPlayerByUID(cid))
	{
		if(exp > 0)
			player->addExperience(exp);
		else if(exp < 0)
			player->removeExperience(exp);
		else
		{
			lua_pushnumber(L, LUA_FALSE);
			return 1;
		}

		lua_pushnumber(L, LUA_TRUE);
	}
	else
	{
		reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushnumber(L, LUA_ERROR);
	}
	return 1;
}
 
It works, but only in TFS 0.3

Here is function to adding/removing levels:
Code:
function doPlayerAddLevel(cid, amount)
	local newExp = 0
	local currentLevel = getPlayerLevel(cid)
	if(amount > 0) then
		newExp = getExperienceForLevel(currentLevel + amount) - getExperienceForLevel(currentLevel)
	else
		newExp = getExperienceForLevel(currentLevel) - getExperienceForLevel(currentLevel + amount)
	end

	return doPlayerAddExp(cid, newExp)
end

Usage:
doPlayerAddLevel(cid, 1) - adding 1 level
doPlayerAddLevel(cid, -(getPlayerLevel(cid) - 100)) - your request

HP/Mana etc will be also changed.
 
Well last time when i tried it (was around alpha4) it didn't worked, so i was not sure if it was fixed already.

but good to know that it works now.


kind regards, Evil Hero
 
Now it's not working...

11:35 You advanced from Level 186 to Level 228.

The script:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == getPlayerSlotItem(cid, CONST_SLOT_HEAD).uid then
doPlayerAddLevel(cid, -(getPlayerLevel(cid) - 100))
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_GIFT_WRAPS)
return TRUE
end
return FALSE
end
 
My function is ok, I found error in sources.

Find: (in luascript.cpp)

player->removeExperience(exp);

change "exp" to "-exp".
 
My function is ok, I found error in sources.

Find: (in luascript.cpp)

player->removeExperience(exp);

change "exp" to "-exp".

Changed that and compiled.

Still didn't work.

data/lib/function.lua:
function doPlayerAddLevel(cid, amount)
local newExp = 0
local currentLevel = getPlayerLevel(cid)
if(amount > 0) then
newExp = getExperienceForLevel(currentLevel + amount) - getExperienceForLevel(currentLevel)
else
newExp = getExperienceForLevel(currentLevel) - getExperienceForLevel(currentLevel + amount)
end

return doPlayerAddExp(cid, newExp)
end

I noticed above if that + sign should be changed to -.

The main script:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == getPlayerSlotItem(cid, CONST_SLOT_HEAD).uid then
doPlayerAddLevel(cid, -(getPlayerLevel(cid) - 100))
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_GIFT_WRAPS)
return TRUE
end
return FALSE
end

It's giving me exp, not removing.
 
PROBLEM SOLVED

This is the correct script:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.uid == getPlayerSlotItem(cid, CONST_SLOT_HEAD).uid then
local exprem = getPlayerExperience(cid)- getExperienceForLevel(100)
doPlayerAddExp(cid, -exprem)
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_GIFT_WRAPS)
return TRUE
end
return FALSE
end

16:50 You were downgraded from Level 160 to Level 100.


Damn, it doesn't decrease HP/MANA for a level 100.
EDIT: It does remove HP/MANA, it just doesn't refresh the bars, when you get bloodhit, it will show you where you're at.
 
Last edited:
doRemoveCreature(cid) would sovle that problem I suppose.
EDIT: @slawkens, Oh yeah, you could do it that way aswell lmao. It's even better I'd say.
 
Last edited:
Back
Top Bottom