#enfusion_scripting

1 messages · Page 6 of 1

coral stirrup
#

still seems like something did with 1.3, but might still be arkensor's fault lol

minor agate
#

There are no changes on this regard there

coral stirrup
#

good to know

#

thanks

minor agate
#

If it eas, whole game would be presenting similar issues

#

So there is a wrong ref usuage somewhere, at least for what you want to do

coral stirrup
#

yeh I think its in EPF

#

but still, would love to see EPF in base game one day (hint hint)

minor agate
#

For example, my name would cause the ref to go crazy

#

It would cause a mem leak or the jnstance to die when you do not expect

coral stirrup
#

I only ever create refs as class members and null them on ~deconstructor()

coral stirrup
#

really?

minor agate
#

When you destroy the class, they become null

coral stirrup
#

even in workbench?

minor agate
#

And it is not a pointer, so you do not need to reset memory content

minor agate
coral stirrup
#

well thats a time saver

minor agate
coral stirrup
#

maybe you can code review Overthrow for me before MANW lol

minor agate
#

Chrck the what not to do ref wise there

#

I provided examples of everything that ypu should not do with refs

coral stirrup
#

cheers

#

ill check that out

dire sinew
#

It's an attribute on the game mode entity. Don't remember whether it is on a component or the entity itself. Basically a list of resource types for which global supply usage should be off.

craggy jolt
#

GameMode_Campaign

valid python
#

Hello, my respects, I have a question: how can we make a red and white barrier indestructible? My request is for a passionate developer and mapper modder. Thank you very much.

pliant ingot
sweet badger
#

Is FileHandle::WriteArray() faster than calling FileHandle::Write() multiple times?

#

Basically I'm asking, does it make sense to put my data into an array for writing, or should I just write it directly?

sweet badger
#

I tested it by writing integers using a) WriteArray() and b) a foreach loop of Write().
10 integers (40b): 0.05ms vs. 0.02ms
100 integers (400b): 0.06ms vs. 0.15ms
1000 integers (4kb): 0.06ms vs 1.5ms.
10000 integers (40kb): 0.08ms 15.4ms.
It appears that yes, it is much much faster, and should always be used when you're writing more than 100 bytes.
The only place where you wouldn't use it is with less than 100 bytes (<25 integers) because WriteArray seems to come with a static cost of ~0.05ms (on my system).

scenic inlet
#

Hi everyone, hope you're all doing well!
I'm trying to figure out how to link a script to my scenario.
I have the script in my core mod, which is listed as a dependency for my scenario mod.
Now I want that script to be active and running in the scenario — how should I do that?

dire sinew
scenic inlet
fervent dawn
#

any idea how to prevent the animations from playing when a weapon is bipod-deployed and then reloaded in reforger? It is annoying to have to reset the bipod and re-acquire a target when using a bolt-action rifle. I tried looking into bipod methods and deployment but it looks like thats all internalized.

#

the only other janky work-around i could think of is keeping track of the player's camera and re-orienting it once they redeploy the bipod

#

it doesn't make sense to me though that a player would pick up a large rifle, orient up in the air, rack the bolt and then redeploy the weapon 🙂

craggy jolt
cunning wharf
#

Hi guys, is **version ** of the mod required?
I don't want to manually update version each time when some mod is updated.
I need to keep mods in config file instead of addon.gproj

{
  "modId": "5F0913BAAC69ABF5",
  "name": "Garbage Collector Patch",
  "version": "1.1.2"
}
pliant ingot
solid hearth
#

You only specify a version if you want to lock it to a specific one.

spark hinge
#

I'm trying to create a standalone mod that overwrites all other mod server start time , game time multiplier, random weather every 4 hours and random start dates .```modded class SCR_BaseGameMode
{
protected float m_fNextWeatherCheck;
protected const float WEATHER_INTERVAL = 14400; // 4 in-game hours in seconds

override void OnGameStart()
{
    super.OnGameStart();

    Print(">>> [TimeWeatherMod] Starting custom time and weather script...");

    SetRandomStartDateTime();
    SCR_Global.SetTimeMultiplier(1); // 1 real minute = 1 game minute

    GetGame().GetCallqueue().CallLater(UpdateWeatherLoop, 1000, true);
}

void SetRandomStartDateTime()
{
    SCR_DateTime dt = new SCR_DateTime();
    dt.SetHour(4);
    dt.SetMinute(2);
    dt.SetSecond(0);
    dt.SetDay(Math.RandomInt(1, 28)); //safe for all months
    dt.SetMonth(Math.RandomInt(1, 12));
    dt.SetYear(Math.RandomInt(1950, 1995));

    GetGame().GetWorld().SetWorldTime(dt);
    m_fNextWeatherCheck = dt.ToSeconds() + WEATHER_INTERVAL;

    PrintFormat("[TimeWeatherMod] Set time to %1/%2/%3 %4:%5",
        dt.GetDay(), dt.GetMonth(), dt.GetYear(), dt.GetHour(), dt.GetMinute());
}

void UpdateWeatherLoop()
{
    float now = GetGame().GetWorld().GetWorldTime().ToSeconds();
    if (now >= m_fNextWeatherCheck)
    {
        ForceRandomWeather();
        m_fNextWeatherCheck = now + WEATHER_INTERVAL;
    }
}

void ForceRandomWeather()
{
    Weather w = GetGame().GetWorld().GetWeather();
    if (!w) return;

    float clouds = Math.RandomFloat01();
    float fog = Math.RandomFloat01();
    float wind = Math.RandomFloat(0.1, 1.0);

    w.SetOvercast(clouds);
    w.SetFog(fog);
    w.SetWindSpeed(wind);

    PrintFormat("[TimeWeatherMod] Weather changed: Clouds %.2f, Fog %.2f, Wind %.2f", clouds, fog, wind);
}

}```

#

does this code look right??

primal iron
#

I'm sorry my English is not perfect, I'm French, I have a configuration problem on the server that I manage, I would like to make a modification of Montignac (this is an example) to change the city to a city that gives a point to the team that captures it but I can't do it and I depend on help on this subject if someone could help me ?

rapid ferry
#

Is there a quick way I can completely duplicate an existing entity into a clone? (if a weapon, include all attachments it has, or any other combo such as children/slots)

primal field
#

Where's base ownership managed? Need to be able to check when there are no more INDFOR/FIA owned control points

topaz locust
#

How do I fire a weapon using a script? Do I just use a signal name in the signals suffix field?

midnight talon
primal field
abstract crescent
#

Is player name safe for logs?
I take player name from "PlayerManager.GetPlayerName" and print it in logs, but is it safe, can player use specific unicode or smf in own name to make some issue by logs?

prime quarry
#

I am fairly new to modding within enfusion. I noticed some mods store most of its data within a json file. Is there capabilities to storing data to a cloud backend database? I haven’t navigated myself just yet, figured I’d ask first. And if it is possible, is it as simple as implementing a database in common practice or is a bit more complex?

midnight talon
smoky pawn
#

I need help - I am trying to make a script to show slide images on a screen in-game, I keep getting bad types or undefined functions. can anybody help??

smoky pawn
#

Current file structure:

│
├── Config/
│   └── CfgMod.c
│
├── Scripts/
│   └── Game/
│       └── REDCoats-TacBrief/
│           ├── SlideManagerComponent.c
│           └── SlideTriggerUserAction.c
│
├── UI/
│   ├── Layouts/
│   │   └── TacBriefScreen.layout
│   └── Images/
│       ├── slide_1.edds
│       ├── slide_2.edds
│       └── slide_3.edds```
smoky pawn
#

My layout is just a Overlay widget with an ImageWidget Child

#

The script is to be attached to an in-game screen placed within the server's map

hushed swan
#

Is it possible to make an override so that the WCS mod works in third person?

analog python
pliant ingot
#

It's possible to get index of array element in attribute from BaseContainer of this element in BaseContainerCustomTitle?

red cedar
#

Hey, have you figured out what was causing the error 422 ?

hushed swan
#

@pliant ingot Democracy - Map Voting is it functional for the version? It seems that as soon as you change the map, an error is displayed for some players and others are able to enter the server, I don't know if it's too many players trying to connect at the same time and they can't allocate some to the queue or something like that.

midnight talon
midnight talon
#

would be sick if BI gave us generic types in scriptland so we could have some type safety on stuff like container keys/values

pliant ingot
red cedar
pliant ingot
red cedar
#

Hey sorry to bother you but have you figured out what was causing the error 422. I'm running into the same problem

pliant ingot
#

And prefer to get this in BaseContainerCustomTitle of this element, because I need to show index of element in front, because it's important and users can be too stupid to find this info in tooltip

woeful vigil
red cedar
#

Yeah that's also what's making me lose my mind..

craggy jolt
#

Am I right to assume that FactionManager factions list is hardcoded? There are only proto getters and the editable list in world editor is not referenced in the scripts.

ocean kernel
#

There was a get faction by ID so just iterate until you get null lmao

torn bane
torn bane
# woeful vigil hello, nop, i didn't solve the problem, docummentation on REST is kinda non exis...

Maybe I can help, yes the base context url is combined with the individual calls. Uncommon design, I agree, but it was desinged so you make a context per endpoint and then do rest actions which should usually only mention the resource name and or action and not the whole URL again. post, put, delete work mostly the same as get, but there are inconsistencies in the default headers and body set. some are form encoded by default, some are just text, some give accept user header, some not. We have already a plan internally to remove all those inconsistencies and do a quality of life update to the API, but it is awaiting implementation, so it is not coming within the next 1 or 2 major updates probably.

The _now variants are all just giga bugged, do not use them. It is bad design to hard freeze the server until a response anway. Only perhaps valid usecase is blocking actions during startup or shutdown, but for those we will try to offer callback friendly ways to tell the game to stop until you had time to do something.

The callback variants do all 4 work.

dark ocean
torn bane
#

If my memory serves me right it should not be an issue. They are already known to client and server because of the shared map, so not much sync happening. We also have 4 factions configured usually but often only use 2

woeful vigil
#

how can i do a nested json like this:

SCR_JsonSaveContext jsonPosition = new SCR_JsonSaveContext();
jsonPosition.WriteValue("x", playerPosition[0]);
jsonPosition.WriteValue("y", playerPosition[1]);
jsonPosition.WriteValue("z", playerPosition[2]);
        
