Jump to content
hydrobull3t

Can't make the loadout to start

Recommended Posts

Hey Guys,

First of all, Thank you for wasting time to read this issue, Im really appreciate your effort for trying to help me and to others.

 

I am trying to create a template with a costume loadout, and I have encountered in issue.

The loadout won't start, I have tried to fix it by myself, but I can't find the issue somewhy.

 

I will Add to here the links for the Class define, Loadout Script, And RPT Log.

(I know I can make it simple through EDEN. But I want to add some functions like Parameters to the Loadout.)

 

RPT LogClass

Define / Clients
Loadout Script

Thank You! 

Edited by hydrobull3t
Edited the link for RPT

Share this post


Link to post
Share on other sites

It seems like your script will not work if any of the classes you've defined are not existant in the mission (due to the way the switch is set up).

 

Checking the vehiclevarnames instead of the actual objects should help to avoid that.

/*scripts\client.sqf*/

if !(isDedicated) then {
diag_log format ["client :1"];
  waitUntil { !IsNull Player };
      if (local player) then {
        
        waitUntil { time > 1 };
        
        // Factions
    diag_log format ["client :%1 %2", faction player, time];
        switch (faction player) do {
               case "BLU_F":
               {
               [] call compile preprocessFile "f\gear_setup\loadouts_bluefor.sqf";}; // Bluefor Set
              };

            switch (vehicleVarName player) do {

            case "MHQ_Commander": {[player] call FNC_SL;};
            case "MHQ_Medic": {[player] call FNC_MED;};
            case "MHQ_UAVO": {[player] call FNC_UAVO;};
            case "MHQ_Engineer": {[player] call FNC_EOD;};

            case "Alpha_SL": {[player] call FNC_SL;};
            case "Alpha_TL": {[player] call FNC_TL;};
            case "Alpha_Marksman": {[player] call FNC_MARK;};
            case "Alpha_EOD": {[player] call FNC_EOD;};
            case "Alpha_Medic": {[player] call FNC_MED;};
            case "Alpha_AT": {[player] call FNC_AT;};
            case "Alpha_AR": {[player] call FNC_AR;};
            case "Alpha_Operator": {[player] call FNC_OP;};

            case "Bravo_SL": {[player] call FNC_SL;};
            case "Bravo_TL": {[player] call FNC_TL;};
            case "Bravo_Marksman": {[player] call FNC_MARK;};
            case "Bravo_EOD": {[player] call FNC_EOD;};
            case "Bravo_Medic": {[player] call FNC_MED;};
            case "Bravo_AT": {[player] call FNC_AT;};
            case "Bravo_AR": {[player] call FNC_AR;};
            case "Bravo_Operator": {[player] call FNC_OP;};

            case "Charlie_Sniper": {[player] call FNC_SNIP;};
            case "Charlie_Spotter": {[player] call FNC_SPOT;};
            case "Charlie_Operator": {[player] call FNC_OP;};
            case "Charlie_Sniper1": {[player] call FNC_SNIP;};
            case "Charlie_Spotter1": {[player] call FNC_SPOT;};
            case "Charlie_Operator1": {[player] call FNC_OP;};

            case "AF_Pilot": {[player] call FNC_AFP;};
            case "AF_Pilot1": {[player] call FNC_AFP;};
            case "AF_Pilot2": {[player] call FNC_AFP;};
            case "AF_TL": {[player] call FNC_AFTL;};
            case "AF_JTAC": {[player] call FNC_AFJ;};
            case "AF_Medic": {[player] call FNC_AFMED;};

            };
       };

};

 

Or just use a different setup with an array instead of a switch.

 

 

Share this post


Link to post
Share on other sites
8 minutes ago, Tajin said:

It seems like your script will not work if any of the classes you've defined are not existant in the mission (due to the way the switch is set up).

 

Checking the vehiclevarnames instead of the actual objects should help to avoid that.


/*scripts\client.sqf*/

