Forum Jump :

Author Message

Posts: 24

Level: Member

Country: us
Location: In the dungeon to hell!
Age: 29
In-game name:

#1 Posted at 2017-09-21 23:35        
So here is my problem the vehicle respawn script works perfect the first time but it won't work after continuous usage, it just stops working. Trying to implement this so it works in Multiplayer, because the mission I'm making it for is a multiplayer mission. Below are the scripts calling it, as well as the two scripts responsible for respawning vehicles. Also to initialize the script its called in the editor like below.

In Editor: nul = [this,"marker1",-90] execVM "respawnVehicle.sqf"

(Note: when player dies last vehicle he used goes with them.)

waitUntil {!isNull player};
waitUntil {player == player};

switch (side player) do {

	case WEST: {

	case EAST: {

		player createDiaryRecord ["Diary", ["Notes","Do NOT die during this mission!<br/><br/>Created by Philip '5n4k3' Simonson"]];
		player createDiaryRecord ["Diary", ["Additional Intel","There are some BLUFOR and OPFOR present and they are fighting.<br/>Best not to get involved unless you have to."]];
		player createDiaryRecord ["Diary", ["Briefing","BLUFOR and OPFOR broke out into a small excursion (fight). Now<br/>they're trying to calm it down but, having trouble doing so. You<br/>have the option to help one of them out."]];

		task3 = player createSimpleTask ["Clear Chernogorsk"];
		task3 setSimpleTaskDescription ["Eliminate all OPFOR in Chernogorsk!","Clear Chernogorsk","Clear Chernogorsk"];
		task3 setTaskState "CREATED";

		task2 = player createSimpleTask ["Clear Elektrozavodsk"];
		task2 setSimpleTaskDescription ["Eliminate all OPFOR in Electrozavodsk!","Clear Elektrozavodsk","Clear Elektrozavodsk"];
		task2 setTaskState "CREATED";

		task1 = player createSimpleTask ["Stay Alive"];
		task1 setSimpleTaskDescription ["Do not die or mission failed!","Stay Alive","Don't die!"];
		task1 setTaskState "CREATED";
		player setCurrentTask task1;

	case CIVILIAN: {
		player createDiaryRecord ["Diary", ["Info","We're going to watch some silly stuff today!"]];


if(isNil {missionNamespace getVariable "PRS_Tasks"}) then {
	missionNamespace setVariable ["PRS_Tasks",true];
	missionNamespace setVariable ["PRS_Task1",false];
	missionNamespace setVariable ["PRS_Task2",false];
	missionNamespace setVariable ["PRS_Task3",false];
} else {
	private ["_t1", "_t2", "_t3"];
	_t1 = missionNamespace getVariable "PRS_Task1";
	_t2 = missionNamespace getVariable "PRS_Task2";
	_t3 = missionNamespace getVariable "PRS_Task3";
	if(_t1) then {
		task1 setTaskState "SUCCEEDED";
	if(_t2) then {
		task2 setTaskState "SUCCEEDED";
	if(_t3) then {
		task3 setTaskState "SUCCEEDED";

player addEventHandler ["Killed",{_var = player getVariable "PRS_DeathCount"; player setVariable ["PRS_DeathCount",_var+1]; nul = [] execVM "briefing.sqf"}];
player addEventHandler ["Respawn",{nul = player execVM "lastVehicle.sqf";}];

private ["_dude", "_veh"];
// parameters
_dude = _this;

_veh = objNull;
while {alive _dude} do {
	_veh = (vehicle _dude);
	if(_dude != _veh) then {
		_dude setVariable ["LastVehicle",_veh];
	sleep 1;
_veh = _dude getVariable "LastVehicle";
if(!isNull _veh) then {
	deleteVehicle _veh;
	_dude setVariable ["LastVehicle",objNull];

if(!isServer) exitWith {};
private ["_veh", "_marker", "_azimuth", "_type", "_markerb", "_pos", "_spawned"];

// parameters for procedure
_veh = _this select 0;
_marker = _this select 1;
_azimuth = _this select 2;

// respawn same vehicle at marker
_type = typeOf _veh;
_markerb = _marker + "_respawn";
waitUntil {!alive _veh || isNull _veh};
if(!alive _veh) then {
	deleteVehicle _veh;
_pos = getMarkerPos _markerb;
_spawned = createVehicle [_type, _pos, [], 0, "NONE"];
_spawned setDir _azimuth;
waitUntil {!isNull _spawned};
_spawned setVehicleInit format ["null = [this,%1,%2] execVM 'respawnVehicle.sqf';", _marker, _azimuth];

Please help and thanks in advance to anyone that can help... if more information is needed please let me know.

Philip "5n4k3" Simonson

Author Message

Posts: 33

Level: Member

Country: de
Location: K-Town
Occupation: Medic
Age: 35
In-game name: Officer D

#2 Posted at 2017-10-09 22:22        
Why not use the Simple Vehicle Respawn script? It works on hosted and dedicated servers.