Problem with my phone for police job

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:

	if action == "police" then
	if LOADOUTS == "police" then
    Citizen.CreateThread(function()
    while true do
      Wait(3)
      DisplayCash(false);
      SetNotificationTextEntry("STRING");
      AddTextComponentString("^2"..GetPlayerName(source).. ", à besoin de Policier, un marqueur a été ajouter" ); -- Message sent to Police
      BLIP.destination = AddBlipForCoord "..GetPlayerName(source).." -- generate a blip to the caller
      SetBlipSprite(BLIP.destination, 1)
      SetBlipColour(BLIP.destination, 2)
      SetBlipRoute(BLIP.destination, true)
      SetNotificationMessage("CHAR_CHAT_CALL", "CHAR_CHAT_CALL", true, 1, "Demande de Policier"); -- Title of the request sent to Police
      DrawNotification(false, true);
      Wait(10000000)
      drawNotification("~g~A patrol was sent, do not move!")
1 Like

You should look into sending a event through the server to another player.
https://wiki.fivem.net/wiki/Developing

Its not a message with the chat its a notification and a marker/marker

I have updated my code… but it doesnt work anyone (its the complete file :slight_smile: )

local police

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

	local action = data.action
	local newstate = data.newstate
	
	if action == "police" and LOADOUTS == "police" then
      Wait(3)
      DisplayCash(false);
      SetNotificationTextEntry("STRING");
      AddTextComponentString("^2"..GetPlayerName(source).. ", à besoin de Policier, un marqueur a été ajouter" ); -- Message sent to Police
      BLIP.destination = AddBlipForChar"..GetPlayerName(source).." -- generate a blip to the caller
      SetBlipSprite(BLIP.destination, 1)
      SetBlipColour(BLIP.destination, 2)
      SetBlipRoute(BLIP.destination, true)
      SetNotificationMessage("CHAR_CHAT_CALL", "CHAR_CHAT_CALL", true, 1, "Demande de Policier"); -- Title of the request sent to Police
      DrawNotification(false, true);
      Wait(10000000)
	drawNotification("~g~A patrol was sent, do not move!")
	end
	
	cb("ok")

end)

what is the native for have the blip to the caller ??

I have re-updated my code :stuck_out_tongue: but it doesnt work :triumph:

	if action == "police" then
    Citizen.CreateThread(function()
    while true do and LOADOUTS == "police" then
	  Wait(3)
      DisplayCash(false);
      SetNotificationTextEntry("STRING");
      AddTextComponentString("^2"..GetPlayerName(source).. ", à besoin de Policier, un marqueur a été ajouter" ); -- Message sent to Police
      SetNotificationMessage("CHAR_CHAT_CALL", "CHAR_CHAT_CALL", true, 1, "Demande de Policier"); -- Title of the request sent to Police
      DrawNotification(false, true);
      Wait(10000000)
	  BLIP.destination = AddBlipForChar " ..GetPlayerName(source).. " -- generate a blip to the caller
      SetBlipSprite(BLIP.destination, 1)
      SetBlipColour(BLIP.destination, 2)
      SetBlipRoute(BLIP.destination, true)
end
	  drawNotification("~g~Une patrouille a été envoyé, ne bougez pas !") -- Notification sent to the caller
end)

now that would sound cool if you can get it working

That’s not valid syntax in LUA. If you want a while loop to continue when two things are true, you need to do
while {experssion 1} and {experssion 2} do and not what you put,
while {experssion 1} do and {experssion 2} then.

As I can’t see all of your code, I have to ask. Where are you setting “LOADOUTS” and are you sure it’s being set to “police”?

I… I don’t think that’s how that works… As far as I know, there’s only 4 Blip functions:

AddBlipForRadius(x, y, z, radius)
AddBlipForPickup(p0)
AddBlipForEntity(entity)
AddBlipForCoord(x, y, z)

Also, again as I can’t see all of the code. Are you initializing “BLIP” to a table? If not, I’m fairly certain this assignment won’t work.

thx ^^ :slight_smile: the loadouts is in the loadouts job addon in the loadouts.lua and i have

LOADOUTS =  {
    ["police"] = {
        name = "Policier",
        command = "police",
        weapons = { "" },
        skins = { "s_m_y_cop_01", "s_f_y_cop_01" },
        permission_level = 0,
		pos = {
        x = 425.661285400391,
        y = -976.179565429688,
        z = 32.8691062927246
	}
    },

and for the BLIP it is the blip to the caller but idk what is the function…

I send the full code :slight_smile: https://pastebin.com/wagPPk5s

I plan to make the continuation(for the doctor, taxi…) after having ended “police”

In same time can u verify my other post with ur addon ? :stuck_out_tongue: for add the name of the job below the money :slight_smile:

I have updated the code… check my new post pls (the code doesnt work any)