Scripts / How do I destroy, hide, show and spaw a specific entity from a level?

Author
Message
yakkyx
1
Years of Service
User Offline
Joined: 20th Jul 2023
Location:
Posted: 20th Jul 2023 20:16
I can't seem to figure it out. This is what I tried:

function pickupobject_quest1_init(e)

end

function pickupobject_quest1_main(e)

local PlayerDist = GetPlayerDistance(e)

if PlayerDist < 100 and g_PlayerHealth > 0 then
Prompt("Press E to pick up hammer")
if g_KeyPressE == 1 then
Spawn(g_Entity[e]['Pistol'] == 1)
PerformLogicConnections(e)
Destroy('Quest1Trigger')
ActivateIfUsed('Pistol')
Show('Pistol')
Destroy(e)
end
end
end

PM
3com
10
Years of Service
User Offline
Joined: 18th May 2014
Location: Catalonia
Posted: 21st Jul 2023 08:47
In short
Spawn(e)
Destroy(e)
Hide(e)
Show(e)

In other words, you work with "e" or the entity ID, not the entity name, so if the hammer ID is equal to 4, so
Spawn(4)
Destroy(4)
Hide(4)
Show(4)

If you want to hide let's say 8 hammers at a time and their IDs are correlative (1 thru 8) you can make as follow:

for i = 1,8,1 do Hide(i) end

hth
Laptop: Lenovo - Intel(R) Celeron(R) CPU 1005M @ 1.90GHz

OS: Windows 10 (64) - Ram: 4 gb - Hd: 283 gb - Video card: Intel(R) HD Graphics
cpu mark: 10396.6
2d graphics mark: 947.9
3d graphics mark: 8310.9
memory mark 2584.8
Disk mark: 1146.3
Passmark rating: 3662.4

PM

Login to post a reply

Server time is: 2024-11-21 09:57:16
Your offset time is: 2024-11-21 09:57:16