SCR_JsonSaveContext jsonPlayer = new SCR_JsonSaveContext();
jsonPlayer.WriteValue("player_name", playerName);
jsonPlayer.WriteValue("position", jsonPosition);
string s_jsonPlayer = jsonPlayer.ExportToString();
#

this is not working: SCRIPT : [JRDX] POST http://127.0.0.1:8000/players/552cd222-9ecd-45ff-8363-b3900ab4f74c -> {"player_name":"JasonREDUX"}

torn bane
# woeful vigil how can i do a nested json like this: ```cpp SCR_JsonSaveContext jsonPosition = ...

It is even easier than this code. The save context supports nearly all possible ways of scripted classes, including array, set, map and other complex members. only needs manual handling when you reference other instances on your members so you do not do recursive writes etc. Just pass your own struct instance to the serializer and it will handle it. Also for position you can just send the vector directly, no need to manually pick it apart into x, y, z

woeful vigil
#
{
  "player_name": "string",
  "position": {
    "x": 0,
    "y": 0,
    "z": 0
  }
}
#

so i need to compose the payload to fit

#

i know it is easier to save the raw position and done, but that's not fun :p

#

you mean something like:

JRDX_PositionStruct pos = new JRDX_PositionStruct();
        pos.x = playerPosition[0];
        pos.y = playerPosition[1];
        pos.z = playerPosition[2];
        
        JRDX_PlayerPayloadStruct payload = new JRDX_PlayerPayloadStruct();
        payload.player_name = playerName;
        payload.position = pos;
torn bane
# woeful vigil you mean something like: ```cpp JRDX_PositionStruct pos = new JRDX_PositionStruc...
class DataStruct
{
  string playerName;
  vector position;
}

would be ideal. Trust me you will not want to store it as xyz named keys, it adds a lot of overhead. [cord, cord, cord] is perfectly fine to parse by your backend application.

If you refuse to listen, then

class NonGoodVecotor { float x, y, z; }
class DataStruct
{
  string playerName;
  ref NonGoodVecotor position;
}

Either way you can just do context.WriteValue("", dataStructInstance) to write it nicely as root object. Rest is auto handled.

woeful vigil
torn bane
#

I just gave you the line ...

DataStruct struct();
struct.playerName = "Jason";
struct.position = "1 2 3";

auto context = new SCR_JsonSaveContext();
context.WriteValue("", struct);
string playerJson = context.ExportToString();
#

Which you can then send off to your rest api or what ever

woeful vigil
#

kk, let's test, thx

#
class JRDX_PlayerSyncComponentClass : ScriptComponentClass {}

class JRDX_PlayerPayloadStruct
{
    string player_name;
    vector position;
}

// Component responsible for syncing local player data to an external REST API
class JRDX_PlayerSyncComponent : ScriptComponent
{
    protected float m_TimeAccumulated = 0;               // Tracks time between syncs
    protected float m_Interval = 10.0;                   // Sync interval in seconds
    protected ref JRDX_PositionSyncCallback m_Callback;  // Callback handler for REST response

    override void OnPostInit(IEntity owner)
    {
        // Enable OnFrame() execution every frame
        SetEventMask(owner, EntityEvent.FRAME);

        // Initialize the REST callback handler
        m_Callback = new JRDX_PositionSyncCallback();
    }

    override void EOnFrame(IEntity owner, float timeSlice)
    {
        // Accumulate time and wait until interval is reached
        m_TimeAccumulated += timeSlice;
        if (m_TimeAccumulated < m_Interval)
            return;

        // Reset timer
        m_TimeAccumulated = 0;

        // Get the local player controller
        PlayerController playerController = GetGame().GetPlayerController(); 
        if (!playerController)
            return;

        // Get player's internal numeric ID
        int playerId = playerController.GetPlayerId();

        // Get player's display name (from PlayerManager)
        string playerName = GetGame().GetPlayerManager().GetPlayerName(playerId);

        // Get globally unique player identity ID from backend (e.g., Steam ID)
        string playerUid = GetGame().GetBackendApi().GetPlayerIdentityId(playerId);

        // Get the currently controlled entity (i.e., the player's avatar)
        IEntity player = SCR_PlayerController.GetLocalControlledEntity();
        if (!player)
            return;

        // Get the player's current world position
        vector playerPosition = player.GetOrigin();

        // Build data        
        JRDX_PlayerPayloadStruct playerPayloadStruct = new JRDX_PlayerPayloadStruct();
        playerPayloadStruct.player_name = playerName;
        playerPayloadStruct.position = playerPosition;
        
        // Serialize to JSON
        auto playerPayloadJson = new SCR_JsonSaveContext();
        playerPayloadJson.WriteValue("", playerPayloadStruct);
        string payload = playerPayloadJson.ExportToString();

        // Configure the REST request
        string contextURL = "http://127.0.0.1:8000";
        RestContext context = GetGame().GetRestApi().GetContext(contextURL);

        // Send the HTTP POST request to the REST API
        string endpoint = string.Format("/players/%1", playerUid);
        context.POST(m_Callback, endpoint, payload);

        // Debug output
        PrintFormat("[JRDX] POST %1%2 -> %3", contextURL, endpoint, payload);
    }
}

// REST callback for handling API responses
class JRDX_PositionSyncCallback : RestCallback
{
    override void OnSuccess(string data, int dataSize)
    {
        PrintFormat("[JRDX] Sync success: %1", data);
    }

    override void OnError(int errorCode)
    {
        PrintFormat("[JRDX] Sync failed. Code: %1", errorCode);
    }

    override void OnTimeout()
    {
        Print("[JRDX] Sync timeout");
    }
}

SCRIPT       : [JRDX] POST http://127.0.0.1:8000/players/552cd222-9ecd-45ff-8363-b3900ab4f74c -> {"player_name":"JasonREDUX","position":[3109.841796875,16.0,2751.820068359375]}
SCRIPT       : [JRDX] Sync failed. Code: 16
WARNING: Unsupported upgrade request.


INFO: 172.18.0.1:56028 - "POST /players/552cd222-9ecd-45ff-8363-b3900ab4f74c HTTP/1.1" 422 Unprocessable Content
#

🤷

#

idk, can't make it work

#

it may be because of the content type? http/1.1? api is waiting for application/json

torn bane
#

Well for starters use a website like webhook.site to see what you even get before directly tring to interface it with your webapp

woeful vigil
#
WARNING: Unsupported upgrade request.


2025-05-13 12:14:22.048 | WARNING | api.player.router:debug_webhook:37 - [DEBUG] Failed to parse JSON: Expecting value: line 1 column 1 (char 0)


2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:40 - 🔎 Incoming request debug:


2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:41 - Method: POST


2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:42 - URL: http://127.0.0.1:8000/players/552cd222-9ecd-45ff-8363-b3900ab4f74c/debug⁠


2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:43 - Path: /players/552cd222-9ecd-45ff-8363-b3900ab4f74c/debug


2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:44 - Query params: {}


2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:45 - Headers: {'host': '127.0.0.1:8000', 'accept': '*/*', 'connection': 'Upgrade, HTTP2-Settings', 'upgrade': 'h2c', 'http2-settings': 'AAMAAABkAAQAoAAAAAIAAAAA', 'user-agent': 'Workbench/1.3.0.170 (Workbench; Windows)', 'content-length': '95', 'content-type': 'application/x-www-form-urlencoded'}


INFO: 172.18.0.1:47302 - "POST /players/552cd222-9ecd-45ff-8363-b3900ab4f74c/debug HTTP/1.1" 200 OK


2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:46 - Content-Type: application/x-www-form-urlencoded


2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:47 - Raw body:




2025-05-13 12:14:22.048 | DEBUG | api.player.router:debug_webhook:48 - Parsed JSON (if valid): None
#

application/x-www-form-urlencoded
body: empty

#

@red cedar maybe this will help you, i give out until this gets modern

midnight talon
#

well that feedback is more specifically asking for the hardcoded US/USSR slots in Conflict to be replaced with dynamic references to faction manager, but I also didn't realise faction manager itself wasn't scriptable when I wrote it. Lemme update that 🙂

midnight talon
#

why tf is anyone using HTTP 1.1 in 2025 is the real question HTTP2 has been standard for a decade now

woeful vigil
midnight talon
#

why wouldn't you? makes no sense

hushed swan
vernal moat
pliant ingot
#

Also mb this requires to use diag exe, not sure if retail exe can provide this info

woeful vigil
woeful vigil
pliant ingot
#

So, it is very hard task

coarse pasture
woeful vigil
hushed swan
coarse pasture
#

Biggest headache was yes, the headers have to be in csv format:
headersCsv = string.Format("Content-Type,application/json,X-Auth-Token,%1", secretKey)

pliant ingot
coarse pasture
# woeful vigil this is crazy xD

Yea...I think its in the documentation but if you look up "API" here in discord you'll see everyone eventually learns that you have to deal with this headache

woeful vigil
coarse pasture
#

