#arma3_scripting

1 messages · Page 116 of 1

half sapphire
#

the tasks is created at random, dynamicaly. the unit wont exist at mission start.

granite sky
#

Just run the task creation function on the server and install the handleDamage there?

half sapphire
#

again. i have no issue a this particular moment with locality per se. that ill figure out. i just want the handleDamage EV to run the code in it once.

meager granite
# half sapphire the tasks is created at random, dynamicaly. the unit wont exist at mission start...

init.sqf:

initHostageUnitGlobal = {
    _this addEventHandler ["HandleDamage", {
        params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];

        // If new damage is about to be big enough AND unit is not unconscious yet, means its time to make them unconscious
        if(_damage >= 0.7 && {lifeState _unit != "INCAPACITATED"}) then {
            _unit setUnconscious true;
            ["Hostage is down!"] remoteExec ["systemChat", -2];
        };

        _damage min 0.7; // Never exceed 0.7 damage for any hit parts
    }];
};

and when you create a hostage somewhere in some script do:

_hostage = ... createUnit ...;
_hostage remoteExecCall ["initHostageUnitGlobal", 0, _hostage];
half sapphire
#

EH*

meager granite
half sapphire
#

ok, lets go back to the simplest expression.

        HostageUnit = _this select 0;  
        private _damage = _this select 2;  
        private _Selection = _this select 1;  
        if (_damage >= 1) then {[format ["%1", _pickone]] remoteExec ["systemChat", -2];}}]] remoteExec ["addEventHandler", HostageUnit];

forget about keeping the unit alive and everything else. lets show a systemchat message ONCE if the unit gets killed.

granite sky
#

uh, that's part of it.

#

The setUnconscious is used as a flag for the first time the condition hit.

#

You could manually setVariable on the unit instead, but the setUnconscious is convenient here.

#

Like if you didn't want to keep the unit alive you could do this:

if(_damage >= 0.7 && !{_unit getVariable ["downCondition", false]}) then {
    _unit setVariable ["downCondition", true];
    ["Hostage is down!"] remoteExec ["systemChat", -2];
};
#

(this wouldn't really be correct because a lot of damage > 1 values won't down the hostage, but whatever)

meager granite
meager granite
meager granite
half sapphire
#

no im on dedi.

#

tried tho

granite sky
#

I don't know what you're inserting that snippet into. Your handler code doesn't define _unit.

half sapphire
#

sorry that pic took to long. yeah fixed that.

#

_unit

meager granite
# half sapphire

!{_unit getVariable ["downCondition", false]} => {!(_unit getVariable ["downCondition", false])}

half sapphire
#

now, yes, no message.

meager granite
#

post whole code

half sapphire
#
[HostageUnit, ["HandleDamage", {  
        _unit = _this select 0;  
        private _damage = _this select 2;  
        
        if(_damage >= 0.7 && !{_unit getVariable ["downCondition", false]}) then {
    _unit setVariable ["downCondition", true];
    ["Hostage is down!"] remoteExec ["systemChat", -2];
};}]] remoteExec ["addEventHandler", HostageUnit];
meager granite
#

! is still not fixed here

half sapphire
#

the error was that i had hostageunit this select 0, instead _unit this select 0; copy/paste missahap. went to edit the photo, photo didnt want to upload, noticed the error... photo went up.

#

unleess im missing something else.

meager granite
#

The error on a screenshot is not about _unit but about ! being in the wrong place

half sapphire
#

error showing the ! inside now lol

#

i dont think downCondtion is a command ??

meager granite
#

its a variable name, can be anything

meager granite
#

and error message

half sapphire
#

[HostageUnit, ["HandleDamage", {
_unit = _this select 0;
private _damage = _this select 2;

    if(_damage >= 0.7 && {!_unit getVariable ["downCondition", false]}) then { 
_unit setVariable ["downCondition", true]; 
["Hostage is down!"] remoteExec ["systemChat", -2]; 

};}]] remoteExec ["addEventHandler", 0];

hallow mortar
#

It's probably trying to do !_unit instead of ! getvariable because order of precedence. Try some () to force the getVariable to evaluate first

half sapphire
#

note: the EH is remoteExec to 0 in that code, but setting to the unit also does not show the system chat. message. i used 0 so i could get the error message

meager granite
half sapphire
#

[HostageUnit, ["HandleDamage", {
_unit = _this select 0;
private _damage = _this select 2;

    if (_damage >= 0.7 && !(_unit getVariable ["downCondition", false])) then { 
_unit setVariable ["downCondition", true]; 
["Hostage is down!"] remoteExec ["systemChat", -2]; 

};}]] remoteExec ["addEventHandler", 0];

#

that works

meager granite
#

{} were there for lazy eval

#

doesn't matter much in your case though

gusty forum
#

Hey, is there a way to make one specific helicopter and its passengers be untargetable by enemy AI, but still have the players inside be targetable once disembarking?

#

I thought about setting anyone to setCaptive when entering the heli, and then disabling it upon disembarking, but how does one achieve that feat?

winter rose
#

addEventHandler, GetOut or GetOutMan 🙂

kindred zephyr
#

@meager granite do you happen to know what triggers the vanilla unconscious state upon being damaged?

I had done some test but its a bit inconsistent, seems like when you damage well enough any of the structural damages or the "unconscious" hit point you can go uncon, but it also appear that certain damages upon any of the other hit points are able to trigger it without the other structural damages being high enough.

kindred zephyr
#

is there any documentation in the matter?

Haven't seen to be able to find explicit how-to's on that and the function itself for reviving doesn't mention how the system gets triggered to set the unconscious state in the function itself. Everything seems to be managed into with that same function though.

meager granite
#

Anybody has a working script snippet to crash the server? All my methods are outdated.

#

Need it for legit reason to stop the server since #shutdown doesn't always work.

still forum
#

callExtension. Make a extension that crashes

meager granite
#

I'd prefer a scripting way, but gonna resort to extension if I won't find a new way.

hallow mortar
#

I think the usual way is to use an external process controller rather than scripting a murder

granite sky
#

Have you tried recursive addEventHandler spamming

#

That certainly used to work.

meager granite
granite sky
#

Takes a few seconds to run out of stack though :P

meager granite
#

Thats fine, gonna run at mission end anyway

little raptor
#

Never tried it but I guess it could crash your game

#

(either that or it displays in-game error)

#

but I guess if it does we'll have to fix that hmmyes

winter rose
#

arrays have a limited 10M size iirc

little raptor
#

yeah but what happens when you exceed that limit?

winter rose
#

it most likely trims it

little raptor
#

just tested, and it shows an in-game error

#

so won't crash meowsweats
but it has to be an integer so 1e30 won't work. [] resize 10000001 does

winter rose
#
private _code = {
  while { true } do {
    0 spawn _code;
  };
};

call _code;
```?
#

good ol' fork bomb

sullen sigil
#

can you not call code from within code

#

oh wait im thinking of cba waitandexec

granite sky
#

spawn-spam might kill more than just Arma.

#

You really want to burn stack rather than memory.

little raptor
#

as Dedmen said the only reliable way is extensions

#

even if you do find a way to actually crash the game using scripts, it will be fixed (or at least it should)

winter rose
granite sky
#

Hmm, recursive addEventHandler did crash but it took a lot longer than it used to.

#

Actually threw "out of memory".

#

4GB stack cap or something.

little raptor
#

the first one is kinda bad meowsweats
I'll see if it can be fixed hmmyes

still forum
#

The openMap one should be fixed by the recent UI stuff fixes

#

Also can't open a map on a server can you?

little raptor
#

yeah if it's dedicated you shouldn't be able to

sharp grotto
tender sable
#

I inadvertently crashed Arma yesterday but it didnt fully crash. Had two hashmapobject definitions. In A's create method it was supposed to create B but I mistakenly typed in definition A into it's own constructor. Just froze. No memory or cpu usage spike but it wouldn't leave the main monitor screen and my task manager wouldn't kill it. Tried to create a new desktop (win 11) and the Arma screen just followed me on to each new one like it was just a poster stuck on my main monitor. I could operate windows just fine. It was just the window that stuck. So to get rid of it I had to sign out and then cancel the sign out when the window/process was finally closed. No idea what the effect would be on a server but if it was anything like I experienced you can use it to turn it into a brain dead server. Or if you want to turn Arma into like a permanent JPG lol

noble comet
#

Hi, could someone help me im trying to make a shot timer which counts the shots a player shoots and calculates the time difference between the start and the time of the last shot

#


_player = player;


_shotCount = 0;


_countShots = {
    _shotCount = _shotCount + 1;
};


_eventHandler = _player addEventHandler ["Fired", {
    [] remoteExecCall _countShots; // Schuss zählen
}];


_startTime = time;


sleep 10;


_endTime = time;


_player removeEventHandler ["Fired", _eventHandler];


if (_shotCount > 0) then {
    _lastShotTime = _endTime - _startTime;
} else {
    _lastShotTime = 0;
}


hint format ["Schüsse in 10 Sekunden: %1 | Letzter Schusszeitunterschied: %2 Sekunden", _shotCount, _lastShotTime];```
#

Thats where i want to implement it after line 9if ([player, 'KSK_Shot'] call BIS_fnc_hasItem) then { whistle_name = _this select 0; if (isNil {missionnamespace getvariable 'shot_soundsource'}) then {} else {deleteVehicle shot_soundsource;}; shot_soundsource = 'Land_HelipadEmpty_F' createVehicle position player; shot_soundsource attachTo [player,[0,0,0]]; _waitTime = random 3; hint "Timer pressed... standby"; sleep _waitTime; [shot_soundsource,[whistle_name,5,1]] remoteExec ['say3D', 0]; sleep 1; hintSilent ""; };

willow hound
bold comet
#

@queen cargo Java has had lambdas since Java 8 which is more than a year old already

queen cargo
#

rly?
kinda lost track after 7

bold comet
#

yep

#

