Issue with TriggerServerEvent and TriggerClientEvet

Hello,

I’m working on a laundry script for dirty monney. However, I’m facing an issue with client and server relation.
Here are the scripts I have:

Client:

Citizen.CreateThread(function(user)
	while true do
		Citizen.Wait(0)
		DrawMarker(1, -146.98616027832, -1108.23010253906, 42.1392707824707, 0, 0, 0, 0, 0, 0, 2.001, 2.0001, 0.5001, 0, 155, 255, 200, 0, 0, 0, 0)
		-- Affiche Marqueur pour faire spawn
		if GetDistanceBetweenCoords(-146.98616027832, -1108.23010253906, 42.1392707824707, GetEntityCoords(LocalPed())) < 1 then
			drawTxt("Appuyer sur ~g~H~s~ afin de pouvoir  ~b~blanchir~s~ votre argent", 2, 1, 0.5, 0.8, 0.6, 255, 255, 255, 255)
			if IsControlJustPressed(1, Keys["H"]) then
				
				Citizen.Wait(0)
				drawNotification("Tu veux donc blanchir de l'argent!")
				Citizen.Wait(500)
				drawNotification("Montre moi combien tu as ...")
				Citizen.Wait(1000)
				
				TriggerServerEvent('laundry:money', user)
				
			end
		end
		Menu.renderGUI()
	end
end)

RegisterNetEvent('laundry:checkdown')
AddEventHandler('laundry:checkdown', function()

	drawNotification("Il faut au moins 100K petit")
	
end)

RegisterNetEvent('laundry:checkup')
AddEventHandler('laundry:checkup', function()
	
	drawNotification("On peut discuter comme des adultes!")

end)

Server:

function drawNotification(text)
    SetNotificationTextEntry("STRING")
    AddTextComponentString(text)
    DrawNotification(false, false)
end

function bankBalanceDirty(player)
  local executed_query = MySQL:executeQuery("SELECT * FROM users WHERE identifier = '@name'", {['@name'] = player})
  local result = MySQL:getResults(executed_query, {'dirty_money'}, "identifier")
  return tonumber(result[1].dirty_money)
end


RegisterServerEvent('laundry:money')
AddEventHandler('laundry:money', function(user)
	
	drawNotification("COUCOU je suis dans le fichier server muthafucker") -- To try if I managed to have a server reaction
	
	local player = user.identifier
	
	local dirty = bankBalanceDirty(player)
	
		if (dirty < 100000) then
			
			TriggerClientEvent('laundry:checkdown')
			drawNotification("Il faut au moins 100K petit caca")
			
		else

			TriggerClientEvent('laundry:checkup')
			
		end

	end)

Have you any lead?

Cheers

With TriggerClientEvent you need to specify what player ID it will trigger on. You need to do something like this TriggerClientEvent(‘laundry:checkdown’, 1)

If you want the event to trigger on every single client, put -1

Hi,

Thanks a lot for this advice! I’ll adapt my code with that.
Actually, my issue is before that, it seems that TriggerServerEvent(‘laundry:money’, user) isn’t working.
I added a print(‘I’m here’) just befor the drawNotification(“COUCOU”). I get none of those sentence (neither in logs neither in the game). Here is the error of I have (I forgot to upload it in my first message)

Thanks for your help and time :slight_smile:

drawNotification(text) should be on the client. That is a client function, not a server thing. If you want to print some testing to the server console, use print(“why wont this shit work”) or something.

Also, where is the ‘user’ variable being set, from Citizen.CreateThread(function(user)