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

TalkAction Guild Information

Critico

Sexy
Joined
Mar 25, 2010
Messages
370
Reaction score
176
IrS1J.png


Credits: Vodkart


The command checks:

- The total number of guild members
- How many players have online
- Displays the name and rank of the players online

In lib/050-function add:

PHP:
function CountGuildMembers(GuildName) -- function by vodkart
local count = 0
local lista = db.getResult("SELECT `name`, `rank_id` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = " .. getGuildId(GuildName) .. ");")  
if(lista:getID() ~= -1) then  
repeat  count = count + 1 until not lista:next()  lista:free() return count end
end

In talkactions/script

guildinformation.lua
PHP:
function onSay(cid, words, param, channel)
local players,str,GuildName = {},'',getPlayerGuildName(cid)
if getPlayerGuildId(cid) <= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"Você precisa estar em uma Guild.") return true end
                                for _, cid in pairs(getPlayersOnline()) do
                                                                if getPlayerGuildName(cid) == GuildName then
                                                                                                table.insert(players, cid)
                                                                end
                                end
                                str = str .. "Membros total da guild: "..CountGuildMembers(GuildName).." Players.\n\nExiste "..#players.." Players online na sua guild:\n\n"
                                for i = 1, #players do
                                str = str.."\n["..getPlayerName(players[i]).."]["..getPlayerGuildRank(players[i]).."]"
                                end
return doShowTextDialog(cid, 2533, str)
end

talkactions.xml
Code:
<talkaction words="!guild" event="script" value="guildinformation.lua"/>
 
Last edited:
Looks great, how would I go about using this as a spell?

Ex. exivarus guildiarus, takes 50 mana and you get that popup?
 
Looks great, how would I go about using this as a spell?

Ex. exivarus guildiarus, takes 50 mana and you get that popup?

script name.lua
Code:
function onCastSpell(cid, var)
local players,str,GuildName = {},'',getPlayerGuildName(cid)
if getPlayerGuildId(cid) <= 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"You must be in the Guild!") return true end
                for _, cid in pairs(getPlayersOnline()) do
                                if getPlayerGuildName(cid) == GuildName then
                                                table.insert(players, cid)
                                end
                end
                str = str .. "Total members of guild: "..CountGuildMembers(GuildName).." Players.\n\nThere are "..#players.." Players online in guild:\n\n"
                for i = 1, #players do
                str = str.."\n["..getPlayerName(players[i]).."]["..getPlayerGuildRank(players[i]).."]"
                end
return doShowTextDialog(cid, 2533, str)
end

spells.xml
Code:
	<instant name="Show Guild" words="exivarus guildiarus" lvl="10" mana="50" prem="1" aggressive="0" exhaustion="10000" needlearn="0" event="script" value="script name.lua">
		<vocation id="1"/>
		<vocation id="5"/>
		<vocation id="2"/>
		<vocation id="6"/>
		<vocation id="3"/>
		<vocation id="7"/>
	</instant>
 
Last edited:
How would you make it show the offline players in the guild and their rank?

for this use:

Lua:
function onSay(cid, words, param, channel) 
        if param == '' then 
                local lista = db.getResult("SELECT `name` FROM `guilds`;") 
                if(lista:getID() ~= -1) then 
                        local v = '' 
                        repeat 
                                v = v .. lista:getDataString("name")  .. "\n" 
                        until not lista:next() 
                        lista:free() 
                        doShowTextDialog(cid, 2529, v) 
                else 
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não existem guilds no servidor.") 
                end 
        else 
                local id = getGuildId(param) 
                if id then 
                        local lista = db.getResult("SELECT `name`, `rank_id` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = " .. id .. ");") 
                        if(lista:getID() ~= -1) then 
                                local v = '' 
                                repeat 
                                        local rank = db.getResult("SELECT `name` FROM `guild_ranks` WHERE `id` = " .. lista:getDataInt("rank_id") .. " LIMIT 1;") 
                                        v = v .. lista:getDataString("name")  .. " [" .. rank:getDataString("name") .. "]\n" 
                                        rank:free() 
                                until not lista:next() 
                                lista:free() 
                                doShowTextDialog(cid, 2529, v) 
                        else 
                                doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "No hay jugadores en este guild.") 
                        end 
                else 
                        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Está Guild não existe.") 
                end 
        end 
        return TRUE 
end
 
That only shows me the name of every guild. Doesn't tell me (Name of my guild, players in my guild, their ranks, and adding their levels would also be nice)
 
Critico are you able to sort it by ranks? i mean 1st position guild master 2nd vices 3rd members etc and something to include all the ranks like for example:

1st gm
2nd vices
3rd council
4th royal guard
5th common army
6th pesant
 
For some reason your script only shows me the name of every guild on the game.. and doesnt even show me the characters name in the guilds.
 
not understand the request '-'

Lua:
function onSay(cid, words, param, channel)
local players,str = {},""
if param == '' then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"You must enter the name of a guild.") return true
elseif not getGuildId(param) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"This guild does not exist") return true end
                                for _, cid in pairs(getPlayersOnline()) do
                                                                if getPlayerGuildName(cid) == param then
                                                                                                table.insert(players, cid)
                                                                end
                                end
                                if #players > 0 then
                                str = str .. "Total members of guild: "..CountGuildMembers(param).." Players.\n\nThere are "..#players.." Players online in guild:\n\n"
                                for i = 1, #players do
                                str = str .. "" .. getPlayerName(players[i]) .."[".. getPlayerGuildRank(players[i]) .."]"
                                if i ~= #players then str = str .. ", " end
                                end
                                str = str .. "."
                                else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "don't have online players in this guild.") return true
end
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, str)
end
 
Good hotkey, I think you could get better it in the following way
Pre Status:
knights:
Druids:
Paladins:
Sorcerer:
All players online in guild:
Show all players in guild
Status (Offline) (Online)
Show vocation of player (Druid) (Sorcerer) (Knight) (Paladin)

Example (In guild Information add name of the guild "Guild Information: Rushandkill"
wIB7Y.png

Please create that Critico :)
 
Last edited:
Back
Top