#Issues when running on dedicated server

1 messages · Page 1 of 1 (latest)

wooden jewel
#

Started a thread rather than just spamming #arma3_scripting.

I decided to write my own custom jetpack system (because sci-fi), and it runs pretty much exactly how I want in singleplayer and when I start a LAN server for some basic multiplayer testing. However, when testing out on a dedicated server, some of the visuals break.

The visual stuff is relatively basic, just creating some particle / light sources, attaching them to the player, and storing the object in an array on the player.

I omitted most of the stuff that isn't necessary, considering that the entire thing is ~1,000 lines in total and most isn't relevant to the effects.

I'd greatly appreciate any kind of help people can give.

#

This is the entry point for my jetpack system, it runs a few checks (player not in water, player has fuel, etc.

// fn_Jetpack.sqf
// Called when pressing the corresponding keybind, starts the jetpack sequence if it does not already exist

// ...

private _jetpack = backpack ace_player;
private _jetStrength = GET_NUMBER(configFile >> "CfgVehicles" >> _jetpack >> "BNA_KC_Jet_strength", 1);

if (isNil "BNA_KC_Jet_JetpackHandle") then
{   
    // Speed and position, used for an initial boost
    private _velocity = velocity ace_player;
    private _position = getPosASL ace_player;

    // Give slight boost to start jetpacking, but only if starting from the ground
    if (ace_player call BNAKC_fnc_CanUseJetpack and isTouchingGround ace_player) then
    {
        // teleport up, increase velocity
    };

    // Event signalling a unit is starting a jetpack, EH handles visual particle effects
    ["BNA_KC_Jet_JetpackFired", [ace_player]] call CBA_fnc_GlobalEvent;

    BNA_KC_Jet_JetpackHandle =
    [
        BNAKC_fnc_JetpackFrameHandler
    ] call CBA_fnc_AddPerFrameHandler;
}
// fn_JetpackFrameHandler.sqf
// Handles the mid-air movement and removes the frame handlers when no longer flying.

// ...
private _thisHandler = _this select 1;
// ...

if (!(ace_player call BNAKC_fnc_CanUseJetpack) or isTouchingGround ace_player) exitWith
{
    [_thisHandler] call CBA_fnc_removePerFrameHandler;
    BNA_KC_Jet_JetpackHandle = nil; // Set to nil, just removing the handler keeps the global variable's value

    [BNA_KC_Jet_JetpackFuelHandle] call CBA_fnc_removePerFrameHandler;
    BNA_KC_Jet_JetpackFuelHandle = nil;
    
    //! Issue starts here, effects are not removed from player when landing on the ground

    // Wait a bit before removing effects, makes it look nicer
    [
        {
            // Delete effects
            {
                deleteVehicle _x;
            } forEach (ace_player getVariable ["BNA_KC_Jet_effectSources", []]);
            [BNA_KC_Jet_JetpackSoundHandle] call CBA_fnc_removePerFrameHandler;
            BNA_KC_Jet_JetpackSoundHandle = nil;
        },
        [],
        0.3
    ] call CBA_fnc_waitAndExecute;
};
// fn_JetpackEffectHandler.sqf
// Creates effects, attaches them to the unit jetpacking, and stores them for later deletion
// CBA XEH for "BNA_KC_Jet_JetpackFired"

//! As I type this I have a feeling this might be the problem line, but I don't necessarily see why?
if !(hasInterface) exitwith {}; // Function only contains visual effects, no need to execute on the server
params ["_unit"];

if (!(_unit call BNAKC_fnc_CanUseJetpack) or isTouchingGround _unit) exitWith {};

// Model points to spawn effects from
private _effectPoints = GET_ARRAY(configFile >> "CfgVehicles" >> _jetpack >> "BNA_KC_Jet_effectPoints", []);

{
    // Create effect, attach to player with offset using the model point
    // pushBack to array for later removal
} forEach _effectPoints;

// Save for later removal upon landing by the jetpack handler
_unit setVariable ["BNA_KC_Jet_effectSources", _effectSources];
gloomy delta
#

is the players BNA_KC_Jet_effectSources being populated in dedi

wooden jewel
#

None of the effects code is handled on the dedicated side because of if !(hasInterface) exitwith {};

#

Oh that's probably why

The code to delete the effects run on the server, but they're only created on the client's end, duh

That's probably what's causing the issue

#

So I either need to run the deletion code for each client, or just create the effects on the dedicated side as well.

Easier to just remove the if !(hasInterface) exitwith {}; line, but I don't see a reason for the server to have to handle the effects, so I'll remoteExec to save the objects on the server

Just something like this should work

// _unit setVariable ["BNA_KC_Jet_effectSources", _effectSources]; // Original
[_unit, ["BNA_KC_Jet_effectSources", _effectSources]] remoteExec ["setVariable"];
gloomy delta
#

create effects on the client

#

minimises network traffic

wooden jewel
#

They are only created on the client, I use createVehicleLocal to create all of the effects

gloomy delta
#

would use a cba event instead of remoteexec but i hate remoteexec so 🤷

wooden jewel
#

Could do that yeah, but it seems a little odd to put a CBA event in a CBA event handler

#

Not the strangest, but still odd

gloomy delta
#

oh is it in a cba eh

#

just have

if (hasInterface) then {/*delete particools*/};``` no?
wooden jewel
# gloomy delta oh is it in a cba eh
// fn_Jetpack.sqf
// Event signalling a unit is starting a jetpack, EH handles visual particle effects
["BNA_KC_Jet_JetpackFired", [ace_player]] call CBA_fnc_GlobalEvent;

Then JetpackEffectHandler listens for that event