Fala galera vim lhe apresentar 2 comando para seu servidor.
talkactions\script
guildlist.lua
function onSay(cid, words, param, channel)
local str = ""
if param == '' then
local lista = db.getResult("SELECT `name` FROM `guilds`;")
if(lista:getID() ~= -1) then
repeat
str = str .. lista:getDataString("name") .. "\n"
until not lista:next()
lista:free()
doShowTextDialog(cid, 2529, str == "" and "Não existem guilds no servidor." or str) return true
end
end
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
repeat
local rank = db.getResult("SELECT `name`, `level` FROM `guild_ranks` WHERE `id` = " .. lista:getDataInt("rank_id") .. " ORDER BY `level` DESC, `name` ASC;")
str = str .. lista:getDataString("name") .. " [" .. rank:getDataString("name") .. "]\n"
rank:free()
until not lista:next()
lista:free()
doShowTextDialog(cid, 2529, str)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Não há jogadores nesta guild.")
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Está Guild não existe.")
end
return true
end
talkactions.xml adicione a tag:
<talkaction words="!glist" script="guildlist.lua"/>
---
Deletar guilds do server que não tem mais players(foram deletadas):
Data/globalevents/script
deleteguild.lua
function onThink(interval, lastExecution)
local guilds = db.getResult("SELECT `name` FROM `guilds`;")
if(guilds:getID() ~= -1) then
repeat
local delete = db.getResult("SELECT `name`, `rank_id` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = " .. getGuildId(guilds:getDataString("name")) .. ");")
if(delete:getID() < 1) then
db.executeQuery("DELETE FROM guilds WHERE id = "..getGuildId(guilds:getDataString("name")))
end
until not guilds:next()
guilds:free()
end
return true
end
globalevents.xml
<globalevent name="Guild Delete" interval="36000" event="script" value="deleteguild.lua"/>