Scripts / Destroy entity doesn't work

Author
Message
HappyAlpaka
8
Years of Service
User Offline
Joined: 21st Jan 2016
Location:
Posted: 30th Jan 2016 05:57
Hi,

i just have a (little) problem:
I want to destroy an Entity when i press the "E" key, while standing next to it.

This is the script i wrote:




function destroyme_init(e)
end

function destroyme_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 300 and g_KeyPressE==1 then
Destroy(e)
end
end




But when i test the game, nothing happens.
Could someone help me please?

Best greetings from Germany,

HappyAlpaka
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 30th Jan 2016 06:55 Edited at: 30th Jan 2016 07:15
Will have to take a look.

Edit: Is it possible that this entity is static, instead of dynamic.
If you put the mouse over it and it turns red, then it is static. Objects must by dynamic for scripts to function ion them.

Edit2:
Try assigning your script to the acid barrel in the barrels folders. See if it works there.

Also make sure that the name of the script and the function names are exactly the same.

The script does run on my machine and destroys the object assigned to it.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

HappyAlpaka
8
Years of Service
User Offline
Joined: 21st Jan 2016
Location:
Posted: 30th Jan 2016 20:13
@Pirate Myke aaah thanks! I didn't changed the entity to dynamic!
Works now, thanks!
PM
Pirate Myke
Forum Support
13
Years of Service
User Offline
Joined: 31st May 2010
Location: El Dorado, California
Posted: 30th Jan 2016 22:18
Good, great to hear.
Intel(R) Core(TM)2 Quad CPU Q6600 @ 2.40GHz, 2400 Mhz, 4 Core(s), 4 Logical Processor(s), 8gb RAM, Nvidia gtx660, Windows 7 Pro 64bit

Login to post a reply

Server time is: 2024-05-03 14:06:46
Your offset time is: 2024-05-03 14:06:46