#arma3_scripting

1 messages · Page 713 of 1

meager epoch
#

the condition or the code :p

little raptor
meager epoch
#

added a sleep and my laptop almost blew up meowsweats

meager epoch
wooden pine
#

any javascript mods for Arma? lmao

meager epoch
little raptor
meager epoch
#

so, basically just put the code in a spawn (or execVM it)?

little raptor
#

yes

meager epoch
#

but not in the unit's init, right?

little raptor
#

wat?

#

what does it have to do with where?

little raptor
meager epoch
#

Where code starts unscheduled
Object initialization fields

little raptor
#

do you even know what code is?

meager epoch
#

yes 👀

#

i tried spawning it in the unit's init, but canSuspend returned false

meager epoch
#

and when testing it, it still returned the position of the bullet when it left the gun

little raptor
meager epoch
#

the EH code is the whole code notlikemeow

little raptor
#
this addEventHandler ["Fired", { 
    params ["", "", "", "", "", "", "_projectile", "_gunner"]; 

    if (_gunner == player) then {
        [_projectile] spawn {
          params ["_projectile"];
          _impactPos = getPosWorld _projectile;
          while {alive _projectile} do {
              _impactPos = getPosWorld _projectile;
              sleep 0.001;
          };
          hint str _impactPos;
        };
    };
}];

was it really that hard?

meager epoch
#

i dont think i would have thought of that honestly

#

im still learning!

#

anyway, thanks salute

#

works blobcloseenjoy

little raptor
#

change the code to:

this addEventHandler ["Fired", { 
    params ["", "", "", "", "", "", "_projectile", "_gunner"]; 

    if (_gunner == player) then {
        [_projectile] spawn {
          params ["_projectile"];
          _impactPos = getPosWorld _projectile;
          pp = [_projectile];
          while {alive _projectile} do {
              _impactPos = getPosWorld _projectile;
              pp1 = [_impactPos];
              sleep 0.001;
          };
          hint str _impactPos;
        };
    };
}];
#

now you see the position of the projectile vs the _impactPos in real time

meager epoch
#

oh, neat

still latch
#

Can someone guide me. What is the purpose of serverNamespace how it is differ from localNamespace on server?
Would be nice to see usage example.(not syntax usage)

little raptor
still latch
#

Ok. Why not to use localNamespace? What was the main point when deciding that new namespace needed? When I need to use multiplayer only namespace?

still latch
#

Hmm ok. Something for server EHs. Will try.

violet cargo
#

Is there any way to round decimals in a float to be a specific format of say 0.00 in script?

violet cargo
#

May I know how?

little raptor
#
_r = round (_num * 10^_decimals) / 10^_decimals;
violet cargo
#

I see. So you're making it a whole int and then rounding it and converting it back to a float?

little raptor
#

if you want it for strings tho, you can use toFixed

little raptor
#

every number is float

violet cargo
#

ah. Alrighty. Never worked with SQF before so this is a new experience

#

Thank you very much

little raptor
#

nope.

violet cargo
#

is there mod (%) in sqf? I'm trying to mod a number by 20 and if it = 0 to do something but it doesn't seem to work

winter rose
violet cargo
#

Ok. I found two things saying a % b and a mod b. Will give mod a try

#

Didn't work with "mod" either.

bitter jewel
#

what do you get as a result

violet cargo
#

I never checked. It just wouldn't run the code for the if statement it was inside

bitter jewel
#

can you just try x % 20 with different values of x in the debug console

violet cargo
#

So it never proved true. I'm getting the health of a vehicle as it repairs slowly. It slowly goes up 1% every 2 seconds. So I know by seeing without the statement that it does hit 60 and 80 which is dividable by 20 with 0 result which is what I'm checking against

violet cargo
#

alright. Lemme rewrite that snippet back in since I took it out after a bit

#
_repairPercent = 100 - (_vehDamage * 100);
if {_repairPercent mod 20 == 0} then
{
    _veh vehicleChat format ["%1 %2% Repaired.", _vehtype, _repairPercent];
};
#

Should be like that

little raptor
#

damage is a float

#

and _repairPercent has trailing decimals

#

you have to round it

#

also

#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
violet cargo
#

gotcha. didn't know there was an sqf

ripe relic
#

I'm looking for some help with this "disableCollisionWith"
I'm trying to make a tree ignore the collision of all players, vehicles, bullets, etc. but I'm having trouble configure it to register all those entities

#

Is there a universal fix to simply disable an object's collision entirely?

little raptor
#

if you have only a few objects, you can attach them to a reference object

#

but it's slow

ripe relic
#

It'll probably be close to a couple dozen objects

quick glacier
#

I'm looking for some help with not losing my mind please.

I'm trying to add wreck recovery to my mission.

The premise is that if a vehicle is destroyed, it can be returned to a specific point on the map, and it will be repaired.

I have been able to achieve this with a proof of concept trigger, that runs some of pierremgi's code from 2017 (because apparently it took me 4 years to think of looking for an Arma discord...

I've run into some issues however.

Mainly in expanding the concept.

Would anyone be around to help me out?

winter rose
#

that's… not really a scripting question?

quick glacier
#

How do I achieve that without the trigger, using a script.

I basically want the wreck to be detected, then respawned at its current location, then remove the wheels, fuel, and set its customisation to what it was before it exploded.

I don't want it to have any inventory and if I can manage it, I don't want it to have any ACE cargo, just a repaired hull from a wreck.

What I currently have, is a trigger that respawns only one wreck, in a specific place, to its default class settings (including a full inventory, fuel tank, and replacing its wheels)

I apologise if this is the wrong place, where should I put this instead?

unkempt sorrel
#

Heyo, I would like to know how to implement a script into my mod? My method doesn't seem to be working, I'm trying to make it so the memory point for the pilotcamera changes after an addAction

quick glacier
#
{hint "Repairing Vehicle...";
{ 
  _x synchronizeObjectsAdd [moduleLogic1];
  _x spawn { 
    private ["_delay","_desertedDelay","_respawnCount","_init","_position","_wreck", "_respawnWhenDisabled"]; 
    _delay = (moduleLogic1 getvariable ["Delay","0"]) call bis_fnc_parsenumber; 
    _desertedDelay = (modulelogic1 getvariable ["DesertedDelay","-1"]) call bis_fnc_parsenumber; 
    _desertedDistance = (moduleLogic1 getvariable ["DesertedDistance","-1"]) call bis_fnc_parsenumber; 
   _respawnCount = (moduleLogic1 getvariable ["RespawnCount","-1"]) call bis_fnc_parsenumber; 
   _init = compile (moduleLogic1 getvariable ["Init",""]); 
   _position = (moduleLogic1 getvariable ["Position","0"]) call bis_fnc_parsenumber; 
   _positionType = (moduleLogic1 getvariable ["PositionType","0"]) call bis_fnc_parsenumber; 
   _wreck = ((moduleLogic1 getvariable ["Wreck","2"]) call bis_fnc_parsenumber); 
   _showNotification  = ((moduleLogic1 getvariable ["ShowNotification","0"]) call bis_fnc_parsenumber); 
   _forcedRespawn = ((moduleLogic1 getvariable ["ForcedRespawn","0"]) call bis_fnc_parsenumber); 
   _respawnWhenDisabled = moduleLogic1 getvariable ["RespawnWhenDisabled", false];   
   [_this,_delay,_desertedDelay,_respawnCount,_init,_position,_positionType,_wreck,_showNotification,_forcedRespawn,_desertedDistance, _respawnWhenDisabled] call bis_fnc_moduleRespawnVehicle; 
_this setFuel 0;
_this setHit ["wheel_1_1_steering", 1];
_this setHit ["wheel_1_2_steering", 1];
_this setHit ["wheel_2_1_steering", 1];
_this setHit ["wheel_2_2_steering", 1];  
    } forEach [veh1];
_x spawn {
_x  synchronizeObjectsRemove [moduleLogic1]; 
  (_x getVariable "bis_fnc_modulerespawnvehicle_data") set [0,false] 
} forEach [veh1];
}];

That's what I have, it was working fine as a trigger, now it's just throwing errors at me.

misty osprey
#

any one know why this throws the undefined variable error for _SpawnMarker, I have it defined as a marker string.

_BuildCTRL buttonSetAction "_SpawnMarker execVM 'WestBuild.sqf'";

livid belfry
#

Evening all, is there a script to get AI helo to sling load a RHS m119a2 in SP I’m using drongo and GM CH53

misty osprey
livid belfry
steady matrix
#

Hey everyone - so I'm having a little bit of confusion with understanding how to properly use _this global variable and forEach together. For instance... what I want to do is create a function that essentially runs a few conditional checks on each unit in the group. So what I'm wondering is... if SQF function file is using _this does that mean that running a trigger that uses forEach unit to execute the function in the code block - that it will run the function on all units?

#

Does that make sense? I feel like I worded that terribly.

#

Basically I guess my confusion is what determines a unit initiating the function that _this in local variable world space, would apply to the unit?

#

sorry _this magic variable***

misty osprey
livid belfry
steady matrix
#

having an underscore at the front of variables places said variable in local scope only, correct?

little raptor
little raptor
little raptor
torpid quartz
#