if !(isDedicated) then {
diag_log format ["client :1"];
  waitUntil { !IsNull Player };
      if (local player) then {
        
        waitUntil { time > 1 };
        
        // Factions
    diag_log format ["client :%1 %2", faction player, time];
        switch (faction player) do {
               case "BLU_F":
               {
               [] call compile preprocessFile "f\gear_setup\loadouts_bluefor.sqf";}; // Bluefor Set
              };

            switch (vehicleVarName player) do {

            case "MHQ_Commander": {[player] call FNC_SL;};
            case "MHQ_Medic": {[player] call FNC_MED;};
            case "MHQ_UAVO": {[player] call FNC_UAVO;};
            case "MHQ_Engineer": {[player] call FNC_EOD;};

            case "Alpha_SL": {[player] call FNC_SL;};
            case "Alpha_TL": {[player] call FNC_TL;};
            case "Alpha_Marksman": {[player] call FNC_MARK;};
            case "Alpha_EOD": {[player] call FNC_EOD;};
            case "Alpha_Medic": {[player] call FNC_MED;};
            case "Alpha_AT": {[player] call FNC_AT;};
            case "Alpha_AR": {[player] call FNC_AR;};
            case "Alpha_Operator": {[player] call FNC_OP;};

            case "Bravo_SL": {[player] call FNC_SL;};
            case "Bravo_TL": {[player] call FNC_TL;};
            case "Bravo_Marksman": {[player] call FNC_MARK;};
            case "Bravo_EOD": {[player] call FNC_EOD;};
            case "Bravo_Medic": {[player] call FNC_MED;};
            case "Bravo_AT": {[player] call FNC_AT;};
            case "Bravo_AR": {[player] call FNC_AR;};
            case "Bravo_Operator": {[player] call FNC_OP;};

            case "Charlie_Sniper": {[player] call FNC_SNIP;};
            case "Charlie_Spotter": {[player] call FNC_SPOT;};
            case "Charlie_Operator": {[player] call FNC_OP;};
            case "Charlie_Sniper1": {[player] call FNC_SNIP;};
            case "Charlie_Spotter1": {[player] call FNC_SPOT;};
            case "Charlie_Operator1": {[player] call FNC_OP;};

            case "AF_Pilot": {[player] call FNC_AFP;};
            case "AF_Pilot1": {[player] call FNC_AFP;};
            case "AF_Pilot2": {[player] call FNC_AFP;};
            case "AF_TL": {[player] call FNC_AFTL;};
            case "AF_JTAC": {[player] call FNC_AFJ;};
            case "AF_Medic": {[player] call FNC_AFMED;};

            };
       };

};

 

Or just use a different setup with an array instead of a switch.

 

 

First of all, Thank you very much for the help.

Unfortunately, The suggestion with 

(vehicleVarName player)

Didn't Worked.

 

