local retval true, entity entity =
GetEntityPlayerIsFreeAimingAt(
player player
)
if retval = true then
ApplyDamageToPed(
ped ped,
damageAmount 500,
armorFirst false
)
local retval true, entity entity =
GetEntityPlayerIsFreeAimingAt(
player player
)
if retval = true then
ApplyDamageToPed(
ped ped,
damageAmount 500,
armorFirst false
)
What the actual F is that code? Did you just copy and paste what’s in the Natives reference without understanding the absolute basics of code?
Do yourself a favor and take some classes on programming first, please - will save you a lot of nerves!
I just want that to work.
It never will with the way you wrote it, that’s for sure
Let me give you an example of what should work, however I dont have a test environment ready that I can use to verify if it does or not. At least it’s a step in the right direction:
Citizen.CreateThread(function()
local player = PlayerPedId()
if IsPlayerFreeAiming(player) then
if GetEntityPlayerIsFreeAimingAt(player) then
local GetEntityPlayerIsFreeAimingAt(player) = entity
if IsEntityAPed(entity) then
-- Do whatever with "entity" as it's confirmed
-- to be a ped being aimed at by the player
end
end
else
Citizen.Wait(100)
end
end)
Stuff like this definitely requires at least some basic knowledge about scripting, so like I said please don’t try and hack things together so they work before learning the very basics.
the above code is missing a while true and also the local is the wrong way round, fixed it below.
Citizen.CreateThread(function()
while true do
Citizen.Wait(5)
local player = PlayerPedId()
if IsPlayerFreeAiming(player) then
if GetEntityPlayerIsFreeAimingAt(player) then
local entity = GetEntityPlayerIsFreeAimingAt(player)
if IsEntityAPed(entity) then
-- Do whatever with "entity" as it's confirmed
-- to be a ped being aimed at by the player
end
end
else
Citizen.Wait(100)
end
end
end)
Thank you very much.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.