• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

[8.42+] doPlayerAddExhaust

Grim90

New Member
Joined
Jul 11, 2008
Messages
35
Reaction score
0
As we know, exhaust is very important thing in ot server.
Well, function such as doPlayerAddExhaust was very helpful for me, so I made it and now I would like to share it

It's simple:

luascript.cpp
Find:
Code:
	//doPlayerAddSkillTry(cid, skillid, n)
	lua_register(m_luaState, "doPlayerAddSkillTry", LuaScriptInterface::luaDoPlayerAddSkillTry);

Add below:
Code:
	//doPlayerAddExhaust(cid, exhaust)
	lua_register(m_luaState, "doPlayerAddExhaust", LuaScriptInterface::luaDoPlayerAddExhaust);

Find:
Code:
int32_t LuaScriptInterface::luaDoPlayerAddSkillTry(lua_State* L)

Add below (as a new function):
Code:
int32_t LuaScriptInterface::luaDoPlayerAddExhaust(lua_State* L)
{
	//doPlayerAddExhaust(uid, type, exhaust)
	uint32_t exhaust = popNumber(L), type = popNumber(L);

	ScriptEnviroment* env = getScriptEnv();
	if(Player* player = env->getPlayerByUID(popNumber(L)))
	{
		player->addExhaust(exhaust, type);
		lua_pushboolean(L, LUA_NO_ERROR);
	}
	else
	{
		reportErrorFunc(getErrorDesc(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, LUA_ERROR);
	}
	return 1;
}

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

Add below:
Code:
static int32_t luaDoPlayerAddExhaust(lua_State* L);

Tested with TFS 0.3 on 8.42.

Usage:
doPlayerAddExhaust(uid, A, B)
Where:
uid - target player
A - exhaustion type:
1 - aggressive spells
2 - non-aggressive spells
etc.
B - exhaustation time
 
doPlayerAddExhaust(cid, 2, 1000)
or
doPlayerAddExhaust(cid, 2, 1)

This works for action?
and crying damson 0.3.5pl?

./luascript.cpp: In static member function `static int32_t LuaScriptInterface::luaDoPlayerAddSkillTry(lua_State*)':
../luascript.cpp:3456: error: invalid conversion from `uint32_t' to `Exhaust_t'

../luascript.cpp:3456: error: initializing argument 2 of `void Player::addExhaust(uint32_t, Exhaust_t)'

../luascript.cpp:3457: error: `LUA_NO_ERROR' was not declared in this scope

../luascript.cpp:3462: error: `LUA_ERROR' was not declared in this scope

make.exe: *** [obj//luascript.o] Error 1

Execution terminated
 
Last edited:
Back
Top