gmstrikker
Well-Known Member
- Joined
- Jul 30, 2014
- Messages
- 458
- Solutions
- 1
- Reaction score
- 50
My tile need guild members online, but dont work so fine
lib/050-function
Code:
function getGuildMembers(GuildId)local players,query ={},db.getResult("SELECT `name` FROM `players` WHERE `rank_id` IN (SELECT `id` FROM `guild_ranks` WHERE `guild_id` = "..GuildId..");")
if(query:getID()~=-1)then
repeat
table.insert(players,query:getDataString("name"))untilnot query:next()
query:free()
end
return#players > 0 and players or falseend
dominarcitys.lua movements
Code:
local config = {
level = 50,
count = 1,
messages = {
[12000] = "A guild %s está penetrando no castelo.",
[12001] = "A guild %s já está dentro do castelo.",
[12002] = "A guild %s está perto de conquistar o castelo."
}
}
function table.insert(table, value)
table[#table + 1] = value
end
function getGuildOnlineMembers(guildId)
local pid, ip = {}, {}
for _, cid in pairs(getPlayersOnline()) do
if getPlayerGuildId(cid) == guildId and getPlayerLevel(cid) >= config.level and not isInArray(ip, getPlayerIp(cid)) then
table.insert(pid, cid)
table.insert(ip, getPlayerIp(cid))
end
end
return pid
end
function onStepIn(cid, item, position, fromPosition)
if not isPlayer(cid) then return true end
if item.actionid == 12000 then
if getPlayerGuildId(cid) < 1 or #getGuildOnlineMembers(getPlayerGuildId(cid)) < config.count then
doPlayerSendCancel(cid, "Você precisa estar em guild ou sua guild precisa ter no minimo "..config.count.." jogadores level "..config.level.." ou mais.")
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
doTeleportThing(cid, fromPosition, true)
return true
end
end
if getGlobalStorageValue(item.actionid + 4819) < os.time() then
broadcastMessage(config.messages[item.actionid]:format(getPlayerGuildName(cid)))
setGlobalStorageValue(item.actionid + 4819, os.time() + 10)
end
doCreatureSetSkullType(cid,3)
return true
end