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

Players in ipairs

Acubens

Old Penguin
Joined
May 6, 2008
Messages
1,303
Solutions
15
Reaction score
218
Location
Venezuela
Hello!! I have 1 question, Mystic Spirit dont support that function with Players online?

check my script, i want send advance msg to my channel "advances" but dont work this is my script,

LUA:
function onAdvance(cid, skill, oldlevel, newlevel)
  
        for _, pid in ipairs(getOnlinePlayers()) do 
	if skill == SKILL_LEVEL and oldlevel < getPlayerLevel(cid)+1 and newlevel > getPlayerLevel(cid)-1 then
		doPlayerSendChannelMessage(pid, "Ok:", "Player name up from "..oldlevel.." to "..getPlayerLevel(cid)..".", TALKTYPE_CHANNEL_O, 9)
	end
        end

end


error:
LUA:
 luaDoPlayerSendChannelMessage(). Condition not found
 
I use Mystic Spirit, that function dont exist, only exist getOnlinePlayers,

Function in Mystic Spirit getOnlinePlayers()

LUA:
int32_t LuaScriptInterface::luaGetOnlinePlayers(lua_State* L)
{
	//getOnlinePlayers()
	int32_t i = 0;
	lua_newtable(L);
	for(AutoList<Player>::listiterator it = Player::listPlayer.list.begin(); it != Player::listPlayer.list.end(); ++it)
	{
		lua_pushnumber(L, ++i);
		lua_pushstring(L, (*it).second->getName().c_str());
		lua_settable(L, -3);
	}
	return 1;
}

Function getPlayersOnline() from TFS 0.3.6pl1
LUA:
int32_t LuaScriptInterface::luaGetPlayersOnline(lua_State* L)
{
	//getPlayersOnline()
	ScriptEnviroment* env = getEnv();
	AutoList<Player>::iterator it = Player::autoList.begin();

	lua_newtable(L);
	for(int32_t i = 1; it != Player::autoList.end(); ++it, ++i)
	{
		lua_pushnumber(L, i);
		lua_pushnumber(L, env->addThing(it->second));
		pushTable(L);
	}
	return 1;
}


how i can convert that function to 0.2?
 
you don't need to convert anything, getOnlinePlayers should work in 0.2 but there isn't doPlayerSendChannelMessage
what did you try to do? adding it :p?
 
i added doPlayerSendChannelMessage() and works perfectly in mystic spirit, the only problem is that when using the function to send the message to everyone via the channel does not work, it gives me error
 
Back
Top