#arma3_scripting

1 messages Β· Page 140 of 1

drowsy geyser
#

caseBomb setVariable ["defused", false, true]; -> not defused.

meager mist
#

yea.. I see it now actually. I thought first maybe I had to pass both a DEFUSED and ARMED variable. But defused false and defused true kinda does that too.

meager granite
#

This whole code is not MP compatible at all with CODE being random for each player

meager mist
meager granite
#

Where do you call this code from?

meager mist
#

It's in the init.sqf

meager granite
#

Yeah, code will be different for each player

#

unless that's what you wanted

#

so each player inputs their own found code

#

and can't say find it and tell another player to input

meager mist
meager granite
#

I didn't see what fixed code is

#

and what these scripts do to advise

#

Can you post these action scripts?

meager mist
#

The addAction scripts that are both on codeHolder and caseBomb?

meager granite
#

yes

meager mist
#

defuseAction.sqf:
createDialog "KeypadDefuse";

searchAction.sqf:

 _host = _this select 0;
 _caller = _this select 1;
 _id = _this select 2;
 
 _host removeAction _id;
 
 _caller playMove "AmovPercMstpSrasWrflDnon_AinvPercMstpSrasWrflDnon_Putdown";
 cutText [format ["Code: %1\n", CODE, 10], "PLAIN DOWN"];
meager granite
#

Also, no search action on wrong laptops?

meager mist
#

yea, that's correct. Only the laptop that will display the code has the action

meager granite
#

Alright

#
CODEINPUT = [];

// Server decides the code and correct laptop
if(isServer) then {
    CODE = [(round(random 9)), (round(random 9)), (round(random 9)), (round(random 9)), (round(random 9)), (round(random 9))]; //6 digit code can be more or less
    publicVariable "CODE";

    codeHolder = selectRandom [LAPTOP1, LAPTOP2, LAPTOP3, LAPTOP4];
    publicVariable "codeHolder";
};

// Waiting for server to decide which laptop is holder
0 spawn {
    waitUntil {!isNil"codeHolder"};
    codeHolder addAction [("Search for a code"),"DEFUSE\searchAction.sqf","",1,true,true,"","(_target distance _this) < 3"];
};

caseBombActionID = caseBomb addAction [("Defuse the bomb"),"DEFUSE\defuseAction.sqf","",1,true,true,"","(_target distance _this) < 5"];

0 spawn {
    waitUntil {caseBomb getVariable ["DEFUSED", false]};
    if(isServer) then {
        // This is global so have only server change the task state
        ["Task_Defuse", "Succeeded"] call BIS_fnc_taskSetState;
    };
    sleep 2;
    casebomb removeAction caseBombActionID;
};

0 spawn {
    waitUntil {caseBomb getVariable ["ARMED", false]};
    if(isServer) then {
        // This is global so have only server change the task state
        ["Task_Defuse", "Failed"] call BIS_fnc_taskSetState;
    };
    sleep 10;
    casebomb removeAction caseBombActionID;
};
#

Also BIS_fnc_selectRandom is just a wrapper for selectRandom command now

#

Fixed waitUntil getting false by default

meager mist
#

wow. Thanks. Very much appreciated. Is the if(isServer) then basically making sure that piece of code is server-side and not locally done?

meager granite
#

Yes, only execute if executor is server

#

init.sqf is executed everywhere on each client initialization (and server and JIP)

#

Keep in mind that init.sqf runs each time player joins so if they go back to lobby and join again init.sqf will run again

meager mist
#

And waitUntil {caseBomb getVariable ["ARMED", false]}; .. where is the variable set in this case? Should that not be mentioned somewhere as well?

meager granite
#

Set it to true when you want it armed or defused

#

false means default variable value if not set elsewhere

#

So until some client sets it to something, this variable will be considered false

meager mist
#

right. and that change happens in fn_codeCompare.sqf.

//Parameters
private ["_code", "_inputCode"];
_code      = [_this, 0, [], [[]]] call BIS_fnc_param;
_inputCode = [_this, 1, [], [[]]] call BIS_fnc_param;

//compare codes
private "_compare";
_compare = [_code, _inputCode] call BIS_fnc_areEqual;

if (_compare) then {
    cutText ["BOMB DEFUSED", "PLAIN DOWN"];
    DEFUSED = true;
} else {
    cutText ["BOMB ARMED", "PLAIN DOWN"];
    ARMED = true;
    playSound "button_wrong";
};

CODEINPUT = [];

//Return Value
_code
meager granite
#

DEFUSED = true; => caseBomb setVariable ["DEFUSED", true, true]
ARMED = true; => caseBomb setVariable ["ARMED", true, true]

#

second true is to broadcast the variable

meager mist
#

And then I also need to change the fn_bombTimer.sqf to get the proper variable. Change it to this?

