[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:

[Solved] How can i pass a true or false from server to client?

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


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?


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)
	has = false



AddEventHandler(‘esx_crafting:pass’, function(has)
hasS = has


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.