Jump to content
Sign in to follow this  
daza

Waituntil problem...i dont have much hair left on my head now.

Recommended Posts

Ive tried searching for a solution. It may be what i want to do isnt suited for waituntil.

Wiki: has an example

_i = 0; waitUntil {_i = _i + 1; _i >= 100}

my little script

dog domove getpos Hum1;

player removeaction doghum;

if (!alive dog) exitwith

{

hint "Dog has been killed!";

};

_distance = dog distance hum1; waituntil {_distance <= 20};

Dog attachTo [hum1,[0,-1.2,-1.6]];

dogout=player addaction ["Dog out of Vehicle","hopout.sqf"];

player removeaction doghalt;

player removeaction hereboy;

player removeaction doggo;

Error report in arma.rpt

dogout=player addaction ["Dog out of Vehicle","hopout.sqf"];

playe>

Error position: <Dog out of Vehicle","hopout.sqf"];

playe>

Error Missing ;

Yet if i have no condition in the script it runs fine, although but it doesnt look very good that the dog teleports from where he is to the humvee.

I havent used check distances before or waituntil.

Do i need a better loop method that will check checking the distances?

Why wont my script work?

Thanks for any feedback

Daza

Share this post


Link to post
Share on other sites

Yes you need a better way of checking distance. Waituntil {_distance <= 20}; will do absolutely nothing in terms of checking the distance. You're only checking the distance at the moment of calculation, ie once. Then you're checking the same distance over and over again.

Something like this perhaps?

_distance = dog distance hum1;

while { _distance >= 20 } do { sleep 1; _distance = dog distance hum1; };

Share this post


Link to post
Share on other sites

waituntil {sleep 1; (dog distance hum1 <= 20)};

Share this post


Link to post
Share on other sites

Thanks for your suggestions guys but neither of them work unfortunately.

I'm still getting the same error message in arma.rpt file.

Perhaps i could use a trigger? what would i put in the condition?

Error in expression <-1.2,-1.6]];

dogout=player addaction ["Dog out of Vehicle","hopout.sqf"];

playe>

Error position: <Dog out of Vehicle","hopout.sqf"];

playe>

Error Missing ;

Share this post


Link to post
Share on other sites

weird, tried running your script with the waituntil sollution from shk and it makes 'dog' soldier run to 'hum1' hummer and gets attached at less then 20 distance. And it adds the action to my menu (ofc I had to // out the removeactions) with no error in the log.

Only changed:

<..
_distance = dog distance hum1; 
waituntil {sleep 1; (dog distance hum1 <= 20)}; 
..>

Share this post


Link to post
Share on other sites

Well _distance will remain the same forever which is why your waitUntil will either get released right away or get stuck forever. Also you don't need a sleep inside the waitUntil. Sure it'll check every frame but it's really nothing performance wise (you can have a large amount of such checks every frame without seeing a script performance hit, as long as it's not a crazy expensive check).

Still does not explain what is wrong with your addAction (which is where your error is at). Is this the entire script? The fact it expects a ; after the first " usually indicates that you opened a quote (with ") somewhere, and now that you closed it, it tries to interpret Dog out... as a command and fails.

Also I hope this is for single player, because the way you're handling it can cause issues in multiplayer even if you fix the problem.

Share this post


Link to post
Share on other sites

I'm messing around with BigDaddys dog attack script.

Yeah i hope to use it in MP eventually, im just trying to get things working before anything else. Im planning on having a unitname that can only have a dog. So the addaction will be given to that unitname rather than player (which perhaps what you were refering to galzohar when you said it would cause issues in MP?)

I'm still very much a newbie at scripting, but i keep at it.

Okay since i was actually working with a dog unit, i tried to do it with a soldier unit and

managed to get it working, change variables back to dog unit and now it doesnt work.

The dog more follows me than actually going to hum1 on its own accord. So i sort of lead it to hummer and it gets very close to it, enough to complete the condition but nothing happens.

As i said before the attachto and detach bits work with the dog, if there is no condition code.

**Update**

I feel like a dumbass

I had a line in the script that creates the dog (Big Daddys script) that i modified. Changing name of dog unit from _dog to Dog but for some reason i forgot one piece i tinkered with earlier that needed removing had put dog = _dog.

So in the getinhummer script of course dog = nothing....

Much appreciated for your help guys, i didn't think of testing it out with a human (because i thought it was a script error) but doing so lead me to see the dog that was the problem.

Well problem fixed so all good!

Cheers

Daza

Edited by Daza
problem solved

Share this post


Link to post
Share on other sites

Of course, for MP you'll have to use the name/variable of the unit rather than player, and make sure you're not having locality issues - not sure what the locality requirements are on addAction and doMove - if they're different (say, server for doMove on the dog and client for the addAction on the player) you're going to have some fun making it work.

If you're going to have multiple dogs you will also have to write the script differently - have it get the dog and soldier and save them as private variables. Again if doMove and addAction have different locality requirements you're up for a decently complicated task of having each command run properly on the correct machine.

Share this post


Link to post
Share on other sites

If your using my latest (call blitzy) from this thread..

Try this..

I added the addaction to the vehicle. Take a look.

Add action to vehicle:

nul = this addAction ["Load K-9 Into Vehicle", "scripts\loaddog.sqf",[],0,false,true,"","alive (_this getvariable 'K-9Unit')"];

loaddog.sqf:

_veh = _this select 0;
_leader = _this select 1;
_id = _this select 2;

_dog = _leader getvariable 'K-9Unit';

_dog domove position _veh;
waituntil {_dog distance _veh <= 5};

_dog attachto [_veh,[0,-1.2,-1.6]];
_veh removeaction _id;
_veh addaction ["UnLoad K-9", "scripts\unloaddog.sqf",[],0,false,true,"","alive (_this getvariable 'K-9Unit')"];

unloaddog.sqf:

_veh = _this select 0;
_leader = _this select 1;
_id = _this select 2;

_dog = _leader getvariable 'K-9Unit';

detach _dog;
_dog setpos (getpos _leader);
_veh removeaction _id;
_veh addAction ["Load K-9 Into Vehicle", "scripts\loaddog.sqf",[],0,false,true,"","alive (_this getvariable 'K-9Unit')"];

Share this post


Link to post
Share on other sites

Thats great BigDaddy!

I was having trouble with trying to get around the local variables and using global ones on my other side scripts for things like that.

As far as local variables go in your scripts, i notice there is a

if (isnil "RE") then {[] execVM "\ca\Modules\MP\data\scripts\MPframework.sqf"};

What does this do?

I also worked out how to make the dog halt with an addaction command, are you able to script this into your Blitzy mission as well?

This is what i had working (when working with global variables).

A invisable marker is needed to be placed on map.

if (!alive dog) exitwith

{

hint "Dog has been killed!";

};

doggo= player addaction ["Command to continue","releasedog.sqf"];

"markrhalt" setmarkerpos (position dog);

while {isNil "proceedk9"} do

{

dog domove (getmarkerpos "markrhalt");

sleep1;

};

proceedk9=false;

publicvariable ="proceed9";

sleep 1;

player removeaction doggo;

Releasedog.sqf

proceedk9=true;

publicvariable ="proceed9";

Also Commanding Dog to come to player/doghandler. This works too.

player removeaction doghum;

if (!alive dog) exitwith

{

hint "Dog has been killed!";

};

proceedk9=true;

publicvariable ="proceed9";

_distance = dog distance k9handler;

waituntil {sleep 1;dog domove getpos k9handler; (dog distance k9handler <= 5)};

dog dofollow k9handler;

It would be great if you could adapt those into your Blitzy mission. You did a great job on creating it, but some of it is over my head lol.

I will be sure to give this a playtest in multiplayer and let you know how that goes.

Cheers

Daza

Share this post


Link to post
Share on other sites

if (isnil "RE") then {[] execVM "\ca\Modules\MP\data\scripts\MPframework.sqf"} ; 

This initializes the MP framework provided by BIS if not already initialized. I use it to make the say command (dog barking/growling) MP friendly.

Also, if your using blitzy, then he's part of your group. You can command him just like you command the AI (which is exactly what he is) select all your squad with the space bar, or f2-f8 (which ever number blitzy is) and tell him move, stop, regroup, etc etc. Once you have him selected, hit number 1 (not f1) and more commands come up. (same as number 2, 3, 4, etc) There are commands to make the dog do back flips, if you look hard enough. (joking, don't ask me where to look) My favorite is to tell the dog to advance, that way, he runs ahead of you.

Even if the dog is currently tracking someone, enough regroup commands will bring the dog back to you.

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  

×