#arma3_scripting

1 messages Β· Page 654 of 1

little raptor
#

example:

hardware1 setVariable ["some_action_ID", hardware1 addAction ["blabla", {}]];

and then to remove it:

hardware1 removeAction (hardware1 getVariable ["some_action_ID", -1])
clever radish
clever radish
little raptor
#

notepad++ is not notepad

clever radish
#

lel

little raptor
#

anyway, I think your code should work as it is (not to say it's good)
just replace those two lines

wherever you use addAction, use this (to store the actionID):

_actionID = something addAction ["blabla", {...}];
something setVariable ["some_action_ID", _actionID];

and wherever you remove the action, use this (to get the actionID):

something removeAction (something getVariable ["some_action_ID", -1]);

of course, something is whatever you're adding/removing the action to/from.

#

@still forum speaking of intercept, I'm assuming that each plugin can only lock the game if the total execution time is less than 3ms right?
In other words:
plugin1 locks -> 1 ms code
plugin2 locks -> 2 ms code
plugin3 -> is ignored during this frame because we reached the 3 ms limit, so it happens in the next frame
is that correct?

also, each code is "unscheduled" right? (if one plugin locks and executes a 1000ms code, the game freezes for 1 second?)

still forum
#

yes

little raptor
#

and there's no limit in execution time?

#

like callExtension

still forum
#

You can't do that in c++

#

atleast not really

little raptor
still forum
#

also intercept is not fair share like SQF.
in your example above.
next frame again starts with plugin1, then plugin2, and plugin3 might again not get its share

clever radish
still forum
little raptor
naive vigil
#

trying to get an ai controlled plane to fly level during an intro segment but flyInHeightASL doesn't appear to be working

#

anyone know why that might be? setup this code in the planes init:
this flyInHeightASL [260, 260, 260]

#

anything else i'm missing?

#

tried it with the waypoints too

dreamy kestrel
#

bit of an odd behavior going on. I am keeping track of objects in an array that we save orientation bits, and registered variables for.
this is saving okay, have verified. when things re-load and restore, I am finding duplicate objects piling up.
the orientation bits are consistent, but the first instance has no variables.
I think possibly there is an instance landing in the array first.
then the variables are restored, and THAT instance lands in the same array.
does A3 treat objects+variables as unique (?)

topaz kettle
#

I want to know whether it is possible to give a player a custom load out and give them the ability to spawn in with it every time, instead of having to manually load it from an arsenal. Any ideas how I can achieve this easily?

clever radish
exotic flax
topaz kettle
#

Don’t worry my buddy found a way. Just ticking something like: respawn with same load out

vocal trout
clever radish
#

I've got two PCs that should be hacked and a task that will should say something like "You hacked %1 computers!" when the two are hacked, though I want the task title to count by itself using a format, but i dont know how to fit the format and %1 inside the task, nor do i know how to share the information about how many PCs have been hacked?

clever radish
vocal trout
#

thx

clever radish
# vocal trout thx

You can actually go into virtual arsenal and export the loadout, thus will save you A lot of time.

vocal trout
#

btw

clever radish
vocal trout
#

It only accepts BI Arsenal format. Am I correct?

#

Or can it accept ACE3 format to?

vocal trout
exotic flax
#

ACE uses setUnitLoadout and getUnitLoadout

#

so it will just be an array which you get and set

vocal trout
#

Ok, thanks guys

clever radish
exotic flax
#

after the second PC has been hacked, check if the first one was indeed hacked, and use setTaskState to complete the task

clever radish
cosmic lichen
#

@clever radish Show us your code.

clever radish
#

[independent, ["task2"], ["Good luck finding this cookie", "Find Cookie", "cookiemarker2"], objNull, 1, 3, true] call BIS_fnc_taskCreate;

cosmic lichen
#

syntax is wrong

#

Perhaps...

#

if no parent task exist, 2nd argument should be string. Dunno if array works as well in that case.

#

Nevermind.

#

The code you posted works fine.

#

@clever radish

clever radish
cosmic lichen
#

Just tested it

#

You are playing an independent unit?

#

not west or east?

clever radish
#

nope, indenpendent

cosmic lichen
#

Then I don't know.

clever radish
#

alright. thanks

cosmic lichen
#

Can you open a empty mission

#

place an independent unit

#

and try it there?

#

Also make sure that "task2" is unique

#

If you've already used it, then it will not create another task.

clever radish
#

It's an empty mission. Whenever i make larger mission scripts or so, i make them in VR. Ill try restart my pc

cosmic lichen
#

Try ["task2"] call BIS_fnc_taskExists; in debug console

#

and see what it returns.

clever radish
#

sure

#

false. The task isnt even creted

#

created

cosmic lichen
#

@torpid swift Why not use the restricted area module?

clever radish
cosmic lichen
#

Zone Restriction

cosmic lichen
#

Modules β†’ Zone Restriction

clever radish
cosmic lichen
#

ah ok

dreamy kestrel
#

re: my Q: ^^, I figured it out. the modules/framework were actually creating TWO instances of a vehicle in the same specs.

clever radish
#

why isn't it possible to put count [trg1, trg2, trg3] > 2 in condition of a trigger if i want it to trigger whenever two of all three is activated?

winter rose
#

hopefully, there are other ways to do so

clever radish
winter rose
#

&& takes boolean, not object

#

(you also forgot 2&3)

#

{ triggerActivated _x } count [trg1, trg2, trg3] > 1

#

if triggerActivated is the proper command 😬

#

and it is, cool

clever radish
# winter rose && takes boolean, not object

Will that work too, if I got three triggers with that code, one being == 1, another == 2, .... so on? - I've got three triggers that will tell the player how many trg's have been activated.

fair drum
#

so. fsms are preeeeetty cool for missionFlow

#

what is the point of assigning a scriptName when it can't be used as a handle?

exotic flax
#

so you can debug it better I would guess

tropic thunder
#

Is there a technical or performance difference between defining inline functions in a set of files and #includeing those files into something like initServer.sqf verses using function-as-files? I prefer the former because I can develop more quickly using the editor to update functions and I find it easier to organize like functions in a single file, but I want to make sure I'm not introducing any kind of performance penalties.

exotic flax
#

There will always be a performance impact when splitting files, including, putting everything in one file, using CfgFunction, using PREP, etc.
However I do believe that the impact is minimal in any way, compared to the impact it will have to you as a developer to stay sane.

fair drum
#

what wiki page do i go to to read about #define, #blah etc etc

fair drum
#

ty

winter rose
wet hill
#

How to create speed limit to vehicle in multiplayer mission?

little raptor
#

You could try addForce (as a function of velocity) to pull the vehicle backwards as it moves, but I don't know the consequences, or if it works at all

winter rose
#

limitSpeed for AI, setVelocity with a normalised multiplied vector mayhaps (will also slow down a freefall πŸ˜„)

little raptor
winter rose
#

not onEachFrame πŸ˜… πŸ”¨

#

πŸšͺπŸƒβ€β™‚οΈβ˜οΈ (already gone)

ripe sapphire
#

Henlo

#

Would it be viable to use unitcapture for 6-7 helicopters at the same time in MP?

#

Or heavy desync/lag?

winter rose
#

it's not ideal, but it should be ok (using unitPLAY, right?)

little raptor
#

No lag

#

the code is scheduled

#

but I guess you should already know the other problems that come with it

#

unit play is generally not recommended for MP

#

it could be better if you do it on the server

#

as long as your server FPS is high

clever radish
winter rose
#

hackedLaptop = 0;
hackedLaptop = hackedLaptop +1;
hackedLaptop = hackedLaptop +1;
hackedLaptop = hackedLaptop +1;

waitUntil { hackedLaptop > 0 };
task set "1 done";
waitUntil { hackedLaptop > 1 };
task set "2 done";
waitUntil { hackedLaptop > 2 };
task set "3 done";
```something like that (pseudocode)
clever radish
#

The PCs has an addaction with a counter script that makes a hint whenever the laptop is hacked. Do i put the "hackedlaptop = hackedlaptop +1" in there?

winter rose
#

you can yes, as long as you public the variable and remove the action afterwards

#

note that addAction is local πŸ‘€

ripe sapphire
winter rose
#

yes

ripe sapphire
#

πŸ‘

ripe sapphire
ripe sapphire
#

Ah ok so its a problem with scheduler

#

πŸ‘

clever radish
tough abyss
winter rose
#

if you get it to work, please tell us how in #community_wiki so we can fill it πŸ™‚

tough abyss
#

for anyone curious about the in-game information about the command, this is what it says

addForceGeneratorRTD [
    bool enabled,
    int type,
    vec3 strength,
    vec3 position,
    vec3 radius,
    vec3 orientation,
    object AttachTo
]
warm hedge
#

I used setActualCollectiveRTD before for my PID controller of AFM, and worked like a charm. Not sure what exactly is the goal for you but does this work?

tough abyss
#

yeah I have that for my collective based altitude autopilot

#

but I want to use force generators to push the tail around to create heading/speed autopilots

warm hedge
#

Ah hmm, I see

tough abyss
#

but yeah if I add one and have enabled set to true, then read it out with forceGeneratorRTD, the first boolean will be set to false (which I guess means it disabled itself)

#

I'm not actually sure anyone can really answer this question without digging in to the rotorlib implementation of A3, but hopefully I'm wrong and someone knows how this works

#

holy fuck just after I wrote that I figured it out

#

to enable it, you can use
index setForceGeneratorRTD [bool enabled];

#

I'd still really like to know what things like int type actually mean, like what the types are etc

#

Quick question. I have variables that are defined in initPlayerLocal and some code that use those variables in initPlayerServer. Most of the time, everything runs correctly. However, there are times that seems to be the client loads initPlayerServer before initPlayerLocal since there are rare occasions that the code can not detect the variable at launch. Anyone knows what is really happening under the scene and which potential solution should I take ?

little raptor
#

it's hard to give you a "potential" solution without looking at the code

tough abyss
#

I seee, gimme a sec I'll try to post the sqf.

winter rose
#

waitUntil not isNil "yourVarName" ?

hallow mortar
#

If you use getVariable you can assume a default value. No idea if that's useful in your specific case tho.

quasi sedge
fathom rapids
#

Can any one help me with a small script to call other scripts.

I would like to drop a officer at my base with an addaction option called β€œRearm”. This is to call a script that rearms the player depending on there slot they chose from the lobby.

Each playerable unit will have a set named variable such as A11SL, A12SL, A13SL for the squad leaders. A11M, A12M, A13M etc for the medics.

I would like the rearm script to call a script that does something like:
If player is A11SL or A12SL or A13SL then run \loadouts\SL.sqf
If player is A11M or A12M or A13M the run \loadouts\medic.sqf

I know how to do the addaction, I just don’t know how to right the script that checks their slot and runs the associated sqf.
is it something like?
if ((player) isEqualTo 'A11SL' (player) isEqualTo 'A12SL' (player) isEqualTo 'A13SL') then{

"loadouts\SquadLeader.sqf"];

if ((player) isEqualTo 'A11M' (player) isEqualTo 'A12M' (player) isEqualTo 'A13M') then{

"loadouts\Medic.sqf"];

winter rose
hallow mortar
#

It sounds like you're missing the operator or and the command execVM, amongst a number of smaller tweaks. But yes, easier to read with proper formatting as Lou said

fathom rapids
#

i dont have the code, i have not written anything yet as i dont know how to do it

little raptor
hallow mortar
little raptor
hallow mortar
#

^that's it

fathom rapids
#

and you would put that on the init of the officer at the armoury?

#

or in a seperate script that the officer calls from the addaction

hallow mortar
#

We should have a pinned message that says "don't put things in the init field"

little raptor
#

something is the officer

#

whatever you set the variable name to

fathom rapids
#

got ya

#

makes sense

#

thank you

languid oyster
#

Is there any way to tell an AI in driver position of a vehicle do hit 'reverse'? No mater what I do, the AI refuses to go backwards. Would like to make an unstick routine for tanks stuck on poles, structures and alike. I already got something with setVelocity and setDir. Just asking if there is any other option.

hallow mortar
#

BIS_fnc_isLoading?

desert cargo
#

@languid oyster have you tried vcom or LAMBS AI?

languid oyster
#

@desert cargo tried both, and like them, except for the fact that AI is able to ghost through walls. Which I dislike very much.

#

@little raptor setDriveOnPath? Will have a look

#

Thank you

hallow mortar
#

Is it absolutely necessary to detect the exact moment the screen ends? Especially as it can be different for different players, it may be best to just have a blanket 10-second wait

loud dagger
#

Hi, I am not sure if this is the right channel to ask, if not please let me know what channel I should be asking this in.
I am a experienced developer, currently trying to make an extension dll for ArmA 3. I would like to use Newtonsoft and I have seen repo's where they use this package.
Tho I can not seem to get it to work. The game crashes with a generic .NET exception code in the .rpt log. Is there a specific version of Newtonsoft I need or anything?
Thanks in advance. πŸ™‚

fathom rapids
#

i find that most times i set the player loadout in the editor, it ignores it when the mission starts and i get the default stuff.

hallow mortar
#

That shouldn't happen

#

If you are right clicking a playable unit, selecting edit loadout, and clicking OK to save the loadout when finished, you should get that loadout if you play as the unit you edited.

#

If you're not getting the expected loadout, you may be running another script or mod that does loadouts

#

Editor defined loadouts are, in my experience, 100% reliable when not overwritten by something else.

fathom rapids
#

i have done it a few times on various missions and it did always default it. I will try it on this mission i have, to see if it does it. I did remove the radio from everyone and that seemed to work. As TFAR was being a pain and doing this whole reissuing radio thing and not setting channels. Some post said to remove the radio from player spawn and make them pick one up from an arsenal. That seemed to work. Having me set their radio again may break it.

languid oyster
#

@little raptor ```sqf
NIC_fn_Drive = {
params [["_vehicle", objNull]];
if (isNull _vehicle) exitWith {};
_relpos = _vehicle getRelPos [30, 180];
_arrowG = createVehicle ["Sign_Arrow_Green_F", _relpos, [], 0, "CAN_COLLIDE"];
_arrowG setPos _relpos;
_vehicle setDriveOnPath [_relpos, getPos player];
};
cursorObject call NIC_fn_Drive;

I've put a Slammer with an AI driver in the editor. Pointed to it, and local executed the code above. Of course that thing does not move or event turn on the motor. Where is my fault?
little raptor
#

The unit won't follow the path unless it is not taking orders

#

which only happens when the unit is stopped

languid oyster
#

@little raptor I'm confused. The unit is stopped when I apply the code?

little raptor
languid oyster
#

@little raptor ```sqf
NIC_fn_Drive = {
params [["_vehicle", objNull]];
if (isNull _vehicle) exitWith {};
doStop _vehicle;
_relpos = _vehicle getRelPos [40, 180];
_arrowG = createVehicle ["Sign_Arrow_Green_F", _relpos, [], 0, "CAN_COLLIDE"];
_arrowG setPos _relpos;
_vehicle setDriveOnPath [[0,0,0], _relpos, getPos player];
};
cursorObject call NIC_fn_Drive;`

This doesn't work either
loud dagger
native narwhal
#

Not really exprienced with scripting but I am getting an error with the following script, that I found online where it states that line 78 has an "Unidentified Variable in expression: _lootarray" I would appreciate some assistance xD ```_getLootTable = {

_lootType = _this select 0;

// Loot Categories
// Get correct array to spawn items from
_lootArray = [];

switch (_lootType) do {
    
    case 1: {
        _lootArray = scclootCivil;
    };
    
    case 2: {
        _lootArray = scclootIndustrial;
    };
    
    case 3: {
        _lootArray = scclootMilitary;
    };
    
    case 4: {
        _lootArray = scclootMedical;
    };
    
    case 5: {
        _lootArray = scclootSupermarket;
    };
    
    default {
        _lootArray = scclootDefault;
    };
    
};

_lootArray;

};```

winter rose
winter rose
#

*splash, out*

languid oyster
#

@little raptor Just wanted to select an additional waypoint. Test code, if you want.

native narwhal
little raptor
#

Try a sleep 0.001 after doStop

#

@languid oyster

little raptor
native narwhal
#

I see

#

Okay

#

Thanks for the help

cosmic lichen
#

LOOT select _lootType```

Wouldn't that be easier than all the switch stuff?
native narwhal
#

I have no idea, bad with scripting as it is, and this is not my script so Idk xD

slate cypress
#

How can I detect a vehicle becoming disabled? I want some code to run as soon as a vehicle has been hit to an extent where the AI just leave.

slate cypress
fathom rapids
#

@little raptor i have placed the script and i seem to get this error

#

'..."_target, "_caller"];

#

if (_caller in [ #A11SL]) exitwith {

#

error undefined variable in expression: a11sl

#

thats if i am in another class

#

if i am in SL then it works, but it is though it is still trying to run through the script even though that slot is not taken or calling it

cosmic lichen
#

What's the value of A11SL @fathom rapids ?

fathom rapids
#

its the variable name of the slot (player) Squad Leader has the variable name of A11SL

#

this is my code

#

'''sqf

#

how do you do this lol

#

'''sqf

cosmic lichen
#

see pinned messages

fathom rapids
#
/* your code */
armaofficer addAction ["Rearm", {
params ["_target", "_caller"];

        if (_caller in [A11SL]) exitWith {
    [_caller] execVM "loadouts\SquadLeader.sqf";
  };
        if (_caller in [A11TL]) exitWith {
    [_caller] execVM "loadouts\TeamLeader.sqf";
  };
        if (_caller in [A11AT]) exitWith {
    [_caller] execVM "loadouts\RiflemanAT.sqf";
  };
        if (_caller in [A11ARB, M11ARC]) exitWith {
    [_caller] execVM "loadouts\AutoRifleman.sqf";
  };
        if (_caller in [A11R]) exitWith {
    [_caller] execVM "loadouts\BasicRifleman.sqf";
  };
        if (_caller in [A11MB, A11MC]) exitWith {
    [_caller] execVM "loadouts\medic.sqf";
  };
}]
#

so even if i am in the squad leader role i get the error about the next one which is A11TL

#

so it is not seeing me and exiting

cosmic lichen
#
/* your code */
armaofficer addAction ["Rearm", {
params ["", "_caller"];
        diag_log _caller;
        diag_log A11SL;
        if (_caller in [A11SL]) exitWith {
    [_caller] execVM "loadouts\SquadLeader.sqf";
  };
        if (_caller in [A11TL]) exitWith {
    [_caller] execVM "loadouts\TeamLeader.sqf";
  };
        if (_caller in [A11AT]) exitWith {
    [_caller] execVM "loadouts\RiflemanAT.sqf";
  };
        if (_caller in [A11ARB, M11ARC]) exitWith {
    [_caller] execVM "loadouts\AutoRifleman.sqf";
  };
        if (_caller in [A11R]) exitWith {
    [_caller] execVM "loadouts\BasicRifleman.sqf";
  };
        if (_caller in [A11MB, A11MC]) exitWith {
    [_caller] execVM "loadouts\medic.sqf";
  };
}]```
#

Try this and check the output in the .rpt file

winter rose
#

you most likely have the unit not spawned

cosmic lichen
#

Yeah, probably

fathom rapids
#

yeah so if i jump in as the medic i want to be able to walk up to my armaofficer, select rearm and take a fresh kit

#

and then the same if i take the Team Leader slot

#

all slot (playable units) have variable names given as per the above code

cosmic lichen
#

yes, but the units do not spawn right?

#

You got the AI disabled.

fathom rapids
#

correct

cosmic lichen
#

SO what it does

#

It goes from top to bottom executing the conditions

#

but A11SL is objNull for example because the unit does not exist.

fathom rapids
#

we want to have no arsenal crate to prevent players from choosing anything and modifying the loadouts. If you return to base then you go to the armoury and select rearm

#

so how do i make it skip?

#

read the variable and execute accordingly

wind hedge
#

// Guys if I do this: 
class CfgFunctions 
{
    #include "vScripts\vServer\vServerFnc.hpp"
    #include "vScripts\vClient\vClientFnc.hpp"
};

// in description.ext

// And then:
class VAL
{
    class allServer
    {
        class vServerFncInit {file = "vScripts\vServer\vServerFnc.sqf";postInit = 1;};
    }
};

// In vServerFnc.hpp
// Then I no longer need to do:

if !(isServer) exitWith {};
call compile preprocessFileLineNumbers "vScripts\vServer\vServerFnc.sqf";

//in initServer.sqf
//RIGHT? ```
cosmic lichen
#

I'd do:
initPlayerLocal.sqf

player setVariable ["Equipment","RiflemanAT"];
armaofficer addAction ["Rearm", {
params ["", "_caller"];
private _type = _caller getVariable ["Equipment", ""];
if (_type == "") exitWith {hint "No gear for you!"};
_caller execVM format ["loadouts\%1.sqf",_type]; 
}]```
fathom rapids
#

ok so where do i define the variable name of the player?

cosmic lichen
#

You don't need to define it anymore

#

You just set a variable in the player's namespace via event script

fathom rapids
#

er sorry

#

how?

cosmic lichen
#

---mission.map
-----mission.sqm
-----description.ext
-----initPlayerLocal.sqf

fathom rapids
#

i am so sorry you have completely lost me there

fathom rapids
#

the script i posted above was in my initplayerlocal.sqf

cosmic lichen
#

@wind hedge What's not working?

cosmic lichen
#
  1. Inside that file place player setVariable ["Equipment","RiflemanAT"];
#
  1. Change the script (see above)
wind hedge
# cosmic lichen <@!137916926847483904> What's not working?

// Guys if I do this: 
class CfgFunctions 
{
    #include "vScripts\vServer\vServerFnc.hpp"
    #include "vScripts\vClient\vClientFnc.hpp"
};

// in description.ext

// And then:
class VAL
{
    class allServer
    {
        class vServerFncInit {file = "vScripts\vServer\vServerFnc.sqf";postInit = 1;};
    }
};

// In vServerFnc.hpp
// Then I no longer need to do:

if !(isServer) exitWith {};
call compile preprocessFileLineNumbers "vScripts\vServer\vServerFnc.sqf";

//in initServer.sqf
//RIGHT? ```
#

it is not that it is not working... I am asking if a call compile is redundant after doing the previous...

cosmic lichen
#

Yes, that's the whole point of CfgFunctions

#

besides some other advantages of course

wind hedge
fathom rapids
#

@cosmic lichen what i dont understand is how does that code identify the different players when you have defind "riflemanAT" in the first line

cosmic lichen
#

Yeah right. My bad.

fathom rapids
#

also i have 4 squads

#

with the same player setups

#

so if any of the squadleaders go up they all get the same kit loaded from the Squadleader.sqf

cosmic lichen
#

New approach:

Init field in the editor:

if (local this) then {this setVariable ["Equipment","RiflemanAT"]};```
fathom rapids
#

They will be named A11SL, A12SL, A13SL and A14SL

#

init field of what?

cosmic lichen
#

In the attribute of the units, there is a field called "init"

fathom rapids
#

So in the init field of the Squad Leaders i should put that code with the text of RiflemanAT changed to SquadLeader

#

and then the same principle for medics etc

cosmic lichen
#

Yes

fathom rapids
#

ok but the previous code with the _type bit in how does it refer to the correct sqf for the slot?

#

do i repeat the if section for the different sqf's?

cosmic lichen
#
armaofficer addAction ["Rearm", {
params ["", "_caller"];
private _type = _caller getVariable ["Equipment", ""]; //Lets say the value it returns is "RiflemanAT"
if (_type == "") exitWith {hint "No gear for you!"};
_caller execVM format ["loadouts\%1.sqf",_type]; //Here we replace %1 with the value above which returns "loadout\RiflemanAT.sqf", which is the path to the file ;)
}]
fathom rapids
#

so i keep repeating

#

if (_type == "") exitWith {hint "No gear for you!"};
_caller execVM format ["loadouts%1.sqf",_type];

#

after?

cosmic lichen
#

no

#

The path will be auto generated if the variables in the init are set correctly.

wind hedge
#

---mission.map
-----mission.sqm
-----description.ext
-----initPlayerLocal.sqf

#

where does postInit = 1 fit there?

cosmic lichen
#

That was not for you.

wind hedge
#

I know but still wanna know πŸ™‚

cosmic lichen
#

It doesn't

fathom rapids
#

right so those name have to be the same as the filenames

#

got it

#

will try now

cosmic lichen
wind hedge
#

Thanks, it is loaded right after initPlayerServer

fathom rapids
#

@cosmic lichen you sir are a star

cosmic lichen
#

My wallet says otherwise

#

But if happy if it works

native narwhal
#

Uhm I am quite lost on what to do with regards to the Undefined Expression

#

Like I understand that it is not defined but what do I do to fix that

cosmic lichen
#

easy

#

private _lootArray = [];
....
....
switch....

native narwhal
#

Ok will test it now

#

Thanks

native narwhal
#

That did not seem to fix the problem, now I get more errors with regards to the scclootcivil and so on

#

All saying that they are undefined

cosmic lichen
#

Well, are they defined?

native narwhal
#

Wdym by that ? (Sorry know little to nothing about scripting)

cosmic lichen
#

Well, where do you define those variables scclootcivil?

#

Sorry, where, not there

native narwhal
#

Uhm I mean they come from another sqf file

cosmic lichen
#

Yes, is that sqf file executed before the one you posted above?

native narwhal
#

Not in the same sqf file no

#

There is no mention of it

#

Though I do have an execute command in a init file

#

Just like what the github script instructions say

cosmic lichen
#
_getLootTable = {
    
    private _lootType = _this select 0;
    
    // Loot Categories
    // Get correct array to spawn items from
    private _lootArray = [];
    
    switch (_lootType) do {
        
        case 1: {
            _lootArray = 1;
        };
        
        case 2: {
            _lootArray = 2;
        };
        
        case 3: {
            _lootArray = 3;
        };
        
        case 4: {
            _lootArray = 4;
        };
        
        case 5: {
            _lootArray = 5;
        };
        
        default {
            _lootArray = 6;
        };
        
    };
    
    _lootArray;
    systemChat str _lootArray;
    
};
call _getLootTable;
#

Execute that in the debug console

#

If it prints a number from 1 to 6 then the basic script works and you need to figure out why the variables are not defined.

native narwhal
#

Nothing happens when I execute it so I am going to assume it is not working at all

#

Shame the script looked so promising

#

I appreciate the help

#

Thanks

cosmic lichen
#

try now

native narwhal
#

Nope

#

Nothing

cosmic lichen
#

It works, I tested it. So the issue is that those other variables are not defined.

#

tbh, if you are new to scripting, rewriting a framework is quite complex.

native narwhal
#

I mean I am not rewriting it

cosmic lichen
#

You should probably get familiar with sqf first before you try something like that.

native narwhal
#

The script is supposed to be configurable

#

And I just followed instructions on the read file

#

And added custom building and items to the script and that's it

native narwhal
cosmic lichen
#

Yes, I posted the code above expected you know the basics of sqf, but you don't. That's why it couldn't work.

If you only wanna add buildings, why don't you contact the developer on github?

native narwhal
#

Because they already put the instructions on how to do that

cosmic lichen
#

Okay, let's start fresh

#

Did you try the script without modifications? Does it work?

native narwhal
#

Yes

#

On vanilla maps with vanilla items

cosmic lichen
#

okay, so what do you wanna add?

native narwhal
#

I tried adding some items and a custom building just for testing

#

Included their class names

#

In the appropriate files

cosmic lichen
#

Which file did you modify? and how?

native narwhal
#

For the items there is file called lootTables.sqf

cosmic lichen
#

Because that script you posted ealier, doesn't look like any configuration file from that framework

native narwhal
# native narwhal For the items there is file called lootTables.sqf

And in it I added the cup_u_c among other things ```// Loot Tables

// By default this list contains items from ARMA 3 only.
// However, items not found are ignored - making it safe to add items from mods here.
// Format is classname, spawn chance.

// Default loot that will spawn in any building not defined in the config file:
scclootDefault = [
["U_Competitor",5]
];

// Civilian loot
scclootCivil = [
["CUP_U_C_Functionary_jacket_03",30], ```

native narwhal
cosmic lichen
#
scclootCivil = [
    ["hgun_P07_F",100],
    ["CUP_U_C_Functionary_jacket_03",30]
];```
Like this right?
native narwhal
#

Yup

cosmic lichen
#

does that work?

native narwhal
#

Wdym? (I know I am a pain in the ass for not knowing basic sqf or scripting, sorry xD)

cosmic lichen
#

All good.

#

So you wanted to add a new loot category?

native narwhal
#

The categories were already pre-made, you have civil military industrial medical and I just added more items to those categories

cosmic lichen
#

You just need to add them here and you are good then.

native narwhal
#

Yup but that's what I did

#

For example ```// Industrial loot
scclootIndustrial = [
["Binocular",30],
["Crowbar",50],
["ACE_TacticalLadder_Pack",30],
["ACE_wirecutter",50],
["V_Safety_yellow_F".50],
["Shovel_Russian",50]
];

// Military loot
scclootMilitary = [
["CUP_srifle_M14",20],
["CUP_20Rnd_762x51_DMR",50],
["rhs_tr8_periscope",10],
["CUP_arifle_Galil_556_black",20],
["CUP_35Rnd_556x45_Galil_Mag",30],
["B_FieldPack_cbr",50],```

cosmic lichen
#

Yep, that should work out of the box according to the documentation.

#

["V_Safety_yellow_F".50],
This line is wrong

native narwhal
#

How do you guys spot these??? xD

cosmic lichen
#

Years of staring at script files at 3 am, not finding the issue.

native narwhal
#

Lmao

little raptor
#

Have you turned off script errors?

native narwhal
#

I don't believe so .... ? xD

cosmic lichen
little raptor
#

The game would've told you about that error otherwise

native narwhal
#

I am getting errors yes

#

Whenever I try to test the mission

#

I get the same error which states that the expression is not defined

#

It states the _lootArray, some of the sccloot expressions like scclootcivil and so on

#

Are not defined

little raptor
#

then look in the rpt log

cosmic lichen
#

Post the whole script

little raptor
#

if you haven't turned that off as well meowsweats

cosmic lichen
#

There must be a typo in it

native narwhal
native narwhal
cosmic lichen
little raptor
cerulean cloak
#
while {true} do
    {
        if (coy_a distance coy_b < 10) then
            {
                (group coy_a) setgroupID ["Coy"];
            }
        else
            {
                (group coy_a) setgroupID ["0"];
            };
    };

I have this in a unit's init and the stuff inside the while do loop runs just fine from the console but not inside the loop for some reason. Anyone able to help?

native narwhal
native narwhal
little raptor
cerulean cloak
#

I thought sleep didn't work in init's though?

little raptor
#

so because it doesn't work your solution was to remove it?

#

do you even know how the while loop works?

#

it keeps running

#

that's it

#

with no sleep, you're telling it to freeze my game plz

cerulean cloak
#

So is there a better way to loop something in an init then?

little raptor
#

don't use init fields at all

#

unless you know how they work

native narwhal
#

The rpt file has a lot of "Error Position" or "Error Undefined variable in expression" multiple times

#

And all of the errors are found in the same file "lootSpawn.sqf"

little raptor
#

Delete everything in the rpt

#

rerun the mission (or whatever you do)

#

then look at the new errors

#

and maybe post them here so someone can tell you what you're doing wrong

native narwhal
#

There is so many errors that I don't think it's worth looking at tbh

#

I will search for another script

#

Though I appreciate the help @little raptor @cosmic lichen

#

And apologies for being a pain in the ass cryblob

small forge
#

There are multiple errors in the RPT refering to missing ] markers in the code. You should probably investigate those lines along with all the other errors in the RPT.

native narwhal
#

I would if I were experienced in scripting but unfortunately I am not

#

And tbh I have been burned out on this thing for the past few days trying to see what the issue is (Yes through research and what not xD) , and I feel for me just to search for these [] is just gonna waste a lot of time

small forge
#

I understand, that is reasonable, but it's not a waste of time. You learn coding and, any stuff that matter, by doing and learning from mistakes. From what I've read it seems like most of the problems just come from missing characters which leads to the whole script kinda dying.

#
["LOP_U_CH>
19:42:53   Error Missing ]```
For example, I'd search for that line and look for a missing ] character. Probably just use the search functionality inside what ever software I'm using to edit the file.
native narwhal
#

Right so I checked that but it all seems fine unless I am that stupid that I either did not see something or did something wrong ["B_FieldPack_cbr",40] ["LOP_U_CHR_Villager_02",60], ["LOP_U_CHR_Functionary_01",50], ["LOP_U_PMC_tacky",80],

cosmic lichen
#

stupid then xD

native narwhal
#

Oh god

cosmic lichen
#

["B_FieldPack_cbr",40] !!!!!!!!!!!!!!!!!!!! missing ,
["LOP_U_CHR_Villager_02",60],

native narwhal
#

That's how tired I am now

#

xD

#

I can't see shit lmao

small forge
#

Syntax problems are a very common problem if you're not experienced. It should be one of the first things to look for when something doesn't work. Every time you make a mistake you're less likely to do it the next time. The debug log is quite helpful in these cases, most of the time at least.

#

Normally the game would give you a big error on your screen when starting the scenario.

willow hound
#

-nologs
This post was made by the systemChat gang

native narwhal
#

Again thanks @cosmic lichen and thanks @small forge Probs should actually start learning scripting after today xD

small forge
#

The first steps are made by implementing code in your scenarios, may it be yours or not. If you put some consistent effort into it you'll learn with time. Just keep the community wiki close for any documentation on SQF

cosmic lichen
#

@native narwhal Does it work now?

native narwhal
#

Well I am proofreading all of the script before doing the test

#

Just to be sure

cosmic lichen
native narwhal
#

Will definitely check it out

#

Thanks πŸ‘Œ

fathom rapids
#

@cosmic lichen just tried packing my pbo and deploying it on the server. When i try it now it says no gear for you. So something is different when acting on a server

#

how do i change this to work on the server?

#

if (local this) then {this setVariable ["Equipment","AutoRifleman"]};

willow hound
#

Init field huh?

fathom rapids
#

yeah of each playable unit

willow hound
#

Put player setVariable ["Equipment", "AutoRifleman"]; into initPlayerLocal.sqf and avoid all those problems.

#

Init fields are a sensitive topic in multiplayer scripting.

fathom rapids
#

i cant do that as i have different roles

small forge
#

My guess is that the init field is not working properly for some reason. The variable is probably not being set. Reasons could be that the (local this) condition doesn't get fulfilled or the init field is not even being ran. Not quite sure about what it could be specifically

fathom rapids
#

i dont want to define them in initplayerlocal

#

works fine when i run the mission in multiplayer on my machine

willow hound
#

Use a switch-statement then krtecek

#

Yes, because your machine is the server krtecek krtecek

fathom rapids
#

been through this with r3vo

#

it wont work

cosmic lichen
#

We m ight need to public the variable

fathom rapids
#

i have 8 slots, all different roles. When the player takes the medic slot and he goes to the armoury and asks for a rearm, the medic kit will be given

willow hound
#

And?

fathom rapids
#

it will be something to do with that init as the initplayerlocal is running and telling there is no gear as it cannot see my role

little raptor
#

@fathom rapids just use getVariable and be done with it

small forge
little raptor
#
if (_caller in [missionNamespace getVariable ["A11SL", objNull]])
willow hound
#

How does having eight slots prevent you from using a switch-statement?

switch (roleDescription player) do {
  case "My Medic Slot": {player setVariable ["Equipment", "Medic"];};
  case "This is the Autorifleman": {player setVariable ["Equipment", "Autorifleman"];};
};
small forge
#

On the wiki: Multiplayer: The variable space of the object is local to each client and by default changes are not broadcast. Since Arma 2: If the public parameter for supported types is true, the value will be synchronized also for a JIP player.
R3vo is probably right, it needs to be broadcasted.

cosmic lichen
#

Where were all those ppl 60min ago πŸ˜„

fathom rapids
#

lol

#

ok now i think i get ansin11's response. The part in the " " will be what i have in my role description under the unit attributes?

#

if it is i have to do this like 35 times as my role descriptions are all different for the different squads

small forge
#

Another way is to check for the unit type if all the medics are the same unit

void panther
#

Hello (-:

#

A friend of mine is creating a few maps and we have the problem, that our player always loot the enemies. So my idea is to randomly drop grenates which explode on looting. My question is, if this is possible with scripting?

willow hound
#

8 slots, 35 slots, what next...

if ("Medic" in roleDescription player) then {
  player setVariable ["Equipment", "Medic"];
};
little raptor
#

"medic" in toLower ...

fathom rapids
#

for example one squad has "Alpha 1-1 - Bravo - Combat Medic" & "Alpha 1-1 - Charlie - Combat Medic"

#

so having "medic" would pick this up?

little raptor
#

@void panther I think this should do the trick

_g = createVehicle ["grenadeHand", _pos];
_g setDamage 1;
willow hound
#

"medic" probably not, because in does case-sensitive comparison, but "Medic" should work πŸ™‚

little raptor
#

I don't remember if it was "grenadehand" or "handgrenade"

fathom rapids
#

ok i will try that

little raptor
#

I think the former was for ammo
latter for mag

cosmic lichen
#

@void panther While it is certainly possible, I would advise to not go that way.

#

Killing player randomly, sounds like fun...not

little raptor
void panther
#

Yeah, we will see how people will find that. I personally would find it very funny

void panther
#

Thank you for helping πŸ˜„

fathom rapids
#

would this work?

#
/* your code */
armaofficer addAction ["Rearm", {
params ["", "_caller"];
private _type = _caller getVariable ["Equipment", ""];
if ("Medic" in roleDescription player) then {
player setVariable ["Equipment", "Medic"];
_caller execVM format ["loadouts\%1.sqf",_type]; 
}]
willow hound
#

Probably not, I believe you use getVariable too early.

fathom rapids
#

then how would i add the next option of AutoRifleman, SquadLeader

#

this is blowing my brains, I know what i want to achieve but just cant get my head round this code.

small forge
#

You should probably put that if statement in something like initPlayerLocal.sqf

fathom rapids
#

thats where it is

small forge
#

then maybe put it before the addAction

willow hound
#

player setVariable proooobably doesn't survive respawning though, might want to move it to onPlayerRespawn.sqf. Let me write something up.

#

onPlayerRespawn.sqf:

private _equipment = "";
if ("Medic" in roleDescription player) then {
  _equipment = "Medic";
};
if ("Autorifleman" in roleDescription player) then {
  _equipment = "Autorifleman";
};
//Add more if-statements just like those for all your roles.
player setVariable ["Equipment", _equipment];
fathom rapids
#

and after that last line i would add

#

_caller execVM format ["loadouts%1.sqf",_type];

willow hound
#

Certainly not πŸ™‚

fathom rapids
#

so how do i call the sqf

willow hound
#

When do you want to call it?

fathom rapids
#

when it has found out what the role is, call the appropriate loadout sqf

#

i have autorifleman.sqf, basicrifleman.sqf, commander.sqf, marksman.sqf, medic.sqf, riflemanAT.sqf, sniper.sqf, squadleader.sqf and teamleader.sqf

small forge
#

player execVM format ["loadouts\%1.sqf", equipment]; at the end of initPlayerLocal.sqf should work for the first time when spawning

willow hound
#

And what about the "Rearm" action?

small forge
#

just change the equipment = here to lowercase

fathom rapids
#

that is placed on the armaofficer on the map

#

we go up to him, scroll and select rearm he then checks our role, and gives up the correct loadout

small forge
#
armaofficer addAction ["Rearm", {
params ["", "_caller"];
private _type = _caller getVariable ["Equipment", ""];
_caller execVM format ["loadouts\%1.sqf",_type]; 
}]```
#

should work just fine as long as you remove the if statement you asked about earlier

cosmic lichen
#

You know what guys

fathom rapids
#

yeah nothing is setting the variable thats why we have the init field with that code

cosmic lichen
#

This is all pointless

fathom rapids
#

please tell me why

cosmic lichen
#

AddAction has local effect and is only locally created

small forge
#

True. Could just use private variables

cosmic lichen
#

So just add the action via initPlayLocal.sqf and assign the script directly

#

without defining a dynamic path to the file.

fathom rapids
#

files(s)

cosmic lichen
#

ahhh

#

nevermind

fathom rapids
#

i have done this before where the player would go to the crate and scroll and select the loadout

cosmic lichen
#

forget about it. I am too tired.

fathom rapids
#

it worked fine but i dont want a medic to take AT weaponary, only to have what they were given

#

but when we RTB to rearm, i want them to go and rearm and get their old kit back

#

i have exported their loadouts into sqf files, so they are ready to go, i just need a way to call them from the rearm guy

willow hound
#

Why should it not work @cosmic lichen? I was going to comment how that would be a big brain move and then you come and say "nevermind"?

cosmic lichen
#

As I said I am really tired πŸ˜„

willow hound
#

As in too tired to explain that big brain idea to the less experienced? πŸ˜›

small forge
#

If you're not worried about respawning with appropriate gear since you have the arming officer. Then just use this: ```
//// initPlayerLocal.sqf
private _equipment = "";

if ("Medic" in roleDescription player) then {
_equipment = "medic";
};
if ("Autorifleman" in roleDescription player) then {
_equipment = "autorifleman";
};
//Add more if-statements just like those for all your roles.

armaofficer addAction ["Rearm", {
params ["", "_caller"];
_caller execVM format ["loadouts%1.sqf", _equipment];
}]```
Should work fine unless there are syntax errors or something I missed

willow hound
#

#arma3_scripting message
If you have that meowthis code in onPlayerRespawn.sqf, the "Equipment" variable is defined every time the player (re-) spawns.
#arma3_scripting message
Then you just use that meowthis in initPlayerLocal.sqf and the "Rearm" action works.

fathom rapids
#

ok i will try

cosmic lichen
#

Just be aware that roleDescription will not work in single player

willow hound
#

Just like... slots...

small forge
#

The wiki says it works on SP. Is the wiki wrong?

autumn swift
#

Does setting other players volume with setPlayerVoNVolume persist after said player dies and respawns?

cosmic lichen
small forge
#

If you know SQF basics, you could try it out by using the getPlayerVoNVolume command to return the value before and after death.

still forum
#

try it out and tell us so it can be added to the wiki

fathom rapids
#

error undefined variable in expression: _equipment

#

script loadouts\any.sqf not found

small forge
#

yeah my bad _equipment doesn't transfer to the scope of the addAction

fathom rapids
#

can that be fixed?

autumn swift
gleaming imp
small forge
# fathom rapids can that be fixed?
 //// initPlayerLocal.sqf

private _equipment = "";

if ("Medic" in roleDescription player) then {
  _equipment = "medic";
};
if ("Autorifleman" in roleDescription player) then {
  _equipment = "autorifleman";
};
//Add more if-statements just like those for all your roles.

armaofficer addAction ["Rearm", {
    params ["", "_caller", "", "_type"];
    _caller execVM format ["loadouts\%1.sqf", _type];
}, _equipment]; ``` Try this. Someone shout out if the syntax to passing args to addAction's script is wrong. Haven't done it in a while
fathom rapids
#

that seemed to work, gonan upload it now to see if that resolved it

gleaming imp
#

forgot to put link πŸ˜„

willow hound
clever radish
#

I need help with a trigger condition. I have set a condition of Ishacking && !(p1 in thisList) && Trg3 for three triggers (Trg1, Trg2, Trg3 is the difference). Whenever p1 is hacking hacking.sqf contains; IsHacking = true Trg1 = true. Whenever p1 leaves area a hint and IsHacking = false is set to be activated.

Now the problem occurs whenever p1 goes into the second and third trigger area and activates the hacking script, it instantly fires the hint, even though the player is still in the trigger area.

native narwhal
#

@cosmic lichen Fixed it, it was a bunch of small mistakes I missed out and some lines stuck to each other. Getting the hang of it, and might even start learning scripting. Thanks a lot for the support xD

willow hound
clever radish
small forge
#

The first thing I notice is that the H is lowercase on the trigger but uppercase in the .sqf file

clever radish
gleaming imp
clever radish
#

I checked Debug and it all sums up with the "IsHacking" part. It turns out fals whenever p1 leaves trigger area on all triggers.

willow hound
#

And should it be that way?

willow hound
small forge
#

@clever radish You set Trg1 = true in the file? You do that with the other triggers too? What are the in game, Eden set, conditions for the triggers? Not the script ones

clever radish
#

Let me start from the begenning - It's much easier. (pls wait while i find all codes, cant copy in one chat. )

TRIGGER1;
CON Ishacking && !(p1 in thisList) && Trg1
ACT hint "Signal lost. Download interrupted."; Ishacking = false; PC1ScriptRunning = false;

TRIGGER2;
CON Ishacking && !(p1 in thisList) && Trg2
ACT hint "Signal lost. Download interrupted."; Ishacking = false; PC2ScriptRunning = false;

PC1;
Hardware1 addaction ["Download Content of device", "HackCounter\PC1.sqf"];

PC2;
Hardware2 addaction ["Download Content of device", "HackCounter\PC2.sqf"];

#

PC1.SQF;
PC1ScriptRunning = true; _HackCount = 0; ishacking = true; Trg1 = true;

ishacking = false;

PC2.SQF;
PC2ScriptRunning = true; _HackCount = 0; ishacking = true; Trg2 = true;

ishacking = false;

#

Of course, bug does not occur whenever p1 completes the hack and ishacking = false in SQF. Capital letters doesn't seem to affect the script.

winter rose
#

…forgetting all the code behind, anything related; what is the behaviour you want?

#

from an outsider's pov

clever radish
small forge
#

What's the purpose of the TrgX variables? Are they always true?

gloomy aspen
#

_markers = allMapMarkers select {toUpper _x find "SHAI" >= 0};
_side = east;
_myunitarray = ["C_Scientist_F"];
_spawnedGroups = [];

{
    _grp = [getmarkerpos _x, _side, [selectRandom _myunitarray],[],[],[],[],[],180] call BIS_Fnc_spawnGroup;
    _spawnedGroups pushBack _grp;//in case you want to access all spawned groups
    {_x disableAI "PATH"} forEach units _grp;
} forEach _markers;
_spawnedGroups```

Hey guys is there anyway I can change this script to only select markers with "SHAI" in them at random? At the moment it spawns the unit on every marker with "SHAI" in the name, id like it to only spawn 15 enemies at a time on randomly chosen markers. 

Aplogies for the lack of markup, i dont know how to do it 😦
winter rose
cosmic lichen
gloomy aspen
#

Awesome, thanks @winter rose

clever radish
small forge
#

@clever radish Are the Eden conditions the same? I mean are they all set to player present or etc?

clever radish
willow hound
#

Isn't that the same as Player not present? tanking

clever radish
#

Bug occurs whenever:

I complete hacking of PC1 and continue to PC2, where the hint from the TRIGGER2 will show and the script will continue after one second. (It will not if i activate the TRIGGER1 for PC1)

Meaning that the hint from TRIGGER2 will show, even though player is inside TRIGGER2 area.

willow hound
#

Well, the trigger is supposed to activate when the player is not in the trigger area, soooo

winter rose
clever radish
willow hound
#

In fact, T2 should be activating when the player is in the T1 area (if the areas are distinct): T1 sets Ishacking to true, the player is not in the T2 area, Trg2 is always true, thus: Everything is true and T2 activates.

gloomy aspen
#

@small forge thanks mate, have looked into that a little but will read more

@winter rose trying your solution now, apologies if im missing an obivious part, but how would i define how many units to be spawned in that instance? 15 of them to be exact

winter rose
clever radish
gloomy aspen
#

private _shaiMarkers = allMapMarkers select { "SHAI" in _x };
private _randomShaiMarker = selectRandom _shaiMarkers;
_side = east;
_myunitarray = ["C_Scientist_F"];
_spawnedGroups = [];

{
    _grp = [getmarkerpos _x, _side, [selectRandom _myunitarray],[],[],[],[],[],10] call BIS_Fnc_spawnGroup;
    _spawnedGroups pushBack _grp;//in case you want to access all spawned groups
    {_x disableAI "PATH"} forEach units _grp;
} forEach _shaiMarkers;
_spawnedGroups

Up to here so far, seems to be spawning the correct number of enemies, but on the same positions each time? Am i using your solution incorrectly?

winter rose
#

nope πŸ™‚

#

you did a forEach _shaiMarkers; why do you want to spawn on each?
you want to spawn on only one, the random one (if I understood it correctly)

gloomy aspen
#

Damn πŸ˜†

15 random marker positions to spawn enemies out of an unlimited number of markers containing the term SHAI in the variable name

Thats the plan!

Surely not as simple as removing forEach ?

#

I tried it just incase thats what you meant, but got a missing semi-colon error on that line and now im even more bewildered!

winter rose
#

for i from 1 to 15 do {
spawn on a randomly selected SHAI marker
}

exotic tinsel
#

So i could use some help. i suck at math especially algebra.
I am trying to create a script to file roads with dirt. Its not working well.
It only does one dirt per road segment but there is plenty of space needing to be filled.
can someone take a look at my code and point out what im doing wrong.
https://pastebin.com/CDb8ZQVQ

gloomy aspen
#

private _shaiMarkers = allMapMarkers select { "SHAI" in _x };

_side = east;
_myunitarray = ["C_Scientist_F"];
_spawnedGroups = [];

{
    _grp = [getmarkerpos _x, _side, [selectRandom _myunitarray],[],[],[],[],[],10] call BIS_Fnc_spawnGroup;
    _spawnedGroups pushBack _grp;//in case you want to access all spawned groups
    {_x disableAI "PATH"} forEach units _grp;
for i from 1 to 15 do {
  private _randomShaiMarker = selectRandom _shaiMarkers;
};
};
_spawnedGroups```

I think Ive really ruined the script now @winter rose .. Im not sure I understand where everything is meant to go, am I just lacking some basic sqf knowledge? Seems like I put all the right bits in the right places, but seemingly not. Theres no errors being thrown up by 3den, but also no effect at all now 😦
quasi sedge
willow hound
#

object 31478 is not a reference to the object. I don't know how you obtained that, but it's probably just the String representation of the reference.

quasi sedge
#

do3DENAction "ToggleMapIDs";

karmic flax
#
this addEventHandler ["Fired", {
    params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
    
    while {!isNil _projectile} do {
        _marker = createMarker ["markername", _projectile];
        _marker setMarkerType "hd_dot"; 
        sleep 1;
    };
        
}];

Im trying to make a simple script that updates the pos of an arty shell on the map as it flies, no need to remove markers this is just for debug testing, any pointers to make it work right?

#

Working on it now but above code gives errors

willow hound
willow hound
quasi sedge
willow hound
#

Double click on the module, there are some checkboxes for additional map object types.

distant oyster
#

is there a way to check when a unit is ready to be moved into a vehicle on mission start? It seems that right at the start of the mission it is not possible to do so but I honestly don't know anything that might cause it. From initPlayerLocal.sqf:

waitUntil {!isNil "MIS_fnc_missionFlow_state" && !isNil "MIS_fnc_missionFlow_plane"};
if (_didJIP) then {
    //--- Bring to respawn screen
    forceRespawn _player;
    if (MIS_fnc_missionFlow_state == "pause") then {
        //--- Respawn during pause
        sleep 1;
        [_player] call MIS_fnc_respawnPlayer;
    };
} else {
    //--- Paradrop
    _player addBackpackGlobal "B_Parachute";
    "RscWaitingForPlayers_layer" cutRsc ["RscWaitingForPlayers", "PLAIN"];
    ["start move in: %1", time] call BIS_fnc_logFormatServer;
    while {!(player in MIS_fnc_missionFlow_plane)} do {
        player moveInCargo MIS_fnc_missionFlow_plane;
        sleep 1;
    };
    ["end move in: %1", time] call BIS_fnc_logFormatServer;
};
``` without the sleep only the hosting player is moved into the plane at mission start. the other client is moved in on the next try. RPT:

1:04:18 "Terra(76561198050689859)/BIS_fnc_log: start move in: 0"
1:04:18 "Terra/BIS_fnc_log: [BIS_fnc_preload] ----- Scripts initialized at 875.977 ms -----"
1:04:18 "TerrasMinion(76561198050689859)/BIS_fnc_log: start move in: 0"
1:04:21 "PLANE STARTING"
1:04:21 "Terra(76561198050689859)/BIS_fnc_log: end move in: 1.003"
1:04:22 "TerrasMinion(76561198050689859)/BIS_fnc_log: end move in: 2.021"

willow hound
#

Same with _player?

distant oyster
#

yep

#

okay i removed the sleep just out of curiosity. the actual time difference for TerrasMinion is 0.277 s.

willow hound
#

That's a lot of attempts

distant oyster
#
 1:13:29 "Terra(76561198050689859)/BIS_fnc_log: start move in: 0"
 1:13:29 "Terra(76561198050689859)/BIS_fnc_log: end move in: 0"
 1:13:29 "Terra/BIS_fnc_log: [BIS_fnc_preload] ----- Scripts initialized at 817.871 ms -----"
 1:13:29 "TerrasMinion(76561198050689859)/BIS_fnc_log: start move in: 0"
 1:13:32 "PLANE STARTING"
 1:13:39 "TerrasMinion(76561198050689859)/BIS_fnc_log: end move in: 0.277"
#

no errors in both rpts blobdoggoshruggoogly

#

another interesting part is that on postInit the hosting player is moved into the plane during the briefing

#

actually no nevermind i changed that. the initPlayerLocal moves the player into the plane

#

but during the briefing, the player is displayed at the position of the plane

spark anchor
#

How do you edit particle effects for ground-hits, explosions, smoke, etc? i.e Blastcore changes some effects drastically and I want to do something similar

exotic flax
spark anchor
#

thanks alot

spark anchor
#

Also, are there maybe any way to use a realtime-GUIs that are made for particles or do you have to just experiment using scripts and stuff?

violet gull
#

Which format for GUIs are consistent across all screen resolutions/aspect ratios? I'm using this and the result is offset for each resolution:

_bat ctrlSetPosition[0.33*safezoneW+safezoneX,0.38*safezoneH+safezoneY,0.02*safezoneW,0.08*safezoneH];```
#

It's looking like pixelGrid commands will be what I need to replace safeZone

#

Disregard, it's only messed up for people who edit their FovLeft and/or FovTop values in their Arma3.cfg πŸ˜›

little raptor
unique sundial
# violet gull Which format for GUIs are consistent across all screen resolutions/aspect ratios...

Safezones give you ability for making controls relative to the screen like 0.8*safezoneH means 80% of screen height. while H and W are straightforward, X and Y need some mind bending and the picture here explains it https://community.bistudio.com/wiki/safeZoneW that safezoneX is negative, so if need additional calculation between width of your control and width of the screen and that safeZoneX offset. I might write some examples though

unique sundial
#

@violet gull Added examples to safeZoneXXXXX pages

fathom rapids
#

does anyone know how to implement the QS Mag Repack into a script form. We are running invade and annex framework on one of our servers and it is implemented, without the clients downloading the mod. I wish to now have it on our training server, but dont know how to extract it and get it working. I would like a simple action that the player performs [LCTRL] + R to execute a mag repack function.

#

we really dont want to add more mods

#

i have googled around and not finding any simple mag repack scripts i can use

tough abyss
#

Have you tried to unpack the pbo? The script is in there.

fathom rapids
#

i have but it refers to a lot of other stuff too

#

i have just found one script that may work, will try it tonight

#

can you tell me how i can execute the command from a [LCTRL] + R key stroke?

#

the code wants me to put

#
this addAction ["Repack",{null = [_this] execVM "repack.sqf";}];
#

on each player

#

i would prefer to have a keybind

#

easier then to duplicate the mission files for other maps

#

something in the initplayerlocal or init sqf's

#

would this work?

#
//fnc in initPlayerLocal.sqf

dokeyPress_fnc = {
    switch (_this) do {
              //key
        case 39: {
            nul = [] execVM "earplugs.sqf";
        };
    };
};
#

just have to work out how to change that to LCTRL + R

tender fossil
#

@fathom rapids Check this script

#include "\a3\ui_f\hpp\definedikcodes.inc"
params ["_ctrl","_button","_BtnShift","_BtnCtrl","_BtnAlt"];

private _buttonDisabled = false; // true: block the original comand, false: Execute the normal command of that button
private _blockInput = { _ButtonDisabled = true; };

if (_button isEqualTo DIK_W) then // DIK_W = 17 = 0x11 = "W"
{
    // For now, button W is just registered, but won't block the original command for now (player can move forward).

    // If SHIFT is pressed, block "W" (walk forward) and show the systemchat message
    if (_BtnShift) then
    {
        systemChat "Shift+W pressed";
        call _blockInput; // call to disable the original command
    };
};

_buttonDisabled

See more at https://community.bistudio.com/wiki/DIK_KeyCodes

fathom rapids
#

would i have to put that top line in the description.ext?

#

and the rest in initlocalpplayer.sqf?

#

thats the issue i have with that wiki, most of the time it doesnt tell you where to put stuff lol

tender fossil
#

There's no single correct way to organize your code, but the BIKI could use more examples, yeah

slate cypress
#

when using event handlers (as they run in unscheduled environment by default), is it good practice to spawn into a scheduled environment unless you need to run a time-critical script or should you just leave it as it is in unscheduled

tender fossil
#

@slate cypress I'm not an expert on this, but I think it depends on the case

#

Scheduled execution tends to be a bit risky because of the way it works in Arma, but you do get rid of the potential FPS drops with it

tender fossil
#

@slate cypress From KK's blog:

The scheduled environment does not guarantee the order or priority of execution of queued scripts. The engine will simply do it when it is feasible and possible. If you have too many non scheduled calls and they also take time to complete, your scheduled scripts can be delayed significantly, we are talking minutes! For the same reason non critical scripts should be run in scheduled environment so that a) they do not get on the way of urgent executions, b) give engine more flexibility for rescheduling when needed.

Having said that, scheduled environment, despite its name, is pretty unpredictable. If you spawn 100 scripts, it is not guaranteed they will execute in the same order they where spawned. Also you cannot predict when they finish. You can however check IF they finished with scriptDone command. And if you have many unoptimised scripts running, especially of a 3rd party addons, and you have no control over what is going on, it is very likely there might be some issues.

#

And like in any case of threaded execution (whether actual threads or simulated ones), you can run into issues of parallel programming that can get really complex and hard to debug, such as data races and deadlocks

still forum
#

unscheduled will freeze the game until its done.
Depends on what you're doing.
if you need the EH code to run right now, then leave it unscheduled, if you don't care about delays, scheduled is better/safer

slate cypress
#

Thanks

gloomy aspen
#

Just out of curiosity, a lot of composition mods on the workshop use the BIS_fnc_attachtoRelative

With say 30 or so items connected to say, 10 different vehicles is there a noticeable performance hit? The objects generally have had simulation disabled but I wonder what the performance cost is of the game 'moving' them relative to a vehicle

#

Apologies if theres a better channel for this question

little raptor
still forum
#

due to suspension, there can be race conditions

#

_v1 = MyGlobalVar;
_v2 = MyGlobalVar;

_v1 != _v2

little raptor
still forum
#

same end result tho

tender fossil
unique sundial
#

it is absolutely is a race condition, where did you dig term data race? Dedmen did not say data race @little raptor

winter rose
unique sundial
#

you quoted Dedmen, it’s confusing

tender fossil
#

So data race and race condition are different things? TIL

#

I always thought they referred to the same phenomenon

winter rose
#

(I never encountered "data race")

#

data race seems to be a kind of race condition, in which two threads access the same data

tender fossil
#

@winter rose Ah, of course. I feel dumb now πŸ˜„

winter rose
#

I didn't know it had a specific name :p

dusky pier
#

Hello, sorry for stupid question, but don't understand how to do this thing 😦

I have trigger, when player leave trigger (onDeactivation) code must move player back
(to the trigger center direction - on 50 meters)

There needed vectors ( i think ), but don't understand how to calculate a new position by vector.

Could you help me with that, please?

winter rose
cosmic lichen
#

If so, there is a module which does that.

winter rose
#

I would say ```sqf
private _pos = getPosATL _unit;
private _vectorFromTo = getPosATL _trigger vectorDiff _pos;
private _vectorFromToNorm = vectorNormalized _vectorFromTo;
private _vector50 = _vectorFromToNorm vectorMultiply 50;
_pos = _pos vectorAdd _vector50;
_pos set [2, 0];
_unit setPosATL _pos;

dusky pier
#

@cosmic lichen something like that, but inverted (when player leave zone - he's getting moved back and see message on the screen)

cosmic lichen
#

_aboveAndBehindPlayer = player modelToWorld [0,-1,3];
@winter rose ?

winter rose
#

he might turn his back to the trigger 😬

cosmic lichen
#

sneaky...

winter rose
#

or move diagonally, etc
yeah I have some experience with such sneaky stuff πŸ˜„

dusky pier
#

@winter rose thank you a lot!

winter rose
#

you could also use getPos/getDir alternative syntaxes, etc

cosmic lichen
#

you could also just turn the player around, looking at the trigger πŸ˜„

#

Going to create some nice confusion

dusky pier
cosmic lichen
#

Yeah, he could also walk backwards

winter rose
#
player setDir (player getDir trigger);
player setPosATL (player modelToWorld [0,50,0]);
``` πŸ˜„
dusky pier
#

