#arma3_scripting

1 messages · Page 156 of 1

indigo snow
#

Yes the frame might freeze for very long if your code isnt optimized to finish in a single frame

#

E.g. calling 600 functions

bold comet
#

or createUnit / createVehicle which is the slowest thing i've had to deal with

lone glade
#

Those are instant for me

indigo snow
#

Relatively seen alganthe

lone glade
#

oh yeah.

indigo snow
#

Then again in a lot of cases you wont run against the 3ms limit in scheduled, and there is no absolute need to stay in unscheduled space

#

Most larger projects prefer to though

bold comet
#

i see stuff i could convert to pfh (custom, not cba) but some other that really has to stay in scheduled mode

lone glade
#

you forgot a un*

indigo snow
#

Phone, thanks

#

Zbug in the end it really comes down to code design, and the priority of it running completely faultless

bold comet
#

actually anything that has a mandatory sleep in it

lone glade
#

nope

#

shall I introduce you to the wonders of waitAndExecute ?

bold comet
#

as long as it's not cba

indigo snow
#

Add a PFEH that removes itself when it runs

lone glade
#

sleep is also unprecise waitAndExecute is 100% precise

indigo snow
#

Essentially

bold comet
#

it's not about precision i really don't mind that

lone glade
#

it's an ACE3 function based on PFHs, but it can be converted to vanilla, which I did.

bold comet
#

ok

indigo snow
#

I'd still argue that for a lot if things the difference between scheduled and unscheduled does not meaningfully matter. As long as youre aware of the differences when you do run into stuff.

bold comet
#

well nothing on google for this one

#

yeah i see what you mean

#

that may explain the few "name unit : unit is dead" logs i find

#

may come from scheduled scripts with an alive condition

#

makes sense

indigo snow
#

Yea exactly

bold comet
#

but if i'm going to scan 150 places on the map in a 200 meters radius, or spawn 50 units, i'd rather use some sleeps so the machine doesn't choke

#

and that means scheduled basically

lone glade
#

The most fucking annoying RPT error I get now is unit _x has too many magazines

indigo snow
#

Or spawn 50 units in batches

bold comet
#

yep :p

indigo snow
#

5 times 10

bold comet
#

still

indigo snow
#

Remove after 5 batches

#

Yea i get it

lone glade
#

it doesn't freeze, it'll just reduce the framerate

indigo snow
#

More convuloted

bold comet
#

it will absolutely destroy the framerate

#

even on the clients actually

grim cliff
#

does anyone know how the command menu works, or how it uses the values passed to it through the global variables

blissful current
#

I noticed when messing around in zeus that you can change the AI spotting skill and speed. Can you do this in the editor as well? If so will the server AI settings overwrite the individual AI adjustments?

hallow mortar
blissful current
#

I found these in edenenhaced. If I change these will the be overidden by the server AI settings (ex: SKILL and PRECISION)

hallow mortar
#

I'm not sure exactly on the order of precedence for CfgAISkill vs Editor setSkill during mission initialisation, but any skill changes after mission start will definitely override the server. (as long as they're executed where the AI is local, of course, because it's an LA command)

blissful current
hallow mortar
#

https://community.bistudio.com/wiki/Multiplayer_Scripting#Locality
AI, and most objects, exist globally and are synced, but one machine (usually the server, but not always - group leader takes ownership for AI, driver takes ownership for vehicles, etc) is their actual owner. That's the machine where the thing is local. A Local Argument command is one that must be executed on the machine where its target is local, in order for it to take effect.

#

setSkill is also a Global Effect command, which means all machines will receive the changes it makes. However, even if it was a Local Effect command, that wouldn't necessarily be a problem unless the AI changed ownership. Their actions are controlled by the machine where they're local, so even if other machines thought their skill should be different, it wouldn't matter - those other machines aren't in charge of what the AI are doing.

granite sky
blissful current
blissful current
hallow mortar
# blissful current Okay so in my case I'm speaking of an enemy AI thats is patrolling around. My mi...

If they were placed in the Editor, or created by a script running on the server, and not in a player's group, they'll be local to the server. initServer.sqf would be an appropriate place for the command. Their Editor attributes will work too, though using a script is a convenient way to bulk-apply stuff without duplicating code or making the mission.sqm massive by giving everything custom attributes.

blissful current
#

Tyvm Nikko! I think I understand.

bold comet
#

the only real performance issue i have to deal with at the moment is the way arma doesn't seem to like a large number of AIs (200+) even if they're not in visual range

#

even with headless clients

#

the client performance quickly becomes crap

#

so i've been drastically limiting the number of ais the mission can spawn at a given time but if you have any idea on how to make it playable with more ais i'm interested

indigo snow
#

Cache them, or only spawn then when player gets close

bold comet
#

this is exactly what i've been doing

#

and it works great if all the players are together

#

but if player 1 and player 2 are 10 km apart and each makes their own ai spawn

#

it will lower the performance of the other client who's 10 km away

indigo snow
#

If you wanna be cheeky you could spawn ai on player clients

bold comet
#

with createVehicleLocal ?

indigo snow
#

No

bold comet
#

nah not for AI

#

what do you mean ?

indigo snow
#

Same as you would on server

bold comet
#

but wouldn't it make clients performance actually worse ?

indigo snow
#

Use player client as ghetto headless

bold comet
#

because server and HC performance is awesome

harsh bloom
#

Has anyone a good way of having an object spawn but despawn if a specific team is near by?

TLDR i'm trying to make the rallies from squad, where your personal squad can spawn on them, but if the enemy comes by it despawns.

indigo snow
#

Yes thats why it was cheeky

tough abyss
#

you should avoid createvehiclelocal its messed up logic

harsh bloom
#

Maybe there is a mod already for this but i don't see one.

bold comet
#

i use it exactly for what it was meant for :p

#

with stuff that has no colision no physics or anything

tough abyss
#

certain objects are transferred to the server when the client d/c, but the object is local to the server only

indigo snow
#

Another one is disabling that one option

tough abyss
#

so if you got multiple createvehiclelocal per client, server performance gets worse the more clients you have that d/c.

thin fox
#

Is there a way to make an AI drone use it's laser to target a enemy?

indigo snow
#

Where AI checks for visibilty are conducted on all clients

bold comet
#

how would you do that ?

#

@tough abyss you're run but the way i use it, even if the client d/cs right when they have local objects, it won't cause an issue

#

you're right*

tough abyss
#

Its engine/design issue, the local client object is transfered to the server. I think AI units aren't effected, but objects are

#

Anyway just a heads up

bold comet
#

yep yep

#

the objects in question are the tutorial spheres

little raptor
#

That's what happens behind the scenes anyway

bold comet
#

so even if they get local to the server that's not an issue

#

i just want them to be invisible to other clients

#

anyways

#

@indigo snow "Another one is disabling that one option Where AI checks for visibilty are conducted on all clients"

#

you got my curiosity here

#

can't leave me hanging too long

thin fox
indigo snow
#

Im looking it up

bold comet
#

ok 😃

indigo snow
#

Hold on phone

bold comet
#

no worries

bold comet
#

but wouldn't it help with cpu usage only where the AI is local ?

#

cause that means the server, and the server really has no issue

indigo snow
#

Opposite

bold comet
#

oh

indigo snow
#

All clients raycast all units

#

This only raycasts local ones

bold comet
#

so you could do that on all players

#

get some performance improvement

#

but players wouldn't spot AIs anymore

indigo snow
#

Might have unintended side effects with certain scripts/mods

#

They would

bold comet
#

so what exactly gets lost with it

indigo snow
#

player knowsAbout someAI

bold comet
#

spotting rely on knowAbout though doesn't it, like if knowsAbout gets above a certain value, unit is spotted and can be targeted

indigo snow
#

Does not influence actual graphics drawing

bold comet
#

for example let's say i'm a client and i have a few AI soldiers in my group, would that make them super dumb ?

#

i mean, dumber than they already are by default

indigo snow
#

I do not have any testing information ready for that

#

Find out haha

bold comet
#

😄

#

ok

#

can't really test in solo cause everything is local

#

but i'll have a test release on the server to try it

indigo snow
#

Set up a dedi on your pc

bold comet
#

see what exactly changes and especially if fps get better with a lot of ai

#

hmmm yeah

#

i could do that indeed

#

i already have a remote server though, might be more accurate to see if fps are better or not

#

better, i'll put that in the main branch, linked to a mission parameter

#

so anyone who wants can test it

runic surge
#

I need a way to retrieve the classname of the respawn loadout a player chose.

The respawn loadouts are generated dynamically on mission start like so:

{
    [west, [_x]] call BIS_fnc_addRespawnInventory;
} forEach blufor_squad;

{
    [east, [_x]] call BIS_fnc_addRespawnInventory;
} forEach opfor_squad;

blufor_squad and opfor_squad are just arrays containing all the unit classnames to make respawn inventories from. The player classname is always "survivor" but he can choose any loadout on mission start and then any time he respawns afterword. It is a multiplayer map

#

I am trying to get my mission that has never had any issues handling loadouts to work with 3CB faction's asinine custom config system which breaks compatibility with every existing script that handles unit spawning and inventory management. I figured it out for setting up the arsenal (which should contain only items from the selected classes) by creating a function to handle the custom config parameters and reformat them

#

If I can get the classname that corresponds to the chosen respawn loadout I can make an event handler that retrieves that same data and adds it to the player after spawning

#

but I can't find a way to do it. Role and display name aren't enough since multiple classes can have the same roles and display names.

bold comet
#

if it breaks local AI i could have it work only for clients who have no AI in local (the majority of them)

fair drum
runic surge
#

one of these returns the classname/vehicle?

#

I found a thread that uses those to return role or display name

#

but I need the classname so I can retrieve the loadout items from that class's config

fair drum
#

You can grab the display name, then do a config compare to grab the associated loadout

runic surge
#

Nah, that won't work

#

multiple classes can have the same display name

#

I checked and it does the same in the inventory lists

#

same for role. units can have the same combination of both

fair drum
#

okay, so you know you can add custom attributes/properties to the config entries right? so add say, a index number that you intend to have them added. then compare that with the index selected

runic surge
#

Custom attributes to the respawn inventories?

#

If you manually define them sure but how do I do that dynamically?

fair drum
#

are you not using the config class for the respawn inventories?

