bem desenvolvido seu código, ta melhor que aquele outro que já vem com os servidores.
Parabéns, ainda bem que vc ta de ferias e pode ficar postando mais conteúdo! rsrsrs
abraços!
info
Grupo: Herói
Registrado: 20/05/10
Posts: 3.4k
Reputação: +1.5k
Gênero: Masculino

bem desenvolvido seu código, ta melhor que aquele outro que já vem com os servidores.
Parabéns, ainda bem que vc ta de ferias e pode ficar postando mais conteúdo! rsrsrs
abraços!
Parabéns cara, muito bom script. Realmente os que já vinham em alguns servidores estavam ultrapassados.
info
Grupo: Visconde
Registrado: 12/09/10
Posts: 416
Reputação: +160
Char no Tibia: Draky Lucas

parabens cara... a ideia foi boa (do cara que fez o pedido) e você soube aplicar lua muito bem sobre a ideia ^^
ficou mt bom.. rep+
VÍDEO
info
Grupo: Infante
Registrado: 13/10/08
Posts: 1.6k
Reputação: +420
Char no Tibia: Demonbholder

os storages tem um número limitado de caracteres que eles podem suportar.
guardando todos os nomes esse número se esgotaria rapidamente, não?
Arrumei um pequeno bug no sistema na parte do comando /vote.
Editado Julho 14 por Oneshot
Gostei bastante do script e deixei nos favoritos para adicionar ele futuramente.
Só uma pequena observação: Enquete, traduzido para o inglês, fica "poll" e não "pool".
Do jeito que você escreveu tá significando Sistema de Piscina Avançado, ou algo do tipo.
Só uma pequena observação, espero que não me entenda mal.
Parabéns pelos ótimos scripts e por ajudar a comunidade XTibiana, continue assim com seus excelentes trabalhos.
info
Grupo: Campones
Registrado: 13/06/12
Posts: 30
Reputação: +1
Char no Tibia: Lek Chegado

cara eu testei aki no meu ot e fiko mto bom!!
P.S concordando com o XDDDDDDDDDD, vc precisa de uma aulinha de ingreis(kkk)antes de dar nome pra sistemas em ingles. pq olha o poder das letras:
Pool = Piscina(BR) Poll = Votação(BR), eu vim pro post pq eu pensei q era script de piscina, msm assim gostei mto do script mais poderia escrever POLL ao inves de POOL? Rainha Elizabeth ia fikar decepcionada vendo isso oO
FMZ!
Editado Agosto 6 por Comet2
Olá,
Falha nossa, sempre fui um péssimo aluno de inglês. Obrigado mesmo pelo aviso.
E Comet2, você precisa de uma "aulinha" de português (kkk).
Valeu aí, colega.
Abraços.
info
Grupo: Artesão
Registrado: 01/03/20
Posts: 110
Reputação: +1
Gênero: Masculino
Char no Tibia: Samuel on Issobra

Eu usei esses comandos e nenhum funciono...
<talkaction log="yes" words="/newpoll;/endpoll" access="5" event="script" value="pollsystem.lua"/> <talkaction words="/vote;/poll" event="script" value="pollsystem.lua"/>
/poll
[13/03/2024 19:59:33] [Error - TalkAction Interface] [13/03/2024 19:59:33] data/talkactions/scripts/pollsystem.lua:onSay [13/03/2024 19:59:33] Description: [13/03/2024 19:59:33] data/talkactions/scripts/pollsystem.lua:86: attempt to call field 'unserialize' (a nil value) [13/03/2024 19:59:33] stack traceback: [13/03/2024 19:59:33] data/talkactions/scripts/pollsystem.lua:86: in function <data/talkactions/scripts/pollsystem.lua:27>
/endpoll
[13/03/2024 19:54:26] [Error - TalkAction Interface] [13/03/2024 19:54:26] data/talkactions/scripts/pollsystem.lua:onSay [13/03/2024 19:54:26] Description: [13/03/2024 19:54:26] data/talkactions/scripts/pollsystem.lua:15: attempt to call field 'unserialize' (a nil value) [13/03/2024 19:54:26] stack traceback: [13/03/2024 19:54:26] data/talkactions/scripts/pollsystem.lua:15: in function 'getMostVotedOption' [13/03/2024 19:54:26] data/talkactions/scripts/pollsystem.lua:103: in function <data/talkactions/scripts/pollsystem.lua:27>
/vote
[13/03/2024 19:56:24] [Error - TalkAction Interface] [13/03/2024 19:56:24] data/talkactions/scripts/pollsystem.lua:onSay [13/03/2024 19:56:24] Description: [13/03/2024 19:56:24] data/talkactions/scripts/pollsystem.lua:61: attempt to call field 'unserialize' (a nil value) [13/03/2024 19:56:24] stack traceback: [13/03/2024 19:56:24] data/talkactions/scripts/pollsystem.lua:61: in function <data/talkactions/scripts/pollsystem.lua:27>
info
Grupo: Artesão
Registrado: 01/03/20
Posts: 110
Reputação: +1
Gênero: Masculino
Char no Tibia: Samuel on Issobra

EU CVOLOQUEI TABLE
NA LIB12 POREM NAO TA FUNCIONANDO IGUAL O VIDEO.
function table.unserialize(str)
if type(str) ~= 'string' or str:len() == 0 then
return {}
end
local chunk, err = load("return " .. str, "unserialize", "t", {})
if not chunk then
return nil, err
end
return chunk()
end
info
Grupo: Marquês
Registrado: 05/07/09
Posts: 1.3k
Reputação: +732
Nome: Advanced Poll System
Tipo: Talkaction
Autor: Oneshot
Fala, meus queridos.
Peregrinando pela seção de Pedidos e Dúvidas, vi um pedido do membro sarioyana que despertou minha vontade de programar sistemas um pouco mais elaborados.
O pedido dele se trata de um sistema de votação, onde o responsável pelo servidor pode iniciar uma votação com quantas opções desejar.
Fiz algo bem simples, você só precisa configurar os storages no ínicio do script, caso você já esteja usando os que estão por padrão.
Abra seu arquivo talkactions.xml e adicione isso:
Crie um novo arquivo chamado pollsystem.lua em data/talkactions/scripts e adicione isso:
local POLL_STORAGE = 80000 local OPTIONS_STORAGE = 80001 local PLAYER_STORAGE = 80000 local function getTotalVotes() local options = table.unserialize(getStorage(OPTIONS_STORAGE)) local amount = 0 for _, option in ipairs(options) do amount = amount + option[2] end return amount end local function getMostVotedOption() local options = table.unserialize(getStorage(OPTIONS_STORAGE)) local value, ret = 0 for _, option in ipairs(options) do if option[2] > value then value = option[2] ret = option[1] end end return ret end function onSay(cid, words, param, channel) param = param or "" if param == "" and not words == "/poll" then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The command ".. words .." need parameters.") end local parameters, vote = {} if(words == "/newpoll") then if getStorage(POLL_STORAGE) ~= -1 then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, but there is a poll in progress.\nIf you want to start a new poll, type /endpoll.") end parameters = string.explode(param, ",") if #parameters < 3 then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "The command /newpoll needs a poll and at least two options.") end if parameters[1] then local options = {} for i = 2, #parameters do table.insert(options, {parameters[i], 0}) end if #options < 2 then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Insert at least two options after the poll") end doSetStorage(POLL_STORAGE, parameters[1]) options = table.serialize(options) doSetStorage(OPTIONS_STORAGE, options) doBroadcastMessage("A new poll is in progress with the title '".. getStorage(POLL_STORAGE) .."?'!\nSee the status with /poll and vote with /vote.") end elseif(words == "/vote") then vote = tonumber(param) or -1 local options = table.unserialize(getStorage(OPTIONS_STORAGE)) if getStorage(POLL_STORAGE) == -1 then return doPlayerSendCancel(cid, "There is not a poll in progress.") end if vote == -1 then return doPlayerSendCancel(cid, "You need to choose a option to vote.") end if getCreatureStorage(cid, PLAYER_STORAGE) == 1 then print(getCreatureStorage(cid, PLAYER_STORAGE)) return doPlayerSendCancel(cid, "You cannot vote two times.") end if vote > #options then return doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE) end options[vote][2] = options[vote][2] + 1 doSetStorage(OPTIONS_STORAGE, table.serialize(options)) doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You have voted in the option ".. options[vote][1] .." successfully!") doCreatureSetStorage(cid, PLAYER_STORAGE, 1) elseif(words == "/poll") then local options = table.unserialize(getStorage(OPTIONS_STORAGE)) if getStorage(POLL_STORAGE) == -1 then return doPlayerSendCancel(cid, "There is not a poll in progress.") end local text = "ADVANCED poll SYSTEM\n\n".. getStorage(POLL_STORAGE) .."?\n" local count = 1 for _, option in ipairs(options) do text = text .."\n#".. count .." ".. option[1] .." ".. (getTotalVotes() == 0 and 0 or math.floor((option[2]/getTotalVotes()) * 100)) .."%\n" count = count + 1 end doPlayerPopupFYI(cid, text) elseif(words == "/endpoll") then if getStorage(POLL_STORAGE) == -1 then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "There is not a poll to be ended.") end if not getMostVotedOption() then return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Wait at least one vote to end this poll.") end doBroadcastMessage("The poll '".. getStorage(POLL_STORAGE) .."?' has been finished!\nThe most voted option was ".. getMostVotedOption() ..".") doSetStorage(POLL_STORAGE, -1) doSetStorage(OPTIONS_STORAGE, -1) for _, player in ipairs(getPlayersOnline()) do doCreatureSetStorage(player, PLAYER_STORAGE, -1) end db.executeQuery("UPDATE `player_storage` SET value = -1 WHERE `key` = ".. PLAYER_STORAGE ..";") end return true endE pronto, o sistema está instalado. Basta agora no jogo com um GOD digitar:
E para finalizar a enquete
Jogadores podem usar os comandos abaixo para visualizar o estado da enquete e votar, respectivamente.
O comando /vote deve ser seguido do número da opção que aparece no comando /poll
Irei postar em breve um vídeo, fiquem ligados.
Um grande abraço.
Editado Agosto 9 por Oneshot