BlockFighter Posted October 16, 2018 Share Posted October 16, 2018 Hi! I have a problem with what is on EventHandler on the server side I can not query on the client side as a variable how can I solve this problem? Because it gives a bug to ''attempt to concatenate local 'cost'" Global Code: shops = { {"Phone1", 1, 2, 3}, {"Phone2", 1, 2, 3}, } Server Code: function getShops() for k, v in ipairs(shops) do return shops[k][4] end end addEvent("getshops", true) addEventHandler("getshops", getRootElement(), getShops) Client Code: local cost = triggerServerEvent("getshops", getRootElement()) dxDrawText("#ffffffCost: #6ad622"..cost.. " $" ,x/2+ 10, y/2+index*58+18.5, panelSize[1], 25*2.3, tocolor(66, 244, 220, 255), 0.8, font2, "left", "top", false, false, false, true) Link to comment
SaNoR Posted October 16, 2018 Share Posted October 16, 2018 Server: function getShops() for k, v in ipairs(shops) do triggerClientEvent("getshopsClient", root, shops[k][4]) end end addEvent("getshops", true) addEventHandler("getshops", getRootElement(), getShops) Client: local cost = 0 addEvent("getshopsClient", true) addEventHandler("getshopsClient", root, function(value) cost = value end) ... dxDrawText("#ffffffCost: #6ad622"..cost.. " $" ,x/2+ 10, y/2+index*58+18.5, panelSize[1], 25*2.3, tocolor(66, 244, 220, 255), 0.8, font2, "left", "top", false, false, false, true) ... Link to comment
BlockFighter Posted October 16, 2018 Author Share Posted October 16, 2018 The 'cost' variable only points to 0 in dxDraw. Link to comment
SaNoR Posted October 16, 2018 Share Posted October 16, 2018 triggerServerEvent("getshops", getRootElement()) Attach trigger to button or "onClientRender" 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