Jump to content

Recommended Posts

Hello everyone. I have been struggling to find out why this script is not executing properly on my dedicated server. Unfortunately my  LINUX dedicated server host is unwilling to provide me with a server.rpt file that would make my troubleshooting easier I believe.

Objective:
Create a script that will add two actions to civilians on the map.

Code executed in the InitServer.sqf:
 

//add actions to civilians
addCivActions = {
    params ["_unit"];
    if (!isNil "_unit" && {_unit isKindOf "Man"}) then {
        [_unit, ["<t color='#FF0000'>Get Down</t>", {
				params ["_target"];
				_target setUnitPos "DOWN";
				removeAllActions _target;
				[_target] spawn {
					sleep 10;
					private _unit = _this select 0;
					if (alive _unit) then {
						_unit setUnitPos "UP";
						[_unit] remoteExec ["addCivActions", 2];
					};
				};
        }, nil, 6, true, true, "", "", 8]] remoteExec ["addAction", [0, -2] select isDedicated];

        [_unit addAction ["<t color='#FF0000'>Stop</t>", {
				params ["_target"];
				_target disableAI "MOVE";
				removeAllActions _target;
				[_target] spawn {
                sleep 10;
                private _unit = _this select 0;
                if (alive _unit) then {
                    _unit enableAI "MOVE";
                    [_unit] remoteExec ["addCivActions", 2];
					};
				};
        }, nil, 6, true, true, "", "", 8]] remoteExec ["addAction", [0, -2] select isDedicated];
		
        _unit addEventHandler ["Killed", {
            params ["_unit"];
            removeAllActions _unit;
        }];

        _unit setVariable ["actionsAdded", true];
    };
};

// Function to check all civilians and add actions if not already added
checkForCivilians = {
    {
        if (side _x == civilian && {!(_x getVariable ["actionsAdded", false])}) then {
            [_x] call addCivActions;
        };
    } forEach allUnits;
};

// Schedule the check to run periodically on the server
[] spawn {
    while {true} do {
        call checkForCivilians;
        sleep 8; // Adjust the interval as needed
    };
};


Problem:

Spoiler

 

On my dedicated server the civilians only have one interaction appear: "Get Down" and they completely ignore the command. They run around no problem.
 DA06AA37F85ABB746D42A9C8FE46349F02F57A4C

However, if I spawn a civilian through Zeus, they will still only have the "get down" command but they obey it and go prone for 10seconds.

A6CCB3F5CB2AE1FEC99EB3C78DBD760B4CA5E09E


A friend inserted the code onto his dedicated server and it executed correctly: 


So, I have no clue how the script executes on my friends dedicated server and not mine.... I don't know where to start with troubleshooting. Typically I would look through the server.rpt for any reports but that is not an option.

 



I am not asking for someone else to re-write my script but I am sure you can tell I am a novice at scripting at best. If there is a simpler solution to achieve what I want I am all ears. Keep in mind the solution must work on a dedicated server and I dont want civilians running around with multiple of the same commands. addAction only executes locally, remoteExec is suppose to supplement the limiting nature of locality..... that is about as far as my understanding goes currently.

Been stuck with this problem for 2 weeks. I have tried executing it as a script outside of Initserver.sqf. I have tried calling the function at the point of civilians spawning. I have tried other things that didn't work too, I am at my wits end especially after asking my friend to throw it on his server and seeing it execute flawlessly..... He literally copy and pasted my code, only difference is he executed the code from the advanced developer tools mod: https://steamcommunity.com/sharedfiles/filedetails/?id=2369477168 while I have a file in my mission folder.

Share this post


Link to post
Share on other sites

As you wrote, addAction code is local to the caller.(GA LE). That means your commands (and functions if any) must be remote executed for other clients (and server if necessary).

This is different from the fact you remote execute the addAction itself , to be added for all players.

Examples:

_target setUnitPos "DOWN";