while {_time > 0 && !DEFUSED} do {
...

to

while {_time > 0 && {caseBomb getVariable ["DEFUSED", false]}} do {
...
#

after testing that's a no ugly_cry

meager granite
#

Looks correct

#

Oh you forgot the !

#
while {_time > 0 && !(caseBomb getVariable ["DEFUSED", false])} do {
#

Same with lazy eval but its a drop in the ocean difference here

while {_time > 0 && {!(caseBomb getVariable ["DEFUSED", false])}} do {
meager mist
#

Could it do the same if I change false to true?

meager granite
#

no, that is default value

#

this condition will break as soon as you assign any value to that variable

#

break as in not do what you want it to do

#
while {
    private _defused = caseBomb getVariable ["DEFUSED", false];
    _time > 0 && !_defused
} do {
...
```if you want it to look neater
meager mist
#

I would like to learn how to make things neater KEKW

#

thanks

meager granite
#
while {
        (_time > 0)
    && !(caseBomb getVariable ["DEFUSED", false])
} do {
```my kind of neater πŸ€“
meager mist
#

I have so much respect for you veterans out there.. Just me doing this kind of stuff for the past months, is making me realize how much work goes into this and how much knowledge you need before comprehending it.

meager granite
#

Scripting itself is rather easy, knowing all quirks of the engine is something is mostly undocumented and only acquired with experience

meager mist
#

yea.. that's it I guess. The logic behind it seems somewhat simple. But knowing the difference between ( ), { } and [ ] is already mind boggling for me.

meager granite
#

That's general programming, wont be an issue after some time doing it

meager mist
#

hmm.. the only issue I have now is that it's going from 5 minutes straight to 4 seconds and not ticking down. I tried a couple of things but no success 😦
This is the part that handles the countdown from 5:

if (caseBomb getVariable ["ARMED", false]) then {
    _time = 5; 
    ARMED = false  //take it I have to change this? But not sure
};```
#

I change the line I commented to the getVariable part, but that didn't seem to do anything

drowsy geyser
meager mist
#

I was about to type that, but slightly different. Just realized it's setting the variable to a condition, so it should be set and not get.

bleak gulch
#

I'd prefer to recode that mess from scratch

#

handle all bomb initialization code on the server side and only init Actions on clients which calls server-side functions via remoteExec

#

use one object-specific global var to determine the current state of the bomb using macro like

#
#define BOMBSTATE_UNARMED  0 // not armed, safe
#define BOMBSTATE_ARMED    1 // ready to explode
#define BOMBSTATE_DEFUSED  2 // defused, safe

init on the server side

if (isServer) then
{
    bomb setVariable ["BEAR_bombState", BOMBSTATE_UNARMED, true];
};
#

use addAction only on clients excluding Headless Client. Check the "BEAR_bombState" variable and depending on its state the matchign action should be shown

#

Assign each action to the server-side function which processes the request from the client, checks conditions, logs, doing other shit by your choice and disarms the bomb, setting it's new state to BOMBSTATE_DEFUSED.

Keep in mind if your server function is not executed in non-scheduled, you have to deal with concurency and lock the variable before processing it. isNil {} is ok for that or just use remoteExecCall.

#

If you figure out on your own how this client-server mechanism works, you will change your mind set eventually and the other things will be done way faster, more reliable and more clear to understand

#

if you're want to debug the vars, use Debug Console or add debug commands into your code. For example:

BEAR_fnc_DisarmTheBomb =
{
    diag_log (format ["[BEAR_fnc_DisarmTheBomb] state: %1", bomb getVariable ["BEAR_bombState", -1]]);
    bomb setVariable ["BEAR_bombState", BOMBSTATE_DEFUSED, true];
};
#

diag_log writes the line into .RPT so you can monitor the variable before you change the bomb state and make sure it has proper state to avoid disarming not armed / already defused bomb.

#

so check diag_log, format, remoteExec, remoteExecCall, setVariable, getVariable, CfgFunctions, initization order and Preprocessor BI Wiki articles

#

the whole idea

1. addAction on client init depending on current state

2. addAction code requests the server to do the job

3. Server process the request(s), makes callback to client-side if needed (for example it removes Actions completely, draws the hint with the message, etc)
meager mist
#

Thanks @bleak gulch for the resources etc.. I'm going to keep working on this and make it less messy. Unfortunately I need this script done by Thursday so it'll be fine for now (still some bugs but fine.) I want to make this better for future missions. I guess I have some reading up to do and make sure I completely understand this.

#

There are a couple things I would want to add/change anyway. Like an addAction on the laptops that don't give the code and saying "No code here", as well as making the defusing set to cut a wire AND the code.

meager granite
#
{
    if(_x == codeHolder) then {
        // action with code
    } else {
        // action without code
    };
} forEach allLaptops
#
allLaptops = [LAPTOP1, LAPTOP2, LAPTOP3, LAPTOP4];
...
codeHolder = selectRandom allLaptops;
#

and similar stuff

meager mist
#

Noted! The next iteration will have that! Thanks.

meager granite
meager mist
#

Is there a reason to put a script like this in it's seperate sqf? Or is putting it in init.sqf is fine? If I'm doing it "optimally"

meager granite
meager mist
#

Ok. I thought maybe there is a good practice idea behind it. I'd probably do it in their won script, so I don't accidentally delete something from other things.

sullen sigil
#

the goodest practice is whatever you can be bothered to do

#

seperate script files is better only for organisation

#

theres no performance improvement for it

tender fossil
#

I'd just like to interject for a moment. When it comes to organisation and readability, there's an obligatory quote: β€œAny fool can write code that a computer can understand. Good programmers write code that humans can understand.” β€”Martin Fowler

meager mist
#

I mean, it probably doesn't show now... but in my dayjob I have properly named folders and names of files everywhere :p I'm not a "Untitled folder" kinda guy. So I want to be more organized :p

sullen sigil
#

i am an untitled folder everywhere kinda guy

#

all my blender models are also just kept in my downloads folder

proper sigil
#

Hey guys, 2 questions as I'm having trouble getting trigger to work correctly - it works but I'm having some locality issues with it and I want to check if my "notes" are right:

  1. Activation and condition - am I doing it right? Expected behavior is that trigger activates whenever a vehicle present in dnt_deployedVehicles will enter trigger area and deactivates when it leaves it. I set activation to none as (count ((vehicles inAreaArray thisTrigger) arrayIntersect dnt_deployedVehicles)) > 0 is only condition I want to activate it
  2. If trigger is only evaluated on the server but I use remoteExec["someth",-2] in "On Activation" then after trigger is activated "someth" function should fire on all clients, right? Or should I leave "Server only" unchecked if I want function to execute later for clients?
fair drum
sonic onyx
#

Hello, I am trying to apply a 10m trigger condition when in this case an ACE flash is detected, a door is opened, I tried to do it in different ways, but it does not apply to me.
I don't have much knowledge about this and I'm not sure what the problem is.

opal zephyr
sonic onyx
opal zephyr
#

If you just placed it on the ground that is not what it would be called when its airborn

lavish stream
#

try using ACE_G_M84, No idea if that works but worth a shot.

sonic onyx
#

Yes I tried, thanks, and it is the page I use as a guide but I can't get it to work.

sonic onyx
#

Ok, after reading it I realized that everything was wrong.
Does anyone know a way to detect an item inside a trigger?
I want to detect the flash when inside the area, but I don't think it will work in
I have only found information about detecting it within an inventory, but it is not what I am looking for.

hallow depot
tidal idol
#

Warlords with custom factions question: Why are units spawned inside sectors to defend not limited to what is shown here? Is it because I have a faction defined in the module to be used?

class CfgWLFactionAssets{
    class WEST{
        class InfantryUnits{
            class B47_WZ_TP_Rifleman_Light_A{};
            class B47_WZ_TP_Rifleman_Light_Mk17_A{};
            class B47_WZ_TP_Rifleman_A{};
            class B47_WZ_TP_Rifleman_Heavy_A{};

            class B47_WZ_TP_Marksman_A{};

            class B47_WZ_TP_Automatic_Rifleman_A{};
            class B47_WZ_TP_Machine_Gunner_A{};
            class B47_WZ_TP_Heavy_Machine_Gunner_A{};

            class B47_WZ_TP_Rifleman_AT_A{};
        };
    };
    class EAST{
        class InfantryUnits{
            class B47_WZ_NP_Rifleman_Light{};
            class B47_WZ_NP_Rifleman{};

            class B47_WZ_NP_Marksman{};

            class B47_WZ_NP_Automatic_Rifleman{};
            class B47_WZ_NP_Machine_Gunner{};
            class B47_WZ_NP_Heavy_Machine_Gunner{};

            class B47_WZ_NP_Rifleman_AT{};
        };
    };```
exotic flame
#

When i'm commanding a ship and i click on the map, my character gives order to move to the position i clicked on. How do i prevent that ?

#

I'm looking for a solution without disabling coms

tidal idol
#

That's intended functionality. Only solution is to not be in a "commanding" seat.

proper sigil
# fair drum 1: ```sqf (vehicles inAreaArray thisTrigger) findIf {_x in dnt_deployedVehicles}...

2: I think I do? Function adds an action to object whenever trigger is activated and removes action when it's deactivated. My intention is that whenever a vic (present in array) enters trigger area action is added to an object for all players (JIP too) to interact with and when object leaves area action should be removed for all players and afaik addAction is added locally for a player?

tidal idol
#

Having a Multiplayer-related issue on Line 30. When in SP, script works fine - radio speaker spawns, light point spawns, spotting tube spawns, and the shot spawns. However, when testing in 3DEN using a MP-host, everything works except for the laser tube sc_scripts_orbitalcannon_beam. Any suggestions to make spawing this work in both SP and MP?

hallow depot
meager granite
#

lineIntersectsSurfaces returns ASL positions, createMine takes AGL

hallow depot
open hollow
#

damn chat GPT-4o is way better on sqf now ( far from perfect) but it can make some code that really works, so we gonna see a lot of questions here of gpt generated code lol

hallow depot
open hollow
#

but now it can do some complex stuff with out so much guidance

hallow depot
#

I've scraped all commands and functions from BI, and all info from the other pages to txt files and made my own gpt with those files.

It's good, but it's just a guidning in the right direction. Still gives wrong commands sometimes, like vectorsubtract instead of Vectordiff 😁

open hollow
#

yea, still have errors like: side group _unit

#

but the code is harder to diferenciate now

open hollow
#

i guess it can be identified beacse it explain every line with a comment, but its much better now
||```sqf
->THIS IS CHAT GPT GENERATED CODE DONT USE IT<-
// rewardOnKill.sqf
params ["_unit", "_killer", "_instigator"];

// Configure the reward item and amount
private _rewardItem = "rvg_money";
private _rewardCount = 10;

// Check if the killer is a player
if (isPlayer _killer) then {
// Check if the unit is not on the same side as the killer
if ((side group _unit) != (side group _killer)) then {
// Check if the unit is not a civilian
if ((side _unit) != civilian) then {
// Add the reward to the killer's inventory
for "_i" from 1 to _rewardCount do {
_killer addMagazine _rewardItem;
};
hint format ["You have received %1 %2 for killing an enemy!", _rewardCount, _rewardItem];
};
};
};

#

we gonna need a chatGPT detector now lol

meager granite
meager granite
#

these can result in different sides

#

isPlayer only checks if effectiveCommander is player, which is not always a case for vehicles

open hollow
#

oh wait side group is right, i didnt know that you can use the group to get the side lol

open hollow
# meager granite these can result in different sides

||```sqf
-> chat GPT GENERATED CODE DONT USE IT <-
{
if (!isPlayer _x && (side _x != civilian)) then {
_x addEventHandler ["Killed", {[_this select 0, _this select 1, _this select 2] execVM "rewardOnKill.sqf";}];
};
} forEach allUnits;

it goes in a killed eventhandler, why it can result of diferent sides?
meager granite
#

execVM nootlikethis

meager granite
#
private _unit = createGroup blufor createUnit ["C_Man_1", getPos player, [], 0, ""];
[side group _unit, side _unit]
``` => `[WEST,CIV]`
#

Either way, much more impressive than before

open hollow
#

yes, well in this use case, that bug is solved by using side group, since you want to know if there was a teamkill

grizzled vapor
#

chatgpt is going to be the way to generate 2000line functions for something that can be written in a human readable way in 100 lines, but going to include nasty race conditions πŸ˜‚

open hollow
#

i feed it up with some code i found in this channel, and described quite well what the code does, also i ask it to improve de code, and give a pretty decent alternative

grizzled vapor
#

"if the code works flawlessly in the first try, its usable" - big no. If you ever need to touch that portion of code again you are essentially fckd. Even if it "works" at a time.

open hollow
#

meh, normally the person that uses chatGPT code is bc gpt has more knowlage than that person on that languaje, so it wont be able to write that code in the first place

undone flower
#

I challenged chat GPT to work with vehicle pylons, it's now arguing why humanity should be erradicated

winter rose
exotic flame
high marsh
#

Stupid freaking robot is what I call it

#

So I remember having a problem working on a particular project in the past ( so I don't have any example code drummed up yet) but: there was always something wrong with how handling a "timer" worked. The player's timer goes up upon killing another player. Which is handled by the method that is called after EntityKilled is evoked. I was using remoteExec to ensure it got put into JIP Qeue and remove any type of locality clashes from server and client. Timer would run on the client and anytime a unit would be killed the function that runs on the player for the timer calls for a reup from the server via remoteExec

#

any inate problems with this? Doesn't seem like a bulletproof way of doing I guess "callbacks?" in the net from SQF level. Timer would constantly drop into the negative despite any logic problems hashed out. It would never kill the player when the timer runs out like it's supposed to or it would kill the player prematurely

granite sky
granite sky
#

remoteExec timing is... not reliable.

high marsh
#

that's fair, ditch the MP Handler for the local EH?

granite sky
#

You can install mission event handlers on clients too.

high marsh
#

That's right. Are they perhaps stackable in the same way then too?

granite sky
#

addMissionEventHandler is stackable. I'm not sure what you mean though.

#

You can install the same code on every machine and they won't interfere.

high marsh
#

I'm assuming that because addMissionEventHandler is stackable because of it's own behavior and not a specific event?

#

and that it gets it's own index for every duplicate event handler added like addEventHandler would

granite sky
#

Yeah, you can install two different EntityKilled handlers on the same client for example.

high marsh
#

but I think I'm starting to understand what you mean. addMissionEventHandler is kin to as if you were to add the event handler to every player?

granite sky
#

I don't know your mission.

#

EntityKilled is installed once and fires for every object killed.

high marsh
#

I'm confused as to why the suggestion is to change how and where the handler is added versus how remoteExec performs

granite sky
#

The Killed EH is only fired when the target object is killed.

high marsh
#

correct

#

I am using EntityKilled + addMissionEventHandler

granite sky
#

On the server?

high marsh
#

ues

granite sky
#

The suggestion is to add it to each client instead.

#

And then clients do their own timer handling.

high marsh
#

Ahh. I see.

#

Sounds good, I'll see how that owrks out. Fingers crossed.

#

one last brain battle here,
is loadFile executed asynchronously under the hood? Not sure how the threaded work load works in SQF besdies unscheduled is faster but encounters blocking and scheduled does not have any blocking

#

(given that you have proper UTF8 endcoded chars)

granite sky
#

I would guess that it's synchronous.

#

"scheduled does not have any blocking" is arguable. If you call a slow command in scheduled then it can take multiple seconds without suspension.

high marsh
#

Shouldn't be a problem, it's just essentially a flat configuration lookup that I'm doing.

slow command
Guess that also depends does it not. A headless a3 client running as a server doesn't have a GUI to render and most of the tasks a CPU can crunch through with ease

#

besides things like high entity count

granite sky
#

Commands that scan the entire map for objects are a common example.

high marsh
#

So it what, bruteforces a check from starting to end?

#

given that there isn't any parameters to check by

#

I'm not familiar with how that works on a fundamental level.

granite sky
#

Scheduled only suspends at checkpoints. Ends of statements, some loop commands.

high marsh
#

so waitUntil uiSleep and sleep are scheduler flags?

granite sky
#

Nah, those are forced yields.

high marsh
#

Ok very good lol

#

Checkpoints, end of statements, and some loop commands though? Is it nearly trivial without debugging it?

#

I know there are some event handlers that run in a scheduled environment but I just considered that black magic

#

I think the ultimate solution here would be just to throw top level SQF out the window and use ded's suirrel wrapper

granite sky
#

As far as I know, all event handlers are unscheduled?

high marsh
#

All except a few, it's been literally years since I last revisted that but a few are scheduled

granite sky
#

name one :P

high marsh
#

πŸ˜“

granite sky
#

Now addAction does run its code as scheduled.

high marsh
#

yeah but on the backend of that isn't it just registering new fields into a dialog

granite sky
#

shrugs

#

It would have been a choice at some stage.

#

Dialog events are generally unscheduled.

high marsh
#

Arma 3 alpha πŸ‘€

granite sky
#

At least I think so. It's not documented.

high marsh
#

onLoad and onUInload

#

this is all to say though, spawn does exist.

#

without exiting the working thread though I do not believe you can do the inverse

granite sky
#
isNil {
   // anything in here is unscheduled
};
high marsh
#

πŸ€¦β€β™‚οΈ I forgot about that. How tacky but it works

ornate whale
#

How is it possible that you can create your own event handlers in CBA, how does it work? I thought that events are hard coded in the Arma 3 engine(game code).

high marsh
#

secret intergalactic trade secrets (probably macros) πŸ˜„

#

shorthand in functions I believe

granite sky
high marsh
#

I don't think that's how CBA ended up handling it though right.

granite sky
#

The method isn't dissimilar.

high marsh
#

Fair

#

Thing it was on the vehicle config level and abstracted to a function

granite sky
#

It's not complicated really. On each machine you maintain a list (hashmap, if you're doing it properly) of event names and the code that should executed when that event name is triggered.

high marsh
#

The hardest part though, do you have qualifying information to be invoking events off of?

ornate whale
#

Do they somehow add function calls into the classes definitions in configs?

granite sky
#

Oh, that's different stuff.

#

CBA also does some fairly expensive each-frame checking for whether specific "events" have occurred.

high marsh
granite sky
#

And in other cases it's just forwarding Arma events.

#

(sometimes when they were added later)

high marsh
#

Graceful

ornate whale
#

I thought they are able to, for example, throw event when you get prone without any kind of additional check via sqf.

high marsh
#

animStateChanged I think is one that throws that

#

but it also executes for every single change in animation change.

#

There is a lot of like IK animation handled like that. \

ornate whale
#

I am just trying to figure out how can you simply detect a condition that is not provided by any EH or command by Arma itself without doing heavy per frame checks. If it is even possible to do different way.

high marsh
#

To check to see if player is prone?

#

@ornate whale

player addEventHandler["AnimStateChanged",{
    if((_this # 1) find "amovppnems" != -1) then {
        hintSilent "player is prone!";
    } else {
        hintSilent "player is not prone!"
    }
}];
#

and yeah this works for rolling and moving whilst prone as well.

ornate whale
high marsh
#

last time I checked you can't read memory addresses in SQF so no. Not really πŸ˜„

#

also, the event handler isn't constantly firing

ornate whale
#

I thought if the config classes could be of any use in this regard

#

Like call a function when a unit fires etc.

high marsh
#

I mean yeah, but that's to lookup the animation moveset of whatever unit you're targeting

#

as far as any soldier goes, I don't think literally any of them change from the Man inheritance

high marsh
#

displayAddEventHandler has a event called mouseButtonDown I believe that would fire at any time on the main display if you left clicked. πŸ€·β€β™‚οΈ

#

actionKeys, etc

#

SQF itself is like an abstraction layer between how the game functions on the engine level and your top level SQF scripts. You can only use hooks that are given in that way

#
animationState player

returns the same info just all lowercase πŸ™‚

still forum
#

"I want to do this"
"Here is the way to do this"
"Yeah okey, but I want to do this without doing that"

But but. But why

high marsh
ornate whale
high marsh
#

if you're not building an addon or need CBA for something very specific that you couldn't do yourself for some reason than no need to

junior moat
#

hey i dont understand this part of addAction, i have the following code:

this addAction ["Mystery Box!", {execVM "Scripts\MysteryBox.sqf";}, nil, 6, true, true, "", "true", 5, false, "", ""];
```in the init of a supply box and i want to pass _caller to the "MysteryBox.sqf" script but i dont understand how to do that. any help?
high marsh
#

you are scripting a mission for example, you can dynamically grab user configuration for keys.

#

or detect when people are prone, etc etc

#

CBA is a good suite of everything if you are building an addon and want to get things off the ground quick imo. But totally not worth adding another potential dependency

#
this addAction["Mystery Box!",{[_caller] execVM "Scripts\MysteryBox.sqf", nil}, 6, true, true, "", "true", 5, false, "", ""];
#

@junior moat

junior moat
high marsh
#

Wait it's not a magic variable I don't think

#

you may need to select it from the past _this variable and so if that doesnt work give this a shot:

junior moat
high marsh
#
this addAction["Mystery Box!",{ [(_this # 1)] execVM "Scripts\MysteryBox.sqf"}, nil, 6, true, true, "", "true", 5, false, "", ""]
#

I need to sleep

junior moat
high marsh
#

@junior moat

junior moat
#

?

high marsh
#
// option 1: just use the _this reserved variable to reference passed arguments (like _caller in this context)

_callerDude = _this # 0; //depending on how it's passed. It can be an array of many arguments, an array of one, etc etc. the # operator selects the index of 0 from _this in this example

// option 2 : use param and params for error checking and type checking

params[
    ["_callerDude","ThisIsADefaultValue",["ThisIsAValueIndicatingAcceptedTypes"],1] //1 indicates we only need one of that type in this variable and you just do this for every variable you need accessed
]
junior moat
#

ah, thanks

high marsh
#

I prefer params for anything that has more than one paramter just because automatic error checking and type checking is a win win

#

there is also param which you specify at which index to do the checks on

sonic onyx
#

Hello, can anyone give me information about ACE advanced throwing? I want to detect when the grenade is thrown, like "Fired" in ARMA.

granite sky
#
["ace_throwableThrown", {
    params ["_unit", "_throwable"];
    // do stuff here
}] call CBA_fnc_addEventHandler;
#

Works locally at least.

sonic onyx
granite sky
#

I don't think that one is in there. I usually just read the source.

solid ocean
#

so im using a script to play a video but when i execute it instead of playing the video it just goes to a blank screen?

confused as to why this is ive followed a guys tutorial on YT and his works fine.

script below:

video = ["\movie\endingcutscene.ogv"] spawn bis_fnc_PlayVideo;
hallow mortar
#

Do you have PiP turned on in your graphics settings?

solid ocean
#

nvm i figured it out now this script only works if its in your mission folder, my video is in a subfolder i moved it now it works πŸ‘

sonic onyx
little raptor
# ornate whale I am just trying to figure out how can you simply detect a condition that is not...

If it's your own code (that you can edit/control), you just add callbacks to the events that you need (e.g. let's say you want something to happen when a light is turned on, so you just call a function [true] call my_fnc_setLight and handle everything there, instead of constantly checking a var waitUntil {my_isLightOn})

If it's someone else's code (including engine code), you're at the mercy of whoever wrote it. If they didn't implement any sort of callback for an event you have no choice but to check in a loop (altho sometimes you can come up with more clever tricks)

cobalt path
#

Error type Any, Expected Number
Any ideas? I am trying to do so, that when you equip specific uniforms, your scale changes (to 1.15 in this situation)
Any ideas where my mistake is? https://pastebin.com/ArqYcJPt

stable dune
#

and you are using local _, so it doesn't remove earlier eachofframe eh, you should save that in variable in player or to global var

silent comet
#

I'm basically trying to spawn a tank on a empty marker when a certain trigger is activated, but I'm not really sure how this works. The code bellow doesn't return any errors, but doesn't work either

_tankGroup = createGroup east;
"CUP_O_T55_TK" createUnit [getMarkerPos "tankSpawnMkr", _tankGroup];

stable dune
silent comet
#

Thanks, I'll try to fix it

sonic onyx
#

Does anyone know the "cook" or "primed" function of ACE advanced throwing?

solid ocean
#

so ive got this video im trying to get to work ingame as a cutscene ive tried multiple different things to get it to work but for some reason the video just speeds ahead while the audio plays at a normal rate and then it will cut off abruptly

Saving it at a different frame rate, a different bitrate nothing nadda.

What am i missing? is their limitations to the video files?

untold copper
bleak gulch
#

Is there way to restrict to change the public variable for non-owners?

// Server (trusted)
PRO_myVariable = "Hello, World!";
publicVariable "PRO_myVariable";

// Client (non-trusted)
PRO_myVariable = "Hello, Universe!"; // throw an error
publicVariable "PRO_myVariable";     // or here

at this moment I have to use set/get + remoteExcec functions to set and retrieve this type of vars which prevent of unauthorized access to the vars from the clients. But is there more convenient way in my approach? I don't like the idea when the game allows to overwrite other's machine variable without any restrictions (on purpose or accidently).

hallow mortar
#

Bear in mind that might affect BI functions as well, though.

bleak gulch
meager granite
#
"Hello, World!" remoteExec ["something", 0];
something = {
    if(remoteExecutedOwner != 2) exitWith {};
    PRO_myVariable = _this;
};
bleak gulch
kindred zephyr
#

whats the purpose of publicing the variable if you only trust the server? Why not feed the value directly to whatever you require it for?

bleak gulch
#

@kindred zephyr
For example you have an object and want to publish its state:

// Server
object setVariabe ["state", 0, true];

// Client decides what to do depending on object's state
switch {object getVariable ["state", -1]} do
{
  case 0: {...};
  case 1: {...};
  default {...};
};

Client must have read-only access to the "state" variable of the object and must never overwrite it because it may affect other client(s) or the whole mission / addon logic.

#

At this moment CfgDisabledCommands doesn't provide ACL mechanism to whitelist the specific arguments for the command, It filters the syntaxes but you cannot specify this logic:

"You can use publicVariable for all variables but var1 and var2. setVariable with true flag is also not allowed for var3 but allowed for var4 because var4 is in local object".

You have to disable publicVariable and setVariable entirely and make a set-get wrapper for all instances using these commands, especially BIS and CBA functions.

storm arch
#

Not having luck using it currently

#

found out you cant put an array like _array in the [] for it wont work when calling so proper format is actually - _array call BIS_fnc_arrayShuffle;

hallow mortar
#

That's because [ ] are what denote an array. If you have an array stored in _array, then using _array is the same as writing e.g [1, 2, 3]. If you then do [_array], that's the same as writing [[1, 2, 3]] - an array inside an array.
BIS_fnc_arrayShuffle will actually "work" with an input consisting of an array inside an array, it's just that it's only shuffling an array of one element (that element being the inner array) so it doesn't do anything noticeable.

meager granite
bleak gulch
#

moreover even using set-get way it's very inconvenient comparing to keywords and/or using dedicated CfgWhatever section to define the access levels.

meager granite
#

with second example broadcasting PRO_myVariable won't overwrite it inside localNamespace

#

If you mean a cheater could overwrite something to alter its behaviour, you already have a cheater with random script access and its FUBAR already

bleak gulch
meager granite
#

Actually, you can even do something like this;

// Server
"Hello, World!" remoteExec ["something", 0];

// Everywhere
something = {
    if(remoteExecutedOwner != 2) exitWith {};
    PRO_myVariable = _this;
    with localNamespace do {
        PRO_myVariable = _this;
    };
};

"PRO_myVariable" addPublicVariableEventHandler {
    missionNamespace setVariable [_this select 0, localNamespace getVariable (_this select 0)];
};
#

This way you won't have to query localNamespace each time you use the variable and it will protect it from broadcasting

bleak gulch
#

god...

meager granite
bleak gulch
#

addPublicVariableEventHandler doesn't work for object variables as I know

#

or?

meager granite
#

Apparently, I haven't tried it myself

#

Broadcasting forbidden variables can be partically solved with BE

bleak gulch
# meager granite Actually, you can even do something like this; ```sqf // Server "Hello, World!" ...

The problem with the addPublicVariableEventHandler is if "PRO_myVariable" pubVar'ed, the other stackable EHs will be fired despite you reverted the variable value back from the localNamespace. If you have 3rd party addons / frameworks with addPublicVariableEventHandler the EH may proceed the variable before your code makes the variable "read-only". It provokes undefined behaviour. In this case you must be sure

  1. Your code, BIS functions, CBA or any 3rd party addons don't use _this select 1 value from the pubVar EH and only work with the variable itself (_this select 0). _this select 1 contains the new variable value which must never be applied.

  2. Your protecting EH is fired before any other stacked EHs.

At this moment you have to make overcomplicated solutions for the very simple task even utilizing AC software.

#

localNamespace is a good option to store private data but the game doesn't serialize the data in that space so it cannot be used with the savegames. We prefer to use locally created vehicle (Logic).

cobalt path
sonic onyx
stable dune
# cobalt path I do want to remove earlier EH. If they will start stacking up, that will hit pe...

You could check before adding new or deleting exiting (if not powerarmor), does unit have EH or not.
so you dont add new if he have already EH.
And remove if the new uniform is not power uniform and player have eh,

private _mfresize = player getVariable ["MRK_EachEH", -1];
private _hasEH = _mfresize != -1;
if (uniform _unit in _powerarmor && !_hasEH) then {
    _mfresize = addMissionEventHandler ["EachFrame", {player setObjectScale 1.15}];
    player setVariable ["MRK_EachEH",_mfresize];
} else {
    if (_hasEH) then {
       removeMissionEventHandler ["EachFrame", _mfresize]; 
    };
};
bleak gulch
meager granite
#

Unless you meant you wanted to protect every single public variable like that, then that's futile

#

Having some protection for own stuff is much more doable

teal hatch
#

yo am new to arma idk if theres a help channel here but whenever i open the map i get this map not the one with like ability to scroll and mark stuff why is that

#

on ytube i see em having smthn on top called "tempmissionsp" with like ability to mark stuff

warm hedge
#

Ability... to... what? Do you mean you are loading Arma 3 Contact and that's why?

meager granite
#

I guess you cannot rely on crew being in the same order on all clients?

#

Hmm, the order always seems to be driver - turrets - seats so you probably can, assuming seats are properly synced

sonic onyx
teal hatch
#

is it cuz of some mod or dlc?

warm hedge
#

Literally I've mentioned in the post

you are loading Arma 3 Contact and that's why?

stable dune
teal hatch
#

appreciate the help

thorn saffron
#

I want to run a script when player has a specific pistol weapon pulled out and only then. It has to be something reusable, ie. it runs every time the player pulls out that specific weapon. I could have a loop script that checks every second if the player has that specific weapon pulled out, but I was wondering if there is more elegant way to do this, or with better performance.

hallow mortar
#

In 2.18 you'll be able to use the WeaponChanged EH, but unfortunately not yet.
For now, I think a loop is the only way.
If it's constructed sensibly it shouldn't be too bad for performance - just check currentWeapon and immediately continue if it doesn't match.

bleak gulch
thorn saffron
#

Multiplier, CBA can be used, it will be an addon.

bleak gulch
#

@thorn saffron
If CBA available, check this
http://cbateam.github.io/CBA_A3/docs/files/events/fnc_addPlayerEventHandler-sqf.html

CBA_fnc_addPlayerEventHandler
CBA_fnc_removePlayerEventHandler

”weapon”    currently selected weapon change
”turretweapon”    currently selected turret weapon change
”muzzle”    currently selected muzzle change
”weaponMode”    currently selected weapon mode change
// Add EH and store its ID
TARO_Weapon_EHID = ["weapon", {systemChat (str _this);}] call CBA_fnc_addPlayerEventHandler;

// Remove EH and set its ID to -1
["weapon", TARO_Weapon_EHID] call CBA_fnc_removePlayerEventHandler;
TARO_Weapon_EHID = -1;
thorn saffron
#

I see, thanks. I was looking at the custom CBA events and missed this one.

little raptor
neon plaza
#

Hey and good morning, anyone have access to a vehicle spawn script?

#

Seems like the respawn module In Arma3 does not like to work.

cyan dust
#

Good Day. I noticed that some buildings (like Land_i_House_Big_01_V1_F for example) do not trigger "EntityKilled" event handler when getting bombed and being replaced with partially ruined model. Is there a known workaround for this issue?

proven charm
#

thats strange, you could try "Killed" EH but maybe it has the same issue..

granite sky
#

Anything that generates a ruin triggers "BuildingChanged".

#

Kinda surprised that those don't generate EntityKilled too though.

cyan dust
#

You're right, thanks!

velvet merlin
#

handleDamage only triggers where the unit is local, right?
even if they are in the vehicle - or can there be in such case some influence from effectiveCommander/to whom the vehicle is local to? (just taking unit/infantry damage)

meager granite
#

Crash damage is done by vehicle owner with no attribution

#

if vehicle owner decides there was a crash and crew damaged, its broadcasted to remote crew

#

HD fire still will only be where unit is local

cobalt path
#

Error Missing )

player addEventHandler ["Fired",
{
    params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
    if
    (
        _weapon = AM_Laser_Musket
    )
    then
    {        
        player setAmmo [currentWeapon player, 11];
    }
    else
    {
    };
}];

Am I too tired to figure out whats wrong with this?

hallow mortar
#

Perhaps the weapon classname should be a "string" rather than a global variable name?

#

Also it's == for comparison - = is to set the variable

cobalt path
#

Perhaps you are right

junior moat
#

hey how would i go about making it so that, at the start of the mission, the screen is completely black? i want to have it start black, some title text appears, music starts playing. and as soon as the lyrics start, theres a quick fade from black. i tried using BIS_fnc_fadeEffect but it didnt seem to work how i wanted it to, any help?

fair drum
junior moat
fair drum
#

Is it a scene that you want everyone to see the same exact thing at the same time? If not, then what I said above won't matter. If so, you'll have to sync the start time with all the clients since each client will have a different load time.

junior moat
#

my current code is as simple as:

if (hasInterface == true) then {
    hint "call intro music";
    playMusic "FalklandsSongIntro";
    [1, "BLACK", 10, 1] spawn BIS_fnc_fadeEffect;
};
#

this works somewhat time

#

its just that i want the black screen to last longer before fading away, unsure how i would go about doing that

fair drum
#

Use cutText

#

And a extremely small number on the timing to make it instant black. Like 1e-6

junior moat
#

got it, ill try that out now

fair drum
#

Then wait, and fade it back in the same way.

junior moat
#

aha, got it working! much appreciated!

bleak gulch
#

@junior moat

if (hasInterface == true)
// change to
if (hasInterface)

there is no reason to evaluate BOOL to BOOL in comparison when hasInterface is already your result (true or false).

brave venture
#

So. Just to make sure I'm not going insane. If I use something along the lines of
while{something} do {get new position; simpleobject setpos (new position);};
It should move the obj to the new position repeatedly, correct?

warm hedge
#

Better to state what makes this question and/or context too

brave venture
#

Is the question not clear?

warm hedge
#

Hence my question

brave venture
#

->It should move the obj to the new position repeatedly, correct?

#

Does the code work as intended?

warm hedge
#

Technically no because it is a psuedo code. If you write it correctly, maybe, maybe not. I can't say without how exactly you've done this or why you ask this

brave venture
#

I'm asking because I swear I'm the definition of insanity. I tell it to get a get a new position every second, It updates to the new position correctly. I tell it to move the object to the new position, it doesnt move.

while {counter < 40} do
{
_relpos = _InterceptObj worldToModel ASLToAGL _InterceptPos;
_obj setPosASL (_InterceptObj modelToWorldWorld _relpos); //not moving for some reason
counter = counter + 1;
sleep 1;
};```
warm hedge
#

Seems like it is doing its work propely. It's just because it is moving to the same position

brave venture
#

Which make no sense, because I'm watching the new position: (_InterceptObj modelToWorldWorld _relpos) change in real time.

warm hedge
#

_InterceptObj it is?

#

Is it a moving object? If yes, I was wrong

brave venture
#

yes. _interceptobj is moving.

warm hedge
#

Also, if you wonder... always do a debug print like systemChat to check how every variables work, or even the code itself

brave venture
#

Yeah. I'm using hintsilent inside the while loop for debug. I just removed it when I posted the code for ease of understanding.

warm hedge
#

Are you sure EVERY variables are working properly?

brave venture
#

I want to say yes because I'm watching the variables change, but at the same time. Its not working for whatever reason, so IDK.
I feel like I need to go back to square one and ask: what can I use to move a simple object after its created?

bleak gulch
#

where is _InterceptPos defined?

tough abyss
#

Anyone know an easy way to replace an item located inside of vehicles to completely replace it? RACS is using a outdated galil mag and i need a script to replace it via script. Problem is, I dont even have the brains to do so and Im completely unsure of any templates out there. Anyone have a template I can use?

fair drum
bleak gulch
fair drum
bleak gulch
#

But it is two operations instead of one.

Also I recommend you to replace second loop with the engine-implemented search like find:

private _index = _magazines find _magToFind; // WAAAAY faster
if ( _index != -1) then
{
    // do replace
};

There is only one downside of this method: mag classname is case sensitive. So you need to point EXACT name of the magazine.

granite sky
#

You're probably better off reducing the number of inventory ops, like:

private _count = { _x == _magToFind } count _magazines;
_vehicle addMagazineCargoGlobal [_magToFind, -_count];
_vehicle addMagazineCargoGlobal [_magToReplace, _count];
bleak gulch
#
// Based on Hypoxic's
// Edited by Katushka
if (isServer) then
{
    // Settings
    private _magToFind = "myMagClassName";
    private _magToReplace = "myNewMagClassName";

    // Job
    vehicles apply
    {
        private _cargo = getMagazineCargo _x;
        private _index = (_cargo select 0) find _magToFind; // speed up!

        if (_index != -1) then
        {
            private _amount = (_cargo select 1) select _index;
            _x addMagazineCargoGlobal [_magToFind, -_amount];
            _x addMagazineCargoGlobal [_magToReplace, _amount];
        };
    };
};
bleak gulch
granite sky
#

Yes, but what makes you think there's only going to be one magazine of that type?

bleak gulch
granite sky
#

Ah right, getMagazineCargo is better than I thought.

bleak gulch
#
getMagazineCargo cursorTarget;

returns this for Box_IND_Ammo_F:

[["30Rnd_556x45_Stanag","20Rnd_762x51_Mag","9Rnd_45ACP_Mag","30Rnd_9x21_Mag","200Rnd_65x39_cased_Box","1Rnd_HE_Grenade_shell","NLAW_F","HandGrenade","MiniGrenade"],[24,6,6,6,3,6,1,6,6]]```
So we have 2 nested arrays. One with the classnames and another one with the amount of magz. We can iterate through the first one using engine search `find` to obtain the index and if it's not -1, then we extract the amount of the magz from the second array.
bleak gulch
fair drum
#

My homies. It was just a simple question and answer. He's probably gonna run it one time and be done lol.

exotic flame
#

setUserMFDText has global or local effect ?

tough abyss
#

thank you guys for all the help honestly

#

this is way more than i would expect out of other communities, you guys rock!

meager granite
#

but you can test it anyway

meager mist
#

Dedicated server scripters.. question for you. How do you test the performance impact of scripts? I've been trying but I still end up with performance issues sometimes from my community. Is there something like autotesting ?

#

(yes, this was because of the waitUntil part of my bomb script KEKW )

#

I've did a session with 4 people, and it was fine. But last night 20 people connected was.. different πŸ˜›

exotic flame
meager granite
#

Unless you messed something up majorly

#

In general FPS in arma declines with amount of players

meager mist
# meager granite That bomb script performance impact should be a drop in an ocean

hmm.. Then I need to investigate it more. I removed the waitUntil part and embedded 1 part in the part where it checks the code. And ran the fail task within a !alive trigger in the editor. But if it's just a drop in an ocean I have no idea what else can be the cause of our significant drops. Used GRAD Civilians, but turned that off and restarted the server, but FPS was dropping over time anyway. Figured it would be that.

meager granite
#

If that's still the same script you posted before, it should not matter at all

meager mist
#

Not even if it checks every frame?

0 spawn {
    waitUntil {caseBomb getVariable ["DEFUSED", false]};
    if(isServer) then {
        // This is global so have only server change the task state
        ["Task_Defuse", "Succeeded"] call BIS_fnc_taskSetState;
    };
    sleep 2;
    casebomb removeAction caseBombActionID;
};```
meager granite
#

waitUntil even checks many times a frame

#

Still its a drop in an ocean

meager granite
#

Ctrl+F'ed enableReload, what the hell is that? Prevents AI from reloading, but players don't care?

meager mist
#

Yea, I was either going to change the waitUntil to the above.. or omit it completely. Still, is there a way to test performance or find a culprit script to make sure this doesn't happen on a bigger playsession?

meager granite
#

Where do you have performance issues? Clients? Server? How did you figure you have these issues at all?

meager mist
#

Last night, when we ran the mission for the community (+- 20 players) the frames kept dropping from 50fps to 5fps in a span of lets say 30 minutes. Every player was reporting the same issue. To a point of unplayability and we had to abort the mission because of it. We didn't encounter these issues the week before, with the same map, loadouts, amount of players but without the 3 scripts we were running and without GRAD civilians loading in civilians for ambience.

#

We turned off GRAD Civilians off in CBA settings, repacked the mission and ran it once again hoping that would've been the issue, but then the same thing happened.

meager granite
#

No way these waitUntils can cause that

#

You probably can have 100 of them and it won't make a difference

meager mist
#

is there any way to test any of the other 2 scripts to see if they are the culprit?

meager granite
#

Post the scripts, I could say what could go wrong

#

This sudden FPS drop sounds like RPT error spam issue

#

Something errors out and spams RPT non-stop and disk writing tanks the FPS

#
for "_i" from 1 to 1000 do {
    0 spawn { 
        waitUntil {player getVariable ["DEFUSED", false]};
    };
};
```1000 never ending threads spawned with 0 delays, FPS went from 200 to 180 on empty mission
#

Honestly surprised it even dropped this much πŸ€”

meager mist
meager mist
hallow mortar
#

You can also do this (increasing FPS drop over time) by doing unscheduled iteration on an array that continually increases in size and is never cleaned up

#

Ask me how I know

still forum
still forum
meager granite
#

Maybe it was while instead or something, don't do much scheduled scripts nowadays

still forum
#

Yeah while would

meager granite
still forum
#

While without sleep is deadly.
Because it will run it till the 3ms limit.
Once it enters such a loop, all other scheduled scripts after that one, won't get a chance to run this frame and game happily wastes it's time running that loop that probably does nothing

winter rose
#

(no chance to fix that btw?)

meager granite
#

Should it even be fixed? Sounds like proper behaviour and makes it distinct from waitUntil

cyan dust
#

Yeah, like you'll get the same with some other 'more mature' languages like python. Just know what you're doing

meager mist
hallow mortar
#

Use < > around a link to suppress the preview card

meager granite
meager mist
#

I apologies in advance for the terrriiiible shit you're about to see :p

meager granite
#

Other than that I don't see anything wrong

#

No idea what that ACE/ACRE stuff does

meager mist
meager granite
#

script contents

meager mist
#

the ACRE stuff has been there for ages, always ran those. They set our radios to the correct naming instead of frequencies.

still forum
meager mist
#

It's in the last pastebin, searchAction.sqf is listed from line 42 and defuse is done in fn_codeCompare.sqf on line 13

meager granite
meager granite
meager mist
#

meowsweats

createDialog "KeypadDefuse";
meager granite
#

Just that?

#

You can have script right inside addAction btw

meager mist
#

yea.. thats what I'm thinking now as well. wtf

meager granite
#
player addAction ["Action", {systemChat "action!"}];
#

its A3 thing, your script is probably from back in the day

meager mist
#

It is, 2014 :p

still forum
meager mist
#

That's why I intend to make this my project to understand scripting. Seems like a good one to fix

meager granite
meager granite
meager mist
#

I can share the .hpp if you'd like.

bleak gulch
meager granite
#

No other scripts but that display config?

meager granite
#

Sudden drops sound like error spam

meager granite
bleak gulch
#

also keep in mind Scheduler has overhead

#

when it switches between the threads it eats performance even if your scripts have zero payload

#

BIS' OldMan is a good example of performance degradation

#

related to spawning thousands of spawned scripts

#

and HIG too (AI cannot see through the grass mod)

#

FSMs also affect performance badly because they are executed in unscheduled environment

#

it means if you have a lot of AI they will blow your server up

#

teh reason why ppl try to move AI away from the Dedi to the Headless Client(s)

#

That massive performance degradation is not related to single waitUntil even if it doesn't have a sleep.

#

As a test you can turn eveything off, even disable CBA and test empty map

meager mist
# meager granite Also check RPT after FPS tanks

So, when looking at the RPTs .. I have 3 messages that come up very frequently.. with this one being the majority.
12:31:05 Server: Object 6:21 not found (message Type_463) <-- this one has multiple variations with numbers
then:
12:11:08 Setting invalid pitch 0.0000 for B Bravo 1-1:23 REMOTE
12:29:46 Server: Network message 1151ff4 is pending T_465
When i search the first one on google, I often see "Don't worry about them.."

meager granite
#

These are usual errors, yes

meager mist
#

The last one, I understand.. it's because of the server setting and actually the server is overloaded with messages

meager granite
#

Check for script errors

#

Error in expression

winter rose
bleak gulch
#

how big is your .RPT file?

#

100 KiB, 1 MiB, 10 MiB, 100 MiB?

meager mist
bleak gulch
#

hm

#

it doesn't look like it was spammed

meager granite
meager mist
meager granite
#

Not scripting error spam then

#

Post your dialog config just for the sake of it

bleak gulch
hallow mortar
#

I'm a bit suspicious of that beeping sound creator tbh, I know you've got that max in there which should be a safety, but I've seen in the past a case where something doing proximity-based frequency of playSound3D got out of control and annihilated the server. Wasn't my mission so I don't know exactly where it went wrong though unfortunately.

meager mist
meager granite
meager mist
meager granite
meager mist
little raptor
#

It prevents reloading when mag is empty I think?

meager granite
#

Was looking for a way to stop player from reloading without magazine deletions

bleak gulch
#

well

#

the problem can be anywhere, ACE, ACRE...

#

As I understand the FPS loss scales with the number of the players, so it is something related to their interaction

meager granite
#

Maybe a player joins with a mod you don't know about and breaks everything for everyone

bleak gulch
#

ya ^

#

also

meager mist
#

We don't allow clientside mods though.

#

So that has to be a server mod as well then.

#

Its worth testing it out without the tracker script. To make sure it's not the thing Katushka said

meager granite
#

Btw, how do you call your bombTimer script?

winter rose
#

Jim

meager mist
meager granite
#

Post exact trigger setup

meager mist
#

300 being the time that the timer runs for (5minutes)

#

one sec. Gotta boot up then

bleak gulch
#

make new monitor script, something like this:

if (isServer) then
{
    while {true} do
    {
        {
            diag_log _x;
        } forEach
        [
            format ["[BEAR_TEST] diag_frameNo: %1", diag_frameNo],
            format ["[BEAR_TEST] diag_fps: %1", diag_fps],
            format ["[BEAR_TEST] allMissionObjects: %1", count allMissionObject ""],
            format ["[BEAR_TEST] holders: %1", (count (allMissionObjects "GroundWeaponHolder")) + (count (allMissionObjects "WeaponHolderSimulated"))],
            format ["[BEAR_TEST] diag_fps: %1", allUnits],
            format ["[BEAR_TEST] diag_fps: %1", allGroups]
        ];
    
        sleep 2;
    };
};
etc
#

you need to monitor these vars:

private _activeScripts = diag_activeScripts;

count allUnits, count allGroups, count vehicles, count allDead, count allDeadMen, count agents, _activeScripts select 0, _activeScripts select 1, _activeScripts select 2, _activeScripts select 3, _diagFPS toFixed 1
meager granite
#

allMissionObjects during gameplay is a bad idea, guaranteed micro freeze

bleak gulch
#

yes I know, but in debug session it's acceptable IMO

meager granite
#

Perhaps. Running that logEntities after FPS tanks could be useful too

meager mist
#

Trigger setup:

#

I guess for the logEntities to be succesfull I'll have to play through it and make it happen, if it even does.

bleak gulch
#

also if you have debug console you may.... ehm πŸ˜„

meager granite
#

Hmm, looks alright except that bomb timer is local and each player will have their own 300 seconds

bleak gulch
#

you can make surgery on the fly on the server side πŸ˜„

meager granite
#

I don't use editor triggers much to say if this one could go wrong or run player count ^ 2 times

meager mist
#

just to be aware: this trigger was not activated when FPS dropped.

bleak gulch
#

remove all EachFrame EHs via debug console for the server

#
if (isServer) then
{
    removeAllMissionEventHandlers "EachFrame";
    onEachFrame {};
};

It will break the mission completely but you have to check FPS

#

right after executing

meager mist
#

I'll run the dedi server and do that. one sec

#

It gives me some gain, not much though. Maybe 8 to 10 fps.

bleak gulch
#

hm

#

how much FPS did you have before executing the script?

#

8-10 FPS if you had 40 is a lot

meager mist
meager mist
bleak gulch
#

Okay. Just keep in mind probably the FPS loss scales with the number of the players and it's related to EachFrame EH somehow

#

maybe yes maybe no

meager mist
#

yea.. I currently have no other way of testing it with large numbers I guess

#

Tell my girlfriend I need her PC for a couple hours :p

meager granite
#

Is there absolutely no way to tell if remote unit is being remote controlled by player?

#

remoteControlled only works where remote controlling player is local

cyan dust
meager granite
#

Yeah, guess I gotta start tracking that with scripting

bleak gulch
#

@meager granite
(unit in allPlayers) ?

#

or playableUnits

#

also cameraOn may help

#

nvm it's local

#

focusOn introduced in 2.16 but I never tried it. Probably also local and doesn't meet your requirements.

#

isPlayer (global)

#

so if unit is not in playableUnits or allPlayers but isPlayer - it's probably under control of some player?

#

need to test πŸ™‚

meager granite
#

isPlayer returns false for remote controlled units

finite bone
#

I see that ace_fire_fnc_burn no longer exists in the repository - how do I go on about adding fire damage to units? Is it now standardized to ace_medical_fnc_addDamageToUnit?

meager mist
granite sky
#

Do the performance problems always correspond with the network message pending warnings?

meager mist
#

We had this issue once before, so I can check. But this was the first time we ever had to cancel a mission. So I can't confirm nor deny that

granite sky
#

Network message pending is pretty bad IME. Can be caused by excessive publicVariable spam or similar. Not sure exactly what it means though.

hallow mortar
#

It can also happen (and destroy the server) if a particular client has a really bad connection

#

high packet loss > lots of guaranteed messages failing to complete ("pending" until they finally get through) > server go crunch

meager mist
granite sky
#

Not sure I saw any relevant evidence.

meager mist
#

Evidence of spam you mean? Or to say clearly that there is no public variable spam.

#

Could still be something within the editor no? That is not linked to the scripts.

manic flame
#

Is there a way to prevent Zeus Virtual entities from triggering the Dynamic Simulation wake up?

silent comet
#

In theory this should stop the unit from triggering the Dynamic Simulation

tranquil pendant
#

Quick one, Is it possible for gun pods to have ballisticsComputer as one of their variables and for it to work? Looking to implement some goofy stuff on jets pylons

drowsy geyser
#

i have a problem if i run the following in debug consol the code does not work (does not toggle between single and fullauto mode):

0 spawn  
{  
    disableSerialization;  
    waituntil {!isnull (finddisplay 46)};  
    (findDisplay 46) displayAddEventHandler ["KeyUp",  
    {  
        params ["_display", "_key", "_shift", "_ctrl", "_alt"];   
        if (_key == 33) then // 'F' key 
        {  
            if (currentWeaponMode player == "Single") then 
            { 
                player selectWeapon [currentWeapon player, currentWeapon player, "FullAuto"];
                hint "switched to fullAuto-Mode";
            } 
            else
            { 
                player selectWeapon [currentWeapon player, currentWeapon player, "Single"]; 
                hint "switched to single-Mode"; 
            }; 
        };
    }]; 
};

however if i run the below without the keyUp eventhandler it works:

if (currentWeaponMode player == "Single") then 
{ 
    player selectWeapon [currentWeapon player, currentWeapon player, "FullAuto"];
    hint "switched to fullAuto-Mode";
} 
else
{ 
    player selectWeapon [currentWeapon player, currentWeapon player, "Single"]; 
    hint "switched to single-Mode"; 
};
drowsy geyser
#

okay weird i solved it now like this:

0 spawn  
{  
    disableSerialization;  
    waituntil {!isnull (finddisplay 46)};  
    (findDisplay 46) displayAddEventHandler ["KeyUp",  
    {  
        params ["_display", "_key", "_shift", "_ctrl", "_alt"];   
        if (_key == 33) then  
        {  
            if (currentWeaponMode player == "Single") then 
            { 
                player selectWeapon [currentWeapon player, currentWeapon player, "FullAuto"];
                hint "switched to fullAuto-Mode";
            }
            else
            {
                if (currentWeaponMode player == "FullAuto") then 
                { 
                    player selectWeapon [currentWeapon player, currentWeapon player, "Single"];
                    hint "switched to single-Mode"; 
                };
            };
        };
    }]; 
};
#

just a note i have created a top down camera and that's why the keybinds are not working so i must add them manually:(sorry for confusing)

bleak gulch
#

if you need switch it is better to use switch

#

as for the key binds, F is strafe right for me πŸ™‚ I play ESDF as Rapha.

drowsy geyser
#

ah okay i guess i will change it to
addUserActionEventHandler ["nextWeapon", "Deactivate",{..

bleak gulch
#
switch (currentWeaponMode player) do
{
    case "Single":
    {

    };

    case "FullAuto":
    {

    };
};```
wind hedge
unreal wharf
#
if (hasInterface) then
{
    this addAction [
        "Take Sample",
        { [_this, "action"] spawn BIS_fnc_initIntelObject },
        [],
        10,
        true,
        true,
        "",
        "isPlayer _this && { _this distance _target < 10 } &&
        { (side group _this) in (_target getVariable ['RscAttributeOwners', [west, east, resistance, civilian]]) }",
        5
    ];
};

I'm using this as part of an intel item script. I need to modify this to also include a function for deleting a unit. The unit is different from the intel item.

#

I'm unsure as to where I should insert the deleteVehicleCrew function, or if it would be possible to add it into this same addAction function.

unreal wharf
#

Or rather than deleteVehicleCrew, using setDamage.

Is it possible to have two different scripts as part of the same action added by addAction?

#

Managed to come up with a solution myself.

if (hasInterface) then 
{ 
 this addAction [ 
  "Take Sample", 
  { testTarget1 setDamage 1;
   [_this, "action"] spawn BIS_fnc_initIntelObject;
  }, 
  [], 
  10, 
  true, 
  true, 
  "", 
  "isPlayer _this && { _this distance _target < 10 } && 
  { (side group _this) in (_target getVariable ['RscAttributeOwners', [west, east, resistance, civilian]]) }", 
  5 
 ]; 
}; 

testTarget1 just being the placeholder for whatever name given to a unit. Will work if unit in question has 'show model' turned off, and simulation disabled.

spring stone
#

I still need help!

wind hedge
#

Is there a way to detect if an ai unit is aiming down sights and force it to fire from the hip?

warm hedge
#

They don't have such state

cedar kindle
#

@spring stone check the arguments for removeAction

#

it takes <object> removeAction <id>

#

so try [objectName, ID1] remoteExec ... -

spring stone
#

Ahhh okay, I'll try thatso in front of the remote exec I put every argument in chronological order? (Just so I finally understand remoteExec)

cedar kindle
#

afaik yes

spring stone
#

ahhh that makes it easier to work with it! :3 thanks!

proven charm
#

i wonder why the player in OnUserSelectedPlayer is sometimes null?

sharp grotto
proven charm
#

hmm ok thx i read that but didnt know it meant null players

sharp grotto
#

Just a guess tho blobdoggoshruggoogly

proven charm
#

i thought the event fires once it has found non-null player πŸ™‚

#

somehow missed this from the wiki: "From Arma 3 v2.18 the server will pospone this event until the object is not null"

#

so they are going to change its behaviour

finite bone
#
Set rendering distance. Setting view distance to >= 0 resets the value to the client's options (set in Options β†’ Video β†’ General β†’ Visibility β†’ Overall).``` Seems like a typo in the wiki ``setViewDistance``
proven charm
finite bone
#

A simple >=0 to be changed to <=0

proven charm
#

or < 0

finite bone
#

1 you mean (since 0 also resets?)

#

or does setting it 0 make it actually 0

proven charm
#

negative value resets, like -1 for example. i dont know about zero

sullen trellis
#

how do i make this to only activate by a specific classname?

player addEventHandler["Dammaged",{ 
 
if (typeof _x isEqualTo "O_Soldier_A_F") then { hint "hit";}; 
}];
proven charm
finite bone
#

replace _x with _this select 0

finite bone
finite bone
#

does the "Dammaged" handler exist?

sullen trellis
#

yes, it works on all units attacking player, but i cant make it only specific classname

#

i have a scenario where there are roaming tiger units, if a player is attacked by a tiger it runs a bleeding script

finite bone
#

These are the parameters inside the eventHandler - params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];

#
player addEventHandler["Dammaged",{
params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
if (typeof _unit isEqualTo "O_Soldier_A_F") then { hint "hit";}; 
}];
sullen trellis
finite bone
#

why dont u run sqf hint typeOf _unit and see what it prints

sullen trellis
#

no results so far

finite bone
#

have you checked if the event handler works without checking the class name?

sullen trellis
#

yep like this it works
player addEventHandler ["Dammaged", {
hint "hit";
}];

finite bone
#

ok then try to get the classname inside - sqf player addEventHandler["Dammaged",{ params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"]; hint format ["Classname: %1", typeOf _unit]; }];

austere nymph
#

Hello chaps, why can't I remove the GPS from the player in a SP mission. It keeps reappearing at launch despite removing it from the inventory and running
this UnlinkItem "ItemGPS"; Any idea ?

proven charm
#

are you running that in the unit init?

austere nymph
#

yep

#

I should add I'm running ace

little raptor
austere nymph
#

Its a DLC unit (SPE) with some modded items

#

Screenshot

#

5 seconds in the items repop back into his inventory at mission start

warm hedge
#

Likely because a Mod is doing it

sullen trellis
austere nymph
#

Would listing the remove item in the InitLocalPlayer.sqf be the way?

spring stone
#

Mhhh doesn't work in my case. Is it still, that I give my addaction an ID like this:
ID = [arguments] remoteExec ..... ?

sullen sigil
#

no just delay removal

warm hedge
#

Or remove the faulty Mod/script

austere nymph
#

I added a trigger 5 seconds into the mission with the necessary removal sqf - Nuked the bugger! No Gps in 1944!

inland iris
#

again its odd that a mod would purposfully add a gps to players

#

but I guess mods are weird sometimes

split nebula
#

most likely the ID won't correspond with the action id on the client if you target more than 1 machine with the remoteExec

proper sigil
#

Had anyone encountered this bizzare problem, where on dedicated server initPlayerLocal.sqf would not launch at all? Tested locally and it does work as intended. Also it was working previously and I did no significant changes to the code yet it seems like it does not launch at all. Even added a diag_log at the very beginning of it and there is not trace of it in RPT file. Like the file is skipped

#

Added waitUntill as well, that's basically 1-st two lines of the code


waitUntil {local player && {getClientStateNumber > 8}};```
proven charm
#

is it in the right folder (root)? checked the name?

#

wait its not supposed to be launched in dedi, only on client

proper sigil
#

Yes, but it does not launch at all which is weird as it did a version or two back. I'm pretty sure file is where it's supposed to be and I don't see any errors. File should launch as player inits on server yet it seems to be completely ignored. Also tested the scripts that are supposed to fire via this file and they all work fine.

proven charm
#

are you checking the logs in right place? diag_log in this case would log to the client machines log file

proper sigil
#

AAaaaah, okay I totally didn't think of that

spring stone
#

So I should use the actual ID? (0,1,2,3....) (This is most likely the last thing that needs to be done to have my script functional T^T)

proper sigil
#

Thanks gencoder8, learned something new today, I'll investigate RPTs and eventually I'll figure it out I hope

austere nymph
inland iris
#

its probably not ace

#

but if you re using a 3cb units they sometimes load in to the misison with the prebuilt loadouts

austere nymph
#

But that's the thing - the mission starts fine and then boom it appears ...

unreal wharf
#

If using 3CB, don’t use 3CB units when doing custom loadouts, either for player or for enemy unifs. The randomization will sometimes just nullify what you want.

austere nymph
#

I'm not

#

these are SPE units

finite bone
#

can you use switch to run cases against distance checks as mentioned in example 4? I'm trying to use switch to run based on the distance between the unit and an object.

hallow mortar
#

You can use switch to run checks against anything that evaluates to a bool:

switch true do {
  case ((_obj distance _unit) < 10) : {
finite bone
#

aight cool thanks

silent comet
#

Any way to forbid an unit from going prone? Or to enforce a specific stance? I did some digging, but only found a way to check the stance

granite sky
junior moat
#

is it possible to detect when music ends? at the start of my mission i have it play some intro music which lasts for about 2 mins. is there any way besides using sleep to play some ambient sounds directly after the intro music ends?

#
if (hasInterface == true) then {
    _intro = 0 spawn {
        playMusic "FalklandsSongIntro";
        100 cutText ["<t color='#ff0000' size='5'>East Falkland Islands, 1982</t><br/><t size = '2'>3km North of Goose Green</t>", "BLACK OUT", 1e-6, false, true];
        sleep 9;
        100 cutText ["<t color='#ff0000' size='5'>East Falkland Islands, 1982</t><br/><t size = '2'>3km North of Goose Green</t>", "BLACK IN", 3, false, true];
        sleep 1;
        playMusic "FirefightAmbience";
    };
};
```i was hoping this would work but it doesnt seem to.
indigo wolf
#

How do I supply default values to params?

junior moat
winter rose
indigo wolf
#

cool thx mate

little raptor
# junior moat how would that look?
addMusicEventHandler ["MusicStop",
{
    params ["_music", "_id"];
    if (_music == "FalklandsSongIntro") then {
       playMusic "...";
       removeMusicEventHandler ["MusicStop", _id];
    }
}]
little raptor
junior moat
#

anyway ill try that event handler now, much thanks o7

acoustic abyss
#

Is there an invisible dummy object that you can apply BIS_fnc_holdActionAdd to?

drowsy geyser
finite bone
#

or uncheck 'Show Model'?

drowsy geyser
#

Its shadow Would still be visible

finite bone
#

You can use invisible helpers, walls, helipads, (or even a tiny cellphone) since the function can be customized to extend the range at which it can be triggered by a player.

junior moat
#

right i cant seem to figure out why this wont work

Description.ext:

class CfgMusic
{
    tracks[] = {};
    class FalklandsSongIntro
    {
        name    = "Falklands War Song";
        sound[]    = { "\Sounds\Music\falklands_war_song.ogg", db + 0, 1.0 };
    };
    
    class FirefightAmbience
    {
        name    = "Firefight Ambience";
        sound[]    = { "\Sounds\Ambient\distant_firefight.ogg", db + 0, 1.0 };
    };
};

fn_introMusic.sqf:

if (hasInterface == true) then {
    _intro = 0 spawn {
        playMusic "FalklandsSongIntro";
        addMusicEventHandler ["MusicStop",
        {
            params ["_music", "_id"];
            if (_music == "FalklandsSongIntro") then {
                playMusic "FirefightAmbience";
                removeMusicEventHandler ["MusicStop", _id];
            }
        }];
        100 cutText ["<t color='#ff0000' size='5'>East Falkland Islands, 1982</t><br/><t size = '2'>3km North of Goose Green</t>", "BLACK OUT", 1e-6, false, true];
        sleep 9.5;
        100 cutText ["<t color='#ff0000' size='5'>East Falkland Islands, 1982</t><br/><t size = '2'>3km North of Goose Green</t>", "BLACK IN", 3, false, true];
    };
};

but this doesnt work for whatever reason

acoustic abyss
# finite bone or uncheck 'Show Model'?

Unchecking "Show Model" disables collisions, and interactions. Because the object I want players to interact with (a satellite dish) is on top of a building, placing an extra object looks out of place. Sign_Sphere200cm_Geometry_F seems to work. PS Appreciate you taking the time.

gaunt tendon
#

hi, pls help

I got my addon config.cpp

class CfgPatches
{
    class CONAN_UAV
    {
        name = "CONAN UAV";
        author = "CONAN";
        url = "";
        requiredVersion = 1.60; 
        requiredAddons[] = {"A3_Functions_F"};
        units[] = {};
        weapons[] = {};
    };
};

class CfgFunctions
{
  class CONAN_UAV
    {
    file = "\CONAN_UAV\Functions";
    class preInit { postInit = 1; };
    class main_Init {};
    class grainFX_Init {};
  };
};

and my folders like this

#

this is my fn_preInit.sqf

//----------------------------------------------------------
diag_log "=================== UAV LOADED ===================";

G_UAV_Action_ID = player addAction ["Drone Support", CONAN_UAV_fnc_main_Init, nil, -99, FALSE, TRUE, "", format ["G_UAV_bCanUse and %1", G_UAV_UseCond]];

G_UAV_Killed_EVH = player addEventHandler ["Killed", {
  player removeAction G_UAV_Action_ID;
}];

G_UAV_Respawn_EVH = player addEventHandler ["Respawn", {
  G_UAV_Action_ID = player addAction ["Drone Support", CONAN_UAV_fnc_main_Init, nil, -99, FALSE, TRUE, "", format ["G_UAV_bCanUse and %1", G_UAV_UseCond]];
}];
//----------------------------------------------------------

my problem is that, when I go check the rpt file after testing, the line
"=================== UAV LOADED ==================="
is not there...

hallow mortar
#

You're missing a layer in your cfgfunctions

#

It should go like this:

class cfgFunctions
{
    class tag
    {
        class category
        {
             class function1 {};
        };
    };
};```
You're missing either the tag or category layer, depending on how you look at it
gaunt tendon
#

thanks : D

class CfgFunctions
{
  class CONAN_UAV
  {
    class CONAN_UAV_scripts
    {
      file = "\CONAN_UAV\Functions";
      class preInit { postInit = 1; };
      class main_Init {};
      class grainFX_Init {};
    };
  };
};

this look ok?

hallow mortar
#

Yes, although it makes me very sad that your function is called preInit but runs on postInit

junior moat
#

or well, at all.

hallow mortar
#

You could just call the category layer "scripts" btw, it's already within the CONAN_UAV tag so it won't conflict with any other "scripts" category outside of that

indigo wolf
#

i have two functions, function 1 creates an object and function 2 is supposed to delete the last created object. how do i do this?

gaunt tendon
#

@hallow mortar

pls helpπŸ₯Ί
I'm getting this

19:49:11 Warning Message: Script \CONAN_UAV\Functions\fn_playerInit.sqf not found
19:49:11 Warning Message: Script \CONAN_UAV\Functions\fn_main_Init.sqf not found
19:49:11 Warning Message: Script \CONAN_UAV\Functions\fn_grainFX_Init.sqf not found

warm hedge
#

Make sure your pboprefix is correct

gaunt tendon
warm hedge
#

No

gaunt tendon
#

...mmmm

warm hedge
#

I forget how you can check in PBO Manager but IIRC somewhere in Edit

gaunt tendon
#

aaah
this it?

warm hedge
#

Okay that's pretty wrong

gaunt tendon
#

yup... how do I change it?

warm hedge
#

It does mean your file is recognized as addons\Functions\fn_main_init.sqf

#

How do you pack PBO

gaunt tendon
#

pbo builder from a3 tools

warm hedge
#

Addon Builder you mean?

gaunt tendon
#

ah yes

#

Im gonna test with this πŸ™‚

warm hedge
#

OPTIONS > Addon prefix

gaunt tendon
finite bone
hallow mortar
hallow mortar
finite bone
#

What version are we now πŸ˜…

hallow mortar
#

2.16

finite bone
#

ah ok

indigo wolf
#

oh lemme try that thanks

gaunt tendon
#

is it normal my a3 publisher freezes up like this?

warm hedge
#

Somehow yes, if it's the first publish

gaunt tendon
#

aaah
ok, i'll just let it finish then
ty

warm hedge
#

No it's already finished

#

You can confirm in your Workshop, if it's done properly, you can close Publisher safely

gaunt tendon
#

yup, they're there... duped... πŸ’€

finite bone
#

Someone help me with the logic:
I want to run a code inside a while loop every 5 seconds using diag_tickTime

bleak gulch
granite sky
#

Why would you use diag_tickTime for that?

finite bone
#

Is there a better alternative

granite sky
#

sleep is usually fine.

#

If it's not then you have far too much scheduled shit running.

finite bone
#

Theres already an existing code that runs based off of diag_tickTime

granite sky
#

That doesn't seem like a good argument.

#

What's it doing in between diag_tickTime checks anyway? eachFrame or what?

finite bone
#
 private _acefireFX = 
        {
            private _firePos = getPos _this;
            private _endTime = diag_tickTime + 20;
            while { diag_tickTime < _endTime } do {
                uiSleep 0.5;
                {
                    private _distanceFromTanker = (vehicle _x) distance2D _firePos;
                    private _unit = _x;
                    private _burndmg = 0;
                    switch true do {
                        case (_distanceFromTanker <= 50) : {_burndmg = 10};
                        case (_distanceFromTanker <= 75) : {_burndmg = 5};
                        case (_distanceFromTanker <= 100) : {_burndmg = 3};
                        case (_distanceFromTanker <= 125) : {_burndmg = 1};
                        case (_distanceFromTanker <= 150) : {_burndmg = 0.3};
                        default {_burndmg = 0};
                    };
                    [_x, _burndmg] remoteExec ["ace_fire_fnc_burn", _x];
                    [_x, _burndmg, "Head", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
                    [_x, _burndmg, "RightLeg", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
                    [_x, _burndmg, "LeftArm", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
                    [_x, _burndmg, "Body", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
                    [_x, _burndmg, "LeftLeg", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
                    [_x, _burndmg, "RightArm", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
                } forEach allUnits;    
            };
        };```
granite sky
#

well, that's horrifying

bleak gulch
#
private _future = 0;

while {true} do
{
    // Payload. Executes every ~1 second.
    // ------------------------
    // ...
    // ------------------------

    if (diag_tickTime >= _future) then
    {
        _future = diag_tickTime + 5;

        // Payload. Executes every ~5 seconds.
        // ------------------------
        // ...
        // ------------------------
    };

    sleep 1;
};
granite sky
#

That's even worse.

bleak gulch
#

wtf? remoteExec ......

granite sky
#

This clearly isn't critical code that actually needs to run precisely on 5 seconds, so just sleep 5. And then don't fire off seven remoteExecs to the same client.

bleak gulch
#

whoah that performance hit

finite bone
#

its still needs work flushed out yes - im trying to get the core idea down before thinking about performance

bleak gulch
granite sky
#

The core principle for this sort of code is performance. Otherwise you end up with abominations like Bloodlust :P

finite bone
#

And yes, that remoteExec on allUnits should not exist

bleak gulch
#

If you need to broadcast shit, it's better to create one function instead of calling it 7 times

#

switch {true} do replace with call-if-exitWith

granite sky
#

best part, it does the full remoteExec spam even if the unit is >150m away.

bleak gulch
#

is it possible to make the checks local?

#

similar loop but players run it locally for them and their subordinates

granite sky
#

That would be a good starting point.

bleak gulch
#

also use ternary operator instead of switch {true} do:

private _burndmg = call
{
    if (_distanceFromTanker <= 50) exitWith {10};
    if (_distanceFromTanker <= 75) exitWith {5};
    0; // default
};
#

kind of

int x = <condition> ? 10 : 5;

in C++

bleak gulch
# granite sky best part, it does the full remoteExec spam even if the unit is >150m away.

It sends 7 remoteExecs per unit instead of 1 per machine every 0.5 seconds (WHAOW). And it keeps spamming even there is nothing happening (switch hits default value). If you have 100 units it's 7 * 100 / 0.5 = 1400 remoteExecs per second :)))))) DATS GUD.

@finite bone
I'd recommend you:

  1. If it's on the server - call remoteExec ONCE per remote machine to notice clients that they should start the local loop. Process the local to the server units as it's a client.

  2. Client should process their local units without spamming to the network. And stop the loop if there is nothing to process. Wait for the server's next remoteExec.

fair drum
#

wouldn't alt syntax of select be closer to a ternary?

#
[10,5] select (condition)
past dagger
#

y'all know how to make a delay on a waypoint? for example if a patrol makes it to the waypoint I would want them to wait 40 seconds then take off to the next

past dagger
fair drum
bleak gulch
meager mist
# bleak gulch did you find the root of the problem?

Not with any definite proof. I’ve ran the mission with 6/7 people to test it out, let them roam and do stuff , even dropped a bike at the end and no change. Ran it on my own dedi server with 9 clients open and no change… nothing in the logs or anything that indicates it.. so no idea.

#

So I might just run it again this Thursday and have a backup mission ready without the scripts and civilians module

#

Somebody mentioned about the memory allocator on the server .. or server settings in general. But no idea what to change on that, or how. The guy that used to do that for us is kinda awol

cyan dust
meager mist
meager mist
#

hmm.. looking into the mission once again.. I've overlooked one error that pops up at initialization.. but not sure if this could be the issue. I have these barrels with m112 explosives attached and used the following to attach them : [this, barrel_5] call BIS_fnc_attachToRelative; but on load, I get [BIS_fnx_attachToRelative] Error: type ANY, expected object, on index 1, in [437691: rhsusf_m112x1_e.p3d,any] as an error that stays there for a second or 2. Could that be it? I got 9 barrels, and 4 explosives attached to it, leading to 36 of them. Is it trying to attach it and not able to because of this error? Overtime making it too many requests for the server?

#

Something else, I omitted the two functions in the init.sqf that have the waitUntil and embedded them into another part of code. Would this be a better way of doing it?
The task succeeded is now within fn_codeCompare.sqf:

//Parameters
private ["_code", "_inputCode"];
_code      = [_this, 0, [], [[]]] call BIS_fnc_param;
_inputCode = [_this, 1, [], [[]]] call BIS_fnc_param;

//compare codes
private "_compare";
_compare = [_code, _inputCode] call BIS_fnc_areEqual;

if (_compare) then {
    cutText ["BOMB DEFUSED", "PLAIN DOWN"];
    caseBomb setVariable ["DEFUSED", true, true];
    if (isServer) then {                                                
        ["Task_Defuse", "Succeeded"] call BIS_fnc_taskSetState;      ///The task success code is now here
    };
        casebomb removeAction caseBombActionID;                          ///The removal of the action to not be able to defuse again is now partly here
} else {
    cutText ["BOMB ARMED", "PLAIN DOWN"];
    caseBomb setVariable ["ARMED", true, true];
    playSound "button_wrong";
    casebomb removeAction caseBombActionID;
};

CODEINPUT = [];

//Return Value
_code```

The task fail is now set on a trigger with a `!alive caseBomb;` condition, same trigger that terminates the tracker script
pulsar bluff
#

Is there any way to detect that Zeus has an item selected from the list but has not yet placed it?

#

"curatorSelected" command works for already-placed

#

but not sure how to detect that Zeus has an object selected (but not yet spawned)

slow hare
meager granite
#

Could be setTimeMultiplier but also scripted continous skipTime

bleak gulch
# meager mist hmm.. looking into the mission once again.. I've overlooked one error that pops ...

barrel_5 is undefined. Are you sure the name of the variable is correct in that script? Even with that script error it should not impact so badly. It's definitely something else. Next time try to dump everything related to the perfomance / resources. count all objects, vehicles, scripts running, units. As a test at the very end of the mission when the objectives will be finished, delete all vehicles from the map, remove EachFrame handlers. It will f..k the mission up but you can measure the FPS.

meager mist
bleak gulch
#

barell_5 is a name of the object. Literally your barell's name. Probably it's barell5 or something else. Make sure it's actually barell_5 πŸ™‚

meager mist
#

I will check all the barrels again because I have barrel 1 to 9 with 4 explosives on them. Just making sure. Otherwise I'll get rid of them, it's just ambience anyway and I can use just barrels.

bleak gulch
#

I'm not 100% sure if your object defined AFTER the init code referring to it executed the game probably will throw an error. Gonna check right now.

#

But it's kinda lame...

#

fortunatelly it works fine:
2 objects were placed in the editor rock_1 and rock_2

// rock_1 init field
diag_log (format ["[rock_1] rock_1: %1 | rock_2: %2 | this: %3", rock_1, rock_2, this]);

// rock_2 init field
diag_log (format ["[rock_2] rock_1: %1 | rock_2: %2 | this: %3", rock_1, rock_2, this]);

.RPT

 9:37:32 "[rock_1] rock_1: rock_1 | rock_2: rock_2 | this: rock_1"
 9:37:32 "[rock_2] rock_1: rock_1 | rock_2: rock_2 | this: rock_2"

Seems good. rock_1 init field code reffers to rock_2 (and vice versa) which is defined AFTER rock_1. But the things didn't mess, so the game inits object variables before the init scripts are executed.

False alarm.

#

so, you have to ensure the barrels are named correctly. Anyway it's minor issue. Probably it may be not related to your mission but to some other addon like ACE, ACRE, CBA or even to the game engine.

meager mist
wind sapphire
#

while {true} do {uiSleep 5; your_code_here};

formal pasture
#

anyone know how I could make a rally point system? squad leader drops his backpack (or some sort of item) and players can spawn on it?

drowsy geyser
#

how would i combine two keys? im doing the below but it does not work: (pressing W and D key at the same time to play the action)

0 spawn 
{ 
    disableSerialization; 
    waituntil {!isnull (finddisplay 46)}; 
    (findDisplay 46) displayAddEventHandler ["KeyDown", 
    { 
        _this spawn 
        { 
            params ["_display", "_key", "_shift", "_ctrl", "_alt"];  
            if (_key == 17 && _key == 32) then 
            { 
                player playActionNow "SlowRF";    
            };
        }; 
    }];
};
stable dune
proven charm
#

_key cant be two keys at the same time

drowsy geyser
#

so how would I combine them?

cyan dust
#

Does anyone know an easy way to open 3DEN-like vehicle customization (color and 'visible parts' selection) ?

proven charm
#

and you need keyUp EH too

#

which keys you need to check?

drowsy geyser
#

if W and D keys are pressed

stable dune
#

W & D

proven charm
#

oh sorry i forgot x)

drowsy geyser
cyan dust
# drowsy geyser so how would I combine them?

What I can think of is something like

  1. EventHandler for KeyDown - add key to your global array, call your script that would check that array contains what you are expecting and run logic if that is the case
  2. EventHandler for KeyUp - remove key from array
#

No need for spawn and etc. Just two event handlers

bleak gulch
# stable dune W & D

u need something like flag register for the keys and check the register each time the keydown/up fired

stable dune
bleak gulch
#
  1. keyDown fired on key1
  2. add DIK to the array
  3. check if we have to process the key register
  4. keyDown fired on key2
  5. add DIK to the array
  6. check if we have to process the key register. Yes if combo found
  7. key1 is up - remove the DIK from the register
#

oh it was another person

bleak gulch
#
currentlyPressedKeys = [];

// keywDown EH:
// ----------------
if !(_key in currentlyPressedKeys) then
{
    currentlyPressedKeys pushBack _key;
};

if ((DIK_W in currentlyPressedKeys) && (DIK_D in currentlyPressedKeys)) then
{
    // Your code
};
// ----------------

// keyUp EH
// ----------------
currentlyPressedKeys = currentlyPressedKeys - [_key];
// ----------------

You can go even further using hash maps or array with preallocated elements and save the performance because you don't need to reallocate memory for currentlyPressedKeys each time the key released.

#

you can use global vars for your keys

keyStatus_W = false;
keyStatus_D = false;

// keyDown EH
// ----------------
switch (_key) do
{
    case DIK_W: {keyStatus_W = true;};
    case DIK_D: {keyStatus_D = true;};
};

if (keyStatus_W && keyStatus_D ) then
{
    // Your code
};
// ----------------


// keyUp EH
// ----------------
switch (_key) do
{
    case DIK_W: {keyStatus_W = false;};
    case DIK_D: {keyStatus_D = false;};
};
// ----------------

But I prefer to use registry, it's faster and more convenient. In this case DIK code can be a key or index in the registry. For example:

pressedKeys = [false, false, false, false,...];
...
// DIK_K is a key code and the index at the same time
pressedKeys set [DIK_K, true]; // Manage the element in the down and up EHs
...
if ((pressedKeys select DIK_K) && (pressedKeys select DIK_M)) then
{
    // Do something if K and M are down
};

With such technique you can make almost unlimited key combos like Q+A+U+T+7+N+F6+SHIFT+PgDn+ESC+ENTER

#

Personally I found hard coding the keys is pretty annoying thing.

drowsy geyser
#

thank you for your effort

drowsy geyser
zealous heath
#

Anyone know how to execute code after countdown completion?

stable dune
zealous heath
# stable dune How are you made your countdown?

bis function, but I think I figured it out, just gotta test it now. I am using trg1 = true in the command line of a laptop that the players have to hack to assign the task and set the trigger countdown to the same as the bis function

zealous heath
fair drum
zealous heath
fair drum
fair drum
#

General thing is if you know exactly when something happens, you shouldn't spend resources waiting for it to happen, just make it happen.

thorn saffron
#

Is there some established way to make a function wait until a spawned function gives a return? I don't want to use call as I need to use sleeps.
I tried using scriptDone, but then it turns the variable that was supposed to be the result of the spawned function into a script handle.
Basically I want to suspend the execution of a function until a spawned function finishes.

Wait, if I use spawn instead of call then I do not get the result back?
Like _thingy = ["derp"] spawn taro_fnc_doTheThing , I thought that _thingy would be the result of the function, but it seems if you use spawn it becomes a script handle.

wind sapphire
#

It sounds like you should spawn your function

little raptor
#

As long as you call from a scheduled script

#
0 spawn {
  _result = call {
     sleep 3;
     1;
  };
  systemChat str _result
}
thorn saffron
# wind sapphire It sounds like you should spawn your function

Well yeah, but how do I get a result of the spawned function as it appears if you spawn then what would be result becomes a script handle.

@little raptor I thought about doing that, but how do I get the result out of that spawned function. I can't do it all inline as I have rather extensive functions that require spawn.

little raptor
#

If your script is not scheduled, you can chain the calls:

_stuff spawn {
  sleep 3;
  [_stuff, 1] call nextScript;  // pass the result and other stuff to the next script
}
little raptor
#

e.g. from an event handler, init field, etc.

thorn saffron
#

The whole thing I'm making is a base network generation. Just calling a function, it's not something that is run often, but it relies on different function that does a position search and that one hangs the whole game when it tries to find a position. I wanted to introduce a sleep every few attempts at finding the position to offload the scripting. The whole thing does not need finish as fast as possible.

little raptor
# thorn saffron The whole thing I'm making is a base network generation. Just calling a function...

If timing is not important, you can spawn that slow function, and pass its result, plus extra args (e.g. local vars that are needed to continue execution) to another function that continues the job like I showed in an example above

// Slow fnc
params ["_args", "_nextFnc"];
_result = ... // Do some slow thing;
_args pushBack _result;
_args call _nextFnc; // pass the result, and the args to the next function 

Which you execute like this:

[[1,2,3], my_fnc_next] spawn slowFnc
#

that's a more general way of doing it.
if the next function is always my_fnc_next, you don't need to pass it

thorn saffron
#

The way I have it set up now is like this:

//this is a generate site function
//doing stuff 
_siteLocation = [_area,_excludedAreas,_inclusionAreas,_condition] call taro_baseNetwork_fnc_findSitePosInArea;

//do stuff with the site location we got from the findSitePosInArea function

findSitePosInArea function is quite heavy and this is the one I want to introduce some sleeps to keep the game going.
Problem is if I switch to spawn instead of a call then _siteLocation seems to become a script handle.
I could edit the findSitePosInArea function so it spawns and inline function, as long as I can get it to return data into the generate site function, into the _siteLocation variable.

little raptor
little raptor
little raptor
#

you no longer have to do weird stuff

#
0 spawn {
//this is a generate site function
//doing stuff 
_siteLocation = [_area,_excludedAreas,_inclusionAreas,_condition] call taro_baseNetwork_fnc_findSitePosInArea;

//do stuff with the site location we got from the findSitePosInArea function
}
past dagger
#

anyone got a script where it auto refuels / rearms / repairs any type of vehicle that gets inside of a trigger with just putting the script into the on activation area

little raptor
#

Even if this function is part of another series of codes, all that matters is that you start this by a spawn, and everything else can be call

bleak gulch
bleak gulch
#

thread returns its handle when spawned

#

you never know when the thread will end so it's pointless to stop the execution of the parent instance and wait until the thread dies

#

Hell'O

viral birch
#

Is there any way to allow players to toggle Grass on / off without effecting terrain quality viasetTerrainGrid? I know that I can strip the grass from the map in CfgSurfaceCharacters, but that would apply globally to all players. I'd like to provide an option for players to choose if they want grass or not while keeping setTerrainGrid = 3.125 so there are no abuses of deformed terrain...Is there any way to do that?

proven charm
viral birch
proven charm
#

ok

granite sky
#

There are low-grass mods that I think adjust the grass models. I don't think there's any way to do it through script.

polar belfry
#

I have a question
I have something that has a light behind it and I want it that when it dies the light to be deleted will this work

_light attachTo [this, [0, -3, 0]]; 
_light setLightColor [1, 0.54, 0.1]; 
_light setLightAmbient [1, 0.54, 0.1]; 
_light setLightUseFlare true; 
_light setLightFlareSize 8; 
_light setLightFlareMaxDistance 3000; 
_light setLightBrightness 1000; 
_light setLightIntensity 90;
_light setLightDayLight true;
this addEventHandler ["Killed", { params ["_unit","_light"]; deletevehicle _light;}];```
granite sky
#

No. _light doesn't exist in the event handler context. You'd need to do something like this instead:

private _light = "#lightpoint" createVehicleLocal [0, 0, 0];
this setVariable ["mymodtag_attachedLight", _light];
// other shit goes here
this addEventHandler ["Killed", {
 params ["_unit"];
 private _light = _unit getVariable ["mymodtag_attachedLight", objNull];
deletevehicle _light;
}];
polar belfry
#

I see

#

I'll try it

#

it works

teal drum
#

Is it possible to make an object ignore the wind when being dropped via a cargo parachute?

drowsy geyser
teal drum
#

Doesn't seem to work when I change the weather through Zeus

#

Tried it on both the parachute and the crate itself

teal drum
#

Will test it out tomorrow, thanks o7

polar belfry
#

Hi I tried to spawn an item at a waypoint and I get this error will post code

#
private _veh = createvehicle [_pos ,"pook_SCUD_nuke_spawner"];```
#

"this" is supposed to be the waypoint

fair drum
#

that syntax of createvehicle takes the class name first, then position

polar belfry
#

oh

meager mist
#

I'm trying to move some of the bombscript outside the trigger, and into scripts. And making sure everyone has the same timer, as it was mentioned before. But I'm not getting it working on dedicated.
This was what was in the trigger before:

[ west, ["Task_Defuse"], ["Find the code and defuse the bomb before it explodes.", "Defuse the bomb", "DEFUSE"], objNull, FALSE ] call BIS_fnc_taskCreate;  
 [ west, ["Task_Secure"], ["Secure the SCUD launcher and bring it back to FOB Sentinel Ridge for proper disposal", "Secure CBRN SCUD Vehicle", "SECURE"], objNull, FALSE ] call BIS_fnc_taskCreate; 
_null = [caseBomb, 300] spawn COB_fnc_bombTimer;

And I've moved it now to init.sqf. Since I saw that _null = is a relic code.. I thought that was the fact it's not showing up, but no bueno. It's working on MP within Editor.

0 spawn {
    waitUntil {sleep 1; triggerActivated bombTimer};
    if (isServer) then    {
        [ west, ["Task_Defuse"], ["Find the code and defuse the bomb before it explodes.", "Defuse the bomb", "DEFUSE"], objNull, FALSE ] call BIS_fnc_taskCreate;  
         [ west, ["Task_Secure"], ["Secure the SCUD launcher and bring it back to FOB Sentinel Ridge for proper disposal", "Secure CBRN SCUD Vehicle", "SECURE"], objNull, FALSE ] call BIS_fnc_taskCreate; 
        [caseBomb, 300] spawn COB_fnc_bombTimer;  
    };
}; 
#

fyi: the tasks work, just not the COB_fnc_bombTimer;

#

I'm guessing I'm forgetting to define caseBomb?

raw vapor
#

I have a sound effect I want to be heard across the whole-ass map. I know ArmA takes into account things like distance and doppler and changes the sound accordingly. Can I do that with a sound that can be heard over like, 20 kilometers? Or does the sound system break down after a point?

fair drum
#

You won't hear it otherwise across the map.

raw vapor
#

Darn. Plan B then. Small delay and play the sound globally.

#

As I was doing before.

fair drum
pale sail
tribal crane
#

Store it somewhere local, like setVariable on a game logic.

bronze temple
#

But when I load it up on a dedicated server for some reason

_cam2 setPos (asltoagl getPosASL player); 

doesn't work

#

Anyone have any insight on this

#

I've tested it all on the dedicated server and found that the issue lies in the setDir as it teleports the camera to the player, and then moves it to where it would view the full character but because it never looks at the player

bleak gulch
#

player is not defined on dedi. Well, it's defined as <OBJ-NULL>

#

you need to be more specify where did you define that code

bronze temple
#

This gets executed in initplayerlocal in a seperate script.

#

initplayerlocal

[] call sal_fnc_openDialogCreation;

with sal_fnc_openDialogCreation being the above script

#

I don't believe it is that I believe it's just the cause of the weird behavior of setDir

#

It works if I put it in after all the setPosASL but not before which could just be a weird bug with the command, the wiki says defining it after you've done a setPos can lead to wierd behavior

bleak gulch
#

well, you didn't post anything related to setDir behaviour before.

_cam2 setPos (asltoagl getPosASL player); 
#

it's still unclear is setDir working or not. And if it's working, why is it glitching?

bronze temple
#

The position works but setDir only works if its done like this

_cam2 = "Land_HandyCam_F" createVehicle [0,0,0]; 
_cam2 enableSimulation false;
_cam2 setPos (asltoagl getPosASL player); 
_cam2 setPosASL (getPosASL _cam2 vectorAdd [2, 3 ,1]);
_cam2 setDir (_cam2 getDir player);
switchCamera _cam2;
#

Which has me confused but I've switched to setVector and I'm about to see if that works better

#

It worked

#
createDialog "playerCreation";
_cam2 = "Land_HandyCam_F" createVehicle [0,0,0];  
_cam2 enableSimulation false; 
_cam2 setPos (asltoagl getPosASL player);  
_cam2 setVectorDir  [0, -1, 0];
_cam2 setVectorUp  [0, 0, 1]; 
_cam2 setPosASL (getPosASL _cam2 vectorAdd [1.8, 3 ,1]); 
switchCamera _cam2;
[] call sal_fnc_determineAP;
#

Just changed it to this, arma is a funny game.

bleak gulch
#

did you try to use setDir before setting the position?

#

also setVectorDir and setVectorUp can be combined in setVectorDirAndUp

bronze temple
#

I did and it gave some weird effect but appreciate the help man

fair drum
#

instead, use a camera target and screenToWorld

#

they don't? what else is going on in your script?

#

they don't for me. do you have dynamic simulation running or something?

#

does it happen with a vanilla jet?

bleak gulch
# bronze temple Just changed it to this, arma is a funny game.

al least you made it working. You can use this if you want to use degree instead of vectors

private _angle = 45;
myObject setVectorDir [sin _angle, cos _angle, 0];

// or

#define MYOBJECT_ANGLE 45
myObject setVectorDir [sin MYOBJECT_ANGLE, cos MYOBJECT_ANGLE, 0];
lime rapids
#

is there any way outside of config to filter specific types/individual of vehicle weapons?

granite sky
#

Be specific.

lime rapids
#

in an if then check if the weapon is fired in a fired eh is an air to ground missile or not that type is simpler than just an if weapon = specified weapon config name then do thing?

wind sapphire
#

it may depend on how it is detected. If you sense the projectile by a handleDamage EH you will have specific information available.

#

I used something like this in an MPkilled EH a while back:

#

if ((currentWeapon _killer) in blck_forbidenVehicleGuns) then {do something};

#

I am not sure if that works if the projectile/missile was fired from a pylon

cedar bay
#

Hey guys. What would be the most simple way to start one of 3 possible sqfs (that each create 2 tasks in the briefing?) when BLUFOR enters a certain trigger?

proven charm
tough abyss
#

-__-

tribal crane
#

Is it failing just because the current channel is already 15, and the watches are evaluated constantly?

tough abyss
#

Nope. Works for every other channel. setCurrentChannel is bugged and doesn't work with custom channel 10

cedar bay
#

Dude tnx. For dedicated I need this && isServer ?

finite bone
queen cargo
#

uhrm .. just some random question comming into my head right now
when could setCurrentChannel fail at all?

#

only reason i could see when it would fail would be on some disabled channel

tough abyss
#

When the channel is disabled or the index is out of bound

#

Or on a custom channel that exists when a unit is not added to it.

#

setCurrentChannel is also the only way to find out if a channel is enabled.

#

Loop through all channels and set the original one at the end.

drowsy geyser
#

how would i get a specific object that is attached to the player?
attachedObjects player returns every attached object, so how could i check if a specific object is attached to the player by the objects classname?

#

attachedObjects returns the .p3d file

finite bone
#

use typeOf

drowsy geyser
#

returns false because attachedObjects returns the .p3d file

#

not the classname -.-

dire star
#

[c4g2,"SERGEANT"] remoteExec ["setRank",c4g2];
[c4g2,["Keni Thomas","Keni","Thomas"]] remoteExec ["setName",0];
[c4g2, "WhiteHead_06"] remoteExec ["setFace", 0, c4g2];
is this script right?

finite bone
#

A very elaborate way but usually typeOf should handle the .p3d files no problem

dire star
#

how do i make my script wait until my squad has left vehicle? i only know ab this one
_incar = true;
while { _incar } do {
if ( ({!(alive _x) || _x in c4 || _x in c5 || _x in c6 } count (units d1)) == count (units d1) ) then {
_incar = false;
};
sleep 2;
};
but idk how to change it for not being in vehicle

warm hedge
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
↓

// your code here
hint "good!";
bleak gulch
#

it's not .p3d

#
_filteredObjects = (attachedObjects _object) select {(typeOf _x) == "classname"};
bleak gulch
dire star
#

what if i have 3 cars that players are in?

#

this will work only for passangers right? i got AI driving and AI gunner on it

bleak gulch
#

if you have more cars, it's better to use forEach or apply πŸ˜„

cosmic lichen
#

Why not check if vehicle player == player?

#

or use a getOut event handler

bleak gulch
#

crew works for any unit in the car (including dead)

bleak gulch
dire star
#

yea mb, i got 3 jeeps driving then will drop off player and i wanna make when players group leave those 3 vehicles Ai will drive off

cosmic lichen
#
{!isNull objectParent _x} count units GROUP == 0
bleak gulch
#

O(2n), counts only alive units, ignores deadmen, AI ignored

waitUntil {sleep 0.5; ({({(alive _x) && {isPlayer _x}} count (crew _x)) > 0} count [car1, car2, car3, ..., carN]) == 0};
dire star
#

yea i need it to count only player group

bleak gulch
#

enjoy

indigo wolf
#

im trying to find nearobjects but make a check to ignore emptydetectors, triggers, and proesses with jip like i have this in my code

private _jipid_attachTo = format [TAG_JIP_attachTo_%1", str(_vehicleinfi)];```
and i am trying to check it with a condition like this
```sqf
if ((typeOf _x != "EmptyDetector") && (str _x not in "TAG_JIP_rocket_attachTo"))``` is this valid or is there a better way?
open hollow
#

dont need to do it one liner lol, also sleep .5 is redundant, waituntils has .5 s sleep in it already πŸ™‚

bleak gulch
#

0.5s delay is for the triggers

open hollow
open hollow
indigo wolf
#

yea i have the nearobjects array loaded for a loop (hence the _x) and I also know theres a jipfunction created with the name TAG_JIP_attachTo so i want to filter out from the nearObjects array with elements of this

bleak gulch
open hollow
indigo wolf
#

im basically trying to find out all objects like houses, vehicles, units except triggers and TAG_JIP_attachTo attached things from the list

open hollow
indigo wolf
#

yes thats fine

open hollow
# indigo wolf yes thats fine

you will need an||to make that working, also is a little more readable if you dont nest to much ifs

if (typeOf _x == "EmptyDetector" || str _x in "TAG_JIP_rocket_attachTo") then {continue};
tough abyss
#

Which doesn't work when there is a channel 10 :/

indigo wolf
#

so the logic works fine?

bleak gulch
#

I don't understand the purpose of using formated strings. Is it really faster than using attachedTo or attachedObjects?

#

Didn't test the code in the game, but something like this

private _filteredObjects = _nearObjects select
{
    (((typeOf _x) != "EmptyDetector") && {isNull (attachedTo _x)})
};

It selects elements with the two conditions:

1. object type is not "EmptyDetector"
                AND
2. object is not attached to anything
meager mist
bleak gulch
#

well I propose to use global var for the objects + function to sync the timers

#
// 200 seconds before explose, propagate over net? YES
bomb setVariable ["theTimer", day_hour_minute_second, true];
#

and the function which syncs the time for the client and JIPs

drowsy geyser
bleak gulch
#

Does attachedObjects player returns anything?

#

and sure it returns array, not boolean

#
  1. attachedObjects player must return non-empty array
  2. I recommend you to replace == with isEqualTo to perform non-case sensitive comparison (NVM, MY BAD. DON DO THIS)
#
  1. The whole expression returns ARRAY, each element must satisfy the condition.