Scripts / [SOLVED] Destroy Entity via Trigger Zone

Author
Message
DareESP
User Offline
Joined: 15th Aug 2021
Location:
Posted: 29th Aug 2021 21:28
Hi All,

I would like to create a zone with the function to destroy an entity when used (make it disappear). I believe it should be easy to do, can someone please help? Totally the opposite of what the trigger zone is doing now.

Thank you in advance!

The author of this post has marked a post as an answer.

Go to answer
PM
bluemeenie195
3
Years of Service
User Offline
Joined: 28th Oct 2018
Location:
Posted: 29th Aug 2021 21:56
This post has been marked by the post author as the answer.
This should work.
Just change the entity # to the one you want to hide.
If you want to completely remove it, change the Hide to Destroy.

function plrinzone_init(e)
end
function plrinzone_main(e)
if g_Entity[e]['plrinzone']==1 then
Hide(1) -- change the 1 to the entity # of the object you want to hide
PlaySound(e,0)
Destroy(e)
ActivateIfUsed(e)
end
end
PM
DareESP
User Offline
Joined: 15th Aug 2021
Location:
Posted: 29th Aug 2021 22:31
Thanks a lot, bluemeenie195. The script is working perfectly!
PM
smallg
Community Leader
15
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 29th Aug 2021 22:48
be aware that simply hiding an object will still leave the physics there if it is enabled (i.e. the player / other objects will still collide with it)
so you will want to add CollisionOff(#) too
or if the object is no longer going to be used at all use Destroy(#) instead as this will remove the entity completely
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
DareESP
User Offline
Joined: 15th Aug 2021
Location:
Posted: 29th Aug 2021 23:26
I used Destroy, as that will be a one-time use object!. Actually, I was checking the normal trigger zone script and I realized that it is very similar to what I wanted, just basically changing it to Hide or Destroy. Still learning, so thanks for all the advice. I could not learn and compare it without the provided script above.

Thanks again for your great help guys!

PM

Login to post a reply

Server time is: 2021-11-27 10:45:27
Your offset time is: 2021-11-27 10:45:27