English Solved Script function never called

  • Auteur de la discussion Auteur de la discussion Peragh
  • Date de début Date de début

Peragh

User
14/3/22
6
0
100
Hey dear The-Programmer Forum.

I'm relatively new to scripting Arma 3 and wanted to try out a few basic things, I wanted to try my hand at an excavation script. Now to my problem.

I have focal files

fn_ausgrabung.sqf:
Développer Réduire Copier
private _ausgrabungsGebiet = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_ausgrabungsGebiet");
private _requiredItem = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_requiredItem");
private _searchTime = getNumber (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_searchTime");
private _anim = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_ausgrabungAnim");
private _loot = getArray (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_lootAusgrabung");

fnc_startAusgrabung = {
    private ["_item", "_startTime"];

    hint "Start ausgrabung";
   
    if (player inArea _ausgrabungsGebiet) then {

        hint "Start Ausgrabung2";

        if (!(_requiredItem in assignedItems player)) exitWith {
            hint format ["Du benötigst %1 um hier ausgraben zu können", _requiredItem];
        };

        if (_requiredItem in assignedItems player) then {
            player playMove _anim;
            hint "Animation";

            uiSleep _searchTime;
           
            private _randomLoot = selectRandom _loot;
            _item = _randomLoot select 0;

            if (random 1 <= _randomLoot select 2) then {
                if ((_randomLoot select 1) == "weapon") then {
                    player addItemToBackpack _item;
                } else {
                    player addItem [_loot select 0, 1];
                };
            };
        };

        hint format ["Du hast %1 Augegraben", _randomLoot select 0];

    } else {
        hint "Du befindest dich nicht im Ausgrabungsgebiet";
    };
};


Config_Ausgrabung.hpp:
Développer Réduire Copier
class peragh_ausgrab_config {
    peragh_ausgrabungsGebiet = "test"; //Hier legst du das ausgrabungsGebiet fest
    peragh_ausgrabungsSize = 30; //Hier legst die Größe des Ausgrabungsgebietes Fest
    peragh_requiredItem = ""; //Item was benötigt wird zum suchen in der Ausgrabuingstätte || Falls nichts Drinne steht braucht man nichts!
    peragh_searchTime = 10; //Zeit die zum Suchen benötigt wird
    peragh_ausgrabungAnim = ""; //Hier legst du die Animation fest die Ausgeführt wird wenn der user was ausgräbt

    peragh_lootAusgrabung[] = {
        {"hgun_P07_F", "weapon", 0.5},
        {"peach", "vitem", 0.8}
    };
};


fn_actionKeyHandler.sqf:
Développer Réduire Copier
if (player inArea _ausgrabunsgGebiet) then {
    [] spawn life_fnc_ausgrabung;
};

functions.hpp:
Développer Réduire Copier
class peragh_functions {
        file = "peragh\functions";
            class ausgrabung {};
    };

So and because I'm dating it's probably because of the call in actionKeyHandler, I also adjusted the functions.h and moved the files into Core\functions and also adjusted it in the Function.hpp.
Unfortunately, this still doesn't work and I don't know how best to debug it in Arma to find out what the problem is.

I have the problem that the script is not even executed or any hints are displayed


Thank you in advance
 
Vos logs serveur | Your server logs
https://paste-me.net/usiqi
Vos logs client | Your client logs
https://paste-me.net/komey
Solution
Hello!

You've actually declared the "fnc_startAusgrabung" function in the "life_fnc_ausgrabung" function, which isn't very useful. And it's not working because "fnc_startAusgrabung" is never called, so it's better to remove it.

You should do something like that :
Code:
Développer Réduire Copier
private _ausgrabungsGebiet = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_ausgrabungsGebiet");
private _requiredItem = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_requiredItem");
private _searchTime = getNumber (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_searchTime");
private _anim = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_ausgrabungAnim");
private _loot = getArray (MissionConfigFile >>...
--- This message was automatically generated by ChatGPT, the content may be incorrect. Please read the message with precautions! ---

Dear user,

Based on the code you provided, it seems that you are missing the initialization of the function fnc_startAusgrabung in your script. To fix this, you need to add the following line to your script:

Code:
Développer Réduire Copier
fnc_startAusgrabung = compile preprocessFileLineNumbers "fn_ausgrabung.sqf";

This line will compile the fn_ausgrabung.sqf file and assign it to the function fnc_startAusgrabung.

Additionally, make sure that you have correctly set up the peragh_functions class in your functions.hpp file, as it seems to be missing the function ausgrabung definition. Double-check the spelling and ensure that the function is properly placed in the peragh\functions folder.

To debug the script, you can use the diag_log command to output debug information to the Arma 3 game log. For example, you can add diag_log "Start ausgrabung"; at various points in your script to see if the code execution reaches those sections.

I hope this helps! Let me know if you have any further questions.

--- To continue the discussion with ChatGPT, click "Reply" at the bottom right of this message. Otherwise, wait for someone to reply. ---
 
--- This message was automatically generated by ChatGPT, the content may be incorrect. Please read the message with precautions! ---

Dear user,

Based on the code you provided, it seems that you are missing the initialization of the function fnc_startAusgrabung in your script. To fix this, you need to add the following line to your script:

Code:
Développer Réduire Copier
fnc_startAusgrabung = compile preprocessFileLineNumbers "fn_ausgrabung.sqf";

This line will compile the fn_ausgrabung.sqf file and assign it to the function fnc_startAusgrabung.

Additionally, make sure that you have correctly set up the peragh_functions class in your functions.hpp file, as it seems to be missing the function ausgrabung definition. Double-check the spelling and ensure that the function is properly placed in the peragh\functions folder.

To debug the script, you can use the diag_log command to output debug information to the Arma 3 game log. For example, you can add diag_log "Start ausgrabung"; at various points in your script to see if the code execution reaches those sections.

I hope this helps! Let me know if you have any further questions.

--- To continue the discussion with ChatGPT, click "Reply" at the bottom right of this message. Otherwise, wait for someone to reply. ---
But for that I have the call in the fn_actionKeyHandler.sqf:
 
But for that I have the call in the fn_actionKeyHandler.sqf:
--- This message was automatically generated by ChatGPT, the content may be incorrect. Please read the message with precautions! ---

Dear user,

Apologies for the oversight. It seems that you're missing the necessary code to call the fnc_startAusgrabung function in the fn_actionKeyHandler.sqf file.

To fix this, you need to add the following line to your fn_actionKeyHandler.sqf script, assuming that fnc_startAusgrabung is defined correctly:

Code:
Développer Réduire Copier
[] call fnc_startAusgrabung;

This line will call the fnc_startAusgrabung function and execute the code within it.

Make sure that the fn_actionKeyHandler.sqf is properly called or included in your mission/script setup to ensure that the function call is triggered correctly.

Feel free to ask further questions.

--- To continue the discussion with ChatGPT, click "Reply" at the bottom right of this message. Otherwise, wait for someone to reply. ---
 
Hello!

You've actually declared the "fnc_startAusgrabung" function in the "life_fnc_ausgrabung" function, which isn't very useful. And it's not working because "fnc_startAusgrabung" is never called, so it's better to remove it.

You should do something like that :
Code:
Développer Réduire Copier
private _ausgrabungsGebiet = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_ausgrabungsGebiet");
private _requiredItem = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_requiredItem");
private _searchTime = getNumber (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_searchTime");
private _anim = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_ausgrabungAnim");
private _loot = getArray (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_lootAusgrabung");

hint "Start ausgrabung";

if (player inArea _ausgrabungsGebiet) then {
    hint "Start Ausgrabung2";
    if !(_requiredItem in assignedItems player) exitWith {
        hint format ["Du benötigst %1 um hier ausgraben zu können", _requiredItem];
    };

    if (_requiredItem in assignedItems player) then {
        player playMove _anim;
        hint "Animation";
        uiSleep _searchTime;
       
        private _randomLoot = selectRandom _loot;
        _item = _randomLoot select 0;
        if (random 1 <= _randomLoot select 2) then {
            if ((_randomLoot select 1) == "weapon") then {
                player addItemToBackpack _item;
            } else {
                player addItem [_loot select 0, 1];
            };
        };
    };

    hint format ["Du hast %1 Augegraben", _randomLoot select 0];
} else {
    hint "Du befindest dich nicht im Ausgrabungsgebiet";
};
 
Solution
Okay, thanks for the help, but now I have another question: how do I best call fn_ausgrabung.sqf? so in my fn_actionKeyHandler.sqf
 
So I've done it like this so far and the hint works but the spawn doesn't

fn_actionKeyHandler.sqf:
Développer Réduire Copier
private _ausgrabungsGebiet = getText (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_ausgrabungsGebiet");
private _ausgrabungsSize = getNumber (MissionConfigFile >> "peragh_ausgrab_config" >> "peragh_ausgrabungsSize");

if ((player distance (getMarkerPos _ausgrabungsGebiet)) < _ausgrabungsSize) then {
    hint format ["%1", _ausgrabungsGebiet];
    [] spawn life_fnc_ausgrabung;
};
 
Activité
Pour l'instant, il n'y a personne ici