Forum Jump :

Author Message


Posts: 71
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age: 18
In-game name: Curious

 
#1 Posted at 2016-10-01 15:16        
     
Hello, I only had a small amount of knowledge with IF statements before, and I ahvn't used them in a while, and well, Can't figure out if I ahve the condition correct:

_Game = "Gameplay" call BIS_fnc_getParamValue;
if (_Game paramsArray select 0) then 
	{
		0 = execVM "Scripts\Tasks\Flying\RandomStartFly.sqf"
	}
else{};

if (_Game paramsArray select 1) then 
	{
		0 = execVM "Scripts\Tasks\Infantry\RandomStartInf.sqf"
	}
else{};

if (_Game paramsArray select 2) then 
	{
		0 = execVM "Scripts\Tasks\Combined Arms\RandomStartSup.sqf"
	}
else{};

I';ve got a funny feeling That Params Array is outside the condition, but like I said, I ahvn't done them in a while. Quick response would be nice as well as an explaination to if statements because I sometimes need a second person to explain (BIs wiki didn't help me fully understand).

Placeholder.

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#2 Posted at 2016-10-01 17:02        
     
Here is the script "cleaned up":

_game = "Gameplay" call BIS_fnc_getParamValue;
if (_game paramsArray select 0) then {
    execVM "Scripts\Tasks\Flying\RandomStartFly.sqf";
};

if (_game paramsArray select 1) then {
    execVM "Scripts\Tasks\Infantry\RandomStartInf.sqf";
};
 
if (_game paramsArray select 2) then {
    execVM "Scripts\Tasks\Combined Arms\RandomStartSup.sqf";
};

The statement `_game paramsArray select 0` doesn't mean anything. Use the "Show Script Errors" parameter when launching the game to see where errors are in your code.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Advertisement


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 58
In-game name: Kobayashi Maru

 
#3 Posted at 2016-10-01 22:12        
     
You need to have a params class in your description.ext but I'm sure you manage that.
Then a sub-class "Gameplay" coming with 3 possible parameters.

class gamePlay
{
title = "Game play";
values[] = {0,1,2}; // or same as texts[] if you want to compare strings
texts[] = {"Flying","Infantry","combined Arms"};
default = 0;
isGlobal = 0; // (Optional) 1 to execute script / function locally for every player who joins, 0 to do it only on server
};

As these params are exclusive from each other (you must choose one), your best bet is to place the choice by default first.
Furthermore, as you're listing a "if then" conditions for an exclusive parameter, it's a good usage to call this check like this:

_game = "Gameplay" call BIS_fnc_getParamValue;
call {
  if (_game paramsArray select 0 == 0) exitWith {
    execVM "Scripts\Tasks\Flying\RandomStartFly.sqf";
  };
  if (_game paramsArray select 0 == 1) exitWith {
    execVM "Scripts\Tasks\Infantry\RandomStartInf.sqf";
  };
  if (_game paramsArray select 0 == 2) exitWith {
    execVM "Scripts\Tasks\Combined Arms\RandomStartSup.sqf";
  };
};
It's faster. No need to check every remaining possibilities if condition is met.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 71
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age: 18
In-game name: Curious

 
#4 Posted at 2016-10-02 09:21        
     
Ohh I really added un-needed lines xD Thank you guys, as always :D

Okay, i'll give you all the information about the mission. I am i the middle of making missions that, depending on which parameter has been set, will focus on certain detachments(Air,Inf and Supp). Here is the description.ext
class Params 
	{
	
	#include "\a3\functions_f\Params\paramDaytimePeriod.hpp"
	#define DAYTIMEPERIOD_DEFAULT 12
 	

	#define TICKETS_MIN	100
	#define TICKETS_MAX	500
	#define TICKETS_DEFAULT -1
	#include "\a3\functions_f\Params\paramRespawnTickets.hpp"	
	
	
		class Gameplay {
				title = "Gameplay (MUST SET)";
				values[] = {0,1,2};
				texts[] = {"Flying","Infantry","Combined Arms"};
				default = 1;
				};

		class AIDiff {
				title = "AI Difficulty (MUST SET)";
				values[] = {0,1,2,3};
				texts[] = {"Easy","Medium","Hard","INSANE"};
				default = 0;
				};
	};

Exclude the AI difficulty part [Might be removing it]

I then wanted the Init file to check what parameters were set, place an object with an addAction which would then start the missions(Give players time to gear up). This is where I asked you lot above ^^ but I keep getting an error on the:

|#|call {
	if (_game paramsArray select 0 == 0) exitWith {
		execVM "Scripts\Tasks\Flying\RandomStartFly.sqf";
	};
	if (_game paramsArray select 0 == 1) exitWith {
		execVM "Scripts\Tasks\Infantry\RandomStartInf.sqf";
	};
	if (_game paramsArray select 0 == 2) exitWith {
		execVM "Scripts\Tasks\Combined Arms\RandomStartSup.sqf";
	};
};

I tried using spawn because I forgot you can't call (might be wrong) in an Init file, like this:

[] spawn {
	if (_game paramsArray select 0 == 0) exitWith {
		execVM "Scripts\Tasks\Flying\RandomStartFly.sqf";

But I now keep getting an error with "paramsArray"

if (_game |#|paramsArray select 0 == 0) exitWith {

It gives me: Missing )

I've probably done something wrong, but atleast I tried? :P I also got an error: Generic Error in expression, but I can't remember where that was. (writing it after all this.)

This post was edited by [Sgt.] Curious (2016-10-02 09:48, 683 days ago)

Placeholder.

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#5 Posted at 2016-10-02 10:58        
     
The _game variable is undefined inside that call/ spawn so you get an error.


Here is what you can do instead:
_game = "Gameplay" call BIS_fnc_getParamValue;
execVM (
    "Scripts\Tasks\" +
    (["Flying\RandomStartFly", "Infantry\RandomStartInf", "Combined Arms\RandomStartSup"] select _game) +
    ".sqf"
);

This post was edited by 654wak654 (2016-10-02 11:22, 683 days ago)

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 71
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age: 18
In-game name: Curious

 
#6 Posted at 2016-10-02 11:09        
     
# 654wak654 :
execVM (
    "Scripts\Tasks\" +
    ["Flying\RandomStartFly", "Infantry\RandomStartInf", "Combined Arms\RandomStartSup"] select _game +
    ".sqf"
);

So i'm getting:
"Generic Error in expression:

"Scripts\Tasks\" |#|+

Also, I didn't know you could that with execVM ;)

Placeholder.

Author Message


Posts: 1189
Rank:


Level: Member

Country: tr
Location:
Occupation: Computer Science student
Age: 20
In-game name: Wak

 
#7 Posted at 2016-10-02 11:21        
     
Well, execVM requires a string, and it doesn't care how the string got there. The error was because of some missing parenthesis, I added them to my original post.

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage

Author Message


Posts: 71
Rank:


Level: Member

Country: uk
Location:
Occupation:
Age: 18
In-game name: Curious

 
#8 Posted at 2016-10-02 18:00        
     
Awesome, all working now :D

Placeholder.

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 58
In-game name: Kobayashi Maru

 
#9 Posted at 2016-10-02 19:00        
     
The good question was: Why didn't you try what I wrote?
_game was defined before the call {} scope. It seems you missed the line..;
call is OK in init.sqf of course;
execVM is already a spawned code.
this was too simple?

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS