Skip to content

Commit

Permalink
Update v2.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Jul 28, 2024
1 parent 19d0253 commit 82c80fe
Show file tree
Hide file tree
Showing 13 changed files with 94 additions and 74 deletions.
7 changes: 2 additions & 5 deletions client/cl_anticombatlog.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ end

local display = function(data)
-- data.playerId, data.playerName, data.coords, data.reason

local showDisplay = true
local timeout = MSK.SetTimeout(60000, function()
showDisplay = false
Expand Down Expand Up @@ -54,7 +54,4 @@ local display = function(data)
end)
end

RegisterNetEvent('msk_core:anticombatlog')
AddEventHandler('msk_core:anticombatlog', function(data)
display(data)
end)
RegisterNetEvent('msk_core:anticombatlog', display)
12 changes: 6 additions & 6 deletions client/cl_callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ end)
MSK.Register = function(eventName, cb)
Callbacks[eventName] = cb
end
MSK.RegisterCallback = MSK.Register
MSK.RegisterClientCallback = MSK.Register
MSK.RegisterCallback = MSK.Register -- Support for old Scripts
MSK.RegisterClientCallback = MSK.Register -- Support for old Scripts
exports('Register', MSK.Register)
exports('RegisterCallback', MSK.Register)
exports('RegisterServerCallback', MSK.Register)
exports('RegisterCallback', MSK.Register) -- Support for old Scripts
exports('RegisterServerCallback', MSK.Register) -- Support for old Scripts

RegisterNetEvent('msk_core:client:triggerClientCallback', function(playerId, eventName, requestId, ...)
if not Callbacks[eventName] then
Expand Down Expand Up @@ -92,6 +92,6 @@ MSK.TriggerCallback = function(eventName, ...)
local result = Citizen.Await(p)
return table.unpack(result)
end
MSK.TriggerServerCallback = MSK.TriggerCallback
MSK.TriggerServerCallback = MSK.TriggerCallback -- Support for old Scripts
exports('TriggerCallback', MSK.TriggerCallback)
exports('TriggerServerCallback', MSK.TriggerCallback)
exports('TriggerServerCallback', MSK.TriggerCallback) -- Support for old Scripts
15 changes: 13 additions & 2 deletions client/cl_input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,20 @@ MSK.Input = function(header, placeholder, field, cb)
placeholder = placeholder,
field = field and type(field) == 'boolean'
})

if not callback or callback and type(callback) == 'boolean' then
local p = promise.new()

callback = function(response)
p:resolve(response)
end

local result = Citizen.Await(p)
return result
end
end
exports('Input', MSK.Input)
exports('openInput', MSK.Input)
exports('openInput', MSK.Input) -- Support for old Scripts

MSK.CloseInput = function()
logging('debug', 'MSK.CloseInput')
Expand All @@ -29,7 +40,7 @@ MSK.CloseInput = function()
})
end
exports('CloseInput', MSK.CloseInput)
exports('closeInput', MSK.CloseInput)
exports('closeInput', MSK.CloseInput) -- Support for old Scripts

RegisterNUICallback('submitInput', function(data)
if data.input == '' then data.input = nil end
Expand Down
11 changes: 11 additions & 0 deletions client/cl_numpad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,17 @@ MSK.Numpad = function(pin, show, cb)
EnterCode = 'Enter Code',
WrongCode = 'Incorrect',
})

if not callback then
local p = promise.new()

callback = function(response)
p:resolve(response)
end

local result = Citizen.Await(p)
return result
end
end
exports('Numpad', MSK.Numpad)

Expand Down
11 changes: 9 additions & 2 deletions client/cl_showCoords.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
local showCoords = false

RegisterNetEvent('msk_core:showCoords', function()
MSK.ShowCoords = function()
showCoords = not showCoords

if showCoords then
CreateThread(startShowCoordsThread)
end
end)
end
exports('ShowCoords', MSK.ShowCoords)
RegisterNetEvent('msk_core:showCoords', MSK.ShowCoords)

MSK.DoesShowCoords = function()
return showCoords
end
exports('DoesShowCoords', MSK.DoesShowCoords)

