Skip to content

Commit

Permalink
Update v1.9.1
Browse files Browse the repository at this point in the history
* Added exports for all functions
* Added MSK.GetPedMugshot
  • Loading branch information
Musiker15 committed Aug 18, 2023
1 parent 8c6a4c9 commit 9a3929f
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 28 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.9
1.9.1
16 changes: 14 additions & 2 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@ elseif Config.Framework:match('qbcore') then
QBCore = exports['qb-core']:GetCoreObject()
end

MSK.RegisterCallback = function(name, cb)
MSK.RegisterClientCallback = function(name, cb)
Callbacks[name] = cb
end
MSK.RegisterCallback = MSK.RegisterClientCallback
exports('RegisterClientCallback', RegisterClientCallback)

MSK.TriggerCallback = function(name, ...)
MSK.TriggerServerCallback = function(name, ...)
local requestId = GenerateRequestKey(callbackRequest)
local response

Expand All @@ -26,6 +28,8 @@ MSK.TriggerCallback = function(name, ...)

return table.unpack(response)
end
MSK.TriggerCallback = MSK.TriggerServerCallback
exports('TriggerServerCallback', TriggerServerCallback)

MSK.Notification = function(title, message, info, time)
if Config.Notification == 'native' then
Expand All @@ -44,12 +48,14 @@ MSK.Notification = function(title, message, info, time)
exports['okokNotify']:Alert(title, message, time or 5000, info or 'info')
end
end
exports('Notification', Notification)

MSK.HelpNotification = function(text)
SetTextComponentFormat('STRING')
AddTextComponentString(text)
DisplayHelpTextFromStringLabel(0, 0, 1, -1)
end
exports('HelpNotification', HelpNotification)

MSK.AdvancedNotification = function(text, title, subtitle, icon, flash, icontype)
if not flash then flash = true end
Expand All @@ -61,6 +67,7 @@ MSK.AdvancedNotification = function(text, title, subtitle, icon, flash, icontype
SetNotificationMessage(icon, icon, flash, icontype, title, subtitle)
DrawNotification(false, true)
end
exports('AdvancedNotification', AdvancedNotification)

MSK.Draw3DText = function(coords, text, size, font)
local coords = type(coords) == "vector3" and coords or vec(coords.x, coords.y, coords.z)
Expand All @@ -85,6 +92,7 @@ MSK.Draw3DText = function(coords, text, size, font)
EndTextCommandDisplayText(0.0, 0.0)
ClearDrawOrigin()
end
exports('Draw3DText', Draw3DText)

MSK.HasItem = function(item)
if not Config.Framework:match('esx') or Config.Framework:match('qbcore') then
Expand All @@ -95,6 +103,7 @@ MSK.HasItem = function(item)
local hasItem = MSK.TriggerCallback('msk_core:hasItem', item)
return hasItem
end
exports('HasItem', HasItem)

MSK.GetVehicleInDirection = function()
local playerPed = PlayerPedId()
Expand All @@ -111,6 +120,7 @@ MSK.GetVehicleInDirection = function()

return nil
end
exports('GetVehicleInDirection', GetVehicleInDirection)

MSK.IsVehicleEmpty = function(vehicle)
if not vehicle or (vehicle and not DoesEntityExist(vehicle)) then return end
Expand All @@ -119,6 +129,7 @@ MSK.IsVehicleEmpty = function(vehicle)

return passengers == 0 and driverSeatFree
end
exports('IsVehicleEmpty', IsVehicleEmpty)

MSK.GetPedMugshot = function(ped, transparent)
if not DoesEntityExist(ped) then return end
Expand All @@ -130,6 +141,7 @@ MSK.GetPedMugshot = function(ped, transparent)

return mugshot, GetPedheadshotTxdString(mugshot)
end
exports('GetPedMugshot', GetPedMugshot)

GenerateRequestKey = function(tbl)
local id = string.upper(MSK.GetRandomString(3)) .. math.random(000, 999) .. string.upper(MSK.GetRandomString(2)) .. math.random(00, 99)
Expand Down
1 change: 1 addition & 0 deletions client/client_input.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ closeInput = function()
SetNuiFocus(false, false)
isOpen = false
end
MSK.CloseInput = closeInput
exports('closeInput', closeInput)

RegisterNUICallback('closeInput', function(data)
Expand Down
18 changes: 0 additions & 18 deletions client/client_progress.lua

This file was deleted.

19 changes: 16 additions & 3 deletions common/common.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,18 @@ MSK.GetRandomString = function(length)
end
end
MSK.GetRandomLetter = MSK.GetRandomString
exports('GetRandomString', GetRandomString)

MSK.Round = function(num, decimal)
return tonumber(string.format("%." .. (decimal or 0) .. "f", num))
end
exports('Round', Round)

MSK.Trim = function(str, bool)
if bool then return (str:gsub("^%s*(.-)%s*$", "%1")) end
return (str:gsub("%s+", ""))
end
exports('Trim', Trim)

MSK.Split = function(str, delimiter)
local result = {}
Expand All @@ -32,8 +35,9 @@ MSK.Split = function(str, delimiter)

return result
end
exports('Split', Split)

MSK.Table_Contains = function(table, value)
MSK.TableContains = function(table, value)
if type(value) == 'table' then
for k, v in pairs(table) do
for k2, v2 in pairs(value) do
Expand All @@ -51,6 +55,8 @@ MSK.Table_Contains = function(table, value)
end
return false
end
MSK.Table_Contains = MSK.TableContains
exports('TableContains', TableContains)

MSK.Comma = function(int, tag)
if not tag then tag = '.' end
Expand All @@ -66,9 +72,10 @@ MSK.Comma = function(int, tag)

return newInt
end
exports('Comma', Comma)

local Timeout = 0
MSK.AddTimeout = function(ms, cb)
MSK.SetTimeout = function(ms, cb)
local requestId = Timeout + 1

SetTimeout(ms, function()
Expand All @@ -79,11 +86,14 @@ MSK.AddTimeout = function(ms, cb)
Timeout = requestId
return requestId
end
MSK.AddTimeout = MSK.SetTimeout
exports('SetTimeout', SetTimeout)

MSK.DelTimeout = function(requestId)
if not requestId then return end
Timeouts[requestId] = true
end
exports('DelTimeout', DelTimeout)

MSK.DumpTable = function(tbl, n)
if not n then n = 0 end
Expand All @@ -100,8 +110,9 @@ MSK.DumpTable = function(tbl, n)

return s .. '}'
end
exports('DumpTable', DumpTable)

MSK.logging = function(code, ...)
MSK.Logging = function(code, ...)
local script = "[^2"..GetInvokingResource().."^0]"

if not MSK.Table_Contains({'error', 'debug', 'info'}, code) then
Expand All @@ -127,6 +138,8 @@ MSK.logging = function(code, ...)
end
end
end
MSK.logging = MSK.Logging
exports('Logging', Logging)

exports('getConfig', function()
return Config
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 '1.9'
version '1.9.1'

lua54 'yes'

Expand Down
13 changes: 11 additions & 2 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ elseif Config.Framework:match('qbcore') then
QBCore = exports['qb-core']:GetCoreObject()
end

MSK.RegisterCallback = function(name, cb)
MSK.RegisterServerCallback = function(name, cb)
Callbacks[name] = cb
end
MSK.RegisterCallback = MSK.RegisterServerCallback
exports('RegisterServerCallback', RegisterServerCallback)

MSK.TriggerCallback = function(name, playerId, ...)
MSK.TriggerClientCallback = function(name, playerId, ...)
local requestId = GenerateRequestKey(callbackRequest)
local response

Expand All @@ -34,6 +36,8 @@ MSK.TriggerCallback = function(name, playerId, ...)

return table.unpack(response)
end
MSK.TriggerCallback = MSK.TriggerClientCallback
exports('TriggerClientCallback', TriggerClientCallback)

MSK.RegisterCommand = function(name, group, cb, console, framework, suggestion)
if type(name) == 'table' then
Expand Down Expand Up @@ -120,16 +124,19 @@ MSK.RegisterCommand = function(name, group, cb, console, framework, suggestion)
ExecuteCommand(('add_ace group.%s command.%s allow'):format(group, name))
end
end
exports('RegisterCommand', RegisterCommand)

MSK.Notification = function(src, title, message, info, time)
if not src or src == 0 then return end
TriggerClientEvent('msk_core:notification', src, title, message, info, time)
end
exports('Notification', Notification)

MSK.AdvancedNotification = function(src, text, title, subtitle, icon, flash, icontype)
if not src or src == 0 then return end
TriggerClientEvent('msk_core:advancedNotification', src, text, title, subtitle, icon, flash, icontype)
end
exports('AdvancedNotification', AdvancedNotification)

MSK.AddWebhook = function(webhook, botColor, botName, botAvatar, title, description, fields, footer, time)
local content = {}
Expand Down Expand Up @@ -173,6 +180,7 @@ MSK.AddWebhook = function(webhook, botColor, botName, botAvatar, title, descript
['Content-Type'] = 'application/json'
})
end
exports('AddWebhook', AddWebhook)

MSK.HasItem = function(xPlayer, item)
if not xPlayer then logging('error', 'Player on Function MSK.HasItem does not exist!') return end
Expand All @@ -192,6 +200,7 @@ MSK.HasItem = function(xPlayer, item)

return hasItem
end
exports('HasItem', HasItem)

MSK.RegisterCallback('msk_core:hasItem', function(source, cb, item)
local src = source
Expand Down
4 changes: 3 additions & 1 deletion server/server_player.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ MSK.GetPlayer = function(player)

return Player
end
exports('GetPlayer', GetPlayer)

MSK.GetPlayers = function(key, val)
local Players
Expand Down Expand Up @@ -67,4 +68,5 @@ MSK.GetPlayers = function(key, val)
end

return Players
end
end
exports('GetPlayers', GetPlayers)

0 comments on commit 9a3929f

Please sign in to comment.