Jalapeno Posted April 11, 2019 Share Posted April 11, 2019 --Row 76 function GetLastDBID() local dbMuv = dbQuery( handler, "SELECT * FROM rust_items ORDER BY `id` DESC" ) local result = dbPoll(dbMuv, -1) if (#result>0) then for _, row in ipairs ( result ) do id = tonumber(row["id"]) return id break end end end addEvent("GetLastDBID", true) addEventHandler("GetLastDBID", root, GetLastDBID) --Row90 Hy guys, i have a little problem with this code, i wan't to get the last item id from my sql table but something doesen't work.... DebugScript: ERROR: Loading script failed: Inventory\codeS.lua:84 'end' expected (to close 'for' at line 81) near 'break' Link to comment
Moderators IIYAMA Posted April 11, 2019 Moderators Share Posted April 11, 2019 Remove the return statement, the break statement also stops the loop. The return statement has no purpose for events, except for stopping the code. If you want to return the value, you need to use a triggerClientEvent. And add another handler on clientside. Or use this tool: https://gitlab.com/IIYAMA12/mta-communication-enchantment Which does all the magic for you. 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