Jump to content
Sign in to follow this  
avibird 1

Is there a command line to stop a script from running for a selective unit inti box!

Recommended Posts

Is there a way to stop a script from running for selective units using the unit inti box. I know how to use the if (playerSide == west && rank player == "CAPTAIN") then {...} to prevent low rank units to use a script within the mission but I need a way to stop the script for units of the same rank. I was hoping for a command line that you could just put in the unit from the editor.

Share this post


Link to post
Share on other sites
Is there a way to stop a script from running for selective units using the unit inti box. I know how to use the if (playerSide == west && rank player == "CAPTAIN") then {...} to prevent low rank units to use a script within the mission but I need a way to stop the script for units of the same rank. I was hoping for a command line that you could just put in the unit from the editor.

Take a look at setVariable and getVariable

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

In the init box I'd put

this setVariable ["canusemyscript", true, true];

And in the script I'd put

if(!(_activator getVariable ["canusemyscript", false])) then
{
//do stuff
}
else
{
//tell them they can't
};

Share this post


Link to post
Share on other sites

So you want something useable just once or something? Like any CAPTAIN can call in a drop but only one drop? Not sure exactly what you're trying to do.

Share this post


Link to post
Share on other sites
So you want something useable just once or something? Like any CAPTAIN can call in a drop but only one drop? Not sure exactly what you're trying to do.

Ok this is the deal, I have a few support scripts that I am using in my mission and yes only the SL (CAPTAIN) can call the scripts using the (playerSide == west && rank player == "CAPTAIN") then {...} The Scripts all can be used again after some time. Some are set to repeat after 15 minutes and others after 45 minutes. I want the BAF CAPTAINS to use A,B and C scripts and the US CAPTAINS to us D,E and F and UN CAPTAINS to use G and H.

I am using the (playerSide == west && rank player == "CAPTAIN") then {...} to allow only the CAPTAINS to call the scripts from the other units but would like to break it down more. RIGHT know All west Captains can call all the scripts in the mission and that is to much fire power for one player to have lol. Hope you can help. with a easy unit inti box stop lol

Share this post


Link to post
Share on other sites

You could use your original check, then use a switch statement with the faction...

However, your original check will not work for UN, as UN are on side GUE

Edited by panther42

Share this post


Link to post
Share on other sites
You could use your original check, then use a switch statement with the faction...

However, your original check will not work for UN, as UN are on side GUE

Hey I don't really understand the switch statement. I delete the UN units from the mission. could you make a sample mision so I can look at it. Scripting is not my thing but I am trying to get a grip on it lol

Share this post


Link to post
Share on other sites

_side = side player;

switch _side do
{
  case WEST:
  {
    //code and such
  };
  case EAST:
  {
    //other code and such
  };
};

You can do similar for the faction.

Share this post


Link to post
Share on other sites

i just learned this stuff recently myself and believe me it's the easy part. just look at Horner's example and try to analyse what it does.

"switch" basicly takes a variable and does something accordingly to its value.

so first of all he defines the variable he wants to switch.

_side = side player;

first he gives it a name: _side

the "_" is to make the variable local.

the "=" basicly says _side has the value of...

then he uses the command "side" http://community.bistudio.com/wiki/side

to get the players side. if you look at the wiki page of "side" especially look at "parameters" and "return value". "parameters" is what you give the command and "return value" is what it gives you back. (applies to most commands like this).

so simply writing "_side = side player;" will assign the actual side of the player to the variable _side.

and now he uses switch to make the script act different for every possible value of _side.

just look at the example. it makes alot of sense if you know what it actually does. control structures are using actual english words to describe what happens and are basicly like little tools which make things alot easier. you can do alot of stuff with them without being a real coder because they do alot of the work for you. all you have to do is fill in the stuff you want them to work with.

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  

×