This repository has been archived by the owner on Sep 12, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
715 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# License | ||
|
||
Copyright (C) since 2024 Musiker15 - MSK Scripts <https://www.msk-scripts.de> | ||
|
||
Contact for business enquiries: info@msk-scripts.de | ||
|
||
This software is a resource for the "FiveM" modification for the game "Grand Theft Auto V" and is comprised of the files this license is attached to. It is only meant to function inside of this environment. | ||
|
||
## Usage Rights | ||
The user is granted permission to use and modify this software for personal or non-commercial purposes. The user is granted permission to integrate this software as a dependency in his resources and publish his resources as long as the resource is available for FREE. | ||
|
||
The user is not allowed to publish, sell or distribute the software or any part of it without the consent of the licensor and apart from forking the official repository on GitHub. | ||
|
||
The user may not create derivatives or copies of the software that violate these licensing terms. | ||
This license may be revoked by the licensor at any time if the user violates the terms of the license. Upon termination of the license, the user must destroy all copies of the software and any resulting modifications. | ||
|
||
The licensor reserves the right to change the licensing terms with each update of the software. The user is required to review and agree to the updated licensing terms in order to continue using the updated version of the software. | ||
|
||
By using the software, the user automatically accepts these licensing terms and any future changes made through software updates. | ||
|
||
## Disclaimer of Liability | ||
The software is provided "as is", without warranties of any kind. The licensor is not liable for any damages resulting from using and modfifying the software. | ||
|
||
## Further information | ||
Further information and documentation referring to the software can be found at https://docu.msk-scripts.de. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,215 @@ | ||
local isWearingArmor, isPlayerLoaded = false, false | ||
local currentItem = {} | ||
|
||
AddEventHandler('onResourceStart', function(resource) | ||
if GetCurrentResourceName() == resource then | ||
isPlayerLoaded = ESX.IsPlayerLoaded() | ||
end | ||
end) | ||
|
||
RegisterNetEvent('esx:playerLoaded') | ||
AddEventHandler('esx:playerLoaded', function(xPlayer, isNew, skin) | ||
Wait(1000) -- Please Do Not Touch! // This is for slower PCs | ||
|
||
if isNew then | ||
isPlayerLoaded = true | ||
return logging('debug', 'Character is not created yet.', 'Returning...') | ||
end | ||
|
||
if not xPlayer then | ||
isPlayerLoaded = true | ||
return logging('error', 'xPlayer not found on Event esx:playerLoaded!', 'Returning...') | ||
end | ||
|
||
if not Config.LoadStatus.health and not Config.LoadStatus.armor then | ||
isPlayerLoaded = true | ||
return logging('debug', 'Config.LoadStatus.health AND Config.LoadStatus.armor is deactivated in config.lua', 'Returning...') | ||
end | ||
|
||
while not ESX.PlayerData.ped do Wait(10) end | ||
|
||
local playerPed = PlayerPedId() | ||
local health, armor, item = MSK.Trigger('msk_armor:getStatusFromDB') | ||
health, armor = tonumber(health), tonumber(armor) | ||
logging('debug', 'TriggerCallback: getStatusFromDB on Event playerLoaded') | ||
logging('debug', 'playerHealth: ' .. health, 'playerArmor: ' .. armor, 'Item: ' .. (item or 'nil')) | ||
|
||
if Config.LoadStatus.health then | ||
if ESX.PlayerData.metadata and ESX.PlayerData.metadata.health then | ||
local maxHealth = math.max(health, tonumber(ESX.PlayerData.metadata.health)) | ||
maxHealth = tonumber(maxHealth) | ||
SetEntityHealth(playerPed, maxHealth) | ||
else | ||
SetEntityHealth(playerPed, health) | ||
end | ||
end | ||
|
||
if Config.LoadStatus.armor then | ||
local setArmor = 0 | ||
if ESX.PlayerData.metadata and ESX.PlayerData.metadata.armor then | ||
local maxArmor = math.max(armor, tonumber(ESX.PlayerData.metadata.armor)) | ||
maxArmor = tonumber(maxArmor) | ||
setArmor = maxArmor | ||
else | ||
setArmor = armor | ||
end | ||
|
||
if setArmor > 100 then SetPlayerMaxArmour(playerPed, setArmor) end | ||
SetPedArmour(playerPed, setArmor) | ||
|
||
if item then | ||
currentItem.item = item | ||
currentItem.percent = Config.Armories[item].percent | ||
end | ||
end | ||
|
||
if Config.LoadStatus.restoreVest then | ||
if armor > 0 then | ||
logging('debug', 'skin bproof', skin.bproof_1) | ||
|
||
if skin and skin.bproof_1 == 0 then | ||
logging('debug', 'bproof_1 is not set. Setting bproof Skin...') | ||
|
||
if skin.sex == 0 then -- Male | ||
local bproof = Config.defaultSkin.Male | ||
if item then bproof = Config.Armories[item].skin.Male end | ||
TriggerEvent('skinchanger:loadClothes', skin, bproof) | ||
else -- Female | ||
local bproof = Config.defaultSkin.Female | ||
if item then bproof = Config.Armories[item].skin.Female end | ||
TriggerEvent('skinchanger:loadClothes', skin, bproof) | ||
end | ||
saveSkin() | ||
end | ||
|
||
if Config.giveNoBProof then | ||
logging('debug', 'TriggerEvent giveNoBProofItem on Event: playerLoaded') | ||
TriggerServerEvent('msk_armor:giveNoBProofItem') | ||
end | ||
|
||
isWearingArmor = true | ||
else | ||
logging('debug', 'Armor is 0 on playerLoaded') | ||
end | ||
end | ||
|
||
isPlayerLoaded = true | ||
end) | ||
|
||
if Config.Refresh.enable then | ||
CreateThread(function() | ||
while true do | ||
local sleep = Config.Refresh.time * 1000 | ||
|
||
if isPlayerLoaded then | ||
if Config.Refresh.debug then logging('debug', 'isWearingArmor:', isWearingArmor) end | ||
|
||
if isWearingArmor and GetPedArmour(PlayerPedId()) <= 0 then | ||
logging('debug', 'Set isWearingArmor = false', 'Remove Vest on Event: refreshArmour') | ||
TriggerEvent('msk_armor:setDelArmor') | ||
TriggerServerEvent('msk_armor:removeNoBProofItem') | ||
end | ||
end | ||
|
||
Wait(sleep) | ||
end | ||
end) | ||
end | ||
|
||
if Config.Hotkey.enable then | ||
CreateThread(function() | ||
while true do | ||
local sleep = 0 | ||
|
||
if IsControlJustPressed(0, Config.Hotkey.key) then | ||
local itemName, item = MSK.Trigger('msk_armor:setHotkey', Config.Hotkey.item) | ||
|
||
if item then | ||
TriggerEvent('msk_armor:setArmor', itemName, item) | ||
else | ||
Config.Notification(nil, 'You can not put on a Vest without a Vest!') | ||
end | ||
end | ||
|
||
Wait(sleep) | ||
end | ||
end) | ||
end | ||
|
||
RegisterNetEvent('msk_armor:setArmor') | ||
AddEventHandler('msk_armor:setArmor', function(itemName, item) | ||
local playerPed = PlayerPedId() | ||
|
||
taskAnimation(Config.Animations.dict, Config.Animations.anim, Config.Animations.time * 1000) | ||
logging('debug', 'setArmor Item:', itemName, item.percent) | ||
|
||
if item.skin.enable then | ||
TriggerEvent('skinchanger:getSkin', function(skin) | ||
if Config.alreadySet then | ||
if skin.sex == 0 then -- Male | ||
TriggerEvent('skinchanger:loadClothes', skin, Config.Armories[itemName].skin.male) | ||
else -- Female | ||
TriggerEvent('skinchanger:loadClothes', skin, Config.Armories[itemName].skin.female) | ||
end | ||
saveSkin() | ||
end | ||
end) | ||
end | ||
|
||
currentItem.item = itemName | ||
currentItem.percent = item.percent | ||
|
||
if item.percent > 100 then SetPlayerMaxArmour(playerPed, item.percent) end | ||
SetPedArmour(playerPed, item.percent) | ||
TriggerServerEvent('msk_armor:refreshArmour', GetEntityHealth(playerPed), item.percent, itemName) | ||
isWearingArmor = true | ||
end) | ||
|
||
RegisterNetEvent('msk_armor:setDelArmor') | ||
AddEventHandler('msk_armor:setDelArmor', function() | ||
local playerPed = PlayerPedId() | ||
|
||
if Config.giveBackVest and GetPedArmour(playerPed) == currentItem.percent then | ||
TriggerServerEvent('msk_armor:giveBackVest', currentItem.item) | ||
end | ||
|
||
taskAnimation(Config.Animations.dict, Config.Animations.anim, Config.Animations.time * 1000) | ||
|
||
TriggerEvent('skinchanger:getSkin', function(skin) | ||
TriggerEvent('skinchanger:loadClothes', skin, {['bproof_1'] = 0, ['bproof_2'] = 0}) | ||
saveSkin() | ||
end) | ||
|
||
if currentItem.percent > 100 then SetPlayerMaxArmour(playerPed, 100) end | ||
SetPedArmour(playerPed, 0) | ||
TriggerServerEvent('msk_armor:refreshArmour', GetEntityHealth(playerPed), 0, 'remove') | ||
currentItem = {} | ||
isWearingArmor = false | ||
end) | ||
|
||
taskAnimation = function(dict, anim, time) | ||
local playerPed = PlayerPedId() | ||
|
||
ESX.Streaming.RequestAnimDict(dict, function() | ||
TaskPlayAnim(playerPed, dict, anim, 8.0, 1.0, -1, 49, 0, false, false, false) -- Standing | ||
-- TaskPlayAnim(playerPed, dict, anim, 8.0, -8, -1, 32, 0, false, false, false) -- Kneeing | ||
RemoveAnimDict(dict) | ||
end) | ||
|
||
Wait(time) | ||
ClearPedTasks(playerPed) | ||
end | ||
|
||
saveSkin = function() | ||
if not Config.saveSkin then return end | ||
Wait(100) | ||
|
||
TriggerEvent('skinchanger:getSkin', function(skin) | ||
TriggerServerEvent('esx_skin:save', skin) | ||
end) | ||
end | ||
|
||
logging = function(code, ...) | ||
if not Config.Debug then return end | ||
MSK.Logging(code, ...) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
Config = {} | ||
---------------------------------------------------------------- | ||
Config.Locale = 'de' | ||
Config.VersionChecker = true | ||
Config.Debug = true | ||
---------------------------------------------------------------- | ||
-- Exports (serverside) | ||
|
||
-- exports.msk_armor:saveStatus({source = playerId}, playerHealth, playerArmor) | ||
-- exports.msk_armor:saveStatus({identifier = playerIdentifier}, playerHealth, playerArmor) | ||
-- exports.msk_armor:saveStatus({player = xPlayer}, playerHealth, playerArmor) | ||
---------------------------------------------------------------- | ||
-- !!! This function is clientside AND serverside !!! | ||
Config.Notification = function(source, message) | ||
if IsDuplicityVersion() then -- serverside | ||
MSK.Notification(source, 'MSK Amror', message) | ||
else -- clientside | ||
MSK.Notification('MSK Amror', message) | ||
end | ||
end | ||
---------------------------------------------------------------- | ||
Config.Hotkey = { | ||
enable = false, -- Set true to enable the Hotkey | ||
key = 38, -- Set the Control you want to use | ||
item = 'bulletproof' -- Set the item that you want to use via Hotkey | ||
} | ||
|
||
Config.LoadStatus = { | ||
health = true, -- Set false if you don't want to restore health after player connect | ||
armor = true, -- Set false if you don't want to restore armor after player connect | ||
restoreVest = true -- Set false if you don't want to restore the ArmorVest after player connect | ||
} | ||
|
||
Config.Refresh = { | ||
enable = true, -- Checks the current Armor status and removes the Vest if armor = 0 | ||
time = 10, -- in seconds (default: 10 seconds) | ||
debug = false, -- Set true if you want to get a print in console // recommended: false (SPAM Alert) | ||
} | ||
|
||
Config.alreadySet = true -- Set to false if you don't want that the Vest Skin will change if the Player has already a Vest Skin | ||
Config.giveNoBProof = true -- Set false if you don't want that you get the 'nobproof' item after using a 'bulletproof' item | ||
Config.giveBackVest = true -- Set true if you want to give the item back if armor = 100% | ||
Config.saveSkin = true -- Set false if you have Skin problems on playerConnect | ||
------------------------------------------------------------ | ||
-- Animation for put on the Vest | ||
Config.Animations = { | ||
dict = 'clothingtie', | ||
anim = 'try_tie_neutral_a', | ||
time = 2 -- in seconds (default: 2 seconds) | ||
} | ||
---------------------------------------------------------------- | ||
-- This Skin will be only set if the Player doesn't have already a Vest Skin and no item is set in msk_armor database table | ||
-- If you dont want to use this then set Config.LoadStatus.restoreVest = false | ||
Config.defaultSkin = { | ||
male = { | ||
['bproof_1'] = 11, | ||
['bproof_2'] = 1 | ||
}, | ||
female = { | ||
['bproof_1'] = 3, | ||
['bproof_2'] = 1 | ||
}, | ||
} | ||
---------------------------------------------------------------- | ||
Config.Armories = { | ||
['bulletproof'] = { -- Item | ||
label = 'Bulletproof Vest', | ||
percent = 100, | ||
skin = { | ||
enable = true, -- Set false to disable change Vest Skin | ||
male = { | ||
['bproof_1'] = 11, | ||
['bproof_2'] = 1, | ||
}, | ||
female = { | ||
['bproof_1'] = 3, | ||
['bproof_2'] = 1, | ||
}, | ||
}, | ||
removeItem = true, | ||
jobs = {enable = false, jobs = {'none'}} -- If enable = false then everyone can use that item | ||
}, | ||
['bulletproof2'] = { -- Item | ||
label = 'Bulletproof Vest', | ||
percent = 50, | ||
skin = { | ||
enable = true, -- Set false to disable change Vest Skin | ||
male = { | ||
['bproof_1'] = 11, | ||
['bproof_2'] = 1, | ||
}, | ||
female = { | ||
['bproof_1'] = 3, | ||
['bproof_2'] = 1, | ||
}, | ||
}, | ||
removeItem = true, | ||
jobs = {enable = false, jobs = {'none'}} -- If enable = false then everyone can use that item | ||
}, | ||
['bulletproofpolice'] = { -- Item | ||
label = 'Police Bulletproof Vest', | ||
percent = 100, | ||
skin = { | ||
enable = true, -- Set false to disable change Vest Skin | ||
male = { | ||
['bproof_1'] = 12, | ||
['bproof_2'] = 3, | ||
}, | ||
female = { | ||
['bproof_1'] = 13, | ||
['bproof_2'] = 1, | ||
}, | ||
}, | ||
removeItem = true, | ||
jobs = {enable = true, jobs = {'police'}} -- If enable = true then only the specific job can use that item | ||
}, | ||
} |
Oops, something went wrong.