sobo
December 10, 2017, 7:28pm
1
client
RegisterNetEvent("TrafficStop")
AddEventHandler("TrafficStop",function()
local PedModels = {
"s_m_y_cop_01",
's_m_m_snowcop_01',
's_m_y_hwaycop_01',
's_f_y_cop_01',
's_m_y_sheriff_01',
's_f_y_sheriff_01',
's_m_y_ranger_01',
's_m_m_armoured_01',
's_m_m_armoured_02',
's_f_y_ranger_01',
's_m_m_ciasec_01',
'u_m_m_fibarchitect',
's_m_y_swat_01',
's_m_y_blackops_01',
's_m_y_blackops_02',
's_m_y_blackops_03',
's_m_y_hwaycop_01',
'u_m_m_doa_01',
}
local ped = PlayerPedId()
local x,y,z = table.unpack(GetEntityCoords(ped, false))
local streetName, crossing = GetStreetNameAtCoord(x, y, z)
streetName = GetStreetNameFromHashKey(streetName)
local message = ""
if crossing ~= nil then
crossing = GetStreetNameFromHashKey(crossing)
message = "^1" .. GetPlayerName(source) .. " is Traffic at ^3" .. streetName .. " ^1and ^3" .. crossing .. " ^1no asst required."
else
message = "^1" .. GetPlayerName(source) .. " is Traffic at ^3" .. streetName .. " ^1no asst required."
end
TriggerServerEvent('TrafficStop', message)
end, false)
and server
AddEventHandler('chatMessage', function(message)
if message == "/ts" then
CancelEvent()
TriggerClientEvent("TrafficStop", from)
end
end)
any ideas, not working at all.
lifevg
December 10, 2017, 8:27pm
2
If im not mistaken having a comma on the last entry there will make it not work⦠Also any errors in the log?
sobo
December 10, 2017, 10:28pm
3
Ill check my errors, when I did the command it just said command entered with no output
Havoc
December 10, 2017, 10:32pm
4
sobo:
from
Wtf is āfromā?? It doesnāt exist. Thatās your problem.
3 Likes
sobo
December 11, 2017, 12:48am
5
i dont know, it was from another script, however i changed that to match āmessageā and i still get nothing. No errors, just says command ts entered
Havoc
December 11, 2017, 1:02am
6
TriggerClientEvent requires an integer as the second argument. This is the player whom you want to trigger the event on.
https://wiki.fivem.net/wiki/TriggerClientEvent
Edit: on server events thereās a variable āsourceā which is the ID of the player.
sobo
December 11, 2017, 1:24am
7
so would it look like this?
AddEventHandler('chatMessage', function(message)
if message == "/ts" then
CancelEvent()
TriggerClientEvent("TrafficStop", -1, message)
end
end)
And should the it be triggerserverevent or the way i have it?
HST
December 11, 2017, 1:51am
8
-1 will send message to all players on server. Use source instead.
sobo
December 11, 2017, 4:26am
10
Still not working, says command ts entered⦠I dont get this shit
Youāre trying to call the server event āTrafficStopā.
From the code youāve shown you only have a client event, not a server one.
Also, what is that list of ped models used for? Itās not being used at all in the code.
sobo
December 11, 2017, 7:11pm
12
the peds are there so that the person making the /ts are the only one. I will change the serverevent to client and see if that works
sobo
December 11, 2017, 7:57pm
13
ok so i took the code that was given in the panic emergency code, however i want to have that list of peds for people to use it and see it and way you can help with that