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

doCreatureAddMaxHealth/Mana

Lejjo

New Member
Joined
Sep 21, 2007
Messages
78
Reaction score
1
Do anyone know how to add this lua function? A function that changes the creatures max hp/mana

Code:
doCreatureAddMaxHealth(cid, maxhp)
doCreatureAddMaxMana(cid, maxmana)

or

Code:
doCreatureChangeMaxHealth(cid, maxhp)
doCreatureChangeMaxMana(cid, maxmana)


Another function that would be really helpful is something that changes the player skill totaly. We have 2 functions such as:

Code:
getPlayerSkill(cid, skillid)
doPlayerAddSkillTry(cid, skillid, n)

But what if we have a function like this:

Code:
setPlayerNewSkill(cid, skillid, newskill)

And if you have 100 in fist fighting, for an example, then you do:

Code:
setPlayerNewSkill(cid, 0, 60)

And you will get 60 in fist fighting.


I kinda need those functions and would be really helpful if someone could add those :)
Would be really good for me :)
Thank you!
 
First Function:


Second Function:


I hope they work :p

I guess he want to change the max health value, not set players health to max, but if it's like you mean it's better to use getCreatureMaxHealth(cid) instead of 10000000000000000000000
 
Code:
function setPlayerNewSkill(cid, skillid, newskill)
skill = getPlayerSkill(cid, skillid)
doPlayerAddSkillTry(cid, skillid, -skill)
doPlayerAddSKillTry(cid, skillid, newskill)
end
I'm on not my computer so i didn't tested.

I don't know if it will work becouse i don't know how doPlayerAddSkillTry(cid, skillid, n) work.
 
I don't need that add skill thing anymore, just the change doCreatureChangeMaxHealth/Mana and I have added it now. If no one helps you, you gotta do it by yourself.

Mod, please close this thead.
 
I think that the tries of any skill level will be 1000, but to get in that 1000 is getting harder as far you get skill level.

Code:
doCreatureChangeMaxHealth = function (cid, maxhp)
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
end

doPlayerChangeMaxMana = function (cid, maxmana)
    doPlayerAddMana(cid, getPlayerMaxMana(cid))
end
 
Last edited:
I think that it will be good if you give us a solution. It's just suggestion, no offence. When you solve the problem, it's good to share you knowlage because somebody may need it too.
 
Well, the happiness didn't last long :p

I manage to use this function on TFS 0.2.6 but now on 0.2.9 it just kills you.

Here is the code

luascript.cpp
Code:
	//doCreatureChangeMaxHealth(cid, newHealth)
	lua_register(m_luaState, "doCreatureChangeMaxHealth", LuaScriptInterface::luaDoCreatureChangeMaxHealth);

Code:
int32_t LuaScriptInterface::luaDoCreatureChangeMaxHealth(lua_State* L)
{
	//doCreatureChangeMaxHealth(uid,newHealth)
	int32_t healthChange = (int32_t)popNumber(L);
	uint32_t cid = popNumber(L);
	ScriptEnviroment* env = getScriptEnv();
	Creature* creature = env->getCreatureByUID(cid);
	if(creature)
	{
 	    creature->changeMaxHealth(healthChange);
		lua_pushnumber(L, LUA_NO_ERROR);
	}
	else
	{
		reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushnumber(L, LUA_ERROR);
	}
	return 1;
}

luascript.h
Code:
        static int32_t luaDoCreatureChangeMaxHealth(lua_State* L);

creature.cpp
Code:
void Creature::changeMaxHealth(int32_t healthChange)
{
   
    healthMax = (int32_t)healthChange;

	g_game.addCreatureHealth(this);
}

creature.h
Code:
        virtual void changeMaxHealth(int32_t healthChange);


When using this script, as I said, it kills you and when you relog, you login with 0 HP so you die again and when you login the second time you don't die.

I wonder why it could work on 0.2.6 but not on 0.2.9 and if anyone could make a fix to this?
 
Back
Top