Jump to content
Sign in to follow this  
FelixK44

Check animation in trigger?

Recommended Posts

Hi, can someone help me? I'm not sure if this is correct it doesn't work so I must of messed up somewhere. I have a trigger placed near the "Jail" and it the init is [] exec "JailZone.sqf" the JailZone script displays the hint but the ArrestCheck script fails somewhere and doesn't show the hint. :confused:

EDIT: If it's possible I would rather have the trigger created through script to instead check if the unit is "captive" and then run a script for all units in the trigger.

"JailZone"

sleep 15;
JailZone1=createTrigger ["EmptyDetector",getPos _object];
JailZone1 setPos (getMarkerPos "JailZone") 
JailZone1 setTriggerArea [50,50,0,false];
JailZone1 setTriggerActivation ["CIV","PRESENT",true];
JailZone1 setTriggerStatements ["this", "{[_x] exec ""ArrestCheck.sqf""} forEach thisList", "'"];

sleep 1;

Hint "Jail Zone Refreshed";

"ArrestCheck"

sleep 15;
_x = _this select 0;
if (animationState _x == "CivilLying01") then { [_x] exec ""Reward.sqf"" };
Hint "Checking Animations";

Edited by FelixK44

Share this post


Link to post
Share on other sites

Please keep in mind that exec is for sqs-files whereas execVM is used to execute sqf-files.

But somehow I'm confused, what do you want again? :D

You already posted a solution to your question, so is this script somehow throwing errors? If it does, what does it say?

Share this post


Link to post
Share on other sites
Please keep in mind that exec is for sqs-files whereas execVM is used to execute sqf-files.

But somehow I'm confused, what do you want again? :D

You already posted a solution to your question, so is this script somehow throwing errors? If it does, what does it say?

New script code, the script stops on "Checking Animations 2"


Hint "Checking Animations 1";
_x = _this select 0;
Hint "Checking Animations 2";
[b]if (animationState _x == "CivilLying01") then { [_x] execVM ""Reward.sqf"" };[/b] <--------- Script not processing this line of code
Hint "Checking Animations 3";

Edited by FelixK44

Share this post


Link to post
Share on other sites

I'd say you have to get rid of the double quotes around Reward.sqf as they are only used in strings to escape the quotes :D

Normally you'd get a corresponding error message either in your .rpt-file or ingame using the -showScriptErrors parameter.

It really helps you figure out what's wrong in your code so you should consider starting your game with the parameter while in development.

Share this post


Link to post
Share on other sites
I'd say you have to get rid of the double quotes around Reward.sqf as they are only used in strings to escape the quotes :D

Normally you'd get a corresponding error message either in your .rpt-file or ingame using the -showScriptErrors parameter.

It really helps you figure out what's wrong in your code so you should consider starting your game with the parameter while in development.

Oh cool thanks for the suggestion about -ShowScriptErrors! In the else { } part of arrestcheck script how do I display a hint? else {Hint "Test"} doesn't work.


sleep 1;
Hint "Checking Animations 1";
_x = _this select 0;
Hint "Checking Animations 2";
{if((_x distance JailZoneArea < 10) && (animationstate _x == "civillying01")) then	{[_x] execVM "ArrestReward.sqf"}  [b]else {}[/b];} foreach thislist;
Hint "Checking Animations 3";



Share this post


Link to post
Share on other sites

Now I'm confused once more xD

Is this the activation field or the content of your ArrestCheck.sqf?

Because if it is the latter, you can't use thisList as it just exists in the scope of the trigger, hence the forEach isn't even executed and the else is never reached ;)

Share this post


Link to post
Share on other sites

I'm trying to create a trigger that's condition to activate is if the civilians in the area are in the animationstate "civilying01" and if they are for it to run a script. :confused:

Share this post


Link to post
Share on other sites

Well yeah I understood that part, but the code you posted in Post #5 is irritating me, like is this the code you actually wrote in your activation field of the trigger or is it the content of your ArrestCheck.sqf?

Using that code in a seperate sqf-file won't work because thisList doesn't exist in that scope.

Try to put the foreach-loop into the activation field of your trigger, it should work the way you want it.

Share this post


Link to post
Share on other sites
Well yeah I understood that part, but the code you posted in Post #5 is irritating me, like is this the code you actually wrote in your activation field of the trigger or is it the content of your ArrestCheck.sqf?

Using that code in a seperate sqf-file won't work because thisList doesn't exist in that scope.

Try to put the foreach-loop into the activation field of your trigger, it should work the way you want it.

Well, the trigger doesn't actually exist when the mission starts. I placed an object in the editor and place this addaction ["Turn in Criminals", "JailZone.sqf"]; in the objects init. When a player uses the action the script gets executed inside JailZone is the arrestcheck script. Both scripts are working the problem is with arrestcheck now.

JailZone.sqf


sleep 1;
JailZone1=createTrigger ["EmptyDetector",getmarkerPos "JailZone"];
JailZone1 setPos (getMarkerPos "JailZone");
JailZone1 setTriggerArea [50,50,0,false];
JailZone1 setTriggerActivation ["CIV","PRESENT",true];
JailZone1 setTriggerStatements ["this", "{[_x] execVM ""ArrestCheck.sqf""} forEach thisList", ""];

sleep 1;

Hint "Jail Zone Refreshed";

ArrestCheck.sqf


sleep 1;

_x = _this select 0;

[b]{if((_x distance JailZoneArea < 10) && (animationstate _x == "civillying01")) then	{[_x] execVM "ArrestReward.sqf"}  else {};} foreach thislist;[/b] <---- Isn't detecting animation for some reason?

Edited by FelixK44

Share this post


Link to post
Share on other sites

Try to change your trigger statements with this one:

JailZone1 setTriggerStatements ["this", "{if((_x distance JailZoneArea < 10) && (animationstate _x == ""civillying01"")) then {[_x] execVM ""ArrestReward.sqf"";} else {};} foreach thisList;", ""];

And forget your ArrestCheck.sqf :D

Share this post


Link to post
Share on other sites
Try to change your trigger statements with this one:

JailZone1 setTriggerStatements ["this", "{if((_x distance JailZoneArea < 10) && (animationstate _x == ""civillying01"")) then {[_x] execVM ""ArrestReward.sqf"";} else {};} foreach thisList;", ""];

And forget your ArrestCheck.sqf :D

Dude thanks! I have another problem though! I need to create another trigger so that players can't keep collecting rewards for arrested civilians. I tried doing it on my own but it doesn't work. :(


sleep 5;
JailZone2=createTrigger ["EmptyDetector",getmarkerPos "JailZone"];
JailZone2 setPos (getMarkerPos "JailZone");
JailZone2 setTriggerArea [50,50,0,false];
JailZone2 setTriggerActivation ["CIV","PRESENT",true];
JailZone2 setTriggerStatements ["this", "{if((_x distance JailZoneArea < 10) && (animationstate _x == ""civillying01"")) [b]then {deleteVehicle [_x]} else {};} foreach thisList;", ""];[/b]  <======

Share this post


Link to post
Share on other sites

Well I'd consider changing the condition of your trigger to a global variable which you can modify to stop the trigger.

// Somewhere BEFORE you set up the triggers
arrestRewardActive = true;

// Set up trigger
JailZone1 setTriggerStatements ["arrestRewardActive", "{if((_x distance JailZoneArea < 10) && (animationstate _x == ""civillying01"")) then {[_x] execVM ""ArrestReward.sqf"";} else {};} foreach thisList;", ""];  


// Somewhere else
arrestRewardActive = false;

Setting arrestRewardActive to true will activate the trigger again.

Share this post


Link to post
Share on other sites

Well, I would rather delete the units that are in the animation state because the arrested units will start piling up. :)

Share this post


Link to post
Share on other sites

Ah sry, didnt understand that entirely, now I do xD

DeleteVehicle expects an object, not an array, so just delete the brackets around _x and it should work fine :)

Share this post


Link to post
Share on other sites

Excellent! Thank you so much for helping me! Now my police mission is complete and time for MP testing. :cool:

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  

×