Перейти к содержанию

Важные функции и переменные

Этот раздел описывает основные функции и переменные, используемые или предоставляемые скриптом. Понимание этих элементов поможет вам настроить или интегрировать скрипт с другими ресурсами.

Уведомления: Добавление системы уведомлений

Раздел с заголовком «Уведомления: Добавление системы уведомлений»
LaughGrenade = LaughGrenade or {}
function LaughGrenade.Notify(message, nType, duration)
if not Config.SendNotification then return end
nType = nType or "info"
duration = duration or Config.NotifyDuration or 5000
local title = Config.NotifyTitle or "Laugh Grenade"
local notifyType = Config.Notify or "default"
if notifyType == "mythic_notify" then
exports['mythic_notify']:SendAlert(nType, message, duration)
elseif notifyType == "k5_notify" then
exports['k5_notify']:notify(message, nType, duration)
elseif notifyType == "FL-Notify" then
exports['FL-Notify']:Notify({
title = title,
message = message,
type = nType,
duration = duration
})
elseif notifyType == "dillen-notifications" then
exports['dillen-notifications']:Notify({
title = title,
message = message,
type = nType,
duration = duration
})
elseif notifyType == "noxen_notify" then
exports['noxen_notify']:Alert(message, nType, duration)
elseif notifyType == "wasabi_notify" then
exports.wasabi_notify:notify(nType, title, message, duration)
elseif notifyType == "ox_lib" then
exports['ox_lib']:notify({
title = title,
description = message,
type = nType,
duration = duration
})
elseif notifyType == "custom" and type(Config.CustomNotify) == "function" then
Config.CustomNotify(message, nType, duration)
else
if type(Config.CustomNotify) == "function" then
Config.CustomNotify(message, nType, duration)
else
BeginTextCommandDisplayHelp("STRING")
AddTextComponentSubstringPlayerName(message)
EndTextCommandDisplayHelp(0, false, true, duration)
end
end
if Config.Debug then
print("[LAUGH NOTIFY] " .. message .. " (type: " .. nType .. ")")
end
end

Этот код создан для отображения уведомлений для разных скриптов уведомлений. Если у вас есть другой скрипт уведомлений, добавьте его либо в раздел custom, либо добавьте ещё один elseif. (Не забудьте добавить необходимые элементы в файл конфигурации в разделе Config.Notify (config.lua)).


function PlayGrenadeSound(coords)
if Config.Sound.url == "" then return end
if Config.SoundSystem == "xsound" then
exports['xsound']:PlayUrlPos('laugh_grenade_' .. GetGameTimer(), Config.Sound.url, Config.Sound.volume, coords, false)
elseif Config.SoundSystem == "interact_sound" then
TriggerServerEvent('InteractSound_SV:PlayOnSource', 'laugh_grenade', Config.Sound.volume)
elseif Config.SoundSystem == "evo_sound" then
exports['evo_sound']:PlayUrl('laugh_grenade', Config.Sound.url, Config.Sound.volume)
end
end

Этот код создан для воспроизведения звука с помощью звуковой системы, установленной на вашем сервере. Если у вас есть другой звуковой скрипт, добавьте его либо в раздел custom, либо добавьте еще один elseif. (Не забудьте добавить необходимые элементы в файл конфигурации в разделе Config.SoundSystem (config.lua)).