Postado Janeiro 9, 2012 13 anos Este é um post popular. Lottery System Olá, hoje vou ensinar como por Lottery System no seu servidor. • autor: guuhtorres/gabreilk • versão do distro:TFS 0.3.5 (MOD) 1º : Vai em Mods na Pasta do seu ot e Crie um Aquivo Chamado "lottery.xml" (Sem Aspas) e Adicione isso dentro dele : <mod name="Lottery System" version="1.5" author="" contact="" enabled="yes"> <config name="lottery_config"><!--[CDATA[ config = { lottery_hour = "3 Hours", -- Time to next lottery (only for broadcast message, real time you can set on globalevents.xml) rewards_id = {2494, 2472, 2514, 2160}, -- Rewards ID crystal_counts = 10, -- Used only if on rewards_id is crystal coin (ID: 2160). website = "yes" -- Only if you have php scripts and table `lottery` in your database! } ]]--></config> <globalevent name="lottery" interval="10800" event="script"><!--[CDATA[ domodlib('lottery_config') function onThink(interval, lastExecution) if(getWorldCreatures(0) == 0)then return true end local list = {} for i, tid in ipairs(getPlayersOnline()) do list[i] = tid end local winner = list[math.random(1, #list)] local random_item = config.rewards_id[math.random(1, #config.rewards_id)] if(random_item == 2160) then 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 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 db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');") end return true end ]]--></globalevent> </mod> 2º: Agora vá em data/globalevents e adicione "lottery.lua" e dentro dela adicione : local config = { lottery_hour = "3 Hours", -- Time to next lottery (only for broadcast message, real time you can set on globalevents.xml) rewards_id = {2494, 2472, 2514, 2160}, -- Rewards ID crystal_counts = 10, -- Used only if on rewards_id is crystal coin (ID: 2160). website = "yes" -- Only if you have php scripts and table `lottery` in your database! } function onThink(interval, lastExecution) if(getWorldCreatures(0) == 0)then return true end local list = {} for i, tid in ipairs(getPlayersOnline()) do list[i] = tid end local winner = list[math.random(1, #list)] local random_item = config.rewards_id[math.random(1, #config.rewards_id)] if(random_item == 2160) then 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 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 db.executeQuery("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');") end return true end 3º: Agora vá em data/globalevents/globalevents.xml e adicione : <globalevent name="lottery" interval="10800" event="script" value="lottery.lua"> Seu sistema de loteria foi adicionado com sucesso em seu server ! Agora se você quiser adicionar o "Lottery System" faça o seguinte : 1º: Crie uma Pasta.php e Coloque o Nome de Lottery (Lottery.Php) e adicione isto: : <!--?PHP $lottery = $SQL--->query('SELECT id, name, item FROM lottery ORDER BY id DESC LIMIT 1;'); foreach($lottery as $result) { $main_content .= '<center><h1>Lottery</h1></center> <center>Every X hours we will choose one player who will win random item! Last Winner: <a href="?subtopic=characters&name='.urlencode($result['name']).'">'.$result['name'].'</a> Item: <i>'.$result['item'].'</i> Congratulations!</center>'; } ?> 2º: Abra o Index.php e Adicione : case "lottery"; $topic = "Lottery System"; $subtopic = "lottery"; include("lottery.php"); break; 3º: DB : CREATE TABLE `lottery` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `item` varchar(255) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; INSERT INTO `lottery`(`id`, `name`, `item`) VALUES (NULL , 'Nobody', 'nothing'); Seu lottery system foi adicionado com sucesso em seu site ! Editado Janeiro 10, 2012 13 anos por GuuhTorres (veja o histórico de edições)
Postado Janeiro 10, 2012 13 anos boa garoto, formate melhor o topico colocando o script entre code ficaria melhor a visualização fora que também evita bugs. fikdik
Postado Janeiro 10, 2012 13 anos Autor Ok,irei arrumar. Muito obrigado pelo comentário e pela dica. -EDIT Editei um pouco o script e as palavras,e acrescentei o "CODE". Espero ter agradado. Obrigado.Att GuuhTorres. Editado Janeiro 10, 2012 13 anos por GuuhTorres (veja o histórico de edições)
Postado Janeiro 24, 2012 13 anos Cara voçe e F@#$ voçe tem futuro continua assim poren to tendo uns problemas me add msn presiso perguntar umas coisas [email protected]
Postado Janeiro 24, 2012 13 anos /\ Que isso calma não solta a franga. legal o system ja vi por ae mas deve ser seu
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.