there's also the streams api, new comparator api, new date api that doesn't suck (third time's a charm)

#

lots of good stuff in version 8

#

most of it being copied from scala

#

which is a good thing

half sphinx
noble comet
half sphinx
#

Yea, but the second part has nothing to do with counting shots and works more or less like a horn per say.

noble comet
#

yea thats a snippet where i want to implement it

noble comet
half sphinx
#
shotCount = 0;

private _eventHandler = player addEventHandler ["Fired", {
    shottime = time;
    shotCount = shotCount + 1;
}];

sleep 10;

player removeEventHandler ["Fired", _eventHandler];

_lastShotTime = [0, time - shottime] select (shotCount > 0);

hint parsetext format ["Schüsse in 10 Sekunden: %1<br/>Letzter Schusszeitunterschied: %2 Sekunden", shotCount, _lastShotTime];
#

this should work

noble comet
#

let me try

#

It work thanks

pulsar bluff
sullen sigil
#

i once managed to make my graphics drivers break as a result of trying to ropecreate and ropecut on every frame

exotic flax
#

Interesting to see people can't make servers crash, because all I need is a broken script in a random mod to take it down 🤷

granite sky
#

I don't run random mods :P

exotic flax
#

We neither, but had enough cases in the past years where a mod worked perfectly fine when testing and even runs perfectly fine with less than 10-20 people on the server, but the moment you increase the amount of people (we run 60+ player missions) it crashed the server within seconds after a script got executed.

granite sky
#

Worst one we had with another mod is RHS breaking the arsenal init, which was an alt-f4 case but not an actual crash.

#

The 32-bit servers fall over pretty easily but that's expected.

exotic flax
#

Worst one we had was the USAF AC-130 mod, everything was fine till someone started the engine of that thing; because it was executing it on all machines (server and clients), causing memory leaks and massive desync everywhere. And with 3 HC's and 60 players it crashed everything within seconds. With smaller player groups it usually crashed everything within an hour or so.
Got fixed pretty soon after it got reported though, so not an issue anymore 😉

fair drum
#

Just use ADTs config search with full depth. That always causes a memory crash after sometime.

wind flax
#

Is there anyway to add all the items from a Unit Loadout Array into the inventory of an object?

wind flax
#

Any other ideas? You'd have to add a check to figure out how many of that item are in

hallow mortar
#

Once flattened, quantity numbers will no longer be associated with their item; there's also no way to determine which command to use (addWeaponCargoGlobal vs addItemCargoGlobal etc).
It would be better to not flatten it, and instead try to split out the arrays since they're in a defined structure.

#

Start of an example:

_loadout params ["_primaryInv","_secondaryInv","_handgunInv","_uniformInv","_vestInv","_backpackInv","_items1Inv","_items2Inv"];
_uniformInv params ["_uniform","_uniformItems"];
_container addItemCargoGlobal [_uniform,1]; // Don't quote me on uniforms being items
{
  if (count _x == 3) then {
    _container addMagazineCargoGlobal [_x#0,_x#1,_x#2];
  } else {
    _container addItemCargoGlobal [_x#0,_x#1];
  }; // you probably need a way to detect weapons in inventory too...not sure how
} forEach _uniformItems;
#

for detecting weapons in inventory, it looks like they should be formatted as an array the same length as the primary weapon array, so that would be how you detect them. You can put them in the container with addWeaponWithAttachmentsCargoGlobal.

granite fog
#

Is it possible to remove current magazine from turret then add it and skip reload phase ?

That's what i am trying to do with no success:

_target removeMagazineTurret [_magazineName, _turret];
_target addMagazineTurret [_magazineName, _turret, (_oldAmmoCount - 1)];
_target setWeaponReloadingTime [_player, _weapon, 0];
_target loadMagazine [_turret, _weapon, _magazineName];

Once again, i need to remove current magazine (because i need to decrease ammo count) then add it back with no reloading

warm hedge
granite fog
#

its not working. This command are for hand weapons not for turrets

meager granite
half sapphire
#

@meager granite @granite sky @hallow mortar thanks for the help last night guys. ended up opting for 2 EH. 1 handledamage thats sets unconscious, and from there an animationchanged EH for the holdaction and revive thingy. works like a charm. even had an action eject for if the unit is in a veh.

sharp grotto
meager granite
half sapphire
#

"if ("unconsciousface" in _anim) then {...}" ... feeling the need to change the unit's name to unconsciousface lol

hallow mortar
# granite fog Is it possible to remove current magazine from turret then add it and skip reloa...

It's very difficult to target specific magazines. Although they are notionally unique and can have unique IDs, we don't really have the commands to work with them in that way. So, uh...

  • save the details of the existing weapon and magazines
  • remove the existing weapon and magazines
  • re-add the magazine you want to load
  • re-add the weapon (the magazine already present should be automatically and instantly loaded)
  • re-add the remaining magazines
    Complicated? Yes. But I don't think there's a way to do it better with the available commands.
    Note that setWeaponReloadingTime is for the time between rounds in a magazine, not the time between magazines.
half sapphire
#

like how long it takes to chamber a round?

dusk gust
#

SetWeaponReloadingTime maybe?
I haven't read anything, but maybe lmao

sharp grotto
#

"This command does not change a weapon's (e.g soldier's rifle) magazine reloading time but changes the ammo reloading state before the next round is shot."

granite fog
hallow mortar
#

That command has a huge red warning saying it's broken if there are multiple magazines of the same type.

granite fog
#

Yeah i see. But anyway i am sure that my magazines would be 100% unique

gentle zenith
dusk gust
warm hedge
#

You already can try in Dev-Branch

gentle zenith
#

Glad it's finally coming, means I can clean up a lot of my use fuel scripts

warm hedge
#

It only took two decades 😄

rugged breach
#

Does anyone have a script or composition for an area arsenal?

jade tendon
#

Part of a radio trigger:
_radio_2 setTriggerStatements["this","[30, 150, 10, "WHITE", -8] execVM "scripts\skyFlares.sqf"",""];
Do you include the middle "[]" or is it something else? TIA

hallow mortar
#

The use of [] is correct; can't speak for what's inside it as I don't know how skyFlares.sqf does.
However, you have a problem with your "".

nocturne bluff
#

pets C#

hallow mortar
#

Because "" denote the ends of a string, you have to be careful using them inside a string. The game can get confused. You need to either escape them by doubling them, or differentiate them by using ' instead.

nocturne bluff
#

Soon..

hallow mortar
#

In this case, you need to change "WHITE" to either ""WHITE"" or 'WHITE', and the same for the execVM file path

delicate steeple
#

Is there a way to add a downward force? I tried addForce and addTorque, but I can't seem to be able to add a downward force (maybe I am using the commands wrong?)

warm hedge
#

Just put minus?

delicate steeple
#

I'll try that, but I don't think addForce works on the up/down axis, only lateral

#

at least thats what it looked like in my testing, I could be using it wrong as well

warm hedge
#

It should

hallow mortar
#

addForce is a 3D vector in world space, so down should be a negative force on the Z axis (third number) in the first array

#

Keep in mind that things commonly found above the ground may have an upwards force keeping them there (for example, engines). You might need to increase your downwards force to overcome that.

delicate steeple
#

Yeah, that might be it. I'm trying to use it on a helicopter, but haven't had any luck

#

I'm launching my game again to test it again with a negative third value

hallow mortar
#

You might also want to try applying the force repeatedly over several frames, depending on how you want the helo to be affected. Because you're pushing against both its active lift and its aerodynamic surfaces, it will lose the added speed quicker than you might expect.
You can also try setVelocity for a slightly different approach.

warm hedge
#

addForce also can be affected by the object's mass

hallow mortar
#

It can, but it sounds like they've already figured out a good value for overcoming the mass since they mentioned lateral force working.

warm hedge
#

I think multiplying with getMass can repro very similar result regardless how heavy it is

delicate steeple
#

actually addVelocity works a lot better for what I am trying to achieve, I did not know of the function before, thank you

jade tendon
delicate steeple
#

Different question, is there an SFM version for collectiveRTD?

warm hedge
#

I think inputAction to detect

jade tendon
#
    while {not isNull p1} do {"pm1" setMarkerPos getPos p1; sleep 0.5;{;}}
};```
if placed in init.sqf, 
will this run on respawn or do i copy the code to onPlayerRespan.sqf?

Or can someone point me to a script that would work better. TIA
warm hedge
#

While cannot recall respawned unit is the same unit with before, one thing I should to point is {;} is very broken and will cause an error

jade tendon
granite sky
#

It'll run until p1 is null. Whatever p1 is. No point running it twice anyway.

jade tendon
#

Sry for the questions, im forcing myself to improve my scripting. I can read and understand the code, but as soon as i try to type it myself, my brain makes itself absent (so to speak)

Im making a dynamic armor campaign with the players as tank commander and want markers to follow each player to allow coordination.

To answer your "whatever p1 is":
p1 is the variable name of the first player slot.
In addition, pm1 is p1's personal marker.

I have a trigger with:
Condition: !alive p1
Activation: deleteMarker "pm1";

and the above code in init.sqf.

When starting, the marker is visible,
on respawn the marker is gone.
(it occurs to me, as i write, to use createMarker in onPlayerRespawn.sqf instead)

granite sky
#

Why are you deleting the marker?

#

When you respawn, p1 is set to the new player. It's probably never null because even when the player is dead and awaiting respawn, it's still pointed to a valid corpse.

split scarab
#

Is it possible to export all the items and their quantity to use in a different mission into a file or something easily saved to reuse? Like Mission 1 would be to Raid and acquire weapons/items/vehicles and Mission 2 would make use of everything you gathered?

I should be able to gather the gear and vehicles myself but I'm not sure how I could easily transfer it to another mission other than printing everything in chat ingame and writing it down by hand

granite sky
#

You can save whatever you like in profileNamespace.

little raptor
split scarab
#

I see, that's like a variable that's saved between game sessions?

granite sky
#

It's saved to the [username].vars.arma3profile file in the profile.

#

Be a bit careful about how much stuff you dump in there, because it's probably gonna be there forever.

#

Another option is to use missionProfileNamespace, but that's a bit busted on Linux.

split scarab
#

So long as I remember to clear it (setting it/them to nil) after I'm done it should be okay right?

granite sky
#

That would be above average behaviour :P

#

Make sure you tag your vars properly too, because everything gets dumped in there.

split scarab
#

Sounds good, thank you :)

elfin inlet
#

I'm trying to code an ammunition for a training style weapon, that when it hits an AI unit it deletes the AI as if Zeus had done it. How would I go about this?

winter rose
#

think the other way around, use a "Hit" or "HandleDamage" event handler to delete the unit if said ammo is used 🙂

elfin inlet
#

I hadn't thought about it that way but makes sense. Would you have an example in mind? I'm still learning EventHandlers and scripting.

winter rose
#
[_VRsoldier, false, 10] spawn BIS_fnc_VREffectKilled;
```perhaps 🙂 not sure
elfin inlet
#

I'll give it a whirl and look into it more. Definitely somewhere to start

little raptor
#

In this case it makes more sense to use projectile event handlers

elfin inlet
#

In what regard? Like I said I'm new to this but with some help I pick it up quick

winter rose
noble comet
#

Could someone help me im trying to spawn ai with a random preseted loadout and position. And does anyone know how to trigger a script via ace or a button on someone who is standing on a marker/ in a trigger?

ancient lion
#

Does anyone know how to reduce Recoil when at all? Ive tried 2 ways and it hasnt done anything:

Method 1:
initPlayerLocal.sqf

player addMPEventhandler ["MPRespawn", {player setCustomAimCoef 0.1}];
 
player setUnitRecoilCoefficient 0.5;
player addEventHandler ["Respawn", {player setUnitRecoilCoefficient 0.5}];
 
player enablestamina false;
player addEventHandler ["Respawn", {player enablestamina false}];```

Method 2:
I followed this Forum Post: https://forums.bohemia.net/forums/topic/186415-player-setcustomaimcoef-1-what-does-1-mean/

Still nothing works, if there another way please @me or Reply to me on the message.
stray creek
#

is there a way to remove all objects starting with land_ on a map ?

#

or an way to get all classnames used in an map?

winter rose
#

it would be ultra slow

#

instead, what is your goal?

stray creek
#

remove all houses and existing buldings

winter rose
#

for what purpose, if I may ask?

stray creek
#

yes, its for an server with civil war era, and its now modern buildings on it.

winter rose
#

I see
Try this (beware - may take time!)

if (isServer) then
{
    private _allTerrainObjects = nearestTerrainObjects
    [
        [worldSize / 2, worldSize / 2],
        ["BUILDING", "HOSPITAL", "HOUSE"],
        worldSize * sqrt 2 / 2,
        false
    ];

    { _x hideObjectGlobal true } forEach _allTerrainObjects;
};
stray creek
#

Did the job thanks 😀

sullen sigil
#

would probably recommend that gets scheduled but shouldnt be too dreadful for most maps

real tartan
#

is there a way to get mission id from RPT log to use it in scripts?

19:14:26 "User/BIS_fnc_log: [BIS_fnc_preload] ----- Scripts initialized at 573.997 ms -----"
19:14:29  Mission id: ff5a621422e2cfa61e2fb358a424d076a6466e61
fair drum
#

anyone got a function to create either an array of strings of all ANSI characters, or a single string of all ANSI characters?

#

like the opposite of toArray syntax 1

#

oh I'm blind, I think toString does it

drowsy sparrow
#

having an odd issue and was wondering if anyone could help, I have a backpack that swaps textures when you perform a specific action and it works for literally everyone except for one guy

#

this one guy has the bits turn invisible (not pulling the correct texture) everyone else it fine

#

is*

noble comet
#

Does anyone know how to spawn ai on a random marker but not twice

winter rose
#

yes

noble comet
#

coud you maybe help me there i use an array for the position

winter rose
#

do you use an array of markers and spawn multiple AI units?

noble comet
winter rose
#

example with BIS_fnc_arrayShuffle:

private _arrayOfPositions = [_pos1, _pos2, _pos3] call BIS_fnc_arrayShuffle;
private _unit = objNull;

while { _arrayOfPositions isNotEqualTo [] } do
{
  _unit = _grp createUnit ["UnitClass", _arrayOfPositions select 0, [], 0, "NONE"];
  _arrayOfPositions deleteAt 0;

  waitUntil { sleep 1; not alive _unit };
};
drowsy sparrow
#

nevermind

#

he had a conflicting mod double dound

#

bound*

granite haven
#
serverNamespace setVariable ["BIS_WL2_cappingValues",
    compileFinal createHashMapFromArray [
        ["B_Quadbike_01_F", 1], ["B_LSV_01_unarmed_F", 1], ["B_MRAP_01_F", 1],
        ["B_Truck_01_transport_F", 1], ["B_Truck_01_fuel_F", 1]
                ....
    ]
];

how come i'm getting the error: Attempt to override final function - bis_wl2_cappingvalues?

#

should the compileFinal happen before the setVariable?

granite fog
#

How to correctly unload gunner interface that was loaded by onLoad event from turretInfoType of vehicle when player leaves vehicle ?

Found that some kind of RHS vehicle e.g. rhs_t72bb_tv still have opened gunner display after leaving vehicle. It closes when player enter to different vehicle or another seat of current vehicle but still persist if player leave the vehicle and enter to another same vehicle (and same seat).

vivid bridge
#

Is it possible to set a condition so that when a helicopter lands, units only then start moving towards the helicopter?

fair drum
# vivid bridge Is it possible to set a condition so that when a helicopter lands, units only th...

Tons of ways, here are a couple of easy ones.

Without Scripting

  • Use Set Waypoint Activation when right clicking a waypoint. Link two waypoints together, one from heli, one from infantry group.

With Scripting

  • Create your waypoints for both the heli and infantry
  • Disable PATH on infantry
  • Use On Activation under Waypoint: Expression inside of the attributes of the heli's waypoint - enable PATH in that expression box using the array of units of the infantry group
molten yacht
#

Does anyone know what the shift-click local waypoint is referred to as programmatically? I'm looking for a way to set it on a specific client

foggy hedge
#

Does "player" variable exist on headless clients, or is it objNull like on the server?
(please ping me if you reply)

hallow mortar
fair drum
# foggy hedge Does "player" variable exist on headless clients, or is it objNull like on the s...
Headless Clients are rather similar to players:

    The Array returned by the allPlayers command also contains Headless Clients.
    The player command returns the Headless Client Entity on the Headless Client's machine.
    Using isPlayer with a Headless Client Entity returns true if a Headless Client is connected to the corresponding slot.
    Headless Clients execute init.sqf and initPlayerLocal.sqf.
    Headless Clients trigger initPlayerServer.sqf.
foggy hedge
#

thx, missed that

vocal mantle
#

@queen cargo How is it large overhead to make an extension? Is it because the game has to wait for the extension to finish? If so use threads.

jade tendon
#

does BIS_fun_objectGrabber not grab objects from the spearhead cdlc?

queen cargo
#

??

vocal mantle
#

you said "@vocal mantle thats correct! however, it is also a kinda large overhead to create an extension and most people are not capable of doing so"

#

@queen cargo I dont know if you are using "overhead" in the same way I am thinking.

queen cargo
#

Na XD most people simply cannot write c/c++ thus its an overhead for em to learn

vocal mantle
#

The only thing that I do not like about Killzone Kid's extension is that you can not edit any file, only the last file you created. I know it was done for security reasons, but I suggested including a header to the file that would let the extension know that the file can be modified.

queen cargo
#

Write your own :P

hallow mortar
#

It doesn't seem to me like there should be any reason why it doesn't, but I can't investigate it in the function viewer right now.
For anyone else looking, the actual function name is BIS_fnc_objectsGrabber

vocal mantle
#

Well that was me a few months ago. I'm no expert but it's easy once you know file I/O, threads and a basic Arma extension.

#

I probably will at some point

#

I'm working on another project in C++ at the moment

dusk gust
queen cargo
#

You do not need threadding for file io

jade tendon
#

us radio
classname: SPE_Radio_Us

I did find a way around it though

dusk gust
#

Strange

jade tendon
#

Im working on a tank commander mission and im trying to create a flare system to allow players to fire a flare above them at night.
Myself and TenuredCLOUD have been working on this but we have run into a problem.
We can get the script to do what we want but they fall to the ground fast instead of slow.
Any help would be appreciated.

_count = _this select 1;
_Height = _this select 2;
_Fallrate = _this select 3;

_c = (random _count);

while {(_c > 0)} do
{

_SmokeClass = selectRandom [
"SmokeShell",
"SmokeShellYellow",
"SmokeShellGreen",
"SmokeShellRed",
"SmokeShellPurple",
"SmokeShellOrange",
"SmokeShellBlue"
]; 
    
    _pos = getPosASL player;
    _pos set [2, (_pos select 2) + _Height]; 

    _flare = _SmokeClass createVehicle _pos;
    _flare setVelocity [0, 0, _Fallrate];
    
    _c = _c - 1;

    sleep _delay;
};```
We are using smokes to test

called with
```_radio_2 = createTrigger["EmptyDetector",[0,0]];
_radio_2 setTriggerActivation["Bravo","PRESENT",true];
_radio_2 setTriggerStatements["this","[5, 3, 500, -1] execVM 'scripts\skyFlares.sqf'",""];
2 setRadioMsg "Fire Flare";```
vocal mantle
#

It just helps in some cases, instead of making the engine wait for the RVextension function to finish. Its not required but I imagine it helps with performance.

hallow mortar
#

setVelocity only applies once, not continuously unless you specifically script that. The object will quickly accelerate to its natural falling velocity under gravity.

#

You could try adjusting the projectile's weight with setMass (note that actual flares have a slower natural descent rate and will behave a bit differently). Otherwise you'll need a continuous application of setVelocity or setVelocityTransformation.

vocal mantle
#

Here is my other C++ project if you are interested in checking it out https://github.com/Benargee/SimpleChat . It's just a project for learning C++. It's a console based chat program that will hopefully work over the internet.

errant solar
#

Hello dear armaholics 🙂 If we talk about scripting, i'm just hydrogen compared to DNA. Maybe someone can help me. I want to multiply the fuel consumption, so the crew have to manage fuel too. is there a possibility to use the Init. so i can just past the script into it?

little raptor
errant solar
little raptor
#

yes. it'll probably be released around Feb-March

warm hedge
#

Tell all of your players to install Dev, it is MP compatible

errant solar
#

okay thanks for your help 🙂

vivid bridge
#

Hi everyone! can you tell me how to make a helicopter shoot off heat traps?

hallow mortar
#

Flares and countermeasures are actually a weapon (CMFlareLauncher usually), so it's just a question of making the pilot fire that weapon. Well, and adding the weapon and its ammo if the helo doesn't come with countermeasures by default.

glossy axle
#

Hi all, I'm looking to add some teleports on my map. I want to have two that link to each other and are bi-directional, for placing on the Tanoan skyscrapers and used as 'elevators'. I have the issue though that the current teleports I use the user can choose to go to any teleporter on the map. Does anyone have a solution to linking two teleports together and limiting the user to switch only between those?

proven charm
#

how do you get list of all valid factions? I tried CfgFactionClasses but it may not have all...

meager granite
proven charm
rough dagger
#

hi folks.. can anyone explain how I can restore a player's incapacitated state to 'healthy'?

real tartan
kindred zephyr
#

its #rev state 1

#

just do the call on the function BIS_fnc_reviveOnState as mentioned above, no need for other things as the function handles the damage resetting too

rough dagger
#

Thanks guys .. seriously appreciated ❤️

cobalt path
#

Question, essentially I want to write a script that would spawn 2 IR strobes and attach them to different parts of the vehicle (I know how to do that), it would be via addaction (I know this too), BUT how do I than later delete it?
I could name the strobes, but than if I want multiple vehicles to have that ability, the variable names would duplicate and it would break

hallow mortar
#

Use setVariable to make vehicle-specific variables

cobalt path
unreal scroll
#

@cobalt path He means, if you have, say, vehicle with the local name _veh in the current scope, then you can:

_veh setvariable ["myvar",value of myvar];

Also you can specify the target for the variable (needed for multiplayer games to make individual variables or just to decrease the network traffic), like

_veh setvariable ["myvar",value of myvar,2];

sets the variable only for your server (local or dedicated).

This makes the variable to "live" inside the individual scope, linked to the vehicle itself, so you can retrieve the value with

_veh getvariable ["myvar",define the default value here];
cobalt path
unreal scroll
#

You better to show us your code, to give you a correct example. Like, if the vehicle got destroyed, you need to remove IR strobes too - it it better to be implemented via Killed/MPKilled event handler.

grizzled cliff
#

@vocal mantle learn to use the STL! :D

#

are you using VS2015?

hallow mortar
#

https://community.bistudio.com/wiki/setVariable
https://community.bistudio.com/wiki/getVariable
setVariable allows you to create a variable within a specific Namespace. Normal global variables exist within the missionNamespace - a Namespace associated with the mission as a whole rather than anything more specific - but every object in the mission also has its own Namespace (there are some other kinds of Namespace too but we care about objects here). A variable in one Namespace is separate from variables in any other Namespace, even if they have the same name.

For example:

_vehicleOne setVariable ["my_var_name",true];
_vehicleTwo setVariable ["my_var_name","test"];

// Returns true:
_vehicleOne getVariable ["my_var_name",false];
// Returns "test":
_vehicleTwo getVariable ["my_var_name",""];

Notice how the two variables contain different values, even though they have the same name, because they are in the Namespaces of different vehicles.

grizzled cliff
#

C++11/14 = god mode

hallow mortar
#

So when you create your strobe, you might do this:

_currentVehicle setVariable ["marki_var_strobeLight",_strobe,true];

and then when you want to delete it later, you can do this:

_currentVehicleStrobe = _currentVehicle getVariable ["marki_var_strobeLight",objNull];
deleteVehicle _currentVehicleStrobe;```
grizzled cliff
#

seriously, makes learning C++ not hard (well not as hard lol)

#

mainly by making sure you cant fuck up

#

if you fucked up then shit wont compile

verbal rivet
#

Quick question: does HandleChatMessage fire on server when receiving a message from client? If not, is there an alternative handler which does so?

grizzled cliff
#

using naked char pointers for strings is asking for problems down the road

unreal scroll
#

Quick question: does HandleChatMessage fire on server when receiving a message from client?
If the server is dedicated - then no, if it is the local serv er - of course, like any other client.

If not, is there an alternative handler which does so?
If you need some code to be executed on the dedicated, then just call the needed command from any client with remoteexec.

verbal rivet
#

My challenge is that I want to handle chat messages sent by clients from a server-only mod. The only requirement I want to impose on client is to run CBA. Is there a way for server to install an event handler on clients in a JIP-compatible fashion?

hallow mortar
#

Yes, remoteExec

grizzled cliff
#

std::string is way safer, but if you need the speed of a naked char pointer (which really is going to be minimal, especially with optimizations turned on in the compiler) you should use std::shared_ptr or std::unique_ptr or std::array

sullen sigil
#

cba has a chat command thing iirc

hallow mortar
#

(don't make the code to be remoteExeced too complex, otherwise you'll clog the network)

verbal rivet
sullen sigil
#

imposing cba as the only requirement for players is pretty pointless too

#

given its made to be a framework for other mods to use

unreal scroll
#

On server:

addMissionEventHandler ["HandleChatMessage",fnc_ChatMessageHandler];
fnc_ChatMessageHandler = {
  [] remoteexec ["some command",2] // Execute on the server
};
publicvariable "fnc_ChatMessageHandler" // needed if you didn't add it as a client function

EH is JIP-compatible already, to make commands JIP-compatible just add additiona JIP params to the remoteexec

verbal rivet
candid sun
#

off-topic, but is it stupid trying to write C# without using VS? i figured i might learn more doing everything manually in notepad++ but it's quite a struggle.

hallow mortar
#

If HandleChatMessage doesn't fire on the DS, then addMissionEventHandler needs to be remoteExeced to the clients with JIP true

#

Note that addMissionEventHandler is a local effect command, meaning that event handlers are only added on the machine where the command is executed. Mission EHs are not automatically added on all clients or JIP - they're not the same as MP EHs, which are global.

cobalt path
hallow mortar
#

I believe that is what I said, yes.
Note that _currentVehicle is a placeholder name, use whichever variable you're already using to refer to the vehicle in question

cobalt path
hallow mortar
#

You can use params to quickly turn the contents of _this into readable private variables, instead of having to do _this select x every time you want to refer to something

verbal rivet
#

Combining the above, it seems like I do need CBA dependency on clients, and need something like this in XEH_PostInit:

MyServerSideHandler = {....code.....}

["cba_events_chatMessageSent", { 
    _this remoteExec ["MyServerSideHandler", 2, false];
}] remoteExec ["CBA_fnc_addEventHandler", 0, true];

Does that make sense?

polar belfry
#

Hello I have a question a script of mine
No fly zone
Condition
(vehicle player in thisList) && {vehicle player iskindof "Plane"}
On Activation

while {triggerActivated (_this#0)} do {
private _position = vehicle player getRelPos [900,200];
_position set [2,10];
private  _missileDir = _position vectorFromTo getPosATL vehicle player;
private _missile = createVehicle ["ammo_Missile_rim162", _position, [], 0, "CAN_COLLIDE"];
_missile setVectorDirAndUp [_missileDir, [0,0,1]];

[_missile, vehicle player] spawn {
    params ["_missile", "_tgt"];
    sleep 0.1;
    _missile setMissileTarget _tgt;
    };
sleep 7;
  };
}```

What I must change so it also aims at ai planes as well
grizzled cliff
#

if you have VS why wouldn't you?

gray bramble
#

In designing the language, they had a goal to make intellisense (the backend for the vs autocomplete among other things) easy to make, and so they probably assumed you'd have it when you wrote code.

grizzled cliff
#

yea, remember C# is a MS language, and VS is designed to handle it

#

they go hand in hand

ornate whale
#

Is there any easy way how to select/collect all first elements of arrays withing an array, similarily to select column command in SQL? Thanks

grizzled cliff
#

if you were doing like mono on linux or something

hallow mortar
#
_firsts = _array apply {_x select 0};```
ornate whale
#

noice XD thanks

grizzled cliff
#

then that'd be a different story, but im sure there are plenty of IDEs that handle C#

polar belfry
#

Would just vehicle not vehicle player make it aim at all alive planes

grizzled cliff
#

if its a matter of understanding templates that VS spits out for classes etc

candid sun
#

i come from a web design background so c# is the first compiled language i've used...VS is pretty confusing to a noob to be honest

hallow mortar
polar belfry
#

Oh..

#

I see just vehicle will return the unit

#

The thing I want to do is that if it's blufor plane it gets whacked

#

No matter ai or player. Should I keep vehicle or do an object parent check

#

I'll put when blufor present for the side check

unreal scroll
#

@hallow mortar

addMissionEventHandler is a local effect command
Yes, you're right, I forgot I use client commands there 🙂

polar belfry
#

how would I check with objectparent if vehicle is plane?

#

I saw the note
Use objectParent instead of vehicle to get a soldier's vehicle. Apart from being faster it is also more reliable, as when used on dead crew, vehicle command may surprisingly return the unit itself.

ornate whale
#

Why do I get NOID <no shape> error when I do playsound "windxxx"? The sound is placed within the misison folder for editing.

class CfgSounds
{
    sounds[] = {};
    class windxxx
    {
        name="windxxx";
        sound[] = {"Sounds\wind.waw",2,1};
        titles[] = {};
    };
};
hallow mortar
hallow mortar
ornate whale
hallow mortar
# polar belfry what shall I use?

Targeting any arbitrary vehicle is more complex than targeting the local player's vehicle. There is no one command substitution, you need to make some structural changes to the code. I don't have time to explain it in detail right now - someone else may be able to help.

polar belfry
#

ok

hallow mortar
#

You said the sound is in the mission folder, but the configured file path is for it to be in the Sounds folder inside the mission folder. Make sure the file path matches the actual path.

ornate whale
#

Is there any way how can I get all the sound names, not file names, that are present in the base game? So I can use them in scripts.

And what is the best way to loop a sound?

hallow mortar
ornate whale
#

Can Arma work with embedded loop stamps in WAV files?

winter rose
#

no

ornate whale
#

So, the right way is to repeatedly play the sound?

winter rose
#

no

#

you must stay silent or the enemy will hear you

tender sable
#

quick question about remoteexec/remoteexeccall: I don't have a way to test this at the moment but, I understand they can be called in both SP and MP. If I have a preInit function that remoteexecalls another function that I want to delay until after all addons go through their preInit phase but prior to say.. init.sqf, if I run a mission in SP it will exec after init.sqf but before init.sqf in MP? As a result, I have no reliable way to execute something after all preInits but before init.sqf in SP? So the only possible way to delay something until after preInits but before init.sqf, I should check if MP in preInit and remoteexec but then, also have an init.sqf check if SP and run it first before everything else? Or is there a more fanciful way of approaching this?

#

Sorry if confusing. does remoteexeccall delay in SP until after init.sqf?

cosmic lichen
#

Execute the code at the top of init.sqf?

tender sable
#

I guess that's the crux of my question. Making an addon that has a hashmapobject as a collection. I want other addons or mission makers to be able to add to the collection or override values in the collection before it processes and compileFinals for general use thorughout the mission. I just want to know if I have to document a warning saying, if using in SP you need to process it manually (call the second function) in init.sqf on your own.

polar belfry
#

before the createvehicle

#

I am still using the given code

tender sable
polar belfry
#

yea I accidentally changed the wrong value

grizzled cliff
#

:P its way more confusing to have to remember all the shit that goes into the thing you are writing

ornate whale
#

Is there any way how to make a looped sound fade in and fade out without muting other sounds? Like a wind or storm, so that it doesn't start at maximum volume?.

drifting spire
#

does BIS_fnc_attachToRelative work with JIP?

candid sun
#

i think it's time for me to man up and open VS again

gray bramble
#

Could be useful to look at a couple youtube videos or such about how the basics of vs works.

fair drum
hallow mortar
#

The easier way would probably be to just put fading in the audio file itself

#

Won't work for every kind of looped sound but for wind it'd be fine

ornate whale
hushed tendon
#

Anyway to get a units launcher and it’s ammo cause you got like primaryWeapon and primaryWeaponMagazine

#

But not finding those commands for the launcher

little raptor
#

secondaryWeapon, etc.

sullen marsh
#

VS is easy peasy if you just want to write a program that compiles

#

Open it, write code, click compile

drifting portal
#

is there a way to play a sound with radio filter through script?
maybe at least fake it if not possible?

#

for example in radio protocol if unit is close to the player you hear the unit normally but if far away the unit sound will have a radio filter applied

exotic flame
mint goblet
#

like many other IDE's

proven charm
#

any tips on how to find UNS_SIMC_61_LIGHT from the config? it's not in CfgWeapons, CfgMagazines, CfgGlasses or CfgVehicles.

little raptor
#

what is that supposed to be? where did get it from?

proven charm
little raptor
#

what kind of item?

proven charm
#

i really have no idea

little raptor
#

well where does it come from?

proven charm
#

from this ```sqf
{
_a = getArray (_manConf >> _x);
{
diag_log format ["--> %1", _x];
} foreach _a;
} foreach ["magazines","items","linkedItems"];

#

the _x

little raptor
#

dunno. what about cfgNonAIVehicles, cfgAmmo?

proven charm
#

checking....

proven charm
little raptor
#

it sounds like it's weight

proven charm
#

yea

little raptor
#

well just dump the config and search blobdoggoshruggoogly

proven charm
#

how do I do that?

little raptor
#

on dev branch you can use the diag_dumpConfigToFile iirc

proven charm
#

ok

little raptor
#

diag_exportConfig 😅

#

needs diag exe

proven charm
#

dont have that :/

#

odd I ran diag_exportConfig in debug console and it copied some stuff to clipboard

little raptor
#

it doesn't copy to clipboard

proven charm
#

oh

little raptor
#

you must download its extension too

#

it's 32 bit notlikemeow

#

well it's open source so you can just compile it to x64

proven charm
#

ok thx

#

What's weird though Is that I found the guy who has the item but I cannot get the item listed using any of the script commands

meager granite
#

Searching for "RscCompass" like this:

17:22:58 bin\config.bin >> RscCompass
17:22:58 bin\config.bin >> RscTitles >> RscCompass
exotic flame
#

How to detect when the player is leaving the mission ? I tried to use Ended and MPEnded event but it's not working

proven charm
meager granite
exotic flame
meager granite
#

Server

addMissionEventHandler ["PlayerDisconnected", {
    _this remoteExecCall ["client_onPlayerDisconnected", 0];
}];

Client

client_onPlayerDisconnected = {
    params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
    systemChat format ["Player UID=%1 just left!", _uid];
};
exotic flame
#

I found a way around anyway

meager granite
#

Wait, are you trying to check when YOUR client is leaving the game?

exotic flame
#

Or more precisely, when my client is leaving the mission

meager granite
#

Display 46 closes when mission ends for whatever reason

#

Wont trigger if game crashes or you kill the process of course

exotic flame
#

I just needed to release a dll but it actually doesn't need to be released precisely when my client is leaving the mission so i'm just reinitialising it on postInit

exotic flame
meager granite
exotic flame
meager granite
#

Is there a way to know when you got the last message from server or something similar?

#

Main purpose - lagswitch detection. At the moment thinking about sending players a RE or PV each X ms and if they stop getting it for longer than a threshold then they lost a connection

#

Such delays can then be double checked with the server to make sure it wasn't the server being frozen but client losing the connection

pulsar bluff
meager granite
#

Objects are not often at all, depending on distance to camera

pulsar bluff
#

setmarkerpos is global

meager granite
#

Yes, but how often it updates it? Does it send the message right away?

#

Also doesn't it send the whole marker instead of just position? Might be too excessive 🤔

vocal mantle
#

@grizzled cliff Thanks for the tips, will look into that. Yes it is VS2015. Otherwise I have accepted that my code starting out wont be perfect. Right now I am happy enough with the functionality of the UI. Next task is implementing sockets.

grizzled cliff
#

lol trust me, doing it the "right" way when learning solves about a billion issues down the road

elfin inlet
#

I'm working on a script I found a while back to make an custom AI unit spawn with random weapons determined by this function. It runs the function without errors, but nothing happens. Can someone tell me why?

_this setVariable ["BIS_enableRandomization", false];
sleep 0.2;
_class = typeOf _this;
_randomWeaponChance = floor (random 100); 
_randomWeapon = floor (random 100); 
_randomWeaponProbability = 50;

if (_randomWeaponChance <= _randomWeaponProbability) then // replace default weapons
{
    if (isServer) then
    {
        removeAllWeapons _this; // delete default weapons / ammo                            
        switch _class do 
        {
            case "AuxNSWGX_OPFOR_VE_Territorial_Base": 
            {
                switch (_randomWeapon) do 
                {
                    case (_randomWeapon <= 40):
                    {
                        _this addWeapon "AuxNSWGX_VE_ARM_47M";
                        _this addMagazines ["AuxNSWGX_VE_762x39_30Rnd_Mag",5];
                        _this addMagazines ["AuxNSWGX_VE_762x39_Tracer_30Rnd_Mag",3];
                    };
                    case (_randomWeapon > 40 and _randomWeapon <= 70): 
                    { 
                        _this addWeapon "AuxNSWGX_VE_ARM_74S";
                        _this addMagazines ["AuxNSWGX_VE_556x45_30Rnd_Mag",5];
                        _this addMagazines ["AuxNSWGX_VE_556x45_Tracer_30Rnd_Mag",3];
                    };
                    case (_randomWeapon> 70 and _randomWeapon <= 80): 
                    { 
                        _this addWeapon "AuxNSWGX_VE_ARM_37";
                        _this addMagazines ["AuxNSWGX_VE_762x51_32Rnd_Mag",5];
                        _this addMagazines ["AuxNSWGX_VE_762x51_Tracer_32Rnd_Mag",3];
                    };
                    case (_randomWeapon > 80 and _randomWeapon <= 90): 
                    { 
                        _this addWeapon "AuxNSWGX_VE_ARM_MX";
                        _this addMagazines ["AuxNSWGX_VE_762x51_32Rnd_Mag",5];
                        _this addMagazines ["AuxNSWGX_VE_762x51_Tracer_32Rnd_Mag",3];
                    };
                    case (_randomWeapon > 90 and _randomWeapon <= 100): 
                    { 
                        _this addWeapon "AuxNSWGX_VE_ARM_CT";
                        _this addMagazines ["AuxNSWGX_VE_95x40_36Rnd_Mag",5];
                        _this addMagazines ["AuxNSWGX_VE_95x40_Tracer_36Rnd_Mag",3];
                    };
                    default 
                    { 
                        _this addWeapon "AuxNSWGX_VE_ARM_47M";
                        _this addMagazines ["AuxNSWGX_VE_556x45_30Rnd_Mag",5];
                        _this addMagazines ["AuxNSWGX_VE_556x45_Tracer_30Rnd_Mag",3];
                    };
                };
            };
        };
    };
};
meager granite
#
_this call selectRandomWeighted [
    {
        _this addWeapon "AuxNSWGX_VE_ARM_47M";
        _this addMagazines ["AuxNSWGX_VE_762x39_30Rnd_Mag",5];
        _this addMagazines ["AuxNSWGX_VE_762x39_Tracer_30Rnd_Mag",3];
    }, 40
    ,{
        _this addWeapon "AuxNSWGX_VE_ARM_74S";
        _this addMagazines ["AuxNSWGX_VE_556x45_30Rnd_Mag",5];
        _this addMagazines ["AuxNSWGX_VE_556x45_Tracer_30Rnd_Mag",3];
    }, 30
    ,...
]
#

(40 and 30 are not percent here, they're 40/70 and 30/70 chance)

#

Probably can just do call instead of _this call

elfin inlet
#

Gotcha. That makes sense.

#

Definitely simplifies it. Scripting is not my specialty but I'm getting there. Thank you for the help

meager granite
#

Another bit of advice, to avoid deep indentations you can replace if(isServer) {... which adds another tab, with if(!isServer) exitWith {};, will make your code more readable

vocal mantle
#

I think learning SQF first has made me worry too much about performance, like my use of char pointers over strings.

meager granite
#
if (_randomWeaponChance <= _randomWeaponProbability) then // replace default weapons
{
    if (isServer) then
    {
        removeAllWeapons _this;
        ...
    };
};
```=>```sqf
if (_randomWeaponChance <= _randomWeaponProbability) then // replace default weapons
{
    if (!isServer) exitWith {};

    removeAllWeapons _this;
    ...
};
#

Or even a one-liner

if(isServer && {_randomWeaponChance <= _randomWeaponProbability}) then ...
elfin inlet
#

And that would reduce the tab again?

meager granite
#

No, just less clutter to focus on important stuff

#

You probably can make this one-liner an exitWith too but I assume you're doing something else for non-servers later

#

Up to you though, your code looks nice already

elfin inlet
#

I didn't have any plans for non-servers as this is for use with a faction for my unit. Just to keep some diversity with the weapons they use. But cool. I'm gonna adjust and give it a whirl

low zodiac
#

Hello!
I am currently running into a small AI related issue.
This is the code that I am using to check if the AI group is inside the helicopter:

{alive _x && {_x in evacHELO}} count units natoSQUAD isEqualTo ({alive _x} count units natoSQUAD)

This works all fine, but when I shoot the legs of an AI in the group (for example the sharpshooter), the AI refuses to board the vehicle, but it still completes the check and triggers the hint.
I've also tried moveInAny after the activation, but that doesn't get the injured AI inside the vehicle.

Does somebody have an idea to force the AI to board the vehicle in any other way? (Already saying sorry if I missed something very obvious :D)

Video for reference: https://www.youtube.com/watch?v=3TH42Pblv9o

ornate whale
#

Is it possible to create a SFX sound without a specific spacial source?

little raptor
#

playSound

hallow mortar
#

playSound can't create SFX classes. It only uses cfgSounds.

little raptor
#

oh you mean CfgSFX ones. well those can only played with createSoundSource afaik

#

you can play them manually tho

#

all you need is the path to their sound files

hallow mortar
#

You'd have to fully reconstruct all the randomisation and looping features though, which is presumably why they want to use SFX in the first place

hushed tendon
ornate whale
#

How do I access a parent element (_x) in forEach within a forEach? Should I declare a private variable for it?

little raptor
#

yes. you should save it into another var before entering the nested forEach

ornate whale
narrow crypt
#

"line 167: '/CfgRespawnInventory/Blufor9.': '{' encountered instead of '='"

  161  {
  162      displayName = "LAT (M4A1 Tac)";                                
  163       icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
  164      role = "LAT";
  165      
  166      weapons[] = {"SMA_M4MOE","launch_NLAW_F","hgun_Pistol_heavy_01_F","Rangefinder","Throw","Put"};
  167      magazines[] = {"SMA_30Rnd_556x45_M855A1","11Rnd_45ACP_Mag","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SmokeShell","SmokeShell","SmokeShell","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","HuD_ChemFlare_Red_Mag","HuD_ChemFlare_Red_Mag","SmokeShellRed","SmokeShellPurple","SmokeShellGreen","HandGrenade","HandGrenade","HandGrenade","HandGrenade","11Rnd_45ACP_Mag","11Rnd_45ACP_Mag","11Rnd_45ACP_Mag","11Rnd_45ACP_Mag"};
  168      items[] = {"ACE_EarPlugs","ACE_EntrenchingTool","ItemAndroid","ACE_IR_Strobe_Item","ItemcTabHCam","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_morphine","ACE_splint","ACE_splint","ACE_tourniquet","ACE_tourniquet","ACE_tourniquet","ACE_tourniquet","kat_chestSeal","kat_guedel","kat_larynx","ACE_epinephrine"};{"ACE_EntrenchingTool","ItemAndroid","ItemcTabHCam","ACE_EarPlugs","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_morphine","ACE_splint","ACE_splint","ACE_tourniquet","ACE_tourniquet","ACE_tourniquet","ACE_tourniquet","kat_chestSeal","kat_guedel","kat_larynx","ACE_epinephrine"};
  169      linkedItems[] = {"USP_CRYE_CPC_FAST_BELT_MC","opscore_highcut_cover_mc_US","USP_BALACLAVA_ESS_CBR","SMA_eotech552_3XDOWN","SMA_SFPEQ_M4TOP_BLK","ItemMap","ItemCompass","Foski_IRStrobeBeaconItem","TFAR_anprc152","ItemGPS"};
  170      uniformClass = "USP_G3C_KP_MX_MC";
  171      backpack = "USP_CRYE_BELT_PACK_MC";
  172  };``` No clue whats up here, or maybe im blind, sorry its kinda unreadable
sullen sigil
#

this is config isssue not scripting

grizzled cliff
#

so i dont know why i do average times, but really need to not do that...

#

18:09:46 avg: 0.135632324218750000000000ms @ 10000
18:09:46 median: 0.000000000000000000000000ms @ 10000
18:09:46 min/max: 0.000000000000000000000000ms/1.098632812500000000000000ms @ 10000
18:09:46 0ms count: 8644

unreal scroll
#

Maybe I need to sleep, but...
Why this doesn't work?

~~```sqf
[player, unit] select (isPlayer _x);

It says ```Error 3 установлено элементов, 1 ожидалось```~~
Yes, I need to sleep...
hallow mortar
#

Here, take these: {}

unreal scroll
#

No, I mean why in this case it doesn't work as expected. I want to select element 0 or element 1 depending on boolean condition.
Like

["", "0"] select (date select 1 < 10) 

returns "" or "0".
But what is wrong with the command above?

hallow mortar
#

Assuming _x is a valid reference to a unit that can be checked with isPlayer, and unit is indeed a single unit, logically nothing is wrong

#

Check other nearby lines for missing ] or variables with unexpected contents

#

Because an open [ somewhere before might only be caught now, when a ] catches up to it

#

When you test the line alone, without any other code, are you still using _x?

unreal scroll
#

Ahhhr

#

Yup, I'm sure I need to sleep )) There is no _x, thanks

green quail
#

trying my hand at a script, having an issue I am having difficulty solving.

class EventHandlers 
{
  class onfire
  {
    fired =
  "_myWeapon = _this select 0; \
  _vehicle = vehicle _myWeapon; \
  _targetRadius = 50; \
  _objects = nearestObjects [getPosATL _vehicle, ['Man'], _targetRadius]; \
  { \
      _object = _x; \
      if (side _object != side player) then { \
         hint format['Firing at enemy: %1', name _object]; \
         diag_log format['Firing at enemy: %1', name _object]; \
        _bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) vectorAdd [0,0,50]), [], 0,'CAN_COLLIDE']; \
        _bullet setVelocityModelSpace [0,0,100]; \
        diag_log 'Bullet created'; \
    }; \
} forEach _objects;";
};
};```

The end goal is to make this fire a bullet at all enemies within X range.
The current error it is generating is: 

``` 0:46:34 "Firing at enemy: Stavros Strambopoulos"
 0:46:34 "Bullet created"
 0:46:34 Error in expression <]; _bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) ve>
 0:46:34   Error position: <createVehicle [((getPosATL _myWeapon) ve>```
warm hedge
#

_myWeapon is a string there, I assume?

green quail
granite sky
#

As far as I can tell those event handlers are undocumented.

granite sky
#

maybe chuck a diag_log str _this at the top of it.

#

config event handlers in general.

warm hedge
#

It is identical with Fired unit EH IIRC

green quail
#

this has a location with weapon configs

granite sky
#

Yes, but it doesn't say what the parameters are.

green quail
#

hm

green quail
# granite sky maybe chuck a `diag_log str _this` at the top of it.

Like this?

class EventHandlers 
{
  class onfire
  {
    fired =
  "diag_log str _this;\
  _myWeapon = _this select 0; \
  _vehicle = vehicle _myWeapon; \
  _targetRadius = 50; \
  _objects = nearestObjects [getPosATL _vehicle, ['Man'], _targetRadius]; \
  { \
      _object = _x; \
      if (side _object != side player) then { \
         hint format['Firing at enemy: %1', name _object]; \
         diag_log format['Firing at enemy: %1', name _object]; \
        _bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) vectorAdd [0,0,50]), [], 0,'CAN_COLLIDE']; \
        _bullet setVelocityModelSpace [0,0,100]; \
        diag_log 'Bullet created'; \
    }; \
} forEach _objects;";
};
};```
granite sky
#

you missed the semicolon.

green quail
#

you're right

#
 1:11:58 "Bullet created"
 1:11:58 Error in expression <]; _bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) ve>
 1:11:58   Error position: <createVehicle [((getPosATL _myWeapon) ve>
 1:11:58   Error 4 elements provided, 3 expected
 1:11:58 "Firing at enemy: Abdul-Latif Khusraw"
 1:11:58 "Bullet created"
 1:11:58 Error in expression <]; _bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) ve>
 1:11:58   Error position: <createVehicle [((getPosATL _myWeapon) ve>
 1:11:58   Error 4 elements provided, 3 expected```
granite sky
#

It doesn't seem to be running the new code.

green quail
#

repacking just in case

green quail
granite sky
#

Maybe that stuff needs the whitespace before the backslash. I wouldn't know.

hallow mortar
#

Wrong createVehicle syntax

#

you're using half of the main syntax and half of the alternative syntax

green quail
#

oh?

hallow mortar
#

https://community.bistudio.com/wiki/createVehicle
You're doing this:

_class createVehicle [_position, _markers, _radius, _placement];

But that isn't a valid syntax. Because you're putting the class as the left argument, like the main syntax, the game is trying to interpret the right argument array as a position (3-element array), as it expects from the main syntax, and getting confused because it's not actually a 3-element position array.
You need to commit to either of the two syntaxes specified in the documentation. I suggest the second one since it has the exact placement parameter.

green quail
#

so to be clear:

type createVehicle position

Parameters:
  type: String - vehicle/object className
  position: Array format Position - desired placement position. If the exact position is occupied, nearest empty position is used.
Return Value:
Object```
#

You are saying I am mixing type and position

#

OH

#

I see

#

createVehicle [type, position, markers, placement, special]
Parameters:
type: String - vehicle/object className

#

so I am using this:
createVehicle [((getPosATL _myWeapon) vectorAdd [0,0,50])

You are suggesting I use:
createVehicle [type, position, markers, placement, special]

hallow mortar
#

You're currently using neither of the actual syntaxes, which is why it isn't working. You have the classname arranged as it would be for the main syntax (left of the command), and everything else arranged as it would be for the alternative syntax (in an array right of the command). Syntaxes can't be mixed like that. You must choose one of the two syntaxes - either _class createVehicle _position or createVehicle [_class, _position, _markers, _placement, _special]. I think the second, alternative syntax is best for what you're doing.

green quail
#

_bullet = createVehicle ['B_9x21_Ball_Tracer_Green', getPosATL _object, [], 0, 'CAN_COLLIDE'];

does this appear better to you @hallow mortar ?

hallow mortar
#

That matches one of the available syntaxes, so it should work.

green quail
#

cool. Sorry, I am slow at this, I am really new to scripting and kinda trying to fumble through this.

#
class EventHandlers 
{
  class onfire
  {
    fired =
  "diag_log str _this;\
  _myWeapon = _this select 0; \
  _vehicle = vehicle _myWeapon; \
  _targetRadius = 50; \
  _objects = nearestObjects [getPosATL _vehicle, ['Man'], _targetRadius]; \
  { \
      _object = _x; \
      if (side _object != side player) then { \
         hint format['Firing at enemy: %1', name _object]; \
         diag_log format['Firing at enemy: %1', name _object]; \
        _bullet = createVehicle ['B_9x21_Ball_Tracer_Green', getPosATL _object, [], 0, 'CAN_COLLIDE']; \
        _bullet setVelocityModelSpace [0,0,100]; \
        diag_log 'Bullet created'; \
    }; \
} forEach _objects;";
};
};```
hallow mortar
#

I'm pretty sure you don't need those \. Dunno if they'll actually break anything by being there, but they don't do anything useful either.

green quail
#

just a means for the script to be recognized across lines. Easier to see, when implementing I use a single line to prevent those problems

#

great news! That appears to be a step in the right direction

#

Do you think it will be hard to make it originate from a memory point and fire the spawn ammo type at the targets?

#

@hallow mortar

hallow mortar
green quail
#

I appreciate you deeply. Thank you.

umbral sphinx
#

Hey everyone!
So i am running Liberation server and i have restart script in the mission file.
The problem is, that after scripted restart HC isnt joining server, and after trying to start it manually it says that server is stopped.
Anyone have idea how to fix it?

candid sun
#

i'm only learning c# to make a game in Unity, i just don't like monodevelop so started using np++ instead. will probably switch to VS express soon.

granite sky
tough abyss
#

Hello 😄 I have a mission where a blufor is in a static weapon trying to push enemy waves. Sometimes he'll die, but I want him to respawn in the same static weapon. How can I do ?

unreal scroll
#

@tough abyss Maybe - just disable damage for him? 🙂 Or you just want him to die?

_unit allowdamage false;
tough abyss
unreal scroll
#

Ok. So how do you suppose it should looks like? Describe in details. Like, you want him to fall unconscious, and maybe then he should "wake up" and return to his place, or to remove him completely, or to keep the body in place, and spawn a new unit?
The basics is very simple - just create a unit with the same loadout (see getunitloadout/setunitloadout) and order him to occupy the gun. The real algorithm depends on the desired design.

silver ridge
#

Yeah I'm not a fan of MonoDevelop at all either, so I can't blame you there.

tough abyss
#

But I want it to be 30sc After

unreal scroll
#

You need the Killed/MPKilled event handler. In its code something like that:

OT_gunner_handler = {
    _this spawn {
        params ["_unit"];
        _loadout = getunitloadout _unit;
        _type = typeof _unit;
        _gun = gun 
       _group = if ({alive _x} count units group _unit > 0) then {group _unit} else {creategroup blufor}; // set the needed side
        _pos = ... // set the needed pos for new unit to spawn, I suppose you wanted him not to be visible for players initially?
        sleep 30;
        if (isNull objectParent _unit) then {
            deletevehicle _unit;
        } else {
            vehicle _unit deleteVehicleCrew _unit;
        };
        _newunit = _group createUnit [_type,_pos,[],0,"NONE"];
        _newunit setunitloadout _loadout;
        _newunit assignAsGunner gun;
        [_newunit] orderGetIn true; // This variant is for more realistic behavior. If not needed, use _newunit moveInAny gun
        _newunit addEventHandler ["Killed", OT_gunner_handler];
    };
};

// Define the gun, in your case it is better to have a global variable to handle it, like gun
gunner gun addEventHandler ["Killed", OT_gunner_handler];
tough abyss
#

Thank you very much ! Where should I put this code ?

unreal scroll
#

Anywhere where it runs during mission init 🙂
I recommend to put it in the gun or gunner init fields.
Don't forget to adjust the name for the gun.
If using it in the gunner init, you can use

this addEventHandler ...
``` instead of gunner gun
#

Ah, I forgot to add the same EH for the new unit. Is it needed? If so, I edited the code above a bit.

tough abyss
#

Man thx very much, tho i'll be honest with you I don't understand anything in coding so it seems like you talk chinese to me

#

I don't even know how to get the pos

#

I'll try putting this code as it is in the gunner init field and see what happens

#

Yea didn't worked, guess i don't know how to use it

#

Thank you very much tho 😦

green quail
real tartan
granite sky
green quail
granite sky
#

They all claim to return values in model space.

green quail
#

hm

granite sky
#

A LOD's just a set of geometry for a model.

green quail
#

yeah, I understand that.

Currently my script looks like this:

    params ['_unit', '_weapon', '_muzzle', '_mode', '_ammo', '_magazine', '_projectile', '_gunner'];
    if (_weapon == 'TESTWEAPON') then {
        _vehicle = vehicle _unit;
        _targetRadius = 300;
        _objects = nearestObjects [getPosATL _vehicle, ['Man', 'LandVehicle'], _targetRadius];
        {
            _object = _x;
            if (side _object != side player) then {
                _muzzlePos = _object selectionPosition ['pos_barrel_end', 'memory', 'FirstPoint'];
                _direction = _muzzlePos vectorFromTo (getPosATL _object);
                _bullet = createVehicle ['B_9x21_Ball_Tracer_Green', _muzzlePos, [], 0, 'CAN_COLLIDE'];
                _bullet setVelocityModelSpace (_direction vectorMultiply 100);
                hint format['Firing at enemy: %1', name _object];
                diag_log format['Firing at enemy: %1', name _object];
                diag_log 'Bullet created';
            };
        } forEach _objects;
    };
};```
#

you're saying to use modelToWorldto translate a location from selectionPosition, to be clear?

granite sky
#

yeah, this part is wrong: _muzzlePos vectorFromTo (getPosATL _object);

green quail
#

wait, is it?

granite sky
#

_muzzlePos is in model space, getPosATL _object is in world space.

green quail
#

Oh

#

so modelToWorld is used to convert _muzzlePos into world space
then I use that value as (for example)
_modelToWorldValue vectorFromTo (getPosATL _object);

#

am I understanding that correctly?

granite sky
#

yes.

green quail
#

_bullet = createVehicle ['B_9x21_Ball_Tracer_Green', _muzzlePos, [], 0, 'CAN_COLLIDE']; would also need adjusted, correct?

granite sky
#

Yes.

green quail
#

got it. So once _muzzlePos is defined in the model space, it needs converted to the world space. Then use the new world space value for all further instances it in this case.

#

Sorry, I am new to scripting and actively taking notes, but I want to make sure they are clear for me in the event I need them again.

granite sky
#

There are a couple of extra complicating factors that might be relevant here.

#

selectionPosition uses render time scope rather than simulation time scope, so you should probably be using modelToWorldVisual and getPosWorldVisual.

#

getPosWorldVisual then needs translating with ASLtoAGL to match.

green quail
#

in which case do I still need to use modelToWorld or selectionPosition?

granite sky
#

you'd use modelToWorldVisual instead of modelToWorld.

#

selectionPosition is required to get the muzzle position.

green quail
#

so I would use selectionPosition, modelToWorldVisual and getPosWorldVisual then?

granite sky
#

or getPosASLVisual maybe. Depends what bit of the target you're intending to shoot at.

green quail
#

ideally, center of mass for men and (land) vehicles

granite sky
#

Most models are centered I think, so getPosWorldVisual might be better.

#

Not sure where getPosASL puts the Z. I recall getPosATL using the floor contact point.

green quail
#

do you mind if I post the new version when I make the adjustments? @granite sky ?

#
    params ['_unit', '_weapon', '_muzzle', '_mode', '_ammo', '_magazine', '_projectile', '_gunner'];
    if (_weapon == 'TESTWEAPON') then {
        _vehicle = vehicle _unit;
        _targetRadius = 300;
        _objects = nearestObjects [getPosASLVisual _vehicle, ['Man', 'LandVehicle'], _targetRadius];
        {
            _object = _x;
            if (side _object != side player) then {
                _muzzlePos = _object selectionPosition ['pos_barrel_end', 'memory', 'FirstPoint'];
                _muzzlePosWorld = _object modelToWorldVisual _muzzlePos;
                _direction = AGLtoASL _muzzlePosWorld vectorFromTo (getPosWorldVisual _object);
                _bullet = createVehicle ['B_9x21_Ball_Tracer_Green', _muzzlePosWorld, [], 0, 'CAN_COLLIDE'];
                _bullet setVelocityModelSpace (_direction vectorMultiply 100);
                hint format['Firing at enemy: %1', name _object];
                diag_log format['Firing at enemy: %1', name _object];
                diag_log 'Bullet created';
            };
        } forEach _objects;
    };
};
granite sky
#

missing the ASL/AGL conversion

green quail
#

f

granite sky
#

_direction = _muzzlePosWorld vectorFromTo (ASLtoAGL getPosWorldVisual _object);

#

well....

#

on second thoughts, conversion should be the other way around:
_direction = AGLtoASL _muzzlePosWorld vectorFromTo (getPosWorldVisual _object);

#

3d directions from AGL positions are not correct.

granite sky
#

wait, I misread this.

#

What are you actually trying to do?

#

It feels like the object shouldn't be trying to shoot itself, but people do some weird shit.

green quail
#

Specifically, this is an eventhandler in a cfgweapon using "fired" to trigger.

The goal is for the script to fire a round, at all men and land vehicles that are not of the same side within 300m.

#

Testing it, what it appears to do is spawn the round at their feet.

#

(though it does not appear to function after that.)

granite sky
#

_object is the wrong var in both of these. Not sure if you meant _unit or _vehicle.

_muzzlePos = _object selectionPosition ['pos_barrel_end', 'memory', 'FirstPoint'];
_muzzlePosWorld = _object modelToWorldVisual _muzzlePos;
green quail
#

as this is firing from a vehicle, should it use _vehicle then?

#

huggggeee hype! It is working!! thank you so, so, so much!

#

the rounds appear to be falling short, wondering if they are targeting the ground point or if their velocity is too low and gravity is winning that fight

granite sky
#

well, 300m is a long way for 9mm.

green quail
#

I switched to 120mm HE for visual confirmation as I couldn't see the 9mm

Also trying an ammo class that doesn't have bullet drop now.

It appears to be aiming at their feet

#

@granite sky do you think adding another variable to set this to aim a little higher would be a good fix?

_this call {
    params ['_unit', '_weapon', '_muzzle', '_mode', '_ammo', '_magazine', '_projectile', '_gunner'];
    if (_weapon == 'TESTWEAPON') then {
        _vehicle = vehicle _unit;
        _targetRadius = 300;
        _objects = nearestObjects [getPosATL _vehicle, ['Man', 'LandVehicle'], _targetRadius];
        {
            _object = _x;
            if (side _object != side player) then {
                _targetPos = _object modelToWorldVisual [0, 0, 1];  // Adjust the offset as needed
                _muzzlePos = _object selectionPosition ['pos_barrel_end', 'memory', 'FirstPoint'];
                _muzzlePosWorld = _object modelToWorldVisual _muzzlePos;
                _direction = _muzzlePosWorld vectorFromTo _targetPos;
                _bullet = createVehicle ['B_9x21_Ball_Tracer_Green', _muzzlePosWorld, [], 0, 'CAN_COLLIDE'];
                _bullet setVelocityModelSpace (_direction vectorMultiply 100);
                hint format['Firing at enemy: %1', name _object];
                diag_log format['Firing at enemy: %1', name _object];
                diag_log 'Bullet created';
            };
        } forEach _objects;
    };
};```
#

the comment is only there to show intent, I don't think arma scripts like comments.

grizzled cliff
#

MS offers the full VS product (well mostly full) now for open source stuff

#

VS2015 community edition

unreal scroll
#

@green quail Do you need a working script for correcting bullet trajectories?

green quail
#

god yes

#

the round fire but appear to be aiming below the ground

#

@young current is this your doing?

#

((I was working with the Goat on this. He was offering advice/solutions to this problem))

unreal scroll
#

As for me, I had problems with FoW static machine guns. I'm not good with configs, so I made a simple workaround for it, in Fired event handler:

private _velocity = velocitymodelspace _projectile;
private _newvelocity = _velocity vectoradd [3,0,-4]; //You need to set your own values
_projectile setvelocitymodelspace _newvelocity;

Considering the effective range for bullets usually is not higher than 300-400 meters, it works very well

green quail
#

I do have to get going here in a moment, would you mind if I pinged you tomorrow?
@unreal scroll

#

I appreciate you!

unborn bramble
#

How performance consuming is attaching "handleDamage" on multiple units? Does it trigger only on hit or just it being added on many units also gonna affect performance? How preferable is editing ammo config for damage edit?

granite sky
#

It only triggers on hits but it does trigger several times per hit.

unreal scroll
#

@unborn bramble Why to ask if you can just test it by yourself? 🙂
Your testing environment and conditions could seriously vary from other players experience.
Place a hundred of units, and kill them without and with EH to see the difference.

"How preferable is editing ammo config for damage edit?"
Simple arithmetic operations almost have no effect.And almost every command could be tested in console for it's burst time.

granite sky
#

On a client, the ragdoll cost is far, far higher than the handleDamage cost.

hallow mortar
#

Adjusting damage by changing the ammo config is probably not a great idea, firstly because there are so many ammo types to modify and secondly because of the wide-ranging balance implications.
If you want to make certain units more or less resilient and you're willing to make a mod to do it (config changes of this type can't be done without a mod), it would be better to change the armour rating of those units, or give them new vest or uniform variants that have appropriate armour.
HandleDamage is the best solution for per-mission changes - mods are overkill for a single mission and depending on the change, can affect gameplay outside of the mission.

dreamy kestrel
#

Q: does a mission or a server get an ID of any sort? i.e. that we might use to inform a persistence variable?

dusk gust
opal zephyr
#

missionNamespace can be used to save values to the mission for persistence

dusk gust
opal zephyr
#

Im not sure if missionNamespace will save after the mission/server is restarted. But players leaving wont affect it. If its a player related thing to save, then use profileNamespace, and that will save between leaving and joining

#

There are some mods out there for specific persistence that save info to an external file. Thats the only way I know of that works for saving mission/server related info after a restart

vocal valley
#

Any one have a script to see your breath when its cold?

dreamy kestrel
queen cargo
#

@candid sun writing c# without VS is like breathing air without O2
you can do it
you should not as it is harmful

ornate whale
#

Is it possible to find out how many doors (entrances) a building has? Through a command or config parameter?

dreamy kestrel
opal zephyr
#

apparently animationNames might work too

dreamy kestrel
#

will have to experiment with selectionNames, and then convert from modelToWorld, etc...

granite sky
#

you could loop that until it returns [0,0,0], I guess.

#

I don't think you get full script access to the path LOD though.

#

which is kinda annoying because the building pathfinding is broken.

dreamy kestrel
#

it can be done with the function I posted, need to experiment with the selections is all...

granite sky
#

It doesn't seem to return any associative data. It's just a list of positions and exits.

#

oh, unless there's stuff other than "pos" and "in" prefixes in there.

dreamy kestrel
#

he wants to know doors, entrances, I believe that is the "in" prefix...

#

but you get the other selection goodness as well. experiment, have fun!

#

there are other scripting commands you can use, but I don't think they are nearly as reliable...

granite sky
#

I would expect buildingExit to find anything with "in" on it, but I might be wrong.

meager granite
ornate whale
#

Currently I do it by looking through buildingExit and grouping them by distance into individual exits

dreamy kestrel
dreamy kestrel
meager granite
vocal mantle
#

Considering it's a language designed and developed by Microsoft, it only makes sense to use their IDE.

dreamy kestrel
errant iron
glossy trench
#

Would anyone wanna help me with an old script that's messing I guess with a mod I have?

warm hedge
glossy trench
#

Okaaaaayyyy, I get it but- also don't at the sametime, although tbh my brain also just hurts atm so uh.. yeah.. thanks I guess..

ivory lake
#

he's saying just ask the question instead of asking for permission to ask it

#

cuz it's a waste of time

reef grove
#

give details

glossy trench
#

Also yeah, I guess let me figure out how I'm gonna word this..

#

So I'm working on a mission that deals with an AI script, "Bon's infantry Recruitment Redux" something created a long time ago back in the ARMA 2 days, now it's a fine script, setting it to an object or player as an addaction, or alternatively too yourself (which is kind of funny ngl). But at the current moment, I have a mod called "MGI's Advanced modules" and I think I've narrowed the problem down to the Bon's script stuff itself. I say this because the mods can work in an absolute environment, but considering that my scenario has some virtual elements too it, not absolute, so things like (Alive/MGI/etc) I think that Bon's script is conflicting with some stuff, I've already fixed one thing with the loadout transfer stuff and getting it disabled on another mod in the mission, but so far MGI's "AI can heal and revive" aswell as "AI can respawn", Bon's script might be conflicting with those two modules within the Mod, because without the sudden Recruiting, AI teammates can actually work with MGI's stuff.. I just don't know where I would be scanning to find such a confliction, mainly because I don't know any SQF myself, so I was wondering if anyone could help..

(First time asking on this kind of stuff btw..)

#

(Also if it helps the mission itself is a Zeus sandbox Scenario using CUP, has a total of 7 supports, ambient Civs using Alive, and Ambient Traffic using MGI's stuff, Spyder's addons having a loadout Transfer for AI and saving classes in subfolders for yourself and others, Ace Arsenal, and Revivable AI both by them and you alike..)

split scarab
#

Is there an Event that's fired when someone tries to equip a restricted uniform? And could you make use of isUniformAllowed and forceAddUniform to bypass the uniform restrictions that prevent you from wearing a uniform from another faction?

warm hedge
#

Do you mean if you tried to drag and drop the uniform on gear screen?

split scarab
#

Yeah or right click to equip or equip in arsenal

warm hedge
#

Not even sure if there is a “good” way to detect dragging item or such

#

Gear screen is very Engine-driven as far as I can tell

split scarab
#

Yeah, I've been looking at 'Take' and that one, not able to test right now if it's fired when trying to equip a restricted item as well

meager granite
drifting portal
#

Why is kbAddTopic taking 10 minutes to get executed?

#

.bikb is 2 million lines (isn't 10 minutes still an exaggeration?)

#

Anyways to go about optimizing it?

winter rose
#

…reduce the file size?

drifting portal
winter rose
#

¯_(ツ)_/¯

drifting portal
winter rose
#

try splitting it in at least 10 different files, it may help 😬

drifting portal
#

Is stacking the whole file into a single line also helps?

meager granite
drifting portal
#

I was testing if the game could load the lines properly

sullen sigil
half sapphire
#

hi guys. im still playing around with handleDamage EH on a AI unit to give it a revive. went back and forward with different methods and find 1 reliable one. not the prettiest but reliable. however, im still having issues with the locality of the EH, since the unit starts server owned but will eventually join a player's group.
if i add the EH with remoteExec 0, it fires twice, if i remoteExec to the unit (where ever is local atm of adding), when the unit changes owner the EH does not register. im confused af.

hallow mortar
#

Add the EH everywhere and put an if !(local _unit) exitWith {}; in it

white drum
noble comet
#

Does anyone know how to delete opfor/bluefor npc via script

#

and also is there an function the save the current goggles, set other ones then wait for a random time and set the old ones again

winter rose
#

deleteVehicle _theGuy?

hallow mortar
hallow mortar
#

There's no need to DM me. This channel is for asking scripting questions.
"Suspending not allowed" means the context you're trying to use it in is "unscheduled" - the code is run immediately and without interruption and can't be managed by the game's script scheduler. To prevent freezing the game, sleep is not allowed in unscheduled code.
You can easily fix this by creating a scheduled context, where sleep is allowed, using spawn (https://community.bistudio.com/wiki/spawn)

half sapphire
#

🤦‍♂️ it's because im zeus deleting the unit and the EH persists. so everytime i run the script i get 1 fire from each previous run. also, why couldn't we have a life state EH for AI. geeez.

dreamy kestrel
half sapphire
#

is it:
[unit, "handleDamage"] remoteExec ["removeAlleventHandlers", 0];

or

[unit ["handleDamage"]] remotexec...

hallow mortar
#

The first one

meager granite
hallow mortar
# hallow mortar The first one

The left and right arguments of the original command remain the same, just in a different place. Left argument is unit (Object), right argument is EH type (String) so they stay that way.
If removeAllEventHandlers took an Array as its right argument it would look more like the second one (plus a comma), but it doesn't.

dreamy kestrel
half sapphire
#

i just wanna say, again, a life state EH for AI would have come SO handy.

hallow mortar
#

Well, we don't even have one for players, and AI only use like 1 of the lifestates beyond healthy and dead (and that one is covered by handleDamage)

granite sky
#

wait, what one's covered by handleDamage?

hallow mortar
#

Injured (essentially, I mean yeah it'll fire for damage that doesn't quite hit the INJURED threshold but that's an easy check)

half sapphire
#

well, lifeState does return "injured", and if setUnconscious it returns "Incapacitated".
for players we got the scriptedEH handlers.. which are complicated in their own way.
handleDamage is a mess cos it fires for each hit part. im using it to setunconscious then have a while (alive unit) { waituntil {unit lifeste == "incap.."

opal zephyr
#

could you just check the anim state?

granite sky
#

Maybe, but there's a lot of variation due to various unconscious-dragging systems.

#

You really just want a lifeStateChanged EH to fire on unconscious and wakeup.

half sapphire
granite sky
#

(for compatibility with other people's medical systems)

opal zephyr
#

Is the goal here to just have something happen once an ai goes unconcious?

granite sky
#

and when they wake up, yes.

half sapphire
#

is it allow to post files here? like, its too long to copy/paste.

opal zephyr
#

use pastebin

#

It might not be the most performant option, but if you create your own eh using a while loop and incapicatedState or lifeState that would fire when the unit is uncon/awake again

half sapphire
#

don't laugh too hard lol

opal zephyr
# opal zephyr It might not be the most performant option, but if you create your own eh using ...

off of this, this is what I was thinking:

[_this#0]spawn{
    params ["_unit"];
    _previousState = lifeState _unit;
    while {alive _unit} do
    {
        _state = lifeState _unit;
        if (_state isNotEqualTo _previousState) then{
            if (_state isEqualTo "UNCONSCIOUS") then{
                //Do stuff for when they become uncon.
            };
            if (_state isEqualTo "ALIVE") then{
                //Do stuff for when they wake up.
            };
        };
        _previousState = lifeState _unit;
        sleep 1;
    };
};
opal zephyr
half sapphire
#

set it to raw on pastebin

opal zephyr
#

hm, still is

half sapphire
#

eeerr. yeah. i swear is nice on my script hahaah

opal zephyr
#

what was the point of posting it? Like what do you want us to look at?

half sapphire
#

well, its relates the idea of what im attempting to do. it also gives you the chance to tell me how wrong some of the code is, which is welcome ahahah

#

do you think some of the code is large enough to make it into functions instead of publicVariable? i mean it is safer and better that way, but its also not that much code. perhaps fn_x = compilefinal "code"?

hallow mortar
#

Using compileFinal does not automatically make the resulting function available on all machines. You'd still have to publicVariable it to make it globally usable. And even if compileFinal did do that, it would still be broadcasting all the code over the network, which is the whole issue.
The absolute best practice would be to use cfgFunctions functions. However, if you're truly opposed to doing that for some reason, the second best would be to define your functions locally using compileFinal on all clients (init.sqf, for example), instead of defining them on the server and then broadcasting them.

half sapphire
#

i get that the best practice would be to declare the functions in .ext and all. i was just wondering if that's a thing people do for just a couple lines of code. in my head, theres's maybe 3 parts that can be turn into functions and are small enough to, i think, not cause lag when broadcasted, which only happnes once when the script is run. 1.46kb of data is broadcasted.

hallow mortar
#

(per player, in addition to everything else that gets broadcast at the start of a mission)

#

The thing is, it's very easy to simply define them locally and not need to broadcast anything, without even using CfgFunctions, as I mentioned towards the end of the previous message.

vocal mantle
primal warren
#

can someone help me with a script where when all subtasks are completed the main task completes. not sure what im doing but in tried this in a trigger killmortar setTaskState "SUCCEEDED" && killbox setTaskState "SUCCEEDED" && killAA setTaskState "SUCCEEDED"; as a test

hallow mortar
half sapphire
#

maybe like this ??:
_tasks = ["killmortar", "killbox", "killAA"]
{[_x, "SUCCEEDED"] call BIS_fnc_taskSetState} forEach _tasks.

primal warren
#

I put it under a trigger condition. am i suppose to be using the task create module ?

hallow mortar
#

The issue you have is that you're not checking the task state, you're setting it. That's no good for a condition - hopefully you can see why. Try this instead.

({taskState _x == "Succeeded"} count [killmortar, killbox, killAA]) == 3```
half sapphire
#

ahhh i missunderstood what he was trying to do.

twilit field
#

How can I check that variable is code (for optional parameter)? Something like

_test_fnc = {
   hint "Test";
};
_main_fnc = {
   params ["_fnc"];
   if (isNull _fnc) then { 0 call _fnc; }; // error - isNull cant be called with code
};
[_test_fnc] call _main_fnc;
sullen sigil
#

i would imagine just use params with {} in the type

twilit field
#

I didnt want to call fnc, but .... I will test it

warm hedge
#

isEqualType?

twilit field
#

look good (so as typeName)

half sapphire
#

man no wonder why there aren't many ai revive scripts. ok.. i think i've pinned down the main issue to a []spawn that starts a countdown loop. that issue im seeing is that it runs for every unit i've ever created in the session. as in, i run the script once, all works ok, delete the unit, run script again, now i get two contdown loops, and so on. why could this be? the loop does have a working break under conditions, and it breaks everytime. its not about deleting the unit while the loop is running. and its not the EH firing multiple times cos i've tried without it. the amount of loops run is consistent with how many times the script is run.

granite sky
#

You'd have to show the code.

half sapphire
#

this starts the loop
if (lifeState HostageUnit == "INCAPACITATED") then {[] spawn RPR_HostageCountDown};

and the loop goes like this:

{  
 RPR_time = 300;  
 RPR_counter = 30;  
  
 while {RPR_time > 0} do   
   {  
    if (lifeState HostageUnit != "INCAPACITATED") then { 
                            ["HQ: The hostage has been revived!!"] remoteExec ["systemChat", 0, true];  
                            ["Hsave", "SUCCEEDED"] call BIS_fnc_taskSetState; sleep 1; ["Hsave", west] call BIS_fnc_deleteTask;  
                            break;  
                            };  
    if (RPR_time == 1) then {  
                  HostageUnit setDamage 1; ["HQ: The hostage has died!"] remoteExec ["systemChat", 0, true]; sleep 1;  
                  ["Hsave", "FAILED"] call BIS_fnc_taskSetState; sleep 1; ["Hsave", west] call BIS_fnc_deleteTask; removeAllActions HostageUnit;
                  [HostageUnit, "HandleDamage"] remoteExec ["removeAllEventHandlers", 0];
                };  
  
    if (RPR_counter == 30) then {  
                 [format ["HQ: The hostage is dying, you have %1 minutes %2 seconds to revive him", floor(RPR_time / 60), RPR_time % 60]]  
                 remoteExec ["systemChat", 0, true]; RPR_counter = 0;  
                };  
  
    RPR_counter = RPR_counter + 1;   
  
    uiSleep 1;  
    RPR_time = RPR_time - 1;  
   };  
};
publicVariable "RPR_HostageCountDown";```
granite sky
#

You're using global variables everywhere. This doesn't seem sensible.

half sapphire
#

i will get to that once the thing runs as intented. unless you are saying that its the publicVariable that's causing the loop to do this werid stuff.

granite sky
#

What's the trigger for the spawn?

half sapphire
granite sky
#

Yes I saw that, but that doesn't tell me anything about how and where it's called.

half sapphire
# granite sky Yes I saw that, but that doesn't tell me anything about how and where it's calle...
HostageUnit spawn {
                    while {alive HostageUnit} do {
                                                  waitUntil {sleep 2; damage HostageUnit >= 0.65};
                                                  [HostageUnit, true] remoteExec ["setUnconscious", HostageUnit];
                                                  [HostageUnit] remoteExec ["removeAllActions", 0];
                                                  [west, "Hsave", ["The Hostage has been Shot! Hurry!!", "SAVE HOSTAGE"],   
                                                  HostageUnit, "ASSIGNED", -1, true, "heal"] call BIS_fnc_taskCreate;
                                                  sleep 3;
                                                  if (lifeState HostageUnit == "INCAPACITATED") then {[] spawn RPR_HostageCountDown;}
....
granite sky
#

There's only one hostage unit or what?

half sapphire
#

yup

granite sky
#

btw your indentation is terrible :P

half sapphire
#

no its not

granite sky
#

Where's this code executed?

half sapphire
#

server side (pated on console for testing)

#

otherwise execVM by server.

#

same issues tho

granite sky
#

What's after that code? You have a conditions of the hostage being alive and >= 0.65 damage, and nothing in there that resets that state.

half sapphire
#

the holdaction has a call there

#

call RPR_HuReviveAct

#

in there, setuncious false, some animation and re add an addaction. nothing fancy.

#

oh and setDamage 0

#

the holdaction is only added once if the loop is spawns several times.

#

ok, further testing. added a hint under the waituntil {damage hostag.. blah blah}; and it displays several times as well. now im even more confused since the holdaction is only added once, when in other tests it added many.

half sapphire
#

think i got it. it didn't like the fact that the unit was once server owned then player owned. so i changed it to _this inside the health and life state check, then the call goes out _this as param. and then again _unit = _this select 0 on the soon to be functions.

opal zephyr
# half sapphire

Im sorry but someone needs to call an exorcist for this abomination

celest oxide
#

Unsure if this is scripting but anybody knows why this is the case. It was working before it’s for my dedicated it was working a couple days ago

granite sky
#

Error looks pretty clear? You have an object in the mission with class "livefirearea" that doesn't exist in your modset.

celest oxide
#

At least the prop wise of what I placed

#

Might be when I deleted it

#

Unsure if it was more a editor related issue

granite sky
#

Does it work fine locally?

celest oxide
#

It worked fine for me originally

#

But when it was loaded in the dedicated as a MP mission it just like bugged tf out

#

It might’ve been a prop I added but wouldn’t make sense because all of it is the the modest

#

Modset*

granite sky
#

Load it locally (editor or whatever) and then run configSourceModList (configFile >> "CfgVehicles" >> "livefirearea");

#

That'll tell you what it's from.

celest oxide
#

Okay sick man appreciate it I’ll try that rn

#

Where would I run the cmd? @granite sky

granite sky
#

In the debug console.

celest oxide
#

Would Eden editor

#

Still work

granite sky
#

In this case, yes.

celest oxide
#

I said a bad word mb

#

I’m dumb

#

I’ll check it out now loading it up

#

@granite sky

granite sky
#

you have a stray backquote at the end of the line.

celest oxide
#

Okay so I have the mod activated

#

So I’m confused now

granite sky
#

I guess it's not loading correctly on the server.

celest oxide
#

How would that happen

#

At this point should I delete the prop if it’s still in and that might fix it

granite sky
#

Nah, if it got past that it'd probably fail to load the mission anyway.

#

You're well outside scripting anyway here.

tulip ridge
#

I'm rewriting some old (and in all honesty, kinda bad) code for an air movement system.
Previously, I just checked if a movement key was pressed: if it is, increase speed in that direction (as well as some other math).

The one thing that bothered me about it though is that it suffered from the same issue/feature that a lot of other movement system in games do, where moving diagonally increased your overall speed since it was being increased in two directions.

I could keep this and try and cap the velocity in a given direction if other keys are being pressed, but that seems like it would get sloppy fast.
https://sqfbin.com/jodidofavugusibucazi

meager granite
#

Or like this

private _vector = [0,0,0];
if(inputAction "MoveForward" == 1)    then {_vector = _vector vectorAdd [0,1,0]};
if(inputAction "MoveBack" == 1)    then {_vector = _vector vectorAdd [0,-1,0]};
if(inputAction "TurnLeft" == 1)    then {_vector = _vector vectorAdd [-1,0,0]};
if(inputAction "TurnRight" == 1)    then {_vector = _vector vectorAdd [1,0,0]};

private _speed = _jetSpeed * BASE_SPEED * diag_deltaTime;
private _velocity = velocityModelSpace _vehicle vectorAdd (vectorNormalized _vector vectorMultiply _speed);
_vehicle setVelocityModelSpace _velocity;
#

Probably could also multiply by inputAction amount in case its an analog input

#

Not sure how exactly these analong inputs work though

#

what values you'd get there if any at all

meager granite
#

Hooked up the controller, looks like you need "HeliCyclicForward", "HeliCyclicBack", "HeliCyclicLeft", "HeliCyclicRight" for heli\jet controls

#

Interestingly these return 3 for keys, 1 for gamepad stick and up to huge numbers for fast mouse movements 🤔

#

Something like this might work

private _vector = [
     (inputAction "TurnRight" max inputAction "HeliCyclicRight") - (inputAction "TurnLeft" max inputAction "HeliCyclicLeft")
    ,(inputAction "MoveForward" max inputAction "HeliCyclicForward") - (inputAction "MoveBack" max inputAction "HeliCyclicBack")
    ,0
];
if(vectorMagnitude _vector > 1) then {_vector = vectorNormalized _vector};
#

This will account for both WASD and analog input

#

Its way too sensitive for mouse though, but I guess its fine

fleet sand
#

Quick question how to get array of all objects that are off the map ? So basicly i need to get all objects like vehicles, players, and static objects that are outside the map border in array ?

meager granite
meager granite
#

Made me think that an argument to return objects NOT in area could be useful

#

For all inArea* commands

fleet sand
meager granite
fleet sand
fleet sand
# meager granite Sure

Just a question what would be resnable for flag how would you put it something like this ?:

//Get all objects off the map:
private _allObj = 8 allObjects 1; 
private _out = _allObj - (_allObj inAreaArray [[worldSize / 2 ,worldSize / 2, 0], worldSize / 2, worldSize / 2, 0, true]);

//Instead we could do
private _allObj = 8 allObjects 1; 
private _out = _allObj inAreaArray [[worldSize / 2 ,worldSize / 2, 0], worldSize / 2, worldSize / 2, 0, true,(true/false)//inArea, notInArea]);

//or like this:
private _allObj = 8 allObjects 1; 
private _out = _allObj !inAreaArray [[worldSize / 2 ,worldSize / 2, 0], worldSize / 2, worldSize / 2, 0, true);
```?
grizzled cliff
#

need to work on performance

#

but its not bad as it is

candid sun
#

i love the way you abuse locations lol

vapid scarab
#

Hey Sa-Matra, do you make any mods?

nocturne bluff
#

Monodevelop is a pile of shit

#

escp Unity version that is like 3000 year old and made of shit

#

But there is really any reason to use it now since we got VS2015 for free + unity intergation

candid sun
#

i'm gonna make the switch soon, it's pretty painful not having autocomplete in particular

nocturne bluff
#

I would marry intelisense

#

Its so nice to never need to pull up docs

meager granite
#

Well, more like I'm not good at them

vapid scarab
#

Have you done any projects besides koth?

meager granite
untold edge
#

hey for someone who's brand new to scripting triggers, how would I have a convoy start moving once an enemy unit/player passes into my trigger area? I know it's something like if inarea connected to the first move waypoint but I couldn't find anything good on youtube/forums

vapid scarab
#

Your first problem is you are trying to do a convoy. Convoys in arma almost never work as intended. Second, look up some youtube videos on triggered waypoints. 'RimmyDownUnder - how to make a mission' youtube video has a good example of this. For your convoy, set the group formation to be collumn and set the speed to medium or slow. Make sure all drivers in all vehicles of the convoy are in the same group. Add vehicles to the group one at a time, and in the same order as their position in the convoy. 1st vic is leader, 2nd vic is added, 3rd vic added.....

#

For the trigger, you will probably want either Blufor detected or Player detected.

untold edge
#

another thing i was thinking of (I've run into the convoy issue before) was just have individual vehicles and connect them all to the trigger

untold edge
vapid scarab
#

Check the video i recommended.

untold edge
#

...im guessing the second one?

vapid scarab
#

No scripting. iirc, its something like you put a hold waypoint then a move waypoint, the hold waypoint never completes, and the trigger is synced to the hold waypoiny. The effect (third option) for the trigger is skip waypoint.

#

The first video

#

But watch the video. See what he does, then trial and error.

untold edge
#

thanks my guy 👍

vapid scarab
#

Ya know most people learn this the hard way after their first failed convoy mission, right? 😁

untold edge
#

well I made a couple convoys that failed miserably and so I just started placing each vehicle individually and stacking the waypoints on top of each other, it worked a lot better. Now I'm trying to slowly step into figuring out triggers for my little missions 🙂

vapid scarab
#

whispering: they dont make it better

untold edge
#

eh

vapid scarab
#

Goodluck

untold edge
#

I can jumpscare my friends with tanks without actually spawning them and controlling them though XD

vapid scarab
#

Thats fair

#

The waypoint thing you are wanting to learn is useful for creating prespawned reinforcements. Which as rimmy will explain is a better way to handle ot than spawning them as zeus

untold edge
#

yeah my entire purpose for learning triggers and scripting is so I can have as much as possible already in the mission ready to go instead of me running around trying to do everything

grizzled cliff
#

eh, for some stl shit still need to google

#

fucking template names a mile long

tulip ridge
tulip ridge
# meager granite Or like this ```sqf private _vector = [0,0,0]; if(inputAction "MoveForward" == 1...

Hm, trying to think of a good way to actually limit the speed, since a single min or max statement doesn't really work since they could be positive or negative.

Use the absolute value and then check if the original one was negative?

// ...
_velocity = velocityModelSpace ace_player vectorAdd (vectorNormalized _vectorSpeed vectorMultiply _speed);
systemChat format ["velocity: %1", _velocity];
_velocity =
[
    _velocity#0 min (_someValue),
    _velocity#1 min (_someValue),
    _velocity#2
];
ace_player setVelocityModelSpace _velocity;
granite sky
#

take vectorMagnitude _velocity and vectorNormalized _velocity. Cap the magnitude however you like, and then multiply by the unit vector.

tulip ridge
#

What do you mean by the unit vector?
Been a while since I've worked with them

_velocity = velocityModelSpace ace_player vectorAdd (vectorNormalized _vectorSpeed vectorMultiply _speed);

_magnitude = vectorMagnitude _velocity;
_magnitude = _magnitude min (_someValue);
_normalized = vectorNormalized _velocity;
granite sky
#

vectorNormalized _velocity is the unit vector (length 1) in the direction of the velocity.

tulip ridge
#

Gotcha

#

So multiply what exactly?
If you mean _magnitude * _normalized, wouldn't that just be _magnitude if the unit vector is just 1?

If you mean _vector * _normalized, then I don't see how capping the magnitude does anything

granite sky
#

_normalized is a vector, not a number.

tulip ridge
#

Oh gotcha

#

So something like this?

_velocity = velocityModelSpace ace_player vectorAdd (vectorNormalized _vectorSpeed vectorMultiply _speed);

_magnitude = vectorMagnitude _velocity;
_magnitude = _magnitude min (_someValue);
_normalized = vectorNormalized _velocity;

_normalized = _normalized vectorMultiply _magnitude;

systemChat format ["velocity: %1", _normalized];
ace_player setVelocityModelSpace _normalized;
granite sky
#

slightly iffy variable name re-use, but yes.

tulip ridge
#

Yeah I realized that, just changed it to _newVelocity, unless there was something more fitting

#

Seems to be working perfect, thanks for the help 👍

nocturne bluff
#

well i use C#

#

its always pretty nice to me

late cliff
#

hi does anyone have a script to spawn in a missle and make it shoot at a specific target? thanks

dreamy kestrel
#

Q: what are the types (i.e. classes) for terrain objects, for instance:

_y = player;
_types = ['road', 'main road', 'track', 'trail'];
_radius = 2500;
_objects = nearestTerrainObjects [_y, _types, _radius];
_classes = _objects apply { typeof _x };
[count _objects, _classes arrayintersect _classes]; // [1944,[""]]
dreamy kestrel
#

if there aren't any that's fine

warm hedge
#

If typeOf returns "", it is what it is

dreamy kestrel
#

or its model or whatever... fair enough, sure.

winter rose
#

there is something like modelInfo or so

little raptor
dreamy kestrel
#

sure no worries I know how to work with it

warm hedge
#

getModelInfo can work after all no?

little raptor
#

yes

dreamy kestrel
vapid scarab
#

so I have a #include in a file: #include "..\..\..\macros\testMacros.hpp"
In it is a single macro: #define TEST(world) "hello WORLD"
I have a file from mission root: components\testComponent\testCategory\fn_testFunction.sqf
in this file is: systemChat TEST(wOrLd);
Expected file is after preprocess: systemChat "hello wOrLd";
Actual file: systemChat TEST(wOrLd);

Any ideas as to why?

vapid scarab
tulip ridge
#

Actually, nevermind, that doesn't work

vapid scarab
#

I was double checking it before I said something...

#

😁

tulip ridge
#

Yeah, would be nice though

fair drum
#

@vapid scarab use single quotes

vapid scarab
#

😑 no way

fair drum
#

also, don't personalize the macro arg, just name it ARG_1 for instance

fair drum
#

just makes it way easier to read, especially when stacking macros. for instance, CBA uses var1,var2,etc arg_1,arg_2, etc

#

using # for quotes is also used

#

from CBA:

#define QUOTE(var1) #var1
vapid scarab
#

What all do you want me using single qoutes for? I swapped the double qoutes in the macro to single qoutes and nothing changed

fair drum
#

from your uploaded file:

#define TEST(ARG_1) 'hello ARG_1'
#include "..\..\..\macros\testMacro.hpp"
systemChat TEST(wOrLd);

Returns: hello wOrLd

#

If you use " you get:

hello ARG_1

vapid scarab
#

👌

#

forgot to hit Ctrl + s

tulip ridge
#

If you're using an ide like vs code, you can make it so that files save "On focus change", so if you go to a different file, alt-tab somewhere else, etc. it'll save your work

opal zephyr
#

Is there a way to delete a display? I dont want to delete ctrl's. I want to delete the actual display

opal zephyr
#

hmm I've found closeDisplay... I think that will work? Its a display created with UionTexture

#

Ok that did not work notlikemeow

#

I guess its more designed for closing an active desploy and not deleting it entirely

opal zephyr
#

I think just overwriting the texture will atleast stop rendering it, which is what I needed. That will work.

sullen trellis
#

scripting is so addicting 😄

meager granite
sullen trellis
#

am i the only one that plays alot with scripts than playing the actual game?

meager granite
tulip ridge
#

Yeah it was the lack of a speed limiter

opal zephyr
#

Thats 3.5 years... of arma tools (I assume)

warm hedge
#

I can say 90 percent of playtime is editing scripting and configuring, rest is playing SP 😄

#

Hell, maybe 96 to 97

fallow pawn
meager granite
sullen trellis
#

_westGroup = [markerPos "m1", WEST, 2] call BIS_fnc_spawnGroup;

[_westGroup, "SIT2"] call BIS_fnc_ambientAnim;
//Not working

warm hedge
#

ambientAnim takes an object not a group

fleet sand
sullen trellis
#

im not very skilled at creating scripts but that works like a charm, thnx both for the assistance

edgy dune
#

can someone explain the purpose and use case for CBA_fnc_createNamespace? The function it self just create a object on the map, whats the benefit of doing that and not just say using a hashmap?

molten yacht
#

Is there any way to set which seat owns a pylon by script?

meager granite
edgy dune
onyx island
#

Guys, I'm learning how to create SQF scripts and I'm having difficulty with the logic of my script. Basically it should generate roadblocks at the map markers, at first I used the player's distance to the marker and thus generate and delete roadblocks but I was having the same problems. Now a trigger is created (I thought it would solve) at the marker position and if someone activates the trigger, the main logic of creating the road block happens and then the trigger for that marker is deleted. The main problem is that more than one roadblock is being created on the dedicated server, for example: if there are 3 players online and someone activates the trigger, 3 roadblocks and 3 groups of soldiers are generated instead of one. Does anyone have any suggestions to correct this error in my logic 😔 ?

code is here >> https://github.com/kaiotcp1/ARMA3-SCRIPTS/blob/main/rb/rbbuild.sqf

GitHub

Contribute to kaiotcp1/ARMA3-SCRIPTS development by creating an account on GitHub.

meager granite
#

Perhaps the only upside is that you can broadcast setVariable on that entity but it all comes down to how you design things

meager granite
edgy dune
#

Okay cool, I am not sure if I need that broadcast just yet, but will keep in mind. thank you

meager granite
#

You probably also start instance of your script on each client, thus the multiple creation of the roadblock

meager granite
#

Only start your script on the server or if you need it for something else, only do creation on server

meager granite
# onyx island

Yeah, init.sqf execute on each client when their game loads into the mission, so you have same script running on each machine in the network

onyx island
meager granite
#

(you don't need nul = stuff for execVM its a remnant of a past editor's init field bug where it needed to end in assignment)

meager granite
onyx island
meager granite
#

Always keep locality and context of your scripts in mind

onyx island
#

Thanks for the explanation, I have a lot of questions about these scopes between server and location...

still forum
faint trout
#

Heya all, does someone know how to remove all current ACE3 Actions via Script from an Object? 🙂

sage wind
winter rose
sage wind
# faint trout Heya all, does someone know how to remove all current ACE3 Actions via Script fr...

You can obtain all the actions from here:

_allActions = cursorTarget getVariable ["ace_interact_menu_actions",[]];
_allSelfActions = cursorTarget getVariable ["ace_interact_menu_selfActions", []];

You can remove a action using this:

[cursorTarget,0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeActionFromObject;

You can just do a loop removing all the action:

_allActions = _target getVariable ["ace_interact_menu_actions",[]];
{
    [_target, 0, _x] call ace_interact_menu_fnc_removeActionFromObject;
} forEach _allActions;

_allSelfActions = _target getVariable ["ace_interact_menu_selfActions",[]];
{
    [_target, 1, _x] call ace_interact_menu_fnc_removeActionFromObject;
} forEach _allSelfActions;

However; doing this will make the game and ace unplayable and i would strongly recommend that you do not under any circumstance do it.

faint trout
tulip ridge
#

Is there a way to specify that a parameter should be an array of a given type?

#

Didn't seem to be a way on the wiki and trying in-game didn't seem to work but I wanted to double check

tulip ridge
#

Yeah I have the wiki page pulled up, but the examples it has only seems to specify three datatypes being accepted, not an array of them

// Example 6
[1, "ok", [1, 2, 3]] call {
    if (!params [
        ["_var1", 0, [0]],
        ["_var2", "", [""]],
        ["_var3", [0,0,0], [[], objNull, 0], [2,3]] // Can accept array of array, array of object, or array of int
    ]) exitWith {};
    hint "ok";
};
// Passes validation
#

I basically want to do:

[["1","1","1"], 5] params
[
    ["_velocity", [0,0,0], [[0]], 3],
    ["_speed", 0, [0]]
];

_velocity; // should be default value, since parameter is not array of Number
winter rose
#

I am not sure what you need, do you need to ensure a param is an array, or that a param is an array of said types?

#

for the latter, see isEqualTypeParams

tulip ridge
#

Ooo alright yeah that helps a lot

#

Never came up when I searched for params, appreciate it 👍

brittle badge
#

nice

cobalt path
#

question, how do I check if a variable exists? I mean I have:

_uv80 setVariable ["marki_var_interior_red",_mf_interior_red,true];

I have a code that spawns an object "_mf_interior_red" and attaches it to the "_uv80". I want to write a check to see if "_mf_interior_red" (or "marki_var_interior_red", not sure which one I should use for this) exists, so I wouldnt spawn 2 of them when execiting it twice. But I do not know how to check if one exists. This variable is tied to the vehicle _uv80

meager granite
#

if variable is nil (wasn't set) or if it was set with some entity but deleted, this will be true

dreamy kestrel
#

this is interesting, which version should we prefer for precise drawn bounding boxes? have a btr named object out there, just for example.

_x = btr;
_geometry = 2;
_bb = _geometry boundingboxreal _x;
// [[-2.10255,-5.00469,-2.98067],[2.10255,5.00469,2.98067],8.01536]

versus, this one seems far more precise, although I have not tried the draw aspects, bit more involved...

_x = btr;
_lod = 'geometry';
_bb = boundingboxreal [_x, _lod];
// [[-1.49762,-4.33178,-1.50323],[1.17009,3.27059,0.957344],3.96751]

what's the difference and which one should I generally use?

fallow pawn
#

I'd say whatever fits your needs. If you feel like you can afford more spacing or "room for error", go with the first syntax.

#

Also a little modification on **BIS_fnc_drawBoundingBox **'s code and you can visualize the differences...

molten yacht
#

Asking again, is there any way to switch who has control over weapon pylons by script? I'd like to grant someone firing authority at key moments.

digital hollow
fleet sand
#

Quick question how to set velocity 180* in oposite direction. Basicly, If vehicle is going dir 90 at 100km. How to set it so it goes dir 270 at 100 km ?

fleet sand
# winter rose multiply vector by -1

Like this ?

private _velocity = velocity _veh;
private _dir = getDir _veh;
_veh setDir (360 - _dir);
private _negVel = _velocity vectorMultiply -1;
_veh setVelocity _negVel;
winter rose
#

yyyup
although I would do the same for vectorDir/vectorUp

#

setDir sets a "flat" 2D direction

fleet sand
ruby bronze
#

It's being executed from initServer.sqf with [] execVM "VS_Boat.sqf";

hallow mortar
#

ACE action menu functions are local, not global, meaning they only take effect on the machine where they are executed. So the script is working (probably) but the actions are only being added on the server, since you're running it from initServer.sqf, which is only executed on the server.

ruby bronze
#

Oh dang, I would not have guessed that. Thank you, I'll try running from init.sqf then

half sapphire
#

hey guys, moving forward with my project. moving thigns around, changing repited execVM's for calls to compiled scripts. as suggested, i've also moved functions that i had publicVariable'd (for testing purposes) to functions. now, my question is for things that have loops and sleeps, i can't just "call AcompiledScript". i have to [] spawn those (i did try call and all hell broke lose). right? so, should i just "[] spawn AcompiledScript".. or "[] spawn {call AcompiledScript}"- did some reading but still unclear.

#

always talking about scripts whith waituntils and sleeps.

granite sky
#

[] spawn AcompiledScript

#

The latter will work too but it's an unnecessary extra layer.

#

"function names" are just a variable with code assigned to it.

hallow mortar
#

I have heard that it's slightly better to use 0 rather than [] for argumentless spawn because making an empty array is a very little bit slower

half sapphire
#

thanks!
also wanted you to know my indentations are now "normal". had em weird like that exactly for the purpose of copy/paste them out into a functions script. used #include in init.sqf . compiled my tasks scripts since they are run many times. so again, thanks for the advices.

ocean folio
#

anyone know of any reasons why agents might be ignoring moveto commands?

#

I have a _agent moveTo getPos player to test and I have 2 of 10 agents who are actually moving

fair drum
ocean folio
#

ooo lemme try that

#

yup, works flawlessly ty

spiral narwhal
#

Is it possible to remotexec more than 1 function by using addAction?

meager granite
#

Or call a function that calls two or more functions?

spiral narwhal
#

if the above was possible... would make my life easier

warm hedge
#

You can do such in regular scripts. So in remoteExec