in the vehicle respawn module there's a place to put an expression. I'm trying to run
clearMagazineCargo this; clearWeaponCargo this; clearItemCargo this;
but it's giving me the error that "this" is an undefined variable

warm hedge
#

Read the desc on the module. It should have the way to get the vehicle that has respawned

serene sentinel
#

Creating unit with this command. It's creating in center of given marker, is there a way to spawn it on random place in marker size?

// 
"B_RangeMaster_F" createUnit [getMarkerPos "marker_1", _groupAlpha, "loon1 = this; this addWeapon 'BAF_L85A2_RIS_SUSAT'", 0.6, "corporal"];
sacred turret
#

can action trigger a custom addAction?

unique sundial
sacred turret
#

got it, thanks!

digital vine
#

Going to sound like a bit of a sideways question….. but…..

Is there any way to Script onto a dedi (I assume in the mission init file) to force a ‘Clan insignia’ onto players. Allowing them to still select and personalise with the normal ‘unit insignias’?

torpid quartz
#

trying to make a create a respawn point for a specific player using
[playername,objectvariblename] call BIS_fnc_addRespawnPosition;

however i'm doing this for a number of players and everyone seems to keep getting everyone else's respawns as well.

#

this is for a MP game. not sure if I need to use "[playername,objectvariblename]" remoteExec ["BIS_fnc_addRespawnPosition"]; instead, but they give the same results when testing on a lan server for me so I guess they both work

torpid quartz
#

scratch that, trying to now give people respawn points based on the class of their unit, putting this in init