runic surge
#

I need my system to work entirely off a list of classnames so I can use custom factions dynamically

fair drum
#

that is adding them dynamically, not generating them. They are still defined in the config if you are using BIS respawn menu

#

so let me go back to thinking for a sec

#

what is in your mission config file

runic surge
#

what part of it

fair drum
#

class CfgRespawnInventory

runic surge
#

nothing

fair drum
#

the loadouts for that respawn menu are defined in CfgRespawnInventory.

runic surge
#

not via BIS_fnc_addRespawnInventory

fair drum
#

your current script does nothing. as that function doesn't take an array of item classnames

runic surge
#

It literally does

#

it works for me

#

BIS_fnc_addRespawnInventory can take an object and create a respawn loadout from it

#

CfgRespawnInventory isn't in my description.ext anywhere

indigo snow
#

Which you could check with a PFEH ;)

#

Nice little segue back there haha

bold comet
#

;p

fair drum
#

looks like I need to add that to the wiki page. as the wiki page only states for inventory params a string (CfgRespawnInventory class), or an array of strings or numbers, but it does appear to search in CfgVehicles within the function itself.

runic surge
#

I am certain that's how I figured it out

#

Maybe it isn't. I created this mission a very long time ago when I was much less proficient and I wouldn't have figured it out on my own then

fair drum
#

testing something

bold comet
#

you know, i'd be glad with anyone reviewing my code, if you want to stop the sass and walk the walk instead ;))

fair drum
#

ok, so BIS_fnc_getRespawnInventories will return the array of inventory class names as strings in the order in which they were added. You can then do a comparison check to the index of the selected, treating it as the getter in that array.

_inventories select _selected

how you get _selected is up to you. either with UI event handler, or ui command checking with the 3 controls I posted above

runic surge
#

my entire issue is how to get _selected

#

the classname isn't stored in the loadout so I can't retrieve it that way

#

actually wait I might have misunderstood

fair drum
#

you can add an event handler to the ui control via https://community.bistudio.com/wiki/User_Interface_Event_Handlers#Listbox_Events or lbCurSel to get the _selected index along with one of these (not sure which one atm - probably combo loadout - you might have to dig a little deeper into that control with how it does its selection):

BIS_RscRespawnControlsMap_ctrlLocList
BIS_RscRespawnControlsMap_ctrlRoleList
BIS_RscRespawnControlsMap_ctrlComboLoadout

you can then use BIS_fnc_getRespawnInventories to get the array of loadout classes that you added (which should be CfgVehicle classes)

then you use _selected to get that position in the array and return that class (since it will be in order) which now you have the CfgVehicle class name. Then you can use getUnitLoadout/setUnitLoadout or whatever else you want to do

runic surge
#

looks like that's just the display name again

#

but you mean I can get the index from that and select the list of classes and they should correspond?

fair drum
#

_selected should be a number if you use lbCurSel on the event handler or command

#

that number, corrisponds to the array position of your class you added, which is found in BIS_fnc_getRespawnInventories

#

also, updated the wiki page to include CfgVehicles soldier classes for BIS_fnc_addRespawnInventory

runic surge
#
_respawnCombo = uiNamespace getVariable (["BIS_RscRespawnControlsMap_ctrlComboLoadout", "BIS_RscRespawnControlsSpectate_ctrlComboLoadout"] select (uiNamespace getVariable ["BIS_RscRespawnControlsSpectate_shown", false])); 
_respawnTemplateDisplayName = _respawnCombo lbText (lbCurSel _respawnCombo); systemChat str _respawnTemplateDisplayName

This is what I was using. Found it on the forum earlier but don't understand how it works

#

but it does use lbCurSel to select so I think I'm almost there

fair drum
#

yeah just grab the lbCurSel, remove the stuff about lbText. we don't want the text, just the selection index number

#

should just be private _selected = lbCurSel _respawnCombo

runic surge
#

it always returns 0

fair drum
#

no matter which inventory you select?

runic surge
#

Yeah. After spawning

#

if it only works in the menu I can't test that without the debug menu so I guess I need to try making it a variable for the player?

fair drum
#

how many items do you have in the drop down menu? or do you have a single thing in the drop down menu, but many roles?

runic surge
#

multiple items in both dropdowns

#

sometimes just one in the left and several in the right

#

depends on how the unit is configured

fair drum
#

well there goes that idea

runic surge
#

Wait that means this won't work

#

unless I sort the class names into a new nested array separated by their class?

#

that wouldn't preserve the order though

fair drum
#

give me a sec

runic surge
#

I can't really make any sense of the addrespawninventory function. Is it possible to set a custom display name through it? It doesn't look like it but I can't tell for sure tbh

fair drum
#

i have a working answer, standby, i have to write it

runic surge
#

oh

#

exciting

fair drum
#

do you use CBA

#

eh I'll just make it scheduled, it shouldn't need to be frame specific

#

@runic surge https://pastebin.com/Gu7R73cQ

it works (this is a testing example, you'll have to change the inventories at the bottom), but that's it. its not optimized or refactored. just the "get it working stage". but I gotta hit the sack for the night

runic surge
#

Thank you for all your help

runic surge
#

you're a legend for doing all that

fair drum
#

you might have to change it up a little bit on a new respawn, but at least its a proof of concept. can't remember if ctrl event handlers stay after the control is closed.

runic surge
#

I executed it in my current session via debug menu and then respawned and it worked. I am going to be doing a lot of testing and if possible making tweaks where necessary

runic surge
#

It seems to be getting parent classes-- it works for vanilla nato but the 3cb faction I am testing with shows vanilla units and rhs units they inherit from. I will investigate further

#

oh this just uses the display name

meager granite
#

I wonder if if CODE could be a thing?

For example, right now:

if(player getVariable "var" get "key" > 100) then {
    123;
} else {
    321;
};
``` => `nil`
But what if you could do
```sqf
if{player getVariable "var" get "key" > 100} then {
    123;
} else {
    321;
};
```=> `321`, which would act as `false` if code returns `nil` ?
#

Also suppress the errors similar to isNil

#

Yes I know it could be done with ENTITY getVariable ARRAY and getOrDefault*, I just wonder if there could be if that treats nil as false

#

Another way to solve this btw:

call {
    if(player getVariable "var" get "key" > 100) exitWith {
        123;
    };
    321;
};
meager granite
#

Is there a quicker way to do agents apply {agent _x} ?

#

Basically allUnits but for agents? 🤔

winter rose
#

allAgents

warm hedge
#

I never understood what agent is. Who/how does one even use Team Member or whatever its called?

winter rose
#

Team & Team Member were introduced with Arma 2 and were never really used
agents however, are "simple AIs" so you can place plenty of them without hogging the CPU (too much)

warm hedge
#

Well agents returns Team Members, for no reason

tired spear
#
_WBK_Combinus = ['WBK_Combine_CP_SMG',1,'',0];
[Zeus] call BIS_fnc_curatorObjectRegisteredTable; 

I wanted to set the cost of the unit after following the curator wiki but this removes all objects from zeus. I'm not sure why

winter rose
#

the first line has nothing to do with the second one

tired spear
#

damn I'm still learning I apologize XD

winter rose
#

no problem at all! Speak freely my son 😄

tired spear
#

In that case, what would apply the first line?

winter rose
#
private _list = ['WBK_Combine_CP_SMG', 1, 'B_Soldier_F', 42];
[Zeus, _list] call BIS_fnc_curatorObjectRegisteredTable; 
tired spear
#

Holy moly thank you I've been trying to do this for 2 days XD its 3 am and I'm supposed to wake up tomorrow for the real army lmao

#

now I just have to make positive numbers negative and I never have to think about it again

#

thanks again I suppose

meager granite
#

Wish BI could just release design doc on agents or something, maybe there is a good reason for them

#

I guess the general reason is simplier AI simulation, but tasks and teams could've been just scripts

meager granite
#

Used targetKnowledge command return, still not the same as what engine does 🤔

#

Now it started drawing the line right to the followed unit 🤔

fair drum
tulip ridge
#

Just check the scope

graceful spruce
#

What language is this

opal zephyr
#

sqf

graceful spruce
#

Fuck knows what that is

winter rose
blissful current
#

Which of these are effected by the server/difficultly settings AI Skill and AI Precision? Im guessing that the ones that having aiming in the name are adjusted by AI Precision and the rest are AI Skill?

winter rose
tribal crane
#

Sleep in unscheduled dies when you've already screwed the pooch and are hammering the script engine. If you have to work around that you've already failed.

graceful spruce
hallow mortar
tribal crane
#

You shouldn't be putting exhaustive searching and crap like that in the PFH because it blocks the entire main thread.

bold comet
#

sleep even works in unscheduled ? thought it didn't

tribal crane
#

Scheduled I mean.

bold comet
#

ha

graceful spruce
#

I’m not learning it but thanks

bold comet
#

i find that the sleep duration only gets unreliable when the engine has a lot of stuff to do like a large batch of createUnits, so that's actually fine by me if the sleeps start getting longer and stuff gets executed later

#

the variables getting changed during the loop is a much bigger problem, potentialy

half zephyr
#

LOL

crude barn
#

Probably a very stupid question, but does anyone know if its possible to set up a headless client on LAN? Normally I would use a dedicated server, but one of the mod I’m using for my mission isn’t really dedicated server compatible and its kind of a pain to make it fully compatible with my mission.

tribal crane
#

Which variables?

fair drum
bold comet
#

anything that's not private to the scope, conditions like "alive unit", etc

#

a unit can be alive and dead in a single while loop

#

it can't be alive and dead in a single frame

graceful spruce
#

Huh

#

No I wanted to see if it’s a language I already know

warm hedge
queen cargo
#

just means you have to write your code with expecting that ..

#

no problem which comes out of it

crude barn
# warm hedge Even though this ain't a <#105462984087728128> topic but how it is not Dedicated...

I’m using johnnyboy’s SOG AI mod, another member of this server helped me out with making it mostly dedicated server compatible, but for the most part its still kinda unstable and I’d rather just use it on LAN. But the problem with that is that ALiVE missions perform much better on dedicated servers and I’m unsure if I can get the same kind of performance that I get with a dedicated server on a LAN.

bold comet
#

exactly

crude barn
#

Ideally I want to use a headless client to offload a lot of the AI calculations (+ ALiVE’s back-end stuff if possible)

tribal crane
#

Yeah, the code he posted was just updating arrays with game state. Nothing that needed to be atomic.

bold comet
#

i've been using while loops a bit carelessly, some could be replaced with pfhs

#

but i'm against that idea that all loops suck no matter what

indigo snow
#

They do suck, but sometimes it doesnt matter that they suck since its trivial

bold comet
#

things that take longer than a frame, can't be altered by external events, for example

lone glade
#

I didn't said all loops sucks, I use foreach, for forspec, and count myself.

red bluff
#

does anyone have a script to put into an object in order to spawn a civilian character? trying to impliment some automation in my units training server and our medical team needs a patient spawner. ive looked online but i can find anything that i can make work

tulip ridge
#

createUnit and then the type of unit to spawn

red bluff
#

would i enter the class name of the character i want to spawn then?

tulip ridge
#

Yes

#

Just note that an object's init field runs once per player

red bluff
#

ah. thats interesting

tulip ridge
#

You probably want to use something like an initServer.sqf script, which runs once on the server's end

red bluff
#

above my head bro

#

im a knuckle dragger

tulip ridge
#

You make a file called initServer.sqf in your mission folder

indigo snow
#

Cheeky

lone glade
#

actually for var too in loadouts

bold comet
#

while { count < x } do { } ?

#

:p

lone glade
#

cmon

hollow plaza
#

I'm consistently running into issues where AI units will have their pathing be re-enabled on a dedicated server even when it is disabled through their attributes, are there any known causes for this and would my only work-around be running a script to disable it after X amount of time through the server?

LAMBS is loaded (although completely disabled for the mission) and while I suspect it is the cause, pathing isn't always re-enabled even with it on and IIRC sometimes it happened even though I didn't have LAMBS at all.

granite sky
#

I'm fairly sure there's nothing in vanilla Arma that will re-enable PATH after you turned it off. If there is, you should try to replicate the issue.

granite sky
#

I mean without you doing that.

wind hedge
#

There are some mods on the workshop that try to "unstuck" ai units by re-enabling features on a loop for all ai units... but in vanilla nothing should re enabled them without a script doing so on a sleep or something

runic surge
#

still much closer than before though

tulip ridge
#

Just check the scope

runic surge
#

what?

tulip ridge
#

Just check the scope of the class as well. Parent / base / whatever you want to call it will usually have a scope of 0 or 1, since then they're not directly usable

#
_displayName == getText (_x >> "displayName" and { getNumber (_x >> "scope") >= 2 }
runic surge
#

Nah the parent classes are standard units as well

#

the mod inherits from them

#

displayName isn't valid anyway since multiple classes can have the same display name, even in the same mod

tulip ridge
#

Yeah I don't really know why you're using displayName anyway

runic surge
#

wasn't my idea

#

Back to square one. My next idea was to create a modified version of BIS_fnc_addRespawnInventory to parse the custom config values.

I can't exactly see how this function parses the config though. I don't see where it retrieves the weapons[] and magazines[] config values

granite sky
#

addRespawnInventory doesn't parse config values. It just stores a reference to a config class.

runic surge
#

so where does the config parsing happen?

granite sky
#

I don't know. Might actually be engine.

#

Oddly enough the config for this stuff seems to be undocumented, although it's superficially straightforward.

#

spawn equipment for units is contained in linkedItems[], items[], magazines[] and weapons[]. Respawn versions exist of each, starting with respawn.

runic surge
#

I know that

#

there is documentation for that

granite sky
#

Where? :P

runic surge
#

and the tutorial for configuring units as well

granite sky
#

No linkedItems in the CfgVehicles one.

#

whatever, what's the problem then?

runic surge
#

anyway that doesn't matter because it doesn't help me parse the necessary config parameters

#

3cb faction mod deliberately has improperly configured unit inventories. This breaks functionality for anything that need to retrieve that info

#

I need to retrieve their custom parameters and parse it

#

specifically for the respawn system (not using preconfigured loadouts)

granite sky
#

Isn't the issue that 3CBF runs an init function on unit creation that changes the loadout?

runic surge
#

The units are improperly configured so they can use their custom init function for randomization

#

it breaks more often than it works

#

it's bad design but I'm trying to work around it

granite sky
#

Aren't you saying that the data you're looking for doesn't exist?

runic surge
#

it's stored in custom config parameters

#

different syntax, but the data is there. their function retrieves it from there

#

but that means the respawn system doesn't know where to retrieve inventory info

#

among many other issues

granite sky
#

And are you trying to fix this with or without writing config?

runic surge
#

I am trying to make their mod work with a mission that uses the respawn system via scripting

#

patching the mod would be obnoxious and it seems they don't want people doing that anyway. The pbos are obfuscated

tulip ridge
#

You don't need to look at the pbos, you can modify a class without ever touching the pbo it's from

runic surge
#

I know but a full config dump is much harder to work with

tulip ridge
#

Just use the config viewer, see what the unit inherits from, and change it's items

runic surge
#

and a patch wouldn't handle updates or changes

tulip ridge
#

You can also just remove their init script

runic surge
#

3cb has hundreds of units

#

without their init script units spawn without ammo

tulip ridge
#

Do they change linkedItems in every class

runic surge
#

linkedItems is fine

#

magazines is the issue

granite sky
#

If you want to read their code, you can put the function name into the debug console and paste the output somewhere, like this:
copyToClipboard str UK3CB_FACTIONS_COMMON_fnc_init_EH

#

No indentation but otherwise quite readable.

tulip ridge
#

Then just modify the base class(es), and add magazines yourself

#

*if you want to go that route

runic surge
#
weapons[]                             = {"UK3CB_QBZ95_hamr","hgun_Rook40_F","Throw","Put","Binocular"};
linkedItems[]                         = {"ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS","UK3CB_CSAT_G_O_H_6b27m","UK3CB_CSAT_G_O_V_Carrier_Rig_Light"};
magazines[]                           = {"UK3CB_DBP88_30rnd_580x42_G","16Rnd_9x21_Mag"};
respawnLinkedItems[]                  = {"ItemMap","ItemCompass","ItemWatch","ItemRadio","ItemGPS","UK3CB_CSAT_G_O_H_6b27m","UK3CB_CSAT_G_O_V_Carrier_Rig_Light"};
respawnMagazines[]                    = {"UK3CB_DBP88_30rnd_580x42_G","16Rnd_9x21_Mag"};
respawnWeapons[]                      = {"UK3CB_QBZ95_hamr","hgun_Rook40_F","Throw","Put","Binocular"};
UK3CB_allowedbackpack[]               = {"UK3CB_CSAT_G_O_B_ASS","UK3CB_CSAT_O_B_TACPACK_OLI"};

UK3CB_allowedfacewear[]               = {"UK3CB_G_Neck_Shemag","UK3CB_G_Tactical_Black_Shemagh_White_Headset","UK3CB_G_Neck_Shemag_KLR_GRN"};
UK3CB_allowedheadgear[]               = {"UK3CB_CSAT_G_O_H_6b27m","UK3CB_CSAT_G_O_H_6b27m_ESS"};

UK3CB_loadout_magazines[]             = {["SmokeShellOrange",1],["SmokeShell",1],["rhs_mag_rgd5",2],["16Rnd_9x21_Mag",1],["UK3CB_DBP88_30rnd_580x42_G",4]};
UK3CB_loadout_magazines_backpack[]    = {["UK3CB_DBP88_30rnd_580x42_G",4],["16Rnd_9x21_Mag",1]};

this is how they format it

granite sky
#

Apparently it looks for a bunch of flags on a logic object:
entities "UK3CB_Factions_Loadout"

runic surge
#

I know how it works

#

that's not the problem

#

the problem is manually reparsing all of this into standard inventory configuration

#

I am not interested in wasting that much time. I want to make it work mission side anyway, no extra mods necessary

#

parsing the config into arrays that match the standard is trivial but I can't get it to work with the BIS respawn functions since they don't look for the custom parameters and parsing apparently happens in the engine somewhere

granite sky
#

So you've already reparsed this stuff and added it to CfgRespawnInventories?

runic surge
#

fixing the mags is as trivial as

_fnc_flattenArray = {
    params ["_nestedArray"];

    private _fixedArray = [];
    
    // Loop through each sub-array and extract the first element
    {
        _fixedArray pushBack (_x select 0);
    } forEach _nestedArray;
    
    _fixedArray
};
runic surge
#

you can't do it dynamically

#

that's for custom loadouts.

#

you use the add inventory function with a classname to do it from a unit class

granite sky
#

So what are you trying to do again? :P

#

Respawn an AI class and have it with a sensible loadout?

runic surge
#

add a set of unit classes to the respawn loadouts on mission start (based on the selected faction in the lobby)

granite sky
#

Probably impossible unless you replace the respawn system?

#

It looks like it only uses config.

runic surge
#

factions are just an array of classnames. this is intentional design. It needs to be no more complex than that. I already solved adding stuff to the arsenal.

#

yes that's the problem

granite sky
#

Well, unless you pre-prep every loadout in config and then select them appropriately.

runic surge
#

that doesn't fit the system

#

you add factions by adding a list of classnames, and that's it

#

that's the point

placid spear
#

I have a script that I usually drop into the init of vehicles as zues, but now I'm trying to make it a standalone mod. tl;dr is its a script that adds variable time fuzes to artillery/mortars. Having a hard time figuring out where to do it.

granite sky
#

All artillery and mortars, or specific classes?

placid spear
#

For now specific classes. I'm using the m109a6 from RHSUSAF for testing

#

In the past I've made a compat mod for ITC to add additional ITC land system rounds to their m109a6, but that was almost completely copy/pasting from their other vehicles

granite sky
#

Your two options are probably an init event handler added to the vehicle classes (massive pain in the arse) or a pre/post-EntityCreated mission event handler.

placid spear
#

Yeah, been trying to do it via vehicle classes, and have been failing miserably

granite sky
#

latter is also pretty nasty because it fires on every entity, right down to butterflies.

#

vehicle classes one is more of a config inheritance problem.

#

Because you need to retain the event handlers that are already defined on the vehicle.

#

plus loading your config only after the vehicle config you're changing has been loaded.

placid spear
#

It's frustrating, because I finally got the script to be play nice in multiplayer as a drop in script, I just need it to init in a mod, dammit XD

#

I don't think I'm stomping on any existing event handlers, at least not on the m109a6

granite sky
#

First thing to do is get a simple mod with a CfgFunctions working, so that you can at least call your function in debug console or wherever.

#

Only do the event handlers once you have the function working.

#

Very non-trivial due to how file paths work in a mod.

placid spear
tulip ridge
#

You can just use a CBA extended event handler and not have to worry about vehicle config at all

granite sky
#

I'd bitch at this but honestly vehicle event handlers are so horrible that it's not a bad idea if you just want to get a mod working.

#

It's pretty similar to the EntityCreated option though.

tulip ridge
placid spear
#

Is vehicle event handlers more performance friendly? Rest of my communities I play with bitch and moan about performance from stuff like fires, so I have to justify anything I add

granite sky
#

When it works, yes.

placid spear
#

(But they won't complain when they use high poly count uniforms and kit, of course)

tulip ridge
#

Adding the event handler itself is not going to cost much, it'd be the code that runs that would cause a difference.

#

You could go two ways with the EH route, add it to all vehicles and filter them in the function, or add it to specific classes

granite sky
#

Well, ideally CBA works with vehicle event handlers underneath, although it depends how busted your other mods are.

#

you'll get those "CBA XEH not defined for class XXXX" warnings in the RPT in that case.

#

And then it falls back to the slow mode which sucks.

tulip ridge
#

All xeh is just addEventHandler

granite sky
#

Nah, a lot of them use vehicle event handlers by preference.

placid spear
#

The things I do because they don't want to use ITC

tulip ridge
placid spear
#

I appreciate the pointers, guys

runic surge
#

would it be possible to create CfgRespawnInventories classes post init somehow?

fair drum
#

And no you can't do config stuff in post in it. The pre and post inits are for your script files and functions

#

We can probably throw examples of other ways to implement dynamic loadouts, but you might be the first in the manner that you want to do

runic surge
#

I'm trying to implement 3cb factions into an existing and totally functional mission that works with every other dlc and mod

#

the point is to get it working with existing stuff to compensate for the poor mod design

granite sky
#

I'd have thought your best bet was to let the BI respawn stuff do what it likes, and then replace the loadout yourself afterwards with a delay from the respawn event.

plush jolt
#

ok im brand new to SQF and arma scripting, though not to scripting/development in general

and im going maybe a bit insane trying to find what i think should be a simple thing, just all the tutorials ive found seem to skip over or assume pre-existing knowledge lol

im trying to apply the Global Mob boltcutter action to an object that doesnt have it by default

following the docs here: https://community.bistudio.com/wiki/Global_Mobilization_Boltcutter

got the action added fine, but then to set the specific boltcutter action i need to set a "config parameter" gm_boltcutAction and i cannot for the life of me figure out how to do that properly

any help, even if its just pointing me at a more complete tutorial would be great

runic surge
#

how do you propose I do that?

tulip ridge
#

Just add a small delay to make sure it runs after the vanilla respawn stuff

runic surge
#

there's no way to know the classname that corresponds to the loadout chosen by the player

tulip ridge
#

That's up to you

runic surge
#

That's why I'm here

#

because I don't have a solution for that part specifically

tulip ridge
#

I don't mean the logic portion, but what should they be wearing

You could save their loadout after init

runic surge
#

what?

#

what they should be wearing is what the class wears by default, which happens after init, which happens after new respawn classes can be added. Getting the loadout after init would only work IF it was possible to retrieve the classname for the loadout chosen by the player

#

which doesn't appear to be possible at all

#

the array returned by BIS_fnc_getRespawnInventories lists the classnames used, which would imply that that is the name of the loadout, but the name of the loadout used by the player isn't stored on the player anywhere

#

and custom display/role names in the menu aren't possible either

warm hedge
granite sky
#

@runic surge The function that actually does the inventory fill is BIS_fnc_respawnMenuInventory, but there are no events to hook there, and the selected loadout isn't stored. You'd need to either replace that function with your own (modified) version or hook the UI controls.

granite sky
runic surge
granite sky
#

ugh :p

runic surge
#

UI stuff is the one thing I don't understand about arma stuff

#

it's a complete mystery to me

fair drum
#

Making an event handler for the control

#

I'm putting this convo in a thread for you.

runic surge
#

oh

fair drum
#

I need a way to retrieve the classname

runic surge
#

so that already didn't work out

last cave
#

blobcloseenjoy hmmyes meowheart meowawww
Now you don't have to intercept the treatment action "inGameUISetEventHandler ["Action",""];" to execute your own code for full right treatment.

meager granite
last cave
#

wait 2.18 for check or mb in dev this work

placid spear
#

@granite sky Thanks again for the assist. Got the eventhandlers working without too much issue, even figured out the weirdness the original ace csw m224 mod did to slap it on there too

sharp torrent
#

Hey. How do I check if generated sqfc files using Arma script compiler work properly? And what patch they should have (if you open sqfc file, at the bottom there is a generated path to the normal sqf file)

granite sky
#

You mean whether Arma is using them?

#

Or whether the compiler works?

hushed tendon
#

I have a quick question about triggers. If I tick server only and have the trigger play music from the section at the bottom, when any player enters it would not play music for players cause it’s server only and I would have to remoteExec the music for players to hear it? And if I didn’t select the server only option when any player ran into the trigger it would play music locally for all players right except JIP?

#

Been scripting for so long yet locality still confuses the hell out of me

granite sky
#

This doesn't seem to be a question about event handlers :P

#

Triggers aren't sufficiently documented to answer your question, but I'd go with "probably yes".

#

In general, sound-playing commands are local effect.

hushed tendon
#

yes triggers

fair drum
#

if using server only with a locally executed command, you must remoteexec it. If not selected, you don't as the trigger exists locally on each client (including JIP).

hallow mortar
#

Clarification: triggers actually use commands like playMusic to do the effects you can select in their attributes

opal zephyr
#

Does anyone know of a way of getting a models geometry mass value through sqf? like getMass but for just regular geo

hallow mortar
#

In 2.18, getModelInfo will have it

opal zephyr
#

When did BI say they were hoping to release that..?

hallow mortar
#

Pretty soon

opal zephyr
#

Hm ok, thanks

#

Ugh thats actually not very useful for me, I need to be able to tell from just the modelpath or config. Spawning the object isnt possible in my case

hallow mortar
tulip ridge
#

Unless you actually cannot spawn it (for whatever reason?)

opal zephyr
opal zephyr
granite sky
tulip ridge
#

Could also spread it out over multiple frames

granite sky
#

I'm assuming you have a lot of similar objects and you don't literally need the mass of 1000 different types.

opal zephyr
hallow mortar
granite sky
#

Uh, you don't want the model mass for those normally.

#

just the item mass, which you can read from config.

hallow mortar
#

I'm pretty sure there are CfgWeapons and CfgMagazine classes that don't even have models

#

Vehicle weapons mostly, but also throw, put, etc and magazines from before proxies

opal zephyr
#

Ill run a test now to see what the count is and if its feasible

granite sky
#

Maybe don't write this code until 2.18 :P

opal zephyr
#

The code would be the same though no? I'm already using the portion of getModelInfo which is for 2.18 only

#

Looks like vanilla + ace would be 271 objects spawned, not as bad as I thought

granite sky
#

So what are you doing with this information?

opal zephyr
#

Filtering items that the player can use for a dynamic loadout system

hallow mortar
#

Why's geo mass more important than inventory mass for that?

opal zephyr
#

The spawn item and use getModelInfo works as you said it would, I appreciate the ideas everyone!

tulip ridge
#

Why does collision matter for a loadout system?

opal zephyr
#

The items are very close to the player and collisions occur

raw vapor
#

So I got code that effectively locks an inventory out from all players, just in case there's an object I want for a prop, but I don't want players shoving stuff into it or taking stuff out.

 h = [] spawn {  
  waitUntil{ !isNull findDisplay 602 };  
  closeDialog 1;};  
}];
[this, false, [0, 1, 1], 0] call ace_dragging_fnc_setCarryable;```

But now what I _want_ to do is make it so, in multiplayer, when someone tries to open a box, it checks the user's steam ID to see if they own the box.

My intention is to make lockers that only certain players can access. What I'm struggling with is how to check the player.
Psuedo code:
```if (variable_for_the_person_trying_to_open_the_box steamID != whatever)
     waitUntil{ !isNull findDisplay 602 };  
     closeDialog 1;};
else
     just open the box normally```
#

Any thoughts that might help?

#

I'm gonna facedesk smilethonk

warm hedge
#

lockInventory is a relatively new command

raw vapor
#

Okay, so that simplifies the issue substantially. Let me fiddle with it a bit and see if I can figure it out myself before coming back for more help.

nocturne bluff
#

my fav is

#

10 while(_thing distance player < 5)

meager granite
#

If you want to do it with Init field in editor, do something like:

this spawn {waitUntil {getPlayerUID player != ""}; _this lockInventory !(getPlayerUID player in ["123", "321"]);};
#

This spawns a thread that waits until player is initialized so we can pull their UID, then locks the inventory if player is not of certain UID

#

Speaking of which, wish there was a command to get steam id without having to wait for player object, such a bad thing to pull system information bit from a gameplay entity which it should be available at all times.

#

GIB ARRAY = getSteamInfo

raw vapor
#

Hmmm. There is a problem with lockInventory.

I can bypass it because it's bugged.

#

The inventory isn't actually locked out, the "inventory" command is merely removed. I can exploit placing objects on the ground next to it.

meager granite
#

check if you're allowed access to both containers

tough abyss
#

I have 2 scripts in my mission, but I've found out that one of them are messing with my "player location" and according to the map I'm lower left corner all the time... is this something script related and how do I fix it?

stable dune
tough abyss
candid scroll
#

@granite sky thanks for catching my scope issue for the fired event, working properly now!

queen cargo
#

because that would not work in SQF @nocturne bluff ?

polar radish
#

i am using a script to add a teleport action to an object

#

the script is
this addAction ["Teleport",{player setPosATL (getPosATL pad2)}];

#

does anyone know how i would add a minimum distance you would have to be to the object for the action to show up?

#

bc at the moment you can be as far as you want and still use it

nocturne bluff
#

...

#

as in 10 loops like that

#

;)

#

aka if you are too daft to fucking realize

queen cargo
#

10x while {_thing distance player < 5} do {...}

meager granite
#

radius

#

You'll need to add other default parameters before getting to radius though

polar radish
#

sick

nocturne bluff
#

Yes.

#

Bravo

#

I also know SQF

lime rapids
warm hedge
#

Nope AFAIK

#

This is about an AI vehicle

lime rapids
warm hedge
#

Both

lime rapids
#

bruh y 2 commands doenotlikemeowcry

#

sqf moment

nocturne bluff
#

Hey everyone!

warm hedge
#

forceSpeed is sir, try to keep it to that speed
limitSpeed is sir, don't overspeed

lime rapids
#

makes sense im still going to complain because it isnt convenient for me though

nocturne bluff
#

X39 knows how to use WHILE loops

#

Amazing

warm hedge
#

Nobody is going to stop you to be hrash against two decades old anything

lime rapids
#

tru

nocturne bluff
#

What will he use next?

#

A if loop!

lime rapids
#

id assume best way to try limit speed of a projectile / missile would be set velocity transformation then, yes?

warm hedge
#

Guess so

nocturne bluff
#

or perhaps he will assign a variable to a value

#

Holy shit mind blown

queen cargo
#

wanna rage further?

#

you used an invalid example

