Jump to content
Sign in to follow this  
Newborn

vehicle respawn problem

Recommended Posts

i use a template script for the respawn but i have got the problem that the vehicle spawn in other directions.

the azimut at the start is for example 0 and after the respawn it spawns with 180.

i attached the script file has anyone an idea about this ???

_vehicle = _this select 0;

if (isServer) then

{

_spawntime = _this select 1;

_side = _this select 2;

_destroyedOnly = _this select 3;

_initLine = _this select 4;

_initLine = format ["%1; this disableTIEquipment true", _initLine];

_startpos = getPos _vehicle;

_type = typeOf _vehicle;

_inside = 0;

_tseconds = 0;

_meters = 0;

_eventdone = 0;

_eventnumber = 0;

_zonesize = 5;

_identityPos = "";

{

_identityPos = format ["%2-%1", _x, _identityPos];

} foreach _startpos;

_vehicle setVariable ["RESPAWN_IDENTITY_POS", _identityPos];

_wait = 1;

while {_wait == 1} do

{

_inside = 0;

_tseconds = 0;

_meters = _vehicle distance _startpos;

//if ((_meters <= _zonesize) && (_eventdone == 0)) then

//{

// _eventnumber = _vehicle addEventHandler ["HandleDamage", {false}];

// _eventdone = 1;

//};

//if ((_meters > _zonesize) && (_eventdone == 1)) then

//{

// _vehicle removeEventHandler ["HandleDamage", _eventnumber];

// _eventdone = 0;

//};

if ((!alive _vehicle) && (!isNull _vehicle)) then

{

sleep _spawntime;

deleteVehicle _vehicle;

_vehicle = _type createVehicle _startpos;

_vehicle setPos _startpos;

_vehicle setVariable ["RESPAWN_IDENTITY_POS", _identityPos];

if (_initLine != "") then

{

_vehicle setVehicleInit _initLine;

processInitCommands;

};

_eventdone = 0;

};

if (!(_destroyedOnly)) then

{

if (((_meters > _zonesize) || ((getDammage _vehicle) != 0)) && (!isNull _vehicle)) then

{

_people = crew _vehicle;

_inside = {_x isKindOf "Man"} count _people;

while {(_tseconds <= (_spawntime * 4)) && (_inside == 0) && (alive _vehicle) && (!(isNull _vehicle))} do

{

sleep 1;

_people = crew _vehicle;

_inside = {_x isKindOf "Man"} count _people;

_tseconds = _tseconds + 1;

};

if ((_inside < 1) && (alive _vehicle) && (!(isNull _vehicle))) then

{

deleteVehicle _vehicle;

_vehicle = _type createVehicle _startpos;

_vehicle setPos _startpos;

_vehicle setVariable ["RESPAWN_IDENTITY_POS", _identityPos];

if (_initLine != "") then

{

_vehicle setVehicleInit _initLine;

processInitCommands;

};

_eventdone = 0;

};

};

};

if(isNull _vehicle) then

{

private "_i";

_i = 1;

while {_i == 1} do

{

{

if (!(isNil {_x getVariable "RESPAWN_IDENTITY_POS"})) then

{

if ((_x getVariable "RESPAWN_IDENTITY_POS") == _identityPos) then

{

_i = 0;

_vehicle = _x;

};

};

} foreach vehicles;

sleep 0.25;

};

};

sleep 1;

};

};

Share this post


Link to post
Share on other sites

Try adding setdir as in the example below, just the highlighted line

if ((!alive _vehicle) && (!isNull _vehicle)) then
{
sleep _spawntime;
deleteVehicle _vehicle;
_vehicle = _type createVehicle _startpos;
_vehicle setPos _startpos;
[b]_vehicle setdir 0;// this line ************[/b]
_vehicle setVariable ["RESPAWN_IDENTITY_POS", _identityPos];
if (_initLine != "") then
{

If it works you may want to make it a variable and pass that to the game if you require a different direction.

There was a bug with setdir a while back where it didn't always work and it may not have been fixed.

Share this post


Link to post
Share on other sites

and if i want to make sure it spawns in the start position

am i wrong if i say it must look like that ???

_vehicle setdir = _startpos;

Share this post


Link to post
Share on other sites

_vehicle setdir _startdir you would have to add a direction variable it's not contained in _startpos

_startdir = _this select 5; place this near the top of the script

you will then have to change the way the script is called by addin an extra parameter

null=[xxx,xxx,xxx,xxx,0] execvm ect xxx would be the original code so don't change that.

Share this post


Link to post
Share on other sites

This stores the position of the vehicle...then stores the direction.

_startpos = getPos _vehicle;

_startdir = getDir _vehicle;

This restores the position....and then the direction :-

_vehicle setPos _startpos;

_vehicle setDir _startdir;

You're missing the red bits!

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  

×