Skip to content

Commit

Permalink
Update v2.7.3
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Nov 16, 2024
1 parent d4d7233 commit 014b6ed
Show file tree
Hide file tree
Showing 16 changed files with 353 additions and 104 deletions.
37 changes: 0 additions & 37 deletions client/functions/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -70,43 +70,6 @@ MSK.AdvancedNotify = MSK.AdvancedNotification
exports('AdvancedNotification', MSK.AdvancedNotification)
RegisterNetEvent("msk_core:advancedNotification", MSK.AdvancedNotification)

MSK.ScaleformAnnounce = function(header, text, typ, duration)
local scaleform = nil

if typ == 1 then
scaleform = MSK.Request.ScaleformMovie("MP_BIG_MESSAGE_FREEMODE")
BeginScaleformMovieMethod(scaleform, "SHOW_SHARD_WASTED_MP_MESSAGE")
ScaleformMovieMethodAddParamTextureNameString(header)
ScaleformMovieMethodAddParamTextureNameString(text)
EndScaleformMovieMethod()
elseif typ == 2 then
scaleform = MSK.Request.ScaleformMovie("POPUP_WARNING")
BeginScaleformMovieMethod(scaleform, "SHOW_POPUP_WARNING")
ScaleformMovieMethodAddParamFloat(500.0)
ScaleformMovieMethodAddParamTextureNameString(header)
ScaleformMovieMethodAddParamTextureNameString(text)
EndScaleformMovieMethod()
end

if not scaleform then return end

local draw = true
while draw do
local sleep = 1

DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)

MSK.Timeout.Set(duration or 8000, function()
draw = false
end)

Wait(sleep)
end
end
MSK.Scaleform = MSK.ScaleformAnnounce
exports('ScaleformAnnounce', MSK.ScaleformAnnounce)
RegisterNetEvent("msk_core:scaleformNotification", MSK.ScaleformAnnounce)

MSK.Subtitle = function(text, duration)
BeginTextCommandPrint('STRING')
AddTextComponentSubstringPlayerName(text)
Expand Down
94 changes: 94 additions & 0 deletions client/functions/scaleform.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
MSK.Scaleform = {}

MSK.Scaleform.Show = function(scaleform, duration)
if not scaleform then return end
local draw = true

MSK.Timeout.Set(duration or 5000, function()
draw = false
end)

while draw do
Wait(0)
DrawScaleformMovieFullscreen(scaleform, 255, 255, 255, 255, 0)
end

SetScaleformMovieAsNoLongerNeeded(scaleform)
end

MSK.Scaleform.FreemodeMessage = function(title, text, duration)
local scaleform = MSK.Request.ScaleformMovie("MP_BIG_MESSAGE_FREEMODE")

BeginScaleformMovieMethod(scaleform, "SHOW_SHARD_WASTED_MP_MESSAGE")
ScaleformMovieMethodAddParamTextureNameString(title)
ScaleformMovieMethodAddParamTextureNameString(text)
EndScaleformMovieMethod()

MSK.Scaleform.Show(scaleform, duration)
end
exports('FreemodeMessage', MSK.Scaleform.FreemodeMessage)
RegisterNetEvent("msk_core:freemodeMessage", MSK.Scaleform.FreemodeMessage)

MSK.Scaleform.PopupWarning = function(title, text, footer, duration)
local scaleform = MSK.Request.ScaleformMovie("POPUP_WARNING")

BeginScaleformMovieMethod(scaleform, "SHOW_POPUP_WARNING")
ScaleformMovieMethodAddParamFloat(500.0) -- black background
ScaleformMovieMethodAddParamTextureNameString(title)
ScaleformMovieMethodAddParamTextureNameString(text)
ScaleformMovieMethodAddParamTextureNameString(footer)
ScaleformMovieMethodAddParamBool(true)
EndScaleformMovieMethod()

MSK.Scaleform.Show(scaleform, duration)
end
exports('PopupWarning', MSK.Scaleform.PopupWarning)
RegisterNetEvent("msk_core:popupWarning", MSK.Scaleform.PopupWarning)

MSK.Scaleform.BreakingNews = function(title, text, footer, duration)
local scaleform = MSK.Request.ScaleformMovie("BREAKING_NEWS")

