Add new scripts sling

do /sling
This commit is contained in:
KingMcDonalds
2023-04-28 16:25:41 -07:00
parent c591c430f2
commit 27e597434a
4 changed files with 5033 additions and 0 deletions
+155
View File
@@ -0,0 +1,155 @@
-- Created by Scully#5775 | https://discord.gg/eNtGFS6
Scully.Sling = {
WeaponOne = {
InUse = false,
Hash = nil,
Object = nil,
Tint = nil,
Ammo = 0,
Components = {}
},
WeaponTwo = {
InUse = false,
Hash = nil,
Object = nil,
Tint = nil,
Ammo = 0,
Components = {}
}
}
function Scully.Sling.LoadWeaponAsset(weaponModel)
if not HasModelLoaded(weaponModel) then
RequestModel(weaponModel)
while not HasModelLoaded(weaponModel) do
Wait(0)
end
end
end
function Scully.Sling.DeleteWeaponAsset(weaponObject)
if DoesEntityExist(weaponObject) then
while DoesEntityExist(weaponObject) do
Wait(0)
DeleteObject(weaponObject)
SetModelAsNoLongerNeeded(weaponObject)
end
end
end
function Scully.Sling.RequestAnimDict(animDict)
if not HasAnimDictLoaded(animDict) then
RequestAnimDict(animDict)
while not HasAnimDictLoaded(animDict) do
Wait(0)
end
end
end
function Scully.Sling.ShowNotification(text)
BeginTextCommandThefeedPost("STRING")
AddTextComponentSubstringPlayerName(text)
EndTextCommandThefeedPostTicker(true, true)
end
RegisterCommand(Scully.Command, function(_, args)
local playerPed, slingOption = PlayerPedId(), args[1]
local currentWeapon = GetSelectedPedWeapon(playerPed)
if not slingOption then slingOption = '1' end
if slingOption == '1' then slingOption = 'WeaponOne' else slingOption = 'WeaponTwo' end
if Scully.Sling[slingOption].InUse then
if currentWeapon ~= `WEAPON_UNARMED` then
Scully.Sling.ShowNotification('~r~You are already holding a weapon!')
return
end
Scully.Sling.RequestAnimDict('mp_player_intdrink')
TaskPlayAnim(playerPed, 'mp_player_intdrink', 'loop_bottle', 8.0, -8.0, 200, 49, 0, 0, 0, 0)
local delayTimerOne, delayTimerTwo = 50, 50
if slingOption == 'WeaponTwo' then delayTimerOne, delayTimerTwo = 300, 100 end
Wait(delayTimerOne)
local slingInfo = Scully.Sling[slingOption]
AttachEntityToEntity(slingInfo.Object, playerPed, GetPedBoneIndex(playerPed, 18905), 0.0, 0.0, 0.0, 90.0, 90.0, 0.0, 1, 1, 0, 1, 1, 0)
Wait(delayTimerTwo)
ClearPedTasks(playerPed)
RemoveAnimDict('mp_player_intdrink')
Scully.Sling.DeleteWeaponAsset(slingInfo.Object)
GiveWeaponToPed(playerPed, slingInfo.Hash, slingInfo.Ammo, false, true)
Scully.CustomAdd(slingInfo.Hash)
SetPedWeaponTintIndex(playerPed, slingInfo.Hash, slingInfo.Tint)
for k, v in pairs(slingInfo.Components) do
GiveWeaponComponentToPed(playerPed, slingInfo.Hash, k)
Scully.Sling.DeleteWeaponAsset(v.Object)
end
SetPedAmmo(playerPed, slingInfo.Hash, slingInfo.Ammo)
Scully.Sling[slingOption] = {
InUse = false,
Hash = nil,
Object = nil,
Tint = nil,
Ammo = 0,
Components = {}
}
else
if currentWeapon == `WEAPON_UNARMED` then
Scully.Sling.ShowNotification('~r~You aren\'t holding a weapon!')
return
end
local validWeapon = Scully.Weapons[currentWeapon]
if not validWeapon then
Scully.Sling.ShowNotification('~r~You can\'t sling this weapon!')
return
end
local weaponComponents = {}
for k, v in pairs(validWeapon.Components) do
if HasPedGotWeaponComponent(playerPed, currentWeapon, k) then
weaponComponents[k] = {
Object = nil,
Hash = k,
Attachment = v.Object,
Bone = v.Bone
}
end
end
Scully.Sling.LoadWeaponAsset(validWeapon.Object)
Scully.Sling[slingOption] = {
InUse = true,
Hash = currentWeapon,
Object = CreateObject(validWeapon.Object, 1.0, 1.0, 1.0, true, true, false),
Tint = GetPedWeaponTintIndex(playerPed, currentWeapon),
Ammo = GetAmmoInPedWeapon(playerPed, currentWeapon),
Components = weaponComponents
}
local slingInfo = Scully.Sling[slingOption]
AttachEntityToEntity(slingInfo.Object, playerPed, GetPedBoneIndex(playerPed, 18905), 0.0, 0.0, 0.0, 90.0, 90.0, 0.0, 1, 1, 0, 1, 1, 0)
for k, v in pairs(slingInfo.Components) do
Scully.Sling.LoadWeaponAsset(v.Attachment)
local attachmentObject = CreateObject(v.Attachment, 1.0, 1.0, 1.0, true, true, false)
AttachEntityToEntity(attachmentObject, slingInfo.Object, GetEntityBoneIndexByName(slingInfo.Object, v.Bone), 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1, 1, 0, 0, 2, 1)
Scully.Sling[slingOption].Components[v.Hash].Object = attachmentObject
end
SetEntityCollision(slingInfo.Object, false, false)
RemoveWeaponFromPed(playerPed, currentWeapon)
Scully.CustomRemoval(currentWeapon)
SetCurrentPedWeapon(playerPed, `WEAPON_UNARMED`, true)
Scully.Sling.RequestAnimDict('mp_player_intdrink')
TaskPlayAnim(playerPed, 'mp_player_intdrink', 'loop_bottle', 8.0, -8.0, 200, 49, 0, 0, 0, 0)
local delayTimer = 100
if slingOption == 'WeaponTwo' then delayTimer = 400 end
Wait(delayTimer)
ClearPedTasks(playerPed)
RemoveAnimDict('mp_player_intdrink')
if slingOption == 'WeaponOne' then
AttachEntityToEntity(slingInfo.Object, playerPed, GetPedBoneIndex(playerPed, 24816), Scully.AttachPoints[1].Position, Scully.AttachPoints[1].Rotation, 1, 1, 0, 0, 2, 1)
else
AttachEntityToEntity(slingInfo.Object, playerPed, GetPedBoneIndex(playerPed, 24816), Scully.AttachPoints[2].Position, Scully.AttachPoints[2].Rotation, 1, 1, 0, 0, 2, 1)
end
end
end)
if Scully.KeybindOne ~= '' then
RegisterKeyMapping(Scully.Command .. ' 1', 'Sling 1', 'keyboard', Scully.KeybindOne)
end
if Scully.KeybindTwo ~= '' then
RegisterKeyMapping(Scully.Command .. ' 2', 'Sling 2', 'keyboard', Scully.KeybindTwo)
end
File diff suppressed because it is too large Load Diff
+16
View File
@@ -0,0 +1,16 @@
-- Created by Scully#5775 | https://discord.gg/eNtGFS6
fx_version 'cerulean'
game 'gta5'
author 'Scully#5775'
description 'very noice weapon sling'
version '1.0'
lua54 'yes'
shared_script 'config.lua'
client_scripts {
'client/*.lua'
}
+1
View File
@@ -181,6 +181,7 @@ start DOJRPCARS
start AIBackup start AIBackup
start cvpiv8 start cvpiv8
start r_pepperspray start r_pepperspray
start scully_sling
#[-----Discord Perms-----] #[-----Discord Perms-----]
start Discord-Presence start Discord-Presence