Jump to content
Sign in to follow this  
clydefrog

Stopping vehicles from moving

Recommended Posts

this is how attachto works

http://community.bistudio.com/wiki/attachTo

if the vehicles are not in the same area use a logic for each vehicle

name them all different ---- mygl1 == the logic for that vehicle

in the init

_nil = [this,mygl1] execVM "Veh_Respawn.sqf";this attachto [mygl1,[0,0,0]];

add this under the _car = _this select 0;

_object = _this select 1;

then at the end of the script above the last };

add

_car attachto [_object,[0,0,0]]; you may have to change the [0,0,0] to something like [0,0,2] if its in the ground

Share this post


Link to post
Share on other sites
this is how attachto works

http://community.bistudio.com/wiki/attachTo

if the vehicles are not in the same area use a logic for each vehicle

name them all different ---- mygl1 == the logic for that vehicle

in the init

_nil = [this,mygl1] execVM "Veh_Respawn.sqf";this attachto [mygl1,[0,0,0]];

add this under the _car = _this select 0;

_object = _this select 1;

then at the end of the script above the last };

add

_car attachto [_object,[0,0,0]]; you may have to change the [0,0,0] to something like [0,0,2] if its in the ground

Ok I think I understand now, after I've tried it I'll let you know how it goes, cheers.

Share this post


Link to post
Share on other sites

Not sure, if acceptable here, but you can use such init for stopping (version for tracked):

this allowCrewInImmobile true;{this setHit [_x, 1]} foreach ["PAS_P","PAS_L"];

Share this post


Link to post
Share on other sites

Well it seems like the game logic attach is working as the engine is on but it stays still, can move wheels but can't move around, but the vehicle respawn is not working, the wreck of the vehicle just stays there for ages, here's the script:

sleep .5;

if !(isServer) exitwith {};

private ["_delay","_car","_pos","_dir","_typeveh","_hgt","_grp","_vel","_speed","_sld","_x","_AIcrew","_AIcrew1","_AIcrew2"];

_delay = 10;       // set this for the delay to respawn a new vehicle after the old one is to damaged;

_car = _this select 0;
_object = _this select 1;
_pos = position _car;
_dir = direction _car;
_hgt = _pos select 2;
_vel = velocity _car;

sleep 2;

_AIcrew = [];
_AIcrew1 = [];
_AIcrew2 = [];
{_AIcrew = _AIcrew + [typeOf _x]} foreach crew _car;
{_AIcrew1 = _AIcrew1 + [(assignedVehicleRole _x select 0)];
_AIcrew2 = _AIcrew2 + [(assignedVehicleRole _x select 1)];
} foreach crew _car;

_typeveh = typeOf _car;
_grp = group _car;

while {true} do
{
sleep 1;

waituntil {!(canmove vehicle _car)};

sleep _delay;  

deleteVehicle _car;
_grp = creategroup east;


if (vehicle _car isKindOf "AIR") then {_pos set [2,500];_car = createVehicle [_typeveh, _pos, [],0,"fly"]} else {_car = _typeveh createVehicle _pos;};
_car setdir _dir;
_car setdamage 0;
_car setFuel 1;
_car setVehicleAmmo 1;
_car setpos _pos;


_sld = objnull;
_ii = 0;
{_sld = _grp createUnit [_x,_pos,[],0,"NONE"];
if (isnil{(_AIcrew2 select _ii)}) then {_sld action ["getin" + (_AIcrew1 select _ii),_car]}else{_sld action ["Getin" + (_AIcrew1 select _ii),_car,(_AIcrew2 select _ii)]};
_ii = _ii + 1;
} foreach _AIcrew;

_speed = 0;
_car setVelocity [(_vel select 0)+(sin _dir*_speed),(_vel select 1)+(cos _dir*_speed),(_vel select 2)];
_car attachto [_object,[0,0,0]]; you may have to change the [0,0,0] to something like [0,0,2] if its in the ground 
};

---------- Post added at 22:50 ---------- Previous post was at 22:43 ----------

Ok I think it's because you didn't comment out this part: "you may have to change the [0,0,0] to something like [0,0,2] if its in the ground "

I changed it and now it works, respawns after 10 seconds but one problem, it respawns with ammo and starts shooting, how can I change the script so it stops the respawned vehicles firing/remove their ammo?

nevermind problem solved, changed the line _car setVehicleAmmo 1; to _car setVehicleAmmo 0;

It all works now, thanks a lot for your help and thanks to everybody else too. They work exactly how I want them to now. Now I just need to hope it all still works properly when it goes on a server. One weird thing that doesn't really matter, but when the new vehicle spawns at the same time you see 3 guys stood by it but as soon as they get in 3 dead bodies fall out of it, they can't be replacing crew that are already inside can they? because normally they don't respawn with anybody inside which is why I needed to know how to do it, maybe it's just some weird animation fault?

Edited by clydefrog

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  

×