DrawSpotLightWithShadow serverevent

Hallo…
I have the problem that this not work…
Clientside:

if light_state then
	ESX.TriggerServerCallback('helip:updateLightFromHeli', function()
	end, cam, light_state)
end
----------
RegisterNetEvent('helip:heliLightUpdate')
AddEventHandler('helip:heliLightUpdate', function(cam, light_state)
	if light_state then
		local rotation = GetCamRot(cam)
		local forward_vector = RotAnglesToVec(rotation)
		local camcoords = GetCamCoord(cam)
		DrawSpotLightWithShadow(camcoords, forward_vector, 255, 255, 255, 600.0, 10.0, 100, 10.0, 200.0, 10.0)
	end
end)

and serverside:

ESX.RegisterServerCallback('helip:updateLightFromHeli', function(source, cb, cam, light_state)
		local players = GetPlayers()

	for k, v in pairs(players) do
		TriggerClientEvent('helip:heliLightUpdate', v, cam, light_state)
	end
end)

The other player can not see the Light but why?

For one thing, I don’t believe the camera is networked fully or at all.

You can pass the cam’s handle/ID to other clients the way you have but I think you will find DoesCamExist(cam) is only true on the client that created the cam, and is false on remote clients. Therefore no rotation, forward_vector or spotlight on remote clients.

At least this is what I encountered when I tried similar techniques of having remote clients read directly off the cam in order to draw a manual, free-aiming spotlight without the lag associated with client-server or client-client communications. I even tried ‘forcibly’ networking the cam entity using the usual natives but it didn’t work. I settled for a laggier method using decorators but if you get this working let us know.

i have tried with position and rotation data but not work…
No error and no light no for me as player or other player…

I’m not sure I understand you. First of all, are you agreeing with me that the code you posted above cannot work? That remote clients cannot directly read changes to the cam that was created by another client?

If so and you are looking for an alternative method, one that uses decorators and client-client communication to acquire cam position and rotation data, then this is a modification to @mraes’s heli script with working manual, free aiming heli spotlight:

Yes but this is only client side… my other player cant see the light only by button G… this light not move to the camera location or target

Again I’m not sure I understand. Language might be a problem here. No offense intended but maybe you could try using Google Translate?

The mod I posted above is synced serverside and other clients do see the heli pilot’s spotlight.

Your own server code above won’t work because other clients cannot identify the pilot’s heli cam and therefore rotation will be 0 for everyone except the original heli pilot client.

local rotation = GetCamRot(cam)