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

Help me here pls REP+

Stewie

Family Guy # ;3
Joined
May 3, 2010
Messages
786
Reaction score
12
Location
TV
Hi,

My server is WAR,i would like players with PZ locked can leave party too:

LUA:
int32_t LuaScriptInterface::luaDoPlayerLeaveParty(lua_State* L)
{
	//doPlayerLeaveParty(cid)
	ScriptEnviroment* env = getEnv();

	Player* player = env->getPlayerByUID(popNumber(L));
	if(!player)
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	g_game.playerLeaveParty(player->getID());
	lua_pushboolean(L, true);
	return 1;
}
 
All I found was this: http://otland.net/f35/doplayerleaveparty-cid-80214/

Somebody posted below an untested script that does what you want:
This is untested but it contains a fix, so you can force a leave even when the player is pz locked.

Code:
doPlayerLeaveParty(cid[, ignorePZ = false])
Code:
int32_t LuaInterface::luaDoPlayerLeaveParty(lua_State* L) //lifeline feature
{
	//doPlayerLeaveParty(cid[, ignorePZ])
	ScriptEnviroment* env = getEnv();
	bool ignorePZ = false;
	
	if(params > 1)
		ignorePZ = popNumber(L);

	Player* player = env->getPlayerByUID(popNumber(L));
	if(!player || player->isRemoved())
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	if(!player->getParty() || player->hasCondition(CONDITION_INFIGHT) && !ingorePZ)
	{
		lua_pushboolean(L, false);
	}
	player->getParty()->leave(player->getID());
	lua_pushboolean(L, true);
	return 1;
}


kind regards, Evil Hero

Although...if you look closely you can see that here:
Code:
	if(!player->getParty() || player->hasCondition(CONDITION_INFIGHT) && !ingorePZ)
it says 'ingorePZ' instead of 'ignorePZ':
Code:
	if(!player->getParty() || player->hasCondition(CONDITION_INFIGHT) && !ignorePZ)

Fixed?:
Code:
int32_t LuaInterface::luaDoPlayerLeaveParty(lua_State* L) //lifeline feature
{
	//doPlayerLeaveParty(cid[, ignorePZ])
	ScriptEnviroment* env = getEnv();
	bool ignorePZ = false;
	
	if(params > 1)
		ignorePZ = popNumber(L);

	Player* player = env->getPlayerByUID(popNumber(L));
	if(!player || player->isRemoved())
	{
		errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
		lua_pushboolean(L, false);
	}
	if(!player->getParty() || player->hasCondition(CONDITION_INFIGHT) && !ignorePZ)
	{
		lua_pushboolean(L, false);
	}
	player->getParty()->leave(player->getID());
	lua_pushboolean(L, true);
	return 1;
}

Still, I have not tested it...but sometimes a misspelling can ruin a whole script.
 
i have this error:

Code:
Compiler: Default compiler
Building Makefile: "\dev-cpp\Makefile.win"
Executing  make...
mingw32-make -f "\dev-cpp\Makefile.win" all
g++.exe -c ../luascript.cpp -o obj//luascript.o -I"include"  -D__USE_MYSQL__ -D__USE_SQLITE__ -D__ENABLE_SERVER_DIAGNOSTIC__ -D__CONSOLE__   -fexpensive-optimizations -O1

../luascript.cpp: In static member function `static int32_t LuaScriptInterface::luaDoPlayerLeaveParty(lua_State*)':
../luascript.cpp:8390: error: `params' was not declared in this scope

../luascript.cpp:8403: error: invalid conversion from `uint32_t' to `Player*'
../luascript.cpp:8403: error:   initializing argument 1 of `bool Party::leave(Player*)'

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

Execution terminated
 
[cpp]int32_t LuaInterface::luaDoPlayerLeaveParty(lua_State* L) //lifeline feature
{
//doPlayerLeaveParty(cid[, ignorePZ])
ScriptEnviroment* env = getEnv();
bool ignorePZ = false;

if(lua_gettop(L) > 1)
ignorePZ = popNumber(L);

Player* player = env->getPlayerByUID(popNumber(L));
if(!player || player->isRemoved())
{
errorEx(getError(LUA_ERROR_PLAYER_NOT_FOUND));
lua_pushboolean(L, false);
}
else if(!player->getParty() || player->hasCondition(CONDITION_INFIGHT) && !ignorePZ)
{
lua_pushboolean(L, false);
}

player->getParty()->leave(player);
lua_pushboolean(L, true);
return 1;
}
[/cpp]
 
Back
Top