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

2 functions

Scooty

Enemia.EU
Joined
Jul 24, 2010
Messages
564
Reaction score
14
Location
Kraków
Hi, i need 2 simple functions but i cant do it myself ;/

1. CountOnlineGuildMembers(cid) - checking number of online players from cids guild
2. CountGuildMembers(cid) - checking number of players from cids guilds(online and offline)

Can somebody do it?

Thanks ;)
 
PHP:
function CountGuildMembers(cid) -- 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(getPlayerGuildName(cid)) .. ");")  
if(lista:getID() ~= -1) then  
repeat  count = count + 1 until not lista:next()  lista:free() return count end
end

function CountOnlineGuildMembers(cid) -- vodkart
        count = 0
        for _, cid in pairs(getPlayersOnline()) do
                if getPlayerGuildName(cid) == getPlayerGuildName(cid) then
                        count = count + 1
                end
        end
        return count
end


exemple talk:
Code:
if getPlayerGuildId(cid) <= 0  then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You must be in the Guild!")
else
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "you guild have "..CountOnlineGuildMembers(cid).." player online / members total of guild : "..CountGuildMembers(cid))
end
 
Last edited:
Back
Top