Scripts / Disappear Script

Author
Message
CorzaX
8
Years of Service
User Offline
Joined: 12th Feb 2016
Location: Melbourne, VIC
Posted: 16th Mar 2016 05:00
I'm still bit of a dumb dumb when it comes to scripts, but what I'm trying to do is simply have an entity, such as a zombie with the ai_neutral script attached, disappear when the player enters a Trigger Zone.

The Trigger Zone has the disappear script attached, and I've added in Destroy(e), where 'e' is number 410 (as this is the zombie entity number).

But in fact, when the game loads, the zombie has already disappeared before I enter the Trigger Zone.

What am I doing wrong? Or is there a better way to do this?

Thanks,
CorzaX24
PM
Belidos
3D Media Maker
9
Years of Service
User Offline
Joined: 23rd Nov 2015
Playing: The Game
Posted: 16th Mar 2016 06:31 Edited at: 21st Mar 2016 08:47
I assume you just added Destroy(410) between the main function and the end in disappear.lua like so?



If so then you haven't added anything to tell the engine that you have entered the zone, you have just told it to destroy the entity as soon as the script starts to run.

You need to wrap the command in an if statement that tells the engine "if the player walks into the zone then...", also personally i'd use Hide(e) rather than Destroy(e) because then you can use Spawn(e) at a later date to bring it back if you want to, with Destory(e) (and I may be wrong so if I am somebody please let me know) it's gone for good.

LUA looks daunting but it's easier than you think, a lot of the basic lua scripting is very logical, you just need to know the commands. I find it helps to type out step by step what you want to do, for this it would be...

If the player enters the zone then hide the zombie

that would translate to..

if g_Entity[e]['plrinzone']==1 then
Hide(410)

Very simple yes? It's gets a lot trickier when you inolve more complicated actions like math etc. But for the basics it's just a matter of laying it out step by step and knowing the commands. For a complete list of LUA commands available there's a file in your scriptbank called global.lua, this lists all of the LUA commands.

Here's the script I would use to do what you want:

hideentity.lua

i7, NV960 4GB, 16GB memory, 2x 4TB Hybrid, Win10.
i5 , AMD 6770 1GB, 8GB memory, 512GB Generic SATAIII + 2TB Seagate Baracuda SATAIII, Win7.
i3, Radeon integrated graphics, 4GB memory, 512gB Generic SATAII, Win8.1.
Q6600, Intel integrated graphics, 2GB memory, 180GB Generic SATAII, WinXP.
CorzaX
8
Years of Service
User Offline
Joined: 12th Feb 2016
Location: Melbourne, VIC
Posted: 16th Mar 2016 12:24
Ah Belidos,

You're a champ! Yeah I did just add that line into the Disappear script. You've solved my problem though, thank you!

It seems easy when you put it that way yeah, and I do kinda run down what I wanna do in my head but maybe writing it down, as you suggested, would benefit me more.

Thanks again mate.

CorzaX
PM

Login to post a reply

Server time is: 2024-12-22 15:35:45
Your offset time is: 2024-12-22 15:35:45