Ir para conteúdo

Featured Replies

Postado

OIa a todos, estou com problemas no lottery system, uso TFS 1.0 e segui de acordo com este tópico 

http://www.tibiaking.com/forum/topic/34002-globalevents-perfect-lottery-system-mysql-atualizado/

O problema é que o player não recebe o item quando acontece o evento. testei usando este comando 

INSERT INTO `lottery` (`id`, `name`, `item`, `world_id`, `item_name`, `date`) VALUES(NULL, 'nomedochar', '2470', '0', 'golden legs', '22/05/2014 - 04:49:50');

e simplesmente o player nao recebe o item também. No site aparece tudo normal mais no jogo o player não recebe nada.

Postado

Usando mesmo script que ti, mas o meu problema é pior ainda: nem acontece nada! Não dá erro no console, nada, simplesmente o globalevents não funciona e passa reto pelo script sem nem tentar rodar. A configuração tá certinha, não vi nada demais.

 

globalevents e lottery.lua:

<?xml version="1.0" encoding="UTF-8"?>
<globalevents>
    <!-- Gray Island Bosses -->
    <globalevent name="grayIslandBosses" type="startup" script="gray island/grayIslandBosses.lua"/>

    <!-- Demon Oak Quest -->
    <globalevent name="DemonOakVoices" interval="15000" script="demon oak quest/voices.lua"/>

    <!-- Spawn -->
    <globalevent name="horseSpawn" time="08:00" script="spawn/horse.lua"/>
    <globalevent type="startup" name="RashidSpawn" script="spawn/RashidSpawn.lua"/>
    <globalevent type="startup" name="CilliaSpawn" script="spawn/CilliaSpawn.lua"/>
    
    <!-- World Changes -->
    <globalevent name="furyGate" type="startup" script="worldchanges/furygate.lua"/>
    <globalevent name="horestis" time="05:05" script="worldchanges/horestis.lua"/>

    <!-- Lottery -->
    <globalevent name="lottery" interval="1000" event="script" value="lottery.lua"/>
    
    <!-- Others -->
    <globalevent type="startup" name="ServerStartup" script="others/startup.lua"/>
    <globalevent type="record" name="PlayerRecord" script="others/record.lua"/>
    <globalevent name="shop" interval="30000" script="others/shop.lua"/>
    <globalevent name="warSystem" interval="3000000" script="others/warEnd.lua"/>
    <!--"<globalevent name="globalSave" time="04:55" script="others/serverSave.lua"/>-->
    <globalevent name="GlobalSave" time="22:20" event="script" value="others/GlobalSave.lua"/>
    <globalevent name="save" interval="1800000" script="others/save.lua"/>
    <globalevent name="RentedMounts" interval="15000" script="others/checkMount.lua"/>
    <globalevent name="cleanHouse" type="startup" script="others/cleanHouse.lua"/>
    <globalevent name="griffinclawFlower" type="start" script="others/griffinclawFlower.lua"/>
</globalevents>
local config = {
        lottery_hour = "2 hours", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message)
        rewards_id = {2470, 2472, 2514, 2160, 9778, 23534, 11302, 9693}, -- ID dos Itens Sorteados na Loteria
        crystal_counts = 20, -- 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-09:00",
                "Monday-13:00",
				"Monday-15:00",
				"Monday-17:00",
                "Monday-19:30",

                "Tuesday-09:00",
                "Tuesday-13:00",
				"Tuesday-15:00",
				"Tuesday-17:00",
                "Tuesday-19:30",

                "Wednesday-09:00",
                "Wednesday-13:00",
				"Wednesday-15:00",
				"Wednesday-17:00",
                "Wednesday-19:30",

                "Thursday-09:00",
                "Thursday-13:00",
				"Thursday-15:00",
				"Thursday-17:00",
                "Thursday-19:30",

                "Friday-01:22",
                "Friday-13:00",
				"Friday-15:00",
				"Friday-17:00",
                "Friday-19:30",
				"Friday-21:30",

				
                "Saturday-08:00",
				"Saturday-10:00",
                "Saturday-13:00",
				"Saturday-15:00",
				"Saturday-17:00",
				"Saturday-20:27",
				"Saturday-20:28",
                "Saturday-20:29",
				"Saturday-23:45",
				
                "Sunday-08:00",
				"Sunday-10:00",
                "Sunday-13:00",
				"Sunday-15:00",
				"Sunday-17:00",
				"Sunday-20:27",
				"Sunday-20:28",
                "Sunday-20:29",
                }
        }
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

 

  • 5 months later...

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.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo