Jump to content
Sign in to follow this  
yamajin82

suitcase help

Recommended Posts

Hello, I am working on a mission that has an officer carrying a suitcase in his hand, I have the script working well enough that he can hold it and I can retrieve it but when I kill the officer carrying it, it is often clipping through the ground and as a result it is sometimes unrecoverable. My question is how do I get him to drop it like he does his weapon, where it detaches from him right before he falls and rests like it should on the ground.

Phase 2 of my question is if the AI officer gets in a car, the suitcase is left hovering at the height it was when it was in his hand while he drives away without it. Is there a way to either hide it and have it still attached to him or simply add it to the vehicle's inventory? Thanks everyone!

Share this post


Link to post
Share on other sites

Without seeing your script it will be more difficult to see what more you can do or whats wrong with it. Do you have the suitcase setposatl after detach? That should eliminate the clipping, though might cause the suitcase to stand up instead.

Share this post


Link to post
Share on other sites

sorry about that, the script is carry.sqf:

switch (take) do

{

case 0:

{

_scase = _this select 0;

_man = _this select 1;

_scase attachto [_man, [-0.23,0,-0.15],"Pelvis"];

_scase setdir 75;

_scase removeAction act1;

act1 = _man addaction ["Drop Case","carry.sqf","",1,false,true,""];

take=1;scase = _scase;taken=true;

};

case 1:

{

_man = _this select 0;

detach scase;

scase setvelocity[.5,.5,-.5];

_man removeAction act1;

act1 = scase addaction ["Take Case","carry.sqf","",1,false,true,""];

take=0;

};

};

and in the suitcase init:

take=0; act1 = this addaction ["Take Case","carry1.sqf","",1,false,true,""]

and on the officer:

suitcase attachto [officer, [-0.03,-.105,-0.27], "LeftHandMiddle1"]; suitcase setdir 90

I'm very new to editing so I'm not sure where I would put the suitcase setposatl, any help is greatly appreciated.

Share this post


Link to post
Share on other sites

quick glance your script is not properly formatted for .sqf. You need to end all lines with ; and the setposatl would go after the detach command.

Share this post


Link to post
Share on other sites

I'm afraid that is quite a poor script really and should be rewritten. Poor use of variables and it's no MP friendly.

Try adding the death line to the script

case 0:

{

_scase = _this select 0;

_man = _this select 1;

_scase attachto [_man, [-0.23,0,-0.15],"Pelvis"];

_scase setdir 75;

_scase removeAction act1;

act1 = _man addaction ["Drop Case","carry.sqf","",1,false,true,""];

take=1;scase = _scase;taken=true;

[_scase,_man] spawn {waituntil {!alive (_this select 1) or take==1} ; detach (_this select 0);};// on death drop

};

I never had a problem picking it up if it was detached.

Share this post


Link to post
Share on other sites

For the vehicle you can check

Vehicle _unit != _ unit;

And the either detach the case and set its pos to [0,0,0]

Or use hideObject.

Share this post


Link to post
Share on other sites
I'm afraid that is quite a poor script really and should be rewritten. Poor use of variables and it's no MP friendly.

Try adding the death line to the script

case 0:

{

_scase = _this select 0;

_man = _this select 1;

_scase attachto [_man, [-0.23,0,-0.15],"Pelvis"];

_scase setdir 75;

_scase removeAction act1;

act1 = _man addaction ["Drop Case","carry.sqf","",1,false,true,""];

take=1;scase = _scase;taken=true;

[_scase,_man] spawn {waituntil {!alive (_this select 1) or take==1} ; detach (_this select 0);};// on death drop

};

I never had a problem picking it up if it was detached.

haha yeah, I dug it up in an old post from 5 years or so ago and was surprized it actually worked at all so I was pleased, but any improvements will be awesome. You guys are collectively the man! Oh, and I was just being lazy with copy&paste, all the ; are there.

Edited by yamajin82

Share this post


Link to post
Share on other sites

So I entered the on death drop to my .sqf and its still clipping through the ground. I'm assuming that I entered the code wrong. In my carry1.sqf the lines of code are inset by one space further each time, for example:

xxxxxxxxxxx

(space)xxxxxxxxxxxxx

(two spaces)xxxxxxxxxxxxxxx

(three spaces) xxxxxxxxxxxxxxxxx

Do I need to maintain that format or can i just go with:

xxxxxxxxxxxxxxxxx

xxxxxxxxxxxxxxxxxx

xxxxxxxxxxxxx

xxxxxxxxxxxx

Thanks!

Edited by yamajin82
clarity

Share this post


Link to post
Share on other sites

For the most part the whitespace at a beginning of a line doesn't matter to the game, it's mostly for human readability.

Which is easier to read?

if (!isNull (player getVariable "CurrentCamp")) exitWith {hint "Already have a camp"};

_nearbyUnits = player nearEntities["Man", 10];
_nearbyPlayers = [];

{
 		if (_x in _nearbyUnits) then
 		{
   		_nearbyPlayers set [count _nearbyPlayers, _x];
 		};
} forEach allPlayerUnits;

if (count _nearbyPlayers > 1) then { // more than 1 player within 10 meters.

	_spawncamp = createVehicle ["Box_IND_Wps_F", position player, [], 0, "CAN_COLLIDE"];
	player setVariable ["CurrentCamp", _spawncamp, true];
	player commandChat "Camp created!";

	_grp = createGroup west;
	_nearbyPlayers joinSilent _grp;
	_grp selectLeader player;

} else {

	player commandChat "Find a friend";
};

or

if (!isNull (player getVariable "CurrentCamp")) exitWith {hint "Already have a camp"};
_nearbyUnits = player nearEntities["Man", 10];
_nearbyPlayers = [];
{
if (_x in _nearbyUnits) then
{
_nearbyPlayers set [count _nearbyPlayers, _x];
};
} forEach allPlayerUnits;
if (count _nearbyPlayers > 1) then { // more than 1 player within 10 meters.
_spawncamp = createVehicle ["Box_IND_Wps_F", position player, [], 0, "CAN_COLLIDE"];
player setVariable ["CurrentCamp", _spawncamp, true];
player commandChat "Camp created!";
_grp = createGroup west;
_nearbyPlayers joinSilent _grp;
_grp selectLeader player;
} else {
player commandChat "Find a friend";
};

It's just good practice indenting code so it's more readable. Same as with a forum thread, if someone posts a wall of text are you gonna bother trying to read it? :)

Share this post


Link to post
Share on other sites

It wasn't right any way, I've tested this and it seems to be working.

switch (take) do
{
case 0:
{
 _scase = _this select 0;
  _man = _this select 1;
   _scase attachto [_man, [-0.23,0,-0.15],"Pelvis"];
    _scase setdir 75;
    _scase removeAction act1;
      act1 = _man addaction ["Drop Case","carry.sqf","",1,false,true,""];
   take=1;scase = _scase;taken=true;

    // on death drop
  [_scase,_man] spawn {waituntil {!alive (_this select 1) or take ==0} ;
   detach scase;
     (_this select 1) removeAction act1;
       [(_this select 1)] execvm "carry.sqf";
      take=1;
   };// on death drop

};


case 1:
{
 _man = _this select 0;
  detach scase;
   scase setvelocity[.5,.5,-.5];
    _man removeAction act1;
     scase removeaction act1;
      act1 = scase addaction ["Take Case","carry.sqf","",1,false,true,""];
   take=0;
};
};

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  

×