holuzs Posted January 17, 2019 Share 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 Link to comment
Moderators IIYAMA Posted January 17, 2019 Moderators Share 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 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