#

which made even less sense thx to the 10 in front of it

#

thus i cleared your stupidity

nocturne bluff
#

Hah.

#

Yeah.

#

You keep thinking that.

indigo snow
#

What

queen cargo
#

10 while(_thing distance player < 5)

vs

10x while {_thing distance player < 5} do {...}

#

so ... tell me
what is more clear what you mean?!

indigo snow
#

The horror

#

Incorrect code in a side off comment

nocturne bluff
#

Truely

#

Im outraged.

#

How could i do this.

indigo snow
#

Monetory recompensation truely

nocturne bluff
#

...

#

wat?

#

Discord is drunk

#

There we go.

candid scroll
#

does BIS_fnc_showNotification by default run for all players?

tough abyss
#

As we all know loops are bad... best ways to script a task to complete is by using EHs?

old owl
candid scroll
#

thank you

tough abyss
#

Also triggers confirmed the cancer that's killing our FPS?

queen cargo
#

simple thing @tough abyss
if you want a performant mission: use no scripts

old owl
# candid scroll thank you

You are welcome! In any case where you are planning on developing anything within a multiplayer environment or scenario with multiple players I would familiarize yourself with remoteExec as it will pretty much always be your go to. In the instance I sent, the -2 is within the targets parameter. When you specify -2 as a target, you are intending to execute globally (all players). I tried to link the wiki for it but I got timed out by a bot I think but I reccomend checking it out. Best of luck 😄

candid scroll
#

Thanks Milo! Really appreciate it. I'm still familiarising myself with all of these arma 3 scripting nuances like remoteExec and client-only functions / contexts!

queen cargo
#

((scripts include triggers, modules, ...))

#

however, that would be a very boring experience

#

which would not even be packable using the editor

tough abyss
#

It's possible if you get some guy to script and "admin" the whole thing

indigo snow
#

Yes a killed EH would be nicer than a trigger monitoring 10 alive x

queen cargo
#

pff ... the trick for real performance is choosing the right disadvantage for the right purpose

#

also invalid pseudo code

#

thus does not matters 😃

tough abyss
#

Ideal way to run things : AI on HC. All scripts on server. And player enjoys the smooth experience.

queen cargo
#

nope

tough abyss
#

No scripts no ai, no players no problems.

queen cargo
#

the ideal world for every IT guy ❤

#

however ... the trick is as said the correct tradeoff

#

it does not makes sense to run everything on server in regards of scripts

#

also you should not just throw all AI on the HC

#

however ... thats at least better then 80% of the stuff which gets produced 😃

thin fox
#

Hello. I'm bit confused. Is this normal?
In the watch, the unit is not local to me, yes, but in the execute box it should return the object/unit by the server (server exec), right?

tender fossil
thin fox
#

yes, it make sense lol

little raptor
runic surge
#

How could you reliably determine whether a primary weapon is a gl variant or not?

old owl
# runic surge How could you reliably determine whether a primary weapon is a gl variant or not...

I think you might be able to with weaponState and then getting it's muzzle. Don't quote me but you could probably do something like:

((weaponState player) select 1) in ["weapon_classname_1", "weapon_classname_2"]

Or alternatively

((weaponState player) select 1) find ["classname_prefix_1", "classname_prefix_2"]

Feels like there is probably a more efficient way of checking this and take this with a grain of salt as it is scratch but in the event that is helpful 🙂

little raptor
#

To actually tell if it's a GL you have to check the weapon config (if it's an alternative muzzle it's in a separate class under the weapon class), get the magazine name, get the ammo name from the magazine config, and finally check the ammo config
I don't remember if GL ammo had a specific simulation or not but that's something to look out for in the ammo config
if it's the same as hand grenade, "shotGrenade", your work is done
If it uses something like "shotBullet", you have to check its indirectFire to see if it's an explosive shot

runic surge
#

I need to find out just from the class name

tough abyss
#

I really like how you can't run loadout scripts on the server, as in non local units won't recieve weapons >.<

runic surge
#

I guess I just need to tell if it is an alternative muzzle and what mags it uses

#

but gl/shotgun muzzles aren't all named the same way. If every weapon that uses additional alternate muzzles has muzzles[] = {"this","EGLM"}; I could retrieve that. I will try that first

meager granite
#

Also maybe cache the result so its faster

#

What info do you need exactly? Just tell if it has GL?

#

Which muzzle is GL specifically? Mags that are fit for that muzzle?

runic surge
#

tell if a weapon has a second muzzle and what ammo it uses

#

pretty sure I got it figured out

meager granite
#

Just checking for second muzzle is easy, check if there are more than 1 muzzle that is available to player

#

If you want a muzzle that has explosive ammo, then its a bit more complicated, you need to check each mag and magazine wells

runic surge
#

what about detecting grenade types? smoke, he, etc for either thrown or launched grenades?

meager granite
#

simulation type + damage properties

#

You can get almost accurate results

runic surge
#

so theres no way to filter out smoke grenades from lethal grenades?

hallow mortar
#

I'm pretty sure smokes have their own sim type

runic surge
#

all I need to do is ensure that lethal grenades are selected instead of smoke by the player

meager granite
#

I have no life so I wrote the code for you:

    doesWeaponHaveGL = {
        params ["_class"];
        private _cfg = configFile >> "CfgWeapons" >> _class;
        getArray(_cfg >> "muzzles") findIf {
            private _muzzle_cfg = if(_x == "this") then {_cfg} else {_cfg >> _x};
            private _mags = getArray(_muzzle_cfg >> "magazines");
            {
                {
                    _mags append getArray _x;
                } forEach configProperties [configFile >> "CfgMagazineWells" >> _x, "isArray _x", true];
            } forEach getArray(_muzzle_cfg >> "magazineWell");

            _mags findIf {
                private _ammo_cfg = configFile >> "CfgAmmo" >> getText(configFile >> "CfgMagazines" >> _x >> "ammo");
                   getText(_ammo_cfg >> "simulation") == "shotShell"
                && getNumber(_ammo_cfg >> "indirectHitRange") > 0
            } >= 0;
        } >= 0;
    };
    ["arifle_MX_GL_F" call doesWeaponHaveGL, "arifle_MX_F" call doesWeaponHaveGL];