@winter rose that awesome, 2 variants - works fine πŸ˜„

But, i think - better will be use - last one, with less code πŸ™‚

Thank you a lot!!!

winter rose
#

πŸ˜›

torpid sedge
#

Does anyone know how to code roleplay shops like cars truck,bike clothing hole lot need help with

hallow mortar
#

I'm trying to make a simple EH that gives you another magazine when you reload. Here's what I've got:

  player addEventHandler ["Reloaded", {
    params ["_unit", "_weapon", "_muzzle", "_newMagazine", "_oldMagazine"];
      if (_weapon in ["launch_rpg7_F","gm_p2a1_launcher_blk"]) then {_unit addMagazine (_newMagazine select 0);} else {
        _unit addMagazine (_oldMagazine select 0);};
  }];

you'll notice there's special cases for launchers. That's the problem: if the weapon you reload is a launcher....you don't get a new magazine. Even with those special cases in place. I don't quite understand or know how to resolve this.

little raptor
#

Did you check?

hallow mortar
#

yes

#

I know the EH is being added correctly because it works for non-launcher weapons

little raptor
hallow mortar
#

I guess I'll check but it'd be a hell of a thing if it was empty

#

can confirm it is not empty

#

_oldMagazine is empty but that's why the special case is what it is

little raptor
#

