Jump to content

Server side variable to client side dxDraw


BlockFighter

Recommended Posts

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...