Histórico de Curtidas
-
xMonkey recebeu reputação de Carlinhous1996 em adicionando tempo a storageDesculpe meu erro.
Correção logo abaixo:
-- Created by pc98 -- Edited by xMonkey local castle_one_name = "Castle", -- Nome do castelo 1 local storages = {154154,54321,123123, 123124}, -- Storages ( se vc eh iniciante, deixe como está...) -- REWARDS I N D I V I D U A I S --------- local premio_por_vezes = 1, -- Premio por vezes de conquista de castelo. (1) = Ativo (0) = Desativa. local premio_vezes = 3, -- Caso ativo, a quantidade de conquista que o player tem, para ganhar PREMIO. local premio = 10522, -- ID do Premio local premio_cont = 1, -- Quantidade do Premio local premio_reset = 1, -- Resetar o contador do premio depois que atingir a meta?? (1) = SIM (0) = NAO local resetReward = {6, "day"} -- Tempo para resetar a storage e receber novamente a recompensa -- Para deixar mais organizado, jogar essas funções em LIB (se jogar em LIB, remover o local na frente de function) -- Custom Functions (inicio) local function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end local function getTimeString(self) local format = { {'dia', self / 60 / 60 / 24}, {'hora', self / 60 / 60 % 24}, {'minuto', self / 60 % 60}, {'segundo', self % 60} } local out = {} for k, t in ipairs(format) do local v = math.floor(t[2]) if(v > 0) then table.insert(out, (k < #format and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or '')) end end local ret = table.concat(out) if ret:len() < 16 and ret:find('segundo') then local a, b = ret:find(' e ') ret = ret:sub(b+1) end return ret end -- Custom Functions (fim) function onUse(cid, item, frompos, item2, topos) local sto_ativ, position = getGlobalStorageValue(storages[2]), getCreaturePosition(cid) if (isPlayerGuild(cid) == true) then if (sto_ativ == 1 or sto_ativ == -1) then guildname = getPlayerGuildName(cid) guild = getPlayerGuildId(cid) guild_sto = getGlobalStorageValue(storages[3]) if (guild ~= guild_sto) then setPlayerStorageValue(cid, guild_sto, guild) if (getPlayerStorageValue(cid, storages[1]) == -1) then setPlayerStorageValue(cid, storages[1], 0) end setGlobalStorageValue(storages[3], getPlayerGuildId(cid)) setPlayerStorageValue(cid,storages[1], getPlayerStorageValue(cid, storages[1]) + 1) sto_vezes_total = getPlayerStorageValue(cid, storages[1]) doBroadcastMessage("O(a) "..getCreatureName(cid).." acabou de conquistar o ".. castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) doRemoveItem(item.uid, 1) if (premio_por_vezes == 1) then if (getPlayerStorageValue(cid, storages[4]) - os.time() > 0) then doPlayerSendTextMessage(cid, 18, "Voce deve aguardar ".. getTimeString(getPlayerStorageValue(cid, storages[4]) - os.time()) .." para receber a recompensa novamente.") return true end if (getPlayerStorageValue(cid, storages[1]) == premio_vezes) then if (getItemWeightById(premio, 1) <= getPlayerFreeCap(cid)) then doBroadcastMessage("O ".. getCreatureName(cid) .." ganhou uma(o) ".. getItemNameById(premio) .." como recompensa das suas ".. premio_vezes .." conquistas!", 21) doPlayerAddItem(cid, premio, premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(premio) .." como recompensa das suas ".. premio_vezes .." conquistas!") if premio_reset == 1 then setPlayerStorageValue(cid,storages[1], 0) end setPlayerStorageValue(cid, storages[4], os.time() + mathtime(resetReward)) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para ganhar o item. Vamos verificar novamente em 10 segundos!") addEvent(additem, 10000, cid, premio, premio_cont, premio_reset) end end end else doBroadcastMessage("O(a) ".. getCreatureName(cid) .." acabou de conquistar o ".. castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) end else doPlayerSendCancel(cid, "O sistema está desativado") end else doPlayerSendCancel(cid, "É nescessario ter guild para dominar o castelo!") doSendMagicEffect(position, 2) end end function additem(cid, premio, premio_cont, premio_reset) if (not isPlayer(cid)) then stopEvent(additem) return true end if (getItemWeightById(premio, 1) <= getPlayerFreeCap(cid)) then doPlayerAddItem(cid, premio, premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(premio) .." como recompensa das suas ".. premio_vezes .." conquistas!") if (premio_reset == 1) then setPlayerStorageValue(cid, storages[1], 0) end setPlayerStorageValue(cid, storages[4], os.time() + mathtime(resetReward)) stopEvent(additem) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para receber o item. Verificando novamente em 10 segundos!") addEvent(additem, 10000, cid) end end function isPlayerGuild(cid) if (getPlayerGuildName(cid) ~= "") then return true else return false end end
-
xMonkey recebeu reputação de carloos em adicionando tempo a storageDesculpe meu erro.
Correção logo abaixo:
-- Created by pc98 -- Edited by xMonkey local castle_one_name = "Castle", -- Nome do castelo 1 local storages = {154154,54321,123123, 123124}, -- Storages ( se vc eh iniciante, deixe como está...) -- REWARDS I N D I V I D U A I S --------- local premio_por_vezes = 1, -- Premio por vezes de conquista de castelo. (1) = Ativo (0) = Desativa. local premio_vezes = 3, -- Caso ativo, a quantidade de conquista que o player tem, para ganhar PREMIO. local premio = 10522, -- ID do Premio local premio_cont = 1, -- Quantidade do Premio local premio_reset = 1, -- Resetar o contador do premio depois que atingir a meta?? (1) = SIM (0) = NAO local resetReward = {6, "day"} -- Tempo para resetar a storage e receber novamente a recompensa -- Para deixar mais organizado, jogar essas funções em LIB (se jogar em LIB, remover o local na frente de function) -- Custom Functions (inicio) local function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end local function getTimeString(self) local format = { {'dia', self / 60 / 60 / 24}, {'hora', self / 60 / 60 % 24}, {'minuto', self / 60 % 60}, {'segundo', self % 60} } local out = {} for k, t in ipairs(format) do local v = math.floor(t[2]) if(v > 0) then table.insert(out, (k < #format and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or '')) end end local ret = table.concat(out) if ret:len() < 16 and ret:find('segundo') then local a, b = ret:find(' e ') ret = ret:sub(b+1) end return ret end -- Custom Functions (fim) function onUse(cid, item, frompos, item2, topos) local sto_ativ, position = getGlobalStorageValue(storages[2]), getCreaturePosition(cid) if (isPlayerGuild(cid) == true) then if (sto_ativ == 1 or sto_ativ == -1) then guildname = getPlayerGuildName(cid) guild = getPlayerGuildId(cid) guild_sto = getGlobalStorageValue(storages[3]) if (guild ~= guild_sto) then setPlayerStorageValue(cid, guild_sto, guild) if (getPlayerStorageValue(cid, storages[1]) == -1) then setPlayerStorageValue(cid, storages[1], 0) end setGlobalStorageValue(storages[3], getPlayerGuildId(cid)) setPlayerStorageValue(cid,storages[1], getPlayerStorageValue(cid, storages[1]) + 1) sto_vezes_total = getPlayerStorageValue(cid, storages[1]) doBroadcastMessage("O(a) "..getCreatureName(cid).." acabou de conquistar o ".. castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) doRemoveItem(item.uid, 1) if (premio_por_vezes == 1) then if (getPlayerStorageValue(cid, storages[4]) - os.time() > 0) then doPlayerSendTextMessage(cid, 18, "Voce deve aguardar ".. getTimeString(getPlayerStorageValue(cid, storages[4]) - os.time()) .." para receber a recompensa novamente.") return true end if (getPlayerStorageValue(cid, storages[1]) == premio_vezes) then if (getItemWeightById(premio, 1) <= getPlayerFreeCap(cid)) then doBroadcastMessage("O ".. getCreatureName(cid) .." ganhou uma(o) ".. getItemNameById(premio) .." como recompensa das suas ".. premio_vezes .." conquistas!", 21) doPlayerAddItem(cid, premio, premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(premio) .." como recompensa das suas ".. premio_vezes .." conquistas!") if premio_reset == 1 then setPlayerStorageValue(cid,storages[1], 0) end setPlayerStorageValue(cid, storages[4], os.time() + mathtime(resetReward)) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para ganhar o item. Vamos verificar novamente em 10 segundos!") addEvent(additem, 10000, cid, premio, premio_cont, premio_reset) end end end else doBroadcastMessage("O(a) ".. getCreatureName(cid) .." acabou de conquistar o ".. castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) end else doPlayerSendCancel(cid, "O sistema está desativado") end else doPlayerSendCancel(cid, "É nescessario ter guild para dominar o castelo!") doSendMagicEffect(position, 2) end end function additem(cid, premio, premio_cont, premio_reset) if (not isPlayer(cid)) then stopEvent(additem) return true end if (getItemWeightById(premio, 1) <= getPlayerFreeCap(cid)) then doPlayerAddItem(cid, premio, premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(premio) .." como recompensa das suas ".. premio_vezes .." conquistas!") if (premio_reset == 1) then setPlayerStorageValue(cid, storages[1], 0) end setPlayerStorageValue(cid, storages[4], os.time() + mathtime(resetReward)) stopEvent(additem) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para receber o item. Verificando novamente em 10 segundos!") addEvent(additem, 10000, cid) end end function isPlayerGuild(cid) if (getPlayerGuildName(cid) ~= "") then return true else return false end end
-
xMonkey recebeu reputação de carloos em adicionando tempo a storageOlá @Carlinhous1996, boa noite!
Você não explicou exatamente quais storages gostaria de adicionar o tempo.
Ao meu ver, seria para receber a recompensa?
Fiz as modificações para só receber as recompensas caso a Storage tenha resetado, após 6 dias.
Também fiz uma pequena organização ao código.
-- Created by pc98 -- Edited by xMonkey local config = { castle_one_name = "Castle", -- Nome do castelo 1 storages = {154154,54321,123123, 123124}, -- Storages ( se vc eh iniciante, deixe como está...) -- REWARDS I N D I V I D U A I S --------- premio_por_vezes = 1, -- Premio por vezes de conquista de castelo. (1) = Ativo (0) = Desativa. premio_vezes = 3, -- Caso ativo, a quantidade de conquista que o player tem, para ganhar PREMIO. premio = 10522, -- ID do Premio premio_cont = 1, -- Quantidade do Premio premio_reset = 1, -- Resetar o contador do premio depois que atingir a meta?? (1) = SIM (0) = NAO resetReward = {6, "day"} -- Tempo para resetar a storage e receber novamente a recompensa } -- Para deixar mais organizado, jogar essas funções em LIB (se jogar em LIB, remover o local na frente de function) -- Custom Functions (inicio) local function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end local function getTimeString(self) local format = { {'dia', self / 60 / 60 / 24}, {'hora', self / 60 / 60 % 24}, {'minuto', self / 60 % 60}, {'segundo', self % 60} } local out = {} for k, t in ipairs(format) do local v = math.floor(t[2]) if(v > 0) then table.insert(out, (k < #format and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or '')) end end local ret = table.concat(out) if ret:len() < 16 and ret:find('segundo') then local a, b = ret:find(' e ') ret = ret:sub(b+1) end return ret end -- Custom Functions (fim) function onUse(cid, item, frompos, item2, topos) local sto_ativ, position = getGlobalStorageValue(config.storages[2]), getCreaturePosition(cid) if (isPlayerGuild(cid) == true) then if (sto_ativ == 1 or sto_ativ == -1) then guildname = getPlayerGuildName(cid) guild = getPlayerGuildId(cid) guild_sto = getGlobalStorageValue(config.storages[3]) if (guild ~= guild_sto) then setPlayerStorageValue(cid, guild_sto, guild) if (getPlayerStorageValue(cid, config.storages[1]) == -1) then setPlayerStorageValue(cid, config.storages[1], 0) end setGlobalStorageValue(config.storages[3], getPlayerGuildId(cid)) setPlayerStorageValue(cid,config.storages[1], getPlayerStorageValue(cid, config.storages[1]) + 1) sto_vezes_total = getPlayerStorageValue(cid, config.storages[1]) doBroadcastMessage("O(a) "..getCreatureName(cid).." acabou de conquistar o ".. config.castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) doRemoveItem(item.uid, 1) if (config.premio_por_vezes == 1) then if (getPlayerStorageValue(cid, config.storages[4]) - os.time() > 0) then doPlayerSendTextMessage(cid, 18, "Voce deve aguardar ".. getTimeString(getPlayerStorageValue(cid, config.storages[4]) - os.time()) .." para receber a recompensa novamente.") return true end if (getPlayerStorageValue(cid, config.storages[1]) == config.premio_vezes) then if (getItemWeightById(config.premio, 1) <= getPlayerFreeCap(cid)) then doBroadcastMessage("O ".. getCreatureName(cid) .." ganhou uma(o) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!", 21) doPlayerAddItem(cid, config.premio, config.premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!") if config.premio_reset == 1 then setPlayerStorageValue(cid,config.storages[1], 0) end setPlayerStorageValue(cid, config.storages[4], os.time() + mathtime(config.resetReward)) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para ganhar o item. Vamos verificar novamente em 10 segundos!") addEvent(additem, 10000, cid, config.premio, config.premio_cont, config.premio_reset) end end end else doBroadcastMessage("O(a) ".. getCreatureName(cid) .." acabou de conquistar o ".. config.castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) end else doPlayerSendCancel(cid, "O sistema está desativado") end else doPlayerSendCancel(cid, "É nescessario ter guild para dominar o castelo!") doSendMagicEffect(position, 2) end end function additem(cid, config.premio, config.premio_cont, config.premio_reset) if (not isPlayer(cid)) then stopEvent(additem) return true end if (getItemWeightById(config.premio, 1) <= getPlayerFreeCap(cid)) then doPlayerAddItem(cid, config.premio, config.premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!") if (config.premio_reset == 1) then setPlayerStorageValue(cid, config.storages[1], 0) end setPlayerStorageValue(cid, config.storages[4], os.time() + mathtime(config.resetReward)) stopEvent(additem) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para receber o item. Verificando novamente em 10 segundos!") addEvent(additem, 10000, cid) end end function isPlayerGuild(cid) if (getPlayerGuildName(cid) ~= "") then return true else return false end end
-
xMonkey recebeu reputação de Carlinhous1996 em adicionando tempo a storageOlá @Carlinhous1996, boa noite!
Você não explicou exatamente quais storages gostaria de adicionar o tempo.
Ao meu ver, seria para receber a recompensa?
Fiz as modificações para só receber as recompensas caso a Storage tenha resetado, após 6 dias.
Também fiz uma pequena organização ao código.
-- Created by pc98 -- Edited by xMonkey local config = { castle_one_name = "Castle", -- Nome do castelo 1 storages = {154154,54321,123123, 123124}, -- Storages ( se vc eh iniciante, deixe como está...) -- REWARDS I N D I V I D U A I S --------- premio_por_vezes = 1, -- Premio por vezes de conquista de castelo. (1) = Ativo (0) = Desativa. premio_vezes = 3, -- Caso ativo, a quantidade de conquista que o player tem, para ganhar PREMIO. premio = 10522, -- ID do Premio premio_cont = 1, -- Quantidade do Premio premio_reset = 1, -- Resetar o contador do premio depois que atingir a meta?? (1) = SIM (0) = NAO resetReward = {6, "day"} -- Tempo para resetar a storage e receber novamente a recompensa } -- Para deixar mais organizado, jogar essas funções em LIB (se jogar em LIB, remover o local na frente de function) -- Custom Functions (inicio) local function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end local function getTimeString(self) local format = { {'dia', self / 60 / 60 / 24}, {'hora', self / 60 / 60 % 24}, {'minuto', self / 60 % 60}, {'segundo', self % 60} } local out = {} for k, t in ipairs(format) do local v = math.floor(t[2]) if(v > 0) then table.insert(out, (k < #format and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or '')) end end local ret = table.concat(out) if ret:len() < 16 and ret:find('segundo') then local a, b = ret:find(' e ') ret = ret:sub(b+1) end return ret end -- Custom Functions (fim) function onUse(cid, item, frompos, item2, topos) local sto_ativ, position = getGlobalStorageValue(config.storages[2]), getCreaturePosition(cid) if (isPlayerGuild(cid) == true) then if (sto_ativ == 1 or sto_ativ == -1) then guildname = getPlayerGuildName(cid) guild = getPlayerGuildId(cid) guild_sto = getGlobalStorageValue(config.storages[3]) if (guild ~= guild_sto) then setPlayerStorageValue(cid, guild_sto, guild) if (getPlayerStorageValue(cid, config.storages[1]) == -1) then setPlayerStorageValue(cid, config.storages[1], 0) end setGlobalStorageValue(config.storages[3], getPlayerGuildId(cid)) setPlayerStorageValue(cid,config.storages[1], getPlayerStorageValue(cid, config.storages[1]) + 1) sto_vezes_total = getPlayerStorageValue(cid, config.storages[1]) doBroadcastMessage("O(a) "..getCreatureName(cid).." acabou de conquistar o ".. config.castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) doRemoveItem(item.uid, 1) if (config.premio_por_vezes == 1) then if (getPlayerStorageValue(cid, config.storages[4]) - os.time() > 0) then doPlayerSendTextMessage(cid, 18, "Voce deve aguardar ".. getTimeString(getPlayerStorageValue(cid, config.storages[4]) - os.time()) .." para receber a recompensa novamente.") return true end if (getPlayerStorageValue(cid, config.storages[1]) == config.premio_vezes) then if (getItemWeightById(config.premio, 1) <= getPlayerFreeCap(cid)) then doBroadcastMessage("O ".. getCreatureName(cid) .." ganhou uma(o) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!", 21) doPlayerAddItem(cid, config.premio, config.premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!") if config.premio_reset == 1 then setPlayerStorageValue(cid,config.storages[1], 0) end setPlayerStorageValue(cid, config.storages[4], os.time() + mathtime(config.resetReward)) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para ganhar o item. Vamos verificar novamente em 10 segundos!") addEvent(additem, 10000, cid, config.premio, config.premio_cont, config.premio_reset) end end end else doBroadcastMessage("O(a) ".. getCreatureName(cid) .." acabou de conquistar o ".. config.castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) end else doPlayerSendCancel(cid, "O sistema está desativado") end else doPlayerSendCancel(cid, "É nescessario ter guild para dominar o castelo!") doSendMagicEffect(position, 2) end end function additem(cid, config.premio, config.premio_cont, config.premio_reset) if (not isPlayer(cid)) then stopEvent(additem) return true end if (getItemWeightById(config.premio, 1) <= getPlayerFreeCap(cid)) then doPlayerAddItem(cid, config.premio, config.premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!") if (config.premio_reset == 1) then setPlayerStorageValue(cid, config.storages[1], 0) end setPlayerStorageValue(cid, config.storages[4], os.time() + mathtime(config.resetReward)) stopEvent(additem) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para receber o item. Verificando novamente em 10 segundos!") addEvent(additem, 10000, cid) end end function isPlayerGuild(cid) if (getPlayerGuildName(cid) ~= "") then return true else return false end end
-
xMonkey recebeu reputação de FeeTads em (Resolvido)Adcionar tempo na alavancaBom dia!
timeToAgain = Tempo para entrar novamente
posLever = posição da alavanca
storP = storageValue que adicionei, caso queira mudar, basta trocar
-- Edited by xMonkey local room = { ['start'] = {x=2192, y=2543, z=8}, ['end'] = {x=2213, y=2564, z=8} } local players_pos = { {x=2194, y=2577, z=8, stackpos = 253}, {x=2195, y=2577, z=8, stackpos = 253}, {x=2196, y=2577, z=8, stackpos = 253}, {x=2197, y=2577, z=8, stackpos = 253} } local boss_name = 'Gravelord' local boss = {x=2203, y=2549, z=8} local kick_pos = {x=2195, y=2583, z=8} local new_player_pos = {x=2205, y=2564, z=8} local player = {0, 0, 0, 0} local all_ready = 0 local timeToAgain = {20, "min"} local posLever = {x=00000, y=00000, z=00} local storP = 12281 -- Para deixar mais organizado, jogar essas funções em LIB (se jogar em LIB, remover o local na frente de function) -- Custom Functions (inicio) local function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end local function getTimeString(self) local format = { {'dia', self / 60 / 60 / 24}, {'hora', self / 60 / 60 % 24}, {'minuto', self / 60 % 60}, {'segundo', self % 60} } local out = {} for k, t in ipairs(format) do local v = math.floor(t[2]) if(v > 0) then table.insert(out, (k < #format and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or '')) end end local ret = table.concat(out) if ret:len() < 16 and ret:find('segundo') then local a, b = ret:find(' e ') ret = ret:sub(b+1) end return ret end -- Custom Functions (fim) function onUse(cid, item, fromPosition, itemEx, toPosition) if item.itemid == 1945 then for i = 1, 4 do player[i] = getThingfromPos(players_pos[i]) if player[i].itemid > 0 and isPlayer(player[i].uid) then if (getPlayerStorageValue(player[i].uid, storP) - os.time() > 0) then doCreatureSay(cid, "O jogador ".. getPlayerName(player[i].uid) .." deve aguardar ".. getTimeString(getPlayerStorageValue(player[i].uid, storP) - os.time()) .." para fazer novamente.", TALKTYPE_ORANGE_1, false, 0, posLever) return true end all_ready = 1 end end if all_ready == 1 then doCreateMonster(boss_name, {x=boss.x, y=boss.y, z=boss.z}) for i = 1, 4 do if isPlayer(player[i].uid) then doSendMagicEffect(players_pos[i], 2) doTeleportThing(player[i].uid, new_player_pos, false) doSendMagicEffect(new_player_pos, 10) setPlayerStorageValue(player[i].uid, storP, os.time() + mathtime(timeToAgain)) addEvent(kickFromArea, (10 * 60 * 1000), player[i].uid, room['start'], room['end'], kick_pos) all_ready = 0 end end doTransformItem(item.uid, 1946) end elseif item.itemid == 1946 then local player_room = 0 for x = room['start'].x, room['end'].x do for y = room['start'].y, room['end'].y do for z = room['start'].z, room['end'].z do local pos = {x=x, y=y, z=z, stackpos=253} local thing = getThingfromPos(pos) if thing.itemid > 0 then if isPlayer(thing.uid) == true then player_room = player_room + 1 end end end end end if player_room >= 1 then doPlayerSendTextMessage(cid, 19, "There is already a player in the boss room.") elseif player_room == 0 then for x = room['start'].x, room['end'].x do for y = room['start'].y, room['end'].y do for z = room['start'].z, room['end'].z do local pos = {x=x, y=y, z=z, stackpos=253} local thing = getThingfromPos(pos) if thing.itemid > 0 then doRemoveCreature(thing.uid) end end end end player_room = 0 doTransformItem(item.uid, 1945) end end return true end
-
xMonkey recebeu reputação de FeeTads em (Resolvido)[ERROR] onThink no consoleBoa tarde, @megatibiano!
Realmente, sua SRC não possui a função getPlayersOnline(), que é um tanto quanto estranho.
Porém, analizando um pouco mais o seu luascript.h, tem um outro jeito
Sua SRC possui getWorldCreatures() e getWorldCreaturesCount()
A função funciona da seguinte forma:
getWorldCreatures(0) = players
getWorldCreatures(1) = monsters
getWorldCreatures(2) = npcs
getWorldCreatures(3) = todos acima (all)
A partir disso, modifiquei seu script.
Teste o script abaixo:
-- Edited by xMonkey local config = { lottery_hour = "2 hours", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message) rewards_id = {2494, 2472, 2514, 2160}, -- ID dos Itens Sorteados na Loteria crystal_counts = 10, -- Usado somente se a rewards_id for crystal coin (ID: 2160). website = "yes", -- Only if you have php scripts and table `lottery` in your database! days = { "Monday-08:00", "Monday-13:00", "Monday-19:30", "Tuesday-08:00", "Tuesday-13:00", "Tuesday-19:30", "Wednesday-08:00", "Wednesday-13:00", "Wednesday-19:30", "Thursday-08:00", "Thursday-13:00", "Thursday-19:30", "Friday-01:22", "Friday-13:00", "Friday-18:15", "Saturday-21:27", "Saturday-21:28", "Saturday-21:29", "Sunday-08:00", "Sunday-13:00", "Sunday-19:30" } } -- Custom Function (inicio) local function getPlayerWorldId(cid) if not(isPlayer(cid)) then return false end local pid = getPlayerGUID(cid) local worldPlayer = 0 local result_plr = db.getResult("SELECT * FROM `players` WHERE `id` = "..pid..";") if(result_plr:getID() ~= -1) then worldPlayer = tonumber(result_plr:getDataInt("world_id")) result_plr:free() return worldPlayer end return false end local function getOnlineParticipants() local players = {} for _, pid in pairs(getWorldCreatures(0)) do if getPlayerAccess(pid) <= 2 and getPlayerStorageValue(pid, 281821) <= os.time() then table.insert(players, pid) end end if #players > 0 then return players end return false end -- Custom Function (fim) function onThink(cid, interval) if table.find(config.days, os.date("%A-%H:%M")) then if(getWorldCreatures(0) <= 0)then return true end local query = db.query or db.executeQuery local random_item = config.rewards_id[math.random(1, #config.rewards_id)] local item_name = getItemNameById(random_item) local data = os.date("%d/%m/%Y - %H:%M:%S") local online = getOnlineParticipants() if online then local winner = online[math.random(1, #online)] local world = tonumber(getPlayerWorldId(winner)) if(random_item == 2160) then doPlayerSetStorageValue(winner, 281821, os.time() + 3600 * 24) doPlayerAddItem(winner, random_item, config.crystal_counts) doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. config.crystal_counts .." " .. getItemNameById(random_item) .. "s! Congratulations! (Next lottery in " .. config.lottery_hour .. ")") else doPlayerSetStorageValue(winner, 281821, os.time() + 3600 * 24) doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " ..getItemNameById(random_item) .. "! Congratulations! (Next lottery in " .. config.lottery_hour .. ")") doPlayerAddItem(winner, random_item, 1) end if(config.website == "yes") then query("INSERT INTO `lottery` (`name`, `item`, `world_id`, `item_name`, `date`) VALUES ('".. getCreatureName(winner).."', '".. random_item .."', '".. world .."', '".. item_name .."', '".. data .."');") end else print("Ninguem OnLine pra ganhar na loteria") end end return true end
OBS: Caso não funcione, por favor, poste seu luascript.cpp para que eu possa analizar como funciona a função em sua SRC
-
xMonkey recebeu reputação de So volto tarde em adicionando tempo a storageOlá @Carlinhous1996, boa noite!
Você não explicou exatamente quais storages gostaria de adicionar o tempo.
Ao meu ver, seria para receber a recompensa?
Fiz as modificações para só receber as recompensas caso a Storage tenha resetado, após 6 dias.
Também fiz uma pequena organização ao código.
-- Created by pc98 -- Edited by xMonkey local config = { castle_one_name = "Castle", -- Nome do castelo 1 storages = {154154,54321,123123, 123124}, -- Storages ( se vc eh iniciante, deixe como está...) -- REWARDS I N D I V I D U A I S --------- premio_por_vezes = 1, -- Premio por vezes de conquista de castelo. (1) = Ativo (0) = Desativa. premio_vezes = 3, -- Caso ativo, a quantidade de conquista que o player tem, para ganhar PREMIO. premio = 10522, -- ID do Premio premio_cont = 1, -- Quantidade do Premio premio_reset = 1, -- Resetar o contador do premio depois que atingir a meta?? (1) = SIM (0) = NAO resetReward = {6, "day"} -- Tempo para resetar a storage e receber novamente a recompensa } -- Para deixar mais organizado, jogar essas funções em LIB (se jogar em LIB, remover o local na frente de function) -- Custom Functions (inicio) local function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end local function getTimeString(self) local format = { {'dia', self / 60 / 60 / 24}, {'hora', self / 60 / 60 % 24}, {'minuto', self / 60 % 60}, {'segundo', self % 60} } local out = {} for k, t in ipairs(format) do local v = math.floor(t[2]) if(v > 0) then table.insert(out, (k < #format and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or '')) end end local ret = table.concat(out) if ret:len() < 16 and ret:find('segundo') then local a, b = ret:find(' e ') ret = ret:sub(b+1) end return ret end -- Custom Functions (fim) function onUse(cid, item, frompos, item2, topos) local sto_ativ, position = getGlobalStorageValue(config.storages[2]), getCreaturePosition(cid) if (isPlayerGuild(cid) == true) then if (sto_ativ == 1 or sto_ativ == -1) then guildname = getPlayerGuildName(cid) guild = getPlayerGuildId(cid) guild_sto = getGlobalStorageValue(config.storages[3]) if (guild ~= guild_sto) then setPlayerStorageValue(cid, guild_sto, guild) if (getPlayerStorageValue(cid, config.storages[1]) == -1) then setPlayerStorageValue(cid, config.storages[1], 0) end setGlobalStorageValue(config.storages[3], getPlayerGuildId(cid)) setPlayerStorageValue(cid,config.storages[1], getPlayerStorageValue(cid, config.storages[1]) + 1) sto_vezes_total = getPlayerStorageValue(cid, config.storages[1]) doBroadcastMessage("O(a) "..getCreatureName(cid).." acabou de conquistar o ".. config.castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) doRemoveItem(item.uid, 1) if (config.premio_por_vezes == 1) then if (getPlayerStorageValue(cid, config.storages[4]) - os.time() > 0) then doPlayerSendTextMessage(cid, 18, "Voce deve aguardar ".. getTimeString(getPlayerStorageValue(cid, config.storages[4]) - os.time()) .." para receber a recompensa novamente.") return true end if (getPlayerStorageValue(cid, config.storages[1]) == config.premio_vezes) then if (getItemWeightById(config.premio, 1) <= getPlayerFreeCap(cid)) then doBroadcastMessage("O ".. getCreatureName(cid) .." ganhou uma(o) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!", 21) doPlayerAddItem(cid, config.premio, config.premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!") if config.premio_reset == 1 then setPlayerStorageValue(cid,config.storages[1], 0) end setPlayerStorageValue(cid, config.storages[4], os.time() + mathtime(config.resetReward)) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para ganhar o item. Vamos verificar novamente em 10 segundos!") addEvent(additem, 10000, cid, config.premio, config.premio_cont, config.premio_reset) end end end else doBroadcastMessage("O(a) ".. getCreatureName(cid) .." acabou de conquistar o ".. config.castle_one_name .." para a guild \"".. guildname .."\" pela ".. sto_vezes_total .."ª vez(s).", 22) doSendMagicEffect(position, 39) end else doPlayerSendCancel(cid, "O sistema está desativado") end else doPlayerSendCancel(cid, "É nescessario ter guild para dominar o castelo!") doSendMagicEffect(position, 2) end end function additem(cid, config.premio, config.premio_cont, config.premio_reset) if (not isPlayer(cid)) then stopEvent(additem) return true end if (getItemWeightById(config.premio, 1) <= getPlayerFreeCap(cid)) then doPlayerAddItem(cid, config.premio, config.premio_cont) doPlayerSendTextMessage(cid, 18, "Voce recebeu o(a) ".. getItemNameById(config.premio) .." como recompensa das suas ".. config.premio_vezes .." conquistas!") if (config.premio_reset == 1) then setPlayerStorageValue(cid, config.storages[1], 0) end setPlayerStorageValue(cid, config.storages[4], os.time() + mathtime(config.resetReward)) stopEvent(additem) else doPlayerSendTextMessage(cid, 18, "Voce nao tem capacidade para receber o item. Verificando novamente em 10 segundos!") addEvent(additem, 10000, cid) end end function isPlayerGuild(cid) if (getPlayerGuildName(cid) ~= "") then return true else return false end end
-
xMonkey recebeu reputação de FeeTads em (Resolvido)[Resolvido] existe função pra checar se algum item é ring ou colar?Boa tarde, @FeeTads!
Não estou entendendo muito bem como você gostaria de utilizar a função no script.
Pelo seu último tópico, ví que seria um sistema de upgrade?
Você não precisa fazer o script checar todo o item.xml apenas para saber se o item que você quer é ou não um RING ou NECKLACE.
Tente usar a função abaixo:
-- By: xMonkey local itemInfo = getItemInfo(itemEx.itemid) if(itemInfo.slotPosition == CONST_SLOT_RING) or (itemInfo.slotPosition == CONST_SLOT_NECKLACE) then ... retorna oq vc quer fazer se for ring ou necklace ... end
A função acima checa se o item pertence a determinado slot
OBS: Coloquei itemEx.itemid, caso seja o contrário, basta modificar para item.itemid
-
xMonkey recebeu reputação de So volto tarde em (Resolvido)Adcionar tempo na alavancaBom dia!
timeToAgain = Tempo para entrar novamente
posLever = posição da alavanca
storP = storageValue que adicionei, caso queira mudar, basta trocar
-- Edited by xMonkey local room = { ['start'] = {x=2192, y=2543, z=8}, ['end'] = {x=2213, y=2564, z=8} } local players_pos = { {x=2194, y=2577, z=8, stackpos = 253}, {x=2195, y=2577, z=8, stackpos = 253}, {x=2196, y=2577, z=8, stackpos = 253}, {x=2197, y=2577, z=8, stackpos = 253} } local boss_name = 'Gravelord' local boss = {x=2203, y=2549, z=8} local kick_pos = {x=2195, y=2583, z=8} local new_player_pos = {x=2205, y=2564, z=8} local player = {0, 0, 0, 0} local all_ready = 0 local timeToAgain = {20, "min"} local posLever = {x=00000, y=00000, z=00} local storP = 12281 -- Para deixar mais organizado, jogar essas funções em LIB (se jogar em LIB, remover o local na frente de function) -- Custom Functions (inicio) local function mathtime(table) -- by dwarfer local unit = {"sec", "min", "hour", "day"} for i, v in pairs(unit) do if v == table[2] then return table[1]*(60^(v == unit[4] and 2 or i-1))*(v == unit[4] and 24 or 1) end end return error("Bad declaration in mathtime function.") end local function getTimeString(self) local format = { {'dia', self / 60 / 60 / 24}, {'hora', self / 60 / 60 % 24}, {'minuto', self / 60 % 60}, {'segundo', self % 60} } local out = {} for k, t in ipairs(format) do local v = math.floor(t[2]) if(v > 0) then table.insert(out, (k < #format and (#out > 0 and ', ' or '') or ' e ') .. v .. ' ' .. t[1] .. (v ~= 1 and 's' or '')) end end local ret = table.concat(out) if ret:len() < 16 and ret:find('segundo') then local a, b = ret:find(' e ') ret = ret:sub(b+1) end return ret end -- Custom Functions (fim) function onUse(cid, item, fromPosition, itemEx, toPosition) if item.itemid == 1945 then for i = 1, 4 do player[i] = getThingfromPos(players_pos[i]) if player[i].itemid > 0 and isPlayer(player[i].uid) then if (getPlayerStorageValue(player[i].uid, storP) - os.time() > 0) then doCreatureSay(cid, "O jogador ".. getPlayerName(player[i].uid) .." deve aguardar ".. getTimeString(getPlayerStorageValue(player[i].uid, storP) - os.time()) .." para fazer novamente.", TALKTYPE_ORANGE_1, false, 0, posLever) return true end all_ready = 1 end end if all_ready == 1 then doCreateMonster(boss_name, {x=boss.x, y=boss.y, z=boss.z}) for i = 1, 4 do if isPlayer(player[i].uid) then doSendMagicEffect(players_pos[i], 2) doTeleportThing(player[i].uid, new_player_pos, false) doSendMagicEffect(new_player_pos, 10) setPlayerStorageValue(player[i].uid, storP, os.time() + mathtime(timeToAgain)) addEvent(kickFromArea, (10 * 60 * 1000), player[i].uid, room['start'], room['end'], kick_pos) all_ready = 0 end end doTransformItem(item.uid, 1946) end elseif item.itemid == 1946 then local player_room = 0 for x = room['start'].x, room['end'].x do for y = room['start'].y, room['end'].y do for z = room['start'].z, room['end'].z do local pos = {x=x, y=y, z=z, stackpos=253} local thing = getThingfromPos(pos) if thing.itemid > 0 then if isPlayer(thing.uid) == true then player_room = player_room + 1 end end end end end if player_room >= 1 then doPlayerSendTextMessage(cid, 19, "There is already a player in the boss room.") elseif player_room == 0 then for x = room['start'].x, room['end'].x do for y = room['start'].y, room['end'].y do for z = room['start'].z, room['end'].z do local pos = {x=x, y=y, z=z, stackpos=253} local thing = getThingfromPos(pos) if thing.itemid > 0 then doRemoveCreature(thing.uid) end end end end player_room = 0 doTransformItem(item.uid, 1945) end end return true end