#arma3_scripting

1 messages ยท Page 286 of 1

dusk sage
#

Well -1 would be everywhere but 1, but as for what 1 is, idk

#

First client is 3 ๐Ÿคท

scarlet spoke
#

Afaik 1 refers to the server

dusk sage
#

2 is the server

#

0 are map objects

#

IIRC

scarlet spoke
#

Oups.. Yeah you're right

jade abyss
#

https://community.bistudio.com/wiki/remoteExec

[default: 0 = everyone]
Number - the function will be executed only on client with the given owner ID. When 0, the function will be executed on each client including the one where remoteExec was called from. When 2, it will be executed only by server. When negative, it will be executed everywhere except for machines with the given client ID. Use -2 to target everyone except the server.```
#

Or send it to someone specific:

[_NiceVariableToSendOver] remoteExecCall ["My_fnc_IsAwesome",(owner _Player)];
dusk sage
#

Yes, but the question is does 1 represent something in particular? @jade abyss

jade abyss
#

(owner _Player) = Number

dusk sage
#

The first connected client is 3

jade abyss
#

So 1 was... ermm... can't remember

dusk sage
#

The server is 2

jade abyss
#

and 1 should be... [FillAnswerHere]

dusk sage
#

๐Ÿ˜„

#

Exactly ๐Ÿคท

little eagle
#

1 is Dscha, because he is always #1

jade abyss
#

My guess: Banana.

#

Commy just confirmed: Its Banana.

dusk sage
#

If 1 is nothing, makes me kinda sad that the server isn't 1

little eagle
#

owner still reports a different id than is used by remoteExec in loaded MP savegames. : (

jade abyss
#

Saving in MP worked? ^^

plucky beacon
#

Alright so if I want to remotely execute a scripts to @jade abyss I use 1
I just find it funny that it's not defined, I figured it would be something like local or something

jade abyss
#

Yep. Exactly. Then i magicly appear and bitchslap you around the room cause you highlighted me without any purpose and then i will steal your milk out of your fridge! HA!

#

(P.S.: I just guess, that we all forget what 1 was)

plucky beacon
#

No! I drink milk all the time! I need it!

#

lol

#

I don't drink coffee

deft zealot
#

Question for our performance cowboys:
Counting bytes of a character given by its unicode value.

First (using toString + count):

count toString [_value]

0.0046 ms

Second (using switch):

switch (true) do {
    case (_value < 128): {1};
    case (_value < 2048): {2};
    default {3};
}

0.0085 ms

Third (using if-else):

if (_value > 127) then {[2, 3] select (_value > 2047)} else {1}

0.0051 ms

indigo snow
#

lookup the function in the in game function browser and you can see it @plucky beacon

plucky beacon
#

I'm not home atm but ya I wanna test it for fun later

#

I'm just reading through the known functions

#

Also that looks like a Dscha question

deft zealot
#

@plucky beacon it creates an I_static_AA_F at 500m distance and fires at the target

plucky beacon
#

Cool

indigo snow
#

@deft zealot is _value an array or a number? what are you attempting? but when chosing between case-switch and if-else chains, its better to call { if condition_one exitWith { CODE}; if condition_two exitWith {CODE}; etc };

dusk sage
#

Better if you have a large amount of cases that is

deft zealot
#

_value is a number

#

and the call-if-exitWith was indeed faster than switch but there was a patch (about half a year ago?) where switch got improved and got better performance now
i cant tell which path it was

dusk sage
#

Are you expecting toString [a single number] to give you more than 128 characters ๐Ÿ˜„ ?

indigo snow
#

it does actually go up to three because #unicode

#

count toString [2078] = 3

deft zealot
#

^

indigo snow
#

method one is best tho

#

0.0011 ms, cant really beat that with complexer if else / switch cases

dusk sage
#

Sure, surrogate pairs and what not

#

But 128 characters

#

nah

indigo snow
#

no no he checks the number itself

dusk sage
#

count toString [_value]

indigo snow
#

those are the boundaries where one number will turn into a 2 length string

dusk sage
#

count "a string"

#

oh right

#

my bad

#

Didn't see the _value in the switch

indigo snow
#

yea

dusk sage
#

I was thinking count toString [_value] > 2048

#

๐Ÿ˜„

indigo snow
#

haha nah 3 it the largest it gets, and counting the toString is definitively most optimal

dusk sage
#

@deft zealot We were looking into array select bool the other day, it was super slow

deft zealot
#

i thought its faster than if (BOOL) then {A} else {B}

indigo snow
#

BoGuu, select BOOL or select CODE? the difference between select BOOL and select NUMBER is within margin of error for me

dusk sage
#

BOOL/SCALAR

#

select is just incredibly slow

indigo snow
#

it increases with the size of the array iirc

#

pretty linearly too

dusk sage
#

It would be yes, but you used both in combination @deft zealot

little eagle
#

select is still faster than then

indigo snow
#

if BOOL then CODE else CODE is my favourite for explaining how SQF commands work, tho

little eagle
#

The mere existence of the IF type is an insult.

indigo snow
#

i suspect you dont regard the WHILE type favourably, either

plucky beacon
#

I think part of it is the lack of else if

#

that you need to nest them

indigo snow
#

you can come close to it with call { if condition_1 exitWith {code}; if condition_2 exitWith {moreCode}; };

plucky beacon
#

basically

#

close enough

indigo snow
#

the main thing I sometimes run into is huge conditions, but thats a problem in every language i guess

jade abyss
#

dat haydouken thingy (or however its beeing spelled)

dusk sage
#

there you go

plucky beacon
#

ye

jade abyss
#

yep, that one

rancid ruin
#

damn, i don't miss PHP

#

would rather write SQF than PHP

halcyon crypt
#

PHP allows you to make money, SQF doesn't really ยฏ_(ใƒ„)_/ยฏ

dusk sage
#

Please buy my status bar

halcyon crypt
#

๐Ÿ˜›

plucky beacon
#

lol "buy my status bar"

jade abyss
#

"Yeah it works but you're leaking memory everywhere. Perhaps we should fix that" - "I'll just restart Apache every 10 Request"
๐Ÿ˜‚ ๐Ÿคฃ

dusk sage
#

'the function hashing mechanism was strlen()'

#

That is my favourite

jade abyss
#

No clue what that means. Explain pls.

dusk sage
#

Note the first diagram ๐Ÿ˜„

#

Means he had to name functions purposefully, just so he could get a nice distribution ๐Ÿคฃ

arctic igloo
#

oh wow that is hilarious, ive always avoid php it felt so just gross to use

plucky beacon
#
_ActivePlayers = {alive _x} count _BluforUnits;

Am I doing this right?

#

I used

_ActivePlayers = {alive _x && {side _x == east}} count _OpforUnits;

as an example

civic maple
#

allPlayers?

little eagle
#

_ActivePlayers sounds like it's an array of player objects, but it's actually a number.

dusk sage
#

@plucky beacon

Use the alt syntax for select

#

allPlayers select {alive _x};

little eagle
#

But Nitro wants the number of players and not the objects apparently

plucky beacon
#

I want the number of ya

#

So when it reaches 1 i do a thing

civic maple
#

ah

plucky beacon
#

I'm getting all sorts of errors, I tried this way too...

{
    _checkedVariables pushBack _x;
    if    (alive _x) then 
        {
            _ActivePlayers pushBack _x;
        };
} forEach _BluforUnits;

https://i.gyazo.com/0b5bb69760b3b4f63aea725f4d8003f8.png
isn't forEach supposed to use _x as the variable for whatever element it's processing?

civic maple
#

yes

#

what's the error?

plucky beacon
#

it's in the image

#

says _X is undefined

civic maple
#

wut

plucky beacon
#

IKR?

little eagle
#

Because there are undefined elements in _BluforUnits

civic maple
#

well that was clear /s

little eagle
#

We went over this already. Wrap it all inside {...} call CBA_fnc_directCall;

plucky beacon
#

that gave me a whole 'nother error, let me get that for you

blissful fractal
#

Yo hope this is the right textchannel ๐Ÿ˜ƒ Is there a way to put allow two license to go in civ car on altis life? ๐Ÿ˜ƒ case "civ_car": {_ret = license_civ_driver;};

indigo snow
#

@plucky beacon use

private _BluforUnits = [Leader_1,Leader_2,Leader_3,FTL_1,FTL_2,FTL_3
private _aliveCount = {{alive _x && {side _x == west}} count _listOfUnits} call CBA_fnc_directCall;

or

private _BluforUnits = [Leader_1,Leader_2,Leader_3,FTL_1,FTL_2,FTL_3];
private _aliveCount = {alive _x && {side _x == west}} count (_BluforUnits arrayIntersect _BluforUnits);

like we discussed earlier today ๐Ÿ˜› you picked the one variant that didnt work.

plucky beacon
#

I want to get rid of the side check but it returns as _activePlays undefined

indigo snow
#

just remove the side check from those two snippets

#

you need to handle the array in a special way to circumvent the nonexistent units

#

you cant use the snippets you posted earlier because of that

plucky beacon
indigo snow
#

yea like we told you

#

that wont work

plucky beacon
#

wait wtf

indigo snow
#

use the two snippets i just posted

#

dont use the other 300 snippets you have in your file

plucky beacon
#

that one gives me the error in the image

indigo snow
#

that one doesnt use the snippet i posted

#

The two in the message I mentioned you in

plucky beacon
#

bu-bu-bu you said just remove theside check :<

indigo snow
#

yes but thats a different snippet than the ones i posted

#
private _someArrayOfJustUnits = [Leader_1,Leader_2,Leader_3,FTL_1,FTL_2,FTL_3
private _aliveCount = {{alive _x} count _someArrayOfJustUnits } call CBA_fnc_directCall;

so like this

plucky beacon
#
private _aliveCount = {{alive _x} count _BluforUnits} call CBA_fnc_directCall;
#

same error

indigo snow
#

what is _bluforunits

#

is it an array of units?

plucky beacon
#

the private array

#

ya

_BluforUnits = [Leader_1,Leader_2,Leader_3,UAV_1,FTL_1,FTL_2,FTL_3,FTL_4,AR_1,AR_2,AR_3,AR_4,AAR_1,AAR_2,AAR_3,AAR_4,Gren_1,Gren_2,Gren_3,Gren_4,Marksman_1,Marksman_2,Marksman_3,Marksman_4,Scout_1,Scout_2,Scout_3,Scout_4,Medic_1,Medic_2,Medic_3,Medic_4,Medic_5];
indigo snow
#

well somewhere in the process you managed to turn it into a number since thats what arma is complaining about

civic maple
#

is the parameter to CBA_fnc_directCall supposed to be code?

#

nvm

indigo snow
#

yes. the following works when pasted into the debug menu. A = 2.

0 = [] spawn {
    private _array = [nil,player,nil,nil,player];
    private _aliveCount = {{alive _x} count _array } call CBA_fnc_directCall;
    A = _aliveCount
};
#

you got some things interfering in your script files @plucky beacon

plucky beacon
#

pbpbpbpbpbpt

#

okay

#

something to do with the names of the nil units, because I did the same debug menu thing and it stopped on the second element because there is no Leader_2

indigo snow
#

ah so you can use nil but not non-existing variables

#

gotta build the array inside of directCall then

plucky beacon
#

so this...

0 = [] spawn { 
    private _BluforUnits = [Leader_1,Leader_2,Leader_3,UAV_1,FTL_1,FTL_2,FTL_3,FTL_4,AR_1,AR_2,AR_3,AR_4,AAR_1,AAR_2,AAR_3,AAR_4,Gren_1,Gren_2,Gren_3,Gren_4,Marksman_1,Marksman_2,Marksman_3,Marksman_4,Scout_1,Scout_2,Scout_3,Scout_4,Medic_1,Medic_2,Medic_3,Medic_4,Medic_5]; 
    private _aliveCount = {{alive _x} count _BluforUnits} call CBA_fnc_directCall; 
    A = _aliveCount; 
 hint a; 
};
#

oh shit you can do that?

indigo snow
#

no not that

dusk sage
#

We went over this already. Wrap it all inside {...} call CBA_fnc_directCall;

#

You so dirty

indigo snow
#

haha

#

turns out even CBA_fnc_directCall doesnt like that

#

gotta use some other way @plucky beacon

dusk sage
#

just check if it's undefined in the scope

#

๐Ÿ˜›

indigo snow
#

check every unit for isNil

dusk sage
#

Although the real question is why aren't they defined

#

If you purposefully put all those units into that array

plucky beacon
#

because players didn't take the spots

indigo snow
#
0 = [] spawn {
    {
        private _array = [someUnit,nil,player]
    } call CBA_fnc_directCall;
};
``` gives a funky error
dusk sage
#

