Jump to content
Sign in to follow this  

Recommended Posts

My convoluted and clunky way of loading and unloading cargo.

 

First the truck and the things attached to it, in this case a German 305 blitz. In its init

this addAction ["load","cargo.sqf",nil,1,false, true, "true", "true", 9, false]; this addAction ["unload","unload.sqf",nil,1,false, true, "true", "true", 9, false];

I attach 2 invisible helipads to it, works better thats why.

 

Game logic with this in its init

pad1 attachto [truck1,[0,-2,0]];

Then the second game logic with this in its init

pad2 attachto [truck1,[0,-9,0]];

That gives you an easy to set location to unload to anywhere. Its right behind the truck but I scatter them a bit more when I unload cause they had a bit of a catching fire problem when they collided as they flew out of the truck 😂.

 

The inits of helipad 1

pad1 disableCollisionWith truck1;

and into the second helipad

pad3 disableCollisionWith box1;    pad3 disableCollisionWith box2;  pad3 disableCollisionWith box3;

Next cargo.sqf to load with

if ((box1 distance truck1) < 8) then  
{box1 attachTo [pad1, [0, 1, 0]];

box1 attachTo [pad1];
detach box1;

box2 attachTo [pad1, [-.5, -1, 0]];

box2 attachTo [pad1];
detach box2;

box3 attachTo [pad1, [.5, -1, 0]];

box3 attachTo [pad1];
detach box3;}

else {hint "too far"};

And to unload we have unload.sqf

 

if ((box1 distance truck1) < 8) then  

{box1 attachTo [pad3, [0, 1, 0]];

box1 attachTo [pad3];
detach box1;

box2 attachTo [pad3, [-.5, -3, 0]];

box2 attachTo [pad3];
detach box2;

box3 attachTo [pad3, [.5, -5, 0]];

box3 attachTo [pad3];
detach box3;}

else {hint "too far"};

Before I had the distance checker in there they would fly across the map, even the unload script had to have it or they would fly to the helipad on the back of the truck. Took awhile cause I aint no good with IF statements. And don't give me the wiki cause the wiki gives no examples like that above, I have to go find them.

 

The first post of this thread from 2019

fixed it for me. Everything I do runs on borrowed snippets from others code. Insert the loading where the hint was and put else too far at the end.

 

This does not care what vehicle it is, you don't have to add support for another truck or van. I could have done that with a van or even a car but then you blow up both the supplies and the car. Theirs been plenty of good cargo handling systems made for the game but they either have to have support added for more trucks and vans or BI breaks them with an update. I don't think BI will break their own code.

 

I detach as soon as I attach even in the truck, works better especially unloading.

 

Now onto making this work with generic supplies so I am not naming the boxes. The truck and the helipad is okay to name for me and you have to name them to attach stuff to them.

  • Like 1

Share this post


Link to post
Share on other sites

Okay I've come to my senses

Get rid of the helipads. I used those cause I saw someone else doing but he was not doing this exactly.

 

So Cargo.sqf is now this

 

if ((box1 distance truck1) < 8) then  


{box1 attachTo [truck1, [0, -1, 0]];

box1 attachTo [truck1];
detach box1;

box2 attachTo [truck1, [-.5, -2, 0]];

box2 attachTo [truck1];
detach box2;

box3 attachTo [truck1, [.5, -2, 0]];

box3 attachTo [truck1];
detach box3;}

else {hint "too far"};

 and the unload.sqf is this

 

if ((box1 distance truck1) < 8) then  


{box1 attachTo [truck1, [0, -9, 0]];

box1 attachTo [truck1];
detach box1;

box2 attachTo [truck1, [-.5, -11, 0]];

box2 attachTo [truck1];
detach box2;

box3 attachTo [truck1, [.5, -13, 0]];

box3 attachTo [truck1];
detach box3;}

else {hint "too far"};

I forgot I have the truck as a reference for all of it and I can attach the cargo to it then attach again to it and detach it well behind it so its where I want it.

Share this post


Link to post
Share on other sites

Okay I made it to where it can have 3 trucks but it doesn't do much good unless you change the name of the boxes so each one can pick up from a different spot. I cannot get it to pick up nearsupplies  even though that is a named thing in the wiki it says its an undefined variable. I tried to define it but it didn't work. If I can get it to do that then this will be a generic cargo hauler.

 

