hello I am looking for someone who can script an alert message that when an online player steals a car the alert comes up in the chat with vehicle name and last known location. plz message if you can!
Sounds like a much needed script… very cool
Not tested
Client side:
Citizen.CreateThread( function()
while true do
Wait(0)
local male = IsPedMale(GetPlayerPed(-1))
if male then
sex = "men"
elseif not male then
sex = "women"
end
local plyPos = GetEntityCoords(GetPlayerPed(-1), true)
local s1, s2 = Citizen.InvokeNative( 0x2EB41072B4C1E4C0, plyPos.x, plyPos.y, plyPos.z, Citizen.PointerValueInt(), Citizen.PointerValueInt() )
local street1 = GetStreetNameFromHashKey(s1)
local street2 = GetStreetNameFromHashKey(s2)
if IsPedTryingToEnterALockedVehicle(GetPlayerPed(-1)) or IsPedJacking(GetPlayerPed(-1)) then
local veh = GetVehiclePedIsTryingToEnter(GetPlayerPed(-1))
local vehName = GetDisplayNameFromVehicleModel(GetEntityModel(veh))
local vehName2 = GetLabelText(vehName)
if s2 == 0 then
TriggerServerEvent('thiefInProgressS1', street1, vehName2, sex)
elseif s2 ~= 0 then
TriggerServerEvent('thiefInProgress', street1, street2, vehName2, sex)
end
Wait(5000)
end
end
end)
Citizen.CreateThread( function()
while true do
Wait(0)
local male = IsPedMale(GetPlayerPed(-1))
if male then
sex = "men"
elseif not male then
sex = "women"
end
local plyPos = GetEntityCoords(GetPlayerPed(-1), true)
local s1, s2 = Citizen.InvokeNative( 0x2EB41072B4C1E4C0, plyPos.x, plyPos.y, plyPos.z, Citizen.PointerValueInt(), Citizen.PointerValueInt() )
local street1 = GetStreetNameFromHashKey(s1)
local street2 = GetStreetNameFromHashKey(s2)
if IsPedShooting(GetPlayerPed(-1)) then
if s2 == 0 then
TriggerServerEvent('gunshotInProgressS1', street1, sex)
elseif s2 ~= 0 then
TriggerServerEvent("gunshotInProgress", street1, street2, sex)
end
Wait(3000)
end
end
end)
Server side:
RegisterServerEvent('thiefInProgress')
AddEventHandler('thiefInProgress', function(street1, street2, veh, sex)
if veh == "NULL" then
TriggerClientEvent("chatMessage", -1, '', { 0, 0, 0 }, "^1Thief of a vehicle by a ^0"..sex.." ^1between ^0"..street1.."^1 and ^0"..street2)
else
TriggerClientEvent("chatMessage", -1, '', { 0, 0, 0 }, "^1Thief of a ^0"..veh.." ^1by a ^0"..sex.." ^1between ^0"..street1.."^1 and ^0"..street2)
end
end)
RegisterServerEvent('thiefInProgressS1')
AddEventHandler('thiefInProgressS1', function(street1, veh, sex)
if veh == "NULL" then
TriggerClientEvent("chatMessage", -1, '', { 0, 0, 0 }, "^1Thief of a vehicle by a ^0"..sex.." ^1at ^0"..street1)
else
TriggerClientEvent("chatMessage", -1, '', { 0, 0, 0 }, "^1Thief of a ^0"..veh.." ^1by a ^0"..sex.." ^1at ^0"..street1)
end
end)
RegisterServerEvent('gunshotInProgress')
AddEventHandler('gunshotInProgress', function(street1, street2, sex)
TriggerClientEvent("chatMessage", -1, '', { 0, 0, 0 }, "^1Gunshot by a ^0"..sex.." ^1between ^0"..street1.."^1 and ^0"..street2)
end)
RegisterServerEvent('gunshotInProgressS1')
AddEventHandler('gunshotInProgressS1', function(street1, sex)
TriggerClientEvent("chatMessage", -1, '', { 0, 0, 0 }, "^1Gunshot by a ^0"..sex.." ^1at ^0"..street1)
end)
Should work.
ill try it and see …
@nynjardin works if i change IsPedTryingToEnterALockedVehicle(GetPlayerPed(-1)) TO
IsPedJacking(GetPlayerPed(-1)) But it spams the chat four times when there is a cross street. If there is no cross street it spams nine times. This could be used as a wanted level alert as well. But with the chat spam its really not usable.
This worked for me. Thank you
Ok, there is a simple way to sovle it, client side:
local jacking = false
Citizen.CreateThread( function()
while true do
Wait(0)
local plyPos = GetEntityCoords(GetPlayerPed(-1), true)
local s1, s2 = Citizen.InvokeNative( 0x2EB41072B4C1E4C0, plyPos.x, plyPos.y, plyPos.z, Citizen.PointerValueInt(), Citizen.PointerValueInt() )
local street1 = GetStreetNameFromHashKey(s1)
local street2 = GetStreetNameFromHashKey(s2)
if IsPedJacking(GetPlayerPed(-1)) then
if not jacking then
jacking = true
TriggerServerEvent('thiefInProgress', street1, street2)
Wait(1000)
jacking = false
end
end
end
end)
You don’t forget the first line of the new script ? And you have to keep the server side script
@nynjardin I didn’t change server side, and i have put the entire client side in. I’m not using essential mode, if that makes a difference.
OK, I’m on my phone right now, I’ll have a look when I come back home.
no problem. no rush. i appreciate the help. I’ll be heading to bed soon. lua is a learning process and i have become a sponge. I wanna soak up as much as i can. I come home from work and hop on the PC, i don’t get off till the sun comes up most times. EDIT: it wasnt showing any chat, now it is. but its still spamming chat. And im unable to change the color. not with { 255, 0, 0 }, or ~r~ or ^1.
Ok, that work for me:
Client:
local jacking = false
Citizen.CreateThread( function()
while true do
Wait(0)
local plyPos = GetEntityCoords(GetPlayerPed(-1), true)
local s1, s2 = Citizen.InvokeNative( 0x2EB41072B4C1E4C0, plyPos.x, plyPos.y, plyPos.z, Citizen.PointerValueInt(), Citizen.PointerValueInt() )
local street1 = GetStreetNameFromHashKey(s1)
local street2 = GetStreetNameFromHashKey(s2)
if IsPedJacking(GetPlayerPed(-1)) or IsPedTryingToEnterALockedVehicle(GetPlayerPed(-1)) then
if not jacking then
jacking = true
TriggerServerEvent('thiefInProgress', street1, street2)
Wait(5000)
jacking = false
end
end
end
end)
Server:
RegisterServerEvent('thiefInProgress')
AddEventHandler('thiefInProgress', function(street1, street2)
if street1 ~= 0 and street2 ~= 0 then
TriggerClientEvent("chatMessage", -1, '', { 0, 0, 0 }, "^1Thief in progress between ^0"..street1.."^1 and ^0"..street2)
elseif not street2 then
TriggerClientEvent("chatMessage", -1, '', { 0, 0, 0 }, "^1Thief in progress at ^0"..street1)
end
end)
For now, I don’t found how to don’t show street2 if street2 don’t exist, but the code work well with color and no spam!
https://gyazo.com/c7f8f6ffbf03a8a21476cad7c05aa719
Thanks works perfect when your in intersection, but when your on main road it will say street and. in chat… anyway to fix that part other then that perfect!
Yes, I’ll try to fix it as soon as possible
how can we ad thise AddBlipForEntity so that a blip appears?
For better visibility, I have edited my first code with this bug fixed.
Also, I don’t know why, the game take time to “see” that player try to enter locked vehicle, so, when yuou try to enter passenger side, that work, but if you try to enter driver side, that don’t work…
@stevenkrause84 Adding blip ask more code because is particulary capricious because you can’t erase a blip… you ask me in private message if a marker can be set on car stolen, yep, I will add it later.
I have created a new post in “Releases” forum with the script, I will update it regulary with new features