Jump to content
kibaBG

[SOLVED] Help with ACE3 Vehicle Rearm Script

Recommended Posts

Hi, there. 

I am trying to make two "factories" in my mission - one producing fuel and the other vehicle ammo points. Both factories should produce a box filled with fuel and "ammo points" respectively. The fuel and ammo points use ACE3 framework.  
For the fuel factory I made these script  and it works perfectly (executed via initServer) : 

while {true} do {
sleep 1800;  
 _fuel = "CargoNet_01_barrels_F" createVehicle [4694.33,9483.27,0];
[_fuel, 1000] call ace_refuel_fnc_makeSource;
_marker = createMarker ["Fuel Produced!", [4697.51,9475.91,0]]; 
_marker setMarkerType "loc_Truck";
sleep 300;
deleteMarker "Fuel Produced!"
};

Every half hour it produces one barrel with 1000 fuel (ACE). 
I tried to make the same thing with ammo points for vehicle rearming but no success.  I am trying to implement ACE3 Rearm framework code (taken from https://ace3.acemod.org/wiki/framework/rearm-framework.html) :
 

while {true} do {
sleep 600;  
_ammobox = "CargoNet_01_box_F" createVehicle [5058.03,6888.37,0];
_ammobox = setVariable ["ace_rearm_isSupplyVehicle",true];
[_ammobox, 1200] call ace_rearm_fnc_setSupplyCount;
_marker = createMarker ["Ammo Produced!", [5056.13,6886.58,0]]; 
_marker setMarkerType "loc_Truck";
sleep 300;
deleteMarker "Ammo Produced!"
};

But it doesn't spawn anything, it doesn't show any error and I have no clue why isn't working. 

Big thanks to everyone who wants to help a big script nOOb like myself.                                                              


 


                     

Share this post


Link to post
Share on other sites

Ok, it spawns a crate but without any rearming points. 

Share this post


Link to post
Share on other sites

There was a corrupted character in the code you pasted:

 

e4nVMRm.png

 

Watch for those red dots - pasting into a code block here is an easy way to check for them.

 

Try this clean code (or just remove the red dot yourself):

while {true} do {
sleep 600;  
_ammobox = "CargoNet_01_box_F" createVehicle [5058.03,6888.37,0];
_ammobox = setVariable ["ace_rearm_isSupplyVehicle",true];
[_ammobox, 1200] call ace_rearm_fnc_setSupplyCount;
_marker = createMarker ["Ammo Produced!", [5056.13,6886.58,0]]; 
_marker setMarkerType "loc_Truck";
sleep 300;
deleteMarker "Ammo Produced!"
};

 

Share this post


Link to post
Share on other sites

Thank you for trying to help me! 
I deleted my sqf, made a new one and pasted your code ... still no luck. 😢
It is strange because if I make a crate in the editor and paste this in the init field it's working like a charm: 

this setVariable ["ace_rearm_isSupplyVehicle", true];
ace_rearm_defaultSupply=6000;

But obviously I need to implement pure script version of this. 

Share this post


Link to post
Share on other sites
1 hour ago, RCA3 said:

Wrong syntax.

 

Ah, good eye. I need new glasses!

 

Lose the "=":

_ammobox setVariable ["ace_rearm_isSupplyVehicle", true];

 

  • Like 1
  • Haha 1

Share this post


Link to post
Share on other sites

I corrected the syntax but still no avail. 😪
Can someone help me to integrate this : 

this setVariable ["ace_rearm_isSupplyVehicle", true];
ace_rearm_defaultSupply=6000;

with this :
 

while {true} do {
sleep 600; 
_ammobox = "CargoNet_01_box_F" CreateVehicle [5052.76,6887.21,0];
//?? 
_marker = createMarker ["Ammo Produced!", [5050.66,6886.46,0]];
_marker setMarkerType "loc_Truck";
sleep 300;
deleteMarker "Ammo Produced!";
};

 

Share this post


Link to post
Share on other sites

The box you are using can be configured as a rearm station in the editor and works fine in-game. However, spawning that box in-game and calling ace_rearm_isSupplyVehicle on it does not work.

 

Apparently, in order for this to work, the vehicle must have an ace_rearm_defaultSupply config entry.

 

So, you have a few options, in order of simplicity:

  • Find and use a box that works
  • Create a composition using the box you want and spawn that using @larrow's Eden Composition Spawning system.
  • Make an addon editing the config of the box you want

Understand that options 2 and 3 are far more complicated than option 1.

 

Now, the code you posted above is periodically spawning a new crate and marker on top of the old ones. This is ... inefficient. Perhaps you should describe exactly what it is you want to accomplish.

  • Like 1

Share this post


Link to post
Share on other sites

Thank you for pointing out I am not using the properly configurated box. 
I just changed the classname to proper one -> "Box_NATO_AmmoVeh_F" and now "the factory" is producing one crate filled with 1200 vehicle rearming points as intended. Problem is solved, thanks to you. ☺️
 

Quote

Now, the code you posted above is periodically spawning a new crate and marker on top of the old ones. This is ... inefficient. Perhaps you should describe exactly what it is you want to accomplish.


Actually it spawns a crate, marks it on the map for 5 min, then deletes the marker. Its just a reminder for the player that a new crate with rearming points is produced.

No markers or crates are spawning on top of each other as you can see on this screenshot:
 
https://drive.google.com/file/d/1CZGhw7NjzXD9A21XZZJU8pMJRnkCX5UR/view?usp=sharing

  • Like 1

Share this post


Link to post
Share on other sites
8 hours ago, kibaBG said:

No markers or crates are spawning on top of each other as you can see on this screenshot:

 

Oh, sorry, you are indeed deleting the markers. But each iteration does spawn a new crate without deleting the previous one. If that's fine for your needs then disregard!

Share this post


Link to post
Share on other sites

Yes, this was my intent. I added addAction so the player can delete the crate manually after they use all fuel or vehicle rearming points. 
 

while {true} do {
sleep 1800; 
_ammobox = "Box_NATO_AmmoVeh_F" CreateVehicle [5052.76,6887.21,0];
_ammobox addAction ["Destroy crate.", {deleteVehicle (_this select 0)}]; 
_marker = createMarker ["Ammo Produced!", [5050.66,6886.46,0]];
_marker setMarkerType "loc_Truck";
sleep 300;
deleteMarker "Ammo Produced!";
};

But it will be interesting if I can read about editing objects config somewhere. @Larrow script for composition spawning is very interesting and I definitely try to use it in my mission.   

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

×