add two new magazines

#

see if it fixes the issue

#

You can also verify that by checking if the new magazine was already loaded:

secondaryWeaponMagazine _unit == _newMagazine
hallow mortar
little raptor
#

Not necessarily

#

maybe the game removes it

#

I don't know

#

Just check
I'm not sure

hallow mortar
#

Nope, firing a rocket still reduces my total amount of rockets by 1

little raptor
#

because if you have enough room, adding two mags should've given you at least 1 mag
so either you don't have enough room
or the code was not being executed

hallow mortar
#

well, I'm definitely holding a launch_RPG7_F and that matches the if criteria, so it would be weird if it wasn't

#

and I'm 100% sure I have enough room

little raptor
#

add a systemChat or hint to make sure

hallow mortar
#

yes, I'm going to

little raptor
#

If it still doesn't work, add the magazine specifically to the backpack

#

That command has always been a bit weird and iffy for me

crude needle
#

in is case sensitive btw

little raptor
#

yes, which is why I suspected that it was the problem

hallow mortar
#

yes, that was it

little raptor
#
if (toLowerANSI _weapon in ["launch_rpg7_f","gm_p2a1_launcher_blk"])
hallow mortar
#

getting the case right in the first place also solved it

quasi sedge
#
objective_1 = true;
if ((!alive target_1) || (!alive target_2) || (!alive target_3) || (!alive target_4)) then
{ 
    objective_1 = false;
    hint "Bridge destroyed";
};
little raptor
#