I still hope to build this out at some point more completely and this was all just playing around with it. So if you make any notable progress please share 🙂

        RestApi restApi = GetGame().GetRestApi(); if (!restApi) { Print("GeoTrakMod ERROR: Update - RestApi null!"); return; }
        string targetUrl = GEO_TRAK_TARGET_URL; string secretKey = GEO_TRAK_SECRET_KEY;
        RestContext context = restApi.GetContext(targetUrl); if (!context) { Print("GeoTrakMod ERROR: Update - Failed RestContext!"); return; }
        string headersCsv; if (!secretKey.IsEmpty()) { headersCsv = string.Format("Content-Type,application/json,X-Auth-Token,%1", secretKey); } else { headersCsv = "Content-Type,application/json"; }
        context.SetHeaders(headersCsv);
        GeoTrakRestCallbackHandler cb = new GeoTrakRestCallbackHandler(targetUrl);
        context.POST(cb, "", jsonContent);```
woeful vigil
#

also, documented where?

#

context.SetHeaders(headersCsv); ok, thx, will test

hushed swan
coarse pasture
# woeful vigil also, documented where?

Finding anything in the documentation is a chore, but I think its out there. Otherwise I found this solution by spelunking in this discord. This is the only way I was able to get anything API working

pliant ingot
woeful vigil
# coarse pasture

great, i guess with this way to set the headers will be enough, i read sometime ago that if u touch headers u have to set everything in headers, let's see

hushed swan
red cedar
#

@woeful vigil to fix it i had to
Host apache on my VPS
apache would then receive the request override the content type header and send it over to my fast api...

it was a pain but it works now

woeful vigil
red cedar
#

yes

woeful vigil
#

so you also using HTTP 1.1

red cedar
woeful vigil
#

kinda boring stuff, forcing us to use http 2 for no reason

#

i tricked it, using traefik with autosigned certs and installing the cert in the Windows as a root cert, but the app is still http 1.1 running with uvicorn

#

so exaggerated effort to make work a simple POST request, Bohemia never changes, SQF 2.0

ocean kernel
#

Holy smokes that's such jank

#

Could just use sanic as the web server pepedumb

woeful vigil
ocean kernel
#

It supports http2 by default

woeful vigil
#

but this is not the problem, is making certificates and a stuff to make work a single http request

#

forced to do that

ocean kernel
#

Ah because it only does https?

woeful vigil
#

yes

ocean kernel
#

So... cloudflare?

woeful vigil
#

or atleast i made it work with https but not with http

#

dude, it's a local dev environment, testing stuff to learn

#

why would i go to cloudflare?

ocean kernel
#

Ah that makes sense, surprised it doesnt do http to be honest

#

Seems a bit sus

woeful vigil
#

or i'm missing info or this is making things harder for no reason

#

could be both even 😄

vernal moat
#

yeah https is not the issue i worked locally with http with dotnet and nginx

woeful vigil
#

doing a POST request?

#

🤔

vernal moat
#

ye

woeful vigil
#

omg, so wth

vernal moat
#

i dont change headers tho

woeful vigil
#

but u accepted the content type reforger is using by default so

coarse pasture
#

I mean I sent a video of it using HTTP2 locally

woeful vigil
vernal moat
#

ye probably more http version issue than ssl

ocean kernel
#

it uses 1.1 and no ssl

vernal moat
#

Request finished HTTP/1.0 POST http://dpl.docker/publish application/x-www-form-urlencoded 442 - 200 - text/plain;+charset=utf-8 1.1830ms
uh lol

#

ha nvm this one is behind proxy

woeful vigil
#

yep, this is how i have it now, traefik using http 2 + ssl, but FastAPI with uvicorn running http 1.1

red cedar
#

As long as i’m not sending data in the body it’s fine… it’s only when i do that it gets fucked up

#

I’ve tried overriding the headers to no avail unfortunately

red cedar
#

oh

#

so... it really is the header that' s simply not correct.
Yet i don't see why apache isn't managing to override the Content-Type header

#

This is the proper postman equivalent(disabled some headers to make it as close as possible)```
POST /validate_server HTTP/1.1
Host: bleh.requestcatcher.com
Content-Length: 50
Content-Type: application/json
Postman-Token: e8886ae3-85f4-4492-8625-31c74abde173

{"token" : "21075082-3a63-4ddc-9357-d73e77c9a8c2"}

#

GOT IT

coarse pasture
red cedar
#

@woeful vigil i have not followed up with the convo but yeah so on my VPS i'm overriding the request header to application/json.

to do that my apache listen for https connection, strip some of the headers then redirect it to the API

#    </IfModule>
<IfModule mod_headers.c>
    Header always set Content-Type "application/json"
    RequestHeader set Content-Type "application/json"
    RequestHeader edit Connection "(^|,\s*)HTTP2-Settings\s*(,|$)" ""
    RequestHeader unset Upgrade
    RequestHeader unset HTTP2-Settings
</IfModule>

The down side is that now all API call will have to be done in json, the upside is that i don't care

tepid heart
#

How can I enable this render in the game world, not in World Editor?

quiet drift
#

Hello, I would appreciate the help of someone who is comfortable enough with enfusion scripting and could check my script to make sure it is optimized and solid, It seems to work perfectly but I am not a coder so it would be good to do a check by someone who is a coder. I had it done by chat-gpt following the corresponding scripts examples available in tools. I don't know if this question is inappropriate, if it is, my apologies.

#

I'm not asking to send it back to me with corrections, just if you spot something that doesn't make sense, please let me know.

quiet drift
pliant ingot
teal vapor
midnight talon
quiet drift
#

That wasn't tested on full pvp server and the mod is used like this by the community, I would like to know if there is something wrong before updating the mod that's it. since i kniw almost nothing about scripting.

quiet drift
#

At least to make it work, but I still don't know if it will cause problem

midnight talon
foggy swift
midnight talon
quiet drift
midnight talon
#

When you run PeerTool in WB it runs a dedicated server in the background and launches a game client to connect to it

#

So it should be testing the full dedicated server + MP client setup

quiet drift
#

but don't know how to write

quiet drift
midnight talon
#

You can even set it up to launch multiple PeerTool clients so you can simulate multiple players connected to your server at once, great for debugging RPL/networking issues

foggy swift
# quiet drift but don't know how to write

if you have api specific questions/a method doesn't exist that it's giving you, you're better off searching for it in the script editor... wiki is also helpful but can be outdated on a decent amount of stuff

quiet drift
#

Just searching everywhere in the components that are exposed in loitering and swim script and some other too

midnight talon
#

Yeah that's the way, documentation is pretty minimal atm so Ctrl+Shift+F is your best friend learning tool

quiet drift
#

I did looked at the wiki just for modded class thing but I'll read the rest, just hard to be motivated to read all that

foggy swift
#

If it breaks in the future, which it probably will, that's normal. Reforger is basically testing grounds for BI. Things are expected to change a lot.

quiet drift
#

Ah damn ok !

#

Hope not too soon lol

midnight talon
#

If what you have works as expected then it sounds like you have a solid foundation for your mod, by going through the logic and reasoning about it you should start to build a bit of an understanding of how it all works until eventually you understand enough to feel comfortable writing your own code from scratch too w/o relying on LLMs

quiet drift
#

I don't think I'm that smart haha but yeah I'll probably learn more

#

Animation is my thing

foggy swift
#

you'll notice it's quite easy to learn, it's just a lot of reading and educating yourself. you will learn something new every day. all of us do.

midnight talon
quiet drift
#

Thanks for the tips guy's!

timid tree
#

is it possible to replicate maps with RplProp()?

serene fox
#

Good morning, are there any known issue with RestAPI - GET and GET_now? i tryed both but can not receive any data.

river imp
torn bane
pliant ingot
#

notnull have any disadvantages in use? (for example, in performance)

#

Some scripts have comments like:

//! \param component must not be null

Instead of just writing notnull in definition...

tepid heart
pliant ingot
# tepid heart I'm more about what is already built into the components, but for some reason it...

is not shown if you run a mission
because it's written to draw only in WB. Looks like you need to mod to do that:

modded class SCR_ResourceComponent {
    override void OnPostInit(IEntity owner) {
        super.OnPostInit(owner);
        SetEventMask(owner, EntityEvent.FRAME);
    };
    override void EOnFrame(IEntity owner, float timeSlice) {
        super.EOnFrame(owner, timeSlice);
        if (m_bEnableDebugVisualization)
            DebugDraw();
    };
};
primal iron
#

Hello, I'd like to create and modify cities, for example, set them as capture points or move them around the map. However, my game must remain vanilla, and the only modification option I have is in the config.json file, so I'd like to create this line, but I can't do it.
I really need someone to help me, please.

midnight talon
primal iron
#

Modding the map ?

#

Can't we just write a line of code?

coarse pasture
primal iron
coarse pasture
serene fox
coarse pasture
midnight talon
#

Wait, there's documentation? huh

woeful vigil
#

👀

#

REST_API_Usage conjecture

midnight talon
#

Dang and here I was thinking we were all just flinging shit at the wall to see what sticks

foggy swift
#

my bet's on the mashed potatoes

minor agate
#

People not using it, and doing an if check later on is probably due to lack of forethought on the lifecycle of the instance and tried to band aid it without refactoring.

ocean kernel
#

I do a null check because I want to print some message instead of a stack trace

#

Which might tell the end user what to do to fix it

pliant ingot
#

Is there any function like Lua's pcall? (If any non-critical error occurs in the called code, the calling code is simply notified of the error and continue to execute)

prime quarry
#

In Reforger is there a way to see when a player joins?

#

I need to call a function on join and trying to located where it might be. Like I guess on spawn or even the continue menu when they press the continue button.

pliant ingot
#

BaseGameMode.OnPlayerConnected

prime quarry
pliant ingot
prime quarry
midnight talon
minor agate
midnight talon
#

If so then it's not really a good substitute

minor agate
midnight talon
#

Ok well then it's not sufficient for my use case

minor agate
midnight talon
# minor agate What is the use case then?

I want to allow "unsetting" a property typed as ResourceName, currently I have to check if it is an empty string which feels wrong. If the prefab is "unset" in workbench then the value should be null not an empty string

minor agate
#

Which default is empty

#

Use a custon object then

#

Its like wanting int to be null if not set

#

They are not objects

midnight talon
#

Specifically this check comes immediately before a call to IsValid which handles the error case of prefab not being found, but I want to intentionally allow unsetting the vale with some specific behaviour in that case

midnight talon
minor agate
#

Its not

#

It is not based on. C#

midnight talon
#

There is a semantic difference between null and a falsy value

minor agate
#

Also

#

It is enforce script. Not enscript 😅

minor agate
#

They are for exposing variables to configs

#

Design is that these values should always have the default from scripts

#

Or the def from the attribute declaration

#

They are always set in one way or another

#

If not defined in config, then they take the default value

#

There is no concept of unset value on them

midnight talon
#

I guess it's the fact that prefab attributes default to an empty string rather than null which I found jarring then

#

I just wanted to add some logic to handle when a prefab attribute is "unset" in workbench and comparing against an empty string felt icky

minor agate
#

If you get it from the script instancd created by it then ypu get the instance from said data

midnight talon
sweet badger
#

Is this accurate / the full story? I did a quick test, and it seems to init entities from the "default" layer first.

tepid heart
#

Or maybe there is a test mission where we could understand how the supply system works?

azure tree
#

Does someone know how to determine where these errors are coming from? I believe this error is preventing me from testing my mod currently. The error is in the base files, so I get it even when I only launch the Reforger addon

#

Because a search on m_sCommandDisplayText yields 0 results in the code

#

