holuzs Posted January 17, 2019 Posted January 17, 2019 (edited) Why I can't trigger client side? Server: itemsS = {} function loadItems() local loadSQL = dbPoll(dbQuery(sql, "SELECT * FROM items"), -1) for i,v in ipairs(loadSQL) do --outputChatBox(v["itemid"] .. " | " .. v["ownerid"] .. " | " .. v["value"] .. " | " .. v["count"]) local insert = table.insert(itemsS, {v["itemid"], v["ownerid"], v["value"], v["count"]}) end for i,v in ipairs(getElementsByType("player")) do loadItemsToOnePlayer(v) end end addEventHandler("onResourceStart", resourceRoot, loadItems) function loadItemsToOnePlayer(player) for i,v in ipairs(itemsS) do if getElementData(player, "user:id")==tonumber(v[2]) then triggerClientEvent("sendItems", player, v[1], v[3], v[4]) end end end Client: addEvent("sendItems", true) addEventHandler("sendItems", root, function(id, value, count) table.insert(itemsC, {id, value, count}) end) Edited January 17, 2019 by holuzs
Moderators IIYAMA Posted January 17, 2019 Moderators Posted January 17, 2019 Because the players/clients haven't loaded their scripts yet. The server is always one step a head in time. 1 Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
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