• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Who is from guild online, help fix

shor

New Member
Joined
Jan 2, 2011
Messages
137
Reaction score
0
Location
Poland
Hiho, I fould on forum talkaction which shows players online from your guild and it works, here is it:

function onSay(cid, words, param)
local onlineMembers = {}
local playerGuild = getPlayerGuildId(cid)

if playerGuild == 0 then
return TRUE
end

for _, name in ipairs(getOnlinePlayers()) do
if getPlayerGuildId(getPlayerByName(name)) == playerGuild then
table.insert(onlineMembers, name)
end
end

if #onlineMembers == 0 then
doPlayerSendTextMessage(cid, 24, "There are no players online from your guild..")
else
local playersOnline = #onlineMembers
local tmp = ""
if(playersOnline > 1) then
local tmp = "(s)"
end

local header = playersOnline .. " player" .. tmp .. " online from your guild."
local str = ""
for i, string in ipairs(onlineMembers) do
str = "\n" .. str .. string .. "\n"
end
doPlayerPopupFYI(cid, header .. ".\n " .. str)
end
return LUA_NO_ERROR
end



But I want command which shows people from other guild online, for example !guildonline NameOfGuild

Can someone change it?
 
16:27 Players online from guild Megiddo:
16:27 1. Vetix
16:27 2. Super Lays
16:27 3. Rash
CODE: :w00t:
PHP:
function onSay(cid, words, param)
	local onlineMembers = {}
	local guild_id = getGuildId(param)
	if guild_id then
		for _, uid in ipairs(getPlayersOnline()) do
			if getPlayerGuildId(uid) == guild_id then
				table.insert(onlineMembers, uid)
			end
		end
		if #onlineMembers > 0 then
			doPlayerSendTextMessage(cid, 24, "Players online from guild " .. param .. ":")
			for i, gmid in ipairs(onlineMembers) do
				doPlayerSendTextMessage(cid, 24, i .. ". " .. getPlayerName(gmid))
			end
		else
			doPlayerSendTextMessage(cid, 24, "No one is online.")
		end
	else
		doPlayerSendTextMessage(cid, 24, "Guild " .. param .. " does not exist.")
	end
	return true
end
 
I added to talkactions.xml
Code:
<talkaction words="!guild" script="guild2.lua"/>

and when I said "!guild Test Guild", nothing happened

when I said only "!guild" I got debug and error in console:
Code:
[20/01/2011 17:59:00] data/talkactions/scripts/guild2.lua:onSay
[20/01/2011 17:59:00] luaGetGuildId(). Guild not found
[20/01/2011 17:59:00] stack traceback:
[20/01/2011 17:59:00] 	[C]: in function 'getGuildId'
[20/01/2011 17:59:00] 	data/talkactions/scripts/guild2.lua:3: in function <data/talkactions/scripts/guild2.lua:1>

Did it work for you? Which tfs did you use? My is 0.2.9
 
Its like this..

Try
XML:
<talkaction words="!guild" event="script" script="guild2.lua"/>

and the code, well you have to change the function or edit source code, if this dosent work that is.
 
What engine do you use? I wrote it for 0.3.6pl1
I think you use other, because I had to change many functions names in code from you post to make it work.
In my sources code of this function is:
PHP:
int32_t LuaScriptInterface::luaGetGuildId(lua_State* L)
{
	//getGuildId(guildName)
	uint32_t guildId;
	if(IOGuild::getInstance()->getGuildId(guildId, popString(L)))
		lua_pushnumber(L, guildId);
	else
		lua_pushboolean(L, false);

	return 1;
}
NO ERROR MESSAGE
 
Back
Top