local DrawGenericText = function(text)
SetTextColour(186, 186, 186, 255)
Expand Down
18 changes: 8 additions & 10 deletions client/main.lua
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
MSK = {}

if Config.Framework:match('esx') then
if Config.Framework == 'esx' then
ESX = exports["es_extended"]:getSharedObject()

RegisterNetEvent('esx:setPlayerData', function(key, val)
if GetInvokingResource() == 'es_extended' then
ESX.PlayerData[key] = val
end
ESX.PlayerData[key] = val
end)

RegisterNetEvent('esx:playerLoaded', function(xPlayer)
Expand All @@ -22,7 +20,7 @@ if Config.Framework:match('esx') then
RegisterNetEvent('esx:setJob', function(job)
ESX.PlayerData.job = job
end)
elseif Config.Framework:match('qbcore') then
elseif Config.Framework == 'qbcore' then
QBCore = exports['qb-core']:GetCoreObject()

RegisterNetEvent('QBCore:Player:SetPlayerData', function(PlayerData)
Expand All @@ -40,7 +38,7 @@ MSK.Notification = function(title, message, typ, duration)
AddTextComponentSubstringPlayerName(message)
EndTextCommandThefeedPostTicker(false, true)
elseif Config.Notification == 'okok' then
exports['okokNotify']:Alert(title, message, duration or 5000, typ or 'info')
exports.okokNotify:Alert(title, message, duration or 5000, typ or 'info')
elseif Config.Notification == 'custom' then
Config.customNotification(title, message, typ or 'info', duration or 5000)
else
Expand Down Expand Up @@ -123,7 +121,7 @@ exports('ScaleformAnnounce', MSK.ScaleformAnnounce)
MSK.Subtitle = function(text, duration)
BeginTextCommandPrint('STRING')
AddTextComponentSubstringPlayerName(text)
EndTextCommandPrint(duration, true)
EndTextCommandPrint(duration or 8000, true)
end
exports('Subtitle', MSK.Subtitle)

Expand Down Expand Up @@ -164,7 +162,7 @@ end
exports('Draw3DText', MSK.Draw3DText)

MSK.HasItem = function(item)
if not Config.Framework:match('esx') and not Config.Framework:match('qbcore') then
if Config.Framework == 'standalone' then
return logging('error', ('Function %s can not used without Framework!'):format('MSK.HasItem'))
end

Expand Down Expand Up @@ -219,9 +217,9 @@ MSK.Progressbar = function(time, text, color)
color = color or Config.progressColor,
})
end
MSK.ProgressStart = MSK.Progressbar
MSK.ProgressStart = MSK.Progressbar -- Support for old Scripts
exports('Progressbar', MSK.Progressbar)
exports('ProgressStart', MSK.Progressbar)
exports('ProgressStart', MSK.Progressbar) -- Support for old Scripts

