• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua Block storage of AFK players in lottery !!! HELP - ME

ninexin

insane.sytes.net
Joined
Jun 10, 2007
Messages
213
Reaction score
3
Location
Brazil
HI i have one afk system and using this storage 38417

look:
Code:
local time = 3 -- Seconds
local say_events = {}
local function SayText(cid)
    if isPlayer(cid) == TRUE then
         if say_events[getPlayerGUID(cid)] ~= nil then
             if isPlayer(cid) == TRUE then
                 doSendAnimatedText(getPlayerPosition(cid),"AFK!", math.random(25,35))
             end
             say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000 / 2, cid)       
         end                                                       
    end
    return TRUE
end
 
local storage = 38417
function onSay(cid, words, param, channel)
local afkCheck = getPlayerStorageValue(cid, storage)
    if(param == "") then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Requer parametro de comando on/off.")
    return TRUE
    end
     if (param == "on") then
        if (afkCheck == -1) then
            if (isPlayer(cid) == TRUE) then
                doSendAnimatedText(getPlayerPosition(cid),"AFK!", math.random(25,35))
            end
            say_events[getPlayerGUID(cid)] = addEvent(SayText, time * 1000, cid)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Você acaba de entrar em modo AFK.")
            doCreatureSetNoMove(cid, true)
            setPlayerStorageValue(cid, storage, 1)
        else
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você ja esta em modo AFK.")
        end
     elseif (param == "off") then
        stopEvent(say_events[getPlayerGUID(cid)])
        say_events[getPlayerGUID(cid)] = nil
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "Você não esta em modo AFK!")
        doCreatureSetNoMove(cid, false)
        setPlayerStorageValue(cid, storage, -1)	
    end
    return TRUE
end

now i need config my lottery script for detect afk players

look my lottrey script:
Code:
-- Lottery System
local config = {
    lottery_hour = "2 Hours", -- Tempo ate a proxima loteria (Esse tempo vai aparecer somente como broadcast message)
    rewards_id = {2160}, -- ID dos Itens Sorteados na Loteria
    crystal_counts = 10, -- Usado somente se a rewards_id for crystal coin (ID: 2160).
    website = "no" -- Only if you have php scripts and table `lottery` in your database!
    }
function onThink(cid ,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! (Proxima Loteria em " .. config.lottery_hour .. ")")
        else
                doBroadcastMessage("[LOTTERY SYSTEM] Winner: " .. getCreatureName(winner) .. ", Reward: " .. getItemNameById(random_item) .. "! Congratulations! (Proxima Loteria em " .. config.lottery_hour .. ")")
                doPlayerAddItem(winner, random_item, 1)
        end
       
        if(config.website == "yes") then
                db.query("INSERT INTO `lottery` (`name`, `item`) VALUES ('".. getCreatureName(winner) .."', '".. getItemNameById(random_item) .."');")
        end
        return true
end

how do I get the code does not list the AFK players!!!


i reep ++ for help plxxx i need so much!!!
sry my bad inglish!
 
Code:
	local list = {}
	for i, tid in ipairs(getPlayersOnline()) do
		if getCreatureStorage(tid, 38417) == -1 then
			list[i] = tid
		end
	end
 
Last edited:
thx for ur attention Cykotitan, but i get this error:
ba8d4876.jpg


im using TFS 0.4 r3777
plx i need one solution!


;**
 
Back
Top