Jump to content
cookies2432

Basic Scripting help

Recommended Posts

So.. I've been grinding my head about this for a couple of hours so i'll just see if i can get some help on here. :)

I'm trying to make it so that a trigger will only go off if i have it detached inside of a trigger's radius.

If possible also make it so that if you move the object away from the trigger's radius the timer will stop?

And a last question would be how you could do a condition for an addAction that only allows you to do the addAction if you're let's say 4m from the object.

 

Thanks for reading and i hope i can get help by someone! :D

 

Also my friend got a question as to how you can increase the "Direct Channel" sound ingame more, even after putting it at max. Thanks!

 

//Cookies

Share this post


Link to post
Share on other sites

"bump" kind of. 

Also i got another question, Can i somehow change the "Spawn AI" modules so that they can spawn custom units, by that i mean non vanilla units such as a "Squad leader" from the "RHS" mod. I'm trying to make waves but the spawn AI modules can only spawn normal blufor units and vehicles. 

 

Thanks!

Share this post


Link to post
Share on other sites

 

I'm trying to make it so that a trigger will only go off if i have it detached inside of a trigger's radius.

 

Sorry but I don't understand a word of this phrase.. Maybe because I am not native english, don't know, but I need to read it in other easy words to help you.

Share this post


Link to post
Share on other sites

Sorry but I don't understand a word of this phrase.. Maybe because I am not native english, don't know, but I need to read it in other easy words to help you.

Basicly, I'm picking up a suitcase for example and I drop it inside of the area of a trigger. This starts a script, a timer. I want it so that the script stops if you move the suitcase outside of the triggers area. 

Share this post


Link to post
Share on other sites

put [] execVM "scriptname.sqf" in ON ACT of the trigger, this will excute a script. is this what you are telling us :D? do you even have the script? 

Share this post


Link to post
Share on other sites

i know that and i have done that, thing is that they can just run there with the object and then run off and the trigger will still go off, i don't want that to happend. i want it so that they have to drop the trigger and that it has to stay there for the whole countdown of the timer.

Share this post


Link to post
Share on other sites

This is my script for it:

 

publicVariable "_time";
_time = 20;
_C4 = C4;
_vault = vault;
while {_time > 0} do {
_time = _time - 1;
hintSilent format["Time Left: \n %1", [((_time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring];
sleep 1;
};
if (_time < 1) then {
bomb="M_Mo_82mm_AT_LG" createVehicle (getPos C4); deletevehicle C4;
deleteVehicle _vault;
};

Share this post


Link to post
Share on other sites

Got it.

 

Ok, modify your script:

 

thingInTrigger = true;

publicVariable "_time";
_time = 20;
_C4 = C4;
_vault = vault;
while {(_time > 0) and (thingInTrigger)} do {
_time = _time - 1;
hintSilent format["Time Left: \n %1", [((_time)/60)+.01,"HH:MM"] call BIS_fnc_timetostring];
sleep 1;
};
if (_time < 1) then {
bomb="M_Mo_82mm_AT_LG" createVehicle (getPos C4); deletevehicle C4;
deleteVehicle _vault;
};

 

 

 

And now, modify the trigger: execution repeatedly and, ON DEACT: thingInTrigger = false;

Share this post


Link to post
Share on other sites


thingInTrigger = true;

publicVariable "_time"; //Makes no sense, can't publish a local variable, check last note on this site https://community.bistudio.com/wiki/publicVariable

_time = 20;

_C4 = C4; //Makes no sense, local variable is not used

_vault = vault; //Makes no sense, local variable is not used

Share this post


Link to post
Share on other sites

Oh. well i did not think that one through.

 

How would i go on about doing it correct? I'm not very good at scripting.

Also i'm having real difficulties with the "distance" command.

Share this post


Link to post
Share on other sites

The question is, why would you want to publish that variable in the first place?

 

Also i'm having real difficulties with the "distance" command.

 

 

What exactly? It measures the distance in 3D between two units or two positions.

Share this post


Link to post
Share on other sites

the _C4 and was supposed to refer to a game object called C4.

With the distance i just can't get it to work, i use for example if ((C4 distance vault) <= 5) then {

         bla bla bla code here

}

 

But it never works. 

C4 and vault are game objects.

Share this post


Link to post
Share on other sites

the _C4 and was supposed to refer to a game object called C4.

With the distance i just can't get it to work, i use for example if ((C4 distance vault) <= 5) then {

bla bla bla code here

}

But it never works.

C4 and vault are game objects.

How and where is that conditions check getting executed? For instance, have you tried testing that condition in a trigger to help troubleshoot your issues?

Share this post


Link to post
Share on other sites

I have tried it in the triggers' condition but it doesn't work however when i did so i used this: C4 distance vault <= 4;  Which i belive is incorrect, or am i totally wrong here?

Share this post


Link to post
Share on other sites

I have tried it in the triggers' condition but it doesn't work however when i did so i used this: C4 distance vault <= 4;  Which i belive is incorrect, or am i totally wrong here?

 

As long as you have two objects in mission, one named "C4" and one named "vault", it should be correct. It's hard to say why you are having issues, as the distance command should be pretty straight forward, unless some of your objects are not named properly. Do you have an example mission we could look at?

Share this post


Link to post
Share on other sites

Basicly, I'm picking up a suitcase for example and I drop it inside of the area of a trigger. This starts a script, a timer. I want it so that the script stops if you move the suitcase outside of the triggers area. 

 

The easiest solution that comes to mind is to simply set the "timeout" of the trigger that is checking for the briefcase. This way you do not need a timer script at all. See these links:

https://community.bistudio.com/wiki/2D_Editor:_Triggers#Countdown.2FTimeout_Counters

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

 

 

Timeout - The trigger's conditions must be satisfied for the entirety of specified amount of time for the trigger to activate. For example, if a soldier walks into a <side> Present type trigger but leaves the area before the timeout is complete, the trigger will not activate.

Share this post


Link to post
Share on other sites

I know of that but that'll delay the trigger from executing as well, which will just delay it all.

Share this post


Link to post
Share on other sites

I know of that but that'll delay the trigger from executing as well, which will just delay it all.

 

So...you're saying you want two triggers then? One that kicks off instantly when a player brings the briefcase in and then another trigger that has a timeout set in case the briefcase gets removed in time? ;) Keep it simple man.

 

EDIT: if you want there to be a "toggle" with the two triggers then you're already on the right path. Simply create a toggle variable. One trigger sets it to true and the other sets it to false as part of their onActivation and they're both checking for the appropriate condition. Both triggers will need to be repeatable in that case.

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

×