BeginScaleformMovieMethod(scaleform, "SET_TEXT")
ScaleformMovieMethodAddParamTextureNameString(text)
ScaleformMovieMethodAddParamTextureNameString(footer)
EndScaleformMovieMethod()

BeginScaleformMovieMethod(scaleform, "SET_SCROLL_TEXT")
ScaleformMovieMethodAddParamInt(0) -- top ticker
ScaleformMovieMethodAddParamInt(0) -- Since this is the first string, start at 0
ScaleformMovieMethodAddParamTextureNameString(title)
EndScaleformMovieMethod()

BeginScaleformMovieMethod(scaleform, "DISPLAY_SCROLL_TEXT")
ScaleformMovieMethodAddParamInt(0) -- Top ticker
ScaleformMovieMethodAddParamInt(0) -- Index of string
EndScaleformMovieMethod()

MSK.Scaleform.Show(scaleform, duration)
end
exports('BreakingNews', MSK.Scaleform.BreakingNews)
RegisterNetEvent("msk_core:breakingNews", MSK.Scaleform.BreakingNews)

MSK.Scaleform.TrafficMovie = function(duration)
local scaleform = MSK.Request.ScaleformMovie("TRAFFIC_CAM")

BeginScaleformMovieMethod(scaleform, "PLAY_CAM_MOVIE")
EndScaleformMovieMethod()

MSK.Scaleform.Show(scaleform, duration)
end
exports('TrafficMovie', MSK.Scaleform.TrafficMovie)
RegisterNetEvent("msk_core:trafficMovie", MSK.Scaleform.TrafficMovie)

-- Do NOT use this! Function is deprecated!
MSK.ScaleformAnnounce = function(title, text, typ, duration)
if typ == 1 then
MSK.Logging('error', "function MSK.ScaleformAnnounce is deprecated! Please use MSK.Scaleform.FreemodeMessage")
MSK.Scaleform.FreemodeMessage(title, text, duration)
elseif typ == 2 then
MSK.Logging('error', "function MSK.ScaleformAnnounce is deprecated! Please use MSK.Scaleform.PopupWarning")
MSK.Scaleform.PopupWarning(title, text, '', duration)
end
end
exports('ScaleformAnnounce', MSK.ScaleformAnnounce)
RegisterNetEvent("msk_core:scaleformNotification", MSK.ScaleformAnnounce)
21 changes: 21 additions & 0 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,30 @@ if GetResourceState('ox_inventory') ~= 'missing' then
MSK.Bridge.Inventory = 'ox_inventory'
elseif GetResourceState('qs-inventory') ~= 'missing' then
MSK.Bridge.Inventory = 'qs-inventory'
elseif GetResourceState('core_inventory') ~= 'missing' then
MSK.Bridge.Inventory = 'core_inventory'
end

MSK.Bridge.isPlayerLoaded = false

if MSK.Bridge.Framework.Type == 'ESX' then
RegisterNetEvent('esx:setPlayerData', function(key, val)
if GetInvokingResource() ~= "es_extended" then return end
TriggerEvent(MSK.Bridge.Framework.Events.setPlayerData, MSK.Bridge.Player)
TriggerServerEvent(MSK.Bridge.Framework.Events.setPlayerData)
end)

RegisterNetEvent('esx:playerLoaded', function(xPlayer, isNew, skin)
ESX.PlayerData = xPlayer
ESX.PlayerLoaded = true
MSK.Bridge.isPlayerLoaded = true
TriggerEvent(MSK.Bridge.Framework.Events.playerLoaded, MSK.Bridge.Player)
end)

RegisterNetEvent('esx:onPlayerLogout', function()
MSK.Bridge.isPlayerLoaded = false
ESX.PlayerLoaded = false
ESX.PlayerData = {}
TriggerEvent(MSK.Bridge.Framework.Events.playerLogout)
end)

Expand Down Expand Up @@ -87,6 +94,20 @@ elseif MSK.Bridge.Framework.Type == 'QBCore' then
TriggerEvent(MSK.Bridge.Framework.Events.setJob, MSK.Bridge.Player, newJob)
TriggerServerEvent(MSK.Bridge.Framework.Events.playerLogout, newJob)
end)
elseif MSK.Bridge.Framework.Type == 'OXCore' then
RegisterNetEvent('ox:playerLoaded', function(playerId, isNew)
MSK.Bridge.isPlayerLoaded = true
TriggerEvent(MSK.Bridge.Framework.Events.playerLoaded, MSK.Bridge.Player)
end)

RegisterNetEvent('ox:playerLogout', function(playerId)
MSK.Bridge.isPlayerLoaded = false
TriggerEvent(MSK.Bridge.Framework.Events.playerLoaded, MSK.Bridge.Player)
end)

RegisterNetEvent('ox:setGroup', function(groupName, grade)
TriggerEvent(MSK.Bridge.Framework.Events.setJob, MSK.Bridge.Player, groupName, grade)
end)
end

local GetLib = function()
Expand Down
2 changes: 1 addition & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Config.VersionChecker = true
-- AUTO will search for your framework
Config.Framework = 'AUTO'

-- Supported Inventories: default, custom, ox_inventory, qs-inventory
-- Supported Inventories: default, custom, ox_inventory, qs-inventory, core_inventory
-- For ESX Default Inventory or Chezza Inventory, set to 'default'
-- Set to 'custom' if you use another inventory and add your own functions
-- You can add your own inventory in: server/inventories/custom.lua
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 'Functions for MSK Scripts'
version '2.7.2'
version '2.7.3'

lua54 'yes'

Expand Down
25 changes: 25 additions & 0 deletions import.lua
Original file line number Diff line number Diff line change
Expand Up @@ -142,4 +142,29 @@ if context == 'server' then
setmetatable(MSK.Player[playerId], playerMeta)
end
end
end

----------------------------------------------------------------
-- Other stuff
----------------------------------------------------------------
if context == 'client' then
RegisterNetEvent('msk_core:playerLoaded', function()
MSK.Bridge.isPlayerLoaded = true

-- esx_multicharacter support
if MSK.Bridge.Framework.Type == 'ESX' then
ESX.PlayerLoaded = true
ESX.PlayerData = ESX.GetPlayerData()
end
end)

RegisterNetEvent('msk_core:playerLogout', function()
MSK.Bridge.isPlayerLoaded = false

-- esx_multicharacter support
if MSK.Bridge.Framework.Type == 'ESX' then
ESX.PlayerLoaded = false
ESX.PlayerData = {}
end
end)
end
16 changes: 9 additions & 7 deletions server/bridge/esx.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
if MSK.Bridge.Framework.Type ~= 'ESX' then return end

local GetPlayerData = function(Player)
Player.GetInventory = Player.inventory
Player.GetInventory = Player.getInventory
Player.AddItem = Player.addInventoryItem
Player.RemoveItem = Player.removeInventoryItem
Player.HasItem = Player.hasItem
Expand All @@ -13,8 +13,8 @@ local GetPlayerData = function(Player)
Player.AddWeapon = Player.addWeapon
Player.RemoveWeapon = Player.removeWeapon
Player.HasWeapon = Player.hasWeapon
Player.SetMeta = Player.setMeta
Player.GetMeta = Player.getMeta
Player.Set = Player.setMeta
Player.Get = Player.getMeta
Player.SetJob = Player.setJob

Player.dob = Player.dateofbirth
Expand All @@ -37,7 +37,7 @@ local GetPlayerData = function(Player)

Player.GetAccount = function(account)
for i = 1, #Player.accounts do
if Player.accounts[i].name == account then
if Player.accounts[i].name == account:lower() then
return Player.accounts[i]
end
end
Expand All @@ -51,7 +51,7 @@ local GetPlayerData = function(Player)
return Player
end

MSK.GetPlayer = function(player)
MSK.GetPlayer = function(player, data)
local Player

if player.player then
Expand All @@ -66,7 +66,9 @@ MSK.GetPlayer = function(player)
Player = nil
end

return GetPlayerData(Player)
if data == nil then data = true end

return data and GetPlayerData(Player) or Player
end
exports('GetPlayer', MSK.GetPlayer)

Expand All @@ -83,7 +85,7 @@ MSK.GetIdentifier = MSK.GetIdentifierFromPlayer
exports('GetIdentifierFromPlayer', MSK.GetIdentifierFromPlayer)

MSK.GetPlayerJob = function(player)
local Player = MSK.GetPlayer(player)
local Player = MSK.GetPlayer(player, false)
return Player.job.name
end
exports('GetPlayerJob', MSK.GetPlayerJob)
12 changes: 7 additions & 5 deletions server/bridge/qbcore.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ GetPlayerData = function(Player)
Player.AddWeapon = Player.AddItem
Player.RemoveWeapon = Player.RemoveItem
Player.HasWeapon = Player.HasItem
Player.SetMeta = Player.Functions.SetMetaData
Player.GetMeta = Player.Functions.GetMetaData
Player.Set = Player.Functions.SetMetaData
Player.Get = Player.Functions.GetMetaData
Player.SetJob = Player.Functions.SetJob

Player.identifier = Player.PlayerData.citizenid
Expand Down Expand Up @@ -60,7 +60,7 @@ GetPlayerData = function(Player)
return Player
end

MSK.GetPlayer = function(player)
MSK.GetPlayer = function(player, data)
local Player

if player.player then
Expand All @@ -75,7 +75,9 @@ MSK.GetPlayer = function(player)
Player = QBCore.Functions.GetPlayerByPhone(tostring(player.phone))
end

return GetPlayerData(Player)
if data == nil then data = true end

return data and GetPlayerData(Player) or Player
end
exports('GetPlayer', MSK.GetPlayer)

Expand All @@ -92,7 +94,7 @@ MSK.GetIdentifier = MSK.GetIdentifierFromPlayer
exports('GetIdentifierFromPlayer', MSK.GetIdentifierFromPlayer)

MSK.GetPlayerJob = function(player)
local Player = MSK.GetPlayer(player)
local Player = MSK.GetPlayer(player, false)
return Player.PlayerData.job.name
end
exports('GetPlayerJob', MSK.GetPlayerJob)
7 changes: 0 additions & 7 deletions server/functions/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,6 @@ end
MSK.AdvancedNotify = MSK.AdvancedNotification
exports('AdvancedNotification', MSK.AdvancedNotification)

MSK.ScaleformAnnounce = function(src, header, text, typ, duration)
if not src or src == 0 then return end
TriggerClientEvent('msk_core:scaleformNotification', src, header, text, typ, duration)
end
MSK.Scaleform = MSK.ScaleformAnnounce
exports('ScaleformAnnounce', MSK.ScaleformAnnounce)

MSK.Subtitle = function(src, message, duration)
if not src or src == 0 then return end
TriggerClientEvent('msk_core:subtitle', src, message, duration)
Expand Down
20 changes: 8 additions & 12 deletions server/functions/registeritems.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,20 @@ MSK.GetRegisteredItem = function(itemName)
end
exports('GetRegisteredItem', MSK.GetRegisteredItem)

MSK.RegisterItem = function(itemName, cb)
RegisteredItems[itemName] = cb
MSK.RegisterItem = function(itemName, callback)
RegisteredItems[itemName] = callback

if RegisteredItems[itemName] then
MSK.Logging('info', ('Item ^3%s^0 is already registerd. Overriding Item...'):format(itemName))
end

if MSK.Bridge.Inventory == 'qs-inventory' then
exports['qs-inventory']:CreateUsableItem(itemName, cb)
elseif MSK.Bridge.Inventory ~= 'ox_inventory' then
if MSK.Bridge.Framework.Type == 'ESX' then
ESX.RegisterUsableItem(itemName, cb)
elseif MSK.Bridge.Framework.Type == 'QBCore' then
QBCore.Functions.CreateUseableItem(itemName, cb)
end
end

if MSK.Bridge.Framework.Type == 'STANDALONE' then
exports['qs-inventory']:CreateUsableItem(itemName, callback)
elseif MSK.Bridge.Framework.Type == 'ESX' then
ESX.RegisterUsableItem(itemName, callback)
elseif MSK.Bridge.Framework.Type == 'QBCore' then
QBCore.Functions.CreateUseableItem(itemName, callback)
elseif MSK.Bridge.Framework.Type == 'STANDALONE' then
-- Register the item here
end
end
Expand Down
Loading

0 comments on commit 014b6ed

Please sign in to comment.