#arma3_scripting

1 messages · Page 548 of 1

winter rose
#
if (true) exitWith { ["loser"] call BIS_fnc_endMissionServer; };```
loud python
#

I love that

dull drum
#

@winter rose , oh, sure, there is a left align but it's for a text. Thanks for looking though.

exotic flax
#

already asked this question a few days ago, but didn't get any response, so will try again ;)
I'm trying to get ACE Interactions (and specifically the explosives module) to work with/through UAV's. With the new UAV's in the Contact DLC, and a mod I'm working on which includes a EOD bot, it would be great to be able to defuse mines and place and arm explosives. However it seems that ACE Interact doesn't work at all since you're technically inside the terminal (not even a vehicle).
Does someone has an idea how to either script or use configs properly to make it possible to use ACE Interact through an UAV?

winter rose
#

I would tell you to maybe try the ACE Discord/Skype/ICQ/whatever 😐

exotic flax
#

As far as I can tell it's a "missing feature", so I already made a feature request on github. However since most hardcore devs are around this Discord I'm hoping someone already has a solution or tried their luck in avail

thorn saffron
#

How do I do something like this in a non-retarded manner?

if (_x isKindOf "CAManBase") then {_icon = taro_HUD_ManIcon;};
if (_x isKindOf "AIR") then {_icon = taro_HUD_AirVehIcon;};
if (_x isKindOf "Ship") then {_icon = taro_HUD_WaterVehIcon;};
if (_x isKindOf "StaticWeapon") then {_icon = taro_HUD_StaticIcon;};
if (_x isKindOf "LandVehicle") then {_icon = taro_HUD_LandVehIcon;};
winter rose
#

non-retarded manner? not in SQF 😁

hollow thistle
#

you can only make it less retarded via switch

#

gimme a moment

winter rose
#
switch (true)``` yeah
hollow thistle
#

private _icon = switch (true) do {
    case (_x isKindOf "CAManBase"): {taro_HUD_ManIcon};
    case (_x isKindOf "AIR"): {taro_HUD_AirVehIcon};
};
#

so on

winter rose
#

dang, he's fast

hollow thistle
#

also depending on which things you can expect to be in _x most of the time you can optimize by making these things be on the top

#

as it checks from top to bottom.

#

not 100% sure that it really stops checking after first find as it's arma but logic says it should.

#

So I would put CAManBase first, LandVehicle second

exotic flax
#

Although also be aware that some classes inherit others, so make sure that the parent classes are lower than the children. Otherwise you will get the parent instead of child.

thorn saffron
#

The checks seem work fine, I didn't get anything mislabeled yet. I'll check with the switch version

#

hmm, it seems that statics are a type of land vehicle, so I might put them above that so they return true first

#

@hollow thistle The switch stops on first find, just tested it.

hollow thistle
#

👍

loud python
#

what sound do I need to fade to 0 if I want to disable direct coms voices?

#

does that count as "radio"?

errant patio
#

do you want to disable them smoothly (i.e. actually use fade?)

#

i'm fairly sure if you want it to just instantly stop working you can use enableChannel? no experience personally though.

#

also, my own question:
I have a script that only works correctly on a dedicated server or a singleplayer game. What's the best way to stop the mission from running otherwise?

spice axle
#

You can check with isServer or hasInterface

#

Or isDedicated

dull drum
#

@winter rose so I've managed to significantly lower the flickering. Some while do loops without proper sleeps made it flicker, so I've just sleeped them. Still blinks when new units (zombies) are being spawn from the underground, but only for a few seconds which is ok-ish I think.

errant patio
#

won't isServer & hasInterface return true for player hosted servers too?

errant patio
winter rose
#

@errant patio see Multiplayer Scripting page too

errant patio
#

yeah, spent a while there but my specific issue is pretty niche (doing some nasty things with setDate lol)

winter rose
#

server only you monster 👀

errant patio
#

i wanted an area that was indoors with nice lighting but to not have to force all players to be there at once, so i made them all set their own dates when they're in there... problem is if the host does it then the rest of the players get that value propagated to them lol

winter rose
#

yep

#

so, don't ( :
Play with setApertureNew instead

errant patio
#

that's no good since it darkens the whole scene right? I have lights that I want to look right

winter rose
#

don't play locally with dates though, friendly advice for your hair 😁

thorn saffron
#

Can 0 and 1 stand in for false and true in sqf?

winter rose
#

@thorn saffron no

#
[false, true] select _zeroOrOne```
thorn saffron
#

hmm, I want to have a bitmask and I'm trying to figure out how can I have a neat CBA setting that uses checkboxes to enable particular parts of the bitmask.

#

I wanted to do it like this:

_bool1 = 1; //true
_bool2 = 0; //false
bitmask = 1* _bool1  + 4*_bool2;
willow basin
#

Quick question, do all event scripts only fire for missions and not mods?

winter rose
#

@willow basin …sorry, what?

willow basin
#

I tried to add init.sqf and initPlayerServer.sqf to my mod. Both are not fired / called. Do they not work for mods?

#

Same with initPlayerLocal

winter rose
#

ah yeah, no (afaik)

willow basin
#

Ah okay then, thanks for the quick answer ^^

winter rose
#

👍

thorn saffron
#

@willow basin You need to set that as post init function, so it gets fired after the mission starts

tough abyss
#

init.sqf is engine called so it should always execute, initPlayerLocal/Server.sqf is scripted so can be overridden by mods @willow basin

twin steppe
#

Hello. Just wondering if there is a way to turn all players on a server into BLUFOR. Example: I join OPFOR but when I enter the game I'm BLUFOR.

#

Is it possible with a simple debug script that I can execute locally?

winter rose
#

. . . . . why?

twin steppe
#

trying to make a 48/2 server into a full BLUFOR one.

winter rose
#

48/2 = 24

what's a 48/2 server?

twin steppe
#

Oh it's the Zeus 3 side server. Independent, OPFOR and BLUFOR.

winter rose
#

just place 48 blufor units?

twin steppe
#

Doing a pvp mission and they'll all be gathered for a short briefing. Just need to make them all BLUFOR for a few minutes, and then turn them back. I guess I can figure out the latter just need to figure out how to actually turn them all into BLUFOR:

winter rose
#

you can make them captive

#

…with setCaptive, both blufor and opfor

twin steppe
#

Ai will be involved. Are you sure there isn't a way of just turning OPFOR into BLUFOR?

winter rose
#

AI won't shoot if others are captive and believe me, it's faster/simpler/everything-er

#

you could setFriend maybe

twin steppe
#

Wont that count as "rouge" or what ever the game sees purple as.

winter rose
#

*rogue?

twin steppe
#

SetFriend is probably the thing I'm looking for.

#

Yeah haha engrish.

winter rose
#

rouge means red 🇨🇳

twin steppe
#

I'll take a look on the wiki. Appreciate the help so far.

winter rose
#

👍

twin steppe
#

west setFriend [resistance, 1]; and then I just remotexec with JIP activated and it should work.

winter rose
#

why remoteExec?

#

it's a server-side command, sooo

twin steppe
#

So incase players leave and come back they dont turn back into OPFOR

#

oh really? Alright sweet.

winter rose
#

don't forget to do the opposite too

twin steppe
#

Oh yeah thanks for reminding me. Would've forgotten that for sure.

winter rose
#
resistance setFriend [west, 1]```
else the resistance will shoot on sight and west will be friendly 😁
twin steppe
#

Yeah haha

astral dawn
#

setFriend from wiki:
Sets how friendly side1 is with side2. For a value smaller than 0.6 it results in being enemy, otherwise it's friendly. Intended to be used on mission start. Changing value during mission can cause unexpected errors in AI behavior. See also Side relations.

#

Typically if you want to change side of unit, you create a new group of needed side, then group the unit into this group

#

Although hell knows, it might work as well with setFriend 🤷

errant jasper
#

Yeah, I echo Sparker's suggestions... It is the group you are in that determine your side.

winter rose
#

in Arma 3 setFriend works better than in previous games

#

(in SP at least)

alpine venture
#

Hi everyone !

#

I'm trying to make a free cam with limited range around your character, i use BIS_fnc_EGSpectator but i can't get the cam position to calculate distance from the character

winter rose
#

cameraOn maybe?

alpine venture
#

Basically getPos player return the same thing, wether i am in camera mode or not

#

Mmh cameraOn doesn't seems to work

#

wether i use the object itself or its position

#

I just saw camcreate, i'm gonna try

#

Ok i managed to make it work with camCreate, camEffect and camDestroy

#

Herre is the code if anyone is interested :

camera = "camcurator" camCreate playerPos;
camera cameraEffect ["internal", "BACK"];
loop = true;
while {loop} do {
  cameraPos = getPos camera;
  distanceToPlayer = cameraPos distance playerPos;
  if (distanceToPlayer > 200) then {
    camDestroy camera;
    loop = false;
  };
  sleep 1;
};```
#

Bizzarely, if you destroy the cam but still try to calculate the distance, the game considers the cam to be at 0,0,0 coords

winter rose
#

Yes, because that's what getPos objNull returns

alpine venture
#

Noted

slim oyster
#

Is there a point to lazy evaluation with additional OR conditions?

#

if (isServer || {!hasInterface}) then {

#

Isn't it checking each condition separated by || left to right until a true condition is found?

austere granite
#

I might be wrong but i believe Arma checks all Or even though one is already matched

#

Should take you two seconds to test if you have the game running

#

For cases like that I'm not sure if lazy eval has any point though of memory. Generally it's just used for bit more complicated function calls

#

I do know that for And it'll still check the second statement even if the first is false

native hemlock
#

From the wiki

["true  || { false  || {false}}", nil, 100000] call BIS_fnc_codePerformance;    // 0.00080 ms
["true  ||  {false} || {false} ", nil, 100000] call BIS_fnc_codePerformance;    // 0.00105 ms
["false ||   false  ||  false  ", nil, 100000] call BIS_fnc_codePerformance;    // 0.00123 ms
["true  ||   false  ||  false  ", nil, 100000] call BIS_fnc_codePerformance;    // 0.00128 ms
["false ||  {false} || {false} ", nil, 100000] call BIS_fnc_codePerformance;    // 0.00200 ms
tough moth
#

Hello, trying to make a simple script to make AI OPFOR aircraft find the nearest player, and issue a DESTROY waypoint on them.

this findNearestEnemy || addWaypoint "DESTROY";

Something like this, but I don't know how to translate that into something tangible. Any help much appreciated!!

mint smelt
#

Hello everyone, I'm having issues with a coding error adding a supply box for a custom faction. Removing the Class Box_NATO_ gives an error stating that the Class needs to be defined while, leaving the code gives an error stating that the member is already defined. Is there something I'm missing?

    class Box_NATO_Ammo_F; // CUP_USBasicAmmunitionBox
    class Box_NATO_Wps_F; // CUP_USBasicWeaponsBox
    class Box_NATO_Support_F; // CUP_USSpecialWeaponsBox
    class Box_NATO_WpsLaunch_F; // CUP_USLaunchersBox
    class Box_NATO_Uniforms_F; // CUP_USBasicWeaponsBox
    class B_SupplyCrate_F; // CUP_USVehicleBox

    class TA_O_WDL_AmmoBox : Box_NATO_Ammo_F {
        author = "Mik92";
        displayName = Custom Faction Ammo Box;
        class TransportMagazines {
            mag_xx(Chemlight_blue,50);
            mag_xx(MiniGrenade,50);
            mag_xx(rhs_mag_an_m14_th3,50);
            mag_xx(rhs_mag_m7a3_cs,50);
            mag_xx(rhs_mag_an_m8hc,50);
            mag_xx(rhs_mag_m18_green,50);
            mag_xx(rhs_mag_30Rnd_556x45_M855A1_PMAG,50);
            mag_xx(rhs_mag_20Rnd_556x45_M855A1_Stanag,50);
            mag_xx(RPG32_F,50);
            mag_xx(rhs_mag_M441_HE,50);
            mag_xx(rhs_mag_m713_Red,50);
            mag_xx(UGL_FlareCIR_F,50);
    //more mag_xx
        };
        class TransportWeapons {
        };
        class TransportItems {
        };
);
daring pawn
#

Have you defined mag_xx

mint smelt
#

I have defined mag_xx in the config.cpp```c
#define mag_xx(a,b) class xx##a {magazine = ##a; count = b;}
#define weap_xx(a,b) class xx##a {weapon = a; count = b;}
#define item_xx(a,b) class xx##a {name = a; count = b;}

runic quest
#

excuse me ,Who has some tutorials about The-Programmer mobile phones? tks!

winter rose
#

better chances on a Life Discord @runic quest

runic quest
#

@winter rose tks!

frigid raven
#

I had a crashdump and now a .mdmp file available. How to investigate this file?

winter rose
#

it's a memory dump (mdmp), I think only BI can but I might be wrong

still forum
#

only BI can

thorn saffron
#

Is there a way to play a voice line sound so the radio effects are applied? The radio protocol sounds do not have any radio effects baked in, so game has to add them on its own. Is there a way to use that in scripted voice lines?

