
Netounico
Membro
-
Registro em
-
Última visita
Histórico de Curtidas
-
Netounico deu reputação a Natanael Beckman em [GlobalEvents] Perfect Lottery System (MySql) - AtualizadoSistema de Loterias por globalevents.
Crie um arquivo .lua com o nome lottery dentro da pasta data/globalevents/scripts/loterry.lua, adicione dentro do arquivo o seguinte code:
local config = { lottery_hour = "2 hours", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message) rewards_id = {2494, 2472, 2514, 2160}, -- ID dos Itens Sorteados na Loteria crystal_counts = 10, -- Usado somente se a rewards_id for crystal coin (ID: 2160). website = "yes", -- Only if you have php scripts and table `lottery` in your database! days = { "Monday-08:00", "Monday-13:00", "Monday-19:30", "Tuesday-08:00", "Tuesday-13:00", "Tuesday-19:30", "Wednesday-08:00", "Wednesday-13:00", "Wednesday-19:30", "Thursday-08:00", "Thursday-13:00", "Thursday-19:30", "Friday-01:22", "Friday-13:00", "Friday-19:30", "Saturday-21:27", "Saturday-21:28", "Saturday-21:29", "Sunday-08:00", "Sunday-13:00", "Sunday-19:30" } } local function getPlayerWorldId(cid) if not(isPlayer(cid)) then return false end local pid = getPlayerGUID(cid) local worldPlayer = 0 local result_plr = db.getResult("SELECT * FROM `players` WHERE `id` = "..pid..";") if(result_plr:getID() ~= -1) then worldPlayer = tonumber(result_plr:getDataInt("world_id")) result_plr:free() return worldPlayer end return false end local function getOnlineParticipants() local players = {} for _, pid in pairs(getPlayersOnline()) do if getPlayerAccess(pid) <= 2 and getPlayerStorageValue(pid, 281821) <= os.time() then table.insert(players, pid) end end if #players > 0 then return players end return false end function onThink(cid, interval) if table.find(config.days, os.date("%A-%H:%M")) then if(getWorldCreatures(o) <= 0)then return true end local query = db.query or db.executeQuery local random_item = config.rewards_id[math.random(1, #config.rewards_id)] local item_name = getItemNameById(random_item) local data = os.date("%d/%m/%Y - %H:%M:%S") local online = getOnlineParticipants() if online then local winner = online[math.random(1, #online)] local world = tonumber(getPlayerWorldId(winner)) if(random_item == 2160) then doPlayerSetStorageValue(winner, 281821, os.time() + 3600 * 24) 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 doPlayerSetStorageValue(winner, 281821, os.time() + 3600 * 24) 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 query("INSERT INTO `lottery` (`name`, `item`, `world_id`, `item_name`, `date`) VALUES ('".. getCreatureName(winner).."', '".. random_item .."', '".. world .."', '".. item_name .."', '".. data .."');") end else print("Ninguem OnLine pra ganhar na loteria") end end return true end Recomendamos modificar: - rewards_id = {2494, 2472, 2514, 2160}, -- ID dos Itens Sorteados na Loteria Recomendo de item count apenas o 2160, outros podem bugar. - crystal_counts = 10, -- Usado somente se a rewards_id for crystal coin (ID: 2160). Altere pra mais ou menos o dinheiro. - "Monday-08:00", Ajuste os dias e horários como desejado. Em globalevents.xml, adicione:
<!-- Lottery --> <globalevent name="lottery" interval="60000" event="script" value="lottery.lua"/> Não mexa no code acima.
Certo, essa é a parte do servidor, agora vamos adicionar as querys necessárias no MySql:
CREATE TABLE `lottery` ( `id` int(11) NOT NULL auto_increment, `name` varchar(255) NOT NULL, `item` varchar(255) NOT NULL, `world_id` tinyint(2) unsigned NOT NULL default '0', `item_name` varchar(255) NOT NULL, `date` varchar(256) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1; Caso você queria adicionar uma query pra testar o site, veja:
INSERT INTO `lottery` (`id`, `name`, `item`, `world_id`, `item_name`, `date`) VALUES(NULL, 'Character', '2470', '0', 'golden legs', '22/05/2014 - 04:49:50'); Agora vamos pra parte do site, crie um arquivo .php com o nome lottery, adicione dentro do arquivo o seguinte code:
<?PHP $main_content .= '<center><h1>Lottery</h1><h3>Lotterys held at 09:00, 14:00 and 20:30 hour, brazil time.</h3></center><br><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><tr BGCOLOR="'.$config['site']['vdarkborder'].'"><td CLASS=white><center><b>Player Name</b></center></td><td CLASS=white width=184 colspan=2><center><b>Winning Item</b></center></td><td width=50 CLASS=white><center><b>World</b></center></td><td width=100 CLASS=white><center><b>Date and Time</b></center></td></tr>'; $lottery = $SQL->query('SELECT id, name, item, world_id, item_name, date FROM lottery WHERE world_id = 0 ORDER BY id DESC;'); foreach($lottery as $result) { $players++; if(is_int($players / 2)) $bgcolor = $config['site']['lightborder']; else $bgcolor = $config['site']['darkborder']; $main_content .= '<TR BGCOLOR='.$bgcolor.'><TD WIDTH=35%><center><a href="?subtopic=characters&name='.urlencode($result['name']).'">'.$result['name'].'</a></center></td><TD WIDTH=5%><img src=\'/item_images/'.urlencode($result['item']).'.gif\'></td><TD WIDTH=30%><center>'.$result['item_name'].'</center></td><TD WIDTH=7%><center>MegaTibia</center></td></td><TD WIDTH=30%><center>'.$result['date'].'</center></td></tr>'; } $main_content .= '</table>'; ?> Em index.php adicione:
case "lottery"; $topic = "Lottery"; $subtopic = "lottery"; include("lottery.php"); break; Em layouts.php adicione o code abaixo:
<a href="?subtopic=lottery"> <div id="submenu_lottery" class="Submenuitem" onmouseover="MouseOverSubmenuItem(this)" onmouseout="MouseOutSubmenuItem(this)"> <div class="LeftChain" style="background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);"></div> <div id="ActiveSubmenuItemIcon_lottery" class="ActiveSubmenuItemIcon" style="background-image:url(<?PHP echo $layout_name; ?>/images/menu/icon-activesubmenu.gif);"></div> <div id="ActiveSubmenuItemLabel_lottery" class="SubmenuitemLabel">Lottery</div> <div class="RightChain" style="background-image:url(<?PHP echo $layout_name; ?>/images/general/chain.gif);"></div> </div> </a> Pronto galera só isso, não esqueça clica em GOSTEI! Comente, participe do tópico, isso nos ajuda muito.
Créditos:
.lua - Killua e Matheus
.php - Matheus e Natanael Beckman
querys - Natanael Beckman e Matheus
Atualização 24/05/2014 - Adicionado regras pra não sorteá membro da staff(GM, GOD) - Adicionando sistema de Storage pra não correr o risco de um player ganhar 2x no mesmo dia. -
Netounico deu reputação a DeathRocks em [8.60]Baiak Barao Editado DeathRocksFala Ae Galera do TibiaKing
Estou mais um vez disponibilizando um Baiak Barao que Acabei de Editar
Espero Que Gostem
Oque eu Mudei e Adicionei ?
-| Novo Visual do Templo
-| Aura System (comando !aura on)
-| Task System
-| Dodge System
-| Run Event (CORRIDA MALUCA)
-| Reset System (ÁREA EXCLUSIVA COM CASTELO E HUNTS) para resetar fale !reset
-| Guild Frags System (ÁREA EXCLUSIVA COM CASTELO E HUNTS)
-| War System (100% RODANDO EM SQLITE)
-| Cast System (100% Roda em Mysql ) ( Para Ativar vai em Config.lua e ache | enableCast = false | mude para true ) Duvidas entrem em http://www.tibiaking.com/forum/topic/34609-add-cast-system-pra-quem-já-tem-os-códigos-na-distro/
-| PvP Balanceado
-| Varios Eventos Automaticos
-| Battle Field Event
-| Capture The Flag Event
-| Adicionado CASTLE 24HORAS (COM CASTELO) e AVISOS DE INVASORES
-| Itens DONATES
-| Área DONATE ~~ (Só Entra Quem Usar o Itens)
-| Vários Novos Script
-| Fast Atk Arrumado
-| Distro 0.4 Rodando 100% ( Se For 64x Bits)
-| Refinamento ( Aprimora seu Item )
-| Level Points System Adicionado (Melhora Seu Skill)
-| Frags no Look
-| Npc Major Ancient (Vende Itens Exclusivos para quem tiver honor points) Obs:Consegue no GFS)
-| Fly System Adicionado fale !fly
-| e Muito Mais que Não Lembro
-| CONFIRA ~~ !
-| SENHA DO GOD: barao/styller
~~ Algumas Imagens do Servidor ~~
CASTELO GFS Localizado na Barao City
Castelo Reset System Localizado na Barao City
Amostra do CASTLE War 24HORAS Vista por Cima
CASTLE WAR 24 HORAS Vista por Baixo + Amostra de Invasão
Donate Área
Amostra de Itens Donate
Amostra de Systema de Points
Amostra do Refinamento
TEMPLO
-| Download
http://www.4shared.com/rar/kv68Q66Hba/Baiak_Barao_Editado_By_DeathRo.html?
-| Scan
https://www.virustotal.com/pt/file/b036f248977d3b75e8fc205983b449a2fd68a942e62a48963adfcfa49fd954b8/analysis/1402686644/
-| Créditos
Gostou ? então dei um +REP Não vai cair o Dedo
-
Netounico deu reputação a iErrorzz em Entrega de itensEm globalevents/globalevents.xml adicionem a tag:
<globalevent name="website_shop" interval="30000" script="shop.lua desc="Auto Shop System."/>
Crie um arquivo lua com o nome shop.lua em globalevents/scripts/... e coloque esse código dentro:
SHOP_MSG_TYPE = MESSAGE_STATUS_CONSOLE_BLUE SQL_interval = 30 -- ### END OF CONFIG ### function onThink(interval, lastExecution) local result_plr = db.getResult("SELECT * FROM `z_ots_comunication` WHERE `type` = 'login';") if(result_plr:getID() ~= -1) then while(true) do id = tonumber(result_plr:getDataInt("id")) action = tostring(result_plr:getDataString("action")) delete = tonumber(result_plr:getDataInt("delete_it")) cid = getCreatureByName(tostring(result_plr:getDataString("name"))) if isPlayer(cid) == TRUE then local itemtogive_id = tonumber(result_plr:getDataInt("param1")) local itemtogive_count = tonumber(result_plr:getDataInt("param2")) local container_id = tonumber(result_plr:getDataInt("param3")) local container_count = tonumber(result_plr:getDataInt("param4")) local add_item_type = tostring(result_plr:getDataString("param5")) local add_item_name = tostring(result_plr:getDataString("param6")) local received_item = 0 local full_weight = 0 if add_item_type == 'container' then container_weight = getItemWeightById(container_id, 1) if isItemRune(itemtogive_id) == TRUE then items_weight = container_count * getItemWeightById(itemtogive_id, 1) else items_weight = container_count * getItemWeightById(itemtogive_id, itemtogive_count) end full_weight = items_weight + container_weight else full_weight = getItemWeightById(itemtogive_id, itemtogive_count) if isItemRune(itemtogive_id) == TRUE then full_weight = getItemWeightById(itemtogive_id, 1) else full_weight = getItemWeightById(itemtogive_id, itemtogive_count) end end local free_cap = getPlayerFreeCap(cid) if full_weight <= free_cap then if add_item_type == 'container' then local new_container = doCreateItemEx(container_id, 1) doItemSetAttribute(new_container, "description", 'Bought by ' .. getCreatureName(cid) .. ' [ID:' .. id .. '].') doItemSetAttribute(new_container, "tid", id) local iter = 0 while iter ~= container_count do local new_item = doCreateItemEx(itemtogive_id, itemtogive_count) doItemSetAttribute(new_item, "description", 'Bought by ' .. getCreatureName(cid) .. ' [ID:' .. id .. '].') doItemSetAttribute(new_item, "tid", id) doAddContainerItemEx(new_container, new_item) iter = iter + 1 end received_item = doPlayerAddItemEx(cid, new_container) else local new_item = doCreateItemEx(itemtogive_id, itemtogive_count) doItemSetAttribute(new_item, "description", 'Bought by ' .. getCreatureName(cid) .. ' [ID:' .. id .. '].') doItemSetAttribute(new_item, "tid", id) received_item = doPlayerAddItemEx(cid, new_item) end if received_item == RETURNVALUE_NOERROR then doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, 'You received >> '.. add_item_name ..' << from OTS SHOP.') doPlayerSave(cid) db.query("DELETE FROM `z_ots_comunication` WHERE `id` = " .. id .. ";") db.query("UPDATE `z_shop_history_item` SET `trans_state`='realized', `trans_real`=" .. os.time() .. " WHERE id = " .. id .. ";") else doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. Please make place for this item in your backpack/hands and wait about '.. SQL_interval ..' seconds to get it.') end else doPlayerSendTextMessage(cid, SHOP_MSG_TYPE, '>> '.. add_item_name ..' << from OTS shop is waiting for you. It weight is '.. full_weight ..' oz., you have only '.. free_cap ..' oz. free capacity. Put some items in depot and wait about '.. SQL_interval ..' seconds to get it.') end end if not(result_plr:next()) then break end end result_plr:free() end return true end Creditos luan