is there some way to determine how to find that offset?

sleek dove
#

unfortunately, it will not give you from which mod if it is overriden by some mods

azure tree
#

It's just the base addon that I have loaded atm

#

and I can't open it in notepad, as it's a base game file, so I can't navigate to the folder

pliant ingot
#

how to check if GenericEntity is active? ScriptComponent has IsActive but there is no equivalent for GenericEntity

azure tree
#

Why would you need to check that? What are you trying to accomplish?

pliant ingot
#

and it's strange thing - you can deactivate and activate entities and components, but you can check its state only for components

azure tree
#

Well if you deactivate an entity, you most likely can't check if it's enabled or disabled anymore, as the disabling makes it inaccessible maybe?

pliant ingot
#

you can activate it again

#

there are EOnActivate and EOnDeactivate events for this

#

Of course I can make my own "enable" methods and flags, but why when it's already exist in engine?

#

And ACTIVE flag on entity doesn't change when you Activate/Deactivate it (and based on comments it's used for different thing)

azure tree
#

Hmmm. then I don't think I can help you any further on this 😦 Sorry man

river imp
midnight talon
hushed swan
#

Does anyone have an alternative mod for the V30 Voting Map, as we don't have a mod for map rotation today?

#

V30 Voting Map is still giving JIP error with 100+ players 😦

coarse pasture
#

I don’t think that you can actually do a mod like that until BI fixes the underlying issue. At least not a mod to move players into the new map/scenario.

hushed swan
#

in my vision

coarse pasture
#

You can always do console log trailing to do that. You’d still need something to print out the next scenario

hushed swan
#

looks good, right?

river imp
#

You just can't do it on a per player basis.

coarse pasture
river imp
#

Not sure why we're talking about it in a scripting channel if you're not wanting a scripted solution.

coarse pasture
#

It was discussion about a mod replacemement and yes the inconsistencies with how servers are shutting down/starting up post game do relate to scripting

river imp
#

I'd say if that functionality is engine side and not script side, then it isn't script related. lol

coarse pasture
#

Again, the inconsistencies with how servers shut down post-game (even with the new startup parameters) can impact scripting. This was mod was pretty useful and can't be used consistently now

river imp
#

It can't be used because of engine side functionality, not scripted functionality meaning it has nothing to do with scripting. Impact scripting != scripting related. lol

slow acorn
#

engine is made by scripts?

#

Why we trying to police this channel

river imp
#

Engine side can't be touched by scripts. Still meaning it has nothing to do with scripting.

#

No one is trying to police anything. I stated a simple fact. Not sure why it's being discussed in the scripting channel if it has nothing to do with scripting.

slow acorn
#

Everything discussed is indeed scripting

slow acorn
coarse pasture
smoky pawn
midnight talon
#

Also if you're trying to "vibe code" using an LLM to generate Enforce Script for you, you're gonna have a bad time. If you want to do any scripting in Enfusion you're gonna have to learn how to write code yourself

pliant ingot
river imp
#

?*

minor agate
#

(Some updates to it made it unusable)

river imp
#

Mario, is there no way to determine if a GenericEntity is "Activated"?

pliant ingot
river imp
#

Yea, which is not optimal.

#

But I think that's all we have unfortunately.

minor agate
river imp
#

@pliant ingot ^^

#

Thanks @minor agate

pliant ingot
minor agate
#

It's just depending on what

#

Otyher things might also deactivate or activate the ent

#

Remember that your mod is not isolated, other things might be managing the instance you are messing with

#

Physics itself might activate it too

#

@pliant ingot On what entity are you using it?

pliant ingot
minor agate
#

Components on it might cause side effects that activate or deactivate it

#

Things in game logic itself might as well

#

It's not if it's just GenericEntity or not

#

Also, what is the idea for checking this?

#

It might be that the design is wrong to begin with (Like, misusing the Active flag)

#

It's not a flag to express that an entity is to not be touched or disabled or whatever

#

It's a flag that controls if the entity is actively ticked by the engine update loop

#

Which is why you should also not abuse it for (Some hackaround for "telling an entity is to be disabled or enabled"), as you would cause it to be processed without need, lowering available resources without need, not to mention possibly causing unintended issues.
Very rarely you need to mess with Active flag unless you are doing something very low level .

craggy jolt
#

Can resource/supply system sluggishness (having to wait 10/20/more seconds before interactions are possible on live Conflict servers) be solved by simply say doubling frame update budgets? Or is this already solved well in some mod and I'm just wasting my time trying to take a dive into it?

#

(Dropping this question since Mario is here)

minor agate
#

If so, that is by design (I also do not like it)

#

Supposedly to make people not abuse the action

craggy jolt
pliant ingot
minor agate
#

Do ClearFlags(...)

minor agate
craggy jolt
pliant ingot
minor agate
#

This was added outside of what I did.

#

I will ask.

#

It was probably to avoid people abusing it (What is called as supplies barbies)

craggy jolt
minor agate
#

It's on supplies side, so not resources. Meaning the update budgets have nothing to do

#

I thought you were talking about some processing lag of sorts

#

(Might be that too tbh)

#

As the budgets are there due to them being physical entities and quite complex

craggy jolt
#

Sorry for the wrong terms, meant resources as in SCR_ResourceSystem and SCR_ResourceComponent, so supply system

minor agate
#

The bigger the server pop and their behavior, the different those budgets have to be

#

So it could also be that if you differ a lot from our vanilla servers

#

What is your server setup in terms of player and gameplay with supplies?

craggy jolt
minor agate
#

(Like a lot of compositions being built, a lot of dropped supplies, etc)

pliant ingot
craggy jolt
minor agate
#

Ok, so it's past our numbers tailored to our normal sizes

#

Mmm

#

sec

minor agate
#

It will come at cost of server FPS but that is hard to predict. Higher values might just work fine for you

#

Also

#

For replication, if you want to increase how often things get replicated

#

Go to SCR_ResourceSystemSubscriptionManager

#

Then increase the REPLICATION_MAX_FRAME_BUDGET const

#

I would say, try maybe twice per each

craggy jolt
#

Got it, wanted to try playing around with these values too, gonna try to reproduce this delay first somehow to see if these values fix/make it worse.

minor agate
#

There is a better handling of all this already implemented by me, but it has not made it's way into stable yet

minor agate
#

That is fixed there, I can tell you how to fix it if you need it ASAP

#

(It can be fixed in a normal modded class mod)

craggy jolt
#

Please do, could be useful to others who have features that rely on supply system as well

#

(No rush for ASAP though)

#

up to you

ocean kernel
#

I get a lot of complaints about slowness with supply system

minor agate
#

It deteriorates the whole thing over time, the more that people use it, the worse it gets

#

The reason is quite stupid as well (on me tho)

ocean kernel
#

It usually is man

midnight talon
#

Not exactly scripting specific but thought I'd ask since Mario is around and we're on the topic of Supply:

I have an issue with this SCR_ResourceComponent on a deployable radio backpack, it can access supply from nearby vehicles just fine initially, but if you place the backpack inside a vehicle's cargo it permanently breaks then can only access supplies by dumping them out of the vehicle into pallets on the ground.
I kind of threw the kitchen sink at it just trying to get it half-working and have avoided debugging this issue until now because it was already a pain and I still don't really understand how supplies work so it's probably just some config issue that will be obvious to someone else. Anyone experienced supply system got any ideas what I've done wrong?

#

(I have free build mode enabled for this prefab, so want players to be able to access nearby supply with it to use for building)

minor agate
#

I ask, as that would make it to get encapsulated by default by the vehicle's encapsulator

#

Making it so that it is managed by the vehicle then

#

Also

#

MilitaryBase consumer is for bases

#

Use the normal consumer

#

You will get "weird" behavior with the one you have

#

(As things might suddenly connect to it think it's a base. then other bases might merge with it)

#

If you want your radio to be stand alone

#

Then normal consumer and generator

midnight talon
#

Ah ok I incorrectly assumed there had to be a 1:1 setup of containers and consumers, so in this instance where the prefab doesn't store any supplies itself I should have no containers added?

minor agate
#

If you want it to connect to bases and use a base's shared supply if available

#

Then use the ServicePoint one

#

If you want it to behave like bases (Pool of supplies and comms with other pools) then use the MilitaryBase one

#

It seems you wanted either normal one or servicepoint one

midnight talon
#

Ah yep I think I used the building service prefab as an example which is probably why it's using the militarybase consumer, will give the regular one a try, cheers mate 👍

ocean kernel
#

How do I specify an optional value for SCR_JsonLoadContext? Or a default value if a field is missing?

#

If a key is missing it just fails reading the whole class

spark otter
#

I usually do something like: ```c
class ConfigStruct
{
string version;

void BuildDefaultConfig()
{
    version = "1.1";
}

}

ConfigStruct m_jConfig = new ConfigStruct();
m_jConfig.BuildDefaultConfig();
and assign default values on file creation, or maybe you can justc
SCR_JsonLoadContext configLoadContainer = new SCR_JsonLoadContext();
if (!configLoadContainer.ReadValue("version", m_jConfig.version))
m_jConfig.version = "1.1";

torn bane
pliant ingot
#

It is possible to check by script if entity has or not Hierarchy component? Because it's essential for one of my entity I want to add debug check in script

spark otter
#

I would just try FindComponent(Hierarchy)

#

on something you know that has it

pliant ingot
woeful vigil
#

ok, back to the REST API stuff, i solved the problem(error 422)

FastAPI

normally we do use uvicorn with FastAPI, but the Reforger REST API requires HTTP2 or h2 connection(i'm not expert on that, don't khow what the hell is h2c or h2) and uvicorn does not support that.

here is the header sent from reforger to the api:

{
  'host': 'localhost:8000',
  'accept': '*/*',
  'connection': 'Upgrade,HTTP2-Settings',
  'upgrade': 'h2c',
  'http2-settings': 'AAMAAABkAAQAoAAAAAIAAAAA',
  'content-type': 'application/json',
  'content-length': '92'
}

Then what i did is switch from uvicorn to hypercorn, ofc, normally http2 requires certificates but since we only need that the connection is type h2/h2c here is a trick:

# hypercorn.toml
bind = ["0.0.0.0:8000"]
insecure_bind = ["0.0.0.0:8000"]
h2 = true
loglevel = "debug"

then run the app like this:

hypercorn main:app -c hypercorn.toml

and it is finally fixed

sending the content as JSON from reforger works just fine, just modify the headers

// configure Headers
string headersCsv = string.Format("Content-Type,application/json");
context.SetHeaders(headersCsv);

mentioning ppl who was involved or curious about --
@coarse pasture @red cedar @vernal moat @ocean kernel @serene fox

pliant ingot
ocean kernel
#

I just use sanic without non-http (cgi, wsgi, whatever) nonsense and dont have this kind of issue

woeful vigil
#

but u using certificates and stuff? https?

vernal moat
pliant ingot
vernal moat
pliant ingot
vernal moat
#

ha add getsibling check maybe ?

pliant ingot
#

so looks like I need to force all these entites to be inherited from specific prefab and check this...

pliant ingot
vernal moat
#

afaik

pliant ingot
#

then force inheritance from specific prefab...

#

and believe that very "not intellectual" users of this will not disable/override it...

ocean kernel
#

How do I make input manager consume action and not pass it to lower priority contexts?

#

Setting Exclusive doesnt do anything

#

This doesnt do anything

minor agate
#

Its practically irrelevant outside of that

coarse pasture
woeful vigil
#

also, forced to use a certificate, which i think is overkill for a dev environment, could be good for production

ocean kernel
#

HTTP to HTTP is a bit more sane to me than HTTP to 1985 CGI

#

Sanic being a web server can do ssl out of the box but we're getting a bit offtopic here

midnight talon
#

Also you can get a free SSL certificate from let's encrypt, it's not a huge deal

woeful vigil
#

dude, but why in the hell would u use a certificate in a local dev environment?

ocean kernel
#

That too, I wouldnt

woeful vigil
midnight talon
#

Idk if the enfusion REST API requires them to be signed by a cert authority, if not then you can even just generate your own on the fly as part of your dev server startup

woeful vigil
#

not, is not required, just required to have h2 connection protocol

minor agate
#

Please make this a thread instead or stop it. Topic can develop a lot and clutter the channel

woeful vigil
#

you can have also self signed certs, not a problem at all, but i found a way to avoid certs, much better for my pov

ocean kernel
#

http2 is not required for the restapi calls in script

elder wigeon
#

Hey guys! Does anyone know how to set a vehicle spawn timeout for the whole team? I.e. no matter who spawned a jeep, whole team will wait to spawn for another one?

ocean kernel
#

Script a counter and track it in spawner

#

Or timer idk

elder wigeon
static vale
torn bane
static vale
torn bane
#

The diag shapes (like the line you see) can also only be done in diag. if you wanted something comparable in vanilla it would need to be done with a lot of hacks and would likely not perform well. Just don't.

static vale
hushed swan
pliant ingot
hushed swan
#

Does anyone know if I can insert a sound on the loading screen?

#

I can now change it on the pause screen, but loading screen no

austere crown
#

helloo doo yoo have anie solution for this

static vale
austere crown
#

doncwhat is need change

austere crown
midnight talon
#

That code is completely nonsense LLM slop, if you wanna write mod scripts you're gonna have to learn to write code yourself

austere crown
minor agate
teal vapor
candid garnet
#

when can we have multiple screens for the script editor... I have 3 screens to use up...

hushed swan
#

I'm trying to create a script where some players (using the bohemian id) can open their respective arsenal boxes, these boxes are only opened by these players, does anyone know how I can do it?

midnight talon
midnight talon
teal vapor
#

Hoping to have a proof of concept script parser + LSP server to make editing in vscode match the experience of the workbench (minus debugging)

static vale
#

Is there any simple or built in ways to display debug info above an entity?

delicate crane
#

Is there any scripts out there for making items visible in pouches when they are in your inventory similar to rhs?

high hawk
upper fable
#

is there a way to force ragdoll on hit over script?

dire sinew
upper fable
#

just making sure it wont f eachother 😛

delicate crane
dire sinew
upper fable
dire sinew
#

Force ragdoll won't change that, as it behaves the same as uncon ragdoll. You would rather want to overhaul the ragdoll physics. I think there are already mods out there that do this.

upper fable
high hawk
#

I just toggle it on a button press

dire sinew
upper fable
upper fable
high hawk
#

If I was near a computer I would, currently away at work in the jungle haha

Could set up a on contact event or something from the players side 🤷🏻

upper fable
high hawk
upper fable
#

all good :P, can you dm the mod link to your ragdoll mod ?

dire sinew
upper fable
#

kinda started as a joke and then i made it lel

high hawk
upper fable
#

i somehow broke it 5 sec into testing it lel

high hawk
#

Yeah haha, I got annoyed while I was working on something else, so I decided to entertain myself

upper fable
#

im broken XD

high hawk
#

But if you are paralyzing people with a water cannon, it'd make for a good laugh

upper fable
#

if i find a fix for that ill let ya know 🙂

upper fable
high hawk
#

While I've been away, I've thought about adding a GM action so admins can abuse more powers coolfrog

upper fable
#

so ill have a look into that 🙂

high hawk
#

Appreciate it, hope it helps 😬

upper fable
coarse pasture
hushed swan
coarse pasture
#

Please stop

oblique lynx
#

Has anyone here had any experience with changing pip optic HDRs during play time? I am able to make the swap, but the reticle on the second HDR doesn't appear. I can make it appear if I set the priority higher, however this then causes the reticle to be duplicated

slow acorn
#
modded class SCR_EditBoxComponent 
{
    // This is to disable forced focusing on 1 edit box for PC players
    // It will affect all menus
    override void UpdateInteractionState(bool forceDisabled)
    {
        if(System.GetPlatform() == EPlatform.WINDOWS)
            return;
        
        super.UpdateInteractionState(forceDisabled);

    }
}
#

The way the text edit/input widget locks focus is terrible on PC. I quick fix if anyone needs it ^^

hushed swan
#

Can anyone help me? I made a script for an arsenal box that identifies the player's UID and enables opening if the UID matches, I see in the console that this logic is working, the only problem is that it is not opening the arsenal interface that used SCR_OpenStorageAction and it worked, despite my script extending it, for some reason it does not work.

#

If I can send the script and someone can analyze it, I believe it is just one line of code that should not follow the logic.

spark otter
#

does ```c
AIWaypointCycle.GetWaypoints();

sweet badger
spark otter
#

yeah it always seemed to pick a random waypoint to spawn the ai on, even when I chose waypoint[0] every time. I just had the idea to use the origin of the ambient patrol spawnpoint component though, should work much better.

#

now im wondering if waypoint[0] is the cycle waypoint, would make sense lol

candid garnet
#

if i'm making a custom class to use in my component (state pattern), and need to replicate it, what do i need that class to inherit from in order to have the replication ability without creating a component?

pliant ingot
midnight talon
#

Anyone familiar with container API know what esoteric incantation must I invoke to get the AreaType of a slot in BaseLoadoutManagerComponent?

slot.Get("AreaType", slotType);
slot.Get("Prefab", slotPrefab);

Gets the slot prefab fine but the type is always NULL

pliant ingot
candid garnet
midnight talon
#

Maybe I'll just have to create a map of slot name -> slot typename

#

I think AreaType should be the correct key for that attribute as it's what I got by copying name from the component in WB but it always returns null 😦

pliant ingot
pliant ingot
pliant ingot
midnight talon
candid garnet
#

how do you do type comparisons if you don't have access to Cast again?

#
// inside of my component:

void ChangeState(ACE_MedicalDefibrillation_DefibrillatorState_Base newState)
{
    if (/* same type as current state in m_DefibrillatorState */)
        return;

    // do other stuff
}

my custom state class does not inherit from any component or script class to get Cast

pliant ingot
#

So you can use Cast, Type and IsInherited methods

pliant ingot
midnight talon
midnight talon
#
typename slotType;
slot.Get("AreaType", slotType);

Is how I'm trying to read it

pliant ingot
#

You should read value first

#

And then call Type on it to get typename

midnight talon
#

read value of what? Isn't slot.Get meant to return the value of specified var?

pliant ingot
#

You try to read typename which isn't type of "AreaType"

#

It should be some sort of class

midnight talon
#

like I wanna dynamically get the class assigned to the current slot I'm processing, not a specific slot's class

pliant ingot
pliant ingot
#

Actually it may be some parent class, but current value is of this class

#

So your var should be of this class or any parent class to successfully get value

#

Just try to use Managed or Class for var type if you want just a typename from it - this should work

midnight talon
#

Your suggestion to use .Type() led me searching for how I can get that as I couldn't find anything I can get from the basecontainer with that method, found a jank work-around that is really not ideal but it does the job - I just said screw container API and spawned item of the currently processed slot to look up its slot as InventoryStorageSlot so I can just call .Type() on that directly then delete it again on conditions where I wanted to avoid inserting it originally

        IEntity item = GetGame().SpawnEntityPrefab(variantResource, GetGame().GetWorld(), itemParams);
        InventoryStorageSlot slot = storage.FindSuitableSlotForItem(item);
        
        // don't insert if slot would already be blocked e.g. armored vest with rig blocks rig vest slot
        if (!slot || storage.IsAreaBlocked(slot.Type()))
        {
            SCR_EntityHelper.DeleteEntityAndChildren(item);
            return;
        }

Thanks for the help Vlad, appreciate it! 🙂

pliant ingot
# midnight talon Your suggestion to use `.Type()` led me searching for how I can get that as I co...

blobdoggoshruggoogly getting type of var from container should be like this:

[BaseContainerProps()]
class MyBaseClass { ... };

[BaseContainerProps()]
class MyClass1 : MyBaseClass { ... };

[BaseContainerProps()]
class MyClass2 : MyBaseClass { ... };
...

class MyComponent : ScriptComponent {
    [Attribute()]
    ref MyBaseClass MyVar;
    
    ...
};

...

void SomeFunc(BaseContainer container) {
    MyBaseClass myVar;
    container.Get("MyVar", myVar);
    typename myVarType = myVar.Type();
    ... // myVarTyoe can be MyBaseClass, MyClass1 or MyClass2
};
midnight talon
pliant ingot
#

But for current value this will work

midnight talon
#

AAAAAH gotcha, so I need to type slotType as the base class all the classes used inherit from rather than typename which seemed to be casting it to null. This works perfectly, thanks Vlad!

ResourceName slotPrefab;
LoadoutAreaType slotType;
slot.Get("AreaType", slotType);
slot.Get("Prefab", slotPrefab);
#

now I can get rid of the unnecessary spawning and deleting of items that shouldn't be inserted in the first place 😄

indigo spruce
#

are there any good resources for learning enforce?

river imp
indigo spruce
#

and from what ive heard enforce syntax is very similar to c++ syntax

#

but i dont know any of the functions in the workbench for scripting

river imp
#

That's as good as it gets.

#

Just invest time in the tools. You'll learn the important functions as you experiment.

teal vapor
# indigo spruce are there any good resources for learning enforce?

https://www.youtube.com/watch?v=Fgl_mAHReP4&list=PLfUcrRpCM_fKjkTrkV-bqnknVbFCPA3YU

Watch videos 1, 2, 4, 5, 6, and 10. They cover a wide landscape of scripting topics.

https://reforger.armaplatform.com/news/modding-boot-camps-introduction

This Modding Boot Camp seminar was originally held on the Arma Discord Server on November 20th, 2024.

Join Modding Supervisor Mario Enríquez for our first Modding Boot Camp, where he gives a quick overview of the Arma Reforger Tools and Workbench.

00:00 - Modding Boot Cam...

▶ Play video
tough cave
#

is it possible to let AI walk out of a rock but not into one from the outside? so surface settings for obstacle-like or static map assets.

serene fox
tough cave
#

that could work at spawn time, I want to make sure they can get out if they get stuck despite tracing and other checks

tawny lotus
#

Wouldn't there be a risk that they would walk and end up inside the rock sometimes? Not sure if the rocks should be "fixed" or smth.

midnight talon
#

I assume BI will fix it eventually so any further effort for now seems overkill

narrow aspen
#

can we set static map marker to be visible to specific faction through script?

cunning wharf
#

Hi! I'm looking for Stack or Queue data structure implementation, do you know is there any of those implemented in Arma already?

#

I can't find such. Maybe you have an idea how regular array, set can be used to achieve the same behavior?

cunning wharf
lilac moss
#

hey guys, does anyone know how to setup a size (as in amount of items the vest/belt can hold)

#

currently working on gun slings based on RHS Weapon Holster system, but can not find that, what will allow me to store slot 1 guns in inventory

cunning wharf
#

Data structure like array, map
but with methods Push(...) Pop(...)
Algorithm fi-fo and fi-lo.

"fi => First In"
"lo => Last Out"

unborn summit
#

Hi folks this is a bit of an open question, am drifting into enfusion coding after 20 years of ofp/arma coding and am starting a long path of coop mission design template creation, which i want to create without any dependencies for addons My question is after creating the subworld what cannot be initialised, created with code that MUST be in the subworld.
For example I presume the AI navigation mesh must be created in the editor (or can it be loaded via code)?
Such things as Player role selection and loadouts, I know can be initialised and controlled by code, but may require a spawn point creating in the editor?
My end aim is to create a template for my community where the mission makers basically only need to edit some json config files, add ai and waypoints and maybe some triggers for win/lose conditions.
So

WHAT MUST be in the world that I cannot initialise/configure from code
Such as maybe some elements of the scenario framwork

TIA

toxic bear
cunning wharf
cunning wharf
#

Guys, any idea why is this happening?
Why in my broadcast method score = 1 ?
This is a GamemodeComponent

#

Here is log

#

interesting that string factionKey passes but int score doesn't...

#

Log is from Workbwnch

midnight talon
cunning wharf
#

Yeah! Thats funny... I forgot that RPC thing doesn't really checking types what you are consuming as this calls happens only in runtime and it is not possible to detect type inconsistency at a compile time...
My bad. Thank you for rapid answer brother. You are my god! 🔥

fringe prairie
#

Nvm, you are searching for slots, not items, my bad.

sleek crystal
#

Anyone able to help me with this issue?

abstract crescent
#

How can i handle swimming? I want change swimming parameter, but cant find where is it.

river imp
teal vapor
#

hoping that if I actually manage to successfully create a language parser maybe I can build a linter that catches these sorts of things

minor agate
teal vapor
#

if someone's already done most of the tree-sitter work I may as well use that though

minor agate
teal vapor
torn bane
#

I have a full grammar for ANTLR and one full implemented for C# Visitor Pattern. I can put it on GitHub later

ocean kernel
#

Is there something I can do to track server memory leaks better?

abstract crescent
ocean kernel
#

Mario

#

Is Supply system causing memory leak in Conflict?

#

I see Conflict servers always leaking

#

Even vanilla

#

Does that have anything to do with the slow supply system updates?

#

When it slows down over time

river imp
restive island
#

Is there an option in the Reforger scripting editor or Enfusion that tests to see if your mod will conflict with other mods?

coarse pasture
hollow gyro
#

has anyone got the script for dr*gs mod on arma reforger?

toxic bear
ocean kernel
#

Thanks but I want to know it in good enough detail to see WHAT is occupying the memory specifically

#

Like how much memory allocated by scripts, resource system, AI, etc

toxic bear
#

Either Enfusion Engine needs to provide something .. (something I am not aware of anyway) or you would need to add your own kind of debug mode inside your scripts .. which will only execute if in Workbench. (Or log everything in sections .. Memory, Cpu etc etc)

ocean kernel
#

Yeah I know

#

Was kinda hoping there is something

#

That I dont know about

coarse pasture
#

The supply system definitely fills up our logs with errors, so wouldn't be shocked if there's something going on there under the hood vanilla

#

We've been working on a script to print out null references on specific functions that seem to be a poblem

toxic bear
open pier
sleek crystal
#

so ive created a custom map and is ready to go besides not having a scenario id. Where can i add that?

river imp
restive island
sleek crystal
river imp
#

No worries.

teal vapor
#

you'd need to instrument the allocator based on runtime type info

minor agate
#

About vanilla, from what I know no mem leaks on that.

#

About modded, idk. Hard to say based on how modders mod things

#

Like for example

#

Someone using a call later on a strong reference, if the call later is not ended then the instance is kept alive

#

Even tho if the system wanted it gone

#

Which is why call laters should alway be avoided

#

It's not so much of an architecture issue only, but also memory usage and lifetime issue

#

Specially even if you pass a system on the arguments

#

Even for us, those leaks are super hard to figure out as the connection to things with call later is gone

#

Hard to debug even with visual studio debug

solid hearth
#

vs debug peepoPuke

minor agate
solid hearth
#

No I know, still puke.

minor agate
#

Just the attach to debug process thing

#

I personally prefer CLion

solid hearth
#

I have an unhealthy amount of debuggers but mostly for nefarious purposes.

hushed swan
#

I created a generic entity in the world and a class searches for it but ends up not finding it
IEntity vpManagerEntity = GetGame().GetWorld().FindEntityByName("VPManagerEntity");
if (!vpManagerEntity)
{
Print("[VPUtils] VPManagerEntity entity not found!");
return null;
}

For some reason I can't start this entity, I've done everything

minor agate
#

Named entities are for those that you have manually named like that in the world file, hence why you have the method in the world class

#

It's not for prefab name or anything like that

hushed swan
minor agate
#

Register the entity somewhere in script upon init of itself, or a component on it

hushed swan
#

can i basically register when i start gamemode?

minor agate
#

Then call SetName("VPManagerEntity"); on it

#

You could also do that

#

(It can be anywhere, just easier to do it on init of the entity or a component on it as you get it right away)

wooden cape
#

Has anyone had items from arsenals disappearing after moving farther than the networkviewdistance parameter?

We're spawning gear on entities when they initialize, but if they move past a the server networkviewdistance, the items disappear from the player inventory.

Likewise, we also noticed teleporting players long distance causes server fps to nearly crash.

It honestly seems like the rpl bubble isn't updating or the player controller isn't attaching to the entity somehow.

#

Gonna try to replicate in the dedi server tools with debug up, but it's honestly super odd.

tired brook
#

Did you fix this problem?

civic moon
#

"m_bCustomBaseWhitelist": true,

True should be 1 or 0 not true or false

civic moon
#

No problem!

ocean kernel
#

It will eventually run out of memory but (un)fortunately it crashes before that happens

#

Anyway I need to know how to find what is leaking memory on servers

#

Or at least how much memory is allocated by category

#

With scripts I would expect to see memory allocation by mod

minor agate
#

Could be anything

#

I know some memory optimizations have been done recently overall game wise. But that is not even on exp currently

ocean kernel
#

Does conflict clear memory on round end now? Assuming it doesnt freeze the whole server like it usually do

#

Also on an offtopic can you improve the speed of printing to log? If something is log spamming it's immediate frame drop

#

Or do something clever like group log messages

#

'My error (message repeated x15 times)'

solid hearth
#

How high is the memory usage? Curious.. One of the scheduled restarts missed and had an instance run for 24h at 15GB memory usage thenking

torn bane
#

Disable logs for better performance, same story as in any previous arma title. Log file writing is never for free. And no we will not add any accumulation

ocean kernel
#

It's fine usually, but sometimes there is huge log spam, even from vanilla

#

Disabling logs is not a solution because it increases risk of losing some valuable logs, even if most of them are garbage

late locust
#

Just print all logs in game chat hmmyes

tired brook
ocean kernel
#

You didnt do the thing the guy said to do lol

civic moon
#

It doesn't work for me. Maybe something else is needed?

"m_bCustomBaseWhitelist": 1,
"m_aCampaignCustomBaseList": [
    {
        "m_sBaseName": "TownBaseMontignac",
        "m_bIsControlPoint": true,
        "m_bCanBeHQ": false,
        "m_bDisableWhenUnusedAsHQ": false,
        "m_fRadioRange": -1
    }
]
ocean kernel
#

Is postframe not a thing on components attached to AI characters?

#

I have a component that does something in postframe on the character and it doesnt work when its controlled by AI

ocean kernel
#

Actually nvm it seems like it's for players as well in multiplayer, only works on the character of the local player

sleek dove
#

You have this specific method to create if you want to receive it on remote proxies, let me find it

#

OnTicksOnRemoteProxy

#

This is only for entities type inheriting from BaseGameEntity

#

And you do something like :
bool OnTicksOnRemoteProxy() { return true; }

timid citrus
#

Does anybody know what script to edit to make more of these?

teal vapor
timid citrus
hushed swan
#

What do I need to call to appear a notification on the hud for the player?

coarse pasture
hushed swan
coarse pasture
cunning wharf
#

Hi guys! I'm trying to implement a bullet hit animation, something like in battlefield, so the instigator has a feedback when bullet hits the target.
Is this right place to do so?
DamageEffectEvaluator

#

Actually I need to display hud on the center of the screen and play sound when bullet hits the target. This explanation is more accurate.

ocean kernel
hushed swan
coarse pasture
#

But yea its tricky lol

ocean kernel
#

Why isnt script component working tho

rapid ferry
#

Good question, I imagine it should still run on server if it owns it

#

Buttt scriptgamecomponent will let you do the remote tick, was mostly reading that part. Not sure why frame not running at all

ocean kernel
#

So like

#

Anything I can do for script editor freezing for 5 seconds every time I click it?

#

Happens when I have quite a few mods loaded

spark otter
spark otter
coarse pasture
#

Active AI will often report out as 0 but they still exist and hold a location in the world

hushed swan
#

Does anyone know how I can disable bacon loadout on a specific box?

proven storm
#

hi im new and im wishing to get into making mods/scripts, im trying to make a item respawn after been taken i tried to google on howto but i cant seem to find anything, also how do i hook a script upto them item?

wooden cape
#

Still having this problem. If zeus moves, say, a vehicle with a bunch of infantry in it, the infantry get moved to their spawn location or debug corner and their RPLs fluctuate massively. They also lose control of their player controller.

The server thinks I'm still in the vehicle as well, and if we move the vehicle back to the rpl bubble location, it teleports the player back into the compartment and returns the server fps back to normal.

We're also seeing items disappearing from player inventories if they take them out of arsenal and move outside the rpl bubble size. As soon as you move back towards the arsenal or drag the vehicle back towards the original location, everything syncs back up.

sleek dove
ocean kernel
#

Ok, but is this a suitable replacement for postframe?

#

Oh wait lol I misunderstood that method

#

I think I get it now

sleek dove
#

It doesn't replace PostFrame, it just tells the game that your component should tick on remote proxies

ocean kernel
#

Yeah sorry about that

#

My bad

sleek dove
#

Or just simply character don't get teleported as well

vernal moat
ocean kernel
#

Yeah that doesnt help for me, when I open like 30 mods script editor takes 5 seconds to focus

vernal moat
vernal moat
ocean kernel
#

Just put him on ignore like you put me

red cedar
ocean kernel
#

It works fine once it has focus, but it takes 5 seconds for it to get focus

bronze lynx
#

Does Reforger support multi class inheritence and if so, what is the syntax?
Example in C++

class C: public A,public B
{
... ... ...
};
bronze lynx
# minor agate No

Thanks for the answer. Is there something else that can some close?

minor agate
#

or aspect oriented design/programming

late locust
#

Btw what is the correct way to override a e.g protected function? Or does it even matter?
I know there was a discussion about this some time ago.
override protected void Foo()
protected override void Foo()
override void Foo()

And same for event where does it go and do we need it?
override event protected void EOnInit()

hushed swan
#

Does anyone know how I can disable bacon loadout on a specific box?

vernal moat
ocean kernel
#

Disable the action in the actions manager component?

hushed swan
#

Is there a separate action just for bacon loadout? Because I don't see it here and even so the bacon loadout appears lol

ocean kernel
#

Of course there is. You can disable it if you wish.

#

Or use a prefab that doesn't inherit the base arsenal entities.

hushed swan
ocean kernel
#

I'm sorry but I am not here to teach you how to use Workbench, I gave you options you can use to disable

ocean kernel
#

I suppose ItemPreviewManagerEntity.SetPreviewItemFromPrefab only works for entities with inventory item component? I wanted something similar to workbench thumbnails for prefabs

teal vapor
pseudo merlin
ocean kernel
#

For overriding vanilla just do it like in vanilla, if its protected do protected I guess

torn bane
teal vapor
torn bane
#

it does more damage than it helps. it could also accidentially make things unstatic

ocean kernel
#

Is garbage system config supposed to automatically insert and remove my entity class or do I have to do it?

sweet badger
ocean kernel
#

Ok

sweet badger
#

e. g. CharacterController OnDeath:

auto garbageSystem = SCR_GarbageSystem.GetByEntityWorld(character);
if (garbageSystem)
    garbageSystem.Insert(character);
#

The garbage system config determines how the inserted entity is treated

ocean kernel
#

Ok

#

Thank u

nova moat
#

Sorry if wrong area

sweet badger
#

How many bytes can you safely broadcast in one go via Rpc?

#

I know this depends on multiple factors, I'm wondering at what order of magnitude (roughly) this is something to worry about.

minor agate
#

What changed was the static one

#

The rest will be kept

#

@late locust

#

You can use it to make methods public that were private or protected

#

Its the aspect of the modding of method signatures

#

Before you were able to also mod a function from.being static

#

That was dropped due to it not making sense and causing more damage than good

teal vapor
ocean kernel
#

Lol wtf unstaticing your statics

sweet badger
#

do these work yet or not?

hushed swan
#

@coarse pasture I finally managed to apply the HUDmessage to the player, but now I'm not able to set a cooldown, have you tried?

coarse pasture
hushed swan
coarse pasture
nova moat
#

Anyone able to point me in the right direciton in terms of getting clothing to be effected by GM Ent Clearing? I have searched high and low, but can't seem to find anything.

midnight talon
#

What's the deal with super with multiple overrides? Ctrl+Click in script editor suggests it works as expected but running the scripts it seems no many how many nested supers I use it always calls the super of the "closest" override

I'm trying to override EPF's override for SCR_SpawnRequestComponent.OnPostInit to call the vanilla version e.g.
super is EPF's override and super.super is the original vanilla one from SCR_SpawnRequestComponent but at runtime it seems to effectively just be calling super.OnPostInit(owner), the logic in SCR_SpawnRequestComponent.OnPostInit to bind components is not called

    override protected void OnPostInit(IEntity owner)
    {
        super.super.OnPostInit(owner);
    }

Is there any easy clean way to do what I'm trying to aside from removing the super calls entirely and copy-pasting code from the super call I want (which only works if that class is scriptable)?

minor agate
#

super.super...nth-super => super

#

If you want vanilla behavior of the class, then you must use vanilla

#

vanilla.OnPostInit(owner); in your example

minor agate
midnight talon
#

wtf I didn't know vanilla keyword existed how did I miss that 😄

pseudo merlin
# minor agate Before you were able to also mod a function from.being static

Is there still a way to make a static methode none-static?
There is one static vanilla which i would like to have none-static the methode is in the class where it get's called from and everything else fit's as well.
No clue why it was made static in the first place only thing the static does in this case is taking away all the functionality of the class to be used with the methode.

midnight talon
# minor agate `vanilla.OnPostInit(owner);` in your example

This seems to have worked perfectly, thanks Mario! What is kind of confusing is I expected Ctrl+Click on the method in script editor to resolve the same as it would at runtime. Using vanilla.OnPostInit works at runtime but ctrl+click in script editor takes me to the EPF override that it's skipping, while doing ctrl+click on super.super.OnPostInit took me to the vanilla method which it wasn't running

minor agate
#

Could have been done to cause inlining

pseudo merlin
# minor agate Could you show me?

I asked/posted it in enfusion_ai a long time ago now i can't find it anymore...
Will have to look up the exact name when i'm on PC tomorrow.
Thanks for checking. 🙂

pseudo merlin
wooden cape
#

What's the most efficient way to call a method that checks if something is complete? Right now we're using callLater(), but isn't that essentially spawning a new thread every x amount of ms we pass into it with the loop parameter to true?

I feel like there's gotta be a better way to call a waited method rather than spawning a new thread over and over.

pseudo merlin
wooden cape
#

So what are you doing to check the bool? Onframe?

#

You still need a way to check the bool in an organized manner

pseudo merlin
#

Yes you could use this.
I always check if there already is something looping in vanilla like Update() which i can use to check so i don't have to add additional code.

#

Guess everything is better than using callLater().

bronze lynx
#

Is there a way to get fire an event every time a chat message is received? I know I can send one, but I don't know how to hook into it to fire an event that executes my own code.
Send message:

PlayerController pc = GetGame().GetPlayerController();
SCR_ChatComponent chatComponent = SCR_ChatComponent.Cast(pc.FindComponent(SCR_ChatComponent));
chatComponent.SendMessage("Hello", 1);
late locust
minor agate
#

The order can be whatever as long as they are before the method identifier

ocean kernel
#

void static ref private

late locust
minor agate
#

If you do not include protected in your override then you made it public

#

Same deal for normal inheritance

late locust
#

Yeah but what if I dont include event for e.g EOnInit

#

Like override event protected void EOnInit(IEntity owner) if that is even needed

#

Cause vanilla game code sometimes does it and sometimes not

minor agate
#

Arkensor learnt it the hard way as well, i had to point it out to an error he had

#

In his case it was the static one

#

Technically all modifiers could be modded

#

With event, it still somewhat works because the class that was created before yours still has it

#

Modding works as in creating a class with the original name that inherits from original with different name

#

It does that literally

#

But this old renamed class does not show up to you when referencing it anymore

#

So the logic of the new class having the things overriden this ways follows, making the feeling like the original became that

late locust
#

So not adding event doesnt delete the event modifier
I guess best to just add override in front and add everything after that 1:1 (If you dont want to change visibility)

minor agate
#

That is what i was getting into

ocean kernel
#

Event is fake anyway, it's just a hint for some backend I guess

minor agate
ocean kernel
#

Ah, not losing anything of value when overriding it then

minor agate
#

Yeah

#

Dont use that

ocean kernel
#

Also

#

Validation should fail if your scripts have no tag for class names

#

Unless it's modding a class name

#

Also x2

#

It should fail for tag that says "TAG"

#

Also x3

#

Script errors on servers should print which mod the script is from

#

Thanks for coming to my ted talk

#

Oh also x4

#

Namespaces

#

Or something

#

My Class names are almost as long as java constructors now

pliant ingot
pliant ingot
livid burrow
#

was this fixed for 1.4? :^)