Maybe its because the original code is outdated? (I haven't scripted for about Year).

Also, I don't remember how the array setup needed to be done, And the BI Wiki is down for Maintenance :( :(.

 

Do you have a suggestion?

Share this post


Link to post
Share on other sites

Depends on how you want to define what unit gets which loadout and there are a lot of ways how that can be done.

 

- You could place area markers for each loadout and use a script that applies loadouts depending on what marker a unit is in.

 

- You could sync them to triggers.

 

- You could use tags in the names of each unit and detect these.

 

- You could have seperate arrays for each type of loadout and simply add the unit-names to these arrays.

 

- You could assign loadouts based on the classnames of units.

 

- You could use the roleDescription and insert the name of the loadout there.

 

- ....

 

 

and probably some other creative ways that I forgot

Share this post


Link to post
Share on other sites
11 minutes ago, Tajin said:

Depends on how you want to define what unit gets which loadout and there are a lot of ways how that can be done.

 

- You could place area markers for each loadout and use a script that applies loadouts depending on what marker a unit is in.

 

- You could sync them to triggers.

 

- You could use tags in the names of each unit and detect these.

 

- You could have seperate arrays for each type of loadout and simply add the unit-names to these arrays.

 

- You could assign loadouts based on the classnames of units.

 

- You could use the roleDescription and insert the name of the loadout there.

 

- ....

 

 

and probably some other creative ways that I forgot

Thank you for your reply.

Its really funny and true, if you didn't practice in something for long time, you forget it although you really like it.

Unfortunately I don't remember how to do all of that stuff.. Perhaps Ill wait to BI Wiki to come back, and try to google your suggestion.

Share this post


Link to post
Share on other sites

Here is an example:

/*scripts\client.sqf*/

if !(isDedicated) then {
    diag_log format ["client :1"];
    waitUntil { !IsNull Player };
    if (local player) then {
        waitUntil { time > 1 };
        
        // Factions
        diag_log format ["client :%1 %2", faction player, time];
        _name = vehicleVarName player;
        _arr = _name splitString "_";
        _arr params ["_group","_class","_num"];

        [player] call (missionNamespace getVariable [format["FNC_%1",_class],{
            diag_log format ["%1 - %2 : Loadout not found", player, vehicleVarName player];
        }]);
    };
};

 

This would just require you to name your units in a certain way, so that the name of the loadout is included in the unitname.

Like this (note the underscores):

 

Bravo_EOD_1
Bravo_EOD_2
Bravo_EOD_3

Charlie_SNIP_1
Charlie_OP_1

 

The second part of the name has to match the names of your loadout-functions. Simple as that.

 

 

 

Share this post


Link to post
Share on other sites

You could fix your switch do.

You can't put another switch do into a switch do instead of a case. Your syntax is broken (especially lines 12-19).

If you want to nest switches, this is the way to do it:

switch (_var_1) do {
	case "value_1": { code };
	case "value_2": {
		switch (_var_2) do {
			case "value_2_1": { code };
			case "value_2_2": { code };
			default {};
		};
	};
	default {};
};

 

Share this post


Link to post
Share on other sites
31 minutes ago, Tajin said:

Here is an example:


/*scripts\client.sqf*/

if !(isDedicated) then {
    diag_log format ["client :1"];
    waitUntil { !IsNull Player };
    if (local player) then {
        waitUntil { time > 1 };
        
        // Factions
        diag_log format ["client :%1 %2", faction player, time];
        _name = vehicleVarName player;
        _arr = _name splitString "_";
        _arr params ["_group","_class","_num"];

        [player] call (missionNamespace getVariable [format["FNC_%1",_class],{
            diag_log format ["%1 - %2 : Loadout not found", player, vehicleVarName player];
        }]);
    };
};

 

This would just require you to name your units in a certain way, so that the name of the loadout is included in the unitname.

Like this (note the underscores):

 

Bravo_EOD_1
Bravo_EOD_2
Bravo_EOD_3

Charlie_SNIP_1
Charlie_OP_1

 

The second part of the name has to match the names of your loadout-functions. Simple as that.

 

 

 

 

Changed the script to this:

/*scripts\client.sqf*/

if !(isDedicated) then {
    diag_log format ["client :1"];
    waitUntil { !IsNull Player };
    if (local player) then {
        waitUntil { time > 1 };
		
		// Factions
	    diag_log format ["client :%1 %2", faction player, time];
        _name = vehicleVarName player;
        _arr = _name splitString "_";
        _arr params ["_group","_class","_num"];


        [player] call (missionNamespace getVariable [format["FNC_%1",_class],{
            diag_log format ["%1 - %2 : Loadout not found", player, vehicleVarName player];
		}]);

            case MHQ_Commander: {[MHQ_Commander] call FNC_SL;};
            case MHQ_Medic: {[MHQ_Medic] call FNC_MED;};
            case MHQ_UAVO: {[MHQ_UAVO] call FNC_UAVO;};
			case MHQ_Engineer: {[MHQ_Engineer] call FNC_EOD;};

			case Alpha_SL: {[Alpha_SL] call FNC_SL;};
			case Alpha_TL: {[Alpha_TL] call FNC_TL;};
            case Alpha_Marksman: {[Alpha_Marksman] call FNC_MARK;};
			case Alpha_EOD: {[Alpha_EOD] call FNC_EOD;};
			case Alpha_Medic: {[Alpha_Medic] call FNC_MED;};
			case Alpha_AT: {[Alpha_AT] call FNC_AT;};
            case Alpha_AR: {[Alpha_AR] call FNC_AR;};
			case Alpha_Operator: {[Alpha_Operator] call FNC_OP;};

			case Bravo_SL: {[Bravo_SL] call FNC_SL;};
			case Bravo_TL: {[Bravo_TL] call FNC_TL;};
            case Bravo_Marksman: {[Bravo_Marksman] call FNC_MARK;};
			case Bravo_EOD: {[Bravo_EOD] call FNC_EOD;};
			case Bravo_Medic: {[Bravo_Medic] call FNC_MED;};
			case Bravo_AT: {[Bravo_AT] call FNC_AT;};
            case Bravo_AR: {[Bravo_AR] call FNC_AR;};
			case Bravo_Operator: {[Bravo_Operator] call FNC_OP;};

            case Charlie_Sniper: {[Charlie_Sniper] call FNC_SNIP;};
			case Charlie_Spotter: {[Charlie_Spotter] call FNC_SPOT;};
            case Charlie_Operator: {[Charlie_Operator] call FNC_OP;};
			case Charlie_Sniper1: {[Charlie_Sniper1] call FNC_SNIP;};
			case Charlie_Spotter1: {[Charlie_Spotter1] call FNC_SPOT;};
			case Charlie_Operator1: {[Charlie_Operator1] call FNC_OP;};

			case AF_Pilot: {[AF_Pilot] call FNC_AFP;};
			case AF_Pilot1: {[AF_Pilot1] call FNC_AFP;};
            case AF_Pilot2: {[AF_Pilot2] call FNC_AFP;};
			case AF_TL: {[AF_TL] call FNC_AFTL;};
			case AF_JTAC: {[AF_JTAC] call FNC_AFJ;};
			case AF_Medic: {[AF_Medic] call FNC_AFMED;};

            };
       };

};  

