Jump to content
Sign in to follow this  
kiptanoi

Clean up (delete) and resend code, howto?

Recommended Posts

How to delete all things, if plane got shoot down, and resend it?

I have try this, but it is no good.

So how can I check if plane got shoot down, and if it is then resend it, and if it not shoot down then drop my soldier.

This is what I have now.

Activate within init.sqf with

fncCallAT1 	= compile preProcessFile "script\fncReinforce.sqf";

waitUntil {Time >= 5};
["USMC_Soldier_AT",1.0] Call fncCallAT1;

fncReinforce.sqf

// ["USMC_Soldier_AT",1.0] Call fncCallAT1;

// Configuration
_unitType 	= _this select 0;
_unitSkill 	= _this select 1;
_pos 		= getPos ASpad;
_dir 		= getPos ASpad;
_trg		= position player;
_airtype 	= "C130J";
_pType 	        = "USMC_Soldier_Pilot";
mygroup 	= creategroup side player;
_Message 	= "This is eagle two, we are inbound with your reinforce drop, please stand by...";



// Create plane
_vehicle = createVehicle [_airtype, _pos, [], 0, "FLY"];
_vehicle setVehicleVarName "plane";
plane = _vehicle;

// Create pilot
_unit = mygroup createUnit [_pType, _pos, [], 0, "FLY"];
_unit setVehicleVarName "pilot";
pilot = _unit;
_unit moveinDriver _vehicle;
_unit flyinHeight 200;
_vehicle flyinHeight 200;

// make trigger to check plane
_trig = createTrigger["EmptyDetector",getPos player];
_trig setTriggerArea[0,0,0,false];
_trig setTriggerActivation["NONE","PRESENT",true];
_trig setTriggerStatements["(!alive plane)", "hint 'I am dead';[] execVM 'script\fncCleanUpReinforce.sqf'", ""];

// Create soldier
unit = mygroup createUnit [_unitType, Position player, [], 0, "FORM"];
unit setSkill _unitSkill;
unit setRank "PRIVATE";
unit moveInCargo [_vehicle, 0];
unit setVehicleVarName "AT1";
AT1 = unit;



// fly to player
_wp10 = mygroup addwaypoint[_trg,0];
_wp10 setWaypointSpeed "FULL";
_wp10 setwaypointtype "MOVE";
_wp10 setWaypointStatements ["true", "eject=true;"];
sleep 2;

// fly home	
_target22 = getPos ASpad;
_wp11 = mygroup addwaypoint[_target22,0];
_wp11 setWaypointSpeed "NORMAL";
_wp11 setwaypointtype "MOVE";
_wp11 setWaypointStatements ["true", "deleteIsReady=true;"];


// Eject soldier at player position
waitUntil{ eject };
	(driver _vehicle) sideChat _Message;
	unassignVehicle AT1;
	AT1 action ["EJECT", _vehicle];
	[AT1] join player;
	deletevehicle _trig;


// delete all
waitUntil{deleteIsReady};
	deletevehicle _trig;
	deletevehicle _vehicle;
	deletevehicle _unit;


fncCleanUpReinforce.sqf

player sideChat "dead";
sleep 2;
deleteVehicle _trig; // delete trigger
deleteVehicle unit; // delete soldier
deletevehicle _unit; // delete pilot
deletevehicle _vehicle; // delete plane
player sideChat "deleted";
sleep 10;
player sideChat "send one more time";
["USMC_Soldier_AT",1.0] Call fncCallAT1;

Edited by Kiptanoi

Share this post


Link to post
Share on other sites

Is it not possible to delete stuff if they are shoot down, and resend the same code?

Share this post


Link to post
Share on other sites

If I understand this correctly you are basically wanting to reset the circumstances if things don't go right for the player right? To basically set up a "Redo"?

In the delete section you have a variable called _trig. I assume that is associated with the _trg from the below segement where it is set = to the players position?

// Configuration

_unitType = _this select 0;

_unitSkill = _this select 1;

_pos = getPos ASpad;

_dir = getPos ASpad;

_trg = position player;<--------Here

_airtype = "C130J";

_pType = "USMC_Soldier_Pilot";

mygroup = creategroup side player;

_Message = "This is eagle two, we are inbound with your reinforce drop, please stand by...";

If that is the case you would just need to update the players position in the script before it begins the new round or commands.

As far as the vehicals if they are respawned via script I always exectued a simple delete script when it is no longer alive or has been abandoned at the end of the creation scripting

[_airtype] exec "deleteveh.sqs"

Deleteveh.sqs

 _veh=_this select 0

#reset
_wait=180

#loop
_wait=_wait-2
~1
?!(alive _veh):goto "Delete"
_driver = driver _veh 
_gunner = gunner _veh
_commander= commander _veh

~1
?!(isnull _driver):goto "reset"
?!(isnull _gunner):goto "reset"
?!(isnull _commander):goto "reset" 

#Delete
?(_wait>0):goto "loop"
deleteVehicle _veh

#exit
exit

That way any vehicle that is created and destroyed or abandoned is deleted 180 seconds.. or however long you want after it is destroyed. Really good for places where allot of vehicle spawning can block runways and what not.

As far as the other items this is a list of deletion commands. Not sure what would apply without looking through them all but I am sure there is something. If you don't already have this link saved. Do so it is a great tool. The commands are in the link

http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA

deleteCenter
deleteCollection
deleteGroup
deleteIdentity
deleteLocation
deleteMarker
deleteMarkerLocal
deleteStatus
deleteTarget
deleteVehicle
deleteWaypoint

I found this which might apply if there is still a pilot in the plane

A safer way to delete unit1 if it is, or might be, inside a vehicle is:

unassignVehicle unit1

unit1 setPos [0,0,0]

deleteVehicle unit1

This is because you cannot call deleteVehicle on a unit (soldier) who's currently inside a Vehicle.

Hope I helped

Edited by Sardaukar17
Posted wrong code

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  

×