๐Ÿ˜„ ?

indigo snow
#

would fail on the first

plucky beacon
#

lol my better array

indigo snow
#

trying to add a nonexisting unit to the array since youre referencing an undefined variable

dusk sage
#

can we just find a way that's not directCall

indigo snow
#

just move to unscheduled

dusk sage
#

Because that's just ugly

indigo snow
#

so much easier haha

#

the actual issue is the fact you cant use the unitVarNames at all

#

unless theyre not nil

#

so gotta check the string version of them all for isNil then add them to the array

plucky beacon
#

okay okay, so make a list of strings

indigo snow
#

["unit1","unit2"] apply {if !(isNil _x) then {missionNamespace getVariable [_x,objNull] } else {objNull} }

#

then remove all instances of objNull

#

or something like that

dusk sage
#

["unit1","unit2"] select {!isNil _x}

indigo snow
#

^thats the one that escaped my mind

#

neat

dusk sage
#

but using unscheduled to avoid undefineds

#

not sure how I feel about that ๐Ÿ™ƒ

plucky beacon
#

part of me wants to stop asking questions simply out of guilt

civic maple
#

everyone's gotta start somewhere, don't be afraid of asking questions

plucky beacon
#

it's been like 2 days all day xD

#

this missionNamespace stuff is alien to me

#

never seen it before

civic maple
#

missionNamespace is all global variables I believe

dusk sage
#

Global variables that are defined in the missionNamespace, yeh

plucky beacon
#

how do you turn a string into an object? gah...

#
_veh = missionNamespace getVariable "refString";

this must be it

#

yes

#

Victory

    private _bluforUnits = ["Leader_1","Leader_2","Leader_3","UAV_1","FTL_1","FTL_2","FTL_3","FTL_4","AR_1","AR_2","AR_3","AR_4","AAR_1","AAR_2","AAR_3","AAR_4","Gren_1","Gren_2","Gren_3","Gren_4","Marksman_1","Marksman_2","Marksman_3","Marksman_4","Scout_1","Scout_2","Scout_3","Scout_4","Medic_1","Medic_2","Medic_3","Medic_4","Medic_5"];

    _numberOfElements = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _bluforUnits;
civic maple
#

\o/

stoic sphinx
#

Anyone here intreseted in zombies that can parkour ?

plucky beacon
#

0/10 not realistic

#

~ign

civic maple
#

mah immersion

little eagle
#

Are you guys still working on this. lol

dusk sage
#

@plucky beacon Might be worth adding a default value, just in case

little eagle
#

Where is the full code?

dusk sage
#

I think that is the full code

plucky beacon
#

oh the full code

#

hang on

#

wtf

#

my ctrl.c isn't working?

#

@little eagle

private ["_BluforUnits","_aliveCount"];

_BluforUnits = ["Leader_1","Leader_2","Leader_3","UAV_1","FTL_1","FTL_2","FTL_3","FTL_4","AR_1","AR_2","AR_3","AR_4","AAR_1","AAR_2","AAR_3","AAR_4","Gren_1","Gren_2","Gren_3","Gren_4","Marksman_1","Marksman_2","Marksman_3","Marksman_4","Scout_1","Scout_2","Scout_3","Scout_4","Medic_1","Medic_2","Medic_3","Medic_4","Medic_5"];

waitUntil {MissionActive};

_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _BluforUnits;

