Guest major gandhi Posted July 11, 2004 Hi, I'm currently trying to implement TJ's cargo-script into my helicopter-addon. (btw I'm a script-noob) The scripts is started but doesn't work corectly in game. Here is the script: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ; BAS Cargo Sling - adapted by TJ 2003 ?(BAS_60Effects == 0):exit player groupchat "sling-script activated" (I made this and the other groupchat-things to see which part of the script is executed in game) _helo = _this select 0 _player = driver _helo ; ?("bas_ah60l" countType [(_helo]) == 1 ): exit (I deleted it because I assume this line only makes sure that the DAP-version can't carry cars) ?!(driver _helo == player):exit #check1 player groupchat "check1" ? !isEngineOn _helo : exit _warned = 0 _action = 0 player groupchat "check2" _heavycargo1= nearestObject [ _helo, "hmmwv"] ? (getpos _helo select 2) < 20 && (getpos _helo select 2)>3 && speed _helo < 10 && _heavycargo1 distance _helo < 15 : goto "liftoption" player groupchat "check3" ~8 goto "check1" #liftoption player groupchat "proceeding" bas_incargo = 1 ?! (local _heavycargo1):goto "nonlocal" _canlift = _helo addaction [format ["Attach HMMWV"], "\BWMOD_NH90\scripts\liftcargo.sqs"] #lifting ? _heavycargo1 distance _helo > 12 : _helo removeaction _canlift; goto "check1" ? bas_w == 1 : goto "next" ~1 goto "lifting" #next Hint format ["%1,\n120Km/h Speed Limit\nWhilst Transporting\nCargo.",name driver _helo] _helo removeaction _canlift ;_drop = driver _helo addaction [format ["Unload HMMWV"], "\BWMOD_NH90\scripts\dropcargo.sqs"];_action = 1 #Grabing _carry = (getpos _helo select 2) -6 ? _carry <0:_carry = 0 _heavycargo1 setpos [(getpos _helo select 0), (getpos _helo select 1),_carry] _rope = "CargoRope" createvehicle [0,0,0] #lifted ~0.001 ;set the position ? (getpos _helo select 2)>6.1:_heavycargo1 setpos [getpos _helo select 0, getpos _helo select 1, (getpos _helo select 2) - 6] ? (getpos _helo select 2)<=6.1:_heavycargo1 setpos [getpos _helo select 0, getpos _helo select 1, 0] ? (getpos _helo select 2)>6.1:_rope setpos [getpos _heavycargo1 select 0, getpos _heavycargo1 select 1, (getpos _heavycargo1 select 2) + 3.12] ? (getpos _helo select 2)<=6.1:_rope setpos [getpos _heavycargo1 select 0, getpos _heavycargo1 select 1, (getpos _helo select 2) -2.5] #rope _heavycargo1 setDir (getDir _helo) _rope setDir (getDir _helo) ? (speed _helo) > 15 || (getpos _heavycargo1 select 2) >=2.5: _helo removeaction _drop; _action= 0 ? (speed _helo) < 15 && (getpos _heavycargo1 select 2) < 2.5 && (bas_w == 1) && _action == 0 && (getdammage _helo) <0.9: _drop = _helo addaction [format ["Unload HMMWV"], "\BWMOD_NH90\scripts\dropcargo.sqs"];_action = 1 ?! (alive _helo) || (driver _helo != player): _helo removeaction _drop; _action= 0;exit ?! (player in _helo): _helo removeaction _drop; _action= 0;exit ? abs(speed _helo) >100 && _warned==0: Hint format ["W A R N I N G !!!\n\nSpeed Limit\n 120km/h. \n\n%1\nWATCH YOUR SPEED",name driver _helo]; _warned = 1 ? abs(speed _helo) > 120 && _warned == 1: Hint format ["W A R N I N G !!!\n\nSpeed Limit Exceeded.\n\n %1\nREDUCE SPEED NOW,\nCargo Sling at\nSnapping Tension!",name driver _helo]; _warned = 2 ? abs(speed _helo) > 140 && _warned == 2: Hint format ["W A R N I N G !!!\n\nExcessive Speed.\n\n%1\nYou have snapped\nThe cargo sling.\n\n\nCargo lost.",name driver _helo]; bas_incargo = 0;bas_w = 0;goto "blown" ? bas_incargo == 0 || bas_w == 0:goto "nip" ? bas_incargo == 1 : goto "lifted" #nip @bas_incargo == 0 _heavycargo1 setvelocity [(velocity _helo select 0), (velocity _helo select 1), (velocity driver _helo select 2)] deletevehicle _rope _helo removeaction _drop ~5 goto "check1" #nonlocal Hint "The Vehicle You Are\nAttempting To Lift\nIs NOT Local To Your\nHelicopter.\nTry Mounting An AI\nTeam Member In It.\n\nWinch Aborted." ~10 goto "check1" #blown _heavycargo1 setvelocity [(velocity _helo select 0), (velocity _helo select 1), (velocity driver _helo select 2)] deletevehicle _rope _helo removeaction _drop @ (getpos _heavycargo1 select 2)<1 _heavycargo1 setdammage 4 [_heavycargo1] exec "\BWMOD_NH90\scripts\bas_mpfire.sqs" goto "check1" I think part of the problem is located here, when I'm deleting this: (getpos _helo select 2) < 20 && (getpos _helo select 2)>3 && the "Attach HMMWV" dialog appears. When I'm attaching the car, it moves synchronous to the heli, but it only moves on the ground (is not flying!!!). My first thought was that the part I deleted is necessary for the car to fly, but when I have it in the script I can't attach the HMMWV anymore. vicious cirlce, lol , very frustrating for me I'm making a gear-srcipt which looks like that: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_nh=_this select 0 player groupchat "gear-script active" #check1 ~2 player groupchat "startcheck1" ? (getpos _nh select 2) > 10 && speed _nh > 10 : goto "Extract" goto "Check1" #Extract player groupchat "startextract" ?(not alive _nh): Exit _nh say "NH90gear" _nh animate ["maingear",1] _nh animate ["sidegear",1] ~1 #check2 player groupchat "startcheck2" ~2 ? (getpos _nh select 2) < 10 && speed _nh < 10 : goto "Retract" goto "Check2" #Retract player groupchat "startretract" ?(not alive _nh): Exit _nh say "NH90gear" _nh animate ["maingear",0] _nh animate ["sidegear",0] ~1 goto "Check1" and again it all worked fine as long as i kept this part : (getpos _nh select 2) < 10 && out of the script. is it possible that there's a special problem with my heli that it can't work with this (getpos _helo select 2) thing. can it be a failure in the config, the modell itself or other scripts does someone have an idea where I made a mistake? perhaps this helps, the global.sqs used to initiate the sling-script. the gear-script is started in the config. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_nh90 = _this select 0 ? (driver _nh90 == player) :[_nh90,player] exec "\BWMOD_NH90\scripts\Sling.sqs" ? (mpgame):exit [_nh90,1,2] exec "\BWMOD_NH90\scripts\rotorwash.sqs" [_nh90] exec "\BWMOD_NH90\scripts\fx.sqs" ? (getpos _nh90 select 2) < 5:_nh90 say "NH90Powerup" exit Share this post Link to post Share on other sites
Matthijs 40 Posted July 12, 2004 The poblem is probably caused by the order in which commands are processed. Look at this line: A < B && C > D All vars are integers. This results in an error. This is because the line is processed as: ((A < B) && C) > D Solution: use brackets to enfirce the processing order you want: ((getpos  _nh select 2) < 10) && ( (a*b)<c ) && ( (d+e)!=f ) && etc.etc. Share this post Link to post Share on other sites
Guest major gandhi Posted July 13, 2004 I changed it to: Quote[/b] ]? ((getPos _nh select 2) >10) && (speed _nh) > 10) : goto "Extract" and I also tried: Quote[/b] ]? ((getPos _nh select 2) >10) && (speed _nh > 10) : goto "Extract" But both versions didn't work. It seems that in game it still doesn't come further than 'check1'. Share this post Link to post Share on other sites
Matthijs 40 Posted July 14, 2004 Just like the boolean equation itself, the "if" statement only looks at the argument directly after the operator or command. To use multiple arguments, use a set of brackets around the complete set. if (arg1 ... arg2) then {...} or ? (arg1 ... arg2) : ... If that doesn't work, remember to note down any errors OFP generates, and put them in your post. Share this post Link to post Share on other sites
BraTTy 0 Posted July 14, 2004 You say that it appears its not getting past "check1" and like TJ was explaining...did you try changing this line <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ? (getpos _helo select 2) < 20 && (getpos _helo select 2)>3 && speed _helo < 10 && _heavycargo1 distance _helo < 15 : goto "liftoption" To this: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ? (getpos _helo select 2) < 20 && (getpos _helo select 2) > 3 && (speed _helo) < 10 && (_heavycargo1 distance _helo) < 15 : goto "liftoption" Share this post Link to post Share on other sites
Guest major gandhi Posted August 28, 2004 so I finally found the problem, TJ gave me the tip. a roadway lod causes the (getpos _helo select 2) to not work correctly. the solution is to delete it (what I did, since it doesn't really makes much sense in my heli) or to replace the (getpos _helo select 2) with (getpos driver _helo select 2) question1: but I have another problem, I want to add the ability to carry more than only one vehicle. solution (by raedor): <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_heavycargo1= nearestObject [ _helo, "BWMOD_Wiesel"] ? isNull _heavycargo1: _heavycargo1= nearestObject [ _helo, "BWMOD_Wolf"] ? isNull _heavycargo1: _heavycargo1= nearestObject [ _helo, "BWMOD_Ente"] ? isNull _heavycargo1: _heavycargo1= nearestObject [ _helo, "BWMOD_Gans"] ? isNull _heavycargo1: _heavycargo1= nearestObject [ _helo, "BWMOD_Laus"] question2: the stuff in fat letters says that the car should get placed at the helo position, btw can somebody tell me which exact loaction that is? is it the barycenter of the heli? atm this point is not hanging at the lower side of the chopper but in the middle of it, somewhere in the cargoarea. This is the one part of the script responsible for setting the postion of the rope and the vehicle: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? (getpos _hpelo select 2)>6.1:_heavycargo1 setpos [getpos _helo select 0, getos _helo select 1, (getpos _helo select 2) - 6] So is it posible to replace the stuff in fat letters with a selection (perhaps a simple point located at the ground of the heli) defined in the modell? I hope you understand what I mean inspite of my bad english, if not please ask! Share this post Link to post Share on other sites