QBCore = exports['qb-core']:GetCoreObject() local canAdvertise = true if Config.AllowPlayersToClearTheirChat then RegisterCommand(Config.ClearChatCommand, function(source, args, rawCommand) TriggerClientEvent('chat:client:ClearChat', source) end) end if Config.AllowStaffsToClearEveryonesChat then RegisterCommand(Config.ClearEveryonesChatCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local time = os.date(Config.DateFormat) if isAdmin(source) then TriggerClientEvent('chat:client:ClearChat', -1) TriggerClientEvent('chat:addMessage', -1, { template = '
SYSTEM {0}
Chatten blev tømt!
', args = { time } }) end end) end if Config.EnableStaffCommand then RegisterCommand(Config.StaffCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.StaffCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name if isAdmin(source) then TriggerClientEvent('chat:addMessage', -1, { template = '
[STAFF] {0} {2}
{1}
', args = { playerName, message, time } }) end end) end if Config.EnableStaffOnlyCommand then RegisterCommand(Config.StaffOnlyCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.StaffOnlyCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name if isAdmin(source) then showOnlyForAdmins(function(admins) TriggerClientEvent('chat:addMessage', admins, { template = '
[STAFF ONLY] {0} {2}
{1}
', args = { playerName, message, time } }) end) end end) end if Config.EnableAdvertisementCommand then RegisterCommand(Config.AdvertisementCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.AdvertisementCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name local bankMoney = xPlayer.PlayerData.money.bank if canAdvertise then if bankMoney >= Config.AdvertisementPrice then xPlayer.Functions.RemoveMoney('bank', Config.AdvertisementPrice) TriggerClientEvent('chat:addMessage', -1, { template = '', args = { playerName, message, time } }) QBCore.Functions.Notify(source, "Du sendte en reklame for "..Config.AdvertisementPrice..',-', 'success', 5000) local time = Config.AdvertisementCooldown * 60 local pastTime = 0 canAdvertise = false while (time > pastTime) do Citizen.Wait(1000) pastTime = pastTime + 1 timeLeft = time - pastTime end canAdvertise = true else QBCore.Functions.Notify(source, "Du har ikke nok penge på banken!", "error", 5000) end else QBCore.Functions.Notify(source, "Du skal lige vente lidt!", "error", 5000) end end) end if Config.EnableTwitchCommand then RegisterCommand(Config.TwitchCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.TwitchCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name local twitch = twitchPermission(source) if twitch then TriggerClientEvent('chat:addMessage', -1, { template = '
{0} {2}
{1}
', args = { playerName, message, time } }) end end) end function twitchPermission(id) for k,v in ipairs(Config.TwitchList) do for k,x in ipairs(GetPlayerIdentifiers(id)) do if string.lower(x) == string.lower(v) then return true end end end return false end if Config.EnableYoutubeCommand then RegisterCommand(Config.YoutubeCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.YoutubeCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name local youtube = youtubePermission(source) if youtube then TriggerClientEvent('chat:addMessage', -1, { template = '
{0} {2}
{1}
', args = { playerName, message, time } }) end end) end function youtubePermission(id) for k,v in ipairs(Config.YoutubeList) do for k,x in ipairs(GetPlayerIdentifiers(id)) do if string.lower(x) == string.lower(v) then return true end end end return false end if Config.EnableTwitterCommand then RegisterCommand(Config.TwitterCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.TwitterCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name TriggerClientEvent('chat:addMessage', -1, { template = '
{0} {2}
{1}
', args = { playerName, message, time } }) end) end if Config.EnablePoliceCommand then RegisterCommand(Config.PoliceCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.PoliceCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name local job = xPlayer.PlayerData.job.name if job == Config.PoliceJobName then TriggerClientEvent('chat:addMessage', -1, { template = '
{0} {2}
{1}
', args = { playerName, message, time } }) end end) end if Config.EnableAmbulanceCommand then RegisterCommand(Config.AmbulanceCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.AmbulanceCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name local job = xPlayer.PlayerData.job.name if job == Config.AmbulanceJobName then TriggerClientEvent('chat:addMessage', -1, { template = '
{0} {2}
{1}
', args = { playerName, message, time } }) end end) end if Config.EnableOOCCommand then RegisterCommand(Config.OOCCommand, function(source, args, rawCommand) local xPlayer = QBCore.Functions.GetPlayer(source) local length = string.len(Config.OOCCommand) local message = rawCommand:sub(length + 1) local time = os.date(Config.DateFormat) playerName = xPlayer.PlayerData.name TriggerClientEvent('chat:ooc', -1, source, playerName, message, time) end) end function isAdmin(xPlayer) for k,v in ipairs(Config.StaffGroups) do if QBCore.Functions.GetPermission(xPlayer) == v then return true end end return false end function showOnlyForAdmins(admins) for _,v in ipairs(QBCore.Functions.GetPlayers()) do for _,x in ipairs(Config.StaffGroups) do if QBCore.Functions.GetPermission(v) == x then admins(v) end end end end