_Kinan Posted November 4, 2017 Share Posted November 4, 2017 (edited) mysql = exports.mysql local plants = {} function refreshplants() local result = exports.mysql:query( "SELECT * FROM plants ORDER BY id" ) while true do row = exports.mysql:fetch_assoc( result ) if row then if row.type == "1" then object_id = 855 item_id = 208 elseif row.type == "2" then object_id = 818 item_id = 206 end if row.irl == "0" then local ob = createObject(object_id,row.x,row.y,row.z) table.insert(plants,{row.id,ob}) mysql:query("UPDATE `plants` SET `irl` = '1' WHERE `plants`.`id` = ".. row.id ..";") end end end end function plant(p,_,seed) if getElementData(p,"farmer") then if seed then outputChatBox("1",root) if seed == "1" then object_id = 855 item_id = 208 elseif seed == "2" then object_id = 818 item_id = 206 end if exports["item-system"]:hasItem(p,item_id) then local s = getRealTime() local timestamp = s.timestamp local x,y,z = getElementPosition(p) refreshplants() exports.mysql:query("INSERT INTO `plants` (`player`,`x`,`y`,`z`, `timecreated`, `type`,`irl`) VALUES ( '".. getPlayerName(p) .."', '".. x .."', '".. y .."','".. z .."', '".. timestamp .."', '".. seed .."','0');") end else -- end else -- end end addCommandHandler("plant",plant) Hello, I keep getting this problem while running my script. Aborting; Running infinite script in [MOD NAME] Also it gets about 15 seconds of lag to load the objects. I don't know either if its from the mysql or the script itself. FIXED, I tried putting break after the mysql assoc. Edited November 4, 2017 by _Kinan Link to comment
Moderators IIYAMA Posted November 4, 2017 Moderators Share Posted November 4, 2017 Yea should break the loop if there are no rows. if row then -- your thing else break end 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