Thank you for your reply!

And to check for example the MHQ Commander: I have assigned him the FNC_SL and as in the loadout file.

Also named him in game as MHQ_Commander.. Still not working..

Share this post


Link to post
Share on other sites
3 minutes ago, belbo said:

You could fix your switch do.

You can't put another switch do into a switch do instead of a case. Your syntax is broken (especially lines 12-19).

Its my old Script, somehow it worked till now 0-0

Share this post


Link to post
Share on other sites
11 minutes ago, hydrobull3t said:

Its my old Script, somehow it worked till now 0-0

In that case you must have removed lines that were previously there.

And with your current version you check for the player variable directly. That will go awry if not ALL of the listed players are present.

You have to check for (str player) and then refer to the strings of the player units.

The most simple way to apply your loadouts would be:

switch (faction player) do {
	case "OPF_F": { };
	case "BLUF_F": {
		switch (str player) do {
			case "MHQ_Commander": { [player] call fnc_sl };
			case "MHQ_Medic": { [player] call fnc_med };
			case "MHQ_UAVO": { [player] call fnc_uavo };
			default { [player] call fnc_op };
		};
	};
	default {};
};

Or you could even just use ["_SL", str player] call BIS_fnc_inString to create a case for all player units with _SL in their name:

private _str = str player;
switch (faction player) do {
	case "OPF_F": { };
	case "BLUF_F": {
		switch (true) do {
			case ( ["_SL",_str] call BIS_fnc_inString || ["_comm",_str] call BIS_fnc_inString ): { [player] call fnc_sl };
			case ( ["_medic",_str] call BIS_fnc_inString ): { [player] call fnc_med };
			case ( ["_uavo",_str] call BIS_fnc_inString ): { [player] call fnc_uavo };
            case ( ["_eod",_str] call BIS_fnc_inString || ["_engin",_str] call BIS_fnc_inString ): { [player] call fnc_eod };
            case ( ["_tl",_str] call BIS_fnc_inString ): { [player] call fnc_tl };
            case ( ["_mark",_str] call BIS_fnc_inString ): { [player] call fnc_mark };
            case ( ["_AT",_str] call BIS_fnc_inString ): { [player] call fnc_at };
            case ( ["_AR",_str] call BIS_fnc_inString ): { [player] call fnc_ar };
            case ( ["_snip",_str] call BIS_fnc_inString ): { [player] call fnc_snip };
            case ( ["_spot",_str] call BIS_fnc_inString ): { [player] call fnc_spot };
            case ( ["_pilot",_str] call BIS_fnc_inString ): { [player] call fnc_afp };
            case ( ["_jtac",_str] call BIS_fnc_inString ): { [player] call fnc_afj };
			default { [player] call fnc_op };
		};
	};
	default {};
};

