#arma3_scripting

1 messages · Page 714 of 1

meager epoch
#

i found some icons online however they never get "found" (the file's always missing)

past wagon
#

oh, yeah that makes sense

meager epoch
#

are they supposed to be in like a special folder or smth or what

#

the path to the .paa is 100% correct

little raptor
#

what is it?

meager epoch
#

"\pictures\icons\holdAction_documents_ca.paa",

little raptor
#

that's wrong

meager epoch
#

how come

little raptor
#

remove \

meager epoch
#

the first?

little raptor
#

yeah meowsweats

meager epoch
#

i execVM files like that, no problems there blobdoggoshruggoogly

warm hedge
#

Arma 3 sometimes requires \, sometimes hate \, sometimes doesn't care \ nootlikethis

little raptor
meager epoch
#

define absolute path derpWolf

little raptor
#

C:\blabla\file.sqf

meager epoch
#

oh

#

ait

past wagon
#

for the "muzzle" parameter on certain commands such as ammo, is that just the same as the player's current weapon?

past wagon
#

unless its like a vehicle turret or something

little raptor
#

actually no

past wagon
#

or like a Type 115

little raptor
#

just use currentMuzzle

past wagon
#

yeah

#

ok

meager epoch
#

Why does the following code throw a Generic Error at the sleep 5?

o1 addEventHandler ["Killed", {
    o1 removeEventHandler ["Killed", _thisEventHandler];
    e1 setCombatBehaviour "AWARE";
    e2 setCombatBehaviour "AWARE";
    ["Cpt. Campbell", "What the hell, Givens!? I told you not to shoot him!"] spawn BIS_fnc_showSubtitle;
    sleep 5;
    ["endF2", false, true, true, true] call BIS_fnc_endMission;
}];
warm hedge
#

You can't sleep in the context

meager epoch
#

I execVM it by the way.

warm hedge
#

Inside of an EH can't use suspend commands

meager epoch
#

oh, so is there no possible way to sleep there?

#

like

#

not at all

warm hedge
#

spawn

meager epoch
#

right

#

@little raptor what's wrong with execVMing it!? camoman

little raptor
meager epoch
#

:(

little raptor
#

I didn't say do it

#

use spawn like polpox said

meager epoch
#

i thought ur saying that that's the proper way of doing it nvm

little raptor
#

and I'd shown you that before

meager epoch
#

yeye all g

little raptor
#

that's the bad way of doing it

magic solstice
#

Does anyone have a script for refueling vehicles in a certain radius?

#

As in if a jet or something got close to a trigger it would get refueled and resupplied

winter rose
#

see setFuel

magic solstice
#

Thanks

bright robin
#

how can i do a respanw based on weneaver all of your group is dead,or 3 min have passed?

#

for a multiplayer game

winter rose
bright robin
#

i know how to code it

#

i mean

#

how it would be structured

#

but no idea on how to actually code it

willow hound
#

Okay, so how would you structure it?

bright robin
# willow hound Okay, so how would you structure it?

first of all,the game would check if the group members are dead,if all are dead,then automatically all respanw at the same time
and a individual clock of a desired time that counts donw when somebody died,when it runs out,it automatically respanws that player individually

#

with this,if all died rougthly at the same time,they would respanw all at once

#

so you encourage more focus on keeping the players alive

#

rather than using then as a disposal tool

#

this is meant for a TvT setting

#

so either all die rougthly at the same time (eg:an explosion,or something like that)
or they focus on keeping the injured alive
this would punish strats based on constant respaning to overwhelm a post

past wagon
bright robin
#

and then add a normal 3 min respanw timer

#

or how much time do you want

#

the issue yet again

#

i not how is writteng

#

or how do you write scripts

#

the syntax,not on what do i have to do

willow hound
#

onPlayerKilled.sqf (this script is automatically executed by the game when the player dies):

if ({alive _x} count units PlayerGroup == 0) then {
  0 remoteExec ["setPlayerRespawnTime", PlayerGroup];
} else {
  setPlayerRespawnTime (3 * 60);
};
```At some point before the player dies (and while he is in the correct group) you have to do `PlayerGroup = group player;` (because dead units have no group).
Not entirely sure if this really works, I've never tried.
bright robin
#

also,any guide on the syntax for scripting?

willow hound
turbid zenith
#

Speaking of respawn

#

Is there a way to set different respawn times for different respawn positions?

bright robin
#

true

#

or for diferent groups

winter rose
#

maybe with checking selected respawn position, dunno

#

but yeah you'll have to script it yourself

eager burrow
#

hi all! - is it posible to put a addon pbo inside the mission folder and load it from there? - it´s a pure script addon , best reguards

still forum
#

no

eager burrow
#

:/ thx

still forum
#

If its just a script you can probably integrate it into the mission somehow.
But you cannot just put a mod into a mission, even if the mod "only" contains scripts

brazen lagoon
#

would there be an FPS gain from using intercept to run a viewculling algorithm locally in a separate process?

brazen lagoon
#

yeah I was thinking about it more and the stuff you'd need probably isn't in shared memory anyway

#

dedmen said the reason that mod even has any fps improvement is likely an edge case bug that he's planning on fixing

visual quarry
#

Not sure which channel to ask, but does anyone know how Savage did the "Skip Travel" stuff in the SOG COOP campaign at all? Cant seem to find module or anything on google, cheers.

hollow thistle
#

It's a part of the "aiHeliTransport" function.

hollow thistle
# little raptor Skip Travel?

There's AI transporting you big distances via heli, you can sit in there, listen to music and enjoy the view, or use hold action to basically skip to the end of the journey.

visual quarry
hollow thistle
#

check the function in the function viewer, idk why but the main function is not on the wiki.

#

VN_ms_fnc_aiHeliTransport

visual quarry
#

Yhea I have no idea, that is way over my head like i said, i just got back in to it, so i have forgotten alot of SQF stuff

hollow thistle
#
    Parameter(s):
        _group          - AI group to pilot the heli, needs pilot and co-pilot [GROUP, defaults to grpNull]
        _vehicle        - Vehicle that will be piloted [OBJECT, defaults to objNull]
        _route          - Array of marker names or positions to go through [ARRAY, defaults to []]
        _lz             - Description [STRING|OBJECT|ARRAY, defaults to nil]
        _goCondition    - Condition to start, _this is equal to the _vehicle [CODE, defaults to {sleep 30; true}]
        _unlock         - Should heli pilot/co-pilot be unlocked after AI is done with transport [BOOL, defaults to true]

    Returns:
        Insertion completed [BOOL]

    Example(s):
        [myGroup, myVehicle, ["marker1", "marker2"], myHelipad, {true}] call vn_ms_fnc_aiHeliTransport
#

from the function header

visual quarry
#

Sorry i should have made it clearer, I found it in the functions viewer, however I am unsure on how to implement it, IE if i put it in the player init i get error messages that appear too fast to read, I havnt touched arma in 3 or 4 years. So i guess explain to me like a five year old.

little raptor
visual quarry
#

so copy and pasting it from the func viewer i change it to the following

[player, h1, ["marker1", "marker2"], hp1 {true}] call vn_ms_fnc_aiHeliTransport

visual quarry
little raptor
#

not object

#

you're putting player

#

which is an object

visual quarry
#

so in this cased change player > Alpha 1-2?

little raptor
hollow thistle
#

It makes no sense to run this on player group as the script tells AI to do the flying.

little raptor
#

¯_(ツ)_/¯

little raptor
#

oh

#

first arg is the AI pilot grp

#

nvm

#

then whom does it transport?! thonk

hollow thistle
#

Whoever sits in the heli

#

it goes from A to B

little raptor
little raptor
hollow thistle
#

AI sits ouside the heli in SOG coop missions.

#

Player pilots can join last minute

#

and fly the heli.

#

If everybody boarded the heli and there's no player pilots then AI will take care of transporting you to the LZ.

visual quarry
#

okay great so i got the ai to get in and fly to the markers, I just now need to add the skip travel stuff in aswell, im sorry for being shit

hollow thistle
#

It should be in there by default. It's disabled when you're close to the LZ.

visual quarry
#

It doesnt appear to be, ive put the helo in the corner of camlaonam, and the option never appears

hollow thistle
#

¯_(ツ)_/¯

#

have you specified the LZ? If not the last route element is the LZ.

visual quarry
#

I did, but i gotta go work now....

#

Ill figure it out after, thank you for the help

meager epoch
#

how can i put down a weapon which cant be picked up in eden?

distant oyster
visual quarry
hollow thistle
#

No, it's only A to B, not A to B to A. You need to script them going back.

#

the script finishes once they reach the destination so you can do it easily by calling it in scheduled script.

visual quarry
#

ah okay, i misunderstood the code then, cheers for all your help aswell as @little raptor

hollow thistle
#

You can basically run the same script again with starting point as LZ to have them go back.

visual quarry
#

Yup, thank you dude.

crude vigil
meager epoch
#

ive set the damage of the gun to 0% and it did it

elder sail
#

Whats a "foreign error" ?

#

(as opposed to a regular error)

little raptor
fleet stirrup
#

Before I put something in feedback tracker as a request for the future, is there no way to locally change an animation source in MP to improve network performance / animation lag?

still forum
still forum
winter rose
fleet stirrup
#

The primary issue is a significant lag (only updating every 5-10 seconds or so) for user animations in multiplayer within the cockpit. In a 2 seat helicopter the animations are practically live for the pilot (person who the aircraft is local to) but not for the gunner (who it isn't.)

My first thought would be to fix this by having the animation sources be local (since it's in the cockpit, desync doesn't matter because neither can see each other) but there may be better solutions

fleet stirrup
winter rose
#

I am not sure such things should be done via animateSource, but I am not a modder so i don't know much about selections etc
these would update locally

fleet stirrup
#

Yeah, it felt dirty to me too, but I couldn't find a way to do it other than that. Selections allow for you to change the textures (which is what I use to set the map background) but the transformations used to move / rotate them are done via UVAnimations (https://community.bistudio.com/wiki/Arma_3:_UVAnimations) which require you to use animateSource to control them.

To fix issues like these I am in the process of moving as much as I can across to the new MFD system (the mod had its start in A2 so it is doing it currently all using modelling and textures) but I can't move all of it across unfortunately, this being one of the parts - hence my interest

winter rose
#

I understand, thanks!

fleet stirrup
#

Thanks for the help! If anyone has any recommendations to me on either ways to improve this lag, or other ways of getting the same output.

I have even tried making tiny MPD objects that are createVehicleLocaled and attachedToed the screens in the model, which shouldn't have the network lag issue that the others do but unfortunately when you're in a vehicle its LOD is always drawn on-top of everything else even if the MPD object is closer, which stops that from working.

fleet stirrup
#

Another option could be having it so different animation sources could be "local" to different turrets. Not sure!

dreamy kestrel
#

Hmm... vectorAdd, etc, only support at most three elements? [1,2,3] vectorAdd [0,0,0,4] isEqualTo [1,2,3] 😦

still forum
#

yes

#

2 or 3 elements

#

nothing else

dreamy kestrel
#

unfortunate... I have a case where 4 would be great.

winter rose
still forum
#

We can support any length without negative performance impact, but has not been a priority so never been done

dreamy kestrel
still forum
dreamy kestrel
#

no worries, thank you; the BIS functions seem to be just fine.

meager epoch
#

Speaking of those... when should one use a BIS function and when the "normal version" of it?

winter rose
meager epoch
#

oh alright

#

thanks

weak obsidian
#

Is there a way to display the satellite or terrain map on an object? Something that would always display the terrain used, regardless which one? Trying to find a way to avoid having to make textures (as paa files) for all kinds of maps.

warm hedge
#

Probably use the texture that used in the Editor's select Map menu?

weak obsidian
#

hm woudln't that be named differently for each map as well? I mean it would still be easier than making them again myself.

warm hedge
#

Defined in config. Should be easy

weak obsidian
#

Ok thx I'll give it a look 🙂

dreamy kestrel
winter rose
dreamy kestrel
brazen lagoon
#

@winter rose @little raptor saw you guys got a call out in the BI blogpost! pretty cool

#

it is always nice knowing I can post something here and you two will point out if I'm doing something incredibly stupid :^)

winter rose
#

oh we do quite stupid stuff ourselves too don't worry 😄
adding @cosmic lichen to the batch, as he hasn't been mentioned :p

cyan dust
#

🎉

#

Yeah, you three helped a lot to us small-time Arma scripting hobbyists, you worth the mention, thanks a lot.

brazen lagoon
#

I just haven't talked with him a lot so I wanted to ping the two that'd helped me the most, but you're right big ups to all 3 of you

next dagger
#

Hi! I was hoping i could get some help, figuring out what I need to do.

I'm using a script that creates a Trigger (createTrigger). This script is executed in the Eden Editor.

Problem: The Trigger does not show up in the editor i.e I can't see or move it around, however if I start the mission the trigger activates as wanted. Thanks!

next dagger
runic surge
#

Is there a way to create an object at the exact center position of the player's screen where it intersects with the terrain, or an object? And at a set distance when pointing at the sky with nothing in the way?

screenToWorld doesn't work for objects, or when you're pointing at the sky, the lineIntersects commands require an endpoint (which kind of defeats the purpose since that's what I am trying to find out in the first place)

winter rose
runic surge
#

I am aware

winter rose
#

other than that, you can use camera position + camera direction + vector multiplication to get what you want

digital rover
runic surge
#

what is _camPos?

digital rover
#

The origin of the line, such as player eyepos when using screenToWorld, you could use ```sqf
eyePos player

little raptor
runic surge
#

Doesn't seem to work. The object being created just gets place away from the object I am looking at, rather than the point on the object I am looking at

runic surge
#

Wait, probably just need to set the position after the createVehicle command

#

forgot about that

runic surge
#

Seems to work with some objects, while ignoring others. It also always chooses the closest object to the player position, but I might be able to force it to use the cursor object

copper raven
grand idol
#

Can server-side scripts be recompiled while in a mission using file patching?

brazen lagoon
#

can you use any of the functions in the BIS sector control stuff outside of it?

#

i want to use the function that tells you which side has a sector without using the entire rest of the module

snow pumice
#

hey i have a side in an array which is in a config, when i select the array the side is a string, is there any better way then call compile the string to get back the side?
https://forums.bohemia.net/forums/topic/210585-side-from-string/
The solution with find would be fine but find is case sensitive so this is less ideal for me

brazen lagoon
#

lol fair

winter rose
brazen lagoon
#

actually tbf since im using alive i think i cant use that anyway

sacred turret
#

does anyone knows why this doesnt work?

[player, "eject", vehicle player] remoteExec ["action", side _caller, true];

inside of an addAction function, whereas _caller is the one who called the action, the rest of the code works fine.
intent is to make everyone from the side who called the action eject one's vehicle

sacred turret
#

well I still cant figure out whats wrong with the code

little raptor
sacred turret
little raptor
#

yes

sacred turret
#

got it, thanks

little raptor
#

because the original version is:

player action ["eject", vehicle player]
little raptor
sacred turret
#

what do you mean?

little raptor
#

why are you even trying to remoteExec that?

sacred turret
#

to exec for each player on the side of the caller, is there a better way to do it?

little raptor
#

you want to eject all players from their vehicles?

sacred turret
#

from one side, yes

little raptor
#

then your code is wrong

#

what you wrote is taking player from your computer

#

not others

#

so you're just ejecting yourself on all computers

sacred turret
#

I've tried to use _this, but couldnt manage to get it to work, outputs an array

#

select 0 works sometimes, but not always

#

how can I make it work?

little raptor
#

first of all, I'm not sure if the command even needs remote execution

#

it has nothing to do with _this and _caller and stuff

#

anyway, you can try this:

{
  if (isPlayer _x) then {
    _x action ["eject", vehicle _x];
  };
} forEach units side _caller;
#

if it doesn't work use remote exec

sacred turret
#

but even tho

#

if it wouldnt work, how could I do it?

somber radish
#

Quick question, is there any advantage to using a MissionConfig instead of variables?

little raptor
#

you can only store string and number constants (and arrays of these) in missionConfig

#

not variables

somber radish
#

I know, but lets say I got a few constants like ```sqf
6mm guns = ["Gun1", "gun2", "gun3"];
Helmets = ["HelmetName1", "HelmetName2"];

So is there any performance gain to using Config instead of variables?
little raptor
#

because you have to fetch them from the config

#

but I think config variables take up less memory

somber radish
#

oh ok Got it

#

So not anything to worry about in other words

#

Thank you!

brazen lagoon
#

Is there anything obviously wrong with this? ```sqf
_ret = nil;

if ((count _result == 1) && {(_result select 0 select 1) > 0}) then {
_ret = (_result select 0) select 0;
} else {
if (count _result == 0) then {
_ret = [_objective, "lastOwner", nil] call ALiVE_fnc_hashGet;
};
};

_ret```

#

it keeps saying _ret is an unknown variable on line 4

#

or can I not return nil like this?

#

yeah this doesn't work for returning nil lol

crude vigil
#

If so, there is no problem in here. It makes sense. But you should of course check at the end if it is still nil after the code in between is executed.

crude vigil
brazen lagoon
#

yeah I figured it out

little raptor
#

but not in scheduled environment

#

it throws an error

crude vigil
#

What exactly do we mean by returning nil exactly? From my knowledge, nil is just anything/nothing.

little raptor
#
_b = call {
  _a = nil;
  _a
};
isNil "_b"
crude vigil
#

You do not return _b though

#

you return if variable _b is nil

little raptor
crude vigil
#

What do you return in _a though?

little raptor
#

nil

crude vigil
#

Ok I accept I wrote that out wrong, you can, yes, return a value indeed. Because it holds a value "any" but I just tried to say that you cannot return it simply by calling the variable name.

little raptor
#

I called _a

#

the only place where "calling a nil variable name" is invalid is scheduled environment

crude vigil
#

Eh whatever, I just woke up and wont be able to go into philosophy, I assume I understood what he wanted to ask and responded according to that without confusing based on what I have understood.

#

Here I changed my answer.

grand idol
#

How would I use a variable as a selection index? For example:

_magazines = [["5Rnd_127x108_Mag",5],["100Rnd_65x39_caseless_black_mag",100],["7Rnd_408_Mag",7]]
_Index = 2;

_magClass = _magazines select _Index select 0;
_ammoCount = _magazines select _Index select 1;

The _magazines and _Index variables get populated elsewhere and I need to select from the array accordingly.

little raptor
grand idol
little raptor
grand idol
#

Yes, but it doesn't populate the array. That I have to get from a DB query since uniformMagazines, vestMagazines, and backpackMagazines are broken.

#

If those guys actually worked, I wouldn't have to involve the DB, but as of now I think I have to.

grand idol
#

Exile mySQL

little raptor
#

why do you use a database? just use getUnitLoadout and check if they're magazines in the config

#

plus using a database means that it won't support all mods that the user is running

#

config reading can be done dynamically

grand idol
#

This script needs to interact with a specific magazine in a players inventory. When the item is double clicked, it fires the EH with the container idc (uniform, vest, backpack) and the index. I need to track that specific mag through the script. Not just a similar class. If uniformMagazines or the others worked, II could use a switch statement evaluating the container idc and use that index to select from the array passed. Since those don't work, I have to use the array in the DB and the index. The data is the same, the source isn't. Either way, I still need a way to use the index number passed by the EH to reference the array and select the right mag.

grand idol
#

The index/array will provide not just the class, but the current ammo count in the mag.

little raptor
grand idol
#

I'm trying to push this with a big update next week, so...

grand idol
# little raptor ok I see what you mean now. I didn't know what you wanted to use the db for but ...

It provides the array of magazines in that specific container. The DB array matches the index passed by the EH There are DB columns mags, weapons, items, etc for each container type. So I query the vestMagazines column for that player and it provides every mag in that containers inventory. If I can tkae the EH index and use it as a selection index for the array everything works great. I just need to figure out how to format that.

#

onLBDblClick only provides the 2 arguments.

little raptor
grand idol
#

config.cpp

class VestContainer: UniformContainer
{
idc = 638;
onLBDblClick = "_this call ExileClient_gui_inventory_event_onItemDoubleClick";
x = "20.5 * (0.03) + (-0.25)";
y = "13 * (0.04) + (-0.25)";
w = "12 * (0.03)";
h = "14 * (0.04)";
colorBackground[] = {0,0,0,0};
sizeEx = "0.8 *             (            (            ((safezoneW / safezoneH) min 1.2) / 1.2) / 25)";
};```
#

ExileClient_gui_inventory_event_onItemDoubleClick:


private["_itemControl", "_itemControlIndex", "_itemClassName", "_itemDisplayName", "_configName", "_configSearch","_type","_magazines","_mag","_ammoCount"];
_itemControl = _this select 0;            // Passed from EH
_itemControlIndex = _this select 1;        // Passed from EH
_itemClassName = _itemControl lbData _itemControlIndex;
_itemDisplayName = _itemControl lbText _itemControlIndex;
_configName = "";


switch (_itemControl) do
{
    case "#633": {
    _type = "uniform";
    ["LoadMags",[getPlayerUID player,_type ]] call ExileClient_system_network_send; 
    };
    case "#638": {
    _type = "vest";
    ["LoadMags",[getPlayerUID player,_type ]] call ExileClient_system_network_send; 
    };
    case "#619": {
    _type = "backpack";
    ["LoadMags",[getPlayerUID player,_type ]] call ExileClient_system_network_send; 
    };
};

    while {true} do
        {
            isNil { player getVariable "bsf_mags" };
        };

    _magazines = player getVariable ["bsf_mags"];    // Gets all mags in container
    _mag = _magazines select _itemControlIndex select 0;
    _ammoCount = _magazines select _itemControlIndex select 1;

... other stuff```
#

ExileServer_BSF_network_LoadMags

params ["_sessionID", "_parameters","_mags"];
_sessionID = _this select 0;
_parameters =  _this select 1;
_playerUID = _parameters select 0;
_type = _parameters select 1;

_playerObject = _sessionID call ExileServer_system_session_getPlayerObject;

switch (_type) do {

    case "uniform": {
            _mags = format["BSF_uniform_mags:%1", _playerUID] call ExileServer_system_database_query_selectSingle;
        };
    case "vest": {
            _mags = format["BSF_vest_mags:%1", _playerUID] call ExileServer_system_database_query_selectSingle;
        };
    case "backpack": {
            _mags = format["BSF_backpack_mags:%1", _playerUID] call ExileServer_system_database_query_selectSingle;
        };
};

_playerObject setVariable ["BSF_Mags", _mags, false];```
grand idol
#

The whole DB and player variable thing is a workaround because of those broken functions that you reported on Sunday.

#

The reason that this is broken up into the 2 scripts is a security measure. The DB functions are run from the server while the rest on is the client.

little raptor
grand idol
#

I haven't actually done that yet.

little raptor
little raptor
#

do you have any idea how expensive that is?

grand idol
#

_itemControl is the container idc - #633, #638, or #619.
_itemControlIndex is the array index.
I need to use _itemControlIndex to make a selection from the array returned to _magazines = player getVariable ["bsf_mags"];

#

I won't be. Right now I'm beating my head against the wall just trying to sort this out and haven't cleaned up yet.

#

There's been a shitload of trial and error.

little raptor
copper raven
#
params ["_sessionID", "_parameters","_mags"];
_sessionID = _this select 0;
_parameters =  _this select 1;

wai meowsweats

grand idol
little raptor
#

that or _itemControlIndex < 0

grand idol
#

It's not though. I've been checking the output to those variables and they've always been accurate. So SHOULD _mag = _magazines select _itemControlIndex select 0; work as far as you know?

little raptor
#

yes

grand idol
#

well shit.

little raptor
#

as long as your listbox items are correct

#

and match your array

grand idol
#

Ok, I'll tidy up and do a round of logging and see if there's something else going on. Knowing that it should work as written is a big help.

little raptor
#

but your approach to the problem is kinda bad. you're fetching the array from the db when the user double clicks, but you don't update the listbox

#

and I still have no idea why you're using a database... nootlikethis

#

you can just do this on the client's PC

grand idol
little raptor
#

you already have them:

params ["_sessionID", "_parameters",

grand idol
#

The thing that I keep running into is matching the specific mag and ammo count.

little raptor
# grand idol How?

how is what you're storing in the database any different from what the user already has in his inventory and can access locally?

#

you're just saving a bunch of stuff in the database

#

with unnecessary network traffic

little raptor
#
private _containers = ["Vest", "Uniform", "Backpack"];
private _allMags = magazinesAmmoFull [_unit, true];
private _magCategories = [[], [], []];
{
  _x params ["_mag", "_cnt", "_loaded", "_type", "_container"];
  private _containerID = _containers find _container;
  if (_containerID >= 0) then {
    _magCategories#_containerID pushBack [_mag, _cnt];
  };
} forEach _allMags;
#

use that in a loop every few seconds to update the inventory mags

#

then just do:

if (_magCategories isNotEqualTo _lastMagCat) then { //inventory changed
  lbClear _lb;
  ...
  //update listbox
};
#

also you can store information in each listbox item

#

using lbSetData and lbSetValue

grand idol
little raptor
#

what does it have to do with what I said?

#

you just want the first instance of a mag that matches your class and cnt in the corresponding container

#

then you remove it

grand idol
#

Not exactly. When a player opens their inventory and double-clicks on an item, it opens a new display with details, ammo count, recipes, etc. They start by interacting with a specific mag and seeing it's count. If a player has 20 different mag classes and they are all partially full, I don't see how to track that without using the array and index.

little raptor
grand idol
#

Yes, I understand that. It's when you have

[
  ["classA", 7], ["classA", 9], ["clasB", 1], ["classC", 23], ["classA", 1], ["classC", 22], ["classB", 3], ....
]```
Which is more likely when a player is using this script.
#

But for now, I need to get some sleep. I appreciate your input as usual.

#

I'll play with the code you posted and see what I can do.

sacred turret
#

guys, is there a reason why

west addScoreSide 100;
resistance addScoreSide 100;

will only work for host? code inside initServer.sqf and outside of any functions or code blocks; wiki says addScoreSide has global effect

unique sundial
#

Does this command have green Se icon?

proven charm
#

I want to allow user to cancel mission loading by pressing ESC but don't know which dialog should get the displayAddEventHandler. any tips?

calm bloom
#

Hello, guys! Does anyone know if one can get current ambient sound path or class? I think livonia's wind sound is way to loud but cant find exactly which sound shader i hear.

sacred turret
winter rose
sacred turret
#

yes

winter rose
sacred turret
#

I mean, I execute the addScoreSide on the initServer, it works for the host; but when I try to get scoreSide locally it returns 0

winter rose
#

server: ```sqf
// initServer.sqf
blufor addScoreSide 1234;
systemChat format ["server score: %1", scoreSide blufor]; // "server score: 1234"

// init.sqf, client-side
systemChat format ["client score: %1", scoreSide blufor]; // "client score: 0"

sacred turret
#

yes, something like that, the clientside part is actually inside an addAction in onPlayerRespawn, but the rest of the code works fine, so I guess it's not it

real tartan
#

how can I spawn fire ?
I tried this, but it does not hurt units.

private _fire = "test_EmptyObjectForFireBig" createVehicle _position;
tidal ferry
#

Hey, quick question for scripters

#

How does isTouchingGround work?

#

Does it work by if you're standing on something (i.e. could be a building), or if you are actually on the natural terrain of a map?

still forum
#

building also

#

but it doesn't work perfectly in all cases

warm vapor
#

Question for you: I see people using spotlight scripts, but the armaholic for them has disappeared long ago. Is there a simple way to achieve spotlight cones for AA, searchlights, etc?

winter rose
warm vapor
#

Found what you're referencing. I had seen it before, but finding the tutorial PBO and learning how to extract it took some doing. Thank you 🙂

still forum
#

We need more such example tutorial scripts on wiki with good explanation

winter rose
#

no

warm vapor
#

Hm. Here's one for you that's kind of interesting.

I'm designing a mission for a StarSim unit. Said unit uses custom planes that, for whatever reason, the AI just don't want to shoot at with AA guns.

SAM? Sure. They'll fire surface-to-air missiles until the cows come home, but they -won't- fire anything - Shilka, Praetorian, none of it seems to care that there's a plane in VTOL mode sitting right in front of them. Is there anything I can do about that from a script level?

winter rose
#

it would be more of a config issue

warm vapor
#

True, that would be the ideal fix, although I can't modify the modpack for obvious reasons - I've reported it though. I was hoping there might be something I could do on a script level. Sounds like probably not

little raptor
digital vine
#

Is there a way to set the init of an object, spawned by script via function?

sacred turret
cosmic lichen
#

Nah. Should work just fine.

little raptor
willow hound
little raptor
#

Or someone else?

digital vine
#

So the object will be spawned, via a zeus module, I have a script which works in the editor for pre-placed objects. I can provide the function sqf I am using if that helps?

digital vine
#

Aye

little raptor
#

Then what do you need init for?

#

Just execute the code immediately after creating the object

digital vine
#

Basically the module spawns a barrel, which I want to lay dormant after its spawn, until it is shot at by a player (MPEventHandler), which it will then set alight and explode

little raptor
#

Like I said, do that after creating the object in the module function

#

It's exactly the same as init

digital vine
#

Will try now and report

#
_activated = _this param [2,true,[true]]; 

if (_activated) then {
    _this spawn {
        params ["_logic", "_units"];     
    _pos = getPos _logic;
    if !(isnull (attachedto _logic)) then {_pos = getposatl (attachedto _logic);};
    _dir = _logic getvariable ["dir",random 360];
    _h = _pos param [2,0]; 
    _h = _h + 0; 
    _pos set [2, _h]; 
    _ExploBar = "Barrel1" createVehicle [0,0,0]; 
    _ExploBar setPosATL _pos;  
 
    _this addMPEventHandler ["MPHit", {    params ["_unit", "_causedBy", "_damage", "_instigator"];
    if !(_instigator in allplayers) exitWith {false};
    private _hitCount = (_unit getVariable ["you_hitCount", 0])+1;
    _unit setVariable ["you_hitCount", _hitCount];
    if (_hitCount >1) then {
        _unit removeMPEventHandler ["MPHit", _thisEventHandler]; 
        _unit spawn {
            private _emitter = "#particlesource" createVehicle position _this;
            _emitter setParticleClass "MediumDestructionFire";
            sleep ((round random 3) +3);
            "HelicopterExploSmall" createVehicle position _this;
            {
            deleteVehicle _x;
            } forEach [_emitter, _this];
        }
    }
}];

    deleteVehicle _logic;

{
    _x addCuratorEditableObjects
    [
    entities [["Barrel1"],["Logic"], true /* Include vehicle crew */,true /* Exclude dead bodies */],
    true
    ];
} count allCurators;

};
};
true

This is the function, still getting errors, although this time it is Type array, expected Object

little raptor
#

_this is an array

#

You should've used _barrelblabla

willow hound
#

@little raptor Say the getPos thing!

little raptor
little raptor
little raptor
digital vine
digital vine
little raptor
#

or ATL

#

but ASL is better

willow hound
#

This part is also not good yet:

{
    _x addCuratorEditableObjects
    [
    entities [["Barrel1"],["Logic"], true /* Include vehicle crew */,true /* Exclude dead bodies */],
    true
    ];
} count allCurators;
````addCuratorEditableObjects` has to run on the server, but the module function is not guaranteed to run on the server.
Additionally, you know exactly which object (i.e. which barrel) you want to add to the Zeus interfaces, so there is no need to use `entities`.
digital vine
willow hound
#

DS_fnc_addToAllCurators:

params ["_objectsArray", "_addCrew"];
{
  _x addCuratorEditableObjects [_objectsArray, _addCrew];
} forEach allCurators; //Using count instead of forEach is a performance optimization.
```Slightly modify the module function:
```sqf
...
deleteVehicle _logic;
[[_exploBar], false] remoteExec ["DS_fnc_addToAllCurators", 2];
...
digital vine
little raptor
#

it's kinda broken

willow hound
#

Locality issues are also in here:

_this addMPEventHandler ["MPHit", {    params ["_unit", "_causedBy", "_damage", "_instigator"];
    if !(_instigator in allplayers) exitWith {false};
    private _hitCount = (_unit getVariable ["you_hitCount", 0])+1;
    _unit setVariable ["you_hitCount", _hitCount];
    if (_hitCount >1) then {
        _unit removeMPEventHandler ["MPHit", _thisEventHandler]; 
        _unit spawn {
            private _emitter = "#particlesource" createVehicle position _this;
            _emitter setParticleClass "MediumDestructionFire";
            sleep ((round random 3) +3);
            "HelicopterExploSmall" createVehicle position _this;
            {
            deleteVehicle _x;
            } forEach [_emitter, _this];
        }
    }
}];
```The MP EH fires on every machine. That is good for your particle effect (because that needs to be created locally on each client), but bad for your `HelicopterExploSmall` explosion - because every machine creates its own explosion, meaning you'll get as many explosions as you have machines.
I'm not sure how you intended the `you_hitCount` object namespace variable, but it's local to each machine, so it only counts how many times the local player has shot the barrel (instead of how many times the barrel has been shot by players in total).
digital vine
#

So to fix this, would you close the MPEh after the emitter then spawn the explosion?

willow hound
#

I think ...

...
if (isServer) then {
  "HelicopterExploSmall" createVehicle getPosASL _this;
};
...
```... should be enough.
digital vine
#

but saying that, the explosion isn't actually working now since not getting the Type array, expected Object error

#

Actually really confused now :/, would you like the sqf as it now looks?

willow hound
#

Sure.

digital vine
#
_activated = _this param [2,true,[true]]; 

if (_activated) then {
    _this spawn {
        params ["_logic", "_units"];     
    _pos = getPosATL _logic;
    if !(isnull (attachedto _logic)) then {_pos = getposatl (attachedto _logic);};
    _dir = _logic getvariable ["dir",random 360];
    _h = _pos param [2,0]; 
    _h = _h + 0; 
    _pos set [2, _h]; 
    _ExploBar = "Barrel1" createVehicle [0,0,0]; 
    _ExploBar setPosATL _pos;  
 
    _ExploBar addMPEventHandler ["MPHit", {    params ["_unit", "_causedBy", "_damage", "_instigator"];
    if !(_instigator in allplayers) exitWith {false};
    private _hitCount = (_unit getVariable ["you_hitCount", 0])+1;
    _unit setVariable ["you_hitCount", _hitCount];
    if (_hitCount >1) then {
        _unit removeMPEventHandler ["MPHit", _thisEventHandler];        
        _unit spawn {
            private _emitter = "#particlesource" createVehicle position _this;
            _emitter setParticleClass "MediumDestructionFire";
            sleep ((round random 3) +3);
            if (isServer) then {
                "HelicopterExploSmall" createVehicle getPosASL _this;
            };
            {
            deleteVehicle _x;
            } forEach [_emitter, _this];
 
        }
    }
}];

    deleteVehicle _logic;

    [[_exploBar], false] remoteExec ["DS_fnc_addToAllCurators", 2];

};
};
true
willow hound
#

Can you run it with some systemChats to see if the MP EH is actually added and fired?

little raptor
#

it's doing nothing

digital vine
digital vine
little raptor
#

yes. but why did you even add it in the first place?! 🙃

digital vine
#

Tbh, I lifted it from another function I created for a parachute resupply, where it was needed to provide a spawn height XD, guess I can snippy snip 🙂

willow hound
#

Then you run the code, test it and if you expected to read Step 3 but it doesn't appear, you know that the line with systemChat "Step 3"; is never reached, helping you find out why the code doesn't behave as expected.

digital vine
#

Awesome, just loading it now.

#

Out of curiosity rather than killing the game, updating the file -->new PBO--> new local mod --> restart the game, is there anyway to do it on the fly for a "local mod" or shortcuts, as all these iterations are killing me XD

little raptor
#

once the mod is done you can put the function in the mod

digital vine
# willow hound Then you run the code, test it and if you expected to read *Step 3* but it doesn...
_activated = _this param [2,true,[true]]; 

if (_activated) then {
    _this spawn {
        params ["_logic", "_units"];     
    _pos = getPosATL _logic;
    if !(isnull (attachedto _logic)) then {_pos = getposatl (attachedto _logic);};
    _dir = _logic getvariable ["dir",random 360];
    _ExploBar = "Barrel1" createVehicle [0,0,0]; 
    _ExploBar setPosATL _pos;  
 
 systemChat "Step 1";

    _ExploBar addMPEventHandler ["MPHit", {    params ["_unit", "_causedBy", "_damage", "_instigator"];
    if !(_instigator in allplayers) exitWith {false};
    private _hitCount = (_unit getVariable ["you_hitCount", 0])+1;
    _unit setVariable ["you_hitCount", _hitCount];

     systemChat "Step 2";

    if (_hitCount >1) then {
        _unit removeMPEventHandler ["MPHit", _thisEventHandler];        
        _unit spawn {
            private _emitter = "#particlesource" createVehicle position _this;
            _emitter setParticleClass "MediumDestructionFire";
            sleep ((round random 3) +3);

            systemChat "Step 3";

            if (isServer) then {
                "HelicopterExploSmall" createVehicle getPosATL _this;
            };

            systemChat "Step 4";
            
            {
            deleteVehicle _x;
            } forEach [_emitter, _this];
 
        }
    }
}];

systemChat "Step 5";

    deleteVehicle _logic;

systemChat "Step 6";

    [[_exploBar], false] remoteExec ["DS_fnc_addToAllCurators", 2];

systemChat "Step 7";

};
};
true

1,5,6,7 Load on spawn
2 after shooting it
3,4 never come :/

digital vine
little raptor
digital vine
#

Still need to figure out why It dies between Step 2 to 5 🤣

willow hound
#

Did you shoot it multiple times?

little raptor
digital vine
#

yes, a few times

#

and will do on next iteration

willow hound
#

Did you get Step 2 every time you shot the barrel?

digital vine
#

just the once

willow hound
#

Perhaps the barrel dies after the first hit and thus the EH stops firing?

digital vine
#

do I need to make it temporarily invincible?

willow hound
#

Does not fire when a unit is set to allowDamage false. However it will fire with "HandleDamage" EH added alongside stopping unit from taking damage (unit addEventHandler ["HandleDamage", {0}];. Will not trigger once the unit is dead.
Maybe, not sure if that will help. Also seems to depend on what kind of invincible 🤷‍♂️

willow hound
digital vine
#

bear with just translating it to read from the mission file rather than a mod

#

almost there

#

@little raptor I have the mission folder way of doing mod iterations, and I've set it to include the mod folder, but this does not seem to add the mod to the zeus interface, have I missed any steps?

little raptor
#

you still need the pbo

#

minus the functions

#

you can't add new objects (inc. modules) after the game is launched

digital vine
#

Ok will go for a re-try

#

Did the systemChat str _hitCount and it only registers 1 :/

#

I attempted to put in the handle damage, will show

#
...
 private _hitCount = (_unit getVariable ["you_hitCount", 0])+1;
    _unit setVariable ["you_hitCount", _hitCount];
    _unit addEventHandler ["HandleDamage",{0}];

     systemChat str _hitCount;

    if (_hitCount >1) then {
...
little raptor
digital vine
#

whats really weird is that it will count up to 2, but only if I manually add it to curator objects

little raptor
digital vine
#

big confuse

elder sail
#

Could someone point out what I've done wrong with my switch/case? I had this as separate if statements but decided to try a switch instead and it returns "error foreign error: invalid switch block" but I'm not sure what I've done wrong.
(It's called with an event handler when the player gets into a vehicle)

VehicleType = "";

switch (true) do {
    case (vehicle player isKindOf "Land"): {VehicleType = "Land"};
    case (vehicle player isKindOf "Ship"): {VehicleType = "Ship"};    
    case (vehicle player isKindOf "Air"): {VehicleType = "Air"};   
};

hint VehicleType;
VehicleType = nil;
little raptor
#

except using switch! meowsweats

#

and using global variable

brazen lagoon
#

is there a good way to return out of a script immediately, regardless of scope?

brazen lagoon
#

ok

elder sail
#

Would there be a better alternative to switch? I thought it'd be more efficient than the if statements i had before. Also yeah variables are just for testing 😅

brazen lagoon
#

do I have to name the parent scope to break out of?

elder sail
little raptor
#

you can make your own switch based on that:

#define switch(x) private __switch__ = x; call
#define case(x) if (x == __switch__) exitWith

switch(_bla) {
  case(_blabla) {
  };
};
brazen lagoon
#

yeah that worked

#

thx

brazen lagoon
#

Anyone have any suggestions on how to do a progress bar while taking an objective?

little raptor
#

RscProgress + ctrlSetProgress (or something, see the wiki)

brazen lagoon
#

My quick + dirty way of doing it is just getting a list of units in the objective + remote execing a hint of how long remains

#

thats probably better

#

is there an example of how to use that? I can't find it on the wiki

brazen lagoon
#

cool

#

now I need to figure out how to do capture blocking

copper raven
leaden summit
#

Hey so I was just looking at BIS_fnc_saveInventory in the wiki and there's this example at the bottom

//--- save it
[player, [missionNamespace, "Var_SavedInventory"]] call BIS_fnc_saveInventory;

//--- load it
[player, [missionNamespace, "Var_SavedInventory"]] call BIS_fnc_loadInventory;

now if I changed that from missionNamespace to profileNamespace will that essentially mean I can have players save gear at the end of one zeus mission, and then I could load it from the initPlayerLocal.sqf so they start the next mission with the same gear they ended the last with?

jade acorn
#

how can I make AI "forget" about the player or any enemy unit? It seems that as long as the enemy is alive, even not visible for them (or far away) they still stay in combat mode. When the enemy dies, they turn to Aware. When I change their status to careless and then back to Safe, they immediately turn to the aware/combat mode

warm hedge
#

_unit reveal [_target,0] should do, IIRC

cosmic lichen
leaden summit
#

Cool thanks for that

proven charm
#

can you read input during mission preload?

little raptor
#

what input?

proven charm
little raptor
#

but not sure. you should try

proven charm
#

I was trying to use finddisplay and displayAddEventHandler "keydown" but don't know which disp ID I should use

#

yes the loading screen

proven charm
#

I'm using startLoadingScreen

#

tried putting the (custom) load screen display to the keydown EH but to no avail

little raptor
#

it's "RscDisplayNotFreeze"

proven charm
little raptor
#

so just use that

little raptor
proven charm
#

yeah

little raptor
# proven charm yeah

you can still try it:

_disp = uiNamespace getVariable ["RscDisplayNotFreeze", displayNull];
proven charm
#

But I have custom loading screen

#
 _loadScreen = (uiNamespace getVariable ['gcCtiLoadScrn', displayNull]);
 _loadCtrl = _loadScreen displayCtrl 1200;

_loadScreen displayAddEventHandler ["KeyDown",
{
diag_log "INPUT!!!";
}];
#

doesnt work

little raptor
proven charm
crude vigil
proven charm
#

hmm ok

#

maybe there's some dialog that could take input but I dont know that dialog ID

velvet merlin
#

how can the group of players become null?

#

isNull group player => <null group>

velvet merlin
#

getting some very weird result with hosted server + one client

little raptor
copper raven
#

i don't think a group can become actually null, it can become empty group(at which point it shows null group, but its actually joinable), or it can be non existant which is == grpNull. I don't think it can become null if it wasn't null beforehand, maybe some network issue blobdoggoshruggoogly

velvet merlin
#

hosted server

#

same for 2.04 stable or perf build

#

with just hosted server its fine

#

however with the additional client, this super funky stuff happens

#

happens even with vanilla CP

#

or starting the vanilla COOP you loose immediately

#

somehow this local host plus client from the same data (but different profile) seems to break the player/system init

#

even breaks it when you JIP with the client into a running mission (as the playable units/groups get wiped)

velvet merlin
#

seems somehow caused by our mod, or some startup parameter

#

trying to narrow it down atm

still forum
#

@velvet merlin check count allGroups

velvet merlin
#

= 0

hollow thistle
#

you broke the game NotLikeThis

still forum
#

maybe something deletes the group after a unit joins a group, or after a unit is spawned

velvet merlin
#

ok seems if i am running my DevCon on both hosted and the client

hollow thistle
#

but group should be not deletable if it contains units... thomp

still forum
winter rose
#

#blameDedmen

velvet merlin
#

seems even just on the client is enough (in a hosted session - DS should be fine)

royal quartz
#

Hi guys just a quick one init.sqf dosnt say if it gets executed for just server or server and client on a dedicated server, which I think it does but can anyone confirm?

I know Serverinit.sqf is executed server side only but im wondering if init.sqf is executed server and locally for each client.

https://community.bistudio.com/wiki/Event_Scripts#init.sqf

hollow thistle
royal quartz
#

Thought so just recently got into arma scripting editing a mission from the workshop to add some bits and founds bugs because of this cheers 😄

velvet merlin
#

how does one execute something on a JIP unit from the server these days?

#

via forum i found this recommended:

#
    addMissionEventHandler ["PlayerConnected",
    {
        params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];

diag_log ["PlayerConnected - _id",_id];
diag_log ["PlayerConnected - _uid",_uid];
diag_log ["PlayerConnected - _name",_name];
diag_log ["PlayerConnected - _jip",_jip];
diag_log ["PlayerConnected - _owner",_owner];
diag_log ["PlayerConnected - _idstr",_idstr];
        {
diag_log ["PlayerConnected - _x",_x];
diag_log ["PlayerConnected - owner _x",owner _x];
//            if ((owner _x) == _uid) exitWith
            if (_x isEqualTo _owner) exitWith
            {
                _unit = _x;

diag_log ["RemoveItems - initServer - PlayerConnected",time,diag_tickTime,LIB_CadetMode,_unit getVariable ["BIS_UnitClass",""],_unit];
                if (_unit getVariable ["BIS_UnitClass",""] == "") then
                {
                    [_unit,BIS_infantryPlayer] call WW2_MissionUtilityFunctions_fnc_SetUnitLoadout;

                    //remove items on veteran/hardcore
                    if (!(LIB_CadetMode)) then
                    {
                        [_unit,true,true,true] spawn WW2_MissionUtilityFunctions_fnc_RemoveItems;
                    };
                };
            };
        } forEach allPlayers;
    }];```
#

but there is no matching data:

#

17:21:46 ["PlayerConnected - _id",1.46288e+009]
17:21:46 ["PlayerConnected - _uid","76561198009068539"]
17:21:46 ["PlayerConnected - _name","test"]
17:21:46 ["PlayerConnected - _jip",true]
17:21:46 ["PlayerConnected - _owner",5]
17:21:46 ["PlayerConnected - _idstr","1462881321"]

17:21:46 ["PlayerConnected - _x",bis_o2_6344]
17:21:46 ["PlayerConnected - owner _x",2]

#

or rather the JIP unit is not yet part of allPlayers as it seems

still forum
#

PlayerConnected is connect to server, not selected into a body, but you can remoteExec to its ownerid (5) as target?

winter rose
# elder sail Could someone point out what I've done wrong with my switch/case? I had this as ...

absolutely no issue on my end
you most likely have another issue somewhere else (missing {}?)
anyway yes, don't use switch as others stated```sqf
onEachFrame {
_vehicleType = "";

switch (true) do
{
case (vehicle player isKindOf "Land"):
{ _vehicleType = "Land" };
case (vehicle player isKindOf "Ship"):
{ _vehicleType = "Ship" };
case (vehicle player isKindOf "Air"):
{ _vehicleType = "Air" };
};
hintSilent _vehicleType;
};

royal quartz
#

What is the easiest way to add an action to an object for everyone.

I assume putting it in serverinit.sqf wont work as theres no UI so it wont add it so I guess just putting the addaction in initPlayerlocal.sqf would be best?

sacred turret
sacred turret
winter rose
royal quartz
# sacred turret any reason why not to use remoteExec?

Oh Durr ofc I could just use that and put the code in {} I have used this before but defined the code as a function inside "initPlayerlocal.sqf" (as it was called dynamically through't the mission on difference objects passed in) but this one I just want to add once.

I find putting code in {} for a remote execute dirty but I guess there is no point defining a function for it as it will be used once.

sacred turret
winter rose
winter rose
royal quartz
winter rose
#

but you can remoteExec without sending it "as code" as you stated earlier

sacred turret
winter rose
#

hence why I would write a ticket to have the getter work on clients 😄

sacred turret
winter rose
#

I don't get what you mean by that, do you happen to have an example?

sacred turret
#

[west, 100] remoteExec ["addScoreSide", 2, true];

#

gimme one sec

winter rose
#

this should work```sqf
[west, 100] remoteExec ["addScoreSide", 2]; // NOT jip, dang it - otherwise each new JIP adds 100 points to the west

sacred turret
#

missadded the true, mb

#

but that's what I meant

royal quartz
winter rose
royal quartz
#
_vehicle remoteExecCall["DeleteVic",BLUFOR ,true];

and DeleteVic is a in line function defined in "initPlayerlocal.sqf"

#

but that is defined as a function as I use it alot with different params. I just want to add an action for everyone once at mission start (and all JIPs) but if possible keep the code server side.

winter rose
#

people really need to understand what is this true/false JIP flag 😵‍💫

royal quartz
#

Boolean - If true, a unique JIP ID is generated and the remoteExecCall statement is added to the JIP queue from which it will be executed for every JIP.

sacred turret
royal quartz
#

its this it adds the code to be run for any person that joins after its run i thought?

winter rose
#

(no need for a remoteExec either, afaik)

royal quartz
winter rose
winter rose
winter rose
sacred turret
#

there isnt any Cfg files in my mission folder, is it located any other place?

royal quartz
sacred turret
winter rose
sacred turret
#

I've emptied the whole files in the folder, but to be honest didn't try to create a new scenario, I had CBA and 3den enhanced installed when I've created this one, maybe thats it

digital vine
#

Probably going to open too big of a can of worms for myself right now….

Is there anyway to script and create a link between a discord group and a dedicated server?

I would like (if possible) to create a script which will read certain ‘roles’ assigned to a user on discord, to be interpreted by a dedicated server, to perform specific actions on specific players when they log into the dedicated server?

I’m anticipating that this’ll be a no, or super complex, but just want a pointer in the right direction to see if this was possible to script?

edgy halo
#

Seems possible but you will have to do some research

#

Like find a way to link someones discord to their steam profile

jade acorn
#

can I use the setFace command safely in unit's init for a MP scenario? the if (isServer) then {[_unit, "HeadClassName"] remoteExec ["setFace", 0, _unit]}; example

hollow plaza
#

Is there any reason as to why this script wouldn't work? I had pretty much the exactly same script just a moment ago and it worked, but then suddenly it felt like it wasn't initialized anymore.

sleep 2;
if (isNull flagOwner Redflag) then {

} else {
systemChat "Red flag has been captured";

}```
#

That's in FlagRed.sqf
init.sqf has execVM "FlagRed.sqf"; in it.

winter rose
winter rose
hollow plaza
#

I think the part that was most puzzling was the fact I tried putting that code directly into the ingame console and it worked somehow

hot kernel
#

any idea how to force the watch gui?

open mirage
#

I did a CQB map for single player where you can reset blown up walls and hide/show killhouses. I never tested it on a server but a friend did and says it doesn't work. Me being a complete idiot when it comes to MP scripting i have no idea how to make it work online. All the codes are pretty much the same it just changes the variable names. What could i do to make it work on a dedicated server?

initPlayerLocal.sqf

 ////////////////////////////BRAVO///////////////////////////////////////////
cqbbdoor = {
    cqb_b_d1 setdamage 0;
    cqb_b_d2 setdamage 0;
    cqb_b_d3 setdamage 0; 
    cqb_b_d4 setdamage 0;
    cqb_b_d5 setdamage 0;
};

//Resets
sign_cqb_b addAction ["Reset Portas", cqbbdoor];

//Hide & Show
hidecqbbravo ={
    sign_cqb_b hideObject true;
};

showcqbbravo ={
    sign_cqb_b hideObject false;
};

laptop1 addAction ["<t color='#00c72f'>Remover  Complexo Bravo</t>", hidecqbbravo];
laptop1 addAction ["<t color='#00c72f'>Construir Complexo Bravo</t>", showcqbbravo]; ```
winter rose
royal quartz
winter rose
open mirage
#

@winter rose the building reset cqb_b_d1 setdamage 0;
I was reading the wiki and i should change hideobject for hideObjectGlobal right?

winter rose
open mirage
#

Only the hideobject part or everything?

winter rose
open mirage
#

Ok, thanks for the help!

zenith edge
#

mmm, those new lasers look hawt. I was looking into it only a few weeks ago because I wanted to script a laser defence system to replace the CRAM system we disabled(due to lag from crams firing)

tired delta
#

Hello everyone, i got a small problem

#

i trying to get the cpmpatibleItems of my weapon but it dose not work with the way im using

#

_weaponClass = currentWeapon player; getArray(configFile >> "CfgWeapons" >> _weaponClass >> "WeaponSlotsInfo" >> "MuzzleSlot" >> "compatibleItems");

#

this is waht im trying

#

but i get an empty string

#

"[]"

umbral comet
#
group_1 = createGroup west;

"B_Soldier_F" createUnit [
    getMarkerPos "spawn1",
    group_1,
    [],
    0,
    "MAJOR"
];

group_1 (getMarkerPos "move1");

Can you tell where I made mistake? Whenever I try to run this code I'll get an error.

copper raven
open mirage
#

@winter rose I changed all the Hideobjects to global and changed the addaction to [laptop1, ["Remover Complexo Alpha", hidecqbalpha]] remoteExec ["addAction", 0, true]; didn't test it on a dedicated server yet but it works on SP. Is this right? Or the remotexec should be in the hideobject code?

winter rose
willow hound
#

The action was already being added to everyone, as the original code is initPlayerLocal.sqf.

#

Every player executes initPlayerLocal.sqf when joining, meaning every player executes the remoteExec statement, meaning every time a player joins, another Remover Complexo Alpha action is added to the laptop for every player (plus the JIP queue).
First player joins, executes initPlayerLocal.sqf: This adds the action to the laptop once and adds the same addAction statement to the JIP queue.
Second player joins, executes initPlayerLocal.sqf: The JIP queue already had an addAction statement, i.e. there already is an action on the laptop, but now initPlayerLocal.sqf adds another one - not just for the second player, but for the first player too, and to the JIP queue as well.

open mirage
#

oh ok, so the addaction was fine as it was and i need to remotexec all the hideobject codes?

#

if so, is there a easier/faster way to do it? Its about 1300 lines

willow hound
open mirage
#

yes, they are not run at the same time. Its 5 CQB training areas that i wanted to be able to "delete" to create something else in those places

#

and if needed making them show up again

#

so its duplicades because i suck at this and made hideObject 0 and hideObject 1 for each object

#

are images allowed here?

willow hound
#

Well, luckily for you, remote execution is versatile 🙂
Aside from not writing hideObject several hundred times (instead I recommend using a forEach-loop), here's what I would do:
1️⃣ Mass-replace hideObject with hideObjectGlobal using a capable text editor.
2️⃣ Create a separate function for each training area, then place the hideObjectGlobal code in those functions accordingly.
3️⃣ Simply use remote execution for those functions in initPlayerLocal.sqf:

laptop1 addAction ["<t color='#00c72f'>Remover Complexo Bravo</t>", { remoteExec ["KER_fnc_hideCQBbravo", 2]; }];
laptop1 addAction ["<t color='#00c72f'>Construir Complexo Bravo</t>", { remoteExec ["KER_fnc_showCQBbravo", 2]; }];
willow hound
open mirage
#

is imgur trusted?

willow hound
#

Well, I'm not afraid to click on imgur links blobdoggoshruggoogly

open mirage
#

So pretty much, each of the colored areas has separate functions

willow hound
#

Correct.

open mirage
#

Ok cool, that was already done so i just need to fix the addaction code to the one you showed

#

btw can the functions also be in the initplayerlocal or should they be seperate?

willow hound
#

It should even work with the MyFunction = { ... }; kind of functions (as long as MyFunction is a global variable).
Ah, but that will give you trouble with dedicated servers, because those don't execute initPlayerLocal.sqf, so they never create the functions you declare in that file.

open mirage
#

sorry for asking so many questions. To turn it into a global variable i need to rename them to have _ at the start?

willow hound
open mirage
willow hound
naive needle
#

Heyyy Guys, does someone has a idea, about how to open a storage box from the other side of the map, without teleporting it close to the player

royal quartz
# winter rose create them *via* `create3DENEntity`

so I used a function added to Zues by a mod to get objects in a certain radius returning all objects as the below. so they can be saved and added back later. (this is just 1 object pulled out). Im trying to take something that was made in Zues and turn it into something I can spawn in eden to make permanent my current issue is the rotation and position.

_object0 = createVehicle ["Land_BagFence_Long_F", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_object0 setVectorDirAndUp [[-0.761385,-0.62988,-0.153437],[-0.123516,-0.0914017,0.988124]];
_object0 setPosASL [13759.5,12832,11.419];

I changed the above into:

_object0 = create3DENEntity ["Object","Land_BagFence_Long_F", [0, 0, 0]];
_object0 setVectorDirAndUp [[-0.761385,-0.62988,-0.153437],[-0.123516,-0.0914017,0.988124]];
_object0 set3DENAttribute ["Position",[13759.5,12832,11.419]];

This creates the object ok in eden editor but it is high above the ground and once the game is run the object turns to rotation [0,0,0] because the position attribute is not set.

Issue:
Position: The object is always put high above where it was copied from.
Rotation: the command to set the objects rotation when spawned via zues again (shown above) has 2 3D vectors and im unsure which values to take to put into the eden rotation attribute to make it work.

naive needle
#

@little raptor what ?

little raptor
#

what what?

naive needle
#

I don't understand what you mean by that

little raptor
naive needle
#

Yes

little raptor
#

or do you mean like its inventory?

naive needle
#

Yes, player action ["GEAR",OBJECT] dosent work on longer distance

little raptor
naive needle
#

Is there a way to bypass it ?

#

or is it hardcoded

little raptor
#

not that I know of. but you can create a helper unit, teleport the unit to the container and open the unit's inventory instead. when the unit's inventory changes, apply the change to yourself

pearl gyro
#

Anyone have a config template to implement uniforms? a video would help too

unique sundial
royal quartz
winter rose
royal quartz
# winter rose isn't there a "Direction" Eden attribute? also, if objects are above/below groun...

Ill have a play with the different Pos functions but Im only able to change the set not the get as its a function added by a mod unless I write my own function which could be easier 🤔

Regarding "Direction" or "Rotation" there is only rotation for object attributes which I can set but I am unsure which values to use from the 2 3D vectors that the function returns.
https://community.bistudio.com/wiki/Eden_Editor:_Setting_Attributes#Attributes

winter rose
#

Im only able to change the set not the get as its a function added by a mod unless I write my own function which could be easier 🤔
yeah try setPosASL or setPosATL, see which one fits (most likely setPosATL given what you said)
if none works then use yourself the getPosASL on the object

#

as for "Rotation", it is a bit weird as there is usually vectorUp + vectorDir, try either one, I don't know

royal quartz
#

ok cheers, yeah rotation does seem wierd as using one or the other (vectorUp or vectorDir) sets the object facing a certain way. For vectorUp its along the Y axis and for Dir its along the Z axis but ill have a play more and try figure it out cheers.

little raptor
still forum
#

Shouldn't be relevant for script commands

winter rose
#

only a couple of them are impacted indeed, afaik

royal quartz
#

so to get it 100% you have to use "setVectorDirAndUp" but that dosnt help for only 1 3D vector in eden editor haha

little raptor
#

why 1?

royal quartz
little raptor
#

and how do you get it?

royal quartz
#

I am unsure what commands are used because im using a module added to zues by a mod that creates the below code for the object to be created 😦

_object0 = createVehicle ["Land_BagFence_Long_F", [0, 0, 0], [], 0, "CAN_COLLIDE"];
_object0 setVectorDirAndUp [[-0.761385,-0.62988,-0.153437],[-0.123516,-0.0914017,0.988124]];
_object0 setPosASL [13759.5,12832,11.419];

Might be worth just writing my own function

little raptor
#

I am unsure what commands
then how did you say there's only 1 rotation vector?

royal quartz
#

It sets the rotation correct on first spawn but once you load into the mission it screws it up because the rotation attribute of the object is not set. My problem is trying to find which vector values from the 2 3D vetors to use in the 1 3D vector the eden has.

_object0 = create3DENEntity ["Object","Land_BagFence_Long_F", [0, 0, 0]];
_object0 setVectorDirAndUp [[-0.761385,-0.62988,-0.153437],[-0.123516,-0.0914017,0.988124]];
_object0 set3DENAttribute ["Position",[13759.5,12832,11.419]];
little raptor
#

if it's only 1 vector it's probably the individual rotation angles

#

which are in radians btw

royal quartz
little raptor
#

first give me that "1 3D vector"

#

as in give me an example of what it is

royal quartz
#

(err not at the PC with the code at current haha but valus out of the sky)

[23.532,28.4623,39.463]

little raptor
#

seem like angles in degrees

#

well I don't know what rotation system eden uses

#

you can try this:

#
_dir = [0, 1, 0];
_up = [0, 0, 1];
{
  _dir = [_dir, _x, _forEachIndex] call BIS_fnc_rotateVector3D;
  _up = [_up , _x, _forEachIndex] call BIS_fnc_rotateVector3D;
} forEach _thatVector;
royal quartz
winter rose
royal quartz
winter rose
#

forEach?

cosmic lichen
#

Just be careful. Rotation values in Eden Editor are different from those in Zeus/Scenario

royal quartz
# winter rose …`forEach`?

yes ofc... but I mean that code leopard20 gave requires me to have the eden rotation already? "_thatVector" is the eden vector i gave him but I need to acheive it the only way around getting the rotation of the object from zues and create the it in eden so I wont have the eden object rotation

royal quartz
cosmic lichen
#

I see

upper siren
winter rose
cosmic lichen
#

I guess he places them in Zeus and wants to import them into eden editor!?!?

winter rose
#

I don't know!!1!1§1!

royal quartz
#

trying to write code to takes objects placed in zues and generate code to place them all in eden

winter rose
#

sounds painful - but I'll be off this convo I think

royal quartz
cosmic lichen
#

You need to loop through all units / vehicles and get their position and rotation, store them in an array in uiNamespace

#

Back in Eden you just loop over that array and use set3DENAttribute/s

royal quartz
cosmic lichen
#

Just try getPos (don't hit me leo)

#

for the Eden rotation I am not sure, I guess it's just some fixed offset or something. Trial and error I guess

royal quartz
#

yeah rotation is the main issue because of how "vectorDir" and "vectorUp" work

#

its a combination of the 2 vectors to get 1 that wil work in eden lol but I am unsure how to transform them

cosmic lichen
#

Yep, I know. No clue why it's different

royal quartz
#

oh well thank you everyone for the comments its just going to be a big pain of trial and error for a few days 😄

cosmic lichen
#

g2g now. Lunch is almost over. Back to work I guess 😩

winter rose
#

runs away

royal quartz
# winter rose …use Eden Editor? 😬

hahahahahahha xD we have a mod that allows players to build in our milsim we have a base building team we want the bases they build to become permanent so not possible but nice try 😉

acoustic night
#

i need help

royal quartz
#

I have it working another way but its generated via code in a .sqf file rather than being in eden editor itself just was hoping to add it to eden so we could edit it if we wanted. Seems alot more effort than its worth so I might stick with how it is but thanks for all the help guys.

acoustic night
#

how do i open the debug menu becuase i close it a while ago and i been trying to search online how to re open it so i can stop infi loading when my friends join me but i cant find anything on how to reopen it

winter rose
little raptor
acoustic night
#

what about in game does it work bc i use that to open it in the editor but it doesnt load up in the game

royal quartz
real tartan
#

trying to get all cars that are occupied by players

private _cars = vehicles select { ( fullCrew [_x, "driver", true] ) isNotEqualTo [] };
winter rose
#

there are no players ref here?

#
allPlayers select { not isNull objectParent _x } apply { vehicle _x };
```something like this
copper raven
#

iterating vehicles is probably better, then you don't have to filter duplicates

#

vehicles select {crew _x findIf {isPlayer _x} != -1} blobdoggoshruggoogly

spark turret
#

can i change the locality of a unit, f.e. a tank by using "_tank setOwner 2"?

#

want to make sure my tank is serverside before the script runs, to avoid any funky stuff

copper raven
#

you'd need to run that on tank's driver i think, perhaps using "Local" event handler 🤔

winter rose
brazen lagoon
#

@spark turret cant you just remoteexec the script

winter rose
#

it would be… better, yes
otherwise the tank might belong to some player, or you are running a race condition expecting the ownership transfer to happen before you run the other code, etc

bitter jewel
#

can i dump an units loadout into a box

urban tiger
#

surely the animation for grabbing in crouch class must be a typo?

AmovPknlMstpSnonWnonDnon_AinvPknlMstpSnonWnonDnon_Putdown
distant oyster
urban tiger
#

just made me giggle blobcloseenjoy

tidal ferry
#

Hey, anyone know how to disable manual respawning via description.ext?

winter rose
#

Yes, the wiki 😃

tidal ferry
# winter rose Yes, the wiki 😃

Thank you- I've already been looking through the description.ext article, and since it's quite a long article and I haven't been able to find what I'm looking for in the fifteen or so minutes I've already spent looking, I was hoping some friendly soul here would be able to point me in the right direction to save some valuable free time 🙂

winter rose
tidal ferry
winter rose
quaint oyster
#

Is it possible to tweak existing base game addactions? I'd like to modify an existing action for unload incapacitated, I'm wanting to modify the visual scroll text with a format or outright hide it so i can create my own with the same text and not have redundant addactions.

tidal ferry
winter rose
#

huh… are you sure about that meowhuh

tidal ferry
#

Yes, I've just tested it myself in 3den

#

With it off, the only option is the ticker for the autorespawn

#

I'd send screenshots but I can't easily paste in here :/

winter rose
#

what is your respawn type? respawn =

tidal ferry
#

respawn = 3

#

Ah, my idiocy appears to know no bounds

#

I think you may be right

#

It was an issue elsewhere in my description.ext file causing issues

winter rose
#

…you made me start Arma and try it

#

paddlin' list it is

tidal ferry
#

Hahaha, I'm really sorry

#

Final testing it now to confirm

winter rose
#

no probz, glad it's sorted ^^

tidal ferry
#

Wait no, even more counter-idiocy, as I seem to be right about it, it only changes the big respawn button

#

That said

#

I found a workaround for it, so

#

Problem failed successfully?

tidal ferry
winter rose
tidal ferry
little raptor
somber radish
#

So I know there is a way to disable weapon drop on death, But I cant remember how... Any help?

tacit tartan
#

Just remove the weapon from the unit

#

onKilledEVH

hallow mortar
#

I'm trying to spawn a Fire effects module on an arbitrary position. I'm doing it like this:

private _moduleGroup = createGroup sideLogic;
"ModuleEffectsFire_F" createUnit [
    getPosATL o_wreck,
    _moduleGroup,
    "newUnit = this; this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];"
];```
The module is being created at the appropriate position, but it doesn't seem to create a fire effect.  What am I missing?
copper raven
#

Maybe you need to set some other parameters via setVariable like most modules? 🤔

hallow mortar
#

I looked at it in the function viewer and it appears to assume a reasonable set of default parameters (the same as it uses when placed in the Editor)

copper raven
#

Did you try running the init func manually? meowsweats

hallow mortar
#

I was hoping to avoid it. After all, if I have to run it manually, I might as well just use a generic logic and not bother with the module at all :U

copper raven
#

Yea but just to see if that's the issue is what i meant

maiden garnet
#

anyone know if its possible to set an init to change an entire factions identity?

#

or, rather set their speaker to all be the same

hallow mortar
# maiden garnet or, rather set their speaker to all be the same

Use init.sqf (NOT a unit init field).
For a whole side (east, west, or resistance)

{_x setSpeaker "speaker_name_here"} forEach (units east);```
For a specific faction(s)
```sqf
{_x setSpeaker "speaker_name_here"} forEach (allUnits select {faction _x in ["faction_one","faction_two"]});```
#

*fixed typo in second one

hallow mortar
hallow mortar
surreal sail
#

Hey, i have a small question regarding sounds / playing sounds in arma.

My Problem: I am trying to recreate the default arma "Play Sound" Zeus Module, because we are using a mod with a ton of ambient sounds for immersion. The default arma sound selection dialog lacks the ability to search for sound by name/classname, so i created a dialog and made the list of all sounds searchable. This works without problems. After selecting a sound, the sound will be attached to the created logic, this also works without any problems. Now my Problem i can't get the sound preview to play while the dialog is open:

I tried: playMusic, playSound and say (i know this is a global function). But the sound is never found. I tried it with the sound-filepath, the name of the class in the CfgSfx.hpp and also the Class of the sound from CfgVehicles.hpp

Is there any possibility to preview the sound to the Zeus User in the dialog? OR Does anybody know how arma previews those sounds? I also thought about creating a temporary soundclass in runtime but i don't know if this would work

SOLVED: We found a solution in the RscAttributesSound.sqf, creating an empty trigger with soundEffect is the solution

cosmic lichen
#

Basically yes. If your code is not time-critical and you don't need a value to be returned you can safely let it run scheduled.

shrewd hedge
#

Hello, anybody could help me trigger a Task with units under show/hide moduel?

#

I use triggerActivated to trigger my next Task; however, next task related to hided unit, and it having trouble complete the task

#

I use this code to finish the task, basicly to destroy a four men crewed tank

#

and I use "!alive D1 && !alive D2 && !alive D3 && !alive D4; "to complete the task, but it doesn't work. Anybody could help me ?

cosmic lichen
#
[d1, d2, d3, d4] findIf {alive _x} == -1

try this

#

@shrewd hedge

shrewd hedge
#

-1 means all dead?

cosmic lichen
#

-1 means it hasn't found an alive unit

#

so yes, means all dead

finite imp
#

Hello guys,

I'm trying to play an air raid siren through a large amount of objects (speakers), 20 in total. I'd like to define an array of all the speaker objects which have variables (sp1 to sp20) and then reference this in-game with

playsound3D ["soundfile", object];

I'm guessing that I can reference an array here aswell, right? So it plays from all the objects inside the array.

How do I go about defining that array? What file inside my mission folder do I have to put this? Thank you already for your help 🙂

dreamy kestrel
little raptor
#

wat?

little raptor
#

since they're named sequentially

#
for "_i" from 1 to 20 do {
  private _obj = missionNamespace getVariable ["sp" + str _i, objNull]; 
  playsound3D ["soundfile", _obj];
}
warm hedge
#

I wish there is a command to convert string into identifier so bad, when I see such code

little raptor
#

you can define your own macro! 😛

#define QUOTE(x) ##x
#define APPEND(x,y) x#y
#define MAKEVAR(x,y) (missionNamespace getVariable QUOTE(APPEND(x,y)))
_obj = MAKEVAR(sp,1)
warm hedge
#

gniiii

finite imp
#

thank you!!!

#

Follow-up question, I can do this via zeus so its not big of a deal, but I'm wondering:

I know how to loop a sound indefinitely, but If I'd like to loop a sound maybe 5 times or for a certain amount of seconds, how would I go about that?

little raptor
#

for loop

finite imp
#

can you go into a little more detail? I dont have much experience with for arguments

little raptor
finite imp
#

Im fucking stupid

#

thank you

finite imp
# little raptor ```sqf for "_i" from 1 to 5 do { //5 times playSound3D ["somefile", _blabla]; ...

Okay I guess I am acutally stupid. Im really sorry, so bear with me:

I took that code what you wrote and tried incorporating it with the code you posted above and got this

for "_i" from 1 to 20 do {
  private _obj = missionNamespace getVariable ["sp" + str _i, objNull]; 
  for "_i" from 1 to 5 do {
    playSound3D ["a3\data_f_curator\sound\cfgsounds\air_raid.wss", _obj];
    sleep _soundduration;
  };
};

because I guess I still have to define the _obj array, correct? Otherwise the game doesn't know what I'm referencing.
But for some reason it plays only once, just like before. Yeah, I don't have much to do with this stuff, I'm sorry.

little raptor
#

And you can't do it like that

#

You have to reverse the two loops

#

and you have to define sound duration

copper raven
#

otherwise maybe some string "variable" interpolation operator(that doesn't actually make a command call in sqf), but that needs extra steps in parser level, and extra behaviour in the inst

little raptor
copper raven
little raptor
#

¯\_(ツ)_/¯

#

better safe than sorry

finite imp
#

The wiki says they can be safely nested without having to worry about recursion

copper raven
#

that's not what were talking about

finite imp
#

alright alright ill keep my mouth shut 😂

copper raven
#

in most languages, what you have will be using the same _i in both loops, meaning both of them will be incrementing it, and causing unexpected behaviour

#

but in sqf, it might not be the case meowsweats

#

yeah, the _i variable is private to the for scope, and has no influence on the parent scopes

shrewd hedge
dreamy kestrel
hallow mortar
#

It's probably used for flickering lights and stuff

little raptor
#

Why don't you open it in function viewer?

#

My guess is that it uses frame no or time

#

And applies it to a sin, with the requested frequency

shrewd hedge
#

my 6th task can not be activated, I guess because I show/hide them, any idea?

#

triggerActivated does not seemed to work for hide/showed unit

dreamy kestrel
#

returns: nothing? nonsense...

copper raven
#

wat?

dreamy kestrel
little raptor
#

Yeah it's a sine wave like I said

dreamy kestrel
#

right, I'm just wrapping my head around it, what sort of applications it might have, i.e. a stochastic period in which to trigger some event, action, etc...

little raptor
#

you can use it for flickering/pulsating stuff, using a sine wave, based on time

if you don't know how that's useful you don't need it meowsweats

dreamy kestrel
#

sure, it's one of those things; if you don't know you have a tool, you don't know what you don't know. anyway, thanks...

willow hound
earnest storm
#

So i have a script that does vinilla damage and I was wondering how I could tell it to do ace damage

brazen lagoon
#

anything see obviously wrong with this script? it's supposed to make a progress bar ctrl if it doesn't exist and then set it to the passed progress amount, then set it back to 0 once the player is far enough away from a position

#
params ["_progress", "_position", "_distance"];

disableSerialization;

private _bar = uiNamespace getVariable "capture_bar";
if (isNil "_bar") then {
    disableSerialization;
    bar = findDisplay 46 ctrlCreate ["RscProgress", -1];
    uiNamespace setVariable ["capture_bar", bar];
    bar ctrlSetPosition [safeZoneX, safezoneY + safezoneH * 0.02, safezoneW, safezoneH * 0.01];
    bar ctrlCommit 0;
    bar progressSetPosition 0.0;
};

_bar = uiNamespace getVariable "capture_bar";
_bar progressSetPosition _progress;

private _waiting_on_obj_leave = uiNamespace getVariable ["in_obj", false];
if !(_waiting_on_obj_leave) then {
    [_position, _distance, _bar] spawn {
        params ["_position", "_distance", "_bar"];

        disableSerialization;
        uiNamespace setVariable ["in_obj", true];
        while {((position player) distance _position) < _distance} do {
            sleep 1;
        };
        _bar progressSetPosition 0.0;
        uiNamespace setVariable ["in_obj", false];
    };
};

uiNamespace setvariable ["capture_bar", nil];
ctrlDelete _bar;```
royal quartz
#

Hi guys I feel im being dumb here 😅

When do objects from the eden editor exist before or after the initServer.sqf? I have the below code which works except the "MHQ1StartPos" and "MHQ1StartDir" are empty but running the same code in debug it works. So the issue is the variable not getting the value.

MHQ1StartPos = getPos MHQ1;
MHQ1StartDir = getDir MHQ1;

[myPole, ["Return MHQ 1 to Base", {MHQ1 setPos (_this select 3 select 0); MHQ1 setDir (_this select 3 select 1);}, [MHQ1StartPos, MHQ1StartDir]]] remoteExecCall ["addAction", 0, true];

from the below link I think its before but the variable are still empty.

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

wind flax
#

Quick question. If I have the server assign a variable to a player (_player setVariable ["blah_blah", "some-value"), could the client (using a script mod) also check this by using player getVariable "blah_blah"?

winter rose
#
_unit setVariable ["name", "value"]; // local
_unit setVariable ["name", "value", true]; // publicly set, on all machines and future JIP
wind flax
willow hound
misty osprey
#

how would I get the amount of cargo seats from the config of a vehicle I tried

_TotalSeats = count (getArray (configfile >> "CfgVehicles" >> _VehType >> "cargoProxyIndexes"));

however for some vehicles for example the CUP CH-47 returns []

winter rose
#

the alternative syntax offers an includeEmpty parameter

#
private _cargoSeatsNum = count fullCrew [_myCH47, "cargo", true];
```perhaps
copper raven
#

you have to create the vehicle keep that in mind(unless u already have it created), i think ace or cba does something like that

wind flax
# winter rose yes, if set publicly

No dice on my end. Any chance you could look over this and see if I'm missing something? I'm stepping into the unknown here. Any help would be greatly appreciated

Client side SQF (in a mod, in the postInit)

if(isNil { player getVariable "_testVariable" }) then {
     // Logic
};

Server side (in initPlayerLocal.sqf (in the mpMissions folder))

params ["_playerUnit", "_didJIP"];

_playerUnit setVariable["_testVariable", "testing", true];
winter rose
misty quail
#

rgr @winter rose thank you

royal quartz
narrow oxide
#

Does anyone know a good persistent save script out there ( for mp dedicated server )

misty osprey
late parrot
#

Any idea why loading triggers from a sqf automatically trigger?

narrow oxide
#

I want it to be automatic so after every 6 hours restart the player gear position base and car will saved

winter rose
#

That's mission-dependent then, and no "does-it-all" script can know and do all this

low sierra
#

_obj2 in not at [0,0,0], but at the end of the code _obj1 can be in [0,0,0]. It happens sometimes.

//SHCEDULED CODE
_obj1 setPosASL getPosASL _obj2;
deleteVehicle _obj2;
```Scheduled code.
#

Like if line one was _obj1 setPosASL getPosASL objNull.

winter rose
low sierra
#

@winter rose no, i'm just talking about this strange thing i found.

#

Btw, i'm not sure.

misty osprey
#

anyone know why the transport unload waypoint isn't work with groups created with BIS_fnc_SpawnGroup

copper raven
low sierra
#

@copper raven i will check it better.

little raptor
misty osprey
maiden garnet
#

this addEventHandler ['CuratorObjectPlaced',{_x setSpeaker "ENG5"} forEach (allUnits select {faction _x in ["I_AGR_SC"]})];

late parrot
#

I have an sqf that loads on select from strategic map but when it loads, the triggers inside the sqf instantly trigger causing events to occur even when they don't meet the criteria

hallow mortar
#

Making it work with curatorObjectPlaced is more complex than I want to type on my phone, but in short:

  • curatorObjectPlaced gives you a reference to the unit placed, so you don't need to run the command for every unit every time (you could but it's wasteful)
  • curatorObjectPlaced only triggers on the curator client, but setSpeaker needs to be run on every client, so you need remoteExec
proud carbon
#

_BossMech setPosWorld (_p1 vectorAdd (_p1 vectorFromTo _p2 vectorMultiply (_LowSpeed*diag_deltaTime)));
So when I call this within a loop function. I am getting odd behaviour.

#

The best way to describe this behaviour is processed by a demon. it does not go after the player like I want to instead it hovers the ground. actually when I hit escape key to bring up the debug I notice it kind of shifts or i guess tps a few inchs to the left or the right.
_p1 = getPosWorld _BossMech; _p2 = eyePos player; I have these that interact if that helps understand what I am trying to achieve.

unique sundial
willow hound
# royal quartz it shouldnt matter that the values are only avaiable server side right? Because ...

As far as I'm aware, that should be correct.
If you had done ...

[myPole, ["Return MHQ 1 to Base", { MHQ1 setPos MHQ1StartPos; MHQ1 setDir MHQ1StartDir; }]] remoteExecCall ["addAction", 0, true];
```... it would be a problem, because the `MHQ1Start*` variables would be resolved on the client (where they don't exist).
But the way you've done it seems correct to me, the variables should all be resolved on the server.
little raptor
little raptor
#

the other is getPosWorld

#

like I said it should be getPosWorldVisual

proud carbon
#

ok so here is what I have.

    _Passes = _Passes + 1;
    systemChat str _Passes;
    _LowSpeed = 0.01;
    _p1 = getPosWorldVisual _BossMech;
    _p2 = eyePos player;
        _BossMech setPosWorld (_p1 vectorAdd (_p1 vectorFromTo _p2 vectorMultiply (_LowSpeed*diag_deltaTime)));
    };
little raptor
#

that's terrible

proud carbon
#

is it?

little raptor
#

never use a while loop without sleep

#

and a while loop is not suitable here

#

as I said already

proud carbon
#

yeah but this is going to be call exec

little raptor
#

wat?

#

it has nothing to do with call

proud carbon
#

yeah but sleep doesn't work with call

little raptor
#

also if it was unscheduled your object wouldn't move at all

little raptor
proud carbon
#

how?

little raptor
#

call doesn't change the environment

#

are you even familiar with the scheduler?

proud carbon
#

no

little raptor
#

Where code starts scheduled

init.sqf
initServer.sqf
initPlayerLocal.sqf
initPlayerServer.sqf
functions with postInit attribute (although suspension is allowed, any long term suspension will halt the mission loading until suspension has finished)
code executed with spawn
code executed with execVM
code executed with exec
code executed with **call from a scheduled environment**
#

Where code starts unscheduled

Debug Console
Triggers
Waypoints (condition and activation)
All pre-init code executions including functions with preInit attribute
FSM conditions
Event Handlers on units and in GUI
EachFrame code (Event Handler / Scripted EH / onEachFrame)
Object initialization fields
Expressions of Eden Editor entity/mission attributes
Code execution with **call from an unscheduled environment**
Code executed with remoteExecCall
Code inside isNil
SQF code called from SQS code
Conversation Event Handler
Code inside collect3DENHistory
proud carbon
little raptor
#

I know

#

like I said just don't use while

proud carbon
#

this is unscheduled yeah?

little raptor
#

no

#

nothing can move when a code runs unscheduled

#

the game is frozen

proud carbon
#

oh so when the while is on the game stops if it was unscheduled.

little raptor
#

that would be true, but while in unscheduled can only run up to 10000 times

#

so it would eventually end

#

but your game would freeze for a second or so until the while is done

little raptor
#
["boss_move_EH", "onEachFrame", {
   params ["_player", "_BossMech"];
   _LowSpeed = 0.01;
   _p1 = getPosWorldVisual _BossMech;
   _p2 = eyePos _player;
   _BossMech setPosWorld (_p1 vectorAdd (_p1 vectorFromTo _p2 vectorMultiply (_LowSpeed*diag_deltaTime)));
}, [player, _BossMech]] call BIS_fnc_addStackedEventHandler
proud carbon
#

ok

#

this will work in MP yeah?

little raptor
#

yes, if you execute it locally

proud carbon
#

ok. what kind of effect that would have if say I have 20 players on?

#

and would it sync?

little raptor
little raptor
proud carbon
little raptor
#

except network traffic

proud carbon
#

lol, the script is making me surf.

torpid quartz
#

I'm creating a sector control King of the Hill game that counts up, not down (since it ending the game on 0 tickets is breaking my dedicated server)

One element of the game mode is when you capture the point the enemy team loses 50 tickets. (there is only east and west)
||it's a dumb gamemode that's meant to go on for hours||

I want to run this on a sector's expression parameter but I'm lacking any examples for formatting and I'm not quite sure how I should lay it out.

if (_this #2 == west && [west,0] call BIS_fnc_respawnTickets >= 51) //if the previous owner was west, and they have more than 51 tickets
{
[west, -50] call BIS_fnc_respawnTickets; //remove 50 tickets from west
};
if else (_this #2 == east && [east,0] call BIS_fnc_respawnTickets >= 51) //if the previous owner was west, and they have more than 51 tickets
{
[east, -50] call BIS_fnc_respawnTickets; //remove 50 tickets from east
};
else
{
// I'm not quite sure if I need to put anything here if I want nothing to happen
};
little raptor
#

what on earth is that? nootlikethis

torpid quartz
#

i know haha

cosmic lichen
#
if (_this #2 == west && {[west, 0] call BIS_fnc_respawnTickets > 50}) exitWith //if the previous owner was west, and they have more than 51 tickets
{
    [west, -50] call BIS_fnc_respawnTickets; //remove 50 tickets from west
};

if else (_this #2 == east && {[east, 0] call BIS_fnc_respawnTickets > 50}) exitWith //if the previous owner was west, and they have more than 51 tickets
{
    [east, -50] call BIS_fnc_respawnTickets; //remove 50 tickets from east
};
proud carbon
torpid quartz
# cosmic lichen ```sqf if (_this #2 == west && {[west, 0] call BIS_fnc_respawnTickets > 50}) exi...

throwing me a missing ";"

just deleted you comments and put the code in incase it tried to read them, this is a copy paste of what's in the expression field. I'll be real it doesn't look like it is missing any hmmmm

if (_this #2 == west && {[west, 0] call BIS_fnc_respawnTickets > 50}) exitWith 
{
    [west, -50] call BIS_fnc_respawnTickets; 
};

if else (_this #2 == east && {[east, 0] call BIS_fnc_respawnTickets > 50}) exitWith 
{
    [east, -50] call BIS_fnc_respawnTickets; 
};
winter rose
#

dafuq @cosmic lichen 😄 ☕
edit: ah, was not your own code to begin with 😄

#
if (...) then
{
  ...
}
else
{
  ...
};
```@torpid quartz
torpid quartz
#

giving it a try now

#

ok works with just the else statement, however it doesn't have the safety net then of the check to make sure the other team has at least 50 tickets before it takes them away. (also i now see i have it checking the wrong side when it's doing the ticket check lol) wait no i didn't lol

So i do need to do an else if check still.

#

i'll just add another "else" after the else if with nothing in it and see if that's good one moment

torpid quartz
#

aw it didn't work lol

winter rose
#
if (_this select 2 == west && { [west, 0] call BIS_fnc_respawnTickets > 50 }) exitWith 
{
    [west, -50] call BIS_fnc_respawnTickets; 
};

if (_this select 2 == east && { [east, 0] call BIS_fnc_respawnTickets > 50 }) exitWith 
{
    [east, -50] call BIS_fnc_respawnTickets; 
};
#

(the pound sign # is greying out Discord's syntax highlighting btw)

little raptor
winter rose
torpid quartz
wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
cosmic lichen
#

Good thing you solved it @winter rose 😄

proud carbon
#

Hey how do I get a thing to look directly at another thing?

little raptor
#

if you mean "face" another thing

vague geode
low sierra
#

There is a alternative for inGameUISetEventHandler?

#

Good day!

little raptor
#

okthnxbai! 👋

winter rose
#

but now we will never know what the alternative is

#

gone with his secret

little raptor