``` => `[true,false]`
#

expand from here

runic surge
#

I appreciate your help but I'm already beyond detecting additional muzzles lol

meager granite
#

Probably also needs indirectHit > 0 check too

meager granite
#

And see if it has explosive ammo

runic surge
#

I need to do this while adding all the grenades to the player inventory not after

granite sky
#

So you want to know which magazines are explosive shells?

#

It's the last bit there. Just change the findif to select.

runic surge
#

Right now I just want items added to the player equipped properly. Only thing I'm lacking is making sure the player has the correct grenade selected when items are added

granite sky
#

What's the correct grenade?

runic surge
#

the one that explodes. whatever the lethal one is

#

it's always the default unless only smokes are in the inventory

granite sky
#

You only want to change which magazine is loaded into the grenade launcher? Nothing else?

runic surge
#

Hand grenades, not launcher

granite sky
#

oh.

runic surge
#

though I suppose it is possible that the launcher might be loaded with a smoke as well

granite sky
#

So your problem is that a player is equipped with multiple grenade types, and you want to make sure their current thrown grenade is set to an explosive one?

runic surge
#

yes, but while the items are being added to the inventory, not after

granite sky
#

I think you can just add the explosives ones first.

meager granite
#

find explosive mag for Throw weapon, select it

granite sky
#

I was wondering if addWeaponItem works with Throw

meager granite
#
player addWeaponItem ["Throw", "HandGrenade", true]
player addWeaponItem ["HandGrenadeMuzzle", "HandGrenade", true]
granite sky
#

yeah you'd probably need to remove and re-add grenades then.

runic surge
granite sky
#

Same way as the grenade launcher rounds.

runic surge
#

I didn't differentiate those

hallow mortar
#

Sa-Matra posted some code a little while ago for doing it

granite sky
#

You have CfgMagazines classnames. Look up the ammo value in CfgAmmo, check indirectHitRange.

hallow mortar
runic surge
#

Is there really no simpler way?

granite sky
#

Nope.

hallow mortar
#

Explosive grenades use simulation type ShotShell, smoke grenades use type shotSmokeX. Should be a reasonable way to distinguish them. (I wouldn't necessarily rely on indirecthit as modded smokes could have "realistic" splash damage)

fair drum
cyan dust
#

Good day. I'm facing the issue when not so large numbers are converting to scientific notation and that may cause issues. Example: 1234567 turns into 1.23457e+06
How do I check that it has happened and how do I turn it back into int? It breaks output to UI

granite sky
#

toFixed

#

You don't need to check. Just use toFixed if it's likely to happen.

old owl
cyan dust
surreal horizon
#

cant send long codes here?

granite sky
#

pastebin as necessary

surreal horizon
#

I'm gonna share a script i made, should i post here os mission makers?

fair drum
#

do you need help with it? is there a problem?

stable dune
surreal horizon
#

it certainly has room for improvement

fading notch
#

does this section have a bank available of working scripts to use? Both SP/MP

old owl
fading notch
old owl
# fading notch Well kind of. An area in this section that has scripts others have made and like...

Honestly not sure if there is a random scripts section here or anything apart just from what was sent in chat prior. I am under NDA for the server I develop for so not much examples wise I am actually able to share myself apart from stuff before I started. Anyway here is a really simple menu that I made in the event that helps you. It would go in the MP missions folder and be opened in the Eden Editor if you were looking for a way to get acclimated/getting your environment setup. Years old though so don't mock me for it looking like crap haha.

edgy salmon
#

Is it possible to script ai aircraft (or any ai unit) engage a player thrown smoke grenade?

#

It would also be cool to know if you can set it to only engage a certain colour of smoke

old owl
#

When you say engage it do you mean like shoot at the smoke grenade?

edgy salmon
#

Yeah, players pop smoke, friendly CAS comes in and shoots at the area the smoke is at

indigo snow
#

addWeapobGlobal

#

???

fair drum
#

lol NDA for a > 10 year old game

indigo snow
#

ah

#

i see the note

old owl
# edgy salmon Yeah, players pop smoke, friendly CAS comes in and shoots at the area the smoke ...
player addEventHandler ["Fired", {
    params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_projectile"];
    
    private _smokeGrenades = ["SmokeShell", "SmokeShellRed", "SmokeShellGreen", "SmokeShellYellow", "SmokeShellPurple", "SmokeShellBlue", "SmokeShellOrange"];
    if (_ammo in _smokeGrenades) then {

        waitUntil {
            uiSleep 1;
            (!(isNull _projectile) && ((speed _projectile) < 1))
        };

        uiSleep 6; // Or however long until smoke is actually visible :)
        
        private _grenadePos = getPosATL _projectile;
        private _fireObjNamespace = format ["gl_fireObject_%1%2", (str (_grenadePos#0)), (str (_grenadePos#1))];

        missionNamespace setVariable [_fireObjNamespace, createVehicle ["ah1w", _grenadePos]];
        private _lcl_fireObj = missionNamespace getVariable _fireObjNamespace;
        _lcl_fireObj hideObject true;
        _lcl_fireObj allowDamage false;

        private _nearbyAirSupport = nearestObjects [_lcl_fireObj, ["O_Plane_CAS_02_F"], 500];
        if (_nearbyAirSupport isNotEqualTo []) then {

            private _nearTargets = nearestObjects [_lcl_fireObj, ["Car", "Tank", "Man"], 200];
            {
                _x params ["_aircraft"];

                private _pilot = currentPilot _x;
                if !(isNull _pilot) then {
                    private _randomTarget = selectRandom _nearTargets;

                    // BRRRRRRRRRRRRRRRRRZZZZZZ :D
                    _pilot doTarget _randomTarget;
                    _pilot doFire _randomTarget;
                };
            } forEach _nearbyAirSupport;

            deleteVehicle _lcl_fireObj;
            missionNamespace setVariable [_fireObjNamespace, nil];
        };
    };
}];
#

No idea whether that will actually work or not since it is scratch. Will likely have parts I trolled on that needs fixed. Also wouldn't be surprised if I messed up the way to fire at the AI or something or used general poor etiquette since I don't often use AI related commands. That should help you though 🙂

edgy salmon
#

Thanks man, will try it out as soon as possible

old owl
# fair drum lol NDA for a > 10 year old game

Yee when said like that but honestly it makes sense. The server had it's mission file leaked a few years back and it was nearly a decade worth of combined developer work just made public when it wasn't supposed to be. What better way to make sure that doesn't happen again than an NDA haha

indigo snow
#

Still, just removeWeaponGlobal first

fair drum
old owl
# fair drum do they not know that anyone that joins can take apart even an obfuscated pbo? i...

They do know that. Server files are not included on the client and cannot be deobfuscated though. Without those the mission wouldn't be able to be re-used without having to reinvent the wheel anyways. Oftentimes a missions most critical and sensitive tasks are performed on server. It makes sense they would want to keep those out of the hands of people who are looking to cheat or do other nefarious things that would impact player quality of life.

acoustic abyss
#

I'm scripting a tank being loaded VIV into a plane without mods. It visually fits, and that's enough for me. But players can still turn the turret to stick out of the plane. Note I do not want to disable seats or simulation of the entire vehicle, so that players can still exit.

What is an elegant way to immobilize a (tank) turret?

granite sky
#

setTurretLimits maybe.

leaden ibex
#

Set the turret hitpoint to destroyed and then reverse it when unloaded?

ivory lake
silent latch
delicate hedge
#

why i cant apply post process effects in thermal view? how to do it?

glass nest
#

how do I make mine creation local?

old owl
old owl
old owl
old owl
delicate hedge
old owl
#

Hmmm are you able to send an excerpt of what you have got? Honestly never even knew that night vision override post processing effects and first time seeing that command so I could just be trolling.

old owl
# delicate hedge after

Honestly appears to work fine properly for me when specified afterwards so not sure why it would be giving you issues. Here is my debug code though in the event it helps you troubleshoot:

[] spawn {
  _handle = ppEffectCreate ["colorCorrections", 1501]; 
  _handle ppEffectEnable true; 
  _handle ppEffectAdjust [1.0, 1.0, 0.0, [1.0, 0.1, 1.0, 0.75], [0.0, 1.0, 1.0, 1.0], [0.199, 0.587, 0.114, 0.0]]; 
  _handle ppEffectCommit 0;
  _handle ppEffectForceInNVG true; 
  uiSleep 10; 
  ppEffectDestroy _handle;
};
delicate hedge
#

it didnt work

old owl
#

Ahhhhh okay I was thinking of thermal NVGs that's my bad.

#

It's probably because it is considered a cameraView. Let me see if there is something for that.

#

Okay so not inherently a cameraView thing as night vision modes do show effect but oddly the thermals do not like you mentioned.

old owl
runic surge
#

anybody know if there is a "move to formation" equivalent function or script that works post init out there anywhere?

#

the example for formationPosition isn't working for me

glass nest
runic surge
tulip ridge
delicate hedge
granite sky
#

Although I'm not sure whether that disables the detection or the pathfinding around known mines. You didn't mention whether they're known mines.

glass nest
granite sky
#

ah ok

#

Curious now whether a createVehicleLocal mine has a local explosion

glass nest
#

the main thing is that AI did not explode on mines

#

AI did not see them and did not blunt them

still forum
prime perch
#

Hi guys, does someone know if .ogv files are still supported in arma?

still forum
#

They are yes

prime perch
#

Oh, just askin, because when I tried to use a video as a mission intro it got "squished"

#

I just wrote "video = ["intro.ogv"] spawn BIS_fnc_playVideo;" in a trigger, maybe I've done something wrong idk

#

It just looks like this

#

I tried to change a video resolution but it just made things worse

fair drum
still forum
#

Of course :3

still forum
prime perch
still forum
#

I usually do it with VLC but I don't remember what settings

#

Usually as.. once in 5 years

prime perch
still forum
#

I'd expect them on wiki

#

The video script function wiki page should lead to it

prime perch
still forum
#

Don't have anything better now

#

VLC has a convert option, to ogg vorbis.

prime perch
#

Hoping at least this will work, thank you very much

prime perch
#

It really worked, thanks a lot!

bold comet
#

not saying it doesn't work but

#

if it does something that's subtle

ornate whale
#

Hello, is there a way how to wait until the game closes the loading screen at the beginning of a MP game? I have an intro in init.sqf, but it usually starts before the loading screen goes off. Thank you

tulip ridge
#

That's the main game display

ornate whale
# tulip ridge You could try waiting until display 46 is initialized

Tried all this, but it seems to be not working:

waitUntil {getClientStateNumber >= 10};
waitUntil {local player && !isNull findDisplay 46};
waitUntil {player == player};
waitUntil {missionNamespace getVariable[ "BIS_fnc_startLoadingScreen_ids", [] ] isEqualTo []};

I can hear the birds singing in the background, so the world is already loaded, but the loading screen is still showing, after pressing the continue button on the briefing screen.

vague bane
#

There a way to make a bar gate open with a trigger? Like when my players vehicle gets to a point it opens, rather than plowing through it/Wasting time getting out of a vehicle to manually open it 🤔

#

And close when you get to the other side*

fading notch
#

Anyone use event handlers to activate a trigger? If so, how did you set it up

broken forge
#

Was there an update that missed up the HandleDisconnect mission event handler or am I using it wrong? For some reason when my server mod adds the mission event handler it's not able to get the player variables to store in the database:

addMissionEventHandler ["HandleDisconnect", {
    // params ["_unit", "_id", "_uid", "_name"];

    private _unit = _this select 0;
    private _uid = _this select 2;
    private _data = [
    _uid,
    "armory_unlocks", [_unit getVariable ["Armory_Unlocks", []]],
    "garage_unlocks", [_unit getVariable ["Garage_Unlocks", []]],
    "locker", [_unit getVariable ["Locker", []]],
    "garage", [_unit getVariable ["Garage", []]],
    "cash", [_unit getVariable ["Cash", 0]],
    "bank", [_unit getVariable ["Cash_Bank", 0]],
    "number", [_unit getVariable ["SOF_Phone_Number", "unknown"]],
    "email", [_unit getVariable ["SOF_Email", "unknown@spearnet.mil"]],
    "paygrade", [_unit getVariable ["Paygrade", "E1"]],
    "reputation", [rating _unit],
    "loadout", [getUnitLoadout _unit],
    "holster", [_unit getVariable ["SOF_HolsterWeapon", true]],
    "position", [getPosASLVisual _unit],
    "direction", [getDirVisual _unit]
    ];

    if (vehicle _unit == _unit) then {
        _data pushBack "currentWeapon";
        _data pushBack [currentMuzzle _unit];
        _data pushBack "stance";
        _data pushBack [stance _unit];
    };

    // ["hsetidbulk", "", "", -1, _data, "", "null", false] call dragonfly_db_fnc_addTask;
    ["hsetidbulk", "", "", -1, _data, "", "null", false] remoteExecCall ["dragonfly_db_fnc_addTask", 2, false];

    deleteVehicle _unit;
}];
granite sky
#

Do the non-getVariable ones work?

broken forge
#

Yes if I recall they do work

broken forge
#

Within the mission I have an initServer.sqf which calls sof_server_init_fnc_serverSetup and within that function it calls sof_server_save_fnc_handleDisconnect which is the above code block.

opal zephyr
#

Is there a way to get the object for the arsenal im in? For example ace has a variable ace_arsenal_currentBox that stores the obj reference for the arsenal you're in

granite sky
#

@broken forge If the unit exists but the variables don't, you need to look into what your setVariable calls are doing with locality and timing.

broken forge
#

Here is part of function on the client side that loads the data from the database and set the player values:

...
        switch (_key) do {
            case "reputation": {
                SETVAR(player,Reputation,_value);
                player addRating _value;
            };
            case "loadout": {
                SETVAR(player,Loadout,_value);
                player setUnitLoadout _value;
            };
            case "direction": {
                SETVAR(player,Direction,_value);
                player setDir _value;
            };
            case "cash": {
                SETVAR(player,Cash,_value);
            };
            case "bank": {
                SETVAR(player,Cash_Bank,_value);
            };
            case "armory_unlocks": {
                EGVAR(armory,arsenalUnlocks) = _value;
                SETVAR(player,Armory_Unlocks,_value);
            };
            case "garage_unlocks": {
                EGVAR(armory,garageUnlocks) = _value;
                SETVAR(player,Garage_Unlocks,_value);
            };
            case "locker": {
                SETVAR(player,Locker,_value);
            };
            case "garage": {
                SETVAR(player,Garage,_value);
            };
            case "email": {
                SETVAR(player,SOF_Email,_value);
            };
            case "number": {
                SETVAR(player,SOF_Phone_Number,_value);
            };
            case "paygrade": {
                SETVAR(player,Paygrade,_value);
            };
            case "stance": {
                SETVAR(player,Stance,_value);
                player playAction _value;
            };
            ...
        };
        ...
granite sky
#

macros lol

broken forge
#

lol, the macro translates to player setVariable ["NameOfVariable", value];

granite sky
#

That's local

broken forge
#

Yep, so do I need to set it global?

granite sky
#

Uh, if you want to read it on the server, yes

#

I don't know why you'd be doing database reads from the client.

broken forge
#

So using this client side is incorrect? ```sqf
["hgetallid", getPlayerUID player, "", -1, [], "sof_client_init_fnc_handlePlayerLoad", netId player, true] remoteExec ["dragonfly_db_fnc_addTask", 2, false];