(if possible)

hallow mortar
#

or a trigger?

little raptor
#

triggers are loops
EHs are better

#

you can also use buildingChanged EH

wind hedge
#

is there any difference between calling a function like this: "myTag_fnc_myFunction" versus calling it "vMyFunctionFnc"?

#

it is just a standard but no difference engine wise right?

noble pond
#

mytag_fnc_myfunction is created by using cfgFunctions in description.ext, but they all work the same

#

in terms of calling the functions at least

#

you could manually define it as well and it would be fine unless its already defined inside cfgFunctions and it'll just throw an error that the function is already defined

still forum
#

One name is shorter

#

:3

void panther
#

Hello πŸ™‚

#

I am trying to figure out how to drop an item if a player loots an enemy. I was able to drop the item, but I have no idea on how to get the container/inventory of the enemy.
My idea is to work with eventListeners, but I cannot find the correct property. Any hints/ideas?

#

Basically I am trying to do the following:

_enemy.container addEventHandler ["ContainerOpened", {
    params ["_unit", "_container"];
    hint "opened";
}];
little raptor
void panther
#

I don't understand what you are saying

little raptor
#

is that simple enough?

void panther
#

Sure, but how do I assign it to the enemy?!

little raptor
#

why should it be "assigned" to the enemy?

#

