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

ADD +1 Magic Level

FKaupert

Joker Wolf
Joined
Nov 14, 2009
Messages
60
Reaction score
0
Location
Brazil
Version: 8.5
System: TFS 0.3.5pl1.r83
Problem: I'm trying to make the player gets 1 Magic Level when he perform an action X, I've tried with two different functions. One function is the TFS function and the other was made by my friend Socket.

TFS FUNCTION
What happens: The function adds the first level of magic level and then doesn't adds more.
Code:
function doPlayerAddMagLevel(cid, amount)
	for i = 1, amount do
		doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)) / getConfigInfo('rateMagic'))
	end
	return true
end

SOCKET FUNCTION
What happens: The function works perfectly on 8.54 servers, but don't work on 8.5 servers ... It doesn't add magic level and gives no error in the console.
Code:
function doPlayerAddMagicLevel(cid, magicLevel)
    local level = getPlayerMagLevel(cid)
    local mana = getPlayerRequiredMana(cid, level + magicLevel)
    doPlayerAddSpentMana(cid, mana)
    return true
end

Could someone help me make this new function in lua OR c++?
 
What about this?
Lua:
function doPlayerAddMagLevel(cid, amount)
	for i = 1, amount do
		doPlayerAddSpentMana(cid, (getPlayerRequiredMana(cid, getPlayerMagLevel(cid, true) + 1) - getPlayerSpentMana(cid)))
	end
	return true
end
 
[CPP]
int32_t LuaScriptInterface::luaDoPlayerAddMagLevel(lua_State* L)
{
bool multiplier = true;
if(lua_gettop(L) > 2)
multiplier = popNumber(L);

uint32_t amount = popNumber(L);
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)))
{
player->magLevel += amount;
lua_pushboolean(L, true);
}
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
return 1;
}
[/CPP]

C++ function, should work if u know how to implent it :)

[CPP]
//doPlayerAddMagLevel(cid, amount)
lua_register(m_luaState, "doPlayerAddMagLevel", LuaScriptInterface::luaDoPlayerAddMagLevel);
-----------------
static int32_t luaDoPlayerAddMagLevel(lua_State* L);
[/CPP]


NOT TESTED!
 

Similar threads

Back
Top