ertlflorian1 Posted May 14, 2013 Share Posted May 14, 2013 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
iPrestege Posted May 14, 2013 Share Posted May 14, 2013 Did you try to create an anonymous function for the timer ? setTimer ( function ( ) resetallcars() end ,milli, 1) Link to comment
ertlflorian1 Posted May 14, 2013 Author Share Posted May 14, 2013 Thank you so much !!! Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now