if(_aliveCount == 1) then
{
    [[],"LastMan.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 0) then
{
    [[],"BluforFailure.sqf"] remoteExec ["execVM",0,false];
};
#

Last man and Blufor failure run only once

#

so I didn't see a need to precompile them

little eagle
#

Wait. Is this supposed to execute LastMan.sqf when everyone but one unit is dead?

#

Like, after 30 minutes of playing for example?

dusk sage
#

I think by the name, that's the intended behaviour

#

๐Ÿ˜›

plucky beacon
#

@little eagle ye? Everyone gets the notification.

dusk sage
#

please no execVM ๐Ÿ˜ฆ

little eagle
#

Well it won't work like that.

#

Because your script runs once at mission start and if they're not dead immediately, nothing will happen, because your script is long finished.

#

Also, that whole array of blue units... Isn't that basically all the blue units?

#

Why name them?

plucky beacon
#

nonono hold up

#

the script is run on a killed event handler for each unit

little eagle
#

Can't be. You can't use waitUntil in an event handler.

plucky beacon
#

so every time they die it runs a check

little eagle
#

You can't use waitUntil in an event handler.

plucky beacon
#

that's for the first iteration after the mission is activated by the group leader

little eagle
#

You said this script is executed every time a unit dies by killed eh.

#

There is waitUntil

#

verboten

plucky beacon
#

yes, AND when the mission is active

little eagle
#

You're doing strange stuff.

#

Duplicate code?

plucky beacon
#
[] remoteExec ["BluforLeft", 2, false];
```when mission activated

```sqf
this addEventHandler ["killed", {[] remoteExec ["BluforLeft", 2, false];}];
``` per unit
little eagle
#

oh my

plucky beacon
#

god what sacrilige did I commit now?

little eagle
#

That must've been painful to name all units and to add that line into every init box.

#

Just to make sure.

#

You're using CBA?

plucky beacon
#

ya?

little eagle
#

@CBA_A3 addon

plucky beacon
#

ya?

little eagle
#

That doesn't sound very confident.

plucky beacon
#

I'm asking why that's relavent

#

I'm so confident I'll bet you $1000 I have CBA running

little eagle
#

You can't use CBA_fnc_.... if you're not using CBA

#

O.K.

plucky beacon
#

but I don't need CBA anymore

#

besides for the mods

little eagle
#

Idk man. I still don't understand why you only execute this for certain blue units.

plucky beacon
#

Because these are the playable units, and the playable units have a specific number of each infantry type, because for each autorifleman on blufor, one autorifleman on opfor is present.

little eagle
#

Then why not iterate through the playable units? It seems like a huge inconvenience to name all the units.

plucky beacon
#

Because I need to compare the unit's existence to it's opfor equivalent, and each class has a custom loadout

#

and It was easier for me to apply arsenal loadouts in Eden then write a function that applies a loadout for each class using kindOf

weak obsidian
#

Couldn't you also check for playableUnits per side?

plucky beacon
#

Well ya that's not the issue

#

Blufor chose to take 3 rifleman and a medic, I need 3 rifleman and a medic on the enemy team. I CAN write the script for checking the classname of each playable unit and spawning the equivalent with the custom loadout

#

but I didn't (yet)

weak obsidian
#

Sorry for jumping in like that - but could you elaborate what you are trying to achieve? Maybe that will make it easier to find a better solution.

#

Ah IC

plucky beacon
#

It was originally a game mode I made up in zeus

#

and designed to have one zeus play "opfor" and in a PVP type game style, remote control the enemy in an attempt to kill all blufor

#

but only using the same exact amount of forces

#

I only recently said "Fuck, I could script this"

#

So eventually, the plan is this will work as a template, that could be used on aany map or mission with a few markers and objects pasted in

weak obsidian
#

If you want to make it reusable I'd script it, leave away that predefined array and create the array dynamically at beginning of misison

plucky beacon
#

right that's the plan ultimately

weak obsidian
#

something like _BluforUnits = west countSide playableUnits;

plucky beacon
#

just working on it one piece at a time, even if ultimately it's a bit out of order

#

but the remaining players was definately most broken

#

and I learned how to use missionNameSpace

weak obsidian
#

So - you have an array of certain named units per side, once only 1 unit from this side is left, you exec lastman.sqf and if a side has completely lost all players the mission ends with failure

plucky beacon
#

ye

#

and similar for the other side too

#

almost identical

#

besides the fact they're not players

weak obsidian
#

So the opfor side is AI?

plucky beacon
#

ya

weak obsidian
#

Aaaah

plucky beacon
#

might work on a PVP variant once this is a-okay

#

but want to get it all done for one side first

#

I already have the failure and victory scripts side specific

#

Here's my messed up backwards upsidedown way of balancing the sides

_BluforUnits = ["Leader_1","Leader_2","Leader_3","UAV_1","FTL_1","FTL_2","FTL_3","FTL_4","AR_1","AR_2","AR_3","AR_4","AAR_1","AAR_2","AAR_3","AAR_4","Gren_1","Gren_2","Gren_3","Gren_4","Marksman_1","Marksman_2","Marksman_3","Marksman_4","Scout_1","Scout_2","Scout_3","Scout_4","Medic_1","Medic_2","Medic_3","Medic_4","Medic_5"];

_OpforUnits = [OpLeader_1,OpLeader_2,OpLeader_3,OpUAV_1,OpFTL_1,OpFTL_2,OpFTL_3,OpFTL_4,OpAR_1,OpAR_2,OpAR_3,OpAR_4,OpAAR_1,OpAAR_2,OpAAR_3,OpAAR_4,OpGren_1,OpGren_2,OpGren_3,OpGren_4,OpMarksman_1,OpMarksman_2,OpMarksman_3,OpMarksman_4,OpScout_1,OpScout_2,OpScout_3,OpScout_4,OpMedic_1,OpMedic_2,OpMedic_3,OpMedic_4,OpMedic_5];

_count = count _BluforUnits;
for "_x" from 0 to _count do 
    {
        if(isNil (_BluforUnits select _x)) then 
            {
                deleteVehicle (_OpforUnits select _x)
            };
    };
#

so basically two arrays, exactly the same size, and when something is nil, it deletes the opfor one

#

and naming wasn't that hard, I have a decen naming convention

#

but it's not dynamic, and like anything in code, if it has to be repeated, it can be coded

dusk sage
#

Why not just forEach

#

Instead of indexing them in a for

#

Or even better, a count

plucky beacon
#

because it used to be a diffrent number of blufor depending on number of zeus'

#

but I use the virtual entity now so I can

weak obsidian
#

Why so complicated? You already are using the killed eventhandler - the names in the blufor array are jus strings, just delete the "OP" + bluforstringname. Unfortunatly Arma does not have good string manipulation though

#

Would that not work?

plucky beacon
#

the variable names really won't be necessary besides Leader_1

#

I could use AllUnits blufor

dusk sage
#

Unfortunatly Arma does not have good string manipulation though
Not much you can't do

weak obsidian
#

No regex afaik?

dusk sage
#

Why would you need regex for that

plucky beacon
#

Also you could just do OP+bluforstringname

dusk sage
#

And I'd use regex and string manipulation loosely in the same sentence

plucky beacon
#

but the importance is the unit classes, so Scout vs. Grenadier vs. Marksman

#

I need to make the scripts for the loadouts which is pretty easy with arsenal but it's busy work :P

weak obsidian
#

so grab the unit classes from the config

plucky beacon
#

ya that's what I'll do

#

I could use classname too because that's consistent

#

so ever B_medic_F is given a loadout for medic

weak obsidian
#

sure - it seems like you would want to grab as much stuff without writing it down manually in an array, because as mucha s I've understood the composition of units can change depending on setup

plucky beacon
#

ya, so basically I would make a public array at the beginning

#

and that array is the reference for the rest of the mission

weak obsidian
#

@dusk sage I am not sure what string manipulation function are inherent to A3? Last time I checked you would need to write your own functions or sth like that no?

#

and in that case (for me) it would be simpler to just use regex

#

So yeah - maybe that will help you get things going, sounds like a cool idea players vs zeus (or TVT)

dusk sage
#

You need to write your own functions in most things, but there is a large amount of commands avaliable

#

You would want to only use regex when it's necessary

weak obsidian
#

Ok I admit I forgot that there are these things like trim split and in. I used to work a lot with CF, which even though has great string manipulation - in the end we did a lot with regex because it showed better performance ๐Ÿ˜ƒ

dusk sage
#

What is CF?

weak obsidian
#

ColdFusion App Server .. I think now it's part of Adobe

#

Well enough of that - it was a long time ago ๐Ÿ˜ƒ Hope I could help DriftingNitro

plucky beacon
#

You did, thanks @weak obsidian

mortal bobcat
#

some really weird stuff happens when i run this (initServer.sqf) on a dedicated server, but not on a listen server

LostSquad_friendlyFactionSide = selectRandom [east,west,resistance];

_nlostSquad = createGroup (LostSquad_friendlyFactionSide);
(units lostSquad) joinSilent _nlostSquad;

_nheliPilots = createGroup (LostSquad_friendlyFactionSide);
(units heliPilots) joinSilent _nheliPilots;

waitUntil {!(isNil "BIS_fnc_init")};

_startPosVariance = [-20,0,20];
_randomStartPos = call BIS_fnc_randomPos;

{
    [0,false] remoteExec ["enableChannel",_x];
    [1,false] remoteExec ["enableChannel",_x];
    [2,false] remoteExec ["enableChannel",_x];
    _x setPos [(_randomStartPos select 0) + (random _startPosVariance),
               (_randomStartPos select 1) + (random _startPosVariance)];
    [_x, 'randomUnitLoadout.sqf'] remoteExec ["execVM", _x, false];
} forEach units _nlostSquad;
#
  1. the setPos seems to do nothing at all and 2. the AI units kill each other like they were enemies
dusk sage
#

what is lostSquad

mortal bobcat
#

a group

#

it's set in the variable name field in 3den

little eagle
#

What's with all this similar looking code that doesn't work recently.

plucky beacon
#

lol

#

Everyone is working with arrays this week

mortal bobcat
#

well mine only breaks in dedicated servers

plucky beacon
#

Lol so was mine

#

but it was a diffrent issue to do with nil units

mortal bobcat
#

the AI units killing each other after changing their sides is really curious

plucky beacon
#

I've seen this glitch before when the unit is owned by a headless client

#

I didn't know you could edit scripts mid mission while testing in eden now

#

in SP at least

#

hmmm just about ready to get this loadout applicator going. So what's the best way to implement a switch:case or some other alternative to nested if-loops considering I need to check for a unit's classname, and then run the loadout script on them?

mortal bobcat
#

update: if i check for the units' individual sides w/ the debug console they show up as WEST no matter what, even if they're in a group that isn't WEST

#

but also if i run the exact same code for switching sides on the debug console (with server exec of course) nothing of the sort happens and they don't kill each other

#

so i wonder what is it about initServer.sqf that makes that behave so strangely

thin pine
#

@stoic sphinx AI zombies path finding + parkour? Did you pull that off yet?

cedar kindle
#

always check a group's side, not the unit

#

unit is civ when dead, group is still correct

digital pulsar
#
    _posRelToPlayer = player selectionPosition "LeftHand";
    _pos = player modelToWorldVisual _posRelToPlayer;
    (vehicle player) worldToModelVisual _pos;
};
_posRelToVic = [] call _leftHandToVicModel;
_obj attachTo [vehicle player, _posRelToVic];``` this works fine when vehicle is stationary but when it moves, offset is affected by velocity, any idea why?
thin pine
#

Try attaching to a memory point if that's possible with your object

digital pulsar
#

i'm interested in littlebirds

#

no selection suits me, don't know about any mempoints

little eagle
#

@mortal bobcat
As cuel pointed out, ALWAYS use side group _unit instead of side _unit, no matter what you see EVERYWHERE, it's wrong and will lead to wrong results.

vague hull
#

woop, finally we got a weaponholder which doesnt delete itself (when empty)

thin pine
#

Wat

little eagle
#

how?

little eagle
#

Those objects must be new.

thin pine
#

Means i can update an old script of mine that used an invisible item as placeholder

little eagle
#

And if you try to manipulate engine placed weapon holders, you're still stuck

#

gj

thin pine
#

.<

jade abyss
#

I've read last week something, about the new WeaponHolder (or was it earlier this week?)

little eagle
#

check the link

jade abyss
little eagle
#

Inb4 these are eternal and never deleted even when you pick up the last item normally

#

Not a fix at all, but very lazy

jade abyss
#

wich is good.

little eagle
#

All I wanted is to not delete the weapon holder when you remove the last item via script command and immediately fill it again with new items.

#

Because atm that will still delete it, even if all of that is done in the same frame...

#

Now that will never be addressed. issue is closed after all ๐Ÿคฆ

rancid ruin
#

who was the guy talking about scripting company of heroes as an arma mission?

plucky beacon
#

What's the best way for me to make a bunch of functions for diffrent loadout applications, do I make a file with inline functions and preprocess it?

dusk sage
#

you could

#

you could also just use CfgFunctions

plucky beacon
#

so in the description?

#

I'd like to keep it clean in seperate files though

#

for easy to edit purposes

dusk sage
#

then use cfgfunctions

plucky beacon
#

I can define funciton by file?

#

oh I guess so

#
class cfgFunctions
{
    class BIS
    {
        class category1
        {
            class Test1         {description="Testing file 1"};
        };
    };
    class CSLA
    {
        class category1
        {
            class Test2         {description="Testing file 2"; file="test.sqf"};
        };
    };
};
plucky beacon
#
class CfgFunctions
{
    class F // Defines the "owner"
    {        
                class setGroupID
        {
            file = "f\setGroupID";
            class setGroupID{};
        };
        class groupMarkers {
            file = "f\groupMarkers";
            class localGroupMarker{};
            class localSpecialistMarker{};
        };
        class FTMemberMarkers
        {
            file = "f\FTMemberMarkers";
            class SetLocalFTMemberMarkers{};
            class GetMarkerColor{};
            class LocalFTMarkerSync{};
        };
          };
};
#

So I found this, interesting that you can set the file to adirectory

#

and as far as I can figure out, setting class is the name of the file without the fn_ prefix

jade abyss
#

Yes, imo the better Choice.

plucky beacon
#

neat

#
class CfgFunctions
{
    class Loadouts // Defines the "owner"
    {
        class Loadout_Blufor
        {
            file = "Loadouts\Loadout_Blufor";
            class asstAutoRifleman{};
            class AutoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
        class Loadout_Opfor
        {
            file = "Loadouts\Loadout_Opfor";
            class asstAutoRifleman{};
            class AutoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
    };
    #include "taw_vd\CfgFunctions.hpp"
};

Neato

#

neatastic

#

When I do this the entire file is a function right? So I don't even need define the function inline

indigo snow
#

With loadouts i recommend taking a real good look at how others have solved it

#

There some interesting sides to it you need to know about

plucky beacon
#

I've worked a lot with loadouts but not as a function

#

I don't really know anywhere else that does this off the top of my head anyway

plucky beacon
#
class CfgFunctions
{
    class La // Defines the "owner"
    {
        class blu
        {
            file = "Loadouts\Loadout_Blufor";
            class asstAutoRifleman{};
            class AutoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
        class Op
        {
            file = "Loadouts\Loadout_Opfor";
            class asstAutoRifleman{};
            class AutoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
    };
    #include "taw_vd\CfgFunctions.hpp"
};

So I'm having trouble understanding the syntax for calling the function.

[Leader_1] call  
fnc_La_blu_autorifleman;
#

the way they explain it is a bit weird because they're using something from teh game files not a mission directory

CSLA_fnc_Test2 - will load script test.sqf
indigo snow
#

La_fnc_autorifleman

#

TAG_fnc_NAME

plucky beacon
#

Oooh

indigo snow
#

Category only gets used in the function browser

plucky beacon
#

but there is two autoriflemans

#

so I originally thought it'd be blu_fnc

indigo snow
#

Yea thats not gonna work then

plucky beacon
#

that's dissapointing

#

I'll just make a diffrent tag

indigo snow
#

It is what it is

plucky beacon
#
class CfgFunctions
{

        class blu
        {
            file = "Loadouts\Loadout_Blufor";
            class asstAutoRifleman{};
            class AutoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
        class Op
        {
            file = "Loadouts\Loadout_Opfor";
            class asstAutoRifleman{};
            class AutoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
    
    #include "taw_vd\CfgFunctions.hpp"
};

would this work?

indigo snow
#

sure

plucky beacon
#

I mean if categories are useless then...

indigo snow
#

uh

#

you still need them tho

#

cant just drop the class

plucky beacon
#

so a class with one category

indigo snow
#

class cfgFunctions { class blu { class loadouts { class Autorifleman {}; }; }; }; sorry for the horrible indentation

plucky beacon
#

it's alright, I can still read it

#
class CfgFunctions
{
    class blu // Defines the "owner"
    {
        class Loadouts
        {
            file = "Loadouts\Loadout_bluFor";
            class asstAutoRifleman{};
            class autoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
    };
    class op
    {
        class Loadouts
        {
            file = "Loadouts\Loadout_opFor";
            class asstAutoRifleman{};
            class autoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
    };
    #include "taw_vd\CfgFunctions.hpp"
};

Okay so trying to call the function like this, maybe I'm not passing the argument correctly, but even still the systemChat in the script isn't coming up.

[Leader_2] call  blu_fnc_autoRifleman;
#

oh wait

#

wait wait wait

#
If 'file' path is not set, system will search for file 'functions\category\fn_function.sqf" (if function is defined in description.ext) or 'ca\modules\functions\category\fn_function.sqf" (if function is in config.cpp).

https://community.bistudio.com/wiki/Functions_Library#Adding_new_functions
doesn't this mean it should automatically be looking in the functions folder or do I need to specify?

rancid ruin
#

i couldn't get that layout of cfgfunctions to work last time i tried it

#

ended up just going for the simple

#
class mytag
{
    tag = "mytag";
    class functions {
        class someFunction {file = "somefolder\fn_someFunction.sqf";};                     // [args] call mytag_someFunction
    };
};
#

the fk happened to the indentation there

plucky beacon
#

Considering I have like 20 functions though, I'd liek to learn to do it the right way :/

#

I can use that just to make sure the script works

rancid ruin
#

i've got 82 functions...works fine

plucky beacon
#

I don't doubt it works

#

it's just a pain to add any more

indigo snow
#
class CfgFunctions
{
    class dpm /*dynamic patrol mission*/
    {
        class missionFunctions
        {
            file = "functions";
            class aStar {};
            class buildPaths {};
            class calcRoute {};
            class gear {};
            class generateRoute {};
            class getNearestRoad {};
            class huntFinal {};
            class huntZone {};
            class squadZone {};
        };
    };
};

does what it says

plucky beacon
#

oh

indigo snow
#

grabs everything in the \functions\ subfolder > dpm_fnc_gear

plucky beacon
#

thanks it worked

#

needed to define the functions directory

#

the cfg functions really confused me on that, because they clearly highlighted everything but that part of the directory, and their example didn't reference it

indigo snow
#

because you were on the A2 page

#

thats the A3 one

plucky beacon
#
class CfgFunctions
{
    class blu // Defines the "owner"
    {
        class Loadouts
        {
            file = "functions\Loadouts\Loadout_bluFor";
            class asstAutoRifleman{};
            class autoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
    };
    class op
    {
        class Loadouts
        {
            file = "functions\Loadouts\Loadout_opFor";
            class asstAutoRifleman{};
            class autoRifleman{};
            class grenadier{};
            class marksman{};
            class medic{};
            class scout{};
            class squadLead{};
            class teamLead{};
            class uavOp{};
        };
    };
    #include "taw_vd\CfgFunctions.hpp"
};
//[unit] call  blu_fnc_<function>;
#

LOL IT HAS NO TEXT

indigo snow
#

add the trailing )

#

discord eats it

plucky beacon
#

trailing?

#

where

indigo snow
#

the last one in that link

#

see how discord doesnt higlight it

plucky beacon
#

ooooh

#

oh wow okay, that's a page

#

bookmarked

plucky beacon
#

TIL functions can't use sleep

#

can functions call other functions?

indigo snow
#

they can and they can

#

if you spawn a fnc they can sleep

plucky beacon
#

oooh you have to spawn it

#

I was using remoteExecCall

indigo snow
#

nothing in a loadout should require sleeping tho

plucky beacon
#

ya it's not the loadout, just makign some other recursive scripts functions

indigo snow
#

sleep thing though purely has to do with scheduled vs non scheduled environment

#

read up on that and itll be clear

plucky beacon
#

ah okay, threads

#

okay so I have this function fn_getUnits

BluforPlayers = [];
OpforPlayers = [];

{
    if(side _x == west) then 
    {
        if(alive _x) then 
        {
            BluforPlayers pushBack _x;
        };
    };
}forEach allUnits;

{
    if(alive _x) then 
    {
        if (side _x == east) then 
        {
            OpforPlayers pushBack _x;
        };
    };
}forEach allUnits;

publicVariable "BluforPlayers";
publicVariable "OpforPlayers";

_formattedBlufor = format ["Units: %1, number of units in array: %2", BluforPlayers, count BluforPlayers];
_formattedOpfor = format ["Units: %1, number of units in array: %2", OpforPlayers, count OpforPlayers];

hint _formattedBlufor;
hint _formattedOpfor;

[BluforPlayers] call missionStarter_fnc_loadoutApply;
[OpforPlayers] call missionStarter_fnc_loadoutApply;

//[BluforPlayers] remoteExecCall ["missionStarter_fnc_loadoutApply", 2, false];
//[OpforPlayers] remoteExecCall ["missionStarter_fnc_loadoutApply", 2, false];

//[] remoteExec ["BluforLeft", 2, false];
//[] remoteExec ["OpforLeft", 2, false];

it outputs the hint and clearly has the units in the array, but nothing happens when the function is called

#

and it calls to this function

_arrayOfUnits = _this select 0;

{
    //Blufor functions
    if (typeOf _x == "B_Officer_F") exitWith {[_x] call blu_fnc_squadLead;};
    if (typeOf _x == "B_Soldier_SL_F") exitWith {[_x] call  blu_fnc_squadLead;};
    if (typeOf _x == "B_Soldier_TL_F") exitWith {[_x] call  blu_fnc_teamLead;};
    if (typeOf _x == "B_Soldier_UAV_F") exitWith {[_x] call  blu_fnc_uavOp;};
    if (typeOf _x == "B_Medic_F") exitWith {[_x] call  blu_fnc_medic;};
    if (typeOf _x == "B_Soldier_AR_F") exitWith {[_x] call  blu_fnc_autoRifleman;};
    if (typeOf _x == "B_Soldier_AAR_F") exitWith {[_x] call  blu_fnc_asstAutoRifleman;};
    if (typeOf _x == "B_Soldier_GL_F") exitWith {[_x] call  blu_fnc_grenadier;};
    if (typeOf _x == "B_Soldier_M_F") exitWith {[_x] call  blu_fnc_marksman;};
    if (typeOf _x == "B_Soldier_lite_F") exitWith {[_x] call  blu_fnc_scout;};
    //Opfor functions
    if (typeOf _x == "O_Officer_F") exitWith {[_x] call op_fnc_squadLead;};
    if (typeOf _x == "O_Soldier_SL_F") exitWith {[_x] call op_fnc_squadLead;};
    if (typeOf _x == "O_Soldier_TL_F") exitWith {[_x] call op_fnc_teamLead;};
    if (typeOf _x == "O_Soldier_UAV_F") exitWith {[_x] call op_fnc_uavOp;};
    if (typeOf _x == "O_Medic_F") exitWith {[_x] call op_fnc_medic;};
    if (typeOf _x == "O_Soldier_AR_F") exitWith {[_x] call op_fnc_autoRifleman;};
    if (typeOf _x == "O_Soldier_AAR_F") exitWith {[_x] call op_fnc_asstAutoRifleman;};
    if (typeOf _x == "O_Soldier_GL_F") exitWith {[_x] call op_fnc_grenadier;};
    if (typeOf _x == "O_Soldier_M_F") exitWith {[_x] call op_fnc_marksman;};
    if (typeOf _x == "O_Soldier_lite_F") exitWith {[_x] call op_fnc_scout;};

} forEach _arrayOfUnits;
little eagle
#

the alive check is pointless. allUnits only reports alive units. allDeadMen is for dead units

plucky beacon
#

oh it does?

little eagle
#

Yup

plucky beacon
#

What about empty vehicles

little eagle
#

They are reported by neither allunits nor alldeadmen

plucky beacon
#

alright well I'll fix that

#

but in any case this isn't calling the loadout applicator

little eagle
#

Those two hints after each other are a bit impractical, aren't they?

#

lol

plucky beacon
#

just old code

little eagle
#

So you're saying it doesn't work

plucky beacon
#

ye, I'm gonna test it with a system chat in the loadoutApply and see if it's even reaching it

#

could be the public variable?

little eagle
#

looks fine to me, but idk what blu_fnc_squadLead actually is.

plucky beacon
#

blufor squad lead loadout

little eagle
#

show it

plucky beacon
#
private _unit = __unit select 0;

comment "Leader Unit";

comment "Remove existing items";
removeAllWeapons _unit;
removeAllItems _unit;
removeAllAssignedItems _unit;
removeUniform _unit;
removeVest _unit;
removeBackpack _unit;
removeHeadgear _unit;
removeGoggles _unit;

comment "Add containers";
_unit forceAddUniform "Gen3_Tan";
_unit addItemToUniform "ACE_EarPlugs";
_unit addItemToUniform "ACE_IR_Strobe_Item";
_unit addItemToUniform "ACE_Flashlight_XL50";
_unit addItemToUniform "ACE_MapTools";
for "_i" from 1 to 2 do {_unit addItemToUniform "ACE_tourniquet";};
_unit addItemToUniform "ACE_morphine";
_unit addItemToUniform "ACE_epinephrine";
for "_i" from 1 to 10 do {_unit addItemToUniform "ACE_elasticBandage";};
for "_i" from 1 to 2 do {_unit addItemToUniform "ACE_CableTie";};
_unit addItemToUniform "SmokeShellBlue";
_unit addItemToUniform "SmokeShellRed";
_unit addItemToUniform "CUP_15Rnd_9x19_M9";
_unit addVest "lbt_operator_coy";
for "_i" from 1 to 8 do {_unit addItemToVest "30Rnd_556x45_Stanag";};
for "_i" from 1 to 4 do {_unit addItemToVest "SmokeShell";};
for "_i" from 1 to 2 do {_unit addItemToVest "HandGrenade";};
for "_i" from 1 to 2 do {_unit addItemToVest "ACE_M84";};
_unit addHeadgear "rhsusf_mich_bare_norotos_arc_alt_tan_headset";

comment "Add weapons";
_unit addWeapon "SMA_MK18MOEBLK";
_unit addPrimaryWeaponItem "CUP_acc_ANPEQ_2";
_unit addPrimaryWeaponItem "RH_ta31rmr";
_unit addPrimaryWeaponItem "SMA_Gripod_01";
_unit addWeapon "CUP_hgun_M9";
_unit addWeapon "Binocular";

comment "Add items";
_unit linkItem "ItemMap";
_unit linkItem "ItemCompass";
_unit linkItem "ItemWatch";
_unit linkItem "tf_anprc152";
_unit linkItem "ItemGPS";
_unit linkItem "ACE_NVG_Gen4";
little eagle
#

first line is kaputt

#

private _unit = __unit select 0;

indigo snow
#

Watch out when doing find an replace lol

plucky beacon
#

wtf

#

goddamit

#

you're right, it was a find and repalce

little eagle
#

easy to tell it was "this" replace with "_unit"

#

turned "_this" into "__unit" : P

plucky beacon
#

le derp, I didn't even check because the laodout function I tested I changed the variable manually

little eagle
#

ยฏ_(ใƒ„)_/ยฏ

obtuse cosmos
#

Hi all, is anyone having issues with the disableAI command or is it just me? It doesn't make a difference where or how I execute it either, Wiki says to execute it where the AI unit is local, still doesn't work for me. I'm not sure what I'm doing wrong, I haven't had any issues with this command before. I'm on the latest stable version. _dummyUnit disableAI "ALL";

plucky beacon
#

are you on a dedicated server?

obtuse cosmos
#

Testing just in the editor for now.

plucky beacon
#

I'll try myself

#

also are you using and AI modifying mods?

obtuse cosmos
#

Nope, no mods.

plucky beacon
#

well I spawned a unit and used it in the unit's init

#

this disableAI "ALL";

obtuse cosmos
#

Ah, hold on.

plucky beacon
#

so _dummyUnit must not be found correctly

obtuse cosmos
#

I just did this in debug console: dummyUnit = (createGroup civilian) createUnit [(typeOf player), (getPos player), [], 0, "LINE"]; dummyUnit disableAI "ALL";

#

It seems to work BUT, the ANIM part doesn't.

#

Maybe I am misunderstanding something? Does ANIM stop all animations? Including head turning, etc...?

plucky beacon
#

everything but head turning

#

you want to disableSimulation then

#

disableAnim stops the switchMove

#
0 = [] spawn { 
_dummyUnit = (createGroup civilian) createUnit [(typeOf player), (getPos player), [], 0, "LINE"];  
_dummyUnit disableAI "ALL";
_dummyUnit enableSimulationGlobal false; 
};
obtuse cosmos
#

Ah, okay.

plucky beacon
#

use that in the pause debug

#

he's be as still as a wax statue

obtuse cosmos
#

Yeah, I know about that but, I can't use that command atm. It seems to break something else I'm doing, lol. ๐Ÿ˜„

plucky beacon
#

I guess he'll just have to retain his freedom to move his head, lol

obtuse cosmos
#

Haha lol

#

Not just what is causing the issue exactly but, when I use it, the camera zoom (Fov) doesn't appear to work. ๐Ÿ˜ฆ

plucky beacon
#

for the player?

little eagle
#

"ALL" - all of the above Available since Arma 3 v1.65

obtuse cosmos
#

Yeah, we are on 1.66, no?

little eagle
#

I think so. Maybe it's broken.

obtuse cosmos
#

Nah, it's resolved. It just doesn't apply for head turning is all.

#

Was my bad.

plucky beacon
#

that's what my game says

obtuse cosmos
#

๐Ÿ˜ƒ

#

_dummyUnit = (createGroup civilian) createUnit [(typeOf player), [0, 0, 0], [], 0, "LINE"];
_dummyUnit setUnitLoadout (getUnitLoadout player);
_dummyUnit switchMove "AmovPercMstpSrasWrflDnon_Salute";
_dummyUnit disableAI "ALL";
_dummyUnit enableSimulation false;

_camera = "camera" camCreate (getPos _dummyUnit);
_camera camPrepareTarget _dummyUnit;
_camera camPrepareFov 0.31;
_camera attachTo [_dummyUnit, [0, 3.55, 1.79]];
_camera camCommitPrepared 0.03;
_camera cameraEffect ["internal", "back", "characterPreview"];

#

How do you do the code tags?

plucky beacon
#

you mean like functions?

little eagle
#

```sqf
code
```

plucky beacon
#

oh on Discord

obtuse cosmos
#

Yes, lol. On Discord.

plucky beacon
#

I got it working commy, the unit has the loadout applied based on their classname

little eagle
#

top

#

Arma3Update168RC

#

is live

plucky beacon
#

wait, today?

obtuse cosmos
#

Anyway, that code I pasted. It all works good. The enableSimulation stops the Fov some how... ๐Ÿ˜ฆ

little eagle
#

Yes, you can dl the RC branch now.

plucky beacon
#

oh shit I oughta do that

obtuse cosmos
#

Is it okay to send screenshots here? Just want to send two, so you can see the issue I am having.

plucky beacon
#

you can't upload files so just link it

#

nothing is embedded

obtuse cosmos
#

rgr

#

Okay, so... When I use the enableSimulation command, it messes up, like so:

#

When I don't use the command though, it shows fine...

plucky beacon
#

well simulation disables any kind of zoom and stuff

obtuse cosmos
#

For the camera though? Is it suppose to?

plucky beacon
#

you might want to spawn them looking at something, maybe targeting scripts

obtuse cosmos
#

The zoom is by the camera, enableSimulation is on the unit.

plucky beacon
#

simulation does some weird stuff

obtuse cosmos
#

What you mean, targeting scripts?

plucky beacon
#

I don't know if any of them will do what you want but that's what I'd guess

obtuse cosmos
#

I don't see why I need this? Also, read notes, doesn't work with soldier weapons.

plucky beacon
#

there is one that does but I can't find it

obtuse cosmos
#

I don't want the AI to do anything really, that's why I tried disableAI but the head turning still happens, enableSimulation stops all that and is great however, it breaks the zoom thing.

plucky beacon
#

that's my best guess

obtuse cosmos
#

???

#

I don't think you are understanding what I'm saying.

#

I'm not trying to get the unit to target or do anything.

plucky beacon
#

If a unit is looking at a dummy target in front of them they won't move their head

obtuse cosmos
#

No.

plucky beacon
#

no?

obtuse cosmos
#

That is PIP (picture in picture) made with ctrlCreate (RscPicture)

plucky beacon
#

yes

obtuse cosmos
#

One of us is confused, lol. ๐Ÿ˜„

#

Ah, are you saying that doTarget/doMove will stop the head turning?

plucky beacon
#

You said "camera doesn't zoom because simulation is disabled" and "head moves around when simulation is enabled" so I said leave simulation enabled and have him stare at a dummy target in front of him.

obtuse cosmos
#

I guess that's what you meant.

plucky beacon
#

but I'm an idiot because he literally can't target anything

obtuse cosmos
#

๐Ÿ˜ƒ

#

It would be nice to just know why it breaks the camera zoom thing, even if I have to do a work around.

plucky beacon
#

the only reference to dummytarget is the position anyway right?

rancid ruin
#

haz try doing the cam stuff before disabling simulation

obtuse cosmos
#

rgr - Will try.

#

Ah, yeah... I forgot that I already tried that I think, I just tried it again to be sure. Doesn't make a difference.

#

Issue still happens.

rancid ruin
#

pastebin the script

obtuse cosmos
#

xD

#

I pasted all necessary code already, scroll up.

rancid ruin
#

ah i see

#

do it without attaching

#

get a pos using modeltoworld and then put the cam in that position

obtuse cosmos
#

Ah... Thank you, it works now! I commented out the attachTo line and changed the camCreate line with:

#

_camera = "camera" camCreate (_dummyUnit modelToWorld [0, 3.55, 1.79]);

#

Thanks again. ๐Ÿ˜ƒ

rancid ruin
#

no problem

#

i was searching my arma folder, i made a gear selector using PIP in a dialog, couldn't find it though

obtuse cosmos
#

The one I have is for the A3 Inventory dialog, was just an idea I was trying I guess.

rancid ruin
#

i remember the problem i ran in to - if you disable PIP in options then the ctrl will just show black

obtuse cosmos
#

Yeah.

rancid ruin
#

ended up using a normal camera in the end

#

fucked if i can find my script though

obtuse cosmos
plucky beacon
#

doesn't DayZ do this? the inventory witha clone of yourself on the menu?

obtuse cosmos
#

๐Ÿ˜„

#

That's where I kinda got the idea, that and a few other games.

#

I don't play DayZ though, nor do I own a copy of it. Just saw it in a video.

plucky beacon
#

I regret buying

obtuse cosmos
#

(:

austere granite
#

Is there a way at all to make sure rscTitles appear above dialogs/custom created displays?

tiny wadi
#

Hello, Ive made a rope and ive attached it to a helicopter

#

then ive used ropeAttachTo on another object but the object ive attached to the rope doesnt stay with the rope and just breaks away

plucky beacon
#

they break when too much tension si applied so their probably just breaking

#

also make sure the simulation of the object being picked up is enabled

little eagle
#

QS, sounds like they're moving some assets from ebo to pbo.

plucky beacon
little eagle
#

what is remainOpfor ?

plucky beacon
#

private ["_aliveCount","_OpforUnits","_tempString"];

_OpforUnits = [];

{
    _tempString = str _x;
    _OpforUnits pushBack _tempString;
}forEach (_this select 0);

_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _OpforUnits;

_formattedOpfor = format ["Units: %1, number of units in array: %2", _OpforUnits, count _OpforUnits];

hint _formattedOpfor;

if(_aliveCount == 1) exitWith
{
    [[],"LastOne.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 0) exitWith
{
    [[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
};

more embaressing code

#

is a unit leaves mid game should I be checking to see if they're nil?

#

unit meaning player

little eagle
#

So it's a function?

plucky beacon
#

ya

little eagle
#

You have to pass the function by name (string) and not the function

#

That would be huge network traffic.

#

You understand?

plucky beacon
#

brb looking at wiki

little eagle
#

lol

plucky beacon
#

oh I see

little eagle
#

just put some quote marks around it

plucky beacon
#

so "remainOpfor"

little eagle
#

yup

plucky beacon
#

just wanted to see if teh example confirmed my understanding

tiny wadi
#

@plucky beacon enabled simulation on the object being towed but still no luck

plucky beacon
#

it must be too heavy

#

there are setMass commands I think, don't know if that will work though

jade abyss
#

Yep

#

Or that Object has no PhysX. If so: Obj stands still.

plucky beacon
#

tries lifting house
house dosn't get picked up

#

rip my dreams of a house sized wrecking ball

civic maple
#

nooooo

jade abyss
#

Place one via Editor, then try it again.

#

(min. Hemmtt)

plucky beacon
#

so I have this function that after checking what's on the blufor side, spwns the appropriate counterpart for the opfor side.
Choose Enemies

private ["_bluforUnits"];
_bluforUnits = _this select 1;

{
    if (typeOf _x == "B_Officer_F") exitWith {[_x , "O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Soldier_SL_F") exitWith {[_x , "O_Soldier_SL_F"] call  missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Soldier_TL_F") exitWith {[_x , "O_Soldier_TL_F"] call  missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Soldier_UAV_F") exitWith {[_x , "O_Soldier_UAV_F"] call  missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Medic_F") exitWith {[_x , "O_Medic_F"] call  missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Soldier_AR_F") exitWith {[_x , "O_Soldier_AR_F"] call  missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Soldier_AAR_F") exitWith {[_x , "O_Soldier_AAR_F"] call  missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Soldier_GL_F") exitWith {[_x , "O_Soldier_GL_F"] call  missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Soldier_M_F") exitWith {[_x , "O_Soldier_M_F"] call  missionStarter_fnc_spawnEnemies;};
    if (typeOf _x == "B_Soldier_lite_F") exitWith {[_x , "O_Soldier_lite_F"] call  missionStarter_fnc_spawnEnemies;};
}forEach _bluforUnits;

Spawn Enemies

priavte ["_bluforUnit","_opforClassname","_markerPos","_newUnit"];

_bluforUnit = _this select 0;
_opforClassname = _this select 1;
_markerPos = getMarkerPos "Opfor_Start";

_newUnit = createVehicle [_opforClassname, getMarkerPos "marker1", [], 5, "NONE"];
#

Whats the best way to make sure opfor are all in a group

dusk sage
#

Use a switch ๐Ÿ˜„ @plucky beacon

little eagle
#

make it case insensitive so you can actually use it @BuGuu

austere granite
#

put the opfor class on a var / return, and pass that instead of having the function name 10 times

#

what else? ๐Ÿ˜„

dusk sage
#
switch (toLower ....)```
austere granite
#

use params or at least inline private _bluforUnits ? ๐Ÿ˜„

little eagle
#

create a pseudo namespace, assign these functions as variables with the varname being the classname once and then just read the correct function from the namespace.

#

that is also faster with more than one unit

plucky beacon
#

Oh boy

#

Uhhh

dusk sage
#

Way to blow his mind commy

plucky beacon
#

@austere granite I can't inline because the opfor are spawned individually by the function.

#

Lets start with making this a switch case

dusk sage
#

Need some dictionaries in SQF

plucky beacon
#

Well we talked about namespaces yesterday but i don't know how I would make a psuedo one

#

I know how to reference the missionnamespace to find a global variable.

#

So basically

Switch(_classname) do {
Case "B_Soldier_AR_f" :{code}
}
#

Im on my phone rn but that's the idea of it

dusk sage
#

Yes

#

Commy pointed out possible problems with case

#

You can combat that by using toLower and writing your hard coded class names in lower case

little eagle
#

once:

missionStarter_spawnEnemiesNamespace = [] call CBA_fnc_createNamespace;

missionStarter_spawnEnemiesNamespace setVariable ["B_Officer_F", {[_x , "O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_SL_F", {[_x , "O_Soldier_SL_F"] call  missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_TL_F", {[_x , "O_Soldier_TL_F"] call  missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_UAV_F", {[_x , "O_Soldier_UAV_F"] call  missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Medic_F", {[_x , "O_Medic_F"] call  missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_AR_F", {[_x , "O_Soldier_AR_F"] call  missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_AAR_F", {[_x , "O_Soldier_AAR_F"] call  missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_GL_F", {[_x , "O_Soldier_GL_F"] call  missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_M_F", {[_x , "O_Soldier_M_F"] call  missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_lite_F", {[_x , "O_Soldier_lite_F"] call  missionStarter_fnc_spawnEnemies;}];

per unit:

call (missionStarter_spawnEnemiesNamespace getVariable typeOf _unit);
#

that is case insensitive

rancid ruin
#

adds a mod requirement doe

little eagle
#

The loadouts use ace items

#

iirc

plucky beacon
#

If it's possible to I want to keep dependy out

rancid ruin
#

does CBA technically need to be a mod in the first place? isn't it just scripts?

little eagle
#

CBA as a whole?

plucky beacon
#

So just

_classname = toLower (typeOf _x)
#

Couldn't that work?

rancid ruin
#

yeah it doesn't have any .dlls in it or anything does it?

little eagle
#

if you write them all in lower case, yeah

#

XEH uses config changes. there are a bunch of other config changes too

rancid ruin
#

oh yeah

little eagle
#

If A4 ever comes around and it's still useful, then rewrite everything from scratch and try to not have configs I guess.

#

But it's just not possible in some cases.

plucky beacon
#

do I also need to lowercase the string next to "case" ?

little eagle
#

yes

plucky beacon
#

oh good, I did

thick ridge
#

Running into a bit of an issue with the lineIntersects commands - seems like it doesn't detect static map objects far away from the player when the game first starts. If I move the player where it stops detecting static map objects, and then restart the mission, the command starts detecting them.

#

Seems like the static map objects aren't loaded it memory unless the player is nearby

meager granite
#

Exactly that

polar folio
#

what's the relation between text size and safezoneH? trying to have a control that is exactly as high as the text size

thick ridge
#

thanks Sa-Matra!

#

hi badbenson

polar folio
#

hi master of ropes. good to see you. choochoo! can't wait for the train man. looks liek a lot fo fun to play around with

meager granite
#

text size is ui height value

#

Text size = SafeZoneH = letters as high as entire screen

polar folio
#

hm yea. in dialogs but inside parseText stuff it seems different

meager granite
#

You mean <t size=> size?

polar folio
#

ye

meager granite
#

It is relative to control's text size

#

size=2 means size * 2

polar folio
#

ah. let me test some stuff with that thought. thx so far

thick ridge
#

Sa-Matra, thanks that fixed it

plucky beacon
#

gaaah this thing, keep getting the error in the image

BluforPlayers = [];

{
    if(side _x == west) then 
    {
        if(alive _x) then 
        {
            BluforPlayers pushBack _x;
        };
    };
}forEach allUnits;

publicVariable "BluforPlayers";

{
    _x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2];
} forEach BluforPlayers;
private ["_bluforUnit","_classname","_LowerClassname"];
_bluforUnit = (_this select 0);
_classname = (typeOf _bluforUnit);
_LowerClassname = (toLower _classname);
switch (_LowerClassname) do {
    case "b_officer_f": {["O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_soldier_sl_f": {["O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_soldier_tl_f": {["O_Soldier_TL_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_soldier_uav_f": {["O_Soldier_UAV_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_medic_f": {["O_Medic_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_soldier_ar_f": {["O_Soldier_AR_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_soldier_aar_f": {["O_Soldier_AAR_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_soldier_gl_f": {["O_Soldier_GL_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_soldier_m_f": {["O_Soldier_M_F"] call missionStarter_fnc_spawnEnemies;};
    case "b_soldier_lite_f": {["O_Soldier_lite_F"] call missionStarter_fnc_spawnEnemies;};
    default { hint "Classname not valid" };
};

https://i.gyazo.com/64c381880e3477cdcdb803fcbfec032b.png

#

and all those private variables are me trying to figure out where exactly it's coming from, I've changed it back to [] for the arguments but then it says it wants an objcet

#

because I guess select 0 is an array, but an array of one object?

#

now it's working now that I made the arguments in brackets again, but I'm getting another error

#

because it says this

if (MissionActive) then
{
    _newUnit addEventHandler ["killed", {[OpforPlayers] remoteExecCall ["missionStarter_fnc_remainOpfor", 2]; }];
};

can't work like

[_x]  addEventHandler ["...
#

do I have to (select 0 (select 0))?

dusk sage
#

Also, it's telling you that you're selecting an from an object type. You are using _x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2]; so _this is an object, not an array, you need to pass [_x] or do _bluforUnit = _this

plucky beacon
#

oh shit it has to equal something?

dusk sage
#

read second one

#

I was just trying to save you writing the same thing over and over

plucky beacon
#

thaaaaanks

#

I see now

meager granite
#

Why not more that table into config?

plucky beacon
#

huh?

meager granite
#
class MyTableOfWhatever {
    b_officer_f            = "O_Soldier_SL_F";
    b_soldier_sl_f        = "O_Soldier_SL_F";
    b_soldier_tl_f        = "O_Soldier_TL_F";
    b_soldier_uav_f        = "O_Soldier_UAV_F";
    b_medic_f            = "O_Medic_F";
    b_soldier_ar_f        = "O_Soldier_AR_F";
    b_soldier_aar_f        = "O_Soldier_AAR_F";
    b_soldier_gl_f        = "O_Soldier_GL_F";
    b_soldier_m_f        = "O_Soldier_M_F";
    b_soldier_lite_f        = "O_Soldier_lite_F";
};

and then do

_opforUnit = getText(missionConfigFile >> "MyTableOfWhatever" >> typeOf _bluforUnit);
plucky beacon
#

because every time I do it one way someone else tells me to do it another way. I've changed it 4 times now

meager granite
#

Well you now learned 5 ways to do same thing

plucky beacon
#

yes

#

and no matter what way it checks the cases it's still not working so I'd like to get that problem solved

meager granite
#

Day well spent ๐Ÿ‘Œ

plucky beacon
#

where the hell are all these brackets coming from, they're littered in my code

#

wtf happened

meager granite
#

So what are you trying to do again?

#

Spawn some opfor units depending on blufor units?

plucky beacon
#

ya

meager granite
#

And why remoteExecCall ?

#

Are you calling this from client to server?

plucky beacon
#

client of the group leader

#

so they are the only ones that can "start" the mission

#

and then it sends to the server

#

as well as a few redundancies

meager granite
#

Why do you iterate all units and not just client's group units?

plucky beacon
#

because they're not all in one group?

meager granite
#

well you just said client of the group leader

plucky beacon
#

starts the script

meager granite
#

So practically all this is gonna be executed only once?

plucky beacon
#

yes

meager granite
#

On server start?

#

After everyone is loaded?

plucky beacon
#

on "mission start" which is defined by a public boolean

#

set by an addaction

meager granite
#

Why not do everything on server?

plucky beacon
#

it does, I'm just redundant like that

meager granite
#

Client -> Send a flag to server

#

Server does everything

plucky beacon
#

yes

#

yup

#

that's what I'm doing

meager granite
#

Client on add action or whatever:

remoteExecCall ["missionStarter_fnc_gimmeEnemies", 2];

Server's fn_gimmeEnemies.sqf:

allUnits select {
    side group _x == blufor
} apply {
    _class = getText(missionConfigFile >> "MyTableOfWhatever" >> typeOf _x);
    if(_class != "") then {
        // createUnit or whatever you want here
    };
}
plucky beacon
#

init_mission.sqf

_unit = _this select 1;

if (_unit != Leader_1) exitWith {hint "You are not the leader, mission must be initiated by the leader.";};
//if (isNil "Leader_1") exitWith {hint "There is no group leader"};

hint "Unit is leader, calling initMission script locally";
systemchat "Unit is leader, calling initMission script locally";
MissionActive = true;
publicVariable "MissionActive";
[[],"initMission_local.sqf"] remoteExec ["execVM",0,true];
sleep 12;
[] remoteExecCall ["missionStarter_fnc_getUnits", 2, false];
meager granite
#

init_mission.sqf is triggered from addAction?

plucky beacon
#

ya

meager granite
#

Do you need MissionActive flag only so server does something on addPublicVariableEventHandler?

plucky beacon
#

It's used in some if checks

meager granite
#

I don't see any check for activating the action again

dusk sage
#

who needs if then {} else {} syntax

#

select {} apply {} looks way cooler

plucky beacon
#

the action is deleted in the local script

dusk sage
#

๐Ÿ˜Ž

meager granite
#

Well you can call action several times on same frame with macros

plucky beacon
#

okay hold up

#

STAHP

meager granite
#

Don't trust the player

plucky beacon
#

can we solve problem #1 first

#

the case switch

#
private ["_bluforUnit","_classname","_LowerClassname","_caseResult"];
_bluforUnit = _this;    
private _caseResult = switch (toLower _bluforUnit) do {
    case "b_officer_f": {"O_Soldier_SL_F"};
    case "b_soldier_sl_f": {"O_Soldier_SL_F"};
    case "b_soldier_tl_f": {"O_Soldier_TL_F"};
    case "b_soldier_uav_f": {"O_Soldier_UAV_F"};
    case "b_medic_f": {"O_Medic_F"};
    case "b_soldier_ar_f": {"O_Soldier_AR_F"};
    case "b_soldier_aar_f": {"O_Soldier_AAR_F"};
    case "b_soldier_gl_f": {"O_Soldier_GL_F"};
    case "b_soldier_m_f": {"O_Soldier_M_F"};
    case "b_soldier_lite_f": {"O_Soldier_lite_F"};
    default { hint "Classname not valid"; "" };
};

if (_caseResult isEqualTo "") exitWith {};

[_caseResult] call missionStarter_fnc_spawnEnemies;
#

blufor unit is the classname that's being passed

meager granite
#

Well you forgot typeOf

plucky beacon
#

from...

meager granite
#

You're trying to lower actual unit, not its class

dusk sage
#
_classname = (typeOf _bluforUnit);
_LowerClassname = (toLower _classname);
#

this bit

#

From your last

plucky beacon
#

oh fuck me

#

duh

#
_LowerClassname = (toLower (typeOf (_this)));
#

would this work?

meager granite
#

yes

plucky beacon
#

neat

meager granite
#

you don't even need parenthesis

#

as all commands are unary

plucky beacon
#

I'll keep because they look neat

dusk sage
#

think of the bytes

#

they are going extinct

plucky beacon
#

fuck your bytes

meager granite
#

Think how much world traffic you can save by removing parenthesis

plucky beacon
#

I paid for mine faire an square

#

also what was that about event handlers? I can create my own?

meager granite
#

Event handlers are engine event handlers

#

There is set of engine events that can call whatever scripts you assign to them

plucky beacon
#

So what was your reccomendation for the addaction?

#

addPublicVariableEventHandler?

meager granite
#

To do what?

#

To send a flag to server to do something?

plucky beacon
#

ya

#

so basically you can only send it to the server once

meager granite
#

remoteExec* is ideal for that

#

You can do it through pveh if you want too

#

To make sure you send it once just add a check before sending it again

#

init_mission.sqf:

_unit = _this select 1;
if (_unit != Leader_1) exitWith {hint "You are not the leader, mission must be initiated by the leader.";};
if (MissionActive) exitWith {hint "Its already on"};
MissionActive = true;
publicVariable "MissionActive";

remoteExecCall ["missionStarter_fnc_gimmeEnemies", 2];
plucky beacon
#

oh so it's just another if?

meager granite
#

Actually MissionActive might not be initialized at all so

if(missionNamespace getVariable ["MissionActive", false]) exitWith {hint "Its already on"};
#

Of course, just dont let player send the flag again

#

Since its the only source where this flag can be set from right now

plucky beacon
#

stupid strings, I messed up my code where it didn't need to be fixed

#

trying to get that other part workign

plucky beacon
#

This is weird

private ["_aliveCount","_OpforUnits","_tempString"];

_OpforUnits = [];

{
    _tempString = str _x;
    _OpforUnits pushBack _tempString;
}forEach (_this select 0);

_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _OpforUnits;

_formattedOpfor = format ["Units: %1, number of units in array: %2", _OpforUnits, count _OpforUnits];

hint _formattedOpfor;
systemChat _formattedOpfor;

if(_aliveCount == 2) exitWith
{
    [[],"LastOne.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 1) exitWith
{
    [[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
};

it's output to system chat shows the 34 elements but the count is incorrect and ends the mission.

#

it happens after this in the getUnits file

{
    _x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2];
} forEach BluforPlayers;

{
    if(alive _x) then 
    {
        if (side _x == east) then 
        {
            OpforPlayers pushBack _x;
        };
    };
}forEach allUnits;

publicVariable "OpforPlayers";
/*
{
    [_x] call missionStarter_fnc_loadoutApply;
    if (MissionActive) then
    {
        _x addEventHandler ["killed", {[OpforPlayers] remoteExecCall ["missionStarter_fnc_remainOpfor", 2]; }];
    };
} forEach OpforPlayers;
*/
[OpforPlayers] call missionStarter_fnc_remainOpfor;
meager granite
#

NotLikeThis

#

When do you call second listing?

plucky beacon
#

sorry just got back

#

call the second listing? you mean _alive count?

meager granite
#

I mean what calls second script listing

#

When and how much

plucky beacon
#

oh, it's at the end of getUnits

#

gimme a second I'll copy it here after I delete some comments

#
BluforPlayers = [];
OpforPlayers = [];

{
    if(side _x == west) then 
    {
        if(alive _x) then 
        {
            BluforPlayers pushBack _x;
        };
    };
}forEach allUnits;
publicVariable "BluforPlayers";

_formattedBlufor = format ["Units: %1, number of units in array: %2", BluforPlayers, count BluforPlayers];
hint _formattedBlufor;

{
    [_x] call missionStarter_fnc_loadoutApply;
    if (MissionActive) then
    {
        _x addEventHandler ["killed", {[BluforPlayers] remoteExecCall ["missionStarter_fnc_remainBlufor", 2]; }];
    };
} forEach BluforPlayers;

[BluforPlayers] call missionStarter_fnc_remainBlufor;

{
    _x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2];
} forEach BluforPlayers;

{
    if(alive _x) then 
    {
        if (side _x == east) then 
        {
            OpforPlayers pushBack _x;
        };
    };
}forEach allUnits;

publicVariable "OpforPlayers";

[OpforPlayers] call missionStarter_fnc_remainOpfor;
#

So this, being called from the initMission, the Opfor players gets passed onto remainOpfor

#
private ["_aliveCount","_OpforUnits","_tempString"];

_OpforUnits = [];

{
    _tempString = str _x;
    _OpforUnits pushBack _tempString;
}forEach (_this select 0);

_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _OpforUnits;

_formattedOpfor = format ["Units: %1, number of units in array: %2", _OpforUnits, count _OpforUnits];

hint _formattedOpfor;
systemChat _formattedOpfor;

if(_aliveCount == 2) exitWith
{
    [[],"LastOne.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 1) exitWith
{
    [[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
};
meager granite
#

This is so bad I'd just Ctrl+A & Del it

plucky beacon
#

LOL

#

no

#
_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _OpforUnits;

it's probably this line

#

because originally it was designed to take out nil units

meager granite
#

Why do you turn units into str and then trying to turn them back into units with getVariable ๐Ÿค”

plucky beacon
#

because isNil doesn't work from objects

dusk sage
#

because he had undefined units which were erroring him out ๐Ÿ˜›

meager granite
#

isNull

plucky beacon
#

isNil

#

Nil

#

non existent not empty

meager granite
#

Vehicle var names are cancer ruining the day for new scripters

#

How do you create opfor units btw?

plucky beacon
#
private ["_bluforUnit","_opforClassname","_markerPos","_newUnit"];

//_bluforUnit = _this select 0;
_opforClassname = _this select 0;
_markerPos = getMarkerPos "Opfor_Start";

_newUnit = group OpGrpLead createUnit [_opforClassname, getMarkerPos "opfor_start", [], 0, "NONE"];
_newUnit disableAI "MOVE";

[_newUnit] call missionStarter_fnc_loadoutApply;
if (MissionActive) then
{
    _newUnit addEventHandler ["killed", {[OpforPlayers] remoteExecCall ["missionStarter_fnc_remainOpfor", 2]; }];
};

zMod1 addCuratorEditableObjects [[_newUnit],true ];
zMod2 addCuratorEditableObjects [[_newUnit],true ];
zMod3 addCuratorEditableObjects [[_newUnit],true ];
#

this is after the case switch

#

and this part is working already, it creates the units and outputs the array of them in system chat

meager granite
#

Ok, I expected you naming each unit individually or something

#

allUnits already returns only alive units btw

plucky beacon
#

I know, that's why alive count is probably the issue

meager granite
#

Not really, it just does nothing

#

allUnits command already returns alive units only

#

Anyway, you don't need any str _tempString stuff

plucky beacon
#

it used to be a problem of detecting nil units but not anymore

meager granite
#

you already get array of units, work with it

plucky beacon
#

the string stuff was for nil

#

gimme a min

meager granite
#

I get what you're trying to do, but your newly created units don't have vehicle var names so you can str them into variable name

#

(_this select 0) is already array of units

#

Just work with it

#

Even more there is no point in checking which units are alive, allUnits already returns alive units only

#

You're sending it into another function and doing alive check 2nd time

#

It all makes no sense

plucky beacon
#

but it's not all units because the global variable is only updated when using the publicVariable command

meager granite
#

Why do you even publicVariable it?

plucky beacon
#

this meant to be run on every death

#

it used to be for using in other files

#

but if I'm passing throuhg functions I don't need to anymore

meager granite
#

Also you know what "Killed" event handler is local to whoever owns the unit?

#

Looks like you assigning it to blufor units only on server

#

It will never run in real MP

ionic orchid
#

I wish drawTri3D or drawPoly3D was a thing

#

well I guess fillTri3D or fillPoly3D, really

plucky beacon
#

even with remoteExecCall?

meager granite
#

It wouldn't even get to remoteExecCall

#

If you assign Killed event handler to remote unit, it will never ever get executed

#

Unless ownership transfers to you

#

(Nobody say anything about MPKilled, it will make things worse)

plucky beacon
#

So how else would I run the function on each death

meager granite
#

Anyway, the whole thing is really badly designed

#

Its really hard to help you fix it

plucky beacon
#

that's not helpful

#

i.e. that I guess

meager granite
#

In your situation I'd create a scheduled thread and check alive units each second or something

#

BUT if you really want to do it through Killed event handler you'd have to do it differently

plucky beacon
#

I originally did that but was told to do it another ay

meager granite
#

You need to understand who will own units in the mission and in which situations

#

I guess OPFOR units will always be owned by server, right?

plucky beacon
#

yes

meager granite
#

You can use Killed event handler there, might as well assign it right after you create the unit

plucky beacon
#

that's what it does already

meager granite
#

The problem is with BLUFOR

#

Do you allow AI units on BLUFOR?

plucky beacon
#

There will be situations where it's only players

meager granite
#

so you have disableAI = 1 in mission config?

#

So when player leaves unit just dies

plucky beacon
#

I probably will, haven't decided yet

meager granite
#

Anyway, lets make it work either way

#

Basically you will need to either:
a) Assign Killed event handler to each blufor unit on each client, preferably including server
b) Assign MPKilled to each blufor unit but only from server

#

How initMission is called again?

plucky beacon
#

by an addaction

meager granite
#

So client pressed action, remoteExec starts initMission on server?

plucky beacon
#
this addaction ["<t color='#4286f4'>Start Mission</t>", "initMission.sqf",nil,6,true,false,"","",2];
#

the remote exec is after it checks if the local unit is the leader

meager granite
#

I don't get it, you had some leader check before

#

or it was another action?

plucky beacon
#

ya it's in the script

#
_unit = _this select 1;

if (_unit != Leader_1) exitWith {hint "You are not the leader, mission must be initiated by the leader.";};

//if (isNil "Leader_1") exitWith {hint "There is no group leader"};

if (MissionActive) exitWith {hint "Its already on"};

hint "Unit is leader, calling initMission script locally";
systemchat "Unit is leader, calling initMission script locally";
MissionActive = true;
publicVariable "MissionActive";
[[],"initMission_local.sqf"] remoteExec ["execVM",0,true];
sleep 12;
[] remoteExecCall ["missionStarter_fnc_getUnits", 2, false];
#

so it checks there, then says that it passed

meager granite
#

calling initMission script locally

#

Your remoteExec calls it for each client + ones that will join afterwards

plucky beacon
#

yes

meager granite
#

Its not locally then

plucky beacon
#

local for each client?

meager granite
#

Its globally

plucky beacon
#

I guess? the point is it runs on each client, and stuff happens locally on each client

#

does local have to only happen on one unit?

meager granite
#

And then each client does
[[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
in the end?

#

Each client sends execVM remote exec to each client resulting in ^ 2 remote execs

plucky beacon
#

yes on the basis that all opfor are dead

#

calculated by the count of the array

meager granite
#

You don't need to count dead units on each client if you're gonna remoteExec victory to everyone

#

just count in one place (server) and then when server decides its game over, remoteExec victory

plucky beacon
#

    EndScreen = true;
    sleep 1;
    playMusic "Victory";
    sleep 2;
    Command sideRadio "MissionAccomplished";
    ["Command", "Mission Accomplished! Well done!"] call BIS_fnc_showSubtitle;
    sleep 2;
    ["End1",True,True,False] call BIS_fnc_endMission;
#

that's what the remainOpfor does

#

remainOpfor happens on the server

#
private ["_aliveCount","_OpforUnits"];

_aliveCount = {!isNull _x && {alive _x}} count (_this select 0);

_formattedOpfor = format ["Units: %1, number of units in array: %2", _OpforUnits, count _OpforUnits];

hint _formattedOpfor;
systemChat _formattedOpfor;

if(_aliveCount == 2) exitWith
{
    [[],"LastOne.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 1) exitWith
{
    [[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
};
meager granite
#

[OpforPlayers] call missionStarter_fnc_remainOpfor;

#

Its called in that initMission

plucky beacon
#

Then it needs to be remoteExecCall because that's supposed to be the first check?

meager granite
#

Nevermind last message, forgot about Killed event handlers

plucky beacon
#

oh

meager granite
#

Basically you're doing useless work on clients, clients don't need to even know about opfor units

plucky beacon
#

what work is uesless ont he client

meager granite
#

The logic should be following:

Client: Press action, send flag to server
Server: Create units
Server: Assign event handlers to handle remaining units
Server: On event handlers send out game over remoteExec's

plucky beacon
#

client presses action, initmission local starts


removeAllActions vehicleSpawner_1;
removeAllActions vehicleSpawner_2;
removeAllActions vehicleSpawner_3;
removeAllActions vehicleSpawner_4;
removeAllActions vehicleSpawner_5;
removeAllActions vehicleSpawner_6;
removeAllActions vehicleSpawner_7;
removeAllActions SpawnerSign;
removeAllActions MissionStarter;

INIT_TIME = 10;
Button_Time = 0;

BEGIN_TIME = diag_tickTime + 0;
while {Button_Time < INIT_TIME} do 
{
    Button_Time = diag_tickTime - BEGIN_TIME;
    uiSleep 0.99;
    
    _time = INIT_TIME - Button_Time;
    _finish_time_minutes = floor(_time / 60);
    _finish_time_seconds = floor(_time) - (60 * _finish_time_minutes);
    
    if(_finish_time_seconds < 10) then
    {
        _finish_time_seconds = format ["%1", _finish_time_seconds];
    };
    
    _formatted_time = format ["%1", _finish_time_seconds];

    hintSilent format ["Operation starting in: %1", _formatted_time];
};

cutText  ["", "BLACK OUT"];
sleep 1;
player setPos (getMarkerPos "west_start");
cutText  ["", "BLACK IN"];
MissionActive = true;
publicVariable "MissionActive";

hint "timer script calling";
systemchat "timer script calling";
playMusic "Intro";

setPlayerRespawnTime 999999;

if(isServer) then {
    [[],"timer.sqf"] remoteExec ["execVM",0,true];
};
#

this doesn't go anwywere else it ends here

#

then the server runs the timer

#
[] remoteExecCall ["missionStarter_fnc_getUnits", 2, false];

starts the server functions

#

getUnits use remoteExecCall to the server redundantly but still to the server nonthe less

meager granite
#

You're confusing me with all these script listing without naming what files are which

#

MissionActive = true;
publicVariable "MissionActive"; in that script above

#

I have no idea what the hell is going on

#

You just said that MissionActive sets in addAction

#

Or that huge script above is now addAction or something?

plucky beacon
#

it's redundant

meager granite
#

initMission_local.sqf is global

#

initMission.sqf is local

#

initMission_local.sqf is called for every client including server
initMission.sqf is called only on client that pressed addAction

plucky beacon
#

หขแต’ แถฆ หขสฐแต’แต˜แถซแตˆ แต–สณแต’แต‡แตƒแต‡แถซสธ สณแต‰แถฐแตƒแตแต‰ แต—สฐแต‰แต

meager granite
#

Why do you do
if (MissionActive) then
checks in fn_getUnits if you set MissionActive to true in initMission.sqf anyway?

#

if fn_getUnits is called only on server, why do you remoteExec server again with

_x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2];
#

Just do _x call missionStarter_fnc_chooseEnemies

plucky beacon
#

because I'm an doofus who does redundant things

meager granite
#

I was under impression your getUnits script was executing on each client because of that

#

Why else you would need to remoteExec server if its already server

plucky beacon
#

because I'm a doofus who does redundant things

meager granite
#

[_x] call missionStarter_fnc_loadoutApply

plucky beacon
#

also the event handler should remain remoteexeccall shoudln't it? because the unit's ownership might not be on the server?

meager granite
#

You added event handler on server, it cannot execute anywhere else

#

if it will ever execute (which would not for blufor in real MP)

#

[_x] call missionStarter_fnc_loadoutApply

#

Setting loadouts from server to remote clients might not always work, some loadout commands require unit to be local

#

That's where you will need remoteExec, to make sure client does loadout themselves

plucky beacon
#

so I need to target the unit?

meager granite
#

[_x] remoteExecCall ["missionStarter_fnc_loadoutApply", _x];

#

Tell them to loadoutApply themselves

#

This doesn't handle JIP players though, but lets not touch that for now

plucky beacon
#

okay

#

I'm following so far

tough abyss
#

Anyone know the differences of a camera created with camCreate and the camera used in players? I'm having problems to make a created camera show the player view even if its placed in player eye position and the correct direction is set.. .seens Fov is different or something.

meager granite
#

Its completely different simulation, when you look through camCreate'd camera you get camera simulated viewport, when you look through unit you get to see their weapon, where they turn their head, etc.

#

Placing camera in some unit's eye will still mean you're just getting basic camera viewport

#

@plucky beacon Since locality of blufor units is unknown and to make things easier you will need MPKilled event handler on blufor units

plucky beacon
#

okay

#
 _index = player addMPEventHandler ["mpkilled", {Null = _this execVM "playerkilled.sqf";}]; 

from the BI wiki

meager granite
#

addMPEventHandler ["MPKilled", {if(isServer) then {BluforPlayers call missionStarter_fnc_remainBlufor}}]

plucky beacon
#

okay so this just makes sure the event is handled by the server

meager granite
#

MP event handlers actually transfer your entire code that you have for event over network to all clients saving you work adding same thing everywhere

#

But you will need to add isServer check in your case so that code proceeds only on server and does nothing on other clients

tough abyss
#

@meager granite but a created camera have the same default FOV of the player default FOV?

plucky beacon
#

oh I get it, it's globally synced but you block clients with a server check

meager granite
#

Yes, we only need to make sure it fires when unit dies regardless of who owns the unit

plucky beacon
#

so even if someone left and AI takes over it still happens

#

I see now

meager granite
#

Just Killed would fire only if died unit was local to current client\server

#

Yes

#

Alternative but harder solution would be to add Killed everywhere and if it was not server that fired the code, remoteExec the server

#

In case with opfor units you can use Killed as server creates the units and other players never own them

plucky beacon
#

right

meager granite
#

So they're always local to server and Killed is sufficent

plucky beacon
#

but the MPeventhandler is good to know because I might convert it to PVP later

meager granite
#

@tough abyss No idea really, I think unit\vehicle fov is defined in CfgVehicles or something

#

Well do MPKilled for both then

plucky beacon
#
    _newUnit addMPEventHandler ["MPKilled", {if(isServer) then {OpforPlayers call missionStarter_fnc_remainOpfor}}];
little eagle
#

Holy shit, you guys are still doing this.

plucky beacon
#

dude we been doing this for days now

little eagle
#

I saw a movie in the mean time.

plucky beacon
#

HAHA

#

we're just learning some MPEventHandlers

little eagle
#

fuck that shit

plucky beacon
#

I saw "we" because I'm embaressed

meager granite
#

Anyway, you're already sending an array of units (dead, null or not, doesn't matter)

#

You don't need any of that str and getVariable shit that people do for vehicle var named units

plucky beacon
#

I think I deleted it

little eagle
#

Doesn't the new entityKilled mission eh trigger for remote units?

meager granite
#

So just iterate through _this to see how many units are still there

plucky beacon
#

in the opforRemain I deleted the string stuff

meager granite
#

It does

#

It even triggers when non-network rabbit on some client dies

little eagle
#

ahahaha