Jump to content

مساعدة


Recommended Posts

السلام عليكم

شباب ليش مايسوي ريفريش للوقت المتبقي
 

addCommandHandler("lottotime", function(player)
    if lottoActive then
        local currentTime = getRealTime().timestamp * 1000
        local elapsedTime = currentTime - lottoStartTime
        local remainingTime = lotteryInterval * 1000 - elapsedTime

        remainingTimeUntilNextLotto = remainingTime  

        if remainingTime > 0 then
            local minutes = math.floor(remainingTime / 60000)
            local seconds = math.floor((remainingTime % 60000) / 1000)

            if remainingTime > (lotteryInterval - 600) * 1000 then
                outputChatBox("• Event is already running. Use /buyticket to participate", player, 255, 0, 0, true)
            else
                outputChatBox("#006600• [#FFFFFFLOTTERY#006600] The lottery is currently running. Use /buyticket to participate.", player, 0, 255, 0, true)
            end
        else
            outputChatBox("• The lottery is currently running. Use /buyticket to participate.", player, 255, 0, 0, true)
        end
    else
        local remainingTime = remainingTimeUntilNextLotto 
        local minutes = math.floor(remainingTime / 60000)
        local seconds = math.floor((remainingTime % 60000) / 1000)
        outputChatBox("#006600• [#FFFFFFLOTTERY#006600] There is no active lottery at the moment. The next lottery starts in #FFFFFF" .. minutes .. " minutes, and #FFFFFF" .. seconds .. " seconds", player, 0, 255, 0, true)
    end
end)
local lottoActive = false
local lottoTimer = nil
local lottoTicketPriceRange = {5000, 20000}
local lottoPrizeRange = {50000, 200000}
local ticketBuyingTime = 60 
local lotteryInterval = 1200 
local winningNumber = nil
local prize = nil
local ticketOwners = {} 
local remainingTimeUntilNextLotto = 0
local ticketPrice = nil
local playerTickets = {} 

function startLotto()
    if lottoActive then
        outputChatBox("#006600[#FFFFFFLOTTERY#006600]#FF0000• Lottery event is already active.", root, 255, 0, 0, true)
        return
    end

    lottoActive = true

    lottoTimer = setTimer(endTicketBuying, ticketBuyingTime * 1000, 1)

    prize = math.random(lottoPrizeRange[1], lottoPrizeRange[2])

    ticketPrice = math.random(lottoTicketPriceRange[1], lottoTicketPriceRange[2])

    lottoStartTime = getRealTime().timestamp * 1000  -- Update this line

    outputChatBox("#006600• [#FFFFFFLOTTERY#006600] Event started! Use #FFFFFF/buyticket #006600[#FFFFFF1-100#006600]#006600 to purchase a ticket for #FFFFFF" .. ticketPrice .. "#006600$. #006600Prize: #FFFFFF" .. prize .. "#006600$", root, 0, 255, 0, true)

    remainingTimeUntilNextLotto = lotteryInterval * 1000
end


المشكلة /lottotime
يضهر 20 دقيقة
not refreshing remaining time

Edited by Snakegold
Link to comment
  • Scripting Moderators

وعليكم السلام

ما يتحدث نهائيًا إلا في حال كانremainingTimeUntilNextLotto ركز في كودك، المتغير
lottoActive مفعل
وفي كودك ما تظهر الوقت إلا لو كان غير مفعل، يعني مستحيل المتغير يتحدث
jiNljFy.png
لكن عالعموم انا اشوف استعمال الوقت غير مناسب هنا والأفضل تستعمل التايمر لأن اصلا تحتاجه
setTimer
getTimerDetails التايمر راح يشغل لك وظيفة بعد وقت معين راح يفيدك هنا، وتقدر تعرف منه كم باقي وقت عبر

Edited by xLive
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...