player addEventHandler ["Respawn", 
{
if (typeOf _this == "IC_CAD_inf_776_B") then {_this setpos (getmarkerpos "GT2Respawn");} 
else { if (typeof _this == "IC_CAD_inf_776_Light_B") then {_this setpos (getmarkerpos "GT1Respawn");} 
else { if (typeof _this == "TIOW_Tactical_SL_1") then {_this setpos (getmarkerpos "ST1Respawn"); };
}];

been trying to get it working, based on the error of missing a ";" I assume part of the formatting is wrong, been trying but no luck yet

winter rose
torpid quartz
twilit briar
#

Hello. I am very new to scripting and i am trying to attach a m2 turret to the turret of a sherman tank so that the M2 turns with the turret instead of glitching through the side when i move the turret. can anyone help?

steady matrix
#

https://pastebin.com/nChrMdJS - working on a Medevac / Hospital script for my dynamic campaign - not near complete - right now I'm just trying to test a few things out - and I can't seem to figure out why its not appending the array as an element in the primary array "hospitalized units". I'm testing by wounding a team mate and carrying him into the evacuation area - and I'm not getting script errors, my hint pops up for initialization, but nothing else. No dice.

#

hospitalizedUnits = [];* shows up empty when I debug using a hint - nothing gets added to the array.

#

Oh wait, I already see some mistakes I made..

steady matrix
#

Hmmm - still having issues no matter what I try - if someone can take a look, hoping someone can catch what I'm doing wrong here. https://pastebin.com/FAd6dPTW

warm hedge
#

You did nothing in this script. The code is not even executed

crude vigil
lavish coral
magic sundial
#

Is there a way to add a haze effect?

#

Like to post-apoc stalker type smog

#

Like from my understanding i can have it so that fog matches the sky colour

#

but i dont know how to do that as well as change the sky colour in the first place

#

anyone have an idea?

warm hedge
#

Customizable fog color you mean?

magic sundial
#

Yeaaaaa

warm hedge
#

Nope by script

#

You can done it using some configs but won't be on-the-fly something

magic sundial
#

yea thats what i'm asking is how to do it by script

warm hedge
#

Nope by script

magic sundial
#

Oh you cant do it via script

#

is that what you're saying

warm hedge
#

Yes

unique sundial
tight cloak
#

feels weird to look in arma 3 scripting and seeing the guy who basically is the reason you know sqf at all

#

@unique sundial thankyou for your blog and all its posts kind sir

sacred turret
#

guys, is there a way to check if a flag pole has been taken (event or maybe trigger) or do I need to do something like a while loop or wait until?

distant oyster
sacred turret
distant oyster
sacred turret
#

in script only, in order to notificate everyone once a flag is stolen, I need to check it every once in a while?

distant oyster
#

i only vaguely remember how ctf works. how did you set up so a flag can be captured?

sacred turret
#
blu_pole = "FlagPole_F" createVehicle position player;
blu_pole setFlagTexture "\A3\Data_F\Flags\flag_blue_CO.paa";
blu_pole setFlagSide west;
#

the take action is vanilla, once you get close a to opposing team flag pole it shows the take action

distant oyster
#

the inGameUISetEventHandler works on the take flag action. give me a minute, I'll make an example

#

@sacred turret

blu_pole = "FlagPole_F" createVehicle position player;
blu_pole setFlagTexture "\A3\Data_F\Flags\flag_blue_CO.paa";
blu_pole setFlagSide west;
[["Action","
    params ['', '_caller', '', '_action'];
    if (_action != 'TakeFlag') exitWith {false};
    format ['%1 has taken the flag!', name _caller] remoteExec ['hint', 0];
    false
"]] remoteExec ["inGameUISetEventHandler", 0];
#

kind of bad that inGameUISetEventHandler is overwriting itself

sacred turret
#

wow thats very nice, thank you

sacred turret
distant oyster
#

if you call inGameUISetEventHandler again the code will not work anymore, this also applies to when a mod / another script calls it

#

well not will not work, it will simply be replaced

sacred turret
distant oyster
#

this is in addition to what the take action does

sacred turret
distant oyster
#

you could overwrite that by returning true instead of false

sacred turret
#

ohh, got it

#

thank you very much man

#

helped a lot, appreciate it

distant oyster
#

np

copper raven
#

is event handler code still recompiled everytime before executing? 🤔 i know it was like that a while ago, wonder if it still is

still forum
#

Don't think so

meager epoch
#

is it possible to hide the apex subtitles in a mission just like u can hide the radio chat/sidechat

#

or to stop a script right away instead of waiting for it to finish or whatever we're waiting for when using terminate

little raptor
#

find which cut they're drawing on and terminate it

copper raven
#

or well, it for sure does recompile once

#

whether it's done again and again, can't test blobdoggoshruggoogly

#

the way i did it is compile the following:

player addEventHandler ["Fired", {hint "actual"}];

and when serializing to bytecode, i change the string representation

        loc.source(std::make_shared<parsing::source_context>("player addEventHandler [\"fired\", {hint \"recompiled\"}];", "test.sqf"));
        loc.begin(parsing::position<>(0, 1, 1));
        loc.end(parsing::position<>(54, 55, 1));

in game, when i shoot, i get a hint with "recompiled"

hallow mortar
#

Does setShotParents work on things that aren't cfgAmmo projectiles? Specifically, can I apply it to a physics object so that kills by collision with that physics object are credited appropriately?

little raptor
#

it's easy to test

hallow mortar
#

...thanks

meager epoch
#

how can i delete an array

#

or clear its elements without using deleteAt for every single one

hallow mortar
#

_array = []

meager epoch
#

right

#

thanks

hallow mortar
# hallow mortar ...thanks

It seems the answer is "no"; using getShotParents on a vehicle I applied setShotParents to returns an empty array.

wanton kernel
#

Hey guys, having a couple of minor issues with targets. It's not a make-or-break, but would be nice to get it nailed.
**Issue 1 **> The swivel targets, do they not work properly in multiplayer? I've seen some suggestions that this is the case, and if so is there a way to fix this? If not I'll just use pop up targets.
**Issue 2 **> I have some scripts that basically tell pop-up targets to stay down when hit, then there is a computer that gives the option to "reset targets". Works a treat in single player but in multiplayer it just ignores the script and the targets pop up as normal. Any ideas? I'll post the scripts here if it helps...

wanton kernel
#

Hmm... So I did try adding "isServer" into my init.sqf, I also tried adding it to the individual reset.sqf... if I simply renamed init.sqf to serverinit.sqf would that work?

#

Let me post the scripts just in case some context makes it easier 😄

#

Ok I can't post files but I can do this...

#

if (isServer) then
{
nopop = true; //disable targets from moving automatically
_0 = [70,iCenter1] execVM "reset.sqf"; //will affect all targets in 50m area around iCenter1
_0 = [70,iCenter2] execVM "reset2.sqf"; //will affect all targets in 50m area around iCenter2
nopop = false;
;
}

#

So as you can see, I tried the "if (isServer)" trick in my init.sqf but no joy. I also have tried adding it to "reset.sqf" and "reset2.sqf" instead but also no joy.

little raptor
#

also I'm pretty sure the problem is not isServer

#

rather it's a locality issue

wanton kernel
#

Ok so that part is the whole of init.sqf

#

I'll copy one of the reset scripts so you can see what it does

little raptor
wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
wanton kernel
#
params [["_dist",70,[1]],["_center",player,[objNull]]];                    //in params
_targets = nearestObjects [position _center, ["TargetBase"], _dist];    //take all nearby practice targets
if (count _targets < 1) exitWith {
    systemChat "No compatible targets were found.";                        //exit if no targets have been found
};
{_x animate ["Terc",0];} forEach _targets;                                //get all targets to upright pos
{_x addEventHandler ["HIT", {                                            //add EH
(_this select 0) animate ["Terc",1];                                    //if hit, get to the ground
(_this select 0) RemoveEventHandler ["HIT",0];                            //remove EH
}
]} forEach _targets;
//systemChat "Ready.";


//swivel targets start here

_SwivelTargets = nearestObjects [position _center, ["Target_Swivel_01_base_F"], _dist];        //swivel targets work differently
if (count _SwivelTargets < 1) exitWith {
    systemChat "No swivel targets were found.";
};
{_x animate ["Terc",0]; _x setVariable ["BIS_poppingEnabled", false];} forEach _SwivelTargets;    //nopop has no effect, it's poppingEnabled now
{_x addEventHandler ["HitPart", {
((_this select 0) select 0) animate ["Terc",1];
((_this select 0) select 0) RemoveEventHandler ["HitPart",0];
}
]} forEach _SwivelTargets;
//systemChat "Swivel ready.";
little raptor
#

use syntax highlighting

wanton kernel
#

^ this is almost identical in reset.sqf and reset2.sqf, and the init.sqf calls on those

little raptor
#

like I posted

wanton kernel
#

Righto

crude vigil
wanton kernel
#
if (isServer) then
{
nopop = true;                                    //disable targets from moving automatically
_0 = [70,iCenter1] execVM "reset.sqf";            //will affect all targets in 50m area around iCenter1
_0 = [70,iCenter2] execVM "reset2.sqf";            //will affect all targets in 50m area around iCenter2
nopop = false;
;
}
crude vigil
#

so yeah initServer.sqf would fix your issue.

little raptor
#

it applies to all

wanton kernel
#

Blimey

#

And then I can ditch the "if (isServer) then" part or keep that in?

little raptor
crude vigil
crude vigil
#

If only I had ability to post pictures...

little raptor
wanton kernel
#

Ah, about halfway down the list it shows those two items as "Singleplayer"

crude vigil
#

Where is that even from, there is a tab called Applies To in my case ...

wanton kernel
#

So are we saying initServer.sqf won't fix the issue 😂

little raptor
#

it only has a different priority in MP

crude vigil
#

And there is clearly a missing column in your case.

wanton kernel
crude vigil
#

Oh mb

#

lol

wanton kernel
#

Which makes it no less confusing 😄

crude vigil
#

Well yeah, good thing Im not a mission maker

distant oyster
#

what am I missing here?

private _items = flatten (missionNamespace getVariable "bis_fnc_arsenal_data");
//--- Add acessories, since they are not included in the arsenal data
private _accessories = (
    "getNumber(_x >> 'type') == 131072 && "+
    "getNumber(_x >> 'scope') == 2 && "+
    format ["!(configName _x in %1)", _items]
) configClasses (configFile >> "CfgWeapons") apply {
    configName _x;
};
_accessories 
``` error: 

Error in expression <x >> 'scope') == 2 &&!(configName _x in "[""srifle_DMR_01_F"",""srifle_EBR_F"",">
Error position: <"[""srifle_DMR_01_F"",""srifle_EBR_F"",">
Error Missing ""

Error in expression <1072 && getNumber(_x >> 'scope') == 2 &&!(configName _x in "[""srifle_DMR_01_F"">
Error position: <!(configName _x in "[""srifle_DMR_01_F"">
Error !: Type String, expected Bool

```sqf
private _items = flatten (missionNamespace getVariable "bis_fnc_arsenal_data"); 
//--- Add acessories, since they are not included in the arsenal data 
private _accessories = ( 
    "getNumber(_x >> 'type') == 131072 && "+ 
    "getNumber(_x >> 'scope') == 2 && "+ 
    "!(configName _x in " + str _items + ")"
) configClasses (configFile >> "CfgWeapons") apply { 
    configName _x; 
}; 
_accessories
``` works
#

ooh would you look at that. format is limited to 8kb and the string is too long

little raptor
#

why not use regex instead?

little raptor
#

especially now that you admit "string is too long"

distant oyster
#

huh i didn't know that the condition knows about variables from the current scope

little raptor
#

but regex and hashmap are the faster options here

grand idol
#

If I need to check if a class name is in a large array, should I use findIf or is there a faster way such as hashmaps (which I haven't dug into yet)? This check will be performed often. I'll be checking to see if an item in a player's inventory is a weapon mag. I don't know that I can check it by type since so many items are children of CA_Magazine.

distant oyster
#

Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.

wanton kernel
#

😂

fair drum
#

is indrectHitRange the correct config value for explosion range? what's making me wonder is a vanilla gbu has a indirectHitRange of 12 which I think is low.

wanton kernel
#

Just going back to my question, if anyone knows the answer as to how to make this script work in multiplayer please can you @ me or DM me? I'm going to continue hunting around... I got the script from this video btw: https://www.youtube.com/watch?v=ehIzXg2Ttqw

little raptor
raw otter
#

anyone know where i can find a dev

little raptor
raw otter
#

setting up a new server

#

like to setup atlas rp cause i thought it was gonna be ez but nope

little raptor
raw otter
#

oh ok

#

thx

fair drum
distant oyster
little raptor
#

for regex:

flatten _array joinString "|" //or some other invalid character
distant oyster
#

i have to sort the items afterwards by their displayname though

#

hmm but yeah that might still be faster

grand idol
little raptor
distant oyster
#

on the other hand the code is nice and readable rn, making it more complicated is going to make maintenance an chore

little raptor
wanton kernel
little raptor
wanton kernel
#

😐

#

Shall I resend the scripts again?

#

so basically...

little raptor
wanton kernel
#

Ok

little raptor
#

not physical place

wanton kernel
#

So a friend is hosting it and I join his session; weirdly the targets seem to behave according to the scripts if he hosts and is on there alone, but as soon as I connect the targets ignore the scripts and resort to their default pop-up behaviour... When we get it working properly it will be on a dedicated hoster (gtx gaming server)

#

tries renaming init.sqf to serverinit.sqf

#

But basically the two of us are testing it now, and if it works we can then open it up to the rest of our buddies

little raptor
#

and how?

wanton kernel
#

Small village has several pop up targets in it. There is an object that is called iCentre1 in the middle and the init.sqf script basically resets "every target within 70 meters of iCentre1"

#

Same for iCentre2 which is in another location

#
nopop = true;                                    //disable targets from moving automatically
_0 = [70,iCenter1] execVM "reset.sqf";            //will affect all targets in 70m area around iCenter1
_0 = [70,iCenter2] execVM "reset2.sqf";            //will affect all targets in 70m area around iCenter2
nopop = false;
;
#

So that's this bit

little raptor
#

I don't mean the place

#

do you create them in Eden?

#

via script?

#

how?

wanton kernel
#

You just asked where I created the targets, sorry what was my assumption 🤣 yes via Eden

little raptor
#

well then they probably will always belong to the server

#

so yeah, you can try initServer.sqf

wanton kernel
#

As I say, works in SP... For example: just now my friend hosted it on his machine, tests it, works fine. I join the session and spawn in, immediately the script stops working completely and the targets revert to their default pop up behaviour 😐

#

initServer.sqf hasn't worked, sad times

#

It seems like such a simple thing but in practice it never is 😂

little raptor
wanton kernel
#

init.sqf or serverinit.sqf hasn't made a difference; it works when my buddy hosts and is on the session by himself, but as soon as I spawn in it reverts to default behaviour and ignores the script 😦

#

Wait a minute, I think my buddy has just had a "oh bollocks" moment 🤣 wait one

#

He hadn't deleted init.sqf and had both, testing with just initServer.sqf now..

#

Ok so confirmed it still doesn't work.

#

In chronological order...
Buddy launches the session and goes to shoot some of those pop up targets.
I spawn in and his targets stay down.
I shoot targets, those targets pop back up, but his targets stay down.
If I then hit the reset button, ALL of the targets pop up and keep popping up after being shot at.

#

So yes, localization issue, but why and how to fix it is beyond me at this moment 🤔

little raptor
#

locality, not localization

wanton kernel
#

That's the one

#

So you have seen my serverinit.sqf script (or init.sqf does not make a difference it seems) I also tried adding this to no avail...
if (isServer) then
{
//script
}

little raptor
# wanton kernel So you have seen my serverinit.sqf script (or init.sqf does not make a differenc...
params [["_dist",70,[1]],["_center",player,[objNull]]];                    //in params
_targets = nearestObjects [position _center, ["TargetBase"], _dist];    //take all nearby practice targets

if (count _targets < 1) exitWith {
    systemChat "No compatible targets were found.";                        //exit if no targets have been found
};
                                //get all targets to upright pos
{
    if (!local _x) then {continue};
    _x animate ["Terc",0];

    _x addEventHandler ["HIT", {                                            //add EH
        (_this select 0) animate ["Terc",1];                                    //if hit, get to the ground
        (_this select 0) RemoveEventHandler ["HIT", _thisEventHandler];                            //remove EH
    }]
} forEach _targets;
//systemChat "Ready.";


//swivel targets start here

_SwivelTargets = nearestObjects [position _center, ["Target_Swivel_01_base_F"], _dist];        //swivel targets work differently
if (count _SwivelTargets < 1) exitWith {
    systemChat "No swivel targets were found.";
};

{
    if (!local _x) then {continue};
    _x animate ["Terc",0]; _x setVariable ["BIS_poppingEnabled", false, true];
    
    _x addEventHandler ["HitPart", {
        ((_this select 0) select 0) animate ["Terc",1];
        ((_this select 0) select 0) RemoveEventHandler ["HitPart", _thisEventHandler];
    }]
} forEach _SwivelTargets;
//systemChat "Swivel ready.";
#

this should work no matter where you try it

wanton kernel
#

That's my script 😮

cunning oriole
#

does playSound have some kind of size limit?

got a new sound set up exactly like the old one and this one is 79kb and it always says that it cant be found in my rpt yet when I run the old sound that is about 10kb it works fine?

cunning oriole
#

actually i think i know what the issue is, I just changed my file extension to .ogg rather than properly converting it

#

im just a lazy fucker 😂

little raptor
wanton kernel
#

You're sure, copy all of that into "initServer.sqf" and not the "reset.sqf"?

little raptor
#

not initServer.sqf

wanton kernel
#

Righto will do that. Should I move/delete the reset.sqf and initServer.sqf for this

little raptor
#

well what did you use before?

#

also why do you have two reset.sqfs?

wanton kernel
#

reset.sqf and reset1.sqf for two different areas on the map (they don't overlap at all)

little raptor
#

don't you use two different positions rn?

#

iCenter1 and iCenter2

wanton kernel
#

It would be easier if I could post a screenshot of the map 😂 but there are 2 areas on the map that have targets in them.
In one area is "iCenter1" and in the other area is "iCenter2"

little raptor
#

then you only need 1 script

#

aren't both scripts the same?

wanton kernel
#

the init.sqf (or serverinit.sqf) that I've been using basically grabs all of the targets within a 70 meter radius of each iCenter object

#

Well yes... but they are separate firing ranges so ideally need to be reset differently

little raptor
#

they are meowfacepalm

wanton kernel
#

two laptops, one to reset each set of targets

#

... you make a valid point ...

little raptor
#

what laptops?

wanton kernel
#

Oh

little raptor
#

you didn't even mention laptops.

wanton kernel
#

this addAction ["Reset Assault targets", {0 = [70, iCenter2] execVM "reset2.sqf"}];

#

Laptop

#

that just calls the script to reset the targets in that area

#

Bugger me; are you saying I don't need any of that init.sqf crap?

#

I must admit I had partially forgotten about the laptop init field until a few minutes ago 🤦‍♂️

little raptor
#

but if you use laptops to reset them it won't work then

wanton kernel
#

uhhhhhhhh

little raptor
#

I thought you only did that from init

wanton kernel
#

I think there is an overlap, although I'm not convinced that the "nopop = true;" is working properly but it could be due to a clash elsewhere

#

So...

#

2 firing ranges in different locations...

#

Each range has a laptop on a table, you walk up to the laptop and you get the "reset targets" option...

#

As an example one laptop has this in its own init field (in the eden editor):

this addAction ["Reset Assault targets", {0 = [70, iCenter2] execVM "reset2.sqf"}];

#

The other is basically the same but for reset1.sqf

#

And I'm now seeing where a possible overlap occurs

#

because in my serverinit.sqf I also have a similar line...

#

nopop = true; //disable targets from moving automatically
_0 = [70,iCenter1] execVM "reset.sqf"; //will affect all targets in 70m area around iCenter1
_0 = [70,iCenter2] execVM "reset2.sqf"; //will affect all targets in 70m area around iCenter2
nopop = false;
;

#

The laptop has to be the object that you walk up to and get the option to reset the firing range...

#

Deleting the reset functions from serverinit.sqf and just leaving "nopop=true;" ...............?

#

pleasesayyespleasesayyespleasesayyes

little raptor
wanton kernel
#

Stops pop up targets from popping up

little raptor
#

you just set it to true

#

then false

#

it does nothing

winter rose
#

it's set to both this way

wanton kernel
#

Don't ask about the false, that's what the guy in the youtube video said to do 😂 and as it worked in single player I didn't question it..... but you are right in that it seems to counter act itself

little raptor
#

execVM runs the script scheduled

#

tell me. do you even use it anywhere besides there?

wanton kernel
#

Ok so update... we reduced "serverinit.sqf" to literally only contain "nopop = true"...
As before, my buddy can shoot targets and they stay down. My targets pop back up.

#

Nope...

little raptor
#

just remove it

wanton kernel
#

Laptop, init, and reset.sqf are the only locations

#

So how would I keep targets down until the button is pressed?

little raptor
#

just remove it and test

#

in SP

wanton kernel
#

The whole serverinit.sqf? Ok will try...

little raptor
#

nopop = true and nopop = false

wanton kernel
#

and leave an empty serverinit.sqf? 😄 because that's the only thing in there right now

#

Ok

#

_0 = [70,iCenter1] execVM "reset.sqf"; //will affect all targets in 70m area around iCenter1
_0 = [70,iCenter2] execVM "reset2.sqf"; //will affect all targets in 70m area around iCenter2
;

#

so that

little raptor
#

yes

#

and like I said you only need 1 script

#

both should be "reset.sqf"

wanton kernel
#

Ok I'm going to just make sure it works before I do the housekeeping but I see what you mean

#

the area we are testing it in is the iCenter1 / reset.sqf area, we have mostly ignored the iCenter2 targets after the first couple of times

#

mission running...... testing...................................................

#

ok so still no

little raptor
#

what still no?

#

I didn't say test it in MP

wanton kernel
#

I thought nopop=true would have stopped the targets popping up, don't we need that?

#

Ah ok one moment

little raptor
#

I just said test if removing the variable makes any difference

#

in SP

wanton kernel
#

In fact I can do all the housekeeping to in this case

#

so wait out...

#

will try it now

#

so; both laptops now call reset.sqf which makes reset2.sqf redundant...

#

and initServer.sqf is just this:

_0 = [70,iCenter1] execVM "reset.sqf"; //will affect all targets in 70m area around iCenter1
_0 = [70,iCenter2] execVM "reset2.sqf"; //will affect all targets in 70m area around iCenter2
;

little raptor
#

well I'm tired, so just gonna tell you what to do:

  1. put this in init.sqf:
[70,iCenter1] execVM "reset.sqf";            //will affect all targets in 70m area around iCenter1
[70,iCenter2] execVM "reset.sqf";            //will affect all targets in 70m area around iCenter2
  1. this is your reset.sqf:
params [["_dist",70,[1]],["_center",player,[objNull]]];                    //in params

_SwivelTargets = nearestObjects [position _center, ["Target_Swivel_01_base_F", "TargetBase"], _dist];        //swivel targets work differently
if (count _SwivelTargets < 1) exitWith {
    systemChat "No targets were found.";
};

{
    if (_x getVariable ["BIS_poppingEnabled", true]) then {_x setVariable ["BIS_poppingEnabled", false, true]};
    _x animate ["Terc",0];
    if (_x getVariable ["HitPart_EH", -1] < 0) then {
        _x setVariable ["HitPart_EH", 
            _x addEventHandler ["HitPart", {
                ((_this select 0) select 0) animate ["Terc",1];
            }]
        ];
    };
} forEach _SwivelTargets;
#

and remove reset2.sqf

#

and change them in your scripts to "reset.sqf"

wanton kernel
#

ok so in SP that works...

#

And I now have half the amount of clutter in my mission folder, thank you 😄

#

test in MP now as it is?

little raptor
#

I changed the one for "non-swivel targets"

#

both use the same code now

wanton kernel
#

ah good point! Will check that now...

#

RIght

#

Works in SP

#

pop ups work, swivels work

#

reset laptop works

#

so shall I now try this in MP?

little raptor
wanton kernel
#

Thank you so much for your time by the way; this is literally the one snag I have hit in the past 3 weeks of editing this mission

#

Just sent the mission file to my buddy. I should probably clarify there are two reasons why he is hosting...
1 - I can't test multiplayer by myself. Playing with one-self is never as fun.
2 - My laptop for some reason hates hosting Arma 3. I've been through all the firewall possibilities and tweaked my router, no joy, but I have friends who can host so it's not something I'm too fussed about 😄

#

crosses fingers and toes

#

Ok so I shot a target and it popped back up

#

buddy shoots the same target, it stays down

#

So essentially the same as before 😂 shall I try renaming init.sqf to initServer.sqf again?

little raptor
#

No

little raptor
wanton kernel
#

Buddy who is hosting the mission shoots a target = target stays down (which is what we want) and if we go to the laptop to press "reset" the targets pop back up.

#

I shoot a target, it pops back up on its own (vanilla behaviour) which is pretty much the problem we had earlier

#

Pain in the butt ey 😄

#

and I'm guessing the "if (isServer) then" won't work?

little raptor
#

No

#

You shouldn't touch anything

wanton kernel
#

ok...

#

I need to touch the targets though

#

Well no actually I don't, I just need to shoot them 🙃

little raptor
#

Change this line: (remove if)

    _x setVariable ["BIS_poppingEnabled", false, true];
wanton kernel
#

Ok will try that...

little raptor
#

if it still doesn't work, it's the problem with that object

#

It probably uses a SP event handler

#

Like Hit

wanton kernel
#

wait

#

currently you have...

#
if (_x getVariable ["BIS_poppingEnabled", true]) then {_x setVariable ["BIS_poppingEnabled", false, true]};
little raptor
#

Yeah change it to that

wanton kernel
#

that's what it is now already; that bit I just copied is from reset.sqf

#
params [["_dist",70,[1]],["_center",player,[objNull]]];                    //in params

_SwivelTargets = nearestObjects [position _center, ["Target_Swivel_01_base_F", "TargetBase"], _dist];        //swivel targets work differently
if (count _SwivelTargets < 1) exitWith {
    systemChat "No targets were found.";
};

{
    if (_x getVariable ["BIS_poppingEnabled", true]) then {_x setVariable ["BIS_poppingEnabled", false, true]};
    _x animate ["Terc",0];
    if (_x getVariable ["HitPart_EH", -1] < 0) then {
        _x setVariable ["HitPart_EH", 
            _x addEventHandler ["HitPart", {
                ((_this select 0) select 0) animate ["Terc",1];
            }]
        ];
    };
} forEach _SwivelTargets;
#

that's the script as it is now

little raptor
#

I know

#

Just change it to what I wrote

#

The whole if

wanton kernel
#

ohhhh I see ok

#
params [["_dist",70,[1]],["_center",player,[objNull]]];                    //in params

_SwivelTargets = nearestObjects [position _center, ["Target_Swivel_01_base_F", "TargetBase"], _dist];        //swivel targets work differently
if (count _SwivelTargets < 1) exitWith {
    systemChat "No targets were found.";
};

{
    _x setVariable ["BIS_poppingEnabled", false, true];
    _x animate ["Terc",0];
    if (_x getVariable ["HitPart_EH", -1] < 0) then {
        _x setVariable ["HitPart_EH", 
            _x addEventHandler ["HitPart", {
                ((_this select 0) select 0) animate ["Terc",1];
            }]
        ];
    };
} forEach _SwivelTargets;
little raptor
#

Yeah

#

But I don't think it'll work

#

Seems like a bug with the object

wanton kernel
#

aww really? you got my hopes up 😂

little raptor
#

Well you can still try

wanton kernel
#

they are just normal pop up targets lol

#

ok will try

little raptor
#

That's why

wanton kernel
#

?

#

Oh

#

It's funny how it works fine for the guy who hosts but not for the clients 🤷‍♂️

little raptor
#

Because the object is local to the guy that hosts

#

It's no different than SP for him

wanton kernel
#

True

little raptor
#

If you try on dedicated it won't work for anyone

wanton kernel
#

Yeah that's the worry 😂

little raptor
#

My guess is that the game is using an event handler to handle the pop up

#

You can just remove the EHs instead

wanton kernel
#

Still pops up for me 🤷‍♂️ nevermind

#

Remove the EHs, don't I need those?

little raptor
#

not those

#

The ones that the game adds

wanton kernel
#

So essentially I need to get the game to remove behaviour 😂

little raptor
wanton kernel
#

Okay will try, thank you for your aid 🙂

little raptor
#

Inside {}

#

You need 3 additional lines, one for each EH I mentioned

wanton kernel
#

Ok we have accidentally found a fix

#

My buddy randomly added nopop=true at the start of init.sqf and the targets stay down when hit, pop up when reset 😂 the swivels are twitching but that's a tomorrow problem lol

#

Thank you again fella, I really don't think we'd have nailed it without your help 🙂

clever apex
#

Simple way to make a projectile (artillery shell, missile, rocket, etc) fall from the sky when a trigger is activated? I want to use a custom projectile not just the three availible in the ordinance module

#

I would like it to be a scripting command

past wagon
#

if I have 8 players and I want each one to have their own customizable loadout saved to a variable, is there a better way than to make a global variable for each player?

past wagon
#

ok

#

yeah ive seen something done with setVariable and getVariable. So I can basically have a separate variable with the same name for each object, that I access with sqf object getVariable "name"

#

great, thanks

#

and I could do something like this, right?

{
    _x setVariable ["playerLoadout", _defaultLoadout];
} forEach allPlayers;
little raptor
past wagon
steady matrix
#

Bravo_2_CorpsePOS = getPosATL Bravo_2; hint str Bravo_2_CorpsePOS; Bravo_2_CorpseEvacuated = Bravo_2_CorpsePOS inArea medevac_collectionZone;

Hey all - so in the above code when I run a hint to test if the values are correct, it shows that Bravo_2_CorpseEvacuated equates to the same value stored in Bravo_2_CorpsePOS rather than a boolean - so I'm assuming that there is something wrong with this santax and I'm not sure how to get it to do what I'm wanting to do.

past wagon
#

first of all

#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
steady matrix
#

Oh thank you!

past wagon
#

also, you need parenthesis:

Bravo_2_CorpsePOS = getPosATL Bravo_2;
hint str Bravo_2_CorpsePOS;
Bravo_2_CorpseEvacuated = ( Bravo_2_CorpsePOS inArea medevac_collectionZone ); //parenthesis here
#

that code should work ^

steady matrix
#

Ahhh, that makes sense. Let me give it a try.

#

Hmmm, so I made the changes as suggested - and even after doing so, Bravo_2_CorpseEvacuated isn't returning a boolean. :/

past wagon
#

is it still returning the position?

steady matrix
#

Correct.

past wagon
#

ok one sec

steady matrix
#

Thank you for the assistance. 🙂

past wagon
steady matrix
#

Sure thing, just in the debug console - can I share my screen with you real quick?

past wagon
#

one sec

#

is medevac_collectionZone a map marker or a trigger?

steady matrix
#

So I tried it two ways - initially I tried to do the trigger which is what the value above is;

past wagon
#
Bravo_2_CorpsePOS = getPosATL Bravo_2;
hint str Bravo_2_CorpsePOS;
Bravo_2_CorpseEvacuated = ( Bravo_2_CorpsePOS inArea "medevac_collectionZone" ); //parenthesis here
sleep 5;
hint str Bravo_2_CorpseEvacuated;
```This is the code I am using to test it and I am getting "true". I am using a map marker, hence the string
steady matrix
#

Then I tried doing it as an areamarker in the same field with the name medevac_collectionArea;

past wagon
#

now that I think about it, I can just do hint str Bravo_2_CorpseEvacuated;

#

lemme try that real quick

past wagon
steady matrix
#

Dang... wondering what the problem is... alright, I'll do some digging. Thank you very much for all the help. Appreciate ya.

past wagon
#

ill be here. lemme know if you figure anything out, I'm happy to help

steady matrix
#

I was trying with a trigger initally and as an object, not a string, - but I will try it with the quotes as an area marker and report back.

past wagon
#

if you wanna send me your full code (idk how much that would be), then I can look at it for you and try to figure it out

#

ok

steady matrix
#

Sure thing - I don't have a whole lot right now, I'm just kind of testing the fundamentals before I go building deeper but... pming you.

past wagon
#

ok

naive pulsar
#

So im trying to figure out why the vls wont lock on to a regular laser designation lock in ace do i have to do some extra special stuff to get it to do that?

#

if so can you dm me and help me out alittle

willow hound
#

@naive pulsar The VLS only locks onto entities of class LaserTarget. Additionally, these LaserTargets have to be present on the data link of the VLS.

little raptor
#

= is not an operator. you never need parentheses

candid condor
#

Could someone help me with this im trying to have a infotext during the mission but I wanna customise it so it looks ww2 like and you dont hear the modern sound but like a typewriter. I dont know if I can ask this in hear. this is the code im using

#
[
    [
        ["The Netherlands, 17/09/1944", "align = 'center' shadow = '0' size = '0.7'"],
        ["","<br/>"], // line break
        ["Easy Company, 506th PIR", "align = 'center' shadow = '0' size = '0.7'"],
        ["","<br/>"], // line break
        [name player,"align = 'center' shadow = '0' size = '0.7'"],
        ["","<br/>"], // line break        
        ["Operation Market Garden", "align = 'center' shadow = '0' size = '1.0'"]
    ]
] spawn BIS_fnc_typeText2;
wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
little raptor
#

Edit your previous message. Also read the bot message to learn how to do it

candid condor
#

Their we go

#

Thxn

little raptor
#

You don't need !code. It's a bot command

little raptor
#

Oh the sound. Right
That function doesn't allow chnaging the sound. So you have to create your own function based on that one

candid condor
#

Frick haha never did that

#

Any idea wear to find something like that?

little raptor
candid condor
little raptor
#

Ok but I mean the function you're spawning

#

The rest is irrelevant

#

BIS_fnc_typeText2

candid condor
#

So change BIS_fnc_typeText2 to something else?

candid condor
#

Alright

#

I will see what I can do

#

Thanks for the help

shrewd hedge
#

Sorry to interrupt, I've got a question, I'm using SAB's C130 mod to drop APC in the air, it works fine with player as pilot. But when I use playAction script, AI pilot is not cooperating? only ideas?
I'm using script like: pilot1 playAction "Open Ramp"; , and I put them in the waypoint.

cyan dust
#

Good day. Is there a way to check if object's variable is public or not?

little raptor
little raptor
#

but you can just check if the var exists on all clients (and it's very "network expensive")

shrewd hedge
#

@little raptor, may I ask how can I let AI paradrop a vehicle from a plane?

little raptor
#

how does that script work exactly?

#

using an action?

shrewd hedge
#

Ja, I know that , but I cannot write script

#

the "action" is already there , it works fine with player

cyan dust
cyan dust
#

Thanks

little raptor
shrewd hedge
#

I can open ramp and then unload all vehicle using c130 mod and drongo logistic mod

#

but for AI ,no clue,

little raptor
shrewd hedge
#

I can not find the action cod? so i type in the action name it appears

#

but it didn't work, so i guess i need the action code

#

I unpacked the C130 mod ,but fund no script related to it

little raptor
shrewd hedge
#

C130 by SAB

little raptor
shrewd hedge
#

"Open Ramp" and "Unload all Vehicles"

little raptor
shrewd hedge
#

so ?

little raptor
#

"Open Ramp"

class openramp
            {
                displayName="Open Ramp";
                position="pos cargo";
                radius=15;
                showWindow=0;
                onlyforplayer=1;
                hideOnUse=1;
                condition="this animationPhase ""ramp_top"" < 0.5";
                statement="this animate [""ramp_top"", 1]; this animate [""ramp_bottom"", 1]";
            };
little raptor
shrewd hedge
#

thanks , I will try

candid condor
#

Hey sorry for barging in again but Im having some trouble with a font

#
[
    [
        ["The Netherlands, 17/09/1944", "align = 'center' shadow = '0' size = '0.7' font='TahomaB '"],
        ["","<br/>"], // line break
        ["Easy Company, 506th PIR", "align = 'center' shadow = '0' size = '0.7' font='TahomaB '"],
        ["","<br/>"], // line break
        [name player,"align = 'center' shadow = '0' size = '0.7' font='TahomaB '"],
        ["","<br/>"], // line break        
        ["Operation Market Garden", "align = 'center' shadow = '0' size = '1.0' font='TahomaB '"]
    ]
] spawn BIS_fnc_typeText2;
#

It gives me an error when I use this font

little raptor
candid condor
#

Even if I remove the space it gives me an error

little raptor
candid condor
#

Yeah I changed that still gives me errors

little raptor
candid condor
#

Nvm my bad apperently I did somethign wrong at the first time

#

Sorry for bothering

shrewd hedge
#

@little raptor it works now, vehicle will be paradropped in the air, but I failed to get the ramp open

low sierra
#

Can i make a spark effect in Arma 3 using scripts?

little raptor
shrewd hedge
#

what if i want to close them?

little raptor
#

0

shrewd hedge
#

shall I change 1 to 0

#

ok

#

oh, It works, the ramp opens, but they won't close up after I paradrop vehicles

#

I set up 2triggers to open and close the ramp

little raptor
#

don't you use waypoints?

shrewd hedge
#

I have waypoints, but i put scirpt in the triggers

little raptor
#

waypoints have completion statements

shrewd hedge
#

ok , so instead of 2 trigger, I shall put scritpts in 2 move WP?

little raptor
#

yeah

#

vehicle this is the vehicle

#
vehicle this animate ["ramp_top", 1]; 
vehicle this animate ["ramp_bottom", 1];
shrewd hedge
#

thanks, i will try that

grim ravine
#

Wonder if someone can point me in the right direction, I'm trying to edit some of the cfgs of a vanilla vehicle (APC_Tracked). I've added an EH to change the cargo of the vehicle when it is spawned which completes however it crashes the server when spawned

#

EH has been added like this;

    class RW_Warrior_30mm_Base : RW_Warrior_Base
    {
        class EventHandlers
            {
                //init = "[_this select 0] call RW_Warrior_fnc_addVehicleLoadout;";
            };```
shrewd hedge
#

it works, i guess after dropping, C130 has trouble finding the right WP, after a circle, AI pilot closed the ramp. Good Job, Leopard! Amazing

bitter jewel
#

can i make an infantry unit appear bloodied without applying damage on them

jade acorn
#

how can I spawn a magazine with certain amount of bullets? unless I can't

copper raven
bitter jewel
sage flume
#

I've been scouring the wiki's to try to find a script to spawn a player in a down (crouched/weapon down) relaxed position but cannot find. I wonder if I could ask for a sample I could try.

hollow thistle
#

go into editor, crouch. get crouching anim by executing

animationState player

use that animation with player switchMove <anim>

little raptor
#

from memory

#

But I'm pretty sure it's correct

#

but it's for rifle tho

#

you can also do:

player switchAction "Crouch"

but I'm not sure if it stays

little raptor
bitter jewel
#

i have an infantry unit i want to keep in a certain animation, namely unconsciousFaceUp, so i switchmove it to that animation and do _unit disableAI "ANIM" which works, except now the unit is constantly playing this sound of being dragged against the ground

#

can i do something about that sound

#

wait i have JSRS soundmod loaded

#

i should try this without that first...

little raptor
bitter jewel
#

yes

little raptor
#

setUnconscious

bitter jewel
#

well yes and no

#

i did that first

#

the unit should not move

#

it should appear dead

#

setUnconscious will make it wave its arm and stuff like that once in a while

little raptor
#
_unit setUnconscious true;
_unit switchMove "UnconsciousFaceUp";
_unit disableAI "ANIM"
bitter jewel
#

i am using them togehter like that already

sage flume
#

Player is still standing/weapon up. Do I need some punctuation that might be missing (simply no scrpting knowledge at all)

#

player switchAction "Crouch",
AmovPknlMstpSlowWrflDnon

little raptor
bitter jewel
#

jsrs did not cause the problem

little raptor
meager epoch
#

Will a condition which has a certain hidden object in it work?

#

in other words, e1 distance blood1 < 2 where blood1 is hidden

#

will it still calculate the distance between the blood and e1

little raptor
#

yes

meager epoch
#

ait cool

bitter jewel
#

lol

#

no wait that is false

#

hmm

surreal peak
#

feel like im going insane, im editing some old code of mine (which was improved & rewritten by someone else) : https://sqfbin.com/pozarezonozepuwoliro and im getting the error:

19:01:36 Error in expression <BIS_fnc_animalBehaviour_disable", false];
                };
          >
19:01:36   Error position: <", false];
                };
          >
19:01:36   Error Missing ;
19:01:36 Error in expression <BIS_fnc_animalBehaviour_disable", false];
                };
          >
19:01:36   Error position: <", false];
                };
          >
19:01:36   Error Missing ;

#

I dont get why I am though

#

I copied _dog setVariable ["BIS_fnc_animalBehaviour_disable", false]; directly from wiki

little raptor
surreal peak
#

I feel like I should know what that is, but I have no idea what that is

little raptor
surreal peak
#

fixed it, was to do with naming the hecking dog

surreal peak
#

Is it possible to add additional parameters to event handlers? I need to pass another unit to AnimDone event handler

winter rose
surreal peak
#

wont the other unit be out of scope so it wont work?

#
            private _EHidMan = _unit1 addEventHandler ["AnimDone", {
                params ["_unit", "_anim"];
                _unit2 setVariable ["foo"];
                
            }];

wont work will it?

#

or have I misunderstood you?

winter rose
surreal peak
#

ahhh

#

ty

bitter jewel
#

if i add an eventhandler to an unit, and then the unit gets killed, will the eventhandler get destroyed by carbage collection or something else at some point?

#

basically i want a corpse to have the "HandleDamage" eventhandler

winter rose
bitter jewel
#

great!

#

thanks

dreamy kestrel
#

Q: I am adding some actions to player via addAction, I have IDs 42, 43, verified.
However, when I ask for actionIDs player thereafter, I do not see those IDs among that list... should I be seeing them there?

#

oh ok I see what happened, it's a CBA thing... CBA_fnc_addPlayerAction

sacred turret
#

guys, does anyone knows why this only works on the host (character1)?

character1 remoteExec ["customAddActionFunction", character1];
character2 remoteExec ["customAddActionFunction", character2];

p.s.: ignore the "customAddActionFunction"

winter rose
sacred turret
#

forgot to add that this is running on initServer

sacred turret
winter rose
#

then you may need to delay it a bit if units don't exist at that time perhaps
also if a unit changes locality, it may need to be re-executed

#

otherwise, it should work

sacred turret
#

the 2 units are created in the editor, not by code

winter rose
sacred turret
#

I tried once in singleplayer (multiplayer server but alone with ai), disabled ai and used zeus to check if the action was there for the other unit, it was

#

but in multiplayer testing with my friend it wasnt for him

winter rose
#

could you place that in initPlayerLocal.sqf for the function to run locally?

sacred turret
#

wouldn't that run for every player?

winter rose
#

you can set conditions in there

sacred turret
#

maybe an if could do it, but still I'm quite curious about why remoteExec isn't working. Never managed to get it to work tho

cunning oriole
#

if you did remote exec then iirc it would result in it running on the targets every time a player joins but you you could do an if statement to see if the player is your target

winter rose
#

if (player == theUnit1) then
Yeah

sacred turret
cunning oriole
#

the remote exec would end up getting called every time a player joined your mission

sacred turret
#

the code is on initServer

cunning oriole
#

initServer only runs when the server starts

#

does that make sense @sacred turret

sacred turret
#

?

winter rose
sacred turret
winter rose
#

I do not understand the question

winter rose
past wagon
#

I think youre confusing init.sqf with initServer.sqf

sacred turret
winter rose
past wagon
#

usually to get stuff started at the beginning of a mission

winter rose
past wagon
#

initServer runs once at the beginning of the mission on the SERVER, init runs locally for every connected client at the beginning of the server

sacred turret
sacred turret
cunning oriole
#

could you try making a script that just hints something to just verify its nothing in your function and remote exec that?

cunning oriole
#

so your not letting the code run until the unit exists etc

#

which if its AI should be very quick

sacred turret
cunning oriole
#

dont think so

sacred turret
winter rose
cunning oriole
#

ah, if the other script worked fine then its not your execution of the script but whats in the script your trying to run?

cunning oriole
sacred turret
#

sorry, I miswrote it

winter rose
#
waitUntil { sleep 1; not isNull player };```
sacred turret
#

initServer or initplayerlocal?

tacit tartan
#

Hey does ArmA have good networking eg strings are easier to send across network then arrays?

winter rose
winter rose
tacit tartan
winter rose
sacred turret
tacit tartan
#

Well do you have any tips for broadcasting variables for the most optimised way

winter rose
#

because if you send 100 messages/second, that's the issue

sacred turret
cunning oriole
tacit tartan
sacred turret
winter rose
tacit tartan
sacred turret
#

I mean, it makes sense, but wouldnt it be almost inconsiderate?

winter rose
cunning oriole
#

^

sacred turret
#

out of curiosity, is it a sqf thing or is it common amongst other languages?

cunning oriole
#

generally just an sqf thing afaik I guess it could have some kind of impact if you called a named function over and over however I doubt it would ever be noticeable with the way modern computers work

#

even then dw about it for sqf, especially for small missions

copper raven
jade acorn
jade acorn
#

So there's no way to modify magazine parameters that was placed on a ground like an object? Only player/container inventory?

copper raven
#

remove the magazine, and readd it with wanted count? not sure i get what you mean

past wagon
#

how do you check the config files to get the magazine for a gun?

#

for example, what if I wanted to give a unit magazines for whatever gun they have...

copper raven
little raptor
past wagon
#

okay

#

thanks

vague geode
#

Quick question: Does anyone know whether the armament of Jets or more precisely the weight of said armament affects flight performance?

Meaning is an empty jet for example faster than one that is fully loaded with GBUs?

I am asking because the armament doesn't seem to affect the mass (getMass) of the vehicle...

cyan dust
#

Good day, is there a faster alternative to

_position = _center getPos [_distance, _angle];

?

  • I don't need Z value
  • I want it to be more efficient
cosmic lichen
#

That't already super fast. Why does it need to be faster?

cyan dust
cyan dust
vague geode
cosmic lichen
#

I only know that vehicle customization adds weight to the vehicle. You might wanna check the config of the pylons to see if they have a mass property

copper raven
torpid quartz
#

Trying to end a mission with this code but have it be the end type of sideScore, so the team with the highest scores see's "your side own" and the other sees "your side lost", however with this code I'm always getting "mission complete" at the end.

["SideScore", true, 3] remoteExec ["BIS_fnc_endMission", 0, true];

I realise now that the "true" is making it say "mission complete" instead of side score. How do i make this function end the mission with the side score end?

fleet stirrup
#

There is no way to animate an animation source locally only? I am having issues with animate and animateSource taking a long time to synchronise changes for things that don't actually need to be synchronised (animations inside a cockpit for a copilot.) Doing this would also improve with MP network performance I am sure!

distant oyster
torpid quartz
torpid quartz
# distant oyster https://community.bistudio.com/wiki/Description.ext#CfgDebriefing

ah right thanks, just figured out I can call end mission functions for specific sides.
So just make a unique briefing for both and run them at the same time on the end trigger, easy.

Saw this as an example

["End6","BIS_fnc_endMission",east] call BIS_fnc_MP;
["End5","BIS_fnc_endMission",west] call BIS_fnc_MP;

just because of where the "east" and "west" are in this function, where would you put them in
["SideScore", true, 3] remoteExec ["BIS_fnc_endMission", 0, true]; ? remoteExec's formatting still is a bit of mental gymnastics for me.

mint cove
#

does anyone know what the script is to save mission progress on dedicated server

winter rose
#

saveGame?

fleet sand
#

Hi guys question here how would i make so i kill x amount of units of 1 side at any given point. So this is what i got so far: ```cs
L_fnc_LeftUnits = {
params[["_number",0.5],["_side",east]];

_totalNumberAlive = {alive _x && {side _x == _side}} count allUnits;

_test = (_totalNumberAlive * _number);

_numberToKill = _totalNumberAlive - round _test;

systemChat format ["All: %1", _totalNumberAlive];
systemChat format ["Alive after purge: %1", round _test];
systemChat format ["Number to kill: %1", round _numberToKill];

// how to make so i kill X amount of units at any given time?
{}foreach units _side;

};

[] spawn L_fnc_LeftUnits;```

mint cove
winter rose
#

type what, where

mint cove
#

like im trying to save my mission progress on bmr insurgency but every time the server resets i lose all the ground i gained

#

i would like to know the script to save the progress and where to put it if you could help me, id be grateful

barren pewter
#

Wondering how to make a script that detects when everyone in an AI group is dead, and when they are they respawn at a designated point.

tacit tartan
distant oyster
willow hound
# fleet sand Hi guys question here how would i make so i kill x amount of units of 1 side at ...
params [["_number", 0.5], ["_side", east]];

private _units = units _side;
private _totalNumberAlive = {alive _x} count _units;
private _test = round (_totalNumberAlive * _number);
private _numberToKill = _totalNumberAlive - _test;

systemChat format ["All: %1", _totalNumberAlive];
systemChat format ["Alive after purge: %1", _test];
systemChat format ["Number to kill: %1", _numberToKill];
 
for "_i" from 1 to _numberToKill do {
  _units # _i setDamage 1;
};
tender fossil
#

how do I open multiple clients on the same machine? I did this before somehow with help from here but I do not recall how exactly...

tender fossil
#

ah, thanks! forgot about BE 😁

fleet sand
willow hound
#

I don't know if units _side is ordered somehow (by group for example). Instead of _units # _i setDamage 1; you could also do selectRandom _units setDamage 1;.

little raptor
cyan dust
#

Good day. Is there a way to find attached object offset?

#

I've tried 'worldToModel' but it's giving incorrect Z value or I'm misusing it.

little raptor
#

the pos must be AGL

#

and the pos must be measured from the model center [0,0,0]

cyan dust
little raptor
cyan dust
proven charm
#

why not just getposAtl Leopard20 ?

little raptor
proven charm
little raptor
#

getPos/ATL/ASL commands use the land contact of the object

#

not model center

proven charm
meager epoch
#

need sum help getting this to work. it also doesnt create any files even when i do it w/o the array (in case theres smth wrong with it)

_iDocuments = [[4351.47, 4349.16, 1], [4342.52, 4362.56, 1], [4348.68, 4353.83, 4.34], [4343.77, 4357.39, 4.34]];
_documents1 = "Land_Document_01_F" createVehicle (selectRandom _iDocuments);
little raptor
#

do you see them up there?! 🤣

cyan dust
meager epoch
little raptor
meager epoch
#

i hope

little raptor
#

also are you sure the obj type is valid?

meager epoch
#

how 👀

little raptor
meager epoch
little raptor
#

yes

meager epoch
#

yeah i double checked

#

that's what its called

little raptor
#

ok so put a sytemChat in your code to make sure it runs

#
systemChat str _documents1;
meager epoch
#

i get this 1bb11d11600# 164611: document_01_f.p3

little raptor
#

so it is being created

#

now find it! 🤣

meager epoch
little raptor
#

pp = [_documents1];

meager epoch
#

if i do getPos _documents1 i get [4349.5,4353.5,0]

#

which means it doesnt get the third value from the array

little raptor
#

don't use getPos meowsweats

proven charm
#

createVehicle can change the spawn pos

meager epoch
little raptor
meager epoch
mint cove
winter rose
mint cove
#

ok thanks

brazen lagoon
#

Is it possible to get a list of all objects on a map?

#

Like, not all mission objects. All terrain objects

winter rose
#

why not?

brazen lagoon
#

yeah, testing that now

grand idol
#

How would I get the ammo count for a specific magazine in the player's inventory? I'm modifying an Exile script the uses onLBDblClick = "_this call ExileClient_gui_inventory_event_onItemDoubleClick"; which returns the control idc and the selected element index.

brazen lagoon
#

if I have an array as a hashmap value that's by reference, right?

#

also, how do I get the ID of a terrain object?

little raptor
#

the question is can you change it by reference. which you can cuz it's an array (using appropriate commands)

brazen lagoon
#

gotcha

brazen lagoon
#

like if you do nearestTerrainObjects itll show a number: path\to\p3d

#

i want that number

#

dewrp outputs an array like this: ```wrp_objects=
[
// p3dname,[
// [ID,[X,Y]]]

#

I'm trying to emulate that in sqf

#

this is actually used it seems: sqf _id = _o select 0; _pos = _o select 1; _obj = _pos nearestObject _id;

past wagon
#

can I get the reload duration for a certain weapon from the config files?

past wagon
#

ok. what is the command for that?

little raptor
#

there is no command meowsweats

willow hound
#

getNumber

past wagon
#

ok

little raptor
#

no it's not a direct number

past wagon
#

...

little raptor
#

you have to get the reload anim

#

then get the anim time

past wagon
#

ohh

#

ok, how do I get the reload animation?

little raptor
#

you get the reload action

#

then find the bound state in CfgMovesMaleStr / actions

past wagon
#

okay. if this is the code to get a weapon's magazines from the files, then what is the code to get an animation's duration?

getArray (configFile >> "cfgWeapons" >> _weapon >> "magazines")
winter rose
#

("magazines"? shouldn't it aim at magazineWells?)

past wagon
#

I tested it, it works

#

it returns the classname of a weapon's respective magazine

#

but its in an array

#

anyway, im new to this config file stuff

little raptor
#

magazines is like default ones

past wagon
#

actually, instead of getting the reload duration and using it as a delay, I can just make the unit do the reload animation

past wagon
#

okay. what about switchMove?

little raptor
#

no

#
configFile >> "CfgWeapons" >> _wpn >> "reloadAction"
#

it's an action

#

not anim state

past wagon
#

ohh

#

ok

brazen lagoon
#

ok. is there any way to get a number from parseNumber that's explicitly not scientific notation?

past wagon
#

but do I still need to get the reload animation for the weapon from the config files? Couldnt I just make the player do a "reload" animation, and it would do the respective animation for that weapon..?

brazen lagoon
#

I mean like yeah technically 1234 is scientific notation but I just mean these are IDs, it doesn't make sense for them to be 1.234e06

winter rose
little raptor
#

all numbers in sqf are floats

#

plus that's just the representation of the number

brazen lagoon
#

i guess so long as internally it's the same number I don't really care

#

what's weird is, if I paste in a big number and hit enter, the resulting display isn't 1.23456e06

#

its 123456

#

confusing display behavior

little raptor
brazen lagoon
#

that returns null...

little raptor
brazen lagoon
#

oh right, you need to put the number of decimals too

#

figured it'd have a default or something. w/e

#

so long as its internally the same number I guess it doesn't matter

#

yep seems to work just the same, thanks for the sanity check

grand idol
#

_mag = magazinesDetailUniform player select 1;
returns
9 mm 10Rnd Mag(8/10)[id/cr:10001197/2]
How would I populate a variable with the ammo count "8" from Mag(8/10)

grand idol
# little raptor find

That number will be different every time the function runs, so I need a way to get whatever number is in that position.

little raptor
#

also why don't you just use magazinesAmmo?

grand idol
# little raptor I have no idea what you mean

I need to get the ammo count for a specific mag in a player's inventory. And then be able to remove that specific mag later. Using magazinesDetailUniform, magazinesDetailVest, or magazinesDetailBackpack allows me to use the controller ID and index to isolate that mag. I need to populate a variable with the current ammo count for that mag.

little raptor
#

I guess you can't use it now

#

unless you're using the dev/RC branch

#

it'll be available soon with v2.06 release

grand idol
#

No, not using dev

little raptor
#
_mag = magazinesDetailUniform player select 1;
_cnt = parseNumber (_mag regexFind ["(?<=Mag\()\d+", 0] param [0, [["", 0]]] select 0 select 0);
grand idol
#

Any idea when the release date is?

little raptor
# grand idol No, not using dev

then you can do this instead:

_mag = magazinesDetailUniform player select 0;
_id1 = (_mag find "Mag(") + 4;
if (_id1 < 4) exitWith {1}; //return 1
_id2 = _mag find ["/", _id1];
parseNumber (_mag select [_id1, _id2 - _id1]); //return cnt
grand idol
#

I saw that

winter rose
little raptor
#

@grand idol corrected the code

#

corrected again meowsweats

#

seems to work fine:

magazinesDetailUniform player apply {
    _id1 = (_x find "Mag(") + 4;
    if (_id1 < 4) then { //return 1
        1;
    } else { 
        _id2 = _x find ["/", _id1];
        parseNumber (_x select [_id1, _id2 - _id1]); //return cnt
    };
};
grand idol
#

Let me play with the 2nd one for a bit.

little raptor
#

what do you expect it to give you?

#

it gives you the original string

little raptor
grand idol
little raptor
#

or -1

grand idol
#

Great, thanks.

past wagon
#

how do I subtract a certain element from an array? I want to get all the magazines a player has, but magazines returns grenades as well.

little raptor
past wagon
#

okay

little raptor
#

@grand idol looks like I was wrong about something. use this instead:

_mag = magazinesDetailUniform player select 1;
diag_log format["%1", _mag call {
  _id1 = (_this find "(") + 1;
  _id2 = _this find ["/", _id1];
  parseNumber (_this select [_id1, _id2 - _id1]);
}]; 
#

actually I think that may still be wrong (if ( is in the mag name it returns incorrect result)

austere wigeon
#

Sorry, simple question, how would I run code on a specific headless client with the variable name of "HC1"? I totally forgot how, and can't find docs on it.

#

This is assuming btw that the sqf script is ran from init.sqf

grand idol
#

Something I just discovered...
magazinesDetail
magazinesDetailVest
magazinesDetailUniform
magazinesDetailBackpack
All return the same array.

past wagon
#

if I spawn code from initPlayerLocal, do I need to pass player?

winter rose
grand idol
little raptor
#

I don't think it'll be fixed before v2.08

bright robin
#

btw,does anyone know how can a 0 scripting skilled player can do a "respanw when all the group is dead,or pases a lot of time"

grand idol
#

back to the drawing board.

past wagon
# winter rose why

Im getting an error that I wasnt getting before, and all I changed was putting the code in a spawn. It's a waitUntil that apparently returns nil now.

#
[] spawn {
    while { true } do {
        waitUntil { sleep 1; alive player && _areasArray findIf { player inArea _x } == -1 };
        player setDamage 1;
    };
};
little raptor
# grand idol That would be a problem.
magazinesDetailVest player apply {
    private _reverse = reverse _x;
    private _i1 = (_reverse find "[)") + 1;
    private _i2 = (_reverse find ["/", _id1]) + 1;
    private _i3 = _reverse find ["(", _id2];
    parseNumber reverse (_reverse select [_i2, _i3 - _i2]); // return cnt
};
#

this fixes it

#

but I guess it's out of question now

bright robin
#

ok,how can i do a system that respanws all group members when they pass out for a desired time,or when all group members die?

past wagon
#
waitUntil { sleep 0.25; currentWeapon player != "" && magazines player - ["HandGrenade", "SmokeShellBlue", "SmokeShellRed"] isEqualTo [] && currentMagazineDetail player splitString "(/" select 1 == "0" };
```Are there any good ways of getting around having a stupidly long `waitUntil` condition?
#

is there a better way to format this?

little raptor
#

wat?

#

currentMagazineDetail player splitString "(/" select 1 == "0"
what on earth?

#

just use ammo

little raptor
#

you're evaluating all of those conditions

#

some are pretty performance intensive

#

second of all, no

#

put them in multiple lines if they're too long for you

past wagon
little raptor
#
waitUntil { 
  sleep 0.25; 
  currentWeapon player != "" && {
    player ammo currentWeapon player == 0 && {
      magazines player - ["HandGrenade", "SmokeShellBlue", "SmokeShellRed"] isEqualTo []
    };
  };
};
past wagon
little raptor
#

&& {}
|| {}

#

what you put in {} is only evaluated if the condition is not satisfied already

past wagon
#

player ammo currentWeapon player == 0
okay, thanks this is a big improvement. So, the "Muzzle" is just the classname of the weapon?

little raptor
#

e.g.:

if (false && {blabla})

blabla is never evaluated

past wagon
little raptor
#

yeah

past wagon
#

thanks

past wagon
#

thanks

past wagon
#

okay

little raptor
#

all of them still need to be evaluated

#

but you exit when it can never become true anymore

#

e.g. false && {} this can never be true anymore

#

because of false

#

so we don't care about what's in {}

#

and the opposite:

true || {}

this is already true, so no need to do {}

past wagon
#

yeah so, in some cases it doesnt need to evaluate it all

#

like:

call {
  if (a) exitWith { hint "a"};
  if (b) exitWith { hint "b"};
  if (c) exitWith { hint "c"};
};
#

although, if ( false ) probably isnt very performance reducing so it doesnt matter

past wagon
#

yeah

little raptor
#

what you wrote was performance intensive

#

and needed lazy eval

past wagon
#

yeah

#

and if I put the condition that is most likely to be false at the beginning, then it will be the most performance effective

little raptor
#

yeah

past wagon
#

right?

#

ok

meager epoch
#

can u use custom images/icons in BIS_fnc_holdActionAdd?

little raptor
little raptor
#

afaik

#

yeah

#

it has a param for that