OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: Gen.Iceman on 03 Aug 2008, 13:24:22
-
Hello all, iam having trouble running the vrs sqf script below with mando hitch.Whenever I hitch a vehicle it hitches for a second and then the vehicle returns back to its inital starting spot (as if its respawning)..I have the "destroyed" respawn time and the "idle" respawn time set to 3 minutes...any help is appreciated. :whistle:
Init field of hummvee:
v = [this, "", 180, 180] execVM "vrs_AI_crew.sqf"
vrs sqf:
/*
VEHICLE RESPAWN SCRIPT WITH CREW RESTRICTIONS
© May 2007 - norrin (norrins_nook@iprimus.com.au)
***********************************************************************************************************************************
Version 1.0
Based upon KaRRiLLioN's original vrs.sqf script heavily modified for use with playable and non-playable AI units and crew restrictions
IMPORTANT: ADD A GAMELOGIC NAMED Server
to the mission to prevent multispawn
to run this script place the following code in the init line of the vehicle:
v = [this, "vehicle name", x, y] execVM "vrs_AI_crew.sqf"
where x and y are the times you wish to set for the vehicle empty respawn delay and vehicle destroyed respawn delay
Note: the vehicle name must be in quotation marks eg. if vehicle name Hmm1 it must appear in the init line as "Hmm1",
if on the otherhand you don't want to rename your vehicles just put "" instead
**********************************************************************************************************************************
BEGIN vrs_AI_crew.sqf
*/
private ["_vcl","_respawndelay","_vclemptydelay","_dir","_pos","_type","_unit","_run","_wait","_delay"];
if (!local Server) exitWith {};
_vcl = _this select 0;
_name_vcl = _this select 1;
_vclemptydelay = _this select 2;
_respawndelay = _this select 3;
_dir = Getdir _vcl;
_pos = Getpos _vcl;
_type = typeOf _vcl;
_run = TRUE;
sleep 5;
for [{}, {_run}, {_run}] do
{
while {_vcl distance _pos < 5 && canMove _vcl} do
{
sleep 1;
};
while {canMove _vcl && count crew _vcl > 0 && ({damage _x}forEach crew _vcl)!= 1} do
{
_wait = Time + _vclemptydelay;
sleep 1;
};
while {canMove _vcl && count crew _vcl < 1 && Time < _wait} do
{
sleep 1;
};
while {canMove _vcl && {damage _x} forEach crew _vcl >= 1 && Time < _wait} do
{
sleep 1;
};
_delay = Time + _respawndelay;
while {!canMove _vcl && Time < _delay} do
{
sleep 1;
};
if (count crew _vcl < 1) then
{
deleteVehicle _vcl;
_vcl = _type createVehicle _pos;
_vcl setVehicleVarName _name_vcl;
player groupchat format ["%1", VehicleVarName _vcl];
_vcl setdir _dir;
sleep 1;
_vcl setvelocity [0,0,0];
_vcl setpos _pos;
sleep 1;
_vcl setvelocity [0,0,0];
sleep 2;
};
if ({damage _x} forEach crew _vcl >= 1)then
{
deleteVehicle _vcl;
_vcl = _type createVehicle _pos;
_vcl setVehicleVarName _name_vcl;
player groupchat format ["%1", VehicleVarName _vcl];
_vcl setdir _dir;
sleep 1;
_vcl setvelocity [0,0,0];
_vcl setpos _pos;
sleep 1;
_vcl setvelocity [0,0,0];
sleep 1;
call {[_vcl] execVM "vcl_lock\lock.sqf"};
};
sleep 2;
};
Regards,
Iceman
-
Probably this is the beginning of the cause:
while {_vcl distance _pos < 5 && canMove _vcl} do
{
sleep 1;
};
Your empty vehicles move away of the spawn point when hitched, the script might assume they have been abandoned away of the spawn position, a bit later the script deletes the vehicle and replaces it with a new one.
Also the forEach present in the script are quite odd, none of them has any sense for me.
For example, what is this supposed to do?
{damage _x} forEach crew _vcl >= 1
-
that I believe has to do with a crew restriction that can also be ran via another script added...iam not using the crew restriction though...
regards,
Iceman
-
Looks like somebody's tried to use the count command:
if ({damage _x >= 1} count crew _vc1 == count crew _vc1) then ...
Which more commonly would be done by using alive:
if ({alive _x} count crew _vc1 == 0) then {....
??? I think?
Wolfrug out.
-
so this respawn script wont work with mando hitch?
,Ice
-
The only relation between hitch and that script is that the hitch script moves the vehicle away of the spawning pos while the vehicle is empty, so the script might conclude that the vehicle is abandoned (empty and away of spawn position), so the script removes it and respawns it. Try to hitch a crewed vehicle and see what happens.
-
It all works fine when someone is in the vehicle... :dry:
ice
-
As expected :cool2:
The script considers abandoned an empty vehicle which is away of its spawn position, then removes it and replaces it by a new one. You would need to modify that respawn script so that it doesnt check for abandoned vehicles using that criteria.