winter rose
#

@thorn saffron well yeah, groupRadio, globalRadio etc

thorn saffron
#

I remember that in Contact when you got a message with some plot stuff it came through radio, but when I got close to the person saying it the radio effect was gone and it smoothly transitioned to direct speech

winter rose
#

I don't remember.

pseudo kernel
#

I have two arrays, both contain the same data, but in other order. How i can compare them? I tried sorting, but and then compare but with no success.

#

The only solution that comes to me, is to subtract them from each other, and then compare the differences in both cases.

winter rose
#

arrayIntersect

tough abyss
#

Compare how? What is the goal?

pseudo kernel
#

I want to force AI helicopter to wait for all players, before take off.

#

In addition, there is more than one vehicle.

tough abyss
#

So how do you want to compare arrays, give an example of content and expected comparison result

pseudo kernel
#

Ok, fixed, thanks for help.

_players = playableUnits select {alive _x && side _x == west};

(_cargoCrew arrayIntersect _players) isEqualTo _players```
#

The _cargoCrew includes all players, but with no order.

tough abyss
#

That won’t work

pseudo kernel
#

Or rather in the order they got in.

tough abyss
#

Both arrays should have same order and in your case it is not guaranteed

#

Seems like you want to know if all players are inside a vehicle

pseudo kernel
#

Vehicles*

#

playableUnits always has same order.

#
[a,B Alpha 1-1:2,B Alpha 1-1:3,B Alpha 1-1:4,B Alpha 1-1:5,B Alpha 1-1:6,B Alpha 1-1:7,B Alpha 1-1:8,B Alpha 1-1:9,B Alpha 1-1:10,B Alpha 1-1:11,B Alpha 1-1:12]```
tough abyss
#

Just iterate through all players and check if inside a vehicle and if any one is not, abort

errant jasper
#

(_players count {_x in vehicleA or _x in vehicleB}) == count _players

tough abyss
#

if (isNull objectParent _x) exitWith {...fail...}

eternal nexus
#

hello i search how to create a script to attach a trailer to a car

young current
#

how realistic you want it to be?

eternal nexus
#

if its possible most realistic

young current
#

no one has made very realistic trailer scirpts

#

they all have problems

eternal nexus
#

its not a probleme if its not most realistic if i can attach trailer and trailler can move and turn its good

young current
#

none of them turn very good.

#

this is perhaps the most advanced one

#

but it still has quite big flaws due to the game engine just not having enough features for this

#

you are not the first one to want make trailers

eternal nexus
young current
#

it is howver proven to be extremely difficult to make look good

eternal nexus
#

look at 2minutes

#

i search to do that

young current
#

that could be made with geometry pin and hole mechanic

#

its much older method

#

but does not work with AI

eternal nexus
#

the trailer have physic

young current
#

perhaps you need to ask those guys how they made it

eternal nexus
#

they don' t want to do that ^^

austere granite
#

all those scripted trailers look silly in MP

young current
#

Unfortunate side effect of life mods, they take but dont share. Then you proably just have to learn how the engine works and figure out a new solution

eternal nexus
#

yes

#

I think it's an axis that works behind the wheel and that the whole trailer is part of the axis can like the sterring

still forum
#

@errant jasper

(_players count {_x in vehicleA or _x in vehicleB}) == count _players
findIf would be much more efficient there

zinc pulsar
#

Im not sure if this is the right place but i need a bit of help.

#

Hello all....was wondering if i would get a bit of help. Im getting some Member already defined error pop ups on loadin....

These are the two that have the same (ExileClient_gui_selectSpawnLocation_show =)

ExileClient_gui_selectSpawnLocation_show = "xs\spawn\Overwrites\ExileClient_gui_selectSpawnLocation_show.sqf";

ExileClient_gui_selectSpawnLocation_show = "Custom\baserespawn.sqf";

my question is how do i remedy this? Do i combine these two into one something like this....

(ExileClient_gui_selectSpawnLocation_show = "xs\spawn\Overwrites\ExileClient_gui_selectSpawnLocation_show.sqf";, "Custom\baserespawn.sqf";)

https://i.imgur.com/xWUx8CA.png

https://gist.github.com/XCSVs/a25ef5f90eeba4ddd83de17dc4daa496

copper raven
#

if _cargoCrew holds units of "In addition, there is more than one vehicle.", then this will do:
private _areInside = playableUnits findIf {!(_x in _cargoCrew) && {side _x isEqualTo west}} == -1
@pseudo kernel

young current
#

@zinc pulsar you might get better answers in Exile discord

zinc pulsar
#

Yeah i already asked in there and not getting an answer....guess everyone is sleep. lol.

hallow mortar
#

So, I'm trying to use allowCuratorLogicIgnoreAreas to stop Zeus placing modules (the intended use of the command). According to the wiki, the command can only be executed on the server, so I've used an if isServer to ensure that happens. However, while it works fine in a local test, on a dedicated server it has no effect and Zeus can use modules freely. This seems...wrong.

rough heart
#

@zinc pulsar you post help questions without a rpt as what the rules in exile discord wants you to. I think that is why you aren't receiving much help.

zinc pulsar
#

There are no errors in my rpt ...that is why i did not post it...and thats not why nobody is responding. Dont be an ass hole.

rough heart
#

Error can be in either client or server rpt

zinc pulsar
#

Ive already fixed it myself by the way. So no help needed...thanks anyway.

rough heart
#

But then again, not my rules

zinc pulsar
#

Basically those 2 scripts are incompatible because the xs spawn includes basespawn so i just needed to delete the basespawn call.

tough abyss
#

Hey sorry about asking this but I am very new to scripting. Stuff like buildings, and world objects, I have it setup but every single time I start the mission the objects are still there. How do I make it so each and every single time I intialize the mission this script will be activated

hallow mortar
#

Any script called from init.sqf, or placed in a unit or object's Init line, should be run on mission start, every mission start.

#

But...your message doesn't make it quite clear what you're actually trying to do.

tough abyss
#

check your dms

tough abyss
#

hey, how could i record and show live stats of kills for a specific side within a running mission?

winter rose
#

with event handlers @tough abyss

tough abyss
#

yea that i got so far working

tough abyss
#

im using if (side _killer == west) then ...
is there some more elegant way to check if _killer side is not _killed side? sorry im a total noob in scripting

rotund otter
#

how do i find a range for an if statement?

#

example:

#
if (100 >= _myinteger >= 0) then
 {
hint "success";
};
astral dawn
#

uh? do you want your number to be within some interval?

rotund otter
#

yes

astral dawn
#

use an &&

rotund otter
#

thanks

astral dawn
#

if (_myNumber >= 0 && _myNumber <= 100) then {}

copper falcon
#

Hi guys, do you know if it's possible to trigger a hide/unhide animation on a weapon with a script ?

tough abyss
#

If model supports it, there will be hide/unhide animation you could trigger with animate or animateSource

heavy patrol
#

Hi there everyone, I'm having a bit of a trouble with a mission I'm making (I know it might not be the right channel, but my issue is about scripting a certain sequence at the start)
I need to make a AI entity attached to a tank, in sitting animation, arriving, then make the AI play the disembark animation and start briefing.

Here are my trouble :
-SetDir doesn't apear to work when under animation & attached
-When under the animation effect the entity will not move with the tank
-I tried using a chair to make it watch the correct orientation and follow with the tank. Only the orientation modification worked.

So I'd like a bit of help if anyone can help me doing this.
Here's a simplified pattern :

AttachTo Tank, orientated to the side > Sit animation > Tank advances > Tank stops > AI "disembark" animation > Start briefing.

spice axle
#

SetVectorUp and setVectorDown are the right ones for setDir

heavy patrol
#

I tried those too, didn't worked either for the player when under the animation effect, it somehow locks itself pointing towards the front of the object, I tried a bit with some memory point like a chair as reference, didn't changed anything. (I could be doing it wrong)

mortal wigeon
#

Is there a way to A) create a directional light via scripting or B) hide the GM spotlight w/o hiding the light effect?

young current
#

whats the thing you want to do?

mortal wigeon
#

Put a bigass spotlight on vehicles and turrets and such

dusky pier
#

hello, i'm trying to find ` key code but can't - arma kay codes page is not show

cloud thunder
dusky pier
#

ah, i find

#

sorry

#

i used that ```sqf
(findDisplay 46) displaySetEventHandler ["KeyDown", "hint str _this"];

cloud thunder
#

oh ` / tilde key , yeah didn't find it on that page either. Yeah its 41 . I don't remeber how to find the hex value though.

winter rose
#

@mortal wigeon maybe create a spotlight, then disable simulation of it and move it somewhere else

mortal wigeon
#

@winter rose If this is what you mean: I tried disabling sim on the GM searchlight and the light effect would remain in-place after that. I could move the model around with attachTo but the light effect stayed still.

winter rose
#

so it works?

young current
#

it doesnt if he wants to attach it to vehciles that move

winter rose
#

ah, that

#

yeah no

young current
#

Id wager you need your own invisible spotlight object for that kind of stuff

random estuary
#

Why not just create a lightsource and attach it?

young current
#

Attached objects dont rotate do they?

#

with animated parts that is

winter rose
#

lightsource is not directional

astral dawn
#

I'm reading on hash tables. Any idea what hash function is used in arma's mission namespace?

#

Or in these get/setVariable commands. I assume it's same.

quartz pebble
#

Guys, anyone knows a way to prevent player connecting to a specific UAV? I mean something other than:

while {true} do
{
    if !(isNull getConnectedUAV player) then
   {
       if (<player_is_restricted_to_connect>) then 
      {
           // do something
      };
   };
   sleep 10;
};
quartz pebble
#

@winter rose thx. That solves 80% of the task. The remaining 20% - is to make it work with JIP players. Think scanning all the ingame UAVs on JIP client side would do the trick.

winter rose
#

that or remoteExec with JIP

finite jackal
#

@mortal wigeon there is new directional light sources called reflectors with the newest Arma update, you can try to use that as a spotlight

still forum
#

@tough abyss

If model supports it, there will be hide/unhide animation you could trigger with
they can't support it, because you can't access them. Atleast unless simpleObj

#

@astral dawn It's in intercept, what do you need it for? Shall i find it for you?

weary yarrow
#

Hey guys, does anyone of you knows any way or hint on how I can get the type of a road. The data has to be somewhere (as the map can read it). I tried surfaceType and found out, that it refers to the ground under the road, I tried getting the width to find out all road segments are 10 meters width (at least all I tested). I just need something to sort "highways" from all other roads, more would be nice, but is not needed

young current
#

not really any engine mechanics for that I think

weary yarrow
#

None? I guess I am not the first one to get this info, noone ever really did it?

weary yarrow
#

I know about these, but they return the road object (or boolean for isOnRoad), none of them return the type of a road (main road, road and so on)

#

I want to know which kind of road I am having

winter rose
#

try checking the road config, idk if it is there such as path, road, highway etc

weary yarrow
#

Ok, I checked to config viewer and have not found a road config for the world data, but I may have missed it, where can I find it?

winter rose
#

somewhere in config, I don't know the config tree. use your google-fu on this one

#

with road position, direction, roadAt, you can assume the roads' width, for example, or directly the config value for the road segment. your call

weary yarrow
#

Thanks, I will have a look

copper falcon
#

@tough abyss I know do to that's with an object but here i talk about a weapon, i can't select the weapon as an object to trigger an animation with "animate" :/

random estuary
#
young current
#

Im a bit curious what that info can be used for. As I can think of anything that needs it

astral dawn
#

@weary yarrow check the link above (by The Tall Man), I give working code there to measure road width. We used that in the old antistasi.
There are many usages for that. We determined roadblock type to create them dynamically. Also now I use it to modify a cost-function in a custom A* algorithm to make AI prefer main road a bit more. Another guy used it in his A* for an addon which emulated GPS functionality for a user.

#

@still forum thx I'll try to find that. I was just curious, but now that I think of it, maybe with that knowledge I can generate collision-free hashes somehow.

young current
#

ah in that kind of stuff it does sound useful

still forum
#

maybe with that knowledge I can generate collision-free hashes somehow
If you want collision free stuff use something like sha256

astral dawn
#

Yes but I cant change the algorithm in arma. But thx I'll keep it in mind if I ever will need to choose a hash fn.

digital hollow
#

How should I check whether memoryPointsGetInCargo is typed as string or array? Could be defined both ways.

memoryPointsGetInCargo = "pos cargo";
memoryPointsGetInCargo[] = {"pos Cargo R", "pos Cargo L", "pos Cargo L", "pos Cargo R"};
digital hollow
#

Thanks. Hmm. But it's way slower than just using getText then checking with isEqualType. Guess I'll just do it the dumb way xD

astral dawn
#

I think getText can only get text

digital hollow
#

I meant isEqualTo ""

astral dawn
#

I don't do cfgs much but they should have more convenient scripted functions for getting cfg values

digital hollow
#

That is fancy! Good for readability, however literally 3x as long as doing both getText and getArray xD

weary yarrow
#

Hey @astral dawn :D Saw this thread earlier, but this roads are mostly 10 meters width (like all of them), but I think I found a way to determine the road type exactly. I am using it for an A* pathfinding too (trying to simulate attacks in Antistasi :D) , but I would like to have better data. Should I give you a message once I found a way, you may want it for Project 0?

astral dawn
#

Sure yes thank you!

#

My way is pretty inefficient, so how do you get road type?

winter rose
#

efficiently

weary yarrow
#

Lou Montana told me to check the road config of the map itself, there is a list which selects the type (1-7) for road indexes, and a file setting a name for every 1 - 7 type. I am currently working on a way to extract this, but I have to see how this works, as given is a four digit road index and roads are numbered by a six digit code

#

I expect something like four digit road index plus two digit segment index

astral dawn
#

Interesting

#

Thinking more of it, probably one can cache road types into an array

#

Or maybe into a namespace 🤔 should work too

weary yarrow
#

My system is caching most of the data, are you creating the grid on the fly?

astral dawn
#

I'm not doing it, another guy was doing it, I don't know exactly. I think he initializes road database at mission start.

mortal wigeon
#

@finite jackal I did some Googling but I'm not finding info on that. Got any pointers?

willow basin
#

Does anybody know if there is a way to prevent ACE3 from ignoring other Mods damage event handlers? I do nothing else but to return a reduced the damage value via handleDamage. But ACE3 simply ignores that :/ and according to their docs have no own eventhandler you can register for that. Heard that for some stuff they use CBA EventHandlers, are they maybe "at fault" or provide a solution here?

astral tendon
#

Is there a way to use doMove without have to remove the AI from their group? they will come back to their possition afther complete the doMove, I was thinking about use waituntil with the doMovecomplete but I don't want to spawn the code for a small thing like that.

astral dawn
#

Instead you can spawn one 'thread' which will monitor how your AIs are performing the doMove

#

But I agree it's a PITA
Maybe there's a way though, I am not sure

astral tendon
#

And that can get urgly if there is allow of units doing that

surreal peak
#

If I want code to constantly search for an object apearing (specifically the "simple object" of blood) I understand that it is a poor idea to use a while loop, is the best way to do this using event handlers?

#

I've never used event handlers but I have heard they are used for some senerios similar to this

astral dawn
#

yes, you either poll the game world for some event (periodic checks in an infinite loop), or use event handlers to make the game notify your code that smth has happened

tame socket
#

@surreal peak how will you be spawning the object?

surreal peak
#

The object just spawned in by ace when someone gets shot

#

Specifically there

tame socket
#

add a hit event handler to the units that you want to check the blood for, then you can simply use nearest object to find the blood like this (sorry ill read the script in a second)

_Unit AddEventHandler["Hit",
{
    params ["_Unit", "_Weapon", "_Damage", "_Shooter"];
    _Blood= NearestObjects [GetPos _Unit, ["BloodClassName"], 5];
}];
#

when a unit is hit it will check for the blood within 5 meters of the unit that was hit

surreal peak
#

ooo that sounds like a good idea

tame socket
#

should be efficient since it will only be checking when a unit is shot instead of continually checking a big area

surreal peak
#

so I just wana check, an event handler is a piece of code which will execute a piece of code whenever the thing it is checking for is fired

#

such as in this case, the code will execute when a "hit" is fired

tame socket
#

