Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pickup only on dead #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 49 additions & 12 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,65 @@ RegisterCommand("stealshoes", function()
TriggerEvent('tnj-stealshoes:client:TheftShoe')
end)

local function IsTargetDead(playerId)
local retval = false
local hasReturned = false
QBCore.Functions.TriggerCallback('shoes:server:isPlayerDead', function(result)
retval = result
hasReturned = true
end, playerId)
while not hasReturned do
Wait(10)
end
return retval
end

RegisterNetEvent('tnj-stealshoes:client:TheftShoe', function() -- This could be used in the radialmenu ;)
local ped = PlayerPedId()
if not IsPedRagdoll(ped) then
local player, distance = QBCore.Functions.GetClosestPlayer()
if player ~= -1 and distance < 1.5 then
local playerId = GetPlayerServerId(player)
if not IsPedInAnyVehicle(GetPlayerPed(player)) and not IsPedInAnyVehicle(ped) then
local oped = GetPlayerPed(player)
local hasShoes = GetPedDrawableVariation(oped, 6)
if hasShoes ~= 34 then
while not HasAnimDictLoaded("random@domestic") do
RequestAnimDict("random@domestic")
Wait(1)
if Config.Down then
if IsTargetDead(playerId) then
if not IsPedInAnyVehicle(GetPlayerPed(player)) and not IsPedInAnyVehicle(ped) then
local oped = GetPlayerPed(player)
local hasShoes = GetPedDrawableVariation(oped, 6)
if hasShoes ~= 34 then
while not HasAnimDictLoaded("random@domestic") do
RequestAnimDict("random@domestic")
Wait(1)
end
TaskPlayAnim(ped, "random@domestic", "pickup_low", 8.00, -8.00, 500, 0, 0.00, 0, 0, 0)
TriggerServerEvent("tnj-stealshoes:server:TheftShoe", playerId)
SetPedComponentVariation(oped, 6, 34, 0, 2)
else
QBCore.Functions.Notify("No shoes to been stolen!", "error")
end
else
QBCore.Functions.Notify('You can\'t steal shoes in vehicle', "error")
end
TaskPlayAnim(ped, "random@domestic", "pickup_low", 8.00, -8.00, 500, 0, 0.00, 0, 0, 0)
TriggerServerEvent("tnj-stealshoes:server:TheftShoe", playerId)
SetPedComponentVariation(oped, 6, 34, 0, 2)
else
QBCore.Functions.Notify("No shoes to been stolen!", "error")
QBCore.Functions.Notify('They are not down!', "error")
end
else
QBCore.Functions.Notify('You can\'t steal shoes in vehicle', "error")
if not IsPedInAnyVehicle(GetPlayerPed(player)) and not IsPedInAnyVehicle(ped) then
local oped = GetPlayerPed(player)
local hasShoes = GetPedDrawableVariation(oped, 6)
if hasShoes ~= 34 then
while not HasAnimDictLoaded("random@domestic") do
RequestAnimDict("random@domestic")
Wait(1)
end
TaskPlayAnim(ped, "random@domestic", "pickup_low", 8.00, -8.00, 500, 0, 0.00, 0, 0, 0)
TriggerServerEvent("tnj-stealshoes:server:TheftShoe", playerId)
SetPedComponentVariation(oped, 6, 34, 0, 2)
else
QBCore.Functions.Notify("No shoes to been stolen!", "error")
end
else
QBCore.Functions.Notify('You can\'t steal shoes in vehicle', "error")
end
end
else
QBCore.Functions.Notify('No one nearby!', "error")
Expand Down
2 changes: 2 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
Config = {}
Config.QBTarget = true

Config.Down = true --set to false if you want to get shoes if a player is not in last stand or down
6 changes: 6 additions & 0 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,10 @@ RegisterNetEvent("tnj-stealshoes:server:Complete", function(playerId)
Receiver.Functions.AddItem("weapon_shoe", 1)
TriggerClientEvent('inventory:client:ItemBox', Receiver.PlayerData.source, QBCore.Shared.Items["weapon_shoe"], 'add')
end
end)

QBCore.Functions.CreateCallback('shoes:server:isPlayerDead', function(_, cb, playerId)
local Player = QBCore.Functions.GetPlayer(playerId)
local status = Player.PlayerData.metadata["isdead"] or Player.PlayerData.metadata["inlaststand"]
cb(status)
end)