it's just there

#

you can use setVariable if that's a necessity

void panther
#

Okay

little raptor
void panther
#

Hmmm... nearOBjects or nearestObjects does not return anything 😦

#

or at least no weaponholder

little raptor
#

or you know just use that

#

why do you need container opened in the first place?

void panther
#

To drop the grenade πŸ˜„

#

which then explodes

little raptor
#

you can use take EH for that too

void panther
#

How do I see the systemChat?

#

nevermind

#

Yeah, I got it πŸ˜„

#

this is how i had to do it in order to get the weapon holders show up:

_enemy addEventHandler ["Killed", {
    params ["_unit", "_killer", "_instigator", "_useEffects"];
    _unit spawn {
        sleep 1;
         _container = nearestObjects [_this, ["WeaponHolderSimulated", "WeaponHolder"], 1];
         {
            systemChat typeof _x;
            _x addEventHandler["ContainerOpened", {
                _claymore = "APERSMine_Range_Ammo" createVehicle position player;
                _claymore setDamage 1.0;
                systemChat "opened container";
            }];
         } forEach _container;
    };
}];
#

I should probably remove the eventhandler afterwards

slate cypress
#

I want the functionality of BIS_fnc_replaceWithSimpleObject but the documentation recommends not to use it in MP scenarios. Is there a workaround?

exotic flax
#

Create simple objects from the start?
Get object class, remove object, create new simple object?

little raptor
noble pond
#

if its a player and they respawn the EH would stay attached no?

slate cypress
exotic flax
#

In that case grab class name, location and direction of the object, remove the object itself and create a new simple object with the data you stored

#

Which afaik is exactly what that BIS function is doing as well

fading crest
#

how would i set a script so i could respawn unit's that are targets on a IFV range from laptop?

brazen lagoon
#

hey can someone link me dedmen's script profiler? I can't find it from searching (probably not searching for the right thing)

#

nvm found it

fair drum
#

can I target a editor folder. say I place a bunch of objects in a folder in the editor, is that stored as a variable somewhere?

frail orbit
#

dipped a toe into scripting and i've fallen at the first hurdle. I've put down a trigger called "trigger1", and I'm getting a mission module to fire off mission1.sqf with the line: trigger1 setTriggerActivation [WEST, NOT PRESENT, true];
And I get the error "undefined variable in expression... line 1"
Am I just not understanding the syntax on the wiki?

slate cypress
exotic flax
#

I haven't looked in the function, so don't know exactly. I guess it will work but will cause some issues server side

slate cypress
slate cypress
#

Are players able to edit their own profile namespace and change data within it?
Is it safe to store data, for example how many points someone has, in their profile namespace or should I store it to the server profile namespace?

cosmic lichen
#

@slate cypress Profilenamspace is not safe. It can be freely edited. So server profile it is

thin jetty
#

Hey guys, you can laugh, but any idea on how to make an item display custom intel?

ionic tinsel
#

How do you control a marker's alpha parameter through scripting events? For that matter, how do you access parameters like that at all with a script in the first place?

hallow mortar
fair drum
agile pumice
#

I'm getting an error for this code. I don't work with locations often so I'm not sure what I'm doing wrong here:

_lockDoors = {
  _nbDoors = getNumber (configfile >> "CfgVehicles" >> typeOf this >> "numberOfDoors");
  for "_i" from 0 to _nbDoors - 1 do {
    _var = format ["bis_disabled_Door_%1", _i];
    this setVariable [_var,selectRandom [0,1],true];
  };
};

_worldCenter = getArray (configFile >> "CfgWorlds" >> worldName >> "centerPosition");
{
  {
    _x call _lockDoors;
  } forEach (nearestTerrainObjects [locationPosition _x, ["house","building","tourism"], size _x]);
} forEach (nearestLocations [_worldCenter, ["NameVillage", "NameCity", "NameCityCapital"], worldSize]);  
hallow mortar
#

What's the exact error?

agile pumice
#

Type array expected number before nearestTerrainObjects

hallow mortar
#

size returns an array, [x,y]. nearestTerrainObjects expects a single number for its radius parameter.

agile pumice
#

so I should do size _x select 0 /2?

hallow mortar
#

That seems likely, though you might also want to introduce something to determine whether the x or y dimension is larger

agile pumice
#

it works, thanks

violet gull
#

Is there any witchcraft I need to know about to get the z axis of a GUI object to be consistent across all resolutions/aspect ratios/interface sizes/FOV?

#

I think my GUI buttons are off because my z = 0.22 of the object they are positioned on top of. No safeZone or whatever stuff used in the z axis of the model/object.

#
class LRRadio {
idc=90909;
type=82;
movingEnable=0;
model="\A3\ui_f\objects\radio.p3d";
scale=(0.235*0.675*(SafeZoneW Min SafeZoneH));
direction[]={0,10,1};
up[]={0,1,0};
inBack=0;
x=0.4*safezoneW+safezoneX;
y=0.58*safezoneH+safezoneY;
z=0.22; // dis b da bad boi?
xBack=0.4*safezoneW+safezoneX;
yBack=0.58*safezoneH+safezoneY;
zBack=0.22;
enableZoom=0;
zoomDuration=1;};
violet gull
#

SOLVED: This seems to have fixed it for the z axis:

z=0.19+pixelH*pixelGridNoUIScale;
languid oyster
#

When the player is in a vehicle, and drives near an ammo bearing vehicle, like the ammo truck, there appears a 'rearm' icon. Upon pressing, the player vehicle is rearmed.
I would like to have a look at this rearm routine. Is this possible, or is it hardcoded?

languid oyster
#

@winter rose thought so. Thank you.

fathom rapids
tender fossil
#

@fathom rapids Paste your code here

#

You need to initialize the event handler during the start of the mission

fathom rapids
#

can you tell me how to do that and where it goes?

#

i can read the scripting code that arma uses, i just cannot write it

#

sorry

little raptor
tender fossil
#

initPlayerLocal.sqf:

fnc_onKeyDown_burbMagRepack = call compile preprocessFileLineNumbers "path/to/your/script.sqf";
fnc_burbMagRepack = call compile preprocessFileLineNumbers 
"path/to/magRepackScript.sqf";

[] spawn {
  waituntil {!isnull (finddisplay 46)};
  burbMagRepack_keyDownEHId = findDisplay 46 displayAddEventHandler ["KeyDown", {call fncBurbMagRepack}];
};

Your script (see above: "path/to/your/script.sqf")

params ["_ctrl","_button","_BtnShift","_BtnCtrl","_BtnAlt"];

private _buttonDisabled = true; // true: block the original comand, false: Execute the normal command of that button

if (_button isEqualTo 39) then
{
    // For now, button R is just registered

    // If CTRL is pressed, repack mags
    if (_BtnCtrl) then
    {
        call fnc_burbMagRepack;
    };
};

_buttonDisabled

"path/to/magRepackScript.sqf":

// Whatever the mag repack script is, paste it here
#

@fathom rapids

#

Fix'd

cosmic lichen
#

Why re-invent the wheel. Just make MagRepack Mod and Earplug mod optional. Then ppl can use or not.

languid oyster
#

Please, can someone explain, why this works,

_turrets = [_unit] call BIS_fnc_getTurrets;
{
    _magazines = getArray (_x >> "magazines");
    _turretPath = (_turretPaths select _foreachindex);
    diag_log format ["_magazines: %1, _turretPath: %2", _magazines, _turretPath];
} forEach _turrets;

while this throws an error?

{
    _magazines = getArray (_x >> "magazines");
    _turretPath = (_turretPaths select _foreachindex);
    diag_log format ["_magazines: %1, _turretPath: %2", _magazines, _turretPath];
} forEach [_unit] call BIS_fnc_getTurrets;
cosmic lichen
#

} forEach [_unit] call BIS_fnc_getTurrets;
} forEach ([_unit] call BIS_fnc_getTurrets);

languid oyster
#

πŸ€¦β€β™‚οΈ

#

@cosmic lichen many thanks. Of course I missed something

quasi sedge
#
//Plant
objective_2 = true;

target_5 addEventHandler ["killed", {
killed = _this select 0;
killer = _this select 1;
systemchat format ["%1", killer];
objective_2 = false;
hint "Plant is destroyed";
}];
#

target_5 is undentified rpt says

warm hedge
#

Put target_5 to the Object Variable Name instead?

quasi sedge
#

ooouf

warm hedge
#

Not sure where you run this thing though

still forum
little raptor
still forum
#

write your own scheduler

#

its c++, everything is possible

little raptor
winter rose
#

params

slate cypress
#

_ before a variable name is convention for a private/local variable?

little raptor
#

local and private are different things

quasi sedge
#
objective_3 = true;

target_6 addEventHandler ["killed", {
killed = _this select 0;
killer = _this select 1;
systemchat format ["%1", killer];
objective_3 = false;
hint "Radar destroyed";
}];```

This will work too? i need only objective_3 = false;
```sqf
objective_3 = true;