setUnitPos is LA GE. If the civilian unit is on server, LA means you need to remoteExec on server. More exactly, you remote exec where the unit is (could be on headless client or even a client PC if in player's group)

Here if civilian AIs stays on server (no join or joinSilent command):
 

[_target, "DOWN"] remoteExec ["setUnitPos",2];

 

_target disableAI "MOVE";

disableAi is GA LE  (but enableAi is LA GE, if I follow BIKI). Say it's OK... You need to remoteExec disableAI everywhere, and treat enableAI as shown for setUnitPos. LE means the effect applies locally only.

[_target,"MOVE"] remoteExec ["disableAi",0,TRUE];

same for removeAllActions

 

Only GA GE commands can be used without remote execution if the target is not local to the caller. Perhaps, your friend tested on a hosted server, not a dedicated one.

  • Like 1

Share this post


Link to post
Share on other sites

So every line of code needs to be remote executed properly, ok. Shouldn't take too long to fix that.

A few questions:
- Why does the action "Get Down" show up but "Stop" doesn't? The syntax is correct, the code isn't functioning properly due to locality but that shouldn't mean the code just stops processing...right?

- Why does disableAI and enableAI execute differently...who wrote this engine? 🤡🤡🤡🤡🤡🤡
- So when Zeus throws a civilian unit down doesn't that execute on the server? Why would the "Get Down" command execute properly from a Zeus spawns a civilian?

- Should I be using [0, -2] select isDedicated] at the end of every remoteExecute?

Just trying to understand why this issue is presenting the way it is. 

Would you recommend a different way of writing this that would be more succinct or am I already on the right path?

Share this post


Link to post
Share on other sites

Hopefully this looks better:

 

//add actions to civilians
addCivActions = {
    params ["_unit"];
    if (!isNil "_unit" && {_unit isKindOf "Man"}) then {
        [_unit, ["<t color='#FF0000'>Get Down</t>", {
				params ["_target"];
				[_target, "DOWN"] remoteExec ["setUnitPos",2];
				[_target] remoteExec ["removeAllActions",0,TRUE];
				[_target] spawn {
					sleep 10;
					private _unit = _this select 0;
					if (alive _unit) then {
						[_unit, "UP"] remoteExec ["setUnitPos",2];
						[_unit] remoteExec ["addCivActions", 2];
					};
				};
        }, nil, 6, true, true, "", "", 8]] remoteExec ["addAction", [0, -2] select isDedicated];

        [_unit addAction ["<t color='#FF0000'>Stop</t>", {
				params ["_target"];
				[_target,"MOVE"] remoteExec ["disableAi",0,TRUE];
				[_target] remoteExec ["removeAllActions",0,TRUE];
				[_target] spawn {
                sleep 10;
                private _unit = _this select 0;
                if (alive _unit) then {
                    [_unit, "MOVE"] remoteExec ["enableAI",2];
                    [_unit] remoteExec ["addCivActions", 2];
					};
				};
        }, nil, 6, true, true, "", "", 8]] remoteExec ["addAction", [0, -2] select isDedicated];
		
        _unit addEventHandler ["Killed", {
            params ["_unit"];
            removeAllActions _unit;
        }];

        _unit setVariable ["actionsAdded", true];
    };
};

// Function to check all civilians and add actions if not already added
checkForCivilians = {
    {
        if (side _x == civilian && {!(_x getVariable ["actionsAdded", false])}) then {
            [_x] call addCivActions;
        };
    } forEach allUnits;
};

// Schedule the check to run periodically on the server
[] spawn {
    while {true} do {
        call checkForCivilians;
        sleep 8; // Adjust the interval as needed
    };
};

So now the issue flipped. I can order civ AI that spawn through my script to "Get Down" and it works..... however when I spawn a civilian while playing as Zeus the "GET DOWN" action is present but the order doesn't seem to execute....
I am assuming this means that when units spawn through Zeus I don't know where that execution is actually occurring.
Either way I am still missing the ability to order them to "STOP"

  • Like 1

Share this post


Link to post
Share on other sites

So I am thinking it has to be a server issue at this point. Maybe something about it being on a Linux Server is causing issues, I dont know.

https://streamable.com/jsiuez

At least in this mission I can see the Stop Action....

Share this post


Link to post
Share on other sites

Any ideas what on a Linux server would be causing issues with a script. Is there some type of setting I can change?

Share this post


Link to post
Share on other sites

I'm not sure if this would help but I have a dedicated server on my Windows 11 computer. I don't mind playing your mission file to see if it's any different.

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

×