granite sky
#

shrugs

#

Main thing is to ensure that you're not setting the same var from two different places at the same time.

#

It looks like the database task runs on the server and then sends data to the client, so that might be fair enough.

broken forge
#

Yep that's what it does, but now you've got me second guessing on how to retrieve and set each player's variables, lol

fair drum
opal zephyr
#

Chat was pretty busy so I'm reposting this question:

Is there a way to get the object for the arsenal im in? For example ace has a variable ace_arsenal_currentBox that stores the obj reference for the arsenal you're in

fair drum
#

to be clear, vanilla arma then?

opal zephyr
#

Yup

granite sky
#

The object is passed into BIS_fnc_arsenal, so maybe. You'd have to read the function.

opal zephyr
#

I've read it, It doesnt seem to be stored anywhere thats accessible outside the function

#

This is used though _box = [_this,0,objnull,[objnull]] call bis_fnc_param; with _this being supposedly the object? Not sure what this code dose exactly though

fair drum
#

i believe that is the old function for param/params

opal zephyr
#

But _this is obviously local to said script. _this is set to params [1,[]] at the start

#

I can get all of the arsenals with missionnamespace getvariable ["bis_fnc_arsenal_boxes",[]] however the best I can do after is filter by distance which is un-ideal

granite sky
#

Is this static arsenals within a mission?

opal zephyr
#

I'd like for it to work with ones added through zeus as well

granite sky
#

Best I can suggest is replacing the BIS function with your own and chaining to it.

#

but you'd need a mod for that.

opal zephyr
#

Mod is fine, this is in a mode already. How would I go about chaining it? If this process is a lot I might just chop part of this feature

granite sky
#

Add a CfgFunctions entry that overwrites the one for BIS_fnc_arsenal and another one that creates another function for the original.

opal zephyr
#

Thats smart, am I allowed to copy and use an entire BI function though?

granite sky
#

You don't have to. You chain to the original.

opal zephyr
#

Hm I'm missing something then

granite sky
#

Because all you need to do in this case is store one parameter on the object.

#

You don't need to change any other functionality, so a wrapper is fine.

opal zephyr
#

Is an example possible to give? I don't get how to overwrite the function while still utilizing its contents

ornate whale
ornate whale
#

The init is already executed on this screen (after briefing) and I have no idea how to know when its over, it can take seconds.

#

Though in SP, it works perfectly fine.

fleet sand
ornate whale
digital radish
#

Does any one else code the crap out of AI air support?

I think this is where I've spent the most time, and abusing the hell out of mission event handlers to drop ordnance at max speed on laser markers or helicopter support, otherwise they rarely shoot rockets at enemy infantry.

tough abyss
#

Do I have to restart the game every time I add a script in my folder?

meager granite
#

no, reload the mission\script

tough abyss
little raptor
#

Tho ideally don't put the backup fnc under BIS tag

polar pivot
#

I am trying to use a script that automatically equips red armbands to all OpFor units. The script works fine if the units are placed in the editor, however if they are placed in Zeus the armband is never applied. I used this exact script around 1 year ago and it all worked fine. Any ideas?

//EQUIP ARMBAND FOR X FACTION ON INIT

_armbandListGreen = ["gsb_armband_nv_g", "gsb_armband_nv_g_r"];
_armbandListRed = ["gsb_armband_nv_r", "gsb_armband_nv_r_r"];
_armbandListYellow = ["gsb_armband_nv_y", "gsb_armband_nv_y_r"];

{
if(side _x == opfor) then
{
   _x linkItem selectRandom _armbandListRed; 
};

} foreach (allUnits);

// EQUIP ARMBAND FOR X FACTION SPAWNED IN ZEUS

