Olá, Vou Ensiar hoje como por Loteria Sytem no seu server
Para TFS 0.3.5 (MOD)
1º:Vai em Mods na Pasta do seu ot e Crie um Aquivo Chamado "lottery.xml" (Sem Aspas)
e Adicone 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 Va em data/globalevents e Adicione "lottery.lua" e dentro dela Adicione :
function onThink(cid, interval, lastExecution)
local config = {
hours = 4,
items = {{2472,1},{2160,10},{2494,1},{2514,1}}
}
local on,list = getPlayersOnline(),{}
if #on > 0 then
for i = 1, #on do
if getPlayerAccess(on[i]) < 3 and getCreatureName(on[i]) ~= "Account Manager" then
table.insert(list, on[i])
end
end
if #list > 0 then
local p,r = list[math.random(#list)],config.items[math.random(#config.items)]
doPlayerAddItem(p, r[1], r[2] or 1)
doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(p) .. ", Reward: "..r[2].." "..getItemNameById(r[1]).."! Congratulations! (Next Lottery in "..config.hours.." hours)")
end
end
return true
end
3º: Agora Va em data/globalevents/globalevents.xml e Adicione:
<globalevent name="lottery" interval="10800" event="script" value="lottery.lua"/>
Pronto....
Agora se Quer Adicionar o Sistema de Loteria no Site e 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!<br/>
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');
Pronto Sua Loteria ja esta adc no seu Site Bom Proveito