[FIXED] Remove prop after scenario animation

Hey

I’m trying to use the WORLD_HUMAN_HAMMERING scenario with TaskStartScenarioInPlace

The problem I have is that it doesnt remove the hammer after the animation.
Even with ClearPedTasks or ClearPedTasksImmediately

Anyone knows a fix?
Thanks!

Store the hammer in a variable and use the DeleteObject native to get rid of it, there are a few posts on the forum with a similar issue to yours that you can reference for further help if needed

Hmm so i do need to create the hammer object first?
Since it now gets created from the scenario itself

Ah, in this case you can try using fetching the hammer via GetClosestObjectOfType - not something I ever messed with myself though and it looks like it’ll take some tinkering before it works.

ok thanks I’ll try that!
If i make it work i’ll post ir here
Thanks

Solution thanks to @_4iY

local hammer = GetClosestObjectOfType(pos.x, pos.y, pos.z, 5.0, GetHashKey('prop_tool_hammer'), false, true ,true)
if DoesEntityExist(hammer) then
    SetEntityAsMissionEntity(hammer, false, false)
    DeleteObject(hammer)
end
1 Like

i tried your exact code but hammer keeps returning as nil

Tip: Use `` for hashing instead of GetHashKey. It will be shockingly faster :smiley:

Example:

-- old, bad
local hammer = GetClosestObjectOfType(position, distance, GetHashKey('prop_tool_hammer'), ...)

-- new, GOOD!
local hammer = GetClosestObjectOfType(position, distance, `prop_tool_hammer`, ...)
1 Like