[help] Noob question "how can i pass a var from server to client"

im not sure how i can pass a true or false from the server to the client.

Thanks :smiley:

Use client and server events.

could you give me an example:D

When i get home i will show you. If you search up my k9 i do some of server to client.

Alright np great script btw
i dont understand what to look for or i wouldxD

Any events on the server called TriggerClientEvent is passing data on the k9.

ok ill look

20Characters

TriggerClientEvent("K9:SearchVehicle", src, K9Config.Items)

Src is the client to target and K9Config.Items is the table im passing from the config.

so just change the src to whatever my var is then set like new var = that var? confused

Src is a players id. Change src to source and pass your true / false over my k9config.items.

ok so like
cause im trying to see if they have the items from the inventory so i made a event that checks it the changes has to true or false

TriggerClientEvent(ā€œesx_crafting:giveWeaponā€, source, has)

Do you know how to register a client event.

edited that part up there so like that?

Yeah the K9:SearchVehicle is a register net event on the client.

Do i need the source part to just pass the true or false?

So something like this?

Server.lua

RegisterServerEvent(ā€˜esx_crafting:checkā€™)
AddEventHandler(ā€˜esx_crafting:checkā€™, function()
local xPlayer = ESX.GetPlayerFromId(source)
local BarrelQuantity = xPlayer.getInventoryItem(ā€˜barrel_poochā€™).count
local FrameQuantity = xPlayer.getInventoryItem(ā€˜frameā€™).count
local StockQuantity = xPlayer.getInventoryItem(ā€˜stockā€™).count

if BarrelQuantity >= 1 and FrameQuantity >= 1 and StockQuantity >= 1 and not BarrelQuantity == nil and not FrameQuantity == nil and not StockQuantity == nil then
	has = true
	TriggerClientEvent("esx_crafting:pass", has)
else
	has = false
end

end)

Client

RegisterNetEvent(ā€˜esx_crafting:passā€™)
AddEventHandler(ā€˜esx_crafting:passā€™, function(has)
hasS = has
end)

TriggerClientEvent(ā€œeventā€, HAS_TO_HAVE_AN_ID, has)

so i do have to put source there?

I added source there still didnā€™t work :frowning:

ah. ok. source only exists when a server event is called from the client. You need to put your server id as where source is.