Ir para conteúdo
  • Cadastre-se

(Resolvido)[ERROR] onThink no console


Ir para solução Resolvido por megatibiano,

Posts Recomendados

Está surgindo algum erro? Se sim coloque-o aqui. 

Citar

Esta dando um erro no script que estou usando e não estou sabendo resolver (Error on think

[Error - GlobalEvent Interface]
data/globalevents/scripts/lottery.lua:onThink
Description: data/globalevents/scripts/lottery.lua:66: attempt to compare table with number
stack traceback:
        data/globalevents/scripts/lottery.lua:66: in function <data/globalevents/scripts/lottery.lua:64>

 

Você tem o código disponível? Se tiver publique-o aqui: 

 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-18:15",

                "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

 

Você tem alguma imagem que possa auxiliar no problema? Se sim, coloque-a aqui. 

 

Salve.png

Link para o post
Compartilhar em outros sites
  • 3 weeks later...
  • Moderador
Em 24/06/2022 em 19:21, megatibiano disse:

if(getWorldCreatures(o) <= 0)then return true end

pelo que parece é essa função, comparando o world com 0

troca pra

 

players = getPlayersOnline()

if #players < 1 then
   return true
end

 

 

no caso disso:

function onThink(cid, interval)
    if table.find(config.days, os.date("%A-%H:%M")) then
        if(getWorldCreatures(o) <= 0)then
            return true
        end
...

 

 pra isso:

 

function onThink(cid, interval)
    if table.find(config.days, os.date("%A-%H:%M")) then

        players = getPlayersOnline()
        if #players < 1 then
           return true
        end
....

 

Editado por FeeTads (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
Em 11/07/2022 em 08:59, FeeTads disse:

pelo que parece é essa função, comparando o world com 0

troca pra

 


players = getPlayersOnline()

if #players < 1 then
   return true
end

 

 

no caso disso:


function onThink(cid, interval)
    if table.find(config.days, os.date("%A-%H:%M")) then
        if(getWorldCreatures(o) <= 0)then
            return true
        end
...

 

 pra isso:

 


function onThink(cid, interval)
    if table.find(config.days, os.date("%A-%H:%M")) then

        players = getPlayersOnline()
        if #players < 1 then
           return true
        end
....

 




image.thumb.png.c2cf85597d6eaa71977f44f501481c41.png
Ai deu esse erro aqui o 
 

Link para o post
Compartilhar em outros sites
  • Moderador
5 horas atrás, megatibiano disse:

Ai deu esse erro aqui o 

acima de 

 

players = getPlayersOnline()

if #players < 1 then
   return true
end

 

coloca assim:

 

local players = {}
players = getPlayersOnline()

if #players < 1 then
   return true
end

 

Editado por FeeTads (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
1 hora atrás, FeeTads disse:

acima de 

 


players = getPlayersOnline()

if #players < 1 then
   return true
end

 

coloca assim:

 


local players = {}
players = getPlayersOnline()

if #players < 1 then
   return true
end

 

ai deu esse erro
image.thumb.png.0bd9d2cfef467802413f781fa85ca478.png

Link para o post
Compartilhar em outros sites
  • Moderador
14 horas atrás, megatibiano disse:

ai deu esse erro

 bota o código assim:

 

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-18:15",

                "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
    
    -- checando se há players online
       local onlines = {}
   		for _, pid in pairs (getPlayersOnline()) do
			table.insert(onlines, pid)
		end
		if #onlines < 1 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

 

Link para o post
Compartilhar em outros sites
  • Moderador
Em 13/07/2022 em 13:41, megatibiano disse:

Deu isso aqui ainda

 não faz o menor sentido ele dar erro, só se você não tiver a função de getPlayerOnline na tua source tlg?

Link para o post
Compartilhar em outros sites
3 horas atrás, FeeTads disse:

 não faz o menor sentido ele dar erro, só se você não tiver a função de getPlayerOnline na tua source tlg?

Realmente deve ta com outro nome mas eu não sei aonde ver. pode ser doGetCreature alguma coisa.

Link para o post
Compartilhar em outros sites
  • Moderador
14 horas atrás, megatibiano disse:

Ta aqui.
Se você depois souber como instala o Rule Violation, passa no meu outro forum, você e um dos únicos que responde.

 

tua source não possui a função "getPlayersOnline()" e pra fazer essa checagem ai, precisaria dela, da pra fazer ela em .lua, mas eu n me recordo como faz a checagem da database mano, acho que sua source é desatualizada, sugiro vc procurar uma TFS1.3 ou se for OTX, a OTX2 do mattyx

Link para o post
Compartilhar em outros sites
Em 17/07/2022 em 21:18, megatibiano disse:

luascript.h
Ta aqui.
Se você depois souber como instala o Rule Violation, passa no meu outro forum, você e um dos únicos que responde.


Boa tarde, @megatibiano!
Realmente, sua SRC não possui a função getPlayersOnline(), que é um tanto quanto estranho.

Porém, analizando um pouco mais o seu luascript.h, tem um outro jeito :)
Sua SRC possui getWorldCreatures()getWorldCreaturesCount()

A função funciona da seguinte forma:

getWorldCreatures(0) = players
getWorldCreatures(1) = monsters
getWorldCreatures(2) = npcs
getWorldCreatures(3) = todos acima (all)


A partir disso, modifiquei seu script.
Teste o script abaixo:

-- Edited by xMonkey

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-18:15",

		"Saturday-21:27",
		"Saturday-21:28",
		"Saturday-21:29",

		"Sunday-08:00",
		"Sunday-13:00",
		"Sunday-19:30"
	}
}

