[HELP] I make a Phone but i have error with my button "call the police"

Hi, i have make a phone with a button "call the police’ after this the player in the job police receive a message with name of the player and a marker for join the caller but doesnt work :cry:

SV_PHONE.LUA

RegisterServerEvent('police')
 AddEventHandler("police", function(source, user)
  Citizen.CreateThread(function()
	if LOADOUTS = "police" then  -- LOADOUTS is the job in the addon LOADOUTS job..
	  Wait(3)
      DisplayCash(false);
      SetNotificationTextEntry("STRING");
      AddTextComponentString("^2"..GetPlayerName(source).. ", need a police" ); -- Message sent to Police
      SetNotificationMessage("CHAR_CHAT_CALL", "CHAR_CHAT_CALL", true, 1, "Police Request"); -- Title of the request sent to Police
      DrawNotification(false, true);
      Wait(10000000)
	  BLIP.destination = AddBlipForChar " idk what is the command for make a blip to the caller " -- generate a blip to the caller
      SetBlipSprite(BLIP.destination, 1)
      SetBlipColour(BLIP.destination, 2)
      SetBlipRoute(BLIP.destination, true)
	end
end)
end)

CLIENT.LUA

local police
local medecin

RegisterNUICallback("telephone", function(data, cb)

	local action = data.action
	local newstate = data.newstate
	
	if action == "police" then
	AddEventHandler("police", function (source, user)
	drawNotification("~g~A patrol is coming, do not move!") -- Notification sent to the caller
	elseif action == "medecin" then
	drawNotification("~g~Medic is coming, dont move !")
	end
	
	cb("ok")
end)

the client are in RegisterNUICallback…

1 Like

i update my code but it doesnt work …

@Havoc check the code :wink:

You arent calling the event. You are adding another handler.

Try using TriggerClientEvent

I have updated the code but it doesnt work anyway :confused:

This part is supposed to have the event. Actually I’m not sure how your sv_phone can all those natives with then being client side