correct, for example this event handler is called Hit, so the code inside of {//here} when the unit that has this event handler is Hit which fires the event handler

#

if the event handler was called Fired, then the event handler would only run when the unit shoots, it just triggers some script to run when the specified event happens

surreal peak
#

What shouuld I do if I want every unit (player/non player, even those who spawn after code executes) to have the event handler?

tame socket
#

how are you spawning the units? what you could do for players is put the script in a sqf file called initPlayerLocal (this .sqf file runs automatically when a player joins the mission), if you have the players respawning then(depending on how you have their respawn set up) you would have to add the script to another .sqf file called onPlayerRespawn (this .sqf file runs automatically when a player dies and respawns)

surreal peak
#

Im planning on using this script for zeusing on a unit I play with so I cant edit the sqf files

#

All I can think of which will not harm server preformance that much would be using CBA framehandlers

#

and check every 30 seconds or so

tame socket
#

im unfamiliar with working with zeus, do you know if you are able to add script to an object as zeus?

surreal peak
#

you can edit an objects inits

#

and add scripts to that object

#

and with achilles there is an execute code module

#

which allows you to execute any sqf code as if it is in the console

tame socket
#

in the objects inits you could change _Unit to this(this refers to the objects whos init your in) and add the event handler to them that way. if you can use the achilles(again unfamiliar with it) to execute sqf code, you could do this

{
    _x AddEventHandler["Hit",
    {
        params ["_Unit", "_Weapon", "_Damage", "_Shooter"];
        _Blood= NearestObjects [GetPos _Unit, ["BloodClassName"], 5];
    }];
} ForEach AllUnits;
#

this will loop through all the units and add the event handler to them

surreal peak
#

That seems like a good idea, will there be any conflicts if I keep adding Event Handlers to the same unit?

tame socket
#

yes, heres how you can fix that

surreal peak
#

removeFrameHandler?

tame socket
#

so if you add an event handler twice to the same unit, it will fire twice since the unit has 2 event handlers on him. so what you can do is store the event handlers Index into a variable on the unit like this

{
    _x SetVariable ["HitIndex", -1, false];//false is whether or not its local or global
} ForEach AllUnits;

{
    if ((_x GetVariable "HitIndex" == -1) then
    {
        _Index = _x AddEventHandler["Hit",
        {
            params ["_Unit", "_Weapon", "_Damage", "_Shooter"];
            _Blood= NearestObjects [GetPos _Unit, ["BloodClassName"], 5];
        }];
        _x SetVariable ["HitIndex", _Index, false];//false is whether or not its local or global
    };
} ForEach AllUnits;```
surreal peak
#

Is setVariable a way to add a custom variable that is stored in the object it is set to?

tame socket
#

this create a variable on every unit spawned (you would want to add it in the initPlayerLocal for new joining players and or to respawning AI's inits(not sure how your mission is setup)
then it checks if the unit has an Event Handler (because of the HitIndex variable) and if its -1 then the unit does not have the event handler so it adds it, if its something other than -1 then it does not add the event handler since the unit already has the event handler on them

#

correct yes

surreal peak
#

sweet, thanks for the help! Can I put the _x setVariable ["HitIndex", -1, false];//false is whether or not its local or global in the other forEach allUnits loop

#

like I did here:

{
_x setVariable ["HitIndex", -1, false];//false is whether or not its local or global
    if ((_x getVariable "HitIndex" != -1) then
    {
        _Index = _x addEventHandler["Hit",
        {
            params ["_Unit", "_Weapon", "_Damage", "_Shooter"];
            _Blood= nearestObjects [getPos _Unit, ["BloodClassName"], 5];
        }];
        _x setVariable ["HitIndex", _Index, false];//false is whether or not its local or global
    };
} forEach allUnits;
tame socket
#

you wont want to do that as that would remove the point of the code shown above and it would make it so the event handler is always going to be added(btw i made an error and corrected it above, it should be == -1 not != -1)

surreal peak
#

ah I see

tame socket
#

so your checking if the unit has a variable that equals -1, if your setting the variable to equal -1 everytime then we wouldnt be able to determine if the unit has the event handler or not, make sense?

surreal peak
#

that is true

#

Thanks for the help! You've been awesoem

tame socket
#

np man, goodluck

tough moth
#

Anyone here have some experience with inidbi2 databases? having trouble getting one to read from the ini file.

astral dawn
#

I've had (a hard time) working with it once, a few years ago, probably I don't remember anything though

#

@rocky mortar might help you cause he made it 😄

tough moth
#

yeah, he's my buddy on steam but i think he's sleeping hehe!

#

ive got it writing perfectly to the ini file, but cant for the life of me figure out how to load it

#

I'll have to wait and hit up code34 when he's around next unless someone else wants to chime in!

astral dawn
tame socket
tough moth
#

@tame socket Hey man! was literally watching your videos! Mind if I PM you? Appreciate any help with this thing.

tame socket
#

for example, lets say you have a client and the server, the client wants to load in his old gear from when he last left the server(assuming it was saved). the client makes a call to the server, the server searches for that clients file, if found it sends the data the client wants back to him

#

sure

tough moth
#

awesome. thanks @astral dawn as well!

tough abyss
#

been trying to get my AddPublicVariableEventHandler to work on ALiVE Spawned units, any tips?

#

about to kill myself

#

been staring at this for about 4-5 hours lol

winter rose
tough abyss
#

Yeah I even did a post on the Alive thread to hopefully get a response, i've checked almost all forums _ i've tried loops i'm just not sure how to get it to run on spawned AI, eventhandlers sure but i've never messed with publicvariables - is it the same sort of deal

tough moth
#

all i know is we used it a while back to make civilians flee from nearby fire (before that was integrated into ALiVE)

#

function was in sqf run at startup, looked like this

#

_ai = _this select 0;

if ((side _ai == civilian) and (!isPlayer _ai)) then {
_ai addEventHandler ["FiredNear", {
_unit = _this select 0;
_gunner = _this select 7;

tough abyss
#

see the system i got is with the initserver.sqf

Playermoney = 0;

"PlayerKilled" AddPublicVariableEventHandler
{
Private ["_information"];
Private _PlayerMoneyBonus = 0;
_information = (_this select 1);
_unit = (_information select 0);
_unitside = side _unit;
_killer = (_information select 1);
_ClientID = Owner _Killer;
_distance = _unit distance _killer;

_PlayerMoneyBonus = _distance + 50 * 1.5;



PlayerClient = _PlayerMoneyBonus;
_ClientID publicVariableClient "PlayerClient";

} foreach Allunits;

#

I followed a tutorial since 'gotta learn somewhere' but still trying to get the basic idea

#

i just don't know how to transfer that into spawned AI

#

I even did the description Extended_Init_Eventhandlers but it just didn't seem to kick off

thorn saffron
#

Is there any way to do this in a less weird way? I basically want to check if X and Y are between select values, but when I tried min<X<max I got script errors when the X wasn't in the range.

if ((_minX<_Xpos) && (_Xpos<_maxX) && (_minY<_Ypos) && (_Ypos<_maxY)) the {}```
astral dawn
thorn saffron
#

nope, what you are linking is for trigger areas, I'm just checking a couple of numbers to see if they stay withing specified range

astral dawn
#

not really, it doesn't have to be trigger, it also works for numbers

#

_width = 20;
_height = 10;
[_x, _y] inArea [[_xMid, _yMid], _width/2, _height/2, 0, true]

#

Might be convenient in some cases (when you have (x, y) of center and width and height) and inconvenient in others...

thorn saffron
#

not feeling this one TBQH

astral dawn
#

alt syntax 3 I mean

#

🤷 whatever
your way is the proper one

twin steppe
#

Trying to make a texture marker on the map. Not working because I have no idea what I'm doing. Any help would be appreciated. Friend of mine helped me! The script under works!

#

EpicMarker = createVehicle ['Land_HelipadEmpty_F', [4159.83,5485.06,-185.933], [], 0, 'CAN_COLLIDE']; EpicMarker setPosWorld [4159.83,5485.06,-185.97]; [EpicMarker, [[0,1,0], [-0,-0,1]]] remoteExecCall ["setVectorDirAndUp", 0, EpicMarker]; EpicMarker enableSimulationGlobal true;

findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",
{

_this select 0 drawIcon ["\a3\UI_F_enoch\Data\CfgUnitInsignia\Astra_ca.paa", [1,1,1,1], getPos EpicMarker, 200, 200, 0, "ASTRA", 1, 0.04, "TahomaB", "right"];
}];

winter rose
#

Possibly, but I can't read plain text, only ```sqf
```

😉

weary yarrow
#

Hey, me again, I took Lou Mantanas hint from yesterday and searched the road config in the map files. I found two files in the road folder, called roads.dbf and roadslib.cfg. I parsed the roadslib to transform a road class to a road type like
Roadclass 5 => Main road
and used a external program to transfrom the roads.dbf into a sqf array looking like this

roadTypes = [[1100,3],[1102,3],[1104,3],[1106,3],[1108,3],[1110,3],[1112,3],[1114,3],[1116,3],[1118,3],[1120,3],[1122,3],[1124,3],[1126,3],[1128,3]];

holding the road index and the road class. So far so good, now I just got the road names like 165797 and 165796 (two connected roads) and assumend the first four digits are the road index and the last two are segment indexes. But there is the problem. The road index 1657 is not in the array, there is a difference of 507 to 657 between them.

There seems to be a offset between it, which is not even the same for every road. I assume it has something to with the layers that are in the roads.dfb (Roads, Path, City Road), but I don't know the offsets and have not found a way to get them. Does anyone knows these offsets or knows how to get these? I hope my question got clear, if not I can explain it further.

#

TL:DR I trying to connect a road segment with a number like 165797 to a road in roads.dbf looking like this 1150. There seems to be a offset I can get nowhere

winter rose
#

you will have to work with roadsConnectedTo

weary yarrow
#

roadsConnectedTo is getting the connected road segments (not really reliable tho), but I am trying to connect a road name, gotten by str _roadSegment, to an index from the roads.dfb file

winter rose
#

that's way too advanced for me, sorry!

weary yarrow
#

No problem

#

This may be something only the dev who wrote this can answer :D

still forum
#

what kind of offset?

#

position? something with 20k/200k?

weary yarrow
#

Each road segment on Stratis is numbered around 160000 +/-, last two digit are for the segment, not the road, so every road is numbered 1600+/-. The world data contains a file called roads.dbf with all road, but there they are numbered 1100 +/-, there seems to be a offset between file road index and world road index

#

I would send a picture but it is disabled on this channel as it seems

winter rose
#

(sparsely)

weary yarrow
#

Will do, posting only one should be ok,right?

winter rose
#

or one post with 3 screens, but not 1 every hour I suppose ^^

weary yarrow
#

Ok, but this one should be enough, it shows the roads.dbf and the four digit codes I assume are indexes for roads

#

I may be totally wrong and the number from str _roadSegment has nothing to do with the roads.dbf

quartz pebble
#

Guys, any way to get ArmA definition files, whose values are used in the game config?
I mean, in config one might see:

class SomeAwesomeTank
{
    scope = 2;
    access = 1;
    ...
}

I thought there must be human readable definitions of those fields values (scope, access, type and so on) somewhere in the game SDK.

exotic flax
#
// type scope
#define private             0
#define protected             1
#define public                 2

// type access
#define ReadAndWrite             0 //! any modifications enabled
#define ReadAndCreate             1 //! only adding new class members is allowed
#define ReadOnly             2 //! no modifications enabled
#define ReadOnlyVerified         3 //! no modifications enabled, CRC test applied
#

although most examples on BIKI also contains comments about what the values do...

quartz pebble
#
although most examples on BIKI

@exotic flax I couldn't find it all in one place. Is there a page I missed?

still forum
#

somewhere in the game SDK
There is no SDK

#

I thought there must be human readable definitions of those fields values
There aren't

still forum
exotic flax
#

sorry Dedmen 😉

quartz pebble
#

@exotic flax @still forum I saw that config reference pages. I was hoping there is something I could download and directly fetch in my code without writing it by hand.

exotic flax
#

Those definitions are only to make it readable, but are not a part of Arma itself.

quartz pebble
#

Apparently they do disappear after binarization and not shipped with the game.

#

But there could be a chance BI devs have shared something I missed🙂

exotic flax
#

makes sense, doesn't it 😉 binarization = binary = 0/1 😉

still forum
#

they are just enums

#

enums are represented as numbers in configs

errant jasper
#

Where do you need it? In game?? Just do something like
["private", "protected", "public"] select (getNumber (_myConfig >> "scope"))

quartz pebble
#
Just do something like

Also an option.

tough abyss
#

so the money system i was making doesnt actually work with multiplayer at all.. any suggestions?

astral dawn
#

Sure, if you provide some context on how it works @tough abyss

hollow lantern
#

is there an easy way to make an AI more aggressive? Aka I have a chopper (AH-1Z) that should attack a target, however it does not use it's full potential and instead shoots a few rounds with the gun (M197)

astral dawn
#

yes, reveal targets to it @hollow lantern

hollow lantern
#

I thought it would already know about it as I gave the eliminate order via ZEUS but sure can try that

solemn token
#
 it does not use it's full potential and instead shoots a few rounds with the gun (M197)

I think reveal would not help here. The AI already knows about the enemy... Otherwise he would not fire.
But I have no better idea, so try it out...

astral dawn
#

hmm 🤔 ask in #arma3_ai to raise the chance of getting a response

hollow lantern
#

I will try that with reveal, maybe he starts firing earlier because he knows earlier

astral dawn
#

can't really know the situation, but you probably know that thing when you send one bullet to a chopper, then he knows where you are and you are terminated within next minute...

hollow lantern
#

yeah target is a MIM-145

#

let's see

tough abyss
#

So I followed a tutorial that more or less does a publicvariable in the InitServer then it goes to the initplayerlocal and pretty much does the stuff locally i'm sure

#

I couldn't get it to work with ALiVE since it's just not wanting to work - but when I got somebody to jump on and test it - it just returns %any but it worked for me

#

I can link the tutorial if it helps, trying to learn this stuff a bit more rather than the basic stuff

astral dawn
#

I'd suggest you to make most, if not all, networking in your mission be based on remoteExecCall instead of publicVariable

#

would make debugging easier as well

#

as a bonus, you can still make things persistent and JIP-compatible with remoteExecCall

tough abyss
#

see that would be ideal

#

i'll try learn how to do that

#

presistence and JIP would be great aswell

#

Thanks Sparker

hollow lantern
tame socket
#

what tutorial did you watch? and you said it returns %any, what returns %any? is it a pile of money on the ground with a value set on it or is it set on a player or what

tough abyss
#

followed this one

tame socket
#

dats me 🙂

tough abyss
#

See it works perfectly fine on my end

tame socket
#

was curious. in the SetVariable, did you make the variable public?

tough abyss
#

I can paste it if you want?

tame socket
#

wait derp im thinking of something else

tough abyss
#

i mean its pretty much your script anyway right lol

tame socket
#

yes please

#

and also a quick explanation on what your goal is with the money

tough abyss
#

so i made like a bunch of case scripts so I could make players earn money to buy grenade launcehrs for weapons, upgrade vehicles and stuff along with selling and buying their kit from various laptops using the holdspace functions - but I was having issues with it working with ALIVE since it just doesnt record the deaths - but also when people join it doesn't work either - i might have slipped up but heres the scripts

#

initserver.sqf

"PlayerKilled" AddPublicVariableEventHandler
{
Private ["_information"];
Private _PlayerMoneyBonus = 0;
_information = (_this select 1);
_unit = (_information select 0);
_unitside = side _unit;
_killer = (_information select 1);
_ClientID = Owner _Killer;
_distance = _unit distance _killer;

_PlayerMoneyBonus = _distance + 50 * 1.5;



PlayerClient = _PlayerMoneyBonus;
_ClientID publicVariableClient "PlayerClient";

} foreach Allunits;

#

initplayerlocal.sqf

PlayerMoney = 0;

{
_x addeventhandler ["Killed",
{
_unit = (_this select 0);
_killer = (_this select 1);
_Instigator = (_this select 2);
PlayerKilled = [_unit, _killer];
PublicVariableServer "PlayerKilled";
}];

} forEach AllUnits;

"PlayerClient" AddPublicVariableEventHandler
{
_PlayerMoneyBonus = (_this select 1);
_Playermoney = Playermoney;
PlayerMoney = (PlayerMoney + 50) + _PlayerMoneyBonus;
hint format ["Player Wallet: $%1", PlayerMoney];
};

tame socket
#

ok so its just a basic (if player 1 kills player 2, give player 1 money) that your stuck on?

tough abyss
#

well I wanted it to be for AI since it's ALiVE

tame socket
#

gotcha, do you want it to work when players kill other players and AI or just when a player kills AI?

tough abyss
#

as much as i'd like it to be players and AI i'm going to say player kills AI

tame socket
#

not tested or anything but heres kind of how i would set things up since i like keeping everything i can on the server. this is using SetVariable and GetVariable to control the amount of Cash that is on the player and it is not exposed to the player either so this is stuff that you would want to run on the server (including the event handler and ControlPlayerCash Function). The server detects that a unit has been killed (since the killed event handler is on the server) so it calls the ControlPlayerCash function and passes in the killed unit and the killer. from there it simply adds 100 to the players cash and then prints a hint back to the player that is the killer telling him/her how much Cash he/she has

ControlPlayerCash =
{
    Params [_DeadUnit, _Killer];
    _KillersCash = _Killer GetVariable ["Cash", 0];
    
    _CID = Owner _Killer;
    //just to keep it simple for the example
    _KillReward = 100;
    _KillersCash = _KillersCash + _KillReward;
    _Killer SetVariable ["Cash", _KillersCash, false];
    
    [Format["You Have %1 In Cash", _KillersCash]] RemoteExec ["hint", _CID, false];
};

{
    _Unit = _x;
    _EHID = _Unit GetVariable ["KilledEHID", -1];
    if (_EHID == -1) then//meaning the unit does not have the killed event handler
    {
        _EHID = _Unit AddEventHandler ["Killed",
        {
            params ["_Unit", "_Killer", "_Instigator", "_UseEffects"];
            _Params = [_Unit, _Killer];
            [_Params] Call ControlPlayerCash];
        }];
        _Unit SetVariable ["KilledEHID", _EHID, false];//set the event handler ID on the unit
    };
} ForEach (AllUnits Select {!(IsPlayer _x)});//for all units that are not players
#

as AI respawn and such you can rerun the ForEach loop and it will add the event handler only to the AI that do not have the event handler already on them

hollow lantern
#

what's the right approach to check if a unit has a weapon? hasWeapon? aka sqf _x hasWeapon (getNumber (configFile >> "CfgWeapons" >> _x) == 2)

tough abyss
#

damn Cody thanks, thats incredible

tame socket
#

do you mean just check if a unit has any weapon at all?

hollow lantern
#

yes

#

aka sidearm / main / launcher

tame socket
#

im not 100% sure if this works on weapons in your weapon slots, but it should work on inventory. just Weapons, so

_WeaponList = Weapons _x;
if (Count _WeaponList > 0) then
{
    hint "HAS WEAPON";
};
hollow lantern
#

I'll give it a try now, thanks

tame socket
#

let me know if it works if you dont mind, hopefully it does so you dont need to iterate through the configs

hollow lantern
#

sure, loading my debug mission rn with it loaded

#

ah yeah 14:09:09 Error Undefined variable in expression: _x but I just fixed that like so: sqf _WeaponList = {Weapons _x} forEach allUnits;

#

seems to work then @tame socket

#

thanks

tame socket
#

sweet

frigid raven
#

Is there a way to call code before and after a function call? Like aspects?

tame socket
#

what do you mean exactly?

frigid raven
#

Well atm. I call code at the top of the function and at the bottom - I try to do some kind of function call stack

#

But I don't like to have this "meta" aspect in every function

#

I'd love to have it like hidden logic that nobody needs to care about when writing functions

#

cause it's always the same logic code

tame socket
#

no clue, also not entirely sure what a function call stack is lol

frigid raven
#

Well I want to know what functions are called in what order

#

So I made an array where in every function __FILE__ is called. At the end of that function I pop that entry so it's saying like "leaving this function". That way I wanna log the function call hierarchy/order

astral dawn
#

is it for debug? ADE has dump callstack command

frigid raven
#

ye debug - cause my client crashes at some point and I wanna see around what function that happens

astral dawn
#

or you could make some #define with a header and footer in each your function

frigid raven
#

maybe there are better ways - but I am already zoned into making that stack 😄

astral dawn
#

use Arma Debug Engine, it dumps callstack and all the local variables at each level!

frigid raven
#

@astral dawn already doing but i dont like the Footer part

#

Arma Debug Engine is working? Never used it 😄

astral dawn
#

I simply don't script without ADE any more, it's so useful for analyzing crashes, takes 10 seconds to understand what was wrong

#

ofc it is

frigid raven
#

ah really

astral dawn
#

typically after I notice that it's broken and I poke Dedmen and he repairs it, but still, use it while it's still operational 😄

frigid raven
#

ok will try out asap

#

thx for the headsup

astral dawn
#

just don't forget to disable BE
to quickly see if it works at all, use ADE_dumpCallStack SQF command

frigid raven
#

aye

#

Started with some kind of warning popup

#

think that's normal eh

astral dawn
#

yes it is

frigid raven
#

@astral dawn where did you got that dumpCallStack API from

#

cant find it here

astral dawn
#

🤷 I think Dedmen told me about it

frigid raven
#

hm

#

unfortunately this function is breaking my logic

astral dawn
#

it can't
anyway, it will dump callstack automatically on any script error

#

BTW if you still want to add your code to start and end of each function, you can iterate through allVariables of missionNamespace, search for those which are code, covnert it to string, append your logic to start and end, then compile it back

#

I tried it and it fucks up line numbers unfortunately

frigid raven
#

well they are fucked up anyway lel

#

but that's nice hacky way

#

u described

#

will try that 😄

astral dawn
#

actually no, it will only work for adding header to functions

#

because they might exit with exitWith{}

#

actually yes, you can wrap old function into a call{} somehow and see what it returns...

frigid raven
#

well even if it exitsWith it still exits normally doesnt it? so after the func call I can still do some logic

frigid raven
#

is there a way to add a string to another string at a specific index?

#

like insertAt

astral dawn
#

Probably only through toArray and toString

frigid raven
#

alrighty

astral dawn
#

BTW I am not sure if you can overwrite functions made with compileFinal or with the cfgFunctions

hollow lantern
#

I have lost the faith in Arma AI. Two AH-1Z Viper approach a SAM site and instead of eliminating the radar, they fire two rounds with their main canon on that radar and nothing. They are even 10m away from that radar. So reveal didn't helped that much. Maybe if I increase the range from 4 to something higher but xdoubt

astral dawn
#

or maybe there was some flag somewhere... can't remember

#

what range @hollow lantern ?

#

ah, the reveal parameter

hollow lantern
#

had 4, testing with 20 now

astral dawn
#

but it's allright, almost everyone who has ever tried to make arma AI do something has lost faith in it at some point, typically within first several hours

hollow lantern
astral dawn
#

I recall seeing some mod somewhere which adds an invisible vehicle at which AIs are very likely to shoot

hollow lantern
#

lol interesting idea

frigid raven
#

@astral dawn are all cfgfunctions compiled with compileFinal ?

astral dawn
#

I don't remember, need to read the cfgFunctions wiki page

#

you can try to overwrite some existing function of yours or BIS and see if it works

tough abyss
#

_WeaponList = {Weapons _x} forEach allUnits;
seems to work then
This will only return weapons of the last unit in the allUnits array. What is the point?

native hemlock
#

@weary yarrow I don't think you are going to be able to translate an object ID to something related to the shapefiles. In A3 they added the ability to define roads on a terrain as shapefiles, instead of individual road objects/models. However if you provide a shapefile, the game will automatically split it up into different road objects/models on its own.

If you write a script to count the number of objects on Stratis it should come out to 163952. Then if you searched through all the road object IDs, the lowest one you should find is 163953. Meaning the road object IDs start immediately after the normal map object IDs. The number you have there (165797) is the object ID of that specific piece of road. You might be able to reverse engineer the logic of if there is a connection between which road has the first ID and some value in the shapefile or similar files, but I don't think you can go much further. It might not even be possible to figure out how many different objects will be created from a given shapefile because of the length between points and the angle between the points.

tame socket
#

@tough abyss i think he possibly missunderstood the point of the foreach loop? it sounds like he doesnt need it at all but idk what hes trying to do

tough abyss
#

@tame socket I got the loop to work, I keep getting an error but with the first params [_deadunit, _killer]; but i've noticed if i put "_deadunit" and "_killer" - I had a Scalar Nan error, but without them - i get a error with the params and it doesnt save money

tame socket
#

@tough abyss just got home, ill test it here in a bit

#

@tough abyss wait derp i see a mistake, in the function call, pass in _Unit and _Killer as separate parameters so

[_Unit, _Killer] Call ControlPlayerCash];
royal marten
#

Hey I am looking for a script that plays a sound(Sound.Ogg) at certain time of day every day?

#

Any tips?

weary yarrow
#

@native hemlock That was obviously not the answer I was looking for, but nevertheless thank you for it. I feared the id's could be unrelated, but hopped they weren't. So basically, as long as I don't want to parse the shape file, the only option would be to mark the streets manual

tame socket
#

@royal marten this should play a sound globally for all clients to hear if they are within 100 meters of wherever the sound is playing. Change whateverTimeYouWantDuringTheDayToPlay to the time of day you want the sound to play in a 24 hour format. You want this to run on the server

_TimeToPlaySound = whateverTimeYouWantDuringTheDayToPlay;

While {true} do
{
    if (DayTime >= _TimeToPlaySound && DayTime < _TimeToPlaySound + 0.1) then
    {
        _DistanceSoundCanBeHeardInMeters = 100;
        _Pitch = 1;
        _IsSpeech = false;
        [_Position, ["SoundName", _DistanceSoundCanBeHeardInMeters, _Pitch, _IsSpeech]] RemoteExec ["say3D", 0, true];
    };
    Sleep 60;/check once a minute
};
tame socket
#

like this?

{
    _Unit = _x;
    
} ForEach (AllUnits Select {(Group _x) == (Group Player)});
#

nvm you removed the question lol

tough abyss
#

Thanks Yes ive find what i want ```sqf
((crew vehicle player) select {(group _x isEqualTo group player)}) apply {name _x};

tame socket
#

that looks cleaner lol

still forum
#

@frigid raven that API command documentation is only for the json network api.
the script command is just a command.
ACE does callstacks by wrapping all their function calls in a macro, which then adds header/footer at call site.

unfortunately this function is breaking my logic
what mean?

are all cfgfunctions compiled with compileFinal ?
Yes unless you enable allow recompile

frigid raven
#

@still forum so when recompile is allowed I can recompile them? That would be cool cause I just need it to work on my local environment

#

unfortunately this function is breaking my logic
what mean?
Hard to explain tbh I added that command at the top of one of my Dialog Handlers. The dialog handlers screwed up afterwards. BUT I have to say that I use @queen cargo 's promise script which does some callback stuff. I can't tell if it's screwing up because of that. I stopped investigating and kept following my approach cause I felt it being simpler for me to use for now.

still forum
#

command shouldn't do anything besides freeze the game for a short moment to dump the callstack to RPT 🤔

queen cargo
#

do not bring me into this @frigid raven :D
i not even have any idea what you guys are talking about

winter rose
#

you did it

random estuary
#

Is there a command or workaround for aimPos/unitAimPositionVisual (which seems to return unit eye pos and scope pos), where it returns muzzle position?

still forum
#

aimPos is just center of body I think? It's the point AI's should preferably aim on

#

Don't know a way to get muzzle position, besides grabbing the players hand memory point and guesstimating from there

#

maybe you can spawn the weapon as simple object, and then get it's muzzle memory point, and the offset to the position where the hand is attached, and then use that to work from hand to muzzle

random estuary
#

What i'm trying to do is create a fired EH, that if the unit is poking their weapon through a wall and there's an object intersecting, to delete the projectile. All the current commands return points which are behind the muzzle, by which time, the weapon can fire through the object. I'm running this to show the intersected object

if(lineIntersects[eyePos player, unitAimPosition player])then
{
    [parseText format["<t size='0.9'>%1</t>",cursorObject],0,-0.2,5,0] spawn bis_fnc_dynamictext;
};```
tough abyss
#

You can try maybe intersect back from fired bullet to check if there is a surface between player and bullet

random estuary
#

That I fear would be a lot of heavy lifting to do codewise

tough abyss
#

Try checkvisibility

#

If bullet cannot see player he must be on the other side of the wall then

frigid raven
#

@queen cargo did u ever noticed that your discord ID is #1337 ?

queen cargo
#

😏

#

Discord Nitro baby

random estuary
#

@tough abyss Will try that but I think it will still be enough for the unit to "poke" the muzzle through the wall to fire

tough abyss
#

What do you mean?

random estuary
#

The bullet can see the target as the bullet is already on the other side of the wall. Using

if(lineIntersects[eyePos player,aimPos player])then
{
    [parseText format["<t size='0.9'>%1</t>",cursorObject],0,-0.2,5,0] spawn bis_fnc_dynamictext;
};```
does, for the most part detect an object but there's a few cm where it doesn't and the weapon can fire through the object.
#

I guess I could create a position a few cm in front of the player and use that instead

still forum
#

The bullet can see the target
He said see the player, the shooter, not the target

tough abyss
#

I never said anything about bullet and target

still forum
#

however checkVisibility might fail if you shoot from inside a smoke grenade?

#

if(lineIntersects[eyePos player,aimPos player])then Just use eyePos plus viewDirection * 1 meter
a gun will probably not be longer than a meter?

tough abyss
#

It might not be visibility 1 but could be >0

random estuary
#

This works

_aimPos = aimPos player;

_aimPosX = _aimPos select 0;
_aimPosY = _aimPos select 1;

_aimPosX = _aimPosX +0.43;
_aimPosY = _aimPosY +0.43;
_newAimPos = [_aimPosX,_aimPosY,_aimPos select 2];

if(lineIntersects[eyePos player,_newAimPos])then
{  
    [parseText format["<t size='0.9'>%1 aim pos %2</t>",cursorObject,_newAimPos],0,-0.2,2,0] spawn bis_fnc_dynamictext;
//and do something here
};```
still forum
#

_aimPosX = _aimPosX +0.43;
_aimPosY = _aimPosY +0.43;

but that might be behind the player, or to the right, or front, or left

#

_aimPosX = _aimPos select 0; _aimPosY = _aimPos select 1;
params
_newAimPos =
vectorAdd
if(lineIntersects[eyePos player,_newAimPos])then
doesn't that detect bushes too? I think shooting through a bush is legit

random estuary
#

I can add a check for object type

still forum
#

aimPos btw returns the memoryPointAim from config

#

I think it might be better to just use the torso if you really don't want to just use eyepos

#

nah actually you are using eyepos.

#

so why aimPos too?

random estuary
#

To see where the unit is aiming

#

nm, should be eyePos i'm adding x and y to

astral dawn
#

@tough abyss that should be redirected to @hollow lantern I think

hollow lantern
#

interesting

#

will try that once I'm home

#

thanks @astral dawn & @tough abyss

wary vine
#

trying to save positions relative to an object as an array, so I can use those positions with multiple buildings of the same types with simple objects.

private _positions = [];
    private _building_classname = "Land_Offices_01_V1_F"; 
    private _building_position = [5483.62,1749.19,-0.0141573];

    private _bank_building = nearestObject [_building_position, _building_classname];

    [
        safe_1, safe_2, safe_3, safe_4
    ] apply 
    {
        _positions pushBack [(_bank_building worldToModel (getPos _x)), (getDir _bank_building) - (getDir _x)];
    };

    copyToClipboard str _positions;
``` is what im using to output the positions.

```sqf
[
    [[8.7031, 7.32751, -7.98319], 0],
    [[9.6826, 7.33655, -7.99525], 0],
    [[11.325, 7.35791, -7.98647], 0],
    [[12.269, 7.37805, -7.99566], 0]
] apply 
{
    _x params ["_position", "_direction"];

    private _spawnPosition = _bank_building modeltoworld (_x select 0);
    _safe = "Lega_Safe" createVehicle _spawnPosition;
    _safe setPosATL _spawnPosition;
    _safe setDir (getDir _bank_building) + (_x select 1);
};
``` is what im using to spawn them back in , but its never on the same position, most of the time, it spawns in the floor of the building. any help would be greatly appreciated.
still forum
#

why are you using ATL with a AGL position?

#

Just use modelToWorldWorld and use setPosWorld

still forum
#

have you tried just logging if the positions you get out are the same on input/output?

wary vine
#

will try that now.

still forum
#

also you are using getPos on the worldToModel, which returns PositionAGLS.
While worldToModel takes PositionAGL.

#

AGLS takes the surface into account, the objects between terrain and the object. In your example the building and the table

#

that could throw you off

wary vine
#

that could be it.

#

so I need postion not getPos right ?

still forum
#

yeah

wary vine
#

only seems to be a 0.01 difference in height.

winter rose
#

… position == getPos ?

still forum
#

no

winter rose
#

wiki says so (and I am not the author)

still forum
#

maybe getPosASL and ASLtoAGL.
Or just don't use worldToModel at all and instead do a manual vectorDiff

wary vine
#

[8.61523,7.33801,-7.97743] position
[8.7031, 7.32751, -7.98319] getPos

still forum
#

no
oops

#

or ASLtoAGL getPosASL
🤔

winter rose
#

dat pos sh*t :D
I had the same issue spawning furnitures according to the model, but I finally got it sorted
I am not home though

wary vine
#

Yeah I did it a long time ago for a similar script,

#

pity i didn't save the function I used to export the positions.

#
    //Spawn teh safe
    private _spawnPosition = _thisBank modeltoworld (_x select 0);
    private _thisSafe = "Lega_BankSafe" createVehicle _spawnPosition;

    //move teh safe.
    _thisSafe setPosATL _spawnPosition;
    _thisSafe setDir (getDir _thisBank) + (_x select 1);
``` i just have this left from spawning them back in
#

i think I got it.

winter rose
#

ping me in ~5h if you don't figure it out before

wary vine
#

Output positions

    private _positions = [];
    private _building_classname = "Land_Offices_01_V1_F"; 
    private _building_position = [5483.62,1749.19,-0.0141573];

    private _bank_building = nearestObject [_building_position, _building_classname];

    [
        safe_1, safe_2, safe_3, safe_4
    ] apply 
    {
        _positions pushBack [(_bank_building worldToModel (ASLtoAGL getPosASL _x)), (getDir _bank_building) - (getDir _x)];
    };

    copyToClipboard str _positions;
#

Spawning them back in

private _safe = objNull;
private _building_classname = "Land_Offices_01_V1_F"; 
private _building_position = [5483.62,1749.19,-0.0141573];

private _bank_building = nearestObject [_building_position, _building_classname];

[[[8.6709,7.24011,-6.19784],-0.00293326],[[9.74805,7.2771,-6.19782],-359.999],[[11.2739,7.31226,-6.19784],-2.54479e-007],[[12.291,7.34351,-6.19677],-359.992]] apply 
{
    _x params ["_position", "_direction"];

    private _spawnPosition = _bank_building modeltoworld  (_x select 0);
    _safe = "Lega_Safe" createVehicle _spawnPosition;
    _safe setPosATL _spawnPosition;
    _safe setDir (getDir _bank_building) + (_x select 1);
};
#

tyvm @still forum @winter rose

quartz pebble
#

Guys, do simple objects support setObjectTexture ?

still forum
#

afaik yes

quartz pebble
#

I hope so, as I coudln't make it work so far.

arctic quest
#

check the objects config. if it doesnt have hiddenselections you cant use setObjectTexture

quartz pebble
#

@arctic quest thx. That was it.

tough abyss
finite dirge
#

That is legit impressive.

tough abyss
#

@tame socket I got it working to some degree - it works pretty smooth - the only issue now is the money isn't saving? so it'll say you have 100 in cash but when I do the hint after 3 kills it just tells me I have any in cash - like its not recording - I'll try messing with it but it's just that last hurdle for me - thanks for the help!

hollow lantern
#

this works in a trigger but not in a script, ideas? sqf { if ((side group _x) != US_GEN call BIS_fnc_friendlySides) then {} } forEach allUnits;

still forum
#

Absolutely zero ideas

#

but that doesn't seem to be the full script?

hollow lantern
#

haven't written anything yet, about to start. Just tested this code block.

#

the error is sqf if (( side group _x) != US_GEN call BIS_fnc_friendlySides) th> 12:03:40 Error position: <!= US_GEN call BIS_fnc_friendlySides) th> 12:03:40 Error !=: Type Array, expected Number,String,Not a Number,Object,Side,Group,Text,Config entry,Display (dialog),Control,Network Object,Team member,Task,Location 12:03:40 File c:\users\aebian\documents\arma 3\missions\thelab.tanoa\initServer.sqf..., line 67

#

the condition works in a trigger

#

just not if I try to use it in a if

#

ah probably because BIS_fnc_friendlySides returns an array

astral dawn
#

BIS_fnc_friendlySides returns an array

#

if ( ! (( side group _x) in (US_GEN call BIS_fnc_friendlySides)) then {};

#

use the in operator, probably that's what you want

hollow lantern
#

ah

still forum
#

the condition works in a trigger
sounds like it doesn't

hollow lantern
#

it does

#

I test that

astral dawn
#

it has no right to work there, can't compare a side and an array 🤷

still forum
#

it working makes no sense

astral dawn
#

maybe it returns nil or some garbage and somehow the trigger gets triggered 😄

hollow lantern
#

hmm yeah because the SAMs start their fire

#

but I'll fix that, thanks

tough abyss
#

@hollow lantern

Syntax:
toCheck call BIS_fnc_sortAlphabetically
Parameters:
toCheck - Side or Object: Side or object whose friendly sides should be returned
Return Value:
Array of Sides
#

Return Value:
Array of Sides

#

there is no way it worked in script

still forum
#

BIS_fnc_sortAlphabetically wat

tough abyss
still forum
#

wat

#

🤣

astral dawn
#

wat 😮

hollow lantern
#

typos ftw

astral dawn
#

example though player call BIS_fnc_friendlySides; // can return [FRIENDLY,WEST,GUER,CIV]

still forum
#

@cosmic lichen why? 😄

tough abyss
#

OMG he is gonna say it wasnt him

thorn saffron
#

"ItemGPS" isKindOf "ItemGPS" gives me false

#

I want to check if unit has either GPS or any kind of UAV console. I thought that the isKindOf will be able to handle this.

tough abyss
#

main and alternative syntaxes support only CfgVehicles, CfgAmmo and CfgNonAIVehicles ItemGPS is CfgWeapons

thorn saffron
#

derp

winter rose
#

@thorn saffron alt syntax 2 allows you to check iirc

tough abyss
#

there is even an example

thorn saffron
#

For some reason I have troubles getting this to work:

_assignedItems = (assignedItems player); 
   _hasGPS = false; 
   _hasRadio = false; 
   { 
    if ("ItemGPS" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)) then {_hasGPS = true;}; 
    if ("UavTerminal_base" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)) then {_hasGPS = true;}; 
    if ("ItemRadio" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)) then {_hasRadio = true;}; 
   } forEach _assignedItems;
systemChat format ["Has GPS/UAV console: %1",_hasGPS];
systemChat format ["Has Radio: %1",{_hasRadio];
winter rose
#

privaaate

thorn saffron
#

I was running the code through console, privates usually dont work there for some reason

spice axle
#

it work there

thorn saffron
#
private _assignedItems = (assignedItems _unit);
private _hasGPS = false;
private _hasRadio = false;
{
 switch (true) do {
    case ("ItemGPS" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)): {_hasGPS = true;};
    case ("UavTerminal_base" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)): {_hasGPS = true;};
    case ("ItemRadio" in ([(configFile >> "CfgWeapons" >> _x), true] call BIS_fnc_returnParents)): {_hasRadio = true;};
     };
} forEach _assignedItems;```
tough abyss
#
if ([player, "ItemGPS"] call BIS_fnc_hasItem) then {hint "Fuck me, you have GPS!"};
thorn saffron
#

wrong

#

I used the assignedItems, as I want to check if GPS is equipped

spice axle
#

it works for me
be sure private _assignedItems = (assignedItems _unit); that _unit is defined for debug console type private _unit = player; or private _assignedItems = (assignedItems player);

tough abyss
#
if (assignedItems player findIf {_x == "ItemGPS"} > -1) then {hint "Fuck me, you have GPS and it is equipped!"};
thorn saffron
#

oh that findIf command is nifty, I never knew it was a thing

exotic tinsel
#

is there a way to get the name of the function you are executing code in? its for error handling. i have something causing a generic error some where so i want to put something at the top of a bunch of functions that is general to fire before the error so i know where it happened. im trying to avoid going to each function and putting something at the top that is specific for the function. i just want to do a mass find and replace.

winter rose
exotic tinsel
#

@winter rose thx mate

finite dirge
exotic tinsel
#

@winter rose would this work?

#

params ["_client_id"]; diag_log _thisScript;

winter rose
#

_thisScript is the script handle, it might output the whole content

#

_fnc_scriptName for functions, or as @finite dirge mentioned, scriptName

exotic tinsel
#

_fnc_scriptName?

winter rose
#

this will return the BIS_fnc_pinkRabbit format yes

exotic tinsel
#

yeah i got it from there but visual code is throwing error saying undefined variable.

finite dirge
#

Yeah, ignore those / don't use the error checking parts of things. It is undefined in that scope, it's MAGIC.

exotic tinsel
#

rgr

#

testing now

#

awesome, just what i needed. you guys rock

winter rose
#

👍

#

can someone test configNull == configNull for wiki purpose please?

astral dawn
#

true

winter rose
#

Danke Schön!

#

it seems it's one of the rare, if not the only one, to be able to compare to itself!

astral dawn
#

Even in SQF-VM it's true 💌

winter rose
#

@queen cargo it's aliiiiiive! and it works Ö

queen cargo
#

Obviously sqf-vm is correct 🤔

winter rose
#

^^

queen cargo
#

(tbh... Think there is no testcase yet)

frigid raven
#

I have an experiment where I want to enrich a function by aspects at the beginning of the call and at the end.
This is teh logicz so far:

    private _beforeAspect = "call coopr_fnc_recordFuncCall;";
    private _afterAspect = "call coopr_fnc_recordFuncCall;";
    //private _cooprFunctions = allVariables missionNamespace select {["coopr_fnc_", _x] call BIS_fnc_inString };
    private _functionString = str (missionNamespace getVariable "coopr_fnc_getSkills");
    private _functionStringAsArray = toArray _functionString;
    // stripping { and }
    _functionStringAsArray deleteAt 0;
    _functionStringAsArray deleteAt (count _functionStringAsArray) - 1;
    // add aspects

   private _enrichedFunction = [_beforeAspect, toString _functionStringAsArray, _afterAspect] joinString "";
   _enrichedFunction;

   missionNamespace setVariable ["coopr_fnc_getSkills", (compile _enrichedFunction)];

Now the main problem (already assumed by @astral dawn ) is that the _afterAspect is badly positioned at the end of the function call. Because it is preventing a return value.
Any ideas how to workaround that? String processing with SQF is a pain and I will not include some Regex Mod to have an easier approach here. Maybe you guys have a nifty hack to get that working. What I mean is a way to locate the last statement of an SQF script as safe as possible and therefore placing the _afterAspect before that statement.

PS: I know there is also an issue with exitWith returns. But I will focus on that later

astral dawn
#

sure, you must wrap the inner code into a call {}

frigid raven
#

and safe the return value?

astral dawn
#

it will also solve that

frigid raven
#

and then call teh afterAspect and after that return the value?

#

Fun fact just as you started to type I remembered u mentioned that wrapping call 😄

#

and a 💡 appeard

astral dawn
#
< we put header here>
private __ret = _this call {
(inner code which we don't modify)
(inner code which we don't modify)
if (true) exitWith {-666}; // Look, we can return that too!
(inner code which we don't modify)
};
<we put footer here>
__ret // now we return whatever the inner code piece wanted to return
frigid raven
#

gotya

astral dawn
#

You've got to check what happens if your function returns nothing though (nil or nothing), it might start b****ing that __ret is undefined or whatever, it can get tricky

frigid raven
#

Will see

astral dawn
#

but really, could you maybe replace all your calls to your functions with some macro of yours, which calls footer, calls your code, then calls the header?

hollow lantern
#

I have an array with objects inside. I'm currently struggling what would be the best way to make the switch statement work because side obviously doesn't like arrays. Should I split the input array or what would you guys do? Code is ```sqf
params["_weapons"];

switch (side _weapons) do
{

    case independent: 
            { 
                    
                { createVehicleCrew ("I_TargetSoldier" createVehicle (getPos _x)) } forEach _weapons; 
                    
            };
    

    case west: 
            { 
                    
                { createVehicleCrew ("W_TargetSoldier" createVehicle (getPos _x)) } forEach _weapons; 
                    
            };


       case east: 
            { 
                    
                { createVehicleCrew ("O_TargetSoldier" createVehicle (getPos _x)) } forEach _weapons; 
                    
            };

}; ```
astral dawn
#

you are doing

switch (side ARRAY) do {};
#

side command doesn't accept an array

winter rose
#

nor weapons do have sides 😄

hollow lantern
#

I just stated that above

astral dawn
#

well it's up to him to make variable names 🤷 but as I see _weapons is an array of objects

hollow lantern
#

stated that as well

#

yes

#

Quote me: I'm currently struggling what would be the best way to make the switch statement work because side obviously doesn't like arrays. Should I split the input array or what would you guys do

winter rose
#

forEach?

astral dawn
#
{ // forEach _weapons
    private _side = side _x;
    switch (_side) do {
        case west: {  };
        case east: { createVehicleCrew ("O_TargetSoldier" createVehicle (getPos _x)); };
        default {}; // Aliens
    };
} forEach _weapons;
winter rose
#

(but _weapons is really a wrong var name in this matter)

hollow lantern
#

well depends. Objects are a SAM Launcher and a SAM Radar

astral dawn
#

This discussion belongs to #style_discussions 😄 oh wait we don't have that

winter rose
#

no moar channels plz

astral dawn
#

no moar channels plz
#new_channels_discussion

winter rose
#

my bad then @hollow lantern ; may I suggest _samSite?

#

but what Sparker said (the forEach code, not the #new_channels_discussion!!)

frigid raven
#

@astral dawn

but really, could you maybe replace all your calls to your functions with some macro of yours, which calls footer, calls your code, then calls the header?
I could but I might wanna build a little aspect adding function for other cases, too.

hollow lantern
#

hmm yeah probably need to learn more to use forEach, I'll test that right away, thanks

astral dawn
#

I'd even suggest this @hollow lantern

{ // forEach _weapons
    private _objectHandle = _x;
    private _side = side _objectHandle;
    private _className = switch (_side) do {
        case west: { "B_TargetSoldier" };
        case east: { "O_TargetSoldier" };
        default { "UFO_Soldier" }; // Aliens
    };
    createVehicleCrew (_className createVehicle (getPos _objectHandle));
} forEach _weapons;
hollow lantern
#

uh oh ok, interesting

astral dawn
#

Or even this 🤔

{ // forEach _weapons
    private _objectHandle = _x;
    private _sideID = [WEST, EAST, INDEPENDENT] find (side _objectHandle);
    if (_sideID != -1) then { // Sanity check
        private _className = ["W_TargetSoldier", "O_TargetSoldier", "I_TargetSoldier"] select _sideID;
        createVehicleCrew (_className createVehicle (getPos _objectHandle));
    };
} forEach _weapons;
hollow lantern
#

woah lol, smartmind

astral dawn
#

hahaha if someone makes one better iteration of this, we can make a meme 😄

#

maybe something like

{
 [side _x, getPos _x] call CBA_fnc_createInvisibleTarget;
} forEach _weapons;

If there was such a CBA command

hollow lantern
#

would buy it /s

#

but yeah I use CBA in my test mission as well so it would work if there was one

heavy patrol
#

Hi, I would like to ask about moving an animated entity while it's attached to a vehicle, and this vehicle moves.
As far as I've tried, the entity stays at the position where it was attached at the start when the vehicle moves. (and so not being "attached" anymore and just standing in the air)
Anyone got a way to script that properly ?

winter rose
#

like moving in the back of a driving truck, or just moving as "placing it somewhere else"?

astral dawn
#

There was a mod for walkable moving ships or something liek that

#

I think he was messing with attachTo, not sure

heavy patrol
#

More like Character is atop a tank, sitting animation, tank moves, guy plays the dismount animation, starts talking.
Thing is, character is in sitting animation, tank moves, guy stays in mid air instead of staying on the tank

#

I also was not able to change it's orientation and had to use a chair, but ended with the same issue.

astral dawn
#

well why don't you do attachTo?

heavy patrol
#

that's what I use sir

#

that's the issue

astral dawn
#

hmm weird!

heavy patrol
#

yup

astral dawn
#

what if you do attachTo on each frame then, while the animation is playing?

heavy patrol
#

and yes, I tried using setDir and the other one specially made for attachTo

#

mmmm

#

that could work

#

though I have no idea how to make a loop in Arma's synthax

#

hopfully it's only at the start, so I guess ressource wise it's all good

astral dawn
#
addMissionEventHandler ["EachFrame", {
    // no params
}];
heavy patrol
#

Ho, I was looking for a simple DoWhile, but this seems perfect ahah.

astral dawn
#

no no, where would you put the while-do{} ?

#

in a spawn? should not put that into a spawn

heavy patrol
#

I'd figure out something I guess

winter rose
#

…show us your attachTo code and surroundings

astral dawn
#

Yeah maybe it's not attaching anything at all? 🤔

heavy patrol
#

Hol' on

#
Cmd switchMove "Acts_NATOCommanderArrival_Commander_1";
Sleep 2;
detach Cmd;

Cmd switchMove "Acts_NATOCommanderArrival_Commander_1";
Cmd playMoveNow "Acts_NATOCommanderArrival_Commander_2";
astral dawn
#

I think you need to switchMove into some animation the AI can get out

#

like the generic walking animation

#

like if you add Cmd switchMove "AmovPercMstpSrasWrflDnon"; at the end, he will be able to recover from his animation

#

but I don't know animations, better ask in #arma3_animation maybe?? AFAIK a limited set of animations has transitions to other animations, and if there is no available transition, character gets stuck.
Correct me if I'm wrong.

heavy patrol
#

I actually tried with the combat ambient anim "sit"

#

Like just for bug test, it's not that the animation doesn't play, it's that, it doesn't stick with the moving object despite being attached to it

#

but when not animated, it keeps attached to it and moves along it

astral dawn
#

weird, for me a guy gets attached to a tank and plays some animation

#

while I drive

#

then he detaches, you have a detach command there

heavy patrol
#

yeah, but in the test I did not used an attach command

#

Basically, my test script was something like

AI attachTo Object [XX,YY,ZZ];
AI switchMove "SIT";

And then I'd drive the tank

astral dawn
#

AI attachTo Object [XX,YY,ZZ];
syntax is wrong

#

although it's right in your initial script 🤷

heavy patrol
#

yeah, I just did that on the fly for the example, I don't remember all the synthaxing, but in the test it was the correct one.

astral dawn
#

oh wait
, it doesn't stick with the moving object despite being attached to it
what do you mean?

#

sooo is it attached or not?

#

or I don't understand

heavy patrol
#

it is attached, but when the tank moves, for some reasons the AI under animation doesn't move with the tank and instead stay mid air at it's position of attach. (I know it's hard to understand, maybe I should take a screenshot)

winter rose
#

as soon as this anim plays, the unit stays where it is in the air

#

But just attachTo is fine, even with the moving tank

#

(I suppose)

heavy patrol
astral dawn
#

so which of the anims is that?

heavy patrol
#

"SIT"

winter rose
#

did you attachTo after the mission start?

#

NOT in the init field?

heavy patrol
#

For the test, the AttachTo command is in the unit init

winter rose
#

meeep wrong ^^

#

try with the console :)

heavy patrol
#

Really ? Damn, if it's that I'm feeling really dumb

winter rose
#

ideally nothing in the init box

heavy patrol
#

Welp, still the same issue through console and trigger execution

winter rose
#

aaah wait
try without the anim

#

or attachTo (some time) after it

#

but first, let's try to get the attachTo working.

heavy patrol
#

Okay, found it thanks to you

#

so, I need to animation first
Then sleep duing 0.02
Then attach

winter rose
#

the BIS fnc attaches the unit to a gamelogic iirc, or something like that

heavy patrol
#

Yeah, seems like I misunderstood how it was managed

winter rose
#

glad to hear it works anyway 👌

heavy patrol
#

Well, thanks for the help, now question is, can I use this to fix problem #2, being the orientation...

winter rose
#

first attachTo, then setDir

heavy patrol
#

yeah ^^'

winter rose
#

?

heavy patrol
#

no, just confirming

winter rose
#

oh ok
setDir an attached object is relative to the direction of the object it is attached to: a.k.a setDir 90 = facing to the right of said object

heavy patrol
#

Yup, that's the part I knew

#

wait, no, isn't it based on the compass ?

winter rose
#

not once attached, iirc at least

heavy patrol
#

I mean we'll see, I'll input 260 and it should face west

winter rose
#

270*

heavy patrol
#

Details

winter rose
#

Half-Trolling :D

#

it should face the tank's left

heavy patrol
#

Ah, you were right

#

Well, I mean right as correct, no as right. You get what I mean.

winter rose
#

right

heavy patrol
#

well thanks a lot, now it's coordinates playing time and syncing up with the player arrival for a cool intro

winter rose
#

Purrfect! With pleasure 👍

heavy patrol
#

🍪

vernal jay
#

hello im trying to simulate a sudden solar flare and i need all electronics to go off once a trigger is activated, ive looked for some things on the wiki but im sitting ducks here, id like so disable the GPS(not only on the map screen, but also on the quick view) and NVG googles. is that even possible?

tame socket
#

@vernal jay something like this maybe?

while {_EMPActive} do
{
    WaitUntil {CurrentVisionMode _Unit == 2 && _EMPActive};
    _Unit action ["nvGogglesOff", _Unit];
};
vernal jay
#

does that force the Nv mode off?

#

ill try it right now

tame socket
#

while the EMP is active it will check if the player has their NVG's on(being used) and will turn it off if the player turns them on(it should anyways)

vernal jay
#

i tried it but it wont work, im sure im doing something wrong

tame socket
#

what did you try

still forum
#

@exotic tinsel

its for error handling. i have something causing a generic error some where so i want to put something at the top of a bunch of functions that is general to fire before the error so i know where it happened.
Arma debug engine prints you a full call stack with all local variables on any error to RPT, without you having to add anything to your functions

14:17:06 "Error at L1 ()
Callstack:"
14:17:06 "    [] L1 ()"
14:17:06 "    [] L25 (A3\functions_f\Debug\fn_debugConsoleExec.sqf)"
14:17:06 "        _this:[{st = 15 / 0;}]"
14:17:06 "    [] L0 ()"
14:17:06 "    [] L25 (A3\functions_f\Debug\fn_debugConsoleExec.sqf)"
14:17:06 "        _x:any"
14:17:06 "    [] L1 ()"
14:17:06 "        _this:[]"
14:17:06 "CALLSTACK END;;;
"
14:17:06 Error in expression <st = 15 / 0;>
14:17:06   Error position: </ 0;>
14:17:06   Error Zero divisor

@astral dawn @frigid raven

You've got to check what happens if your function returns nothing though (nil or nothing)
Even worse, when the code returns nothing at all.

private _ret = call {
1 = 1;
}

Is error on the _ret = because you cannot assign anything to _ret because the call didn't return anything, because = is "bugged" and doesn't return anything.

frigid raven
#

@still forum isn't there any way to guard clause this somehow ?

#

So close but yet so far 😢

still forum
frigid raven
#

Ok I will try this 👍

jaunty ravine
#

Anyone know of a way to tell a group spawned in via script to get in a vehicle spawned at the same time that is part of said group?

winter rose
#

@jaunty ravine you have to have this vehicle assigned to the group, then assign members to a seat, then allowGetIn them

jaunty ravine
#

The vehicle is already part of the group (rhs_group_rus_msv_btr70_squad).

winter rose
#

then the other steps

still forum
queen cargo
#

It is bugged btw.
somehow it is not accepting changes when i switch to pretty sqf

#

uhm ...

#

wtf.

#

now it is?

#

what magic is this

still forum
#

I'm fixing it while youre testing 😄

queen cargo
#

😄

#

explains stuff

still forum
#

prettyprint didn't actually write the script to file and used the file from last normal sqf

#

If more users gonna use this I probably shouldn't write everything into a single file

crisp turtle
#

Does anyone know if there's a way to disable ACE fall damage on a unit by using a script in it's init?
Pulling me hair out, i can do it in vanilla but not with ACE

winter rose
#

I somehow suspect you are -not- the real Danny DeVito

crisp turtle
#

I like my MilSim between a shoot and the other

jaunty ravine
#

@winter rose Forgive me for pinging you but could you explain how I assign seats?

jaunty ravine
#

Okay, thank you.

jaunty ravine
#

Okay, so, and forgive my infinite ignorance, but how do I assign them as cargo to a vehicle that I'm about to spawn in? Just for context, here's my current code:


["Unit0","Unit1","Unit2","Unit3","Unit4","Unit5","Unit6","Unit7"] assignAsCargo ;
["Unit0","Unit1","Unit2","Unit3","Unit4","Unit5","Unit6","Unit7"] orderGetIn true;

Rwy_Bridges_1_QRF_Spawn = Rwy_Bridges_1_QRF addWaypoint [getMarkerPos "Rwy_Bridges_1_QRF_Spawn", -1];
Rwy_Bridges_1_QRF_Spawn setWaypointType "GETIN";

Rwy_Bridges_1_QRF_WP1 = Rwy_Bridges_1_QRF addWaypoint [getMarkerPos "Rwy_Bridges_1_QRF_WP1", -1];
Rwy_Bridges_1_QRF_WP1 setWaypointType "MOVE";

Rwy_Bridges_1_QRF_WP2 = Rwy_Bridges_1_QRF addWaypoint [getMarkerPos "Rwy_Bridges_1_QRF_WP2", -1];
Rwy_Bridges_1_QRF_WP2 setWaypointType "GETOUT";```
still forum
#

you can only assign as cargo after you've spawned the vehicle

jaunty ravine
#

My goal is to create a QRF that is a BTR-70 loaded with troop who spawn at Rwy_Bridges_1_QRF_Spawn and move to Rwy_Bridges_1_QRF_WP1 and unload at Rwy_Bridges_1_QRF_WP2.

#

Hold up let me test something.

winter rose
#

immediately loaded with troops? movein* commands, moveInCargo etc

jaunty ravine
#

Yeah, either immediately loaded with troops or have the troops get in upon spawning.

winter rose
#

also, ```sqf
player setDamage 1;``` → sqf player setDamage 1;

jaunty ravine
#

So far I've had the goal of making them spawn in then get in the BTR but it'd be preferable if they spawned already in the BTR.

smoky verge
#

"{alive _x} count allPlayers isEqualTo 0"
I usually use this to end the mission when all players are dead
if I wanted to make it blufor exclusive could I simply switch "allPlayers" with "BLUFOR" ?

winter rose
#

nope

#

alive _x && side _x == blufor

smoky verge
#

all that instead of allPlayers right?

still forum
#

:u

winter rose
#

let me be lazy

allPlayers findIf { alive _x && side _x == blufor } == -1;```
smoky verge
#

wow I didn't even get close
thanks @winter rose and @still forum

jaunty ravine
#

Can anyone figure out why this piece of code spits out an error?

Rwy_Bridges_1_QRF_BTR setVehicleVarName "1_QRF_BTR";```
still forum
#

setVehicleVarName takes object, not array

tough abyss
#

_enemy = allUnits select {!isPlayer _x && side _x == EAST};

is this ok to only select all ai east units?

winter rose
#

looks like it

#

private _enemies

queen cargo
#

@still forum kinda doubt it ... the discord bot also gets barely used 🤷

exotic tinsel
#

is there a universal value compare method? or do i have to actually figure out the datatype and use the proper compare method for each?

plain current
#

isEqualTo

still forum
#

it was already pinned in kp discord, chances are gud

plain current
#

player isEqualTo 1 // false "hello isEqualTo "Hello" // false 1 isEqualTo 1 // true

exotic tinsel
#

what about true isEqualTo ""?

plain current
#

prolly false

exotic tinsel
#

no error?

still forum
#

no error

plain current
#

don't think type juggeling is a thing

exotic tinsel
#

ok thanks

plain current
#

basically === of js/php or so

frigid raven
#

Next try for implementing these "aspects" around function calls fails by having undefined variables.
This is the "enriching" code snippet:

    // given "_functionNameOrTags" = "coopr_fnc_getSkills"
    private _function = missionNamespace getVariable _functionNameOrTags;
    private _enrichedFunction = {
        call _beforeAspect;
        private _returnValue = call _function;
        call _afterAspect;
        _returnValue;
    };
    missionNamespace setVariable [_functionNameOrTags, _enrichedFunction];

When calling
coopr_fnc_getSkills it will return

{
call _beforeAspect;
private _returnValue = call _function;
call _afterAspect;
_returnValue;
}

Which surely is useless since every var in there is undefined.
I know that I have to have the code string to be written hardcoded in that codeblock for the _enrichedFunction but I have no idea how to do that. Also _beforeAspect and _afterAspect are surely misplaced here, too.
Here is the full function code: https://github.com/CoopR-Mod/CoopR-Mod/blob/294d2514051623af57b7be3fdd4434031cebf2f4/addons/core/helper/fn_addFunctionAspects.sqf#L64

still forum
#

you can use format to build it

#

your before/after/function will have to be global variables then

frigid raven
#

if they are global I only can run this function once right

still forum
#

no?

frigid raven
#

since another call would overwrite the globals again

#

better said give em another value/code

still forum
#

use format to build a string of code.

#

replace _function with %1 and use _functionNameOrTags

#

bam you now have the global variable name of your function in there

frigid raven
#

gotya

still forum
#

the before and after you probably want to make generic functions, where you just pass a argument to them

#

and the arguments values you again force into there using format

frigid raven
#

👍

plain current
#

that's an interesting bit of code, what is it supposed to accomplish?

still forum
#

callstack

#

to have a calltrace at some point

#

just pushback/popback on an array

#

something that ArmaDebugEngine already does with 0 effort 😉

plain current
#

just what i was about to say 😉

astral dawn
#

Yes I have suggested him ADE a lot of times but any way 🤷
I don't get it, which variables are undefined in your function xetra11? And why do you do private _returnValue = call _function; instead of private _returnValue = _this call _function; ?

#

Although... _this will still be passed into that probably

plain current
#

but why not just have something like this?

calltrace = {
    params["_args","_fnc"];
    trace pushBack [_args, _fnc];

    _ret = _args call _fnc;
    _ret;
};

[["hello"], { params["_msg"]; hint _msg; }] call calltrace;
diag_log str trace;
astral dawn
#

that would involve replacing each function call with a custom function call I guess

#

And he refused that

plain current
#

asking for a bit too much in my opinion 😄

#

replace call fnc = no go, memory based solution = no go, oof

astral dawn
#
{
call _beforeAspect;
private _returnValue = call _function;
call _afterAspect;
_returnValue;
}

ah ok, so _function is undefined. Why do you do it like this instead of the approach you took initially, which converted code to string, added strings at start and end, then compiled them back?

#

ah nevermind, it's the same as Dedmen suggested

still forum
#

Although... _this will still be passed into that probably
if you don't pass _this, Arma will just see the _this variable in the higher scope and use that, so passing _this is redundant

astral dawn
#

yes I see || the damn arma passing of local variables through a call ||
BTW format seems to have a character limit

still forum
#

format limit is 8k afaik

#

doesn't matter here

plain current
#

#armadebugengine

still forum
#
_enrichedFunction  = compile format ["'%1' call XTR_beforeAspect; private _returnValue = call %1; '%1' call XTR_afterAspect; if (isNil '_returnValue') then {nil} else {_returnValue}", _functionNameOrTags]

like this

#

before pushes onto callstack, after pops it

#

problem with that approach is, you need to keep the callstack seperate betwen multiple scripts

#

solution would be to store it in a local variable that you have created at the top level

#

but you don't really have control over that

#

actually. no real idea how to solve that

#

SQF doesn't have a way to see which script stack you are in

plain current
#

idk if i'm retarded but i still don't have any clue whats the point of this XD

astral dawn
#

achieve ADE callstack dump without ADE and without actually dumping variables

still forum
#

every spawned script has a seperate stack, or every eventhandler. There's not really a way to tell which you belong to

plain current
#

Are you gonna run ^^ what dedmen posted with like { _enriched.... } foreach allVars select {_x typeName == "code"}?

still forum
#

You will have to add a

_thisCallstack = [] variable, at the top of every new script that starts, and then just use it in the before/after functions and implicitly grab the variable from the higher scope to pushBack/popBack from it.
But... How are you gonna get the top of every new script? especially when your code is called from say a trigger, or some other function that you don't control

astral dawn
#

Ideally we'd want __FILE and __LINE macros in our callstack, but for that we would need to wrap every function call outside, not inside I guess

still forum
#

I think he only wants it for his own functions

astral dawn
#

Are you gonna run ^^ what dedmen posted with like { _enriched.... } foreach allVars select {_x typeName == "code"}?
That's what I suggested yeah
But I think that I think he only wants it for his own functions is the more likely case

plain current
#

Hmpf, interesting

still forum
#

Ah!

#

I know how to solve the seperate callstack problem

plain current
#

Since thye're gonna be compileFinal'd for the production version anyways, so why not use ADE for debugging?

still forum
#

He doesn't want it for production

astral dawn
#

I would kindly ask everyone to run an ADE for easier debugging to be honest

#

Lack of callstack and memory dump in SQF is such an utter BS

#

You get a memory dump when a program crashes, why not have it for SQF >_>

still forum
#
{
call _beforeAspect;
private _returnValue = call _function;
call _afterAspect;
_returnValue;
}
{
//if callstack doesn't exist yet, create it. Otherwise use the _callstack that already exists in a higher scope
private _callstack = if (isNil "_callstack") then {[]} else {_callstack}; 
call _beforeAspect; //This will pushBack into _callstack
private _returnValue = call _function;
call _afterAspect; //this will delete last element from _callstack
_returnValue;
}

tada

plain current
#

You can just put diag_log everywhere but that's same as asking me to debug a js app without chrome dev tools...

still forum
#

that will create your callstack variable as high as possible

astral dawn
#

hmm wait

still forum
#

🚶

astral dawn
#

function a {

0 call fnc_b;
1 call fnc_c;

};

plain current
#

can u not just use _thisScript to seperate between files/threads?

astral dawn
#

They will push into callstack to

#

ah nvm, we retrieve from callstack when we leave the function call, im stupid 😄

still forum
#

nice idea!
But _thisScript doesn't work with non-spawned

#

doesn't matter tho, there can not be multiple unscheduled stacks running at same time

#

but I think that's a bit harder, you have to turn _thisScript into a variable name so that you can put an array into it

plain current
#

i'm so confused, you're trying to run a replace on all code variables to add a call to add it to a stack trade on those, why not just log the thread (if any) and function name, that way you'd have a full stack of scheduled and non scheduled scripts?

still forum
#

He wants to log the stack when he needs it

plain current
#

doesnt _thisScript return the file name and/or name passed to scriptName

still forum
#

not always flood the RPT with everything that's going on

plain current
#

idk if it's just me getting too used to somewhat verbose error messages working with vue and other ts/js apps and the very (except c/pp link errors) verbose error msg's of visual studio, that i dont really get the point of this.
I just deploy my code in small bits that are easy to test for syntax errors, as well as run my code through my sqf git CI, so I've never had a need to call stacks and so on...

still forum
#

until your code breaks because some other function 5 levels up somehow got a variable set to the wrong value. then you have a error 5 levels down and don't know where that wrong input ever came from because your function is called from dozens of places which could all be wrong

astral dawn
#

I've never had a need to call stacks and so on...
Not even for ADE?

#

ADE saved me so many times, with callstacks not even 5 levels deep but much much larger, without it it would be impossible to solve many of the errors

still forum
#

with vue and other ts/js apps and the very (except c/pp link errors) verbose error msg's of visual studio
Yeah all these give you callstacks
SQF doesn't

plain current
#

ADE is a great help, but i've managed years without it :D
When it comes to functions a few lvls up and code sending fucked up args, idk somehow i have this very rarely in sqf, either since it's not as oop as other languages or because the apps written in it are generally smaller and less complex or because it's the last thing i added 😄

#

And i'm not saying callstacks are useless or any of that, i'm just saying if you're trying to accomplish callstacks without changing the call fnc or using ADE, mby the time could be spent a bit better?

still forum
#

that probably yes. Though it's still a nice learning experience I'd say

astral dawn
#

Yeah I agree, I'd be glad to share my solution to that but it's buried in Git history long time ago 🤣

#

Well not directly to the callstack problem, but I... I don't remember why, but I was trying to add footers and headers to functions

still forum
#

that's easy to do with cba style mods, because you have control over the whole compilation pipeline :3

plain current
#

This is what I'd prolly do if i had to do it in script:

{
    _code = missionNamespace getVariable _x;
    
    _newCode = format["
        [%1, _this] call calltrace_before;
        _ret = _this call %1;
        [%1, _this, _ret] call calltrace_after;
        _ret;
    ", _code];

    missionNamespace setVariable [_x, _newCode];

} foreach (allVariables select {typeName _x == "CODE"});
#

Tho i'd realistically do it by detouring call, spawn and execVM in memory

#

(if i couldn't use ADE)

still forum
#

typeName _x == "CODE" isEqualType {}

plain current
#

Aha

surreal peak
#

I cant test it right now as im on my laptop, but does getVariable throw an error if you try to use it on an object which hasnt had a variable set to it yet?

winter rose
#

@surreal peak there is the alternative syntax, allowing for a fallback

surreal peak
#

oooo I didnt see that, thank you very much!

still forum
#

no it doesn't

surreal peak
#

I didnt find the syntax lou said, but I just realised it allows for a default return value which is close enough to what I want

finite dirge
#

That is what he is referring to and the alt syntax.

astral dawn
#

alternatively you can check the returned value for isNil

surreal peak
#

Another question: What is the least resource intensive way to constantly check for a certain simple object being created? Right now im using a FrameHandler from CBA which is used to loop a check for #slop in allMissionObjects although I understand that this is not very resource friendly

finite dirge
#

So you are just looking for a type/class in there? Not for a specific global var or anything? How is the object being created?

surreal peak
#

To make it easier to explain ill show the script:

_handle = [{

    _bloodObjects = allSimpleObjects [ace_drop_1,ace_drop_2,ace_drop_3,ace_drop_4];
    systemChat str _bloodObjects;
    {
        _isBlood = _x getVariable ["bloodDropAction",0];
        if (_isBlood != -1) then
        {
            _arrow = "Sign_Arrow_Green_F"  createVehicle (getPos _x);
            _arrow setPos (_arrow modelToWorld [0,2,0]);
            _x setVariable ["bloodDropAction", -1, false];
            hint "found blood and highlighted";
        }; 
    } forEach _bloodObjects;
    
}, 1, []] call CBA_fnc_addPerFrameHandler;
#

im constantly searching for ace_drop's which are created in the createBlood part of ace 3

#

ive got the code working, but I would like to optimise it in a way that will not make it too complicated to expand the code

#

btw, in the actual script im not gonna do it every second, thats just because im testing

finite dirge
#

Fair enough, that would have been the obvious and simple way to gain some performance rooYahaha

surreal peak
#

yeah 😄 Origianlly I was gonna make this only fire on the on "hit" event handler, although I think ill fully complete the script before that so i can learn a bit more about event handlers before diving feet first into them

finite dirge
#

That's probably a better bet, but even then, having this run on every hit may be a bit much for your usage too though.

surreal peak
#

any ideas what I could do?

#

Code optimisation isnt my greatest strong point 😄

finite dirge
#

I guess I don't get the point of the script. Is this to find all on the map and highlight them with an arrow? How often do you want to do this? Does this need to be for all blood, or just in a small area (like around a player)?

surreal peak
#

the arrow is for testing, in the end Im gonna make another object which is small and invisible spawn on the object, this will allow me to use ace interaction in order to clean the blood

#

Im planning on using this in more stealthy zeus missions where hopfully there shouldnt be too much blood

finite dirge
#

Then running it on "Hit" would seem to make the most sense.

surreal peak
#

ok thanks!

finite dirge
surreal peak
#

I assume nearestObjects still works for simpleObjects?

finite dirge
#

If it has an associated config class it should.

surreal peak
#

hmmmm

blood = nearestObjects [player,["ace_drop_1","ace_drop_2","ace_drop_3","ace_drop_4"],100];```
doesnt see any of the ace_drop 's
#

although when I leave the bracket which the ace_drops are in empty (to return all nearby objects) the ace_drops show up

finite dirge
#

That may still be more performant to do so, not sure. Hmm. Seems it doesn't support simples at all, or just those aren't classed, not sure.

surreal peak
#

on further look it returns the ace_drops as a p3d file

#

as in ace_drop_1.p3d

#

in allSimpleObjects im not putting the ace_drops in a string, but I cant do that for nearestObjects

finite dirge
#

Correct, that's not how the function works. 😦

surreal peak
#

soooo guess im using the inefficient method...

finite dirge
#

on Hit then seems excessive. Maybe just a loop checking every few seconds?

surreal peak
#

since thats what im doing, that seems good