Jump to content
  • 0

Problem with vehicle delete


flyxdvd

Question

Hello,

 

im using this mission script from blackeagls.

 

I like to edit/code some stuff in since i study game-development(early years) i like to experiment with code etc.

Im trying to add that vehicle's despawn when the mission is finished it works atm, but not for the first time mission spawned.

 

example: restarting server, going to the mission and clear it, i get the mission like "mission has been cleared by survivors" but the vehicles don't despawn/deleted. the mission then re-spawns for a second time and when i clear it i get

"mission has been cleared by survivors" and deletes the vehicle's.

 

so the main problem is why the first mission doesn't delete the vehicles.

 

i edited a total of 2 files and added 1 files so here they are:

 

 
the SM1.sqf

private ["_coords","_MainMarker","_wait","_crate];
 
 
//set variable
 
//Find a safe position on map to spawn marker and AI units
_FindNewPosition = false;
_coords = [mapCenter,300,mapRange,30,0,10,0] call BIS_fnc_findSafePos;
{
if ((_x distance _coords) < MinDistanceFromMission) then {
_FindNewPosition = true;
};
} foreach AllMissionCoords;
if (_FindNewPosition) exitWith {[] execVM "\q\addons\custom_server\AIMission\Major\SM1.sqf"};
AllMissionCoords = AllMissionCoords + [_coords];
 
//Sleeps specifed ammount in init.sqf
sleep blck_AISpawnTime;
 
//Sends message to all players about the AI Mission
["Rebels are gathering! Check your map for the location!"] execVM "\q\addons\custom_server\AIMission\AIM.sqf";
 
//Sets public variable for all units to see mapmarker
Ccoords = _coords;
publicVariable "Ccoords";
[] execVM "debug\addmarkers.sqf";
 
//Crates the crate
_crate = objNull;
_crate = createVehicle ["Box_NATO_Wps_F",[(_coords select 0) - 3, _coords select 1,0],[], 0, "CAN_COLLIDE"];
 
//Sets variables (not sure if needed but left just incase so cleanup doesnt happen
_crate setVariable ["Mission",1,true];
_crate setVariable ["ObjectID","1",true];
_crate setVariable ["permaLoot",true,true];
 
//Fills the crate with items
[_crate] call blck_FillBoxes_Major;
 
//Spawns the AI
[_coords,blck_MinAI_Major,blck_MaxAI_Major,blck_WeaponList_Major,blck_SpawnVeh_Major] execVM "\q\addons\custom_server\AIMission\spawnai.sqf";
 
//Waits until player gets near the _crate to end mission
waitUntil{{isPlayer _x && _x distance _crate < 10  } count playableunits > 0};
 
//Announces that the mission is complete
["The Rebel Gathering has settled down!"] execVM "\q\addons\custom_server\AIMission\AIM.sqf";
 
//Remove AI Mission Position Tracker
AllMissionCoords = AllMissionCoords - [_coords];
 
//Removes the markers
[] execVM "debug\remmarkers.sqf";
MissionGo = 0;
Ccoords = 0;
publicVariable "Ccoords";
 
 
 
//the delete vehicle exec
[] execVM "\q\addons\custom_server\AIMission\delveh1.sqf";
 
//Spawns mission again

[] execVM "\q\addons\custom_server\AIMission\major\SM1.sqf";

 

the spawnVehicle.sqf

//Debug information 
diag_log format["SpawnVehicles _this: %1",_this];
 
//Gets position information from spawnai1.sqf
_pos = _this select 0;
 
//Creates a group for Vehicles
_aiGroup = createGroup RESISTANCE;
_ai = ObjNull;
 
//Finds a safe positon in area to spawn
_safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
 
//Spawns 1 AI Unit
"O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai = this", 0.1, "PRIVATE"];
removeBackpackGlobal _ai;
removeAllItemsWithMagazines  _ai;
_ai setVariable["LASTLOGOUT_EPOCH",1000000000000];
_ai setVariable["LAST_CHECK",1000000000000];
_ai setVehicleVarName "ai1"; ai1 = _ai;\\gave the ai's a name to delete it with. so with the rest.
_ai enableAI "TARGET";
_ai enableAI "AUTOTARGET";
_ai enableAI "MOVE";
_ai enableAI "ANIM";
_ai enableAI "FSM";
_ai allowDammage true;
_ai setCombatMode "RED";
_ai setBehaviour "COMBAT";
_ai setVariable ["AI",true,true];
 
 
//Spawns 1 AI Unit
_ai1 = ObjNull;
_safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
"O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai1 = this", 0.1, "PRIVATE"];
removeBackpackGlobal _ai1;
removeAllItemsWithMagazines  _ai1;
_ai1 setVariable["LASTLOGOUT_EPOCH",1000000000000];
_ai1 setVariable["LAST_CHECK",1000000000000];
_ai1 setVehicleVarName "ai2"; ai2 = _ai1;
_ai1 enableAI "TARGET";
_ai1 enableAI "AUTOTARGET";
_ai1 enableAI "MOVE";
_ai1 enableAI "ANIM";
_ai1 enableAI "FSM";
_ai1 allowDammage true;
_ai1 setCombatMode "RED";
_ai1 setBehaviour "COMBAT";
_ai1 setVariable ["AI",true,true];
 
 
//Spawns 1 AI Unit
_ai2 = ObjNull;
_safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
"O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai2 = this", 0.1, "PRIVATE"];
removeBackpackGlobal _ai2;
removeAllItemsWithMagazines  _ai2;
_ai2 setVariable["LASTLOGOUT_EPOCH",1000000000000];
_ai2 setVariable["LAST_CHECK",1000000000000];
_ai2 setVehicleVarName "ai3"; ai3 = _ai2;
_ai2 enableAI "TARGET";
_ai2 enableAI "AUTOTARGET";
_ai2 enableAI "MOVE";
_ai2 enableAI "ANIM";
_ai2 enableAI "FSM";
_ai2 allowDammage true;
_ai2 setCombatMode "RED";
_ai2 setBehaviour "COMBAT";
_ai2 setVariable ["AI",true,true];
 
 
//Spawns 1 AI Unit
_ai3 = ObjNull;
_safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
"O_G_Soldier_SL_F" createUnit [_safepos, _aiGroup, "_ai3 = this", 0.1, "PRIVATE"];
removeBackpackGlobal _ai3;
removeAllItemsWithMagazines  _ai3;
_ai3 setVariable["LASTLOGOUT_EPOCH",1000000000000];
_ai3 setVariable["LAST_CHECK",1000000000000];
_ai3 setVehicleVarName "ai4"; ai4 = _ai3;
_ai3 enableAI "TARGET";
_ai3 enableAI "AUTOTARGET";
_ai3 enableAI "MOVE";
_ai3 enableAI "ANIM";
_ai3 enableAI "FSM";
_ai3 allowDammage true;
_ai3 setCombatMode "RED";
_ai3 setBehaviour "COMBAT";
_ai3 setVariable ["AI",true,true];
 
 
//Spawns a AI Vehicle
_safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
_veh = ObjNull;
_veh = createVehicle["B_G_Offroad_01_armed_F", _safepos, [], 0, "NONE"];
_veh setVariable["LASTLOGOUT_EPOCH",1000000000000];
_veh setVariable["LAST_CHECK",1000000000000];
_veh setVehicleVarName "veh1"; veh1 = _veh; \\gave the vehicle a name so i can delete it. did this with both of em.
//Moves 2 AI units into vehicle
_ai moveInAny _veh;
_ai1 moveInAny _veh;
//So Vehicle doesnt despawn
EPOCH_VehicleSlotsLimit = EPOCH_VehicleSlotsLimit + 1;
EPOCH_VehicleSlots pushBack str(EPOCH_VehicleSlotsLimit);
_slot = EPOCH_VehicleSlots select 0;
_veh setVariable ['VEHICLE_SLOT',_slot,true];
EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_slot];
EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
publicVariable 'EPOCH_VehicleSlotCount';
_veh call EPOCH_server_setVToken;
//Creates vehicle inventory
clearWeaponCargoGlobal    _veh;
clearMagazineCargoGlobal  _veh;
clearBackpackCargoGlobal  _veh;
clearItemCargoGlobal       _veh;
 
 
_safepos = [_pos,0,27,0,0,20,0] call BIS_fnc_findSafePos;
_veh2 = ObjNull;
_veh2 = createVehicle["B_G_Offroad_01_armed_F", _safepos, [], 0, "NONE"];
_veh2 setVariable["LASTLOGOUT_EPOCH",1000000000000];
_veh2 setVariable["LAST_CHECK",1000000000000];
_veh2 setVehicleVarName "veh2"; veh2 = _veh2;
_ai2 moveInAny _veh2;
_ai3 moveInAny _veh2;
EPOCH_VehicleSlotsLimit = EPOCH_VehicleSlotsLimit + 1;
EPOCH_VehicleSlots pushBack str(EPOCH_VehicleSlotsLimit);
_slot = EPOCH_VehicleSlots select 0;
_veh2 setVariable ['VEHICLE_SLOT',_slot,true];
EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_slot];
EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
publicVariable 'EPOCH_VehicleSlotCount';
_veh2 call EPOCH_server_setVToken;
clearWeaponCargoGlobal    _veh2;
clearMagazineCargoGlobal  _veh2;
clearBackpackCargoGlobal  _veh2;
clearItemCargoGlobal       _veh2;

 

delveh1.sqf is the delete vehicle type of script which is called at the end of the mission.

{
_x action ["Eject", veh1];
} forEach crew veh1;
deleteVehicle veh1;
deleteVehicle ai1;
deleteVehicle ai2;
 
{
_x action ["Eject", veh2];
} forEach crew veh2;
deleteVehicle veh2;
deleteVehicle ai3;
deleteVehicle ai4;

 
Any help would be greatly appreciated ^^
kind regards,
Flyx
Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...