I'd only recommend using unit names that make sense to be used with BIS_fnc_inString. AF_TL and Bravo_TL will get the same fnc_tl loadout. Call the AF_TL "AF_AFTL" instead for example.

Share this post


Link to post
Share on other sites
3 minutes ago, belbo said:

In that case you must have removed lines that were previously there.

And with your current version you check for the player variable directly. That will go awry if not ALL of the listed players are present.

You have to check for (str player) and then refer to the strings of the player units.

Thanks for the reply,

I left it while it worked (year ago) and didn't touched it...

Can you show me please example of 

 (str player)

As im trying to figure things on the go (I don't remember lot of stuff)

Share this post


Link to post
Share on other sites
13 minutes ago, belbo said:

In that case you must have removed lines that were previously there.

And with your current version you check for the player variable directly. That will go awry if not ALL of the listed players are present.

You have to check for (str player) and then refer to the strings of the player units.

The most simple way to apply your loadouts would be:

Or you could even just use ["_SL", str player] call BIS_fnc_inString to create a case for all player units with _SL in their name:

 

If I choose this (looks easier)

Than how for example, the "case "MHQ_Commander": { [player] call fnc_sl };" will know what loadout to call?

I need some sort of function that will order to get the loadout from like this: [] call compile preprocessFile "f\gear_setup\loadouts_bluefor.sqf";}; // Bluefor Set ??

switch (faction player) do {
	case "OPF_F": { };
	case "BLUF_F": {
		switch (str player) do {
			case "MHQ_Commander": { [player] call fnc_sl };
			case "MHQ_Medic": { [player] call fnc_med };
			case "MHQ_UAVO": { [player] call fnc_uavo };
			default { [player] call fnc_op };
		};
	};
	default {};
};

Share this post


Link to post
Share on other sites
20 minutes ago, hydrobull3t said:

Changed the script to this: ...

Don't mix two completely different scripts together.

Especially not like that.

 

What I posted was supposed to be the complete file. ;)

Share this post


Link to post
Share on other sites

You have to define your fnc_whatever variables before executing the switch that calls these variables of course.

[] call compile preprocessFileLineNumbers "scripts\loadouts.sqf";
[] call compile preprocessFileLineNumbers "scripts\client.sqf";

 

Share this post


Link to post
Share on other sites
1 minute ago, Tajin said:

Don't mix two completely different scripts together.

Especially not like that.

 

What I posted was supposed to be the complete file. ;)

Thanks for the reply,

ohhh, I see..

If I may ask, How is your script will know what to call?

I need some sort of function that will order to get the loadout from like this: [] call compile preprocessFile "f\gear_setup\loadouts_bluefor.sqf";}; // Bluefor Set ?? 

Or Im not getting it 0-0

Share this post


Link to post
Share on other sites
7 minutes ago, belbo said:

You have to define your fnc_whatever variables before executing the switch that calls these variables of course.


[] call compile preprocessFileLineNumbers "scripts\loadouts.sqf";
[] call compile preprocessFileLineNumbers "scripts\client.sqf";

 

So something Like that?

/*scripts\client.sqf*/