So one sqf for 3 trucks is this

 

params ["_veh"]; 
if (truck1 == _veh) then {
if ((box1 distance truck1) <8) then  

{box1 attachTo [truck1, [0, -1, 0]];

box1 attachTo [truck1];
detach box1;

box2 attachTo [truck1, [-.5, -2, 0]];

box2 attachTo [truck1];
detach box2;

box3 attachTo [truck1, [.5, -2, 0]];

box3 attachTo [truck1];
detach box3;}

else {hint "too far"};

};


if (truck2 == _veh) then {
if ((box1 distance truck2) <8) then  

{box1 attachTo [truck2, [0, -1, 0]];

box1 attachTo [truck2];
detach box1;

box2 attachTo [truck2, [-.5, -2, 0]];

box2 attachTo [truck2];
detach box2;

box3 attachTo [truck2, [.5, -2, 0]];

box3 attachTo [truck2];
detach box3;}

else {hint "too far"};

};



if (truck3 == _veh) then {
if ((box1 distance truck3) <8) then  

{box1 attachTo [truck3, [0, -1, 0]];

box1 attachTo [truck3];
detach box1;

box2 attachTo [truck3, [-.5, -2, 0]];

box2 attachTo [truck3];
detach box2;

box3 attachTo [truck3, [.5, -2, 0]];

box3 attachTo [truck3];
detach box3;}

else {hint "too far"};

};

I didn't change the name of the cargo boxes/ammo boxes for the 2nd and third trucks but you'd just put more boxes on the map, name the box4 box5 and box6 and so on. Then change the box numbers in the above script for the second and third trucks to match.

 

I will one day figure out how to do this generically and just pick up unnamed cargo.

 

Okay I forgot the unload.sqf which has been changed to reflect a 2nd truck hauling different cargo from a different place

 

params ["_veh"];   
if (truck1 == _veh) then {

if ((box1 distance truck1) < 8) then  


{box1 attachTo [truck1, [0, -9, 0]];

box1 attachTo [truck1];
detach box1;

box2 attachTo [truck1, [-.5, -11, 0]];

box2 attachTo [truck1];
detach box2;

box3 attachTo [truck1, [.5, -13, 0]];

box3 attachTo [truck1];
detach box3;}

else {hint "too far"};
};


if (truck2 == _veh) then {
if ((box4 distance truck2) < 8) then  


{box4 attachTo [truck2, [0, -9, 0]];

box4 attachTo [truck2];
detach box4;

box5 attachTo [truck2, [-.5, -11, 0]];

box5 attachTo [truck2];
detach box5;

box6 attachTo [truck2, [.5, -13, 0]];

box6 attachTo [truck2];
detach box6;}

else {hint "too far"};


};


if (truck3 == _veh) then {

if ((box1 distance truck3) < 8) then  


{box1 attachTo [truck3, [0, -9, 0]];

box1 attachTo [truck3];
detach box1;

box2 attachTo [truck3, [-.5, -11, 0]];

box2 attachTo [truck3];
detach box2;

box3 attachTo [truck3, [.5, -13, 0]];

box3 attachTo [truck3];
detach box3;}

else {hint "too far"};

};

For some reason a base object in the game in an undefined variable reammobox_f.

 

Share this post


Link to post
Share on other sites

Yea, I managed to make the truck generic but so far not the cargo boxes.

playersCar = vehicle player;


if ((box1 distance playersCar) <8) then  

{box1 attachTo [playersCar, [0, -1, 0]];

box1 attachTo [playersCar];
detach box1;

box2 attachTo [playersCar, [-.5, -2, 0]];

box2 attachTo [playersCar];
detach box2;

box3 attachTo [playersCar, [.5, -2, 0]];

box3 attachTo [playersCar];
detach box3;}

else {hint "too far"};


if ((box4 distance playersCar) <8) then  

{box4 attachTo [playersCar, [0, -1, 0]];

box4 attachTo [playersCar];
detach box4;

box5 attachTo [playersCar, [-.5, -2, 0]];

box5 attachTo [playersCar];
detach box5;

box6 attachTo [playersCar, [.5, -2, 0]];

box6 attachTo [playersCar];
detach box6;}

else {hint "too far"};

playersCar = vehicle player; fixed at least the truck problem. Now I have to get the boxes/cargo to work that way.

 

unload.sqf

playersCar = vehicle player;

if ((box1 distance playersCar) < 8) then  


{box1 attachTo [playersCar, [0, -9, 0]];

box1 attachTo [playersCar];
detach box1;

box2 attachTo [playersCar, [-.5, -11, 0]];

box2 attachTo [playersCar];
detach box2;

box3 attachTo [playersCar, [.5, -13, 0]];

box3 attachTo [playersCar];
detach box3;};



if ((box4 distance playersCar) < 8) then  


{box4 attachTo [playersCar, [0, -9, 0]];

box4 attachTo [playersCar];
detach box4;

box5 attachTo [playersCar, [-.5, -11, 0]];

box5 attachTo [playersCar];
detach box5;

box6 attachTo [playersCar, [.5, -13, 0]];

box6 attachTo [playersCar];
detach box6;}

else {hint "too far"};

 Made a lift script which is not hard but it doesn't work like I want it to

 

playersCar = vehicle player;
this = this object;

if (( playersCar distance this) <5) then
{this attachTo [playersCar, [0, -1, 0]];
this attachTo [playersCar];
this detach};

Keeps saying it needs another ; but I think that will be the hand loading script if or when I get it to work, adding an addaction to the boxes themselves calling that as an sqf. Time for bed

  • Like 1

Share this post


Link to post
Share on other sites

I was not going to ask for help but finally something cropped up that I do not understand. I put this in the init of all the ammo boxes in the map.

playersbox = this;  
this = playersbox;
this addAction ["lift","lift.sqf",nil,1,false, true, "true", "true", 9, false];                                                                                                                                                                                                  this addAction ["drop","drop.sqf",nil,1,false, true, "true", "true", 9, false];    

Then this is the sqf for lifting

if ((playersbox distance player) <3) then  

{playersbox attachTo [player, [0, 1, 1.5]]};

and for dropping, which throws it LOl but it works for both loading and unloading of a vehicle, needs adjustment.

playersCar = vehicle player;
if ((playersbox distance playerscar) <10) then 
{playersbox attachTo [player, [0, 7, 4]]};
detach playersbox;

I don't need playerscar in that but it works better with it, why, who knows. I took it out and then it just sat the box in front of me.

 

The thing disturbing me is that it will only work on ONE BOX.

 

All the ammo boxes have the same init, none of them are named, they are all the same ammo box. The addaction shows on every box but it only works on one box. Yeah I know I can't write scripts for **** but this is very puzzling.

 

I might try to adding the action to the player again but last time I tried that I had to name all the boxes.

Share this post


Link to post
Share on other sites

By saying it only works on ONE BOX, do you mean a specific type/class of box, or that it only works the first time you execute the action, and after that you can click at any other and nothing happens?

I don't know if this can actually help you, but this is what I use in some addAction script when I want to "mount" a medium container and a quadbike - whether there's one nearby - upon a pickup truck.
It searches whether you have an accepted vehicle nearby, then searches for the container classes and for a quad. Maybe it helps you get some ideas for yours.

 

Spoiler

private _nearbyVehicles = nearestObjects[player, ["Car"], 15];
{
    private _currentVehicle = _x;
    if (typeName _currentVehicle == "OBJECT" && (typeOf _currentVehicle in ["B_GEN_Offroad_01_gen_F", "I_G_Offroad_01_repair_F", "O_G_Offroad_01_repair_F", "B_G_Offroad_01_repair_F"])) then
	{
	
    _nearbyVehicles = nearestObjects [_currentVehicle, ["B_T_Quadbike_01_F", "B_Quadbike_01_F", "C_Quadbike_01_F"], 20, false, false];

    _nearbyContainers = nearestObjects [_currentVehicle, [
        "Land_Cargo10_cyan_F",
        "Land_Cargo10_white_F",
        "Land_Cargo10_light_green_F",
        "Land_Cargo10_military_green_F",
        "Land_Cargo10_grey_F",
        "Land_Cargo10_sand_F",
        "Land_Cargo10_yellow_F",
        "Land_Cargo10_blue_F",
        "Land_Cargo10_orange_F",
        "Land_Cargo10_red_F",
        "Land_Cargo10_brick_red_F",
        "Land_Cargo10_IDAP_F"
    ], 20, false, false];

    {
        _x attachTo [_currentVehicle, [0, -2.1, 0.75]];
		_x setDir 270;
		

    } forEach _nearbyContainers;

    {
        _x attachTo [_currentVehicle, [0, -2, 3.25]];
		_x setDir 90;
		

    } forEach _nearbyVehicles;
	
	};
} forEach _nearbyVehicles;

 

 

Share this post


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

By saying it only works on ONE BOX, do you mean a specific type/class of box, or that it only works the first time you execute the action, and after that you can click at any other and nothing happens?

I don't know if this can actually help you, but this is what I use in some addAction script when I want to "mount" a medium container and a quadbike - whether there's one nearby - upon a pickup truck.
It searches whether you have an accepted vehicle nearby, then searches for the container classes and for a quad. Maybe it helps you get some ideas for yours.

 

No it will work on different ones but it will work on only one of them, it will work on that same one over and over as well. I changed them out and put 6 of the same ammobox on the ground and it still only worked on one of them.

 

That will likely help me try to use "nearsupplies" which I have tried to do in the past but I couldn't get it to work. maybe nearbject or nearest.

 

Whats weird to me in doing all of this is that things in the game are called undefined variables. The game certainly knows of these objects exist, they are in the game, so how can they be undefined but anyway that part of my learning that I'm going through.

Share this post


Link to post
Share on other sites

Someone already made a script to pick them up and set them down but it won't load them into trucks that are very high.

I can get them inside the truck but then I cannot drop them with that script cause I can't see the object. He was using smaller vehicles I guess. Some adjustments will have to be made. In that post he showed me how to do several things though.

 

 

Share this post


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

The thing disturbing me is that it will only work on ONE BOX.

 

Global variables are unique. When your mission starts, the last box processed wins.

playersbox = this;  
this = playersbox;

You assign your variable correctly, but the second line is the same as "this = this" or "playersbox = playersbox." It's redundant and unnecessary.

 

But we still need to make this work for all boxes. Fortunately, Arma makes that easy.

 

https://community.bistudio.com/wiki/addAction

 

We simply send this to the script the addAction is calling:

this addAction ["lift","lift.sqf",nil,1,false, true, "true", "true", 9, false];

 

Since it is being called by an addAction, the script will automatically take four params through this:

params ["_target", "_caller", "_actionId", "_arguments"];

if ((_target distance _caller) <3) then  

{_target attachTo [_caller, [0, 1, 1.5]]};

 

Now it's a dynamic system that can be added to any object.

 

Have a look through the first few links in my signature.

 

If you find yourself confused about how a command does or doesn't work, check its entry on the Wiki. Syntax is generally explained there in detail, and there are usually a few example use cases. If you are still unsure, ask!

  • Like 1

Share this post


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

 

Global variables are unique. When your mission starts, the last box processed wins.


playersbox = this;  
this = playersbox;

You assign your variable correctly, but the second line is the same as "this = this" or "playersbox = playersbox." It's redundant and unnecessary.

 

But we still need to make this work for all boxes. Fortunately, Arma makes that easy.

 

https://community.bistudio.com/wiki/addAction

 

We simply send this to the script the addAction is calling:


this addAction ["lift","lift.sqf",nil,1,false, true, "true", "true", 9, false];

 

Since it is being called by an addAction, the script will automatically take four params through this:


params ["_target", "_caller", "_actionId", "_arguments"];

if ((_target distance _caller) <3) then  

{_target attachTo [_caller, [0, 1, 1.5]]};

 

Now it's a dynamic system that can be added to any object.

 

Have a look through the first few links in my signature.

 

If you find yourself confused about how a command does or doesn't work, check its entry on the Wiki. Syntax is generally explained there in detail, and there are usually a few example use cases. If you are still unsure, ask!

Thank you Harzach

 

Here is something you need to know about what I've been trying to learn.

_object = (_this select 0);

_user = (_this select 1);

From kibaBG's script linked above. He simply calls the boxes objects and the player user, writes the scipt and it works with none of the undefined variable stuff like what I get all the time. So I guess thats how you define a variable in some scripts, maybe not all.

 

See I have have thought that I had to go get the name or base name of the vehicles or object from the configs and actually define it, IT NEVER WORKED LOL.

 

Yeah that thing I was doing in the init with the playersbox. I was trying to brute force it. When I still worked, I had jobs where much brute force was needed much of the time. Thus my legs wore out before I got to be 60.

Share this post


Link to post
Share on other sites
24 minutes ago, Alleged Accomplice said:

He simply calls the boxes objects and the player user

 

 

No, he uses the params being passed to the script. It's the same as in my example with the addAction. 

 

The addAction is passing this to lift.sqf, which in turn we can parse out to four local variables:

params ["_target", "_caller", "_actionId", "_arguments"];

//  which is the same as

private _target = _this select 0;
private _caller = _this select 1;
private _actionId = _this select 2;
private _arguments = _this select 3;

 

Those four variables are determined by the addAction's functionality. If we were to just call a script from an object's init:

this execVM "myScript.sqf";

 

this contains the object, which is passed to the script. In the script, we could do something like:

params ["_this"];

hint str _this;

 

This will print a hint containing the object reference. If the object were an empty quadbike, we might see a hint like:

Quote

1cd8885a040# 5: quadbike_01_f.p3d

 

If the object has a variable name, it will print that variable name.

 

Again, read through the first few links below.

Share this post


Link to post
Share on other sites
Quote

No, he uses the params being passed to the script. It's the same as in my example with the addAction. 

 

The addAction is passing this to lift.sqf, which in turn we can parse out to four local variables:

 

Here is what I put into the init of the ammoboxes. The same thing he did. If its its getting stuff from somewhere else and using it, I don't have whatever it is and it worked. I am probably not understanding you when you say params passed to the script.

this addAction["Pickup Box",{
_object  = (_this select 0);
_user = (_this select 1);
_object attachTo[_user,[0,1,1],"Pelivs"];
},nil,1.5,false,false,"","true",2,false,"",""];
this addAction["Drop Box",{
{
  detach _x;
  _x enableSimulationGlobal true;
} forEach attachedObjects player;
},nil,1.5,false,false,"","true",2,false,"",""];

I'm guessing the params are _object = (this select 0) and the next one.

Share this post


Link to post
Share on other sites

It's the same thing.

 

Expanded vertically for clarity:

this addAction 
[
	"Pickup Box",
	{
		params ["_target", "_caller", "_actionId", "_arguments"];
		_target attachTo [_caller, [0,1,1], "Pelivs"];
	},
	nil,
	1.5,
	false,
	false,
	"",
	"true",
	2,
	false,
	"",
	""
];

this addAction 
[
	"Drop Box",
	{
		params ["_target", "_caller", "_actionId", "_arguments"];
		{
			detach _x;
			_x enableSimulationGlobal true;
		} forEach attachedObjects _caller;
	},
	nil,
	1.5,
	false,
	false,
	"",
	"true",
	2,
	false,
	"",
	""
];

 

Share this post


Link to post
Share on other sites
38 minutes ago, Alleged Accomplice said:

I am probably not understanding you when you say params passed to the script.

 

You can tell a script to execute:

execVM "myScript.sqf";
//  myScript.sqf

hint "TESTING";

You can tell a script to execute taking into account certain information:

"TESTING" execVM "myScript.sqf";
//  myScript.sqf

hint _this;

That's the most basic example I can think of.

 

Further:

["TESTING",1,2,3] execVM "myScript.sqf";
//  myScript.sqf

params ["_string","_vala","_valb","_valc"];

hint format ["%1, %1, %2-%3-%4",_string,_vala,_valb,_valc];

SD3M6kI.png

Share this post


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

It's the same thing.

 

Expanded vertically for clarity:


this addAction 
[
	"Pickup Box",
	{
		params ["_target", "_caller", "_actionId", "_arguments"];
		_target attachTo [_caller, [0,1,1], "Pelivs"];
	},
	nil,
	1.5,
	false,
	false,
	"",
	"true",
	2,
	false,
	"",
	""
];

this addAction 
[
	"Drop Box",
	{
		params ["_target", "_caller", "_actionId", "_arguments"];
		{
			detach _x;
			_x enableSimulationGlobal true;
		} forEach attachedObjects _caller;
	},
	nil,
	1.5,
	false,
	false,
	"",
	"true",
	2,
	false,
	"",
	""
];

 

Makes sense now but I needed to see the way he did it cause me an the wiki rarely get along. I needed to see something besides a = 3 and then making a hint appear and other stuff like that. It would be a better wiki for those like me, those who really need it, if it had like real things being done like moving a box, putting it in a truck or whatever.

 

I know the wiki is beloved here but they should have put script they actually used in the wiki.

 

I have to change it to where drop will attach to the truck. When I get too close to the truck and look at it it gives me the trucks embedded addactions, and I do not see the drop menu. So fixing it so it attaches and then detaches to the truck. Basically it will get thrown sideways.

 

Oh God I had a lot of fun throwing the boxes with my old script, they can really be made to fly if you attach them to you like 7 meters in front and then they detach on the way there.

 

Basic examples are okay but the examples with meat on the bones work better

Share this post


Link to post
Share on other sites
1 minute ago, Alleged Accomplice said:

I know the wiki is beloved here but they should have put script they actually used in the wiki.

 

Specific examples are beyond the scope of the Wiki. The Wiki describes the syntax, structure, and basic usage of a command/function/etc. Use the community to help work out the rest - which is what you are doing here, now.

Share this post


Link to post
Share on other sites
1 minute ago, Harzach said:

 

Specific examples are beyond the scope of the Wiki. The Wiki describes the syntax, structure, and basic usage of a command/function/etc. Use the community to help work out the rest - which is what you are doing here, now.

Hey I got

playersCar = vehicle player;

from the wiki. I don't think it was exactly that way in the wiki but somehow that struck me when I was looking at that page. "HEY THAT MIGHT WORK! And it did.

 

Anyway thank you again for all your help. I aint slept in many hours so I might begin to make less and less sense soon LOL.

Share this post


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

And it did.

 

Just understand that if the player is not in a car, then your variable playersCar now equals the player themself.

 

https://community.bistudio.com/wiki/vehicle

 

Quote

Vehicle in which given unit is mounted. If none, unit is returned. Alternatively, use objectParent instead.

 

So, objectParent is a better solution.

Share this post


Link to post
Share on other sites
5 minutes ago, Alleged Accomplice said:

Anyway thank you

 

You are welcome. Ask questions. They're free and there are folks here who are happy to answer them.

Share this post


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

 

Just understand that if the player is not in a car, then your variable playersCar now equals the player themself.

 

https://community.bistudio.com/wiki/vehicle

 

 

So, objectParent is a better solution.

The things I have learned here will likely cause me to try to use the script I found here on the truck or to just throw the ammoboxes using attach detach. I don't have to use playerscar anymore now I don't think so who knows. Now that I know more I will cobble together something clunky but it will somehow still work.

 

I had one going the other day that kept saying the cargo was too far away but it still loaded and another that threw an error every time but still worked.

Share this post


Link to post
Share on other sites
16 minutes ago, Alleged Accomplice said:

I don't have to use playerscar anymore

 

Just so it's clear, "playersCar" is itself meaningless. You could use 

raspberryBrontosaurus = vehicle player;

instead.

Share this post


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

 

Just so it's clear, "playersCar" is itself meaningless. You could use 


raspberryBrontosaurus = vehicle player;

instead.

Yeah, I just stuck with what I saw. I'm not even sure if I have to use vehicle player as much anymore either. Since I can't sleep I am beginning to test.
 

I don't really play the game much at all. Sometimes I go on KOTH. I do stuff like this. I created a multiplayer battle several years back but I have not done that in awhile. Never posted it cause I used so many addons or whatever no one would want it. It was fun to create it, it was complicated as hell, it helps keep my mind sharp even if I'm not good at it. I cannot create a battle with AI in it for **** so I don't do those.

Share this post


Link to post
Share on other sites

Hand load trucks, put in the init of every box you want to load or might want to. If nothing is in the the init of any of them you can select them all and attributes and add it to the init of all of them at once. you "pick up" the box then you stand about a yard/meter from the truck and look up at the box , roll the wheel and click drop when you want to load it. Looking up takes the trucks embedded addaction out of the way.

didn't actually work. I thought it did.

 

on taller modern trucks it may have to be this. I have been using the new DLC WWII trucks to work on this with.

Didn't work either

If loading into a van then this

 

this addAction["Pickup Box",{
_object  = (_this select 0);
_user = (_this select 1);
_object attachTo[_user,[0,1.5,1],"Pelivs"];
},nil,1.5,false,false,"","true",2,false,"",""];
this addAction["Drop Box",{
{
  detach _x;
  _x enableSimulationGlobal true;
} forEach attachedObjects player;
},nil,1.5,false,false,"","true",2,false,"",""];

In the last one the box will just drop and not get thrown. Its best to make the box indestructible when throwing them cause they will land on each other and sometimes catch fire. I left "pelvis" in that cause this is partially borrowed code and sometimes when I take things out, they stop working, so even if it seems unnecessary, as long as it doesn't do anything I just leave it.;

 

Gonna work on auto loading from the inside of the truck and loading static weapons/turrets more now.

 

Edit, I forgot I need to unload this

  • Like 1

Share this post


Link to post
Share on other sites

Some of that above stopped working for me. Anyway I fixed it. I have this weird feeling that after you've used a saved scenario for so much testing it gets polluted. I had everything on that one, all the bombs all the loading and unloading.

 

 

 

 

 

Unload, add to the trucks init.

this addAction ["load","cargo3.sqf",nil,1,false, true, "true", "true", 5, false];

this addAction ["unload","unload.sqf",nil,1,false, true, "true", "true", 3, false];

Has the load for loading from the inside which still works. I cannot get away from naming the boxes though I am still working on it.

 

if ((box1 distance truck1) < 5) then  


{box1 attachTo [truck1, [0, -1, 0]];

box1 attachTo [truck1];
detach box1;

box2 attachTo [truck1, [-.5, -2, 0]];

box2 attachTo [truck1];
detach box2;

box3 attachTo [truck1, [.5, -2, 0]];

box3 attachTo [truck1];
detach box3;}

else {hint "too far"};

That is the load.sqf

 

This is the unload which works for handloaded or auto loaded.

if ((box1 distance truck1) < 50) then

{box1 attachTo [truck1, [0, -9, 0]];
detach box1;

box2 attachTo [truck1, [-.5, -11, 0]];
detach box2;

box3 attachTo [truck1, [.5, -13, 0]];
detach box3;}

Cannot take the IF first line out of that.

Share this post


Link to post
Share on other sites

This is embarrassing but on some of these I was simply attaching the ammoboxes to myself and couldn't see them because they were behind me. They unloaded with the unload script even though they were attached to me. I have deleted some but I am going back up and deleting the others I know do not work like they are supposed to.

 

This below works but read below that on how they have to be unloaded.

this addAction["Pickup Box",{ 
_object  = (_this select 0); 
_user = (_this select 1); 
_object attachTo[_user,[0,3,3],"Pelivs"]; 
},nil,1.5,false,false,"","true",7,false,"",""]; 
this addAction["Drop Box",{ 
{ 
  detach _x; 
  _x enableSimulationGlobal true; 
} forEach attachedObjects player; 
},nil,1.5,false,false,"","true",7,false,"",""];

 The other autoload and unload still work. The handload above works but you have to get in the back of the truck and re pickup the boxes and drop them again to unload. You can't ready your weapon or you cant look at them, if you do you switch to the other side and it unreadies the weapon. 

On some vehicles this may not work. I was using the WWII German open cargo truck. You can do the handload and unload without naming a thing. I loaded a Flak 38 into one but using this you have to be careful and get it just right or use this below.

this addAction ["load","gunload.sqf",nil,1,false, true, "true", "true", 12, false];

this addAction ["unload","ungunload.sqf",nil,1,false, true, "true", "true", 12, false];

You can load the Flak 36 but it looks funny. Heck you can even fire it from the truck.

if ((gun1 distance truck9) < 10) then  


{gun1 attachTo [truck9, [0, -2, .5]];

gun1 attachTo [truck9];
}

That loads it and the next unloads it.

if ((gun1 distance truck9) < 50) then

{gun1 attachTo [truck9, [0, -9, 0]];
detach gun1};

I may be done with this. I got what I wanted in a roundabout way, not the way I wanted but it works.

 

Only the Hemtt cargo works out of the big modern trucks. The troop transport just let the boxes fall through in most cases.  The hemtt cargo you have to load them close to the rear. You can't get in but you can aim through tailgate and repickup the boxes. I assume the pickup trucks will work and that vans will.

  • Like 1

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  

×