Lottery System
Explicação:
Lottery System é um Sistema que Todos os Players que Estiverem Online no Seu OtServer Poderam Ganhar.
O Script Sortea algum Player Online, e Sorteia o Item que o Player Ganhará é claro que ele sorteia so os items que voce escolheu no Script, ele esta arrumado para o evento acontecer em 3 a 3 horas é so arruma na tag o 10800 que no Caso é 3 Horas.
Versoes Testadas:
TFS> 0.3.4, 0.3.5 e 0.3.6 Forao Testadas!
8.50 :button_ok:
8.52 :button_ok:
8.54 :button_ok:
8.60 :button_ok:
Script Em Mods:
Vá em Data>Mods crie uma pasta.xml chamada lottery e coloque isto dentro dela:
<mod name="Lottery System" version="1.4" author="vDk" contact="zlom290@gmail.com" 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) 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>
Feche e Salve!
Script Em Arquivos.lua:
Se seu OtServer nao Tiver a Pasta Mods, Voce podera colocar normalmente em pastas.lua!!
Vá em Data>Globalevents.xml abra-lo e Adicione esta Tag:
<globalevent name="lottery" interval="10800" event="script" value="lottery.lua"/>
Agora vá em Data>GlobalEvents>Scripts crie uma pasta.lua chamada lottery e coloque isto:
-- by vDk 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) 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
Feche e Salve Tudo!
Para Sites.php e MySql:
Bom Se voce Tem um Site e Quiser adicionar este Script nele, para Anunciar no Seu site quem Ganhou a Loteria entao Siga essas Etapas.
(Nao Sei mecher Muinto Nisso.)
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!<br/> Last Winner: <a href="?subtopic=characters&name='.urlencode($result['name']).'">'.$result['name'].'</a> Item: <i>'.$result['item'].'</i> Congratulations!</center>'; } ?>
Abra o Index.Php e Adicione Isto:
case "lottery"; $topic = "Lottery System"; $subtopic = "lottery"; include("lottery.php"); break;
e Por Ultimo na DateBase, Crie uma e Coloque:
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');
Feche e Salve Tudo, e Esta Pronto.
Creditos:
Criador do Script = Vdk 100%
Criador do Topico = DevilMoon
Abraços..