if !(isDedicated) then {
diag_log format ["client :1"];
  waitUntil { !IsNull Player };
      if (local player) then {
        
        waitUntil { time > 1 };
        
        // Factions
    diag_log format ["client :%1 %2", faction player, time];
        switch (faction player) do {
	case "OPF_F": { };
	case "BLUF_F": {
		switch (str player) do {
			case "MHQ_Commander": { [player] call fnc_sl };
			case "MHQ_Medic": { [player] call fnc_med };
			case "MHQ_UAVO": { [player] call fnc_uavo };
			default { [player] call fnc_op };
		};
        [] call compile preprocessFileLineNumbers "f\gear_setup\loadouts_bluefor.sqf";
        [] call compile preprocessFileLineNumbers "f\gear_setup\client.sqf";
	};
	default {};
};

 

Share this post


Link to post
Share on other sites

No. These are the calls for the scripts that YOU posted. Why... what... why would you even put it in there AFTER I explained that you screw up your whole syntax when you put random code into a switch?

 

You first call loadouts_blufor.sqf -> There you define the fnc_XYZ-variables as your loadouts.

Then you call your client.sqf -> The one with the switch that calls the fnc_XYZ-codes depending on str player.

You put that in your initPlayerLocal.sqf:

[] call compile preprocessFileLineNumbers "f\gear_setup\loadouts_bluefor.sqf";

[] call compile preprocessFileLineNumbers "f\gear_setup\client.sqf";

 

The first one is https://pastebin.com/YfS7ZbTv

and the second one is https://pastebin.com/MjjhvDBm, provided you fix it according to either Tajin's suggestion or mine.

  • Haha 1
  • Sad 1

Share this post


Link to post
Share on other sites
15 minutes ago, hydrobull3t said:

If I may ask, How is your script will know what to call?

 

By breaking the unit-names appart.

 

This:

"Bravo_EOD_3"

 

gets split into

"Bravo"

"EOD"

"3"

 

The middle part of it is then used as function name, resulting in this "FNC_EOD".

The function then gets fetched from missionNamespace and called. (if the function doesn't exist, it'll run a default function instead, which in my case simply logs an error)

 

So its just a question of naming your units correctly.

Share this post


Link to post
Share on other sites
21 minutes ago, belbo said:

No. These are the calls for the scripts that YOU posted. Why... what... why would you even put it in there AFTER I explained that you screw up your whole syntax when you put random code into a switch?

 

You first call loadouts_blufor.sqf -> There you define the fnc_XYZ-variables as your loadouts.

Then you call your client.sqf -> The one with the switch that calls the fnc_XYZ-codes depending on str player.

You put that in your initPlayerLocal.sqf:

[] call compile preprocessFileLineNumbers "f\gear_setup\loadouts_bluefor.sqf";

[] call compile preprocessFileLineNumbers "f\gear_setup\client.sqf";

 

The first one is https://pastebin.com/YfS7ZbTv

and the second one is https://pastebin.com/MjjhvDBm, provided you fix it according to either Tajin's suggestion or mine.

Thank you for your reply, Sorry for my mistakes..

 

So as I understand.

1. need to create initPlayerLocal.sqf in root mission file, and put 

[] call compile preprocessFileLineNumbers "f\gear_setup\loadouts_bluefor.sqf";

[] call compile preprocessFileLineNumbers "f\gear_setup\client.sqf";

in it.

 

2. loadout_bluefor.sqf, rename each role to something like Command_SL_1

 

3. Fix the client.sqf with 

switch (faction player) do {
	case "OPF_F": { };
	case "BLUF_F": {
		switch (str player) do {
			case "Command_SL_1": { [player] call fnc_sl };
			case "Alpha_SL_1": { [player] call fnc_sl };
			case "Bravo_SL_1": { [player] call fnc_sl };
			default { [player] call fnc_op };
		};
	};
	default {};
};

and continue to add the names of the Roles and The variables names. 

Share this post


Link to post
Share on other sites
12 minutes ago, Tajin said:

 

By breaking the unit-names appart.

 

This:

"Bravo_EOD_3"

 

gets split into

"Bravo"

"EOD"

"3"

 

The middle part of it is then used as function name, resulting in this "FNC_EOD".

The function then gets fetched from missionNamespace and called. (if the function doesn't exist, it'll run a default function instead, which in my case simply logs an error)

 

So its just a question of naming your units correctly.

Thanks again for the help,

 

So as I understand,

 

1. Edit the client.sqf with the script you have added

2. the loadout_bluefor.sqf is ok, so no need to touch

3. rename in game the var name of each character to something else but that will include the name after FNC_X.. for example. 

Loadout_bluefor.sqf has FNC_SL

So i rename in game the character to Command_SL_1?

  • Like 1

Share this post


Link to post
Share on other sites
45 minutes ago, Tajin said:

 

By breaking the unit-names appart.

 

This:

"Bravo_EOD_3"

 

gets split into

"Bravo"

"EOD"

"3"

 

The middle part of it is then used as function name, resulting in this "FNC_EOD".

The function then gets fetched from missionNamespace and called. (if the function doesn't exist, it'll run a default function instead, which in my case simply logs an error)

 

So its just a question of naming your units correctly.

Hello again,

I have tried your suggestion without luck :(

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

×