-
Notifications
You must be signed in to change notification settings - Fork 0
/
veh_sv.lua
42 lines (34 loc) · 1.56 KB
/
veh_sv.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
-- Made by C3
-- FIXED
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
-- Discord Webhook URL
local discordWebhook = "YOUR_DISCORD_WEBHOOK_URL_HERE"
-- Function to send a Discord webhook message
function SendDiscordWebhook(message)
if discordWebhook ~= "" then
PerformHttpRequest(discordWebhook, function(err, text, headers) end, 'POST', json.encode({content = message}), { ['Content-Type'] = 'application/json' })
end
end
-- Event triggered when an entity is damaged
AddEventHandler('entityDamaged', function(entity, damageData)
if DoesEntityExist(entity) and IsEntityAVehicle(entity) then
local health = GetEntityHealth(entity)
if health <= 0 then
local plate = ESX.Game.GetVehicleProperties(entity).plate
if plate then
local xPlayer = ESX.GetPlayerFromIdentifier(ESX.GetPlayerIdentifier(source))
if xPlayer then
ESX.Game.DeleteVehicle(entity)
xPlayer.showNotification("Your vehicle has been destroyed and deleted.")
-- Notify the Discord server
local playerName = xPlayer.getName()
local vehicleModel = GetDisplayNameFromVehicleModel(GetEntityModel(entity))
local message = string.format("%s's vehicle (%s) has been destroyed and deleted.", playerName, vehicleModel)
SendDiscordWebhook(message)
end
end
end
end
end)
print("Made by C3 for FG!")