target_6 addEventHandler ["killed", {
objective_3 = false;
hint "Radar destroyed";
}];```
#

sorry im not into programming at almost all

#

all code in init.sqf

little raptor
# still forum write your own scheduler

is there a good way to do that?
All I can think of is measuring the execution time with std::chrono::high_resolution_clock::now() after every function call meowsweats

still forum
#

figure something out πŸ˜„

little raptor
slate cypress
#
_playerVehicles = [];

{
    _x addEventHandler [
        "Hit",
        {
            params ["_unit", "_source", "_damage", "_instigator"];
            [_unit] spawn
            {
                _unit = _this select 0;
                if (!(_unit in playerVehicles)) then
                {
#

Why is _playerVehicles not accessible from inside the EH?

#

This is a followup to my previous Q about variable scopes

#

If I use _ without private

winter rose
#

Because the EH has its own scope @slate cypress

slate cypress
#

or are there other ways

slate cypress
winter rose
#

(also, you have playerVehicles both with and without underscore)

slate cypress
slate cypress
#

so what would be the difference between using sqf private playerVehicles = []; and ```sqf
playerVehicles = [];

#

both will be accessible from the EH

#

private would mean that playerVehicles cannot be accessed from outside that scope/script but it can't be accessed from outside even without private?

winter rose
#
private playerVehicles = [];
````private` is of no use here
slate cypress
slate cypress
# winter rose global != public

global means it can be accessed from anywhere in the script and public means it can be accessed from anywhere in the script and other scripts in the mission?

wraith cloud
#

no, a public variable is accessible by the server and other clients

slate cypress
wraith cloud
#

Correct

slate cypress
#

got it thanks

#

and thank you montana

timid niche
#

Can you pushBack to the front?

#

so it wouldn't rly be pushback but yeah

slate cypress
#

I think you want to use set if you want to insert a value at the front.

#

Index 0

#

append and pushBack will both add it at the end

#

set will replace the value though

still forum
#

you can use insert to add to front

#

with 2.02 that is

winter rose
#

yes sir; is3DENPreview

slate cypress
#
_modelInfo = getModelInfo _unit;
                        _modelPath = _modelInfo select 1;
                        _simpleObject = createSimpleObject [_modelPath, getPosWorld _unit];

How can I modify this so that the simple object is in the same orientation as _unit?

winter rose
slate cypress
#
_modelInfo = getModelInfo _unit;
_modelPath = _modelInfo select 1;
_orientation = vectorDir _unit;

deleteVehicle _unit;

_simpleObject = createSimpleObject [_modelPath, getPosWorld _unit];
_simpleObject setVectorDir _orientation;
winter rose
#
  • setVectorUp after vDir too
little raptor
#

@slate cypress setVectorDirAndUp

slate cypress
#
_modelInfo = getModelInfo _unit;
_modelPath = _modelInfo select 1;
_vectorUp = vectorUp _unit;
_vectorDir = vectorDir _unit;

deleteVehicle _unit;

_simpleObject = createSimpleObject [_modelPath, getPosWorld _unit];
_simpleObject setVectorDirAndUp [_vectorDir, _vectorUp];

It still doesn't work unfortunately.

winter rose
#

of course, you delete the unit before getting its pos

slate cypress
winter rose
#

how is it? 180Β° opposed? other?

#

because simple objects are sometimes wrongly oriented

slate cypress
#

Yes 180 degrees

winter rose
#

also have you heard of our lord and saviour BIS_fnc_replaceWithSimpleObject?

slate cypress
#

Also the wheels are in the ground

little raptor
#

Simple objects use the model center as "land contact"

slate cypress
little raptor
#

(they actually don't have land contact)

winter rose
slate cypress
winter rose
#

performance I suppose

slate cypress
#

I tried it and it worked... however it didn't register as a simple object to any of the machines

winter rose
#

I have no more info about it

slate cypress
winter rose
#

no

#

otherwise it would be that one, but better πŸ˜„

little raptor
#

params
[
    ["_template",objNull,[objNull]],
    ["_forceSuperSimple",false,[true]]
];

if (isNull _template || {count crew _template > 0}) exitWith {["[x] Template object (%1) must not be NULL and must not contain any crew!",_template] call bis_fnc_error;};

if (isSimpleObject _template) exitWith {["[x] Function was executed on simple object!"] call bis_fnc_error;};

private _class = typeOf _template;

if (_class == "") exitWith {["[x] Cannot retrieve classname!"] call bis_fnc_error;};

//scan simulated object
private _data = [_template] call BIS_fnc_simpleObjectData;

//get world position, dir and vector up
//private _pos = getPosASL _template; _pos set [2, (_pos select 2) - (_data select 3)];
private _pos = getPosWorld _template;
private _dir = getDir _template;
private _vectorUp = vectorUp _template;

//delete simulated object
deleteVehicle _template;

//create simple object
private _object = [_data,_pos,_dir,false,_forceSuperSimple] call BIS_fnc_createSimpleObject;

//set position (to negate built-in auto-adjusting)
_object setPosWorld _pos;

//set vector up
_object setVectorUp _vectorUp;


_object
#

comes from that function

slate cypress
#

interesting

#

ok that concludes this thanks

slate cypress
#

how can I delete this simple object after?

#

deleteVehicle doesn't seem to work with simple objects

winter rose
#

it does

slate cypress
#
sleep waitForDisabledVehicle - waitForBody - 1;
deleteVehicle _unit;

"The vehicle has been deleted!" remoteExec ["hint", 0];
#

"The vehicle has been deleted" gets outputted

#

vehicle remains

winter rose
#

what is _unit? πŸ™ƒ

slate cypress
winter rose
#

how do you get it?

slate cypress
#
"A vehicle has been disabled!" remoteExec ["hint", 0];

sleep waitForBody + 1;

_unit call BIS_fnc_replaceWithSimpleObject;

"The vehicle has been turned into a simple object!" remoteExec ["hint", 0];

sleep waitForDisabledVehicle - waitForBody - 1;

deleteVehicle _unit;

"The vehicle has been deleted!" remoteExec ["hint", 0];
winter rose
#

yep, the original _unit has been deleted

#
private _simpleObject = [_unit] call BIS_fnc_replaceWithSimpleObject;
little raptor
#

publicVars are synced with a delay
they probably only exist way after init

#

JIP is different

lean cedar
#

So I'm trying to use this

_arsenalNames = [];
_arsenalDataLocal = [];
_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];

for "_i" from 0 to (count _arsenalData - 1) step 2 do {
    _name = _arsenalData select _i;
    _arsenalDataLocal = _arsenalDataLocal + [_name,_arsenalData select (_i + 1)];
    _nul = _arsenalNames pushBack ( format[ "missionnamespace:%1", _name ] );
};
missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
[player,_arsenalNames] call bis_fnc_setrespawninventory;```
which I found on the forums to import loadouts from virtual arsenal into the respawn menu.
As it said there, it is in both initPlayerLocal.sqf and OnPlayerKilled.sqf
However, rather than allowing me to choose, it just gives me a random kit I have saved.
little raptor
#

Yes

exotic flax
#

are you sure this is correct

_arsenalData = profilenamespace getvariable ["bis_fnc_saveInventory_data",[]];

missionnamespace setvariable ["bis_fnc_saveInventory_data",_arsenalDataLocal];
because it will get and set from different locations

void panther
#

I am having troubles with scopes.

#

What do I have to do, to have an outer variable be found in e.g. an event handler?

#

No matter what I do, it is not defined within the event handler's scope

#

is that even possible?

little raptor
#

Altho the code is written very badly

exotic flax
#

Problem is; if one person stores it in the mission namespace, and a second person overwrites it, the first person will get the loadout from the second person.
And, if you save stuff in mission namespace, it won't be available in the profile namespace... so will never be available

brave jungle
#

any known issues with BIS_fnc_EGSpectator currently causing the respawn UI not to load with default arguments?

finite sail
#

/#login PRONIGHT

exotic flax
#

missionNamespace is global, profileNamespace is local
So it will mess up stuff when used wrong

little raptor
#

it's not "shared"

#

aka not public

#

it requires the public flag to become public

exotic flax
#

Returns the global namespace attached to mission.
So it's global for the mission, aka everyone can access it

little raptor
exotic flax
#

which still doesn't solve the issue of using 2 different namespaces πŸ€·β€β™‚οΈ

little raptor
#

Depends which namespace the game reads from

#

it can be valid

#

I don't know

#

I haven't looked at how the game reads the inventory stuff

#

Yeah that makes sense

timid niche
split coral
#

... on Tuesday

spark sun
spark sun
split coral
#

Well that's only the official ETA. We'll see.

timid niche
#

who is fastest, BE or BI

little raptor
timid niche
little raptor
#

Then go for it 🀣

timid niche
#

hahaha

spark sun
#

BI as they should release on Tuesday

mellow thunder
#

Radical, delete the saved in in the script and test it.

lean cedar
#

Alright, seems to be working now

#

Thanks!

naive needle
#

Can it be good for performance to activate dynamicSimulation for groundweapon holder ?

still forum
#

not really

void panther
#

If I have a script for a mission and iterate over all units. Is that particular code executed on the server or on each client?

still forum
#

depends on where you execute that script

void panther
#

init.sqf?! πŸ˜„

still forum
#

how do you execute it?

#

init.sqf runs on server and all clients

void panther
#

[] execVM "inventory_ieds.sqf";

still forum
#

init.sqf runs on server and clients.
initPlayerLocal only on players
initServer only on server, ...

#

I think the wiki page for them is called "Event Scripts"

winter rose
void panther
#

Okay, I will take a look. Not sure if that is the behaviour I want/need πŸ˜„

hallow mortar
#

I suspect the best approach for you will be to run the script in initServer.sqf, and in the script use remoteExec to target the machine where each unit is local

void panther
#

Yes, I think that would work.

still forum
hallow mortar
#

it might not be only players

#

and it sounds like inventory commands so you only want it to happen once per unit

covert crow
#

can someone give me the bohemia page on vehicle parts? I wanna damage an engine when players are inside

void panther
#

yeah, that is my concern, that it is executed too many times or for the wrong players πŸ˜„

young current
little raptor
#

if it's a one time thing

void panther
#

I tried initPlayerLocal.sqf, but whatever I put in there it is only executed on the host. 😦

little raptor
void panther
#

But isn't initPlayerLocal supposed to work as well?

little raptor
#

yeah

void panther
#

Just want to understand, because documentation states it should work

little raptor
#

I'm not sure what you meant by only executed on the host.

void panther
#

the person hosting the mission sees all the stuff what is scripted in initPlayerLocal.sqf. Other players connecting, won't

little raptor
#

and what "stuff" is that?