Jump to content
hoverguy

Function not called (line is "ignored")

Recommended Posts

Hi everyone,

 

I am having troubles trying to call a function on the server (either dedicated or local host)

 

Here is what I have (mock-up):

 

initServer.sqf

[] call compile preprocessFileLineNumbers "\HG_Server\Core\Setup\serverInitialization.sqf";

serverInitialization.sqf

// lines of code
 
/* Database Initialization */
[] call SETUP_fnc_initExtDB;
/* -------------------- */
 
/* Reset Character State */
["resetCharState",1] call HG_fnc_handleQuery; // <- THIS LINE IS NOT EVEN CALLED
/* -------------------- */
 
// lines of code

Every line of code with HG_fnc_handleQuery in it is "ignored"... (in other functions too)...

 

Before you ask:

- HG_fnc_handleQuery is defined on the server (in addon -> config.cpp -> CfgFunctions) and is always called by the server

- If I try the mission as a local host or on dedicated -> can't call the function, even in debug console

- If I use the function ALONE outside of the mission and call it -> works and a value is returned as expected

- There is no suspension of any kind inside the function (otherwise "suspending not allowed in this context" would be thrown in RPT) which is weird because if I spawn it, it works but this is not a solution to me when I want a return value

- If I do

hint str HG_fnc_handleQuery

I can see that the function is defined correctly

 

I also tried this:

private["_query","_queryResult"];
_query = format["pInfosRequest",(getPlayerUID player)];
diag_log format["QUERY IS %1",_query];
_queryResult = [_query,2] call HG_fnc_handleQuery;
diag_log format["QUERY RESULT IS %1",_queryResult];

RPT:

QUERY IS pInfosRequest:454545445
QUERY RESULT IS <null>
And of course the famous error shows up -> 
Error Undefined variable in expression: _queryresult

 

Any clues guys?

 

EDIT: Fixed, was missing closing curly bracket... was not even mentioned in RPT...

Share this post


Link to post
Share on other sites

Can you post how you defined the function? Like post your description.ext or config

 

Sure here it goes:

class CfgFunctions
{
    class Setup
    {
        tag = "SETUP";
 
        class SSetup
        {
            file = "\HG_Server\Core\Setup";
            class initExtDB {};
            // other functions
        };
    };
 
    class Database
    {
        tag = "HG";
 
        class SDatabase
        {
            file = "\HG_Server\Core\Database";
            class handleQuery {};
            // other functions
        };
    };
};

Share this post


Link to post
Share on other sites

OK, you need to redefine how those are for it to work. I can write code at the moment very easily as I'm on my phone, so I will do my best explaining it.

In cfgfunctions, the first class you define is going to be the first portion in your function call. IE, if you want HG_fnc_handleQuery, your first class will be class HG. Next class is orgazational from what I can tell. Simply using class functions is fine. Then you need a final class. This is your function name. So for your query, it should be class handleQuery. So you should have some thing like

Class cfgfunctions {

Class HG {

Class functions {

Class handleQuery {

file="file path";

};

};

};

};

Share this post


Link to post
Share on other sites

OK, you need to redefine how those are for it to work. I can write code at the moment very easily as I'm on my phone, so I will do my best explaining it.

In cfgfunctions, the first class you define is going to be the first portion in your function call. IE, if you want HG_fnc_handleQuery, your first class will be class HG. Next class is orgazational from what I can tell. Simply using class functions is fine. Then you need a final class. This is your function name. So for your query, it should be class handleQuery. So you should have some thing like

Class cfgfunctions {

Class HG {

Class functions {

Class handleQuery {

file="file path";

};

};

};

};

 

Thanks for taking the time to answer, but the way I define functions classes/subclasses in CfgFunctions is correct because the tag tokken "replaces" current parent class name (more of a macro/reference than a replacement).

Share this post


Link to post
Share on other sites

Doesn't hurt to try it that way. Never know when a certain method is incompatible in certain circumstances. Also, usually I find that you need to define the file with its extension (IE .sqf). Could try that as well.

Also, is add-on that has the script on all clients or only server? If it's only server, clients would be unable to call the function as its undefined for them.

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

×