Postado Fevereiro 27, 2012 13 anos Este é um post popular. post_pattern = { author = "Maxwell Denisson(MaXwEllDeN)", developed_in = "The Forgotten Server 0.3.6", code_version = 1.0 } Introdução Com esse sistema, você pode criar enquetes no seu servidor, para saber a opniao de seus players. Instalação Abra a pasta creatureevents, dentro da pasta scripts copie qualquer arquivo com extenção .lua, renomeie para PollMaX, abra com algum editor de texto, apague tudo que tiver dentro e cole o seguinte conteúdo: --[[ Poll System Author: Maxwell Denisson(MaXwEllDeN) Version: 1.0 ]] local POLL = _POLL_SYS function onLogin(cid) if (POLL.on) then local PVotes = string.explode(POLL.func.playerGetVotes (cid), ", ") for _, a in pairs(PVotes) do if not (POLL.func.hasPoll(a)) then POLL.func.removePlayerVote(cid, a) end end local kyz = 0 local polls = {} local msgeX = "MaX Poll System:\nParticipe de nossa(s) enquete(s) -> " for _, a in pairs(POLL.func.getPolls()) do kyz = 1 table.insert(polls, a[1]) msgeX = msgeX .. a[1] .. ", " end if (kyz ~= 0) then doPlayerSendTextMessage(cid, 27, msgeX:sub(1, #msgeX-2)) end end return true end Abra a pasta lib na sua pasta data, copie qualquer arquivo com extenção .lua, renomeie para PollMaX, abra com algum editor de texto, apague tudo que tiver dentro e cole o seguinte conteúdo: --[[ Poll System Author: Maxwell Denisson(MaXwEllDeN) Version: 1.0 ]] _POLL_SYS = { func = {}, VotdSto = 42873, on = true } local InStalled = false function printTableSI(aff) -- BETA ~ By MaXwEllDeN local s = "{" for a, b in pairs(aff) do local index = "[".. a .. "]" if (type(a) == "string") then index = '["'.. a ..'"]' end if (type(b) == "table") then value = printTableSI(b) elseif (type(b) == "string") then value = '"'.. b .. '"' else value = b end s = s .. index .. " = " .. value .. ", " end s = "{" .. s:sub(2, #s) return (#s < 3) and "{}" or (s:sub(1, #s-2) .. "}") end _POLL_SYS.func.install = function () return (db.getResult("ALTER TABLE `server_config` ADD COLUMN `polls` VARCHAR( 255 ) NOT NULL DEFAULT ('{}');")) and true or false end _POLL_SYS.func.getPolls = function () local get = db.getResult("SELECT `polls` FROM `server_config` WHERE `config` = 'db_version';") local resultado = get:getDataString('polls') return (resultado) and loadstring("return " .. resultado)() or nil end _POLL_SYS.func.setPolls = function (newpoll) return (db.getResult("UPDATE `server_config` SET `polls` = '".. newpoll .."' WHERE `config` = `db_version`;")) and true or false end _POLL_SYS.func.addPoll = function (poll, options) local Apoll = _POLL_SYS.func.getPolls() table.insert(Apoll, {poll, options}) return _POLL_SYS.func.setPolls(printTableSI(Apoll)) end _POLL_SYS.func.removePoll = function (poll) local Apoll = _POLL_SYS.func.getPolls() local Npoll = {} for _, b in pairs(Apoll) do if (b[1]:lower() ~= poll:lower()) then table.insert(Npoll, b) end end local Npoll = printTableSI(Npoll) return _POLL_SYS.func.setPolls(Npoll) end _POLL_SYS.func.hasPoll = function (poll) local polls = _POLL_SYS.func.getPolls() for _, b in pairs(polls) do if (b[1]:lower() == poll:lower()) then return true end end return false end _POLL_SYS.func.hasPollOption = function (poll, option) local polls = _POLL_SYS.func.getPolls() for _, b in pairs(polls) do if (b[1]:lower() == poll:lower()) then if (b[2][option:lower()]) then return true end end end return false end _POLL_SYS.func.playerSetVotes = function (player, votes) return setPlayerStorageValue(player, 77734, votes) end _POLL_SYS.func.playerGetVotes = function (player) if (getPlayerStorageValue(player, 77734) == -1) then setPlayerStorageValue(player, 77734, "") end return getPlayerStorageValue(player, 77734) end _POLL_SYS.func.playerAddVote = function (player, poll) return setPlayerStorageValue(player, 77734, getPlayerStorageValue(player, 77734) .. ", ".. poll .. "") end _POLL_SYS.func.hasPlayerVote = function (player, poll) local _, votes = _POLL_SYS.func.playerGetVotes(player):gsub(poll:lower(), "fuu") return (votes > 0) and true or false end _POLL_SYS.func.removePlayerVote = function (player, poll) local _, votes = _POLL_SYS.func.playerGetVotes(player):gsub(poll:lower(), " ") return (votes > 0) and _POLL_SYS.func.playerSetVotes(player, _) or false end _POLL_SYS.func.removeAllPlayersVote = function (poll) for _, cid in pairs(getOnlinePlayers()) do local cid = getPlayerByNameWildcard(cid) _POLL_SYS.func.removePlayerVote(cid, poll) end end _POLL_SYS.func.addVote = function (poll, option, player) local polls = _POLL_SYS.func.getPolls () for _, b in pairs(polls) do if (b[1]:lower() == poll:lower()) then print(UHU) for a, _ in pairs(b[2]) do if (a:lower() == option:lower()) then b[2][a] = _ + 1 _POLL_SYS.func.playerAddVote (player, poll) _POLL_SYS.func.setPolls (printTableSI(polls)) return true end end end end return false end _POLL_SYS.func.getPollHighestValue = function (poll) local value = "" local polls = _POLL_SYS.func.getPolls() for _, a in pairs(polls) do if (a[1]:lower() == poll:lower()) then for b, c in pairs(a[2]) do for _, d in pairs(a[2]) do if (_ ~= b) then if (c > d) then value = b end end end end end end return value end if not(InStalled) then local file = io.open("data/lib/PollSystem.lua", "r") local content = file:read("*all") local content, _ = content:gsub("In".. string.upper("s") .."talled = false", "InStalled = true") file:close() local file = io.open("data/lib/PollSystem.lua", "w+") file:write(content) file:close() return _POLL_SYS.func.install() end Abra a pasta talkactions, dentro da pasta scripts copie qualquer arquivo com extenção .lua, renomeie para PollMaX, abra com algum editor de texto, apague tudo que tiver dentro e cole o seguinte conteúdo: --[[ Poll System Author: Maxwell Denisson(MaXwEllDeN) Version: 1.0 ]] function onSay(cid, words, param) local funcs = {"add", "result", "finalize", "list", "vote"} local POLL = _POLL_SYS if not(POLL.on) then return false end local paramCHECK = param:lower() local param = param:lower() local params = string.explode(param, ";") local param = params[1] local helpE = "Max Poll System Help: \n \n * vote - serve para votar em uma enquete. \n" local helpE = helpE .." Exemplo de uso: " .. words .. " vote; enquete; opção " .. words .. " vote; Quem é o mais gato?; Maxwell\n" local helpE = helpE .."\n * list - lista as enquetes existentes. \n" local helpE = helpE .." Exemplo de uso: " .. words .. " list" if (getPlayerAccess(cid) >= 4) then helpE = helpE .. "\n\n * add - serve para adicionar uma enquete. \n Exemplo de uso: " .. words .. " add; Você votaria no sim?; {'Não', 'Sim'}\n" helpE = helpE .. "\nVocê votaria no sim? é a enquete, o que estiver dentro de {} são as opções, ATENÇÃO: TODAS OPÇÕES DEVEM SER FEITAS DENTRO DE \'\', E SEPARADAS POR VIRGULA!" helpE = helpE .. "\n\n * finalize - serve para finalizar uma enquete. \n Exemplo de uso: ".. words .. " finalize; Você votaria no sim?\n\nVocê votaria no sim é a enquete que você deseja finalizar." end if not(isInArray(funcs, param)) then return doShowTextDialog(cid, 1953, helpE) end if (param == "add") and (getPlayerAccess(cid) >= 4) then if not(params[3]) then return doShowTextDialog(cid, 1953, helpE) end local optionS = loadstring("return " .. params[3]:lower())() if (type(optionS) ~= "table") then return doShowTextDialog(cid, 1953, helpE) end local _, paramCHECK = paramCHECK:gsub(";", "a") if (paramCHECK > 2) then return doPlayerSendTextMessage(cid, 27, "Você não pode usar \";\" nas opções") end if not (optionS[2]) then return doPlayerSendTextMessage(cid, 27, "Sua enquete deve ter no mínimo 2 opções") end local Opt = {} for _, b in pairs(optionS) do Opt[b] = 0 end if (POLL.func.hasPoll(params[2])) then return doPlayerSendTextMessage(cid, 27, "Já existe uma enquete nomeada ".. params[2]) end POLL.func.addPoll(''..params[2]..'', Opt) doPlayerSendTextMessage(cid, 27, "A enquete ".. params[2] .." foi adicionada com as opções: ".. params[3]:lower() ..".") elseif (param == "finalize") and (getPlayerAccess(cid) >= 4) then if not (params[2]) then return doShowTextDialog(cid, 1953, helpE) end if not (POLL.func.hasPoll(params[2])) then return doPlayerSendTextMessage(cid, 27, "Não existe nenhum enquete no banco de dados nomeada ".. params[2] .. "!") end local HValue = POLL.func.getPollHighestValue(params[2]) if (HValue == "") then doBroadcastMessage("A enquete " .. params[2] .. " foi finalizada, sem opções vencedoras!") else doBroadcastMessage("A enquete " .. params[2] .. " foi finalizada, e a opção que recebeu mais votos foi: ".. HValue ..".") end doPlayerSendTextMessage(cid, 27, "A enquete ".. params[2] .." foi finalizada.") POLL.func.removePoll (params[2]) POLL.func.removeAllPlayersVote (params[2]) elseif (param == "list") then local polls = POLL.func.getPolls() local kizizim = 0 mszi = "MaX Poll System:\n\nEnquetes Ativas:\n" local function getPollsOptions(poll) local fukZz = "" for _, b in pairs(polls) do if (b[1] == poll:lower()) then for c, _ in pairs(b[2]) do fukZz = fukZz .. "\n " .. c end return fukZz end end end for a, b in pairs(polls) do kizizim = 1 mszi = mszi .. "\n * ".. b[1] .. getPollsOptions(b[1]) end mszi = mszi .. "\n~-~-~-~-~-~-~-~-~-~-~-~-~-" if (kizizim == 0) then return doPlayerSendTextMessage(cid, 27, "Não existe nenhuma enquete no momento!") end doShowTextDialog(cid, 1953, mszi) elseif (param == "vote") then if not (params[3]) then return doShowTextDialog(cid, 1953, helpE) end if not (POLL.func.hasPoll(params[2])) then return doPlayerSendTextMessage(cid, 27, "Não existe nenhum enquete nomeada \"".. params[2] .. "\"! Para ver a lista das enquetes disponíveis digite: ".. words .. " list") end if (POLL.func.hasPlayerVote(cid, params[2])) then return doPlayerSendTextMessage(cid, 27, "Você já votou nesta enquete.") end if not(POLL.func.hasPollOption(params[2], params[3])) then return doPlayerSendTextMessage(cid, 27, "A enquete ".. params[2] .. " não tem nenhuma opção nomeada ".. params[3] .. "! Para ver a lista das enquetes e suas opções disponíveis digite: ".. words .. " list") end POLL.func.addVote(params[2], params[3], cid) doPlayerSendTextMessage(cid, 27, "Obrigado por participar da enqute ".. params[2] .. ".") elseif (param == "result") then local polls = POLL.func.getPolls() local kizizim = 0 mszi = "MaX Poll System:\n\nResultado das enquetes:\n" local function getPollsOptions(poll) local fukZz = "" for _, b in pairs(polls) do if (b[1] == poll:lower()) then for c, d in pairs(b[2]) do fukZz = fukZz .. "\n " .. c .. " - ".. d .. " voto(s)." end return fukZz end end end for a, b in pairs(polls) do kizizim = 1 mszi = mszi .. "\n * ".. b[1] .. getPollsOptions(b[1]) end mszi = mszi .. "\n~-~-~-~-~-~-~-~-~-~-~-~-~" if (kizizim == 0) then return doPlayerSendTextMessage(cid, 27, "Não existe nenhuma enquete no momento!") end doShowTextDialog(cid, 1953, mszi) end return true end Depois instale as seguintes Tags: #Creatureevents.xml <event type="login" name="PollLogin" event="script" value="PollMax.lua"/> <!-- Poll System By MaXwEllDeN --> #Talkactions.xml <talkaction words="!polls" event="script" value="PollMax.lua"/> <!-- Poll System By MaXwEllDeN --> Condiderações Finais Faz tempo que eu fiz esse sistema, por isso pode conter vários bugs, quem encontrar faça o favor de reportar! Editado Fevereiro 27, 2012 13 anos por MaXwEllDeN (veja o histórico de edições) -"Supra Omnes Lux Lucis" - Acima de todos brilha a Luz -
Postado Fevereiro 27, 2012 13 anos Legal esse script mais com essas enquete ai é fail maxwell é gato ( Não nunca sera jamais ) Reputado System https://www.youtube.com/watch?v=o0PV0qAXufk
Postado Julho 24, 2012 12 anos Autor Legal esse script mais com essas enquete ai é fail maxwell é gato ( Não nunca sera jamais ) Reputado Que Fail o quê rapá! ashduahds vlw! -"Supra Omnes Lux Lucis" - Acima de todos brilha a Luz -
Postado Julho 24, 2012 12 anos ta da hora mesmo cara o lpz tbm tinha feito um sistema de enquete esses dias! outra coisa, to esperando vc disponibilizar o seu private shop system! kkkkkkk já tais uma cara escondendo o sistema '-' decidiu se vai postar ou n? [*Ninguém será digno do sucesso se não usar suas derrotas para conquistá-lo.*] DISCORD: vodkart#6090
Postado Julho 24, 2012 12 anos Autor ta da hora mesmo cara o lpz tbm tinha feito um sistema de enquete esses dias! outra coisa, to esperando vc disponibilizar o seu private shop system! kkkkkkk já tais uma cara escondendo o sistema '-' decidiu se vai postar ou n? Xii mano, nem sei se posto o P.V. ahsduahds -"Supra Omnes Lux Lucis" - Acima de todos brilha a Luz -
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.