Jump to content

setTimer Problem


Recommended Posts

The function getNextWangCarsLieferung will be performed very often if i hide the setTimer (resetallcars(), milli, 1) getNextWangCarsLieferung only will be once permormed ??

local wangcarslieferungh = 20 
local wangcarslieferungm = 33 
-- Bei wangcarslieferungh eine Zahl zwischen 00-23 angeben und bei wangcarslieferungm eine Zahl zwischen 01-59 
  
function getNextWangCarsLieferung () 
if (wangcarslieferungh >= 0) and (wangcarslieferungh <= 23) and (wangcarslieferungm >= 1) and (wangcarslieferungm <= 59) then 
    local time = getRealTime () 
    local minutesofreset = wangcarslieferungm+(wangcarslieferungh*60) 
    local currentminutes = time.minute+(time.hour*60) 
    if (minutesofreset >= currentminutes) then  
    outputChatBox ("1") 
    local milli = (minutesofreset-currentminutes)*60000 
    outputChatBox(milli) 
    setTimer (resetallcars(), milli, 1) 
    else 
    outputChatBox ("2") 
    local milli = ((minutesofreset-currentminutes)+1440)*60000 
    outputChatBox(milli) 
    setTimer (resetallcars(), milli, 1) 
    end 
    end 
end 
addEventHandler ("onResourceStart", getResourceRootElement (getThisResource()), getNextWangCarsLieferung) 
     
function resetallcars () 
local query = dbQuery ( handler, "SELECT * FROM wangcars") 
    for i, row in pairs (dbPoll(query, -1)) do 
        local queryi = dbQuery ( handler, "UPDATE wangcars SET Stueck='3' WHERE Name='"..row.Name.."'" ) 
        dbFree (queryi) 
    setElementData (root, "stueck"..string.upper(string.sub(row.Name, 1, 1))..string.sub(row.Name, 2, string.len(row.Name)), 3) 
    end 
        setTimer (getNextWangCarsLieferung(), 500000, 1) 
        outputChatBox ("Wang Cars hat gerade eine Lieferung bekommen!", root, 0, 255, 0) 
end 

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...