Jump to content
Sign in to follow this  
Coolinator

How to remove dead bodies?

Recommended Posts

How do i remove dead bodies? At base, sometimes there pile of dead bodies from disconnected players. i want to remove them but like in a certain minimum amount of dead bodies.

For example, when there's 5 dead bodies on ground, their bodies will start deleting. I want to remove friendly bodies without affecting our enemy AI dead bodies because we still want to see enemy AI dead bodies that we just killed.. not from the friendly teammates at base who just disconnect and their dead body will lay on the ground at base forever.

Edited by Coolinator

Share this post


Link to post
Share on other sites

The limiting to just a "side" of bodies may be a little tough, or at least in my thoughts, but without that a simple script that would delete all dead bodies every 10 minutes would be:

while {true} do {

{
deleteVehicle _x;
sleep 0.01;
} forEach allDeadMen;

sleep 600;

};

The reason I say limiting to a side may be tough is because dead bodies are apart of the civilian side, not their original side when they were "alive".

Edited by JShock

Share this post


Link to post
Share on other sites
The limiting to just a "side" of bodies may be a little tough, or at least in my thoughts, but without that a simple script that would delete all dead bodies every 10 minutes would be:

while {true} do {

{
deleteVehicle _x;
sleep 0.01;
} forEach allDeadMen;

sleep 600;

};

Thank you but will this work on dedicated server? and how do i use this? could you explain step by step plz! sorry im still not sure how to iniatlize a script :(

Share this post


Link to post
Share on other sites
Thank you but will this work on dedicated server? and how do i use this? could you explain step by step plz! sorry im still not sure how to iniatlize a script :(

It should with the following put into your init.sqf:

if (isServer) then {

_clearBodies = [] spawn {

while {true} do {

{
deleteVehicle _x;
sleep 0.01;
} forEach allDeadMen;

sleep 600;

};  

};

Step by Step:

- if (isServer) makes sure this is run on the server, not the client

- When that is true it moves to "spawn" some code, all spawn does is make a set of code run in a scheduled environment, so instead of the script waiting for a result to come back from the code, the game continues to run as it normally would while the code within the "spawn" is run in the background

- The code itself is a simple while {true} do {} loop, which is essentially an "always" running loop, within that is a forEach loop that runs for each "dead man", and deletes "_x" which is the dead body, for each dead body on the map.

- Then sleep 600 is 600 seconds of a wait time between each "go through" (technical terms: each iteration) of the while loop (equivalent to 10 minutes)

Edited by JShock

Share this post


Link to post
Share on other sites


It should with the following put into your init.sqf:


Step by Step:

- if (isServer) makes sure this is run on the server, not the client

- When that is true it moves to "spawn" some code, all spawn does is make a set of code run in a scheduled environment, so instead of the script waiting for a result to come back from the code, the game continues to run as it normally would

- The code itself is a simple while {true} do {} loop, which is essentially an "always" running loop, within that is a forEach loop that runs for each "dead man", and deletes "_x" which is the dead body, for each dead body on the map.

- Then sleep 600 is 600 seconds of a wait time between each "go through" of the while loop (equivalent to 10 minutes)

okay thank you so much!!!! will this still work if i tried to do this?

put in init.sqf: execVM "dead.sqf";

then in my dead.sqf

if (isServer) then {

_clearBodies = [] spawn {

while {true} do {

{
deleteVehicle _x;
sleep 0.01;
} forEach allDeadMen;

sleep 600;

};  

};

if (isServer) then {

_clearBodies = [] spawn {

while {true} do {

{
deleteVehicle _x;
sleep 0.01;
} forEach allDeadMen;

sleep 600;

};  

};

Share this post


Link to post
Share on other sites
Yep should have the same effect.

wait sir, im hosting dedicated, shouldnt it be if (!isDedicated) instead of if (!isServer) or it doesnt really matter?

Share this post


Link to post
Share on other sites

First, I'm not using an "!", secondly, no it shouldn't really matter at least in your case since you are using it solely on a dedicated box. Just remember if you use (isDedicated) in place of (isServer) and what to test it to see if it works in the editor preview, it won't work, because previewing returns true for "server" not "dedicated".

Share this post


Link to post
Share on other sites
First, I'm not using an "!", secondly, no it shouldn't really matter at least in your case since you are using it solely on a dedicated box. Just remember if you use (isDedicated) in place of (isServer) and what to test it to see if it works in the editor preview, it won't work, because previewing returns true for "server" not "dedicated".

Ahh okay i get it now!!! thank you so much for clearing that up! and thank you for help, i really appreciate it :) im creating my first mission for Arma 3 and it took me 5 days to finish it lol. Thank you so much! :)

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×