if (hasInterface) then {
   private _zeus = (allMissionObjects "ModuleCurator_F") select 0;

   _zeus addEventHandler ["CuratorObjectPlaced", {
       params ["_curator", "_entity"];
       
       _armbandListRed = ["gsb_armband_nv_r", "gsb_armband_nv_r_r"];
       
       if (_entity isKindOf "Man" && {(side _entity) == opfor}) then {
           _x linkItem selectRandom _armbandListRed;
       };
       
   }];
}; ```
south swan
#

if (_entity isKindOf "Man" && {(side _entity) == opfor}) then { _x linkItem... _x is not defined in EH scope

polar pivot
proven charm
#

does anyone know how to get the angle to which a door is facing? I tried playing with the trigger, axis etc selectionPosition to get the angle but to no avail

south swan
#

which "angle'?

proven charm
#

where its facing

ornate whale
proven charm
#

just exit

ornate whale
# proven charm just exit

I am not proficient with working with the LODs and model sections. But I was dealing with this when spawning units infront of the door and orienting them accordingly. I did it by finding the position of the door and its corresponding path exit point, then creating a vector between, which shows the direction. I found the corresponding exit point by selecting the one that is closest to the door pos. This works for external doors, not sure about internal.

proven charm
#

hmm but how do you know which exit point "belongs" to the door?

#

oh ok

ornate whale
#

There might a different way probably. Some command that would work with the model selections.

#

IDK

proven charm
#

ill try that

south swan
#

inb4 calculating direction between "OpenDoor" and "CloseDoor" action positions on bot navmesh

ornate whale
#

Or maybe just calculating the normal of the closed door?

south swan
#

inb4 internal door

#

at the model origin

#

what's the end goal, if you don't mind sharing?

proven charm
#

trying to place a tripwire behind the door

ornate whale
#

If you don't need it to be fully procedural, you may utilize some handplaced pointers or arrows in Eden, or use model space coordinates to specify those points.

proven charm
#

trying to do this automatically

south swan
#

is Paths LOD even accessible from SQF? tanking

proven charm
#

tried buildingExit now but the positions returned arent front of the door :/

ornate whale
proven charm
#

yea I hear you

#

no luck there

ornate whale
proven charm
#

trying that

little raptor
#

If you do you can just measure the euler angles between the original matrix and the current matrix

south swan
#

well, for the use case the question seems to be mostly about the original selections dir

little raptor
#

It's not really possible to tell the angle it's facing
You can only tell how much it's changed from its original coords

proven charm
#

tried all LODs of selectionVectorDirAndUp now and I get some coords but still not same dir as door

little raptor
#

Actually I have an idea but it might not work perfectly

#

You can get the FirstPoint selectionPosition, then AveragePoint selectionPosition
The vector between these almost always lands on the door plane itself (assuming it's very thin)
Then you get a vector perpendicular to this and you have your door angle

proven charm
#

this is my test code incase anyone wants to take a look : ```sqf
_vv = bldg selectionVectorDirAndUp [format ["Door%1", _doorIndex], "Memory"];
_v = ((_vv # 0) vectorMultiply -1);

_trapPos = _bldgDoorPos vectorAdd _v;

south swan
#

relying on point order seems... brave

proven charm
south swan
#

i'm talking a obout Leo's idea

proven charm
#

ah

little raptor
#

It just gives the bone transform. The door itself can be angled with respect to the bone

south swan
#

"along the door" may (or may not) be acceptably calculated as difference between door's AveragePoint and said door's axis AveragePoint tanking

little raptor
#

There's a door axis selection?

#

I only remember door handles think_turtle

#

Actually yeah there should be an axis

proven charm
little raptor
#

Unless they use rotateX/Y/Z anims

south swan
#

i'm not sure it's guaranteed to be present in Memory LOD, though

#

well, rotateY (or whatever dir) also needs an axis, it's just 1 point there, no?

little raptor
#

I think so yeah

little raptor
stable dune
proven charm
#

tried this now ```sqf
private _doorPos1 = bldg selectionPosition [format ["Door%1", _doorIndex], "Memory", "FirstPoint"];
private _doorPos2 = bldg selectionPosition [format ["Door%1", _doorIndex], "Memory", "AveragePoint"];

_doorAngle = (_doorPos1 getdir _doorPos2);

south swan
#

this getDir should approximate direction along the door, not perpendicular to it

proven charm
#

<---- not good with maths

#

wish there was just normal vector for the door and I could get this working

south swan
#

mandatory bad MS Paint drawing 🙃

proven charm
#

you saying it wont work? 😐

south swan
#

why wouldn't it? Should be "close enuf" for most purposes

still forum
#

Men's doing mafs

#

Mafemafifs

winter rose
#

kwik maffs

still forum
#

Mafmen

sharp grotto
#

If you want it perfect you can always hardcode the positions

south swan
#

for all, what, 4000 simulation="house" objects in vanilla?

little raptor
#

You can also use the avg and first point like you did instead of using axis
I also assumed that the door always rotates around Z axis (in model space)
This returns n in model space

#

You can use [0,0,0] getDir (house vectorModelToWorld _n to get the door angle

proven charm
#

wow Leo, that code seems to be working nicely! Only thing I noticed is that it sometimes gets the position inside the house and sometimes outside. but still at front door. thx 👍

little raptor
south swan
#

nah, it's just some doors have hinges on the left side and others on the right side 🤣

little raptor
#

Oh that's what you mean. Yeah you can't guarantee which side it ends up on

proven charm
south swan
#

i'd say sign of _n vectorDotProduct _p1 can show if _n points inside or outside the building

little raptor
#

It uses geometry LOD so it's different

south swan
#

at least for outside doors and convex building shapes

little raptor
#

Actually no if you subtract it from p1 or p2

south swan
#

dot would be zero for perpendicular vectors, though

little raptor
#

Well yeah hence sign is zero

south swan
#

they aren't guaranteed to be perpendicular, though

#

more bad MSPaint

#

_vec would be perpendicular to _n by cross product definition, but i propose to use trigger/axis model coordinates for center-ish direction

proven charm
#

well thx again guys, I can live with the fact that the pos varies from door to door. I might make the whole thing random to have some variation in the mission

little raptor
south swan
#

ah, i've misread that, sorry

proven charm
#

tripwire mines are weird, I can walk over them and they dont always detonate...

sharp grotto
#

mostly happens when placed inside buildings

proven charm
covert oak
#

In case there isn't a lot of cross talk between channel here, I'll ask again here as suggested.
I'm adding a command to RscMenuEngage via config.cpp which calls an sqf file. I'd like to pass the location information along to the script, that is the player's cross hair location or map pointer location, similar to how the vanilla "supress" command works.

More detail here:
#arma3_gui message

last cave
#

lol Blue unit in red side group...
Side unit == blue
side group unit == red
Very strange bug...

covert oak
#

Also, chatGPT says:
_targetPos: This is automatically set by the system when the player interacts with the map or game world.
But I'm dubious of that claim.

last cave
tulip ridge
covert oak
#

That won't work with the map or collide with objects.
I used lineIntersectsWith to get accurate position data, but the vanilla commands have to have a solution for this.

#

I posted the actual code in GUI, link to that message above.

#

Like I said, im always dubious of anything chatGPT spits out, but bis does this somehow.

still forum
#

You need to differentiate between map opening and non-map.
Because the methods of getting the position are different

still forum
#

The way is screenToWorld, and then running a lineIntersectsSurfaces, to find the first surface on the line

last cave
#

Is it possible to disable physX for an object without disabling the ability to change animationsource?

On the server, sometimes there are cases when an object jumps when someone appears nearby or some object has activated physX within the radius of visibility. And it happens that the object even falls. For example, from the table. It is too stupid to create a cycle that will move the object back.

tulip ridge
last cave
#

The laptop on which the action is taking place is on the table. And sometimes it jumps off the table itself when PhysX is turned on. And the laptop was previously placed in the editor a little higher than the table surface.

But when it falls on the table, it can very strongly move\turn\fall off the table
It can be seen that it bounces a little.

ornate whale
#

When I use it on a server it doesn't get replicated on a client.

fleet sand
ornate whale
fleet sand
#

what is your code ?

ornate whale
# fleet sand what is your code ?

You want to see my code? It is quite long. It runs only on server.
Even if I try it via debug console (just the playMove and switchMove), it works only on the server.

#

This is the part I use for playing anims, just a snippet.

isNil
{
    if (!alive _unit) exitWith {_halt=2;};

    _unit switchMove _anim;
    _unit playMoveNow _anim;

    if (animationState _unit != _anim) exitWith
    {
        _halt=1;
    };
};
#

But some animations work, partially.

#

I move the unit and attach it to a logic object before playing an anim.

fleet sand
#

try with puting anim globlay

[_unit , _anim] remoteExec ["switchMove"];
[_unit , _anim] remoteExec ["playMoveNow"];

Even Tho they have GE this would enshoure they are played globaly.

ornate whale
#

If someone connects then they will see a standing unit on a chair before the update arrives, or will have to catch up on a very long JIP queue.

#

Since the anims cycle randomly indefinitely.

ornate whale
ornate whale
covert oak
hallow mortar
gray anvil
#

Are the CBA eventhandlers executed locally or globally?

proven charm
#

@stable dune it sometimes says you are typing but your not sending messages

stable dune
# proven charm <@790272937994879047> it sometimes says you are typing but your not sending mess...

I like type, but then I take a look from wiki or Google or search from channels , usually I answer before asking.
Many ppl asking same thing, sometimes in different content.
And I was answering to kbu, that depends what eventhandler a he means.
"XEH should always have the same locality as vanilla EH",
But if he means eventhandlers that can be added with CBA_fnc_addEventhandler , then it depends how it's called.

proven charm
#

ok no problem there, just wanted to let you know. i thought there was cat walking on your keyboard ;D

gray anvil
#

addEventHandler should be local, not sure about the XEH_inits though

still forum
still forum
restive hinge
#

Can anyone please sanity check my script? It performs an ambient sound and fires on a repeatable trigger with a loop which keeps firing ambient sounds if at least 1 player is in the trigger.

params ["_trigger", "_unitsArray", "_soundPath", "_soundsIndex"];

if (isServer) then {
    _countPlayersOnActivation = count [allPlayers select {alive _x && _x inArea _trigger}];
    systemChat str (format ["Players in trigger: %1", _countPlayersOnActivation]);

    while {true && _countPlayersOnActivation == 1} do {
        _countPlayersInTrigger = count [allPlayers select {alive _x && _x inArea _trigger}];
        systemChat "Loop activated";
        _randomDelay = [10, 15] call BIS_fnc_randomInt;
        _randomUnit = selectRandom _unitsArray;
        _randomIndex = [1, _soundsIndex] call BIS_fnc_randomInt;
        if (_countPlayersInTrigger < 1) exitWith {
            systemChat "No players in trigger, breaking loop";
        };
        systemChat "Firing phrase";
        playSound3D [getMissionPath (format ["\sounds\%1_%2.ogg", _soundPath, _randomIndex]), _randomUnit, false, getPosASL _randomUnit, 5];
        sleep _randomDelay;
    };
};
#

I feel like this is a flustercluck

#

Trigger activation:

_unitsArray = allUnits select {!(isPlayer _x) && _x inArea thisTrigger}; 
[thisTrigger, _unitsArray, "pub\pub", 17] execVM "scripts\ambientAI.sqf";
#

There must be a better way to do this. Currently if a player exits the trigger and re-enters it while sleep is not executed fully the trigger activates again

#

Seems to me I have to track execution process using a global var or somehow halt the entire trigger with waitUntil

granite sky
#

shrugs

#

You could do all area checking with the trigger here. You'd need to store the spawned script handle.

#

triggerActivated would be what you check from the spawned script.

#

Alternatively you could drop the trigger entirely and just have a permanent loop doing the proximity checking, but it seems like the trigger would work here.

restive hinge
#

I sticked with a trigger so it could run only in proximity with players

#

I could really do the loop with activation without the trigger, actually, yes

#

Skill issue

granite sky
#

allPlayers inAreaArray [_centerPos, _radius, _radius]

#

Trigger is probably a bit quicker if it fits your requirements, but they're a bit of a pain.

restive hinge
#

However it seems to me that running a loop for each zone would somehow hit perfomance?

hollow junco
#

Yow, is there a good way to ensure that setVelocity is being applied at the same rate no matter what the server framerate is?

I've made a script for boosting an aircraft, but the rate of the boost is highly variable depending on whether I'm in SP or MP.

south swan
#

since when setVelocity has anything to do with framerate? tanking

hollow junco
#

it does when you're applying it each frame to simulate an acceleration

south swan
#

🤷‍♂️ i'd assume you use getVelocity and vectorAdd somewhere as well. And i propose you to vectorMultiply the added velocity by diag_tickTime diag_deltaTime then

hollow junco
#

would it be diag_deltaTime?

south swan
#

yeah, you're correct

hollow junco
#

Brill, thanks! I'll give that a go! I couldn't find that function when I've looked in the past, thanks for pointing it out!

south swan
#

i mean, it's found by you, not me 🤣

hollow junco
#

Well, you set me in the right direction. 😄

frozen seal
#

hi all! I'm having an issue with this command used on terrain objects:

_object setDamage [1, false];

It works good for the hosting machine (image 1) however the connected clients see both destroyed and pristine building models at the same time (images 2 and 3).
What am I missing? I thought setDamage is a global argument/effect command? Why do buildings get duplicated?

#

Seems like it's more likely to happen for JIP players..

granite sky
#

There's something super-janky going on with map object loading vs hiding/destruction at init time. I haven't been able to pin it down in a simple mission.

#

What I can tell you is that if you wait until initClient fires, then that asks the server for a list of destroyed buildings, and hides them on the client side, then it works.

#

Nothing else seems to be reliable.

frozen seal
#

I do hide some buildings client-side and it seems to be working fine, the problem is that in this particular case I don't need to hide them, I need to destroy them

granite sky
#

I've had similar issues with both object destruction and hiding on the server side.

#

Well, except that hiding isn't reliable on the server either :P

frozen seal
#

I tried waiting 5 seconds after mission start and it seems like if the player is able to join before these 5 seconds the destruction works fine for him, but if he joins after the destruction triggers he sees the glitch

#

I guess I can wait for all players to fully load and then trigger the destruction script manually.. but man

granite sky
#

Yeah it's shitty. I wish I had a simple replication and then someone might look into it.

#

but it seems to be strongly dependent on timings that you can't control accurately.

patent goblet
frozen seal