#

the JIP error on RequestScenarioChangeTransition

torn bane
#

I don't know, I think some of it was done but that was already released as 1.3 patch. I think the current 1.4 did nothing specifically more. you have to try it out

full matrix
#

how can I let an ai group move to an entity like a ConflictMilitaryBase (basePosition)?

I tried it like this:

AIWaypoint waypoint = AIWaypoint.Cast(GetGame().SpawnEntityPrefab(resource, null, GenerateSpawnParameters(basePosition.GetOrigin())))

group.AddWaypoint(waypoint);

torn bane
#

that is already the right idea. perhaps your ai is not yet activated, so call activateai() on the group. then they will go there (if you used e.g. waypoint move prefab)

late locust
#

Also make sure to have SCR_AIWorld Entity with all Navmesh assigned in your world.
Not sure if you need it for waypoints but PerceptionManager aswell.
*If you are in a empty debug world

full matrix
#

Thx, I will check that as well 🙂 I get null for waypoint, can I evaluate certain statements while debugging like in other IDEs? My assumption is that GenerateSpawnParameters could be the cause.

prime quarry
#

How would you properly replicate data from an array list to be fetched by a client?

#

I am using restapi and a callback to call a method that will populate data. It is populated on the server side of things but when I go to use it via the client it doesn't work.

#
    [RplProp()]
    ref array<string> m_PlayerData;

        if (Replication.IsServer()) {
            if (!m_PlayerData)
                m_PlayerData= new array<string>();
        }

Doing this within SCR_BaseGameMode's class.

pliant ingot
quiet drift
#

Hi, is there any problem to do a modded class of SCR_CharacterControllerComponent and modify it like in BootCamp 10 with the custom WeaponAnimationComponent ?
I added the constructor but took the same name as the original component because it's not a custom one, then I do anim event registering, and after that, DropLiveGrenadeFromHand function.
I figured out It's working but I literally don't know if what I'm doing won't cause issues with something I couldn't spot by myself

prime quarry
# pliant ingot You need to call `Replication.BumpMe()` each time you modify `RplProp`

So I am doing that (I believe), still learning the scripting...

modded class SCR_BaseGameMode {
    [RplProp()]
    ref array<string> m_PlayerData;

    void SetPlayerData(string identityId, array<string> p_Data)
    {
        if (!Replication.IsServer())
            return;

        string dataLine = identityId + "|";
        for (int i = 0; i < p_Data.Count(); i++)
        {
            dataLine += p_Data[i];
            if (i < p_Data.Count() - 1)
                dataLine += ",";
        }
    
        for (int i = 0; i < m_PlayerData.Count(); i++)
        {
            array<string> parts = {};
            m_PlayerData[i].Split("|", parts, true);
            if (parts.Count() > 0 && parts[0] == identityId)
            {
                m_PlayerData[i] = dataLine;
                Replication.BumpMe();
                return;
            }
        }

        m_PlayerData.Insert(dataLine);
        Replication.BumpMe();
    }

    // This will be used client side.
    array<string> GetDataFromPlayer(string identityId)
    {
        if (!m_PlayerData)
        {
            Print("[DEBUG] m_PlayerData is definintely null.");
            return {};
        }
    
        foreach (string entry : m_PlayerData)
        {
            array<string> parts = {};
            entry.Split("|", parts, true);
            if (parts.Count() == 2 && parts[0] == identityId)
            {
                array<string> p_Data = {};
                parts[1].Split(",", p_Data, true);
                return p_Data;
            }
        }
    
        return {};
    }
    
    override void OnGameStart() {
        super.OnGameStart();

        if (!Replication.IsServer())
            return;
    
        if (!m_PlayerData)
            m_PlayerData = new array<string>();
    }

    override void OnPlayerAuditSuccess(int iPlayerID) {
        super.OnPlayerAuditSuccess(iPlayerID);
        PrintFormat("MB_Utils | Player (%1) connected. Caching data...", iPlayerID);
        MB_Utils.GetPlayerData(iPlayerID);
    }

    override void OnPlayerDisconnected(int playerId, KickCauseCode cause, int timeout) {
        super.OnPlayerDisconnected(playerId, cause, timeout);
        PrintFormat("MB_Utils | Player (%1) disconnected. Removing cached data...", playerId);    
        MB_Utils.RemovePlayerFromCache(MB_Utils.GetPlayerIdentityId(playerId));
    }
}

Then my callback will call this:

array<string> p_Data = MB_Utils.GetPlayerData(playerIdentityId);
        
            SCR_BaseGameMode gameMode = SCR_BaseGameMode.Cast(GetGame().GetGameMode());
            if (gameMode && p_Data && p_Data.Count() > 0)
            {
                gameMode.SetPlayerData(playerIdentityId, p_Data);
            }

But not seeing the data on the client at all. Appreciate any help! 😄

pliant ingot
prime quarry
pliant ingot
prime quarry
pliant ingot
prime quarry
pliant ingot
#

On server side when controller/component is created retrieve info and send it in Rpc

#

on client side in function save this data and now you can work

ocean kernel
#

json it

river imp
#

I don't see the need to replicate an entire array to every player when the player controller could just store the data for its player.

#

I mean, unless players actually need to know the data of the other players.

#

Highly doubtful though.

gloomy lynx
#

anyone know what script prevents moving inventory items while under water?

#

been searching and cant find anything obvious

serene fox
#

Hey, is there a smart method to get all spawned Characters with a specified faction in the world?

pseudo merlin
serene fox
pseudo merlin
#

Hi, 🙂
Well i use:

array<AIAgent> agents = {};

SCR_AIWorld aiWorld = SCR_AIWorld.Cast(GetGame().GetAIWorld());

aiWorld.GetAIAgents(agents);

which will give you all A.I. agents.

and then you have to sort them by faction like:

string factionKey;
        
IEntity agentEntity;

SCR_ChimeraCharacter chimeraCharacter;

foreach (AIAgent agent : agents)
{
    if (agent)
    {
        agentEntity = agent.GetControlledEntity();
        
        if (agentEntity)
        {
            chimeraCharacter = SCR_ChimeraCharacter.Cast(agentEntity);
            
            if (chimeraCharacter)
            {
                string factionKey = chimeraCharacter.GetFactionKey();
                
                if (factionKey == "US")
                    Print("Do US Stuff");
                
                if (factionKey == "USSR")
                    Print("Do USSR Stuff");
            }
        }
    }
}
#

May you would need/like to put them in faction arrays.
So far the only way i'm aware of to get it sorted like this.

serene fox
#

Thanks mate

#

@pseudo merlin the array also contents Groups?

SCRIPT       : AIAgent agent = <0x000002003513D5C0> SCR_AIGroup
SCRIPT       : AIAgent agent = <0x000001FFB3642230> SCR_ChimeraAIAgent
SCRIPT       : AIAgent agent = <0x000001FFB72BEBB0> ChimeraAIAgent
SCRIPT       : AIAgent agent = <0x000001FFB3642430> SCR_ChimeraAIAgent
SCRIPT       : AIAgent agent = <0x000001FFB3642630> SCR_ChimeraAIAgent
#

Do you know if i need to check all members from such groups also?

pseudo merlin
#

Oh yeah no you don't.
Yes AIGroup and AIAnimal does inherit from AIAgent as well.
So you may need a cast check like:

if (agent.IsInherited(AIGroup) || agent.IsInherited(AIAnimal))
    continue;

Right after the if (agent) condition of the foreach loop.

#

@serene fox

#

I think this is how it's supposed to work with the IsInherited() methode.

full matrix
#

is there a way to get multiple entities by type ("prefab?") instead of name?
GetGame().GetWorld().FindEntityByName("Base_1"); for instance I want to get all ConflictMilitaryBases

pliant ingot
# serene fox Hey, is there a smart method to get all spawned Characters with a specified fact...
  1. Create your component and add it to {37578B1666981FCE}Prefabs/Characters/Core/Character_Base.et.
  2. Create your system and add it to {86E953538A28A98D}Configs/Systems/ChimeraSystemsConfig.conf
  3. In your component:
  • check for FactionAffiliationComponent on owner
  • check for player presence in SCR_CharacterControllerComponent on owner and add event handler to m_OnControlledByPlayer
  • if all conditions meet call function on your system which will save component's entity to array or even map with faction key
serene fox
pliant ingot
ocean kernel
#

mouse2 input doesnt work lol

#

Now it works ugh

late locust
#

Why can e.g CallLater(func fn..) use func as argument but I cant?
func arguments are not supported in script methods

dire sinew
#

Because they are engine-based methods. You can't do it in pure enforce script atm.

#

Same as methods that accept arguments of type void.

ocean kernel
#

Not allowed, sowwy

ocean kernel
#

Is there an easy way to always make an entity upright? in terms of pitch and roll angles, I only want it to be able to rotate around the yaw axis

glossy onyx
#

I made a script for removing sand bags how do I actually add it to the editor

dire sinew
glossy onyx
#

Yes we want to remove them so no one can super gob

#

Fob

dire sinew
glossy onyx
#

Prevent people from placing

dire sinew
# glossy onyx Prevent people from placing

The placeable prefabs for the building mode are registered in EditorModeBuilding.et on the SCR_CampaignBuildingPlacingEditorComponent. So try to replace it with your own custom whitelist of placeable objects.

glossy onyx
#

I’ll try that

dire sinew
# glossy onyx I’ll try that

Actually a better place is Compositions_FreeRoamBuilding.conf. Also after you created the override, you can use right click to open the context menu to clear the array in your override:

ocean kernel
#

Is there a helper function that will delete all null values from array?

ocean kernel
#

Okie

sweet badger
#

A RemoveAll (and RemoveAllOrdered) method could be useful, even though it's trivial to implement yourself

ocean kernel
#

Right

fervent cedar
#

does Remove(null) work?

dire sinew
ocean kernel
#

Seems like PointInfo's GetWorldTransform does not actually return world transform

#

Aha I have to call Init I guess

#

This sounds familiar

sweet badger
prime quarry
prime quarry
pliant ingot
ocean kernel
#

Is my system with frame point lying about time delta or am I tripping? I have a simple float for a timer and 15 seconds elapse in 5

#

I think I'm going crazy

#

Okay I was using GetFixedTimeSlice instead of GetTimeSlice

#

Whew

#

Not crazy

late locust
#

Any way to force stream out an entity?

pliant ingot
late locust
#

I tried that but I think that just enables streaming in general

pliant ingot