Scripts / Despawning Character(WIP & Need Help(

Author
Message
Volga
9
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 18th Nov 2014 21:29
Hi. I'm trying to destroy a character. I'm new to LUA. I wrote a basic code for that. Character is disappearing but there are some problems. Character does not attack before disappears.(I know why it happens. The reason for this is changing the main. However I don't know how to link codes. Switch command maybe?) When the character disappears, his weapon does not disapper. Also, even if the character disappears, I can't pass through the character as if he is still there. How can I solve this problem? I will be glad if you share the code which I need. Thanks in advance.

Code:

function spawn_init(e)
end

function despawncharacter_main(e)
PlayerDX = g_Entity[e]['x'] - g_PlayerPosX; PlayerDY = g_Entity[e]['y'] - g_PlayerPosY; PlayerDZ = g_Entity[e]['z'] - g_PlayerPosZ;
PlayerDist = math.sqrt(math.abs(PlayerDX*PlayerDX)+math.abs(PlayerDY*PlayerDY)+math.abs(PlayerDZ*PlayerDZ));
if PlayerDist < 200 then
Destroy(e)
end
end

Vertigo
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Nov 2014 13:27
remember to backup the original ai_soldier.lua script



no easy way to hide the gun im afraid as they arent linked to the model but seperate

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Volga
9
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 19th Nov 2014 17:32
Thank you but when I save this code as "despawncharacter.lua", it gives an error. Which function name should I use to name it? Also, do I need to add this to global.lua?

Vertigo
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Nov 2014 18:58
your script name must match the function names

i.e. to call it despawncharacter.lua
you must change
Quote: "function ai_soldier_main(e)"
to
Quote: "despawncharacter_main(e)"

the same for _init(e) and _exit(e)
(only the 'function' calls that are ai_soldier though)

life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Volga
9
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 19th Nov 2014 19:31
Thank you, now I can pass through the character but it doesn't attack before it despawns.

Vertigo
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 19th Nov 2014 20:08
they do


life's one big game

windows vista ultimate

i5 @3.3ghz, 4gb ram, geforce gtx460, directx 11
Volga
9
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 19th Nov 2014 20:28
I deleted the code and copied again and that happened:

Vertigo
Volga
9
Years of Service
User Offline
Joined: 31st May 2014
Location: Turkey
Posted: 19th Nov 2014 20:29
That:

Vertigo

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-05-02 08:02:17
Your offset time is: 2024-05-02 08:02:17