MSK.ProgressStop = function()
SendNUIMessage({
Expand Down
13 changes: 7 additions & 6 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ Config.showCoords = {
}
----------------------------------------------------------------
-- Set to 'msk' for MSK UI Notification
-- Set to 'native' for FiveM Native Notification
-- Set to 'okok' for OKOK Notification
-- Set to 'custom' for Config.customNotification()
-- Set to 'okok' for OKOK Notification
-- Set to 'native' for FiveM Native Notification
Config.Notification = 'msk'

Config.NotifyTypes = {
Expand All @@ -30,7 +30,7 @@ Config.NotifyTypes = {

Config.customNotification = function(title, message, typ, duration)
-- Set Config.Notification = 'custom'
-- Add your own clientside Notification here
-- Add your own clientside Notification here
end

Config.progressColor = "#5eb131" -- Default Color for ProgressBar
Expand All @@ -43,13 +43,14 @@ Config.LoggingTypes = {
----------------------------------------------------------------
Config.AntiCombatlog = {
enable = false, -- Set to true if you want to use this Feature

console = {
enable = false,
text = "Der Spieler ^3%s^0 mit der ^3ID %s^0 hat den Server verlassen.\n^4Uhrzeit:^0 %s\n^4Grund:^0 %s\n^4Identifier:^0\n %s\n %s\n %s\n^4Koordinaten:^0 %s"
},

discord = {
-- Webhook in sv_anticombatlog.lua
enable = false,
enable = false, -- Set true to enable DiscordLogs // Add Webhook Link in sv_anticombatlog.lua
color = "6205745", -- https://www.mathsisfun.com/hexadecimal-decimal-colors.html
botName = "MSK Scripts",
botAvatar = "https://i.imgur.com/PizJGsh.png",
Expand All @@ -62,7 +63,7 @@ Config.AntiCombatlog = {
Config.BanSystem = {
enable = false, -- Set to true if you want to use this Feature

discordLog = false, -- Set true to enable DiscordLogs // Webhook on sv_bansystem.lua
discordLog = false, -- Set true to enable DiscordLogs // Add Webhook Link in sv_bansystem.lua
botColor = "6205745", -- https://www.mathsisfun.com/hexadecimal-decimal-colors.html
botName = "MSK Scripts",
botAvatar = "https://i.imgur.com/PizJGsh.png",
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_core'
description 'Core functions for MSK Scripts'
version '2.1.5'
version '2.2.0'

lua54 'yes'

Expand Down
29 changes: 12 additions & 17 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
MSK = {}

if Config.Framework:match('esx') then
if Config.Framework == 'esx' then
ESX = exports["es_extended"]:getSharedObject()
elseif Config.Framework:match('qbcore') then
elseif Config.Framework == 'qbcore' then
QBCore = exports['qb-core']:GetCoreObject()
end

Expand Down Expand Up @@ -78,13 +78,10 @@ MSK.RegisterCommand = function(name, group, cb, console, framework, suggestion)
MSK.Notification(source, error)
end
else
if Config.Framework:match('esx') and framework then
local xPlayer = ESX.GetPlayerFromId(source)
cb(xPlayer, args, rawCommand)
elseif Config.Framework:match('qbcore') and framework then
local Player = QBCore.Functions.GetPlayer(source)
if Config.Framework ~= 'standalone' and framework then
local Player = MSK.GetPlayer({source = source})
cb(Player, args, rawCommand)
elseif Config.Framework:match('standalone') or not framework then
else
cb(source, args, rawCommand)
end
end
Expand Down Expand Up @@ -178,19 +175,17 @@ MSK.AddWebhook = function(webhook, botColor, botName, botAvatar, title, descript
end
exports('AddWebhook', MSK.AddWebhook)

MSK.HasItem = function(xPlayer, item)
if not xPlayer then logging('error', 'Player on Function MSK.HasItem does not exist!') return end
if not Config.Framework:match('esx') and not Config.Framework:match('qbcore') then
MSK.HasItem = function(Player, item)
if not Player then logging('error', 'Player on Function MSK.HasItem does not exist!') return end
if Config.Framework == 'standalone' then
return logging('error', ('Function %s can not used without Framework!'):format('^3MSK.HasItem^0'))
end
local hasItem

if Config.Framework:match('esx') then
hasItem = xPlayer.getInventoryItem(item)
elseif Config.Framework:match('qbcore') then
hasItem = xPlayer.Functions.GetItemByName(item)
else
logging('error', 'Framework on Function MSK.HasItem is not configured!')
if Config.Framework == 'esx' then
hasItem = Player.hasItem(item)
elseif Config.Framework == 'qbcore' then
hasItem = Player.Functions.GetItemByName(item)
end

return hasItem
Expand Down
22 changes: 11 additions & 11 deletions server/sv_bansystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ local formatTime = function(time)
return banTime, os.date('%d-%m-%Y %H:%M', banTime)
end

banPlayer = function(source, playerId, time, reason)
MSK.BanPlayer = function(source, playerId, time, reason)
local playerName = GetPlayerName(playerId)

if not playerName then
Expand Down Expand Up @@ -153,10 +153,10 @@ banPlayer = function(source, playerId, time, reason)
end
end)
end
MSK.BanPlayer = banPlayer
exports('banPlayer', banPlayer)
exports('BanPlayer', MSK.BanPlayer)
exports('banPlayer', MSK.BanPlayer) -- Support for old Scripts

unbanPlayer = function(source, banId)
MSK.UnbanPlayer = function(source, banId)
MySQL.query('DELETE FROM msk_bansystem WHERE id = @id', {
['@id'] = banId
}, function(response)
Expand All @@ -181,8 +181,8 @@ unbanPlayer = function(source, banId)
end
end)
end
MSK.UnbanPlayer = unbanPlayer
exports('unbanPlayer', unbanPlayer)
exports('UnbanPlayer', MSK.UnbanPlayer)
exports('unbanPlayer', MSK.UnbanPlayer) -- Support for old Scripts

AddEventHandler('playerConnecting', function(playerName, setKickReason, deferrals)
local src = source
Expand All @@ -193,7 +193,7 @@ AddEventHandler('playerConnecting', function(playerName, setKickReason, deferral
CancelEvent() -- FiveM Native Function for cancelling the currently executing event
setKickReason(('Banned by %s until %s for %s. BanID: %s'):format(isBanned.from, isBanned.time, isBanned.reason, isBanned.id))
elseif isBanned and expired then
unbanPlayer(nil, isBanned.id)
MSK.UnbanPlayer(nil, isBanned.id)
end
end)

Expand All @@ -218,10 +218,10 @@ if Config.BanSystem.enable and Config.BanSystem.commands.enable then

if not playerId or not time then return end
if not reason then reason = 'Unknown' end
if src == 0 then return banPlayer(nil, playerId, time, reason) end
if src == 0 then return MSK.BanPlayer(nil, playerId, time, reason) end

if isAllowed(src) then
banPlayer(src, playerId, time, reason)
MSK.BanPlayer(src, playerId, time, reason)
else
Config.Notification(src, 'You don\'t have permission to do that!')
end
Expand All @@ -232,10 +232,10 @@ if Config.BanSystem.enable and Config.BanSystem.commands.enable then
local banId = args[1]

if not banId then return end
if src == 0 then return unbanPlayer(nil, banId) end
if src == 0 then return MSK.UnbanPlayer(nil, banId) end

if isAllowed(src) then
unbanPlayer(src, banId)
MSK.UnbanPlayer(src, banId)
else
Config.Notification(src, 'You don\'t have permission to do that!')
end
Expand Down
16 changes: 8 additions & 8 deletions server/sv_callback.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ local CallbackHandler = {}
MSK.Register = function(eventName, cb)
Callbacks[eventName] = cb
end
MSK.RegisterCallback = MSK.Register
MSK.RegisterServerCallback = MSK.Register
MSK.RegisterCallback = MSK.Register -- Support for old Scripts
MSK.RegisterServerCallback = MSK.Register -- Support for old Scripts
exports('Register', MSK.Register)
exports('RegisterCallback', MSK.Register)
exports('RegisterServerCallback', MSK.Register)
exports('RegisterCallback', MSK.Register) -- Support for old Scripts
exports('RegisterServerCallback', MSK.Register) -- Support for old Scripts

RegisterNetEvent('msk_core:server:triggerCallback', function(eventName, requestId, cb, ...)
local playerId = source
Expand Down Expand Up @@ -66,11 +66,11 @@ MSK.Trigger = function(eventName, playerId, ...)
local result = Citizen.Await(p)
return table.unpack(result)
end
MSK.TriggerCallback = MSK.Trigger
MSK.TriggerClientCallback = MSK.Trigger
MSK.TriggerCallback = MSK.Trigger -- Support for old Scripts
MSK.TriggerClientCallback = MSK.Trigger -- Support for old Scripts
exports('Trigger', MSK.Trigger)
exports('TriggerCallback', MSK.Trigger)
exports('TriggerClientCallback', MSK.Trigger)
exports('TriggerCallback', MSK.Trigger) -- Support for old Scripts
exports('TriggerClientCallback', MSK.Trigger) -- Support for old Scripts

RegisterNetEvent("msk_core:server:callbackResponse", function(requestId, ...)
if not CallbackHandler[requestId] then return end
Expand Down
Loading

0 comments on commit 82c80fe

Please sign in to comment.