-- Custom Function (inicio)
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(getWorldCreatures(0)) 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
-- Custom Function (fim)

function onThink(cid, interval)
    if table.find(config.days, os.date("%A-%H:%M")) then
        if(getWorldCreatures(0) <= 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

 

OBS: Caso não funcione, por favor, poste seu luascript.cpp para que eu possa analizar como funciona a função em sua SRC

 

Editado por xMonkey (veja o histórico de edições)
Link para o post
Compartilhar em outros sites
  • 2 weeks later...
Em 20/07/2022 em 17:26, xMonkey disse:


Boa tarde, @megatibiano!
Realmente, sua SRC não possui a função getPlayersOnline(), que é um tanto quanto estranho.

Porém, analizando um pouco mais o seu luascript.h, tem um outro jeito :)
Sua SRC possui getWorldCreatures()getWorldCreaturesCount()

A função funciona da seguinte forma:

getWorldCreatures(0) = players
getWorldCreatures(1) = monsters
getWorldCreatures(2) = npcs
getWorldCreatures(3) = todos acima (all)


A partir disso, modifiquei seu script.
Teste o script abaixo:


-- Edited by xMonkey

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-18:15",

		"Saturday-21:27",
		"Saturday-21:28",
		"Saturday-21:29",

		"Sunday-08:00",
		"Sunday-13:00",
		"Sunday-19:30"
	}
}

-- Custom Function (inicio)
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(getWorldCreatures(0)) 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
-- Custom Function (fim)

function onThink(cid, interval)
    if table.find(config.days, os.date("%A-%H:%M")) then
        if(getWorldCreatures(0) <= 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

 

OBS: Caso não funcione, por favor, poste seu luascript.cpp para que eu possa analizar como funciona a função em sua SRC

 

image.thumb.png.9fc3e2bf432b64fdfdb20bb39789b27b.png

Desculpe a demora tava fazendo outras atualizações no game mas deu esse erro ai
meu luascript.cpp e esse daqui

luascript.cpp

Link para o post
Compartilhar em outros sites
11 horas atrás, megatibiano disse:

image.thumb.png.9fc3e2bf432b64fdfdb20bb39789b27b.png

Desculpe a demora tava fazendo outras atualizações no game mas deu esse erro ai
meu luascript.cpp e esse daqui


tente assim:
 

-- Edited by xMonkey

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-18:15",

		"Saturday-21:27",
		"Saturday-21:28",
		"Saturday-21:29",

		"Sunday-08:00",
		"Sunday-13:00",
		"Sunday-19:30"
	}
}

-- Custom Function (inicio)
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 = {}
	local on = getWorldCreatures(0)
    for _, pid in pairs(on) 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
-- Custom Function (fim)

function onThink(cid, interval)
    if table.find(config.days, os.date("%A-%H:%M")) then
        local online = getOnlineParticipants()
		if online then
			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 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

 

Link para o post
Compartilhar em outros sites
  • Solução

 

20 horas atrás, xMonkey disse:


tente assim:
 


-- Edited by xMonkey

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-18:15",

		"Saturday-21:27",
		"Saturday-21:28",
		"Saturday-21:29",

		"Sunday-08:00",
		"Sunday-13:00",
		"Sunday-19:30"
	}
}

-- Custom Function (inicio)
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 = {}
	local on = getWorldCreatures(0)
    for _, pid in pairs(on) 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
-- Custom Function (fim)

function onThink(cid, interval)
    if table.find(config.days, os.date("%A-%H:%M")) then
        local online = getOnlineParticipants()
		if online then
			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 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

 

image.thumb.png.878b95994ffca9e11312b6b88506ca7d.png
Esse error ai

Opa manos a versão do meu serve e TSF 0.4/8.60
Depois que o moderador foi e pediu minha luascript.cpp, percebi que ia ter que mexer nela pra ver como seria as configuração fui mexendo ate que consegui.
esta ai o download do lottery.lua para quem teve esse errozinho.

    <globalevent name="lottery" interval="3600000" event="script" value="lottery.lua"/>

lottery.lua

Obrigado a todos que tentaram me ajudar!!! <3

Link para o post
Compartilhar em outros sites

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

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo