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

battle mode

Dominik ms

Member
Joined
Jan 20, 2010
Messages
424
Reaction score
6
Whats is wrong??
I want script to check player fight mode (this 3 options on right from eq)
fightMode = FIGHTMODE_ATTACK;
fightMode = FIGHTMODE_BALANCED;
fightMode = FIGHTMODE_DEFENSE;


PHP:
int32_t LuaScriptInterface::luaGetBattleMode(lua_State* L)
{
	//getBattleMode(cid)
	ScriptEnviroment* env = getEnv();
	fightMode_t fightMode = FIGHTMODE_ATTACK;
	if(Player* player = env->getPlayerByUID(popNumber(L)))
		lua_pushnumber(L, rawFightMode);
	else
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}

	return 0;
}
 
Add in player.h:
[cpp] fightMode_t getFightMode() const {return fightMode;}[/cpp]
And this is the code for luascript.cpp:
[cpp]int32_t LuaScriptInterface::luaGetBattleMode(lua_State* L)
{
//getBattleMode(cid)
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)))
lua_pushnumber(L, player->getFightMode());
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}

return 0;
}[/cpp]
 
Not work, no bugs
i am testing with:
PHP:
say(cid, "" .. getBattleMode(cid) .. "")
then
PHP:
[Error - Action Interface]
data/actions/scripts/test.lua:onUse
Description:
data/actions/scripts/test.lua:2: attempt to concatenate a nil value
stack traceback:
        data/actions/scripts/test.lua:2: in function <data/actions/scripts/test.
lua:1>

if
PHP:
say(cid, getBattleMode(cid))
PHP:
GoD Dominik:
 
Last edited:
Add in player.h:
[cpp] fightMode_t getFightMode() const {return fightMode;}[/cpp]
And this is the code for luascript.cpp:
[cpp]int32_t LuaScriptInterface::luaGetBattleMode(lua_State* L)
{
//getBattleMode(cid)
ScriptEnviroment* env = getEnv();
if(Player* player = env->getPlayerByUID(popNumber(L)))
lua_pushnumber(L, player->getFightMode());
else
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}

return 0;
}[/cpp]

I think won't work good, because i made that function for my server and it is returning:

Ex:
Code:
Fightmode Attack = 1.2263
Fightmode Balanced = 1.22222555454
Fightmode Defense = 2

Something like that
 
Back
Top