Jump to content
curtcooll

Veh respawn script help

Recommended Posts

So as you can see the veh respawn works the issue is for some reason since installing the game 2 years later the bottum part does not work when trying to respawn the NPC pilots and gunners etc, It was working not sure what has changed it does give me some sort of bad vehicle type which im guess is something to do with the code where the unitsgrp create group part this script is someone else but the bottum part _unitsgrp = creategroup east; everything from there to the bottum was added by my mate 

========================================================= 
*/ 
   
if (!isServer) exitWith {}; 

// Define variables 
_unit = _this select 0; 
_delay = if (count _this > 1) then {_this select 1} else {30}; 
_deserted = if (count _this > 2) then {_this select 2} else {120}; 
_respawns = if (count _this > 3) then {_this select 3} else {0}; 
_explode = if (count _this > 4) then {_this select 4} else {false}; 
_dynamic = if (count _this > 5) then {_this select 5} else {false}; 
_unitinit = if (count _this > 6) then {_this select 6} else {}; 
_haveinit = if (count _this > 6) then {true} else {false}; 

_hasname = false; 
_unitname = vehicleVarName _unit; 
if (isNil _unitname) then {_hasname = false;} else {_hasname = true;}; 
_noend = true; 
_run = true; 
_rounds = 0; 

if (_delay < 0) then {_delay = 0}; 
if (_deserted < 0) then {_deserted = 0}; 
if (_respawns <= 0) then {_respawns= 0; _noend = true;}; 
if (_respawns > 0) then {_noend = false}; 

_dir = getDir _unit; 
_position = getPosASL _unit; 
_type = typeOf _unit; 
_dead = false; 
_nodelay = false; 
_crew = crew _unit; 

// Start monitoring the vehicle 
while {_run} do  
{     
    sleep (2 + random 10); 
      if ((getDammage _unit > 0.8) and ({alive _x} count crew _unit == 0)) then {_dead = true}; 

    // Check if the vehicle is deserted. 
    if (_deserted > 0) then 
    { 
        if ((getPosASL _unit distance _position > 10) and ({alive _x} count crew _unit == 0) and (getDammage _unit < 0.8)) then  
        { 
            _timeout = time + _deserted; 
            sleep 0.1; 
             waitUntil {_timeout < time or !alive _unit or {alive _x} count crew _unit > 0}; 
            if ({alive _x} count crew _unit > 0) then {_dead = false};  
            if ({alive _x} count crew _unit == 0) then {_dead = true; _nodelay =true};  
            if !(alive _unit) then {_dead = true; _nodelay = false};  
        }; 
    }; 

    	// Respawn vehicle
      if (_dead) then 
	{	
		if (_nodelay) then {sleep 0.1; _nodelay = false;} else {sleep _delay;};
		if (_dynamic) then {_position = getPosASL _unit; _dir = getDir _unit;};
		sleep 0.1;

		deleteVehicle _unit;
		sleep 2;
		_unit = _type createVehicle _position;
		_unit setPosASL _position;
		_unit setDir _dir;

		if (_haveinit) then {[[netID _unit, _unitinit], "fnc_setVehicleInit", true, true] spawn BIS_fnc_MP;};

		if (_hasname) then {[[netID _unit, _unitname], "fnc_setVehicleVarName", true, true] spawn BIS_fnc_MP;};

		_dead = false;

        // Check respawn amount 
        if !(_noend) then {_rounds = _rounds + 1}; 
        if ((_rounds == _respawns) and !(_noend)) then {_run = false;}; 
        sleep 1; 
         
        _unitsgrp = creategroup  east; 
		
             { typeof _x createUnit [getpos _unit, _unitsgrp];}  foreach _crew; 
              //helicoptertransport synchronizeObjectsAdd [_unitsGroup]; 
             _unitsGroup = units _unitsgrp; 
			 //_unitsgroup = synchronizeObjectsAdd [helicoptertransport]; 

for [{ _loop = 0 },{ _loop < count  _unitsGroup},{ _loop = _loop + 1}] do 
{     
    _guy = _unitsGroup select _loop; 
    //_guy setSkill (_AI_skillArray select _loop); 
    if (_loop == 0) then {_guy moveInDriver _unit}; 
	if (_loop == 0) then {_guy synchronizeObjectsAdd [helicoptertransport]}; 
    if (_loop == 1) then {_guy moveInTurret [_unit,[0]]};     
    //if (_loop == 1) then {_guy moveinturret _vcl_new};  
      
    sleep 0.1; 
}; 
              
}; 

};   

Share this post


Link to post
Share on other sites
6 hours ago, curtcooll said:

it does give me some sort of bad vehicle type

 

How is the script being called?

What is the exact error?

 

Consider pasting your .rpt file on a site like pastebin.com and sharing the link here.

  • Like 2

Share this post


Link to post
Share on other sites
5 hours ago, Harzach said:

 

How is the script being called?

What is the exact error?

 

Consider pasting your .rpt file on a site like pastebin.com and sharing the link here.

 

I just made a pastebin and the error is bad veh type thats all i get the veh spawns but ai does not and it was working back in 2020 100 percent as my mate help me with the part to spawn AI back into veh, I know prev that bad veh type refers to ID is wrong or something along those lines 

https://pastebin.com/QMcn6ZPF

Share this post


Link to post
Share on other sites

You should show the freaking .rpt file. We can already see ur script...

Share this post


Link to post
Share on other sites
2 hours ago, curtcooll said:

I just made a pastebin

 

Run Arma until you get the error. Close Arma. Find your most recent .rpt file (it will be in %localappdata%\Arma 3). Upload that file to pastebin.com or any similar site, then link it here.

Share this post


Link to post
Share on other sites
34 minutes ago, Harzach said:

 

Run Arma until you get the error. Close Arma. Find your most recent .rpt file (it will be in %localappdata%\Arma 3). Upload that file to pastebin.com or any similar site, then link it here.

oh ok i found it 

 

https://pastebin.com/YTtuaW93

Share this post


Link to post
Share on other sites

Rule of arma 3 script error fighting:

Always look in .rpt file for the first error caused by a script which occurs.

That error has to get fought first.

 

Therefore the script u r showing in op is the wrong one.

Share this post


Link to post
Share on other sites
2 minutes ago, sarogahtyp said:

Rule of arma 3 script error fighting:

Always look in .rpt file for the first error caused by a script which occurs.

That error has to get fought first.

 

Therefore the script u r showing in op is the wrong one.

 

Its the correct script, im still getting the bad vehicle type error, I just have so many different back ups had find out which was the latest one, I have the latest backup and it would seem that for whatever reason stuff is broke 

Share this post


Link to post
Share on other sites

Your .rpt is rife with undefined variable errors. Overall, it looks like there are a bunch of markers/waypoints/whatever missing, so the mission is completely broken.

 

To the point of the topic, _crew is undefined, so I'll ask once again, how is this script being called?

  • Like 1

Share this post


Link to post
Share on other sites
3 minutes ago, Harzach said:

Your .rpt is rife with undefined variable errors. Overall, it looks like there are a bunch of markers/waypoints/whatever missing, so the mission is completely broken.

 

To the point of the topic, _crew is undefined, so I'll ask once again, how is this script being called?

I can give you the entire mission so you can see so i have no idea as i have said its been years since ive scripted and its gonna take me weeks just to relearn everything again to even understand alot of the stuff, I honestly dont understand why there are so many errors back in 2020 everything was working fine i made sure even before i unistall the game unless somehow i deleted the complete working one and backup an older version which is possible 

Share this post


Link to post
Share on other sites

Hmm, may be I'm a little bit harsh but imho, you should consider re-working your whole scenario. You have too many errors and it's not a simple question of respawning vehicle. HQ is missing, Warning Message: Bad vehicle type can apply on any created unit (createUnit generates this kind of message, but that can be something else. Vehicle here doesn't mean vehicle like car or tank).

Frankly, you'll lost a lot of time trying to cheat/tweak a script you're not the author. Perhaps you're friend with gardenCrimson author and you could ask him a debug but,anyway, I doubt you'll solve all your problems.

First of all, you're in MP session and it's tough without any basic of scripting.

So, instead of "giving" us your mission, start to make things work, step by step. You'll find help here and even tools for building a decent scenario with all the stuff you want.

For example, you can find script/module for respawning a vehicle in MP, without difficulty.

The mean is totally different from your old script. Beyond multiple errors you can do, your original script is outdated, using outdated BI functions like bis_fnc_MP or missing custom ones like fnc_setVehicleVarName (in your post, but not in the link for gardenCrimson).

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
32 minutes ago, pierremgi said:

Hmm, may be I'm a little bit harsh but imho, you should consider re-working your whole scenario.

 

Yeah, it looks like this mission is cobbled together from other missions, some of which were built in Alpha.

 

The script in question is Tophe's Vehicle Respawn, which is vintage 2013. Not sure who that gardencrimson guy is, but he's just using Tophe's scripts, which he does credit to him.

  • Like 2

Share this post


Link to post
Share on other sites
55 minutes ago, pierremgi said:

Hmm, may be I'm a little bit harsh but imho, you should consider re-working your whole scenario. You have too many errors and it's not a simple question of respawning vehicle. HQ is missing, Warning Message: Bad vehicle type can apply on any created unit (createUnit generates this kind of message, but that can be something else. Vehicle here doesn't mean vehicle like car or tank).

Frankly, you'll lost a lot of time trying to cheat/tweak a script you're not the author. Perhaps you're friend with gardenCrimson author and you could ask him a debug but,anyway, I doubt you'll solve all your problems.

First of all, you're in MP session and it's tough without any basic of scripting.

So, instead of "giving" us your mission, start to make things work, step by step. You'll find help here and even tools for building a decent scenario with all the stuff you want.

For example, you can find script/module for respawning a vehicle in MP, without difficulty.

The mean is totally different from your old script. Beyond multiple errors you can do, your original script is outdated, using outdated BI functions like bis_fnc_MP or missing custom ones like fnc_setVehicleVarName (in your post, but not in the link for gardenCrimson).

 

 

 

I can respawn the veh not and issue but respawn the veh with the AI from before does not work as it used to work, I have removed the shop/money feature for now to resolve all other errors and the bad vehicle type is refer to this bit of code which my mate made which no longer seems to work, It used to work as it would resync the module for calling the heli to wherver but it wont respawn the AI, I used to have a script where it would respawn a single pilot and that pilot would get into the heli but then my mate come up with this. 

       // _unitsgrp = creategroup  east; 
		
             //{ typeof _x createUnit [getpos _unit, _unitsgrp];}  foreach _crew; 
              //helicopter synchronizeObjectsAdd [_unitsGroup]; 
            // _unitsGroup = units _unitsgrp; 
			 //_unitsgroup = synchronizeObjectsAdd [helicopter]; 

//for [{ _loop = 0 },{ _loop < count  _unitsGroup},{ _loop = _loop + 1}] do 
//{     
   // _guy = _unitsGroup select _loop; 
    //_guy setSkill (_AI_skillArray select _loop); 
  //  if (_loop == 0) then {_guy moveInDriver _unit}; 
//	if (_loop == 0) then {_guy synchronizeObjectsAdd [helicopter]}; 
  //  if (_loop == 1) then {_guy moveInTurret [_unit,[0]]};     
    //if (_loop == 1) then {_guy moveinturret _vcl_new};  

 

Share this post


Link to post
Share on other sites
26 minutes ago, Harzach said:

 

Yeah, it looks like this mission is cobbled together from other missions, some of which were built in Alpha.

 

The script in question is Tophe's Vehicle Respawn, which is vintage 2013. Not sure who that gardencrimson guy is, but he's just using Tophe's scripts, which he does credit to him.

Yeah i know the errors im getting with the shop system were issues i had before so i have removed that for now everything else is working the veh respawn is working when i remove the above code but the AI that were in that veh without that code does not work anymore as it used to, Is there a script that i can find that can respawn the AI, I used to have old script that would spawn only the pilot and the pilot would have to then get in to the heli, i just cant work out why its giving bad vehicle type from what i can work out that my mate mate that lot of code i commented out that used to work would create the AI that were in the veh and place them back in there no issue 

Share this post


Link to post
Share on other sites

I just spoke to my mate and from what she said the functions used in the code could possibly not supported functions in the game which would explain why shop/money system is throwing errors also where would i find where the newer functions that were changed 

Share this post


Link to post
Share on other sites
28 minutes ago, curtcooll said:

where would i find where the newer functions that were changed 

 

https://community.bistudio.com/wiki/Category:Scripting_Commands

https://community.bistudio.com/wiki/Category:Arma_3:_Functions

These links will not give you an instant knowledge for MP scripting.

Just for your few line script, you should apply at least :

params

remoteExec instead of BIS_fnc_MP

Not saying it's hard to understand what synchronizeObjectsAdd could offer for your stuff. :h:  Sorry, I will not dig into your bunch of sqfs for that.

 

  • Like 1

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

 

 

 

 

 

These links will not give you an instant knowledge for MP scripting.

Just for your few line script, you should apply at least :

 

 

 

 

Not saying it's hard to understand what synchronizeObjectsAdd could offer for your stuff. :h:  Sorry, I will not dig into your bunch of sqfs for that.

 

yeah what that used to do synchronizeobjectsadd was to resync the system to let you recall heli to wherver you are, I understand what this does and such but what i dont understand is what was changed in arma functions/code so what i need to change, Issue i have with my dexlixa is its gonna take me months to even understand anything let alone fix what has been changed in arma with this script, I guess ill have to wait for my mate if she decides to help me fix it, I know it will take someone who is experinced to fix this is no time, its just annoying that its gonna take me months just to understand the basicis let alone even fix the simple of things, It just sucks i know i had this sorta issue before when arma changed ID of certain things but at least then i was fresh out of uni from coding so it was easy now its not, I appreciate your help but trying to understand what you just send me is like rocket science and with 5 kids its just gonna take months like it did back in 2019 when i started back trying to learn, I understand what im also typing here is hard to understand as my english is terrible.

Share this post


Link to post
Share on other sites

The real point to be taken away here is that the mission is a house of (deprecated) cards. It would be better, and probably less time-consuming, to start fresh. Decide what exactly it is you want out of your mission, and build it using the community's latest knowledge. 

 

I mean, it's a King of the Hill mission. KotH has sort of come a long way since 2013...

 

DG9yWgJ.png

Share this post


Link to post
Share on other sites
13 minutes ago, Harzach said:

The real point to be taken away here is that the mission is a house of (deprecated) cards. It would be better, and probably less time-consuming, to start fresh. Decide what exactly it is you want out of your mission, and build it using the community's latest knowledge. 

 

I mean, it's a King of the Hill mission. KotH has sort of come a long way since 2013...

 

DG9yWgJ.png

Cheers well 90 percent of my mission works you can respawn into the AI team mates you have if you die, I just made it for a 1v1 with my mate, Its only really a few lines of code that need sorting out to fix the issues, Im going to be taking the respawn script i have  and give it to my mate for his server for patrols, I know what the issue is and the line of code that is messed up and thats due to the game change in some sort of function, I think this here is the issue as the veh error issue is whatever if i can figure out what to change, Its just an issue with my autism when something does not work i have to get it fixed other wise it just drives me nuts, If not for helping my mate setup his server i would not be having any issue lol

createUnit [getpos _unit, _unitsgrp];}

 

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

×