Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 22

Thread: Setting up Multiplaryer options using Class Params

  1. #11
    You shouldn't just copy paste stuff without knowing how it works. I'm not going to fix the whole thing since it will be better if you figure out how to do it yourself.

    Here's an example:
    Code:
    class View {
      title="View Distance";
      values[]={1000,2000,3000,4000,5000,6000,7000,8000,9000,100 00};
      texts[]={"1000m","2000m","3000m","4000m","5000m","6000m","7000m","8000m","9000m","10000m"};
      default = 3000;
    };
    You have tons of useless IF lines like viewparam == 1 etc, which actually do nothing. None of them will ever be true as the values given in desc.ext are from 1000 to 10000.

    So, we can replace those 11 lines with just:

    Code:
    setViewDistance (paramsArray select 0);
    It sets viewdistance to the value selected in parameters, no IF stuff required.

  2. #12
    First Sergeant cobra4v320's Avatar
    Join Date
    Mar 10 2009
    Location
    Seattle Washington
    Posts
    841
    Author of the Thread
    Can anyone tell me why this does not work?

    init.sqf
    Code:
    enableEnvironment (paramsarray select 0);
    description.ext
    Code:
    class Params 
    {
      	class Environment 
    	{
        		title = "Enable Environment";
        		values[] = {0, 1};
        		texts[] = {"False","True"};
        		default = 0;
      	};
    };

  3. #13
    Because the command takes a boolean (true/false) and you are giving it a number (0/1).

  4. #14
    First Sergeant cobra4v320's Avatar
    Join Date
    Mar 10 2009
    Location
    Seattle Washington
    Posts
    841
    Author of the Thread
    So I have also tried below but that does not work either.

    Code:
    class Params 
    {
      	class Environment 
    	{
        		title = "Enable Environment";
        		values[] = {false, true};
        		texts[] = {"False","True"};
        		default = false;
      	};
    };

  5. #15
    That's because BIS don't want to fix/change the feature where you can use 1/0 as true/false for the desc.ext options.

    So, just do:
    Code:
    class Params 
    {
      	class Environment 
    	{
        		title = "Enable Environment";
        		values[] = {0, 1};
        		texts[] = {"False","True"};
        		default = 0;
      	};
    };
    Code:
    if ((paramsarray select 0) == 1) then {
      enableEnvironment true;
    };

  6. #16
    Check out top of i_common.sqf in Domination how params array is dealt with. Not sure if relevant to question, but worth a look anyways.
    Regards
    Carl Gustaffa - left this game due becoming Steam Exclusive

  7. #17
    First Sergeant cobra4v320's Avatar
    Join Date
    Mar 10 2009
    Location
    Seattle Washington
    Posts
    841
    Author of the Thread
    Thanks Shk and carlGustaffa for the assistance and I have looked at the f2 framework and the domination folders.

  8. #18
    First Sergeant cobra4v320's Avatar
    Join Date
    Mar 10 2009
    Location
    Seattle Washington
    Posts
    841
    Author of the Thread
    This is what works with enableEnvironment

    Code:
    if ((paramsarray select 0) == 1) then {enableEnvironment true} else {enableEnvironment False}


    ---------- Post added at 09:51 AM ---------- Previous post was at 09:47 AM ----------

    Here is a working multiplayer parameters

    description.ext
    Code:
    class Params 
    {
      	class TimeOfDay 
    	{
        		title = "Time of Day";
                    values[] = {1337,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
    		texts[] = {"Random","00.00","01.00","02.00","03.00","04.00","05.00","06.00","07.00","08.00","09.00","10.00","11.00","12.00","13.00","14.00","15.00","16.00","17.00","1800","19.00","20.00","21.00","22.00","23.00"};
                    default = 12;
      	};
    
      	class Weather 
    	{
        		title = "Weather Conditions";
        		values[] = {0,1,2,3};
        		texts[] = {"Clear","Stormy","Cloudy","Foggy"};
        		default = 0;
      	};
    
      	class Terrain 
    	{
        		title = "Enable Grass";
        		values[] = {50,25,12.5,6.25,3.125};
        		texts[]={"No Grass", "Default MP", "Default SP", "More", "Max"};
        		default = 25;
      	};
    
      	class Environment 
    	{
        		title = "Enable Environment";
        		values[] = {0, 1};
        		texts[] = {"False","True"};
        		default = 0;
      	};
    
    	class ViewDistance
    	{	
    		title = "View Distance:";
    		values[] = { 1200, 1500, 2000, 2500, 3000, 3500, 4000, 4500, 5000};
    		texts[] = { "1.2 km", "1.5 km", "2 km", "2.5 km", "3 km", "3.5km", "4 km", "4.5 km", "5 km"};
    		default = 2000;
    	};
    };
    init.sqf
    Code:
    skiptime (((paramsarray select 0) - daytime + 24) % 24);
    
    switch (paramsarray select 1) do {
      case 1: { 0 setOvercast 0; 0 setRain 0; 0 setFog 0 };
      case 2: { 0 setOvercast 1; 0 setRain 1; 0 setFog 0.2 };
      case 3: { 0 setOvercast 0.7; 0 setRain 0; 0 setFog 0 };
      case 4: { 0 setOvercast 0.7; 0 setRain 1; 0 setFog 0.7 };
    };
    
    setTerrainGrid (paramsarray select 2);
    
    if ((paramsarray select 3) == 1) then {enableEnvironment true} else {enableEnvironment false};
    
    setViewDistance (paramsarray select 4);

  9. #19
    Thanks a lot for the info, guys.

    How does one establish a parameter setting the time the mission will run for?

  10. #20
    Another technique I saw while poking through AAS (I think) is dynamically assigning the parameters to the values itself:

    Code:
    if (isNil "paramsArray") then {
    	if (isClass (missionConfigFile/"Params")) then {
    		for "_i" from 0 to (count (missionConfigFile/"Params") - 1) do {
    			_paramName = configName ((missionConfigFile >> "Params") select _i);
                _paramValue = getNumber (missionConfigFile >> "Params" >> _paramName >> "default");
                call compile format ["%1 = %2", _paramName, _paramValue];
    		};
    	};
    } else {
    	for "_i" from 0 to (count paramsArray - 1) do {
            _paramName = configName ((missionConfigFile >> "Params") select _i);
            _paramValue = paramsArray select _i;
            call compile format ["%1 = %2", _paramName, _paramValue];
    	};
    };
    Lets say you have:

    Code:
    class P_TimeOfDay 
    	{
        		title = "Time of Day";
                    values[] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23};
    		texts[] = {,"00.00","01.00","02.00","03.00","04.00","05.00","06.00","07.00","08.00","09.00","10.00","11.00","12.00","13.00","14.00","15.00","16.00","17.00","1800","19.00","20.00","21.00","22.00","23.00"};
                    default = 12;
      	};
    Then in your script you can just do for example:
    skipTime P_TimeOfDay;

    If you run using the editor the parameters default to the default values. I like this method better than the index selecting, and think it is more readable.

Page 2 of 3 FirstFirst 123 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •