#arma3_scripting
1 messages · Page 713 of 1
it must be scheduled
how do i schedule it
added a sleep and my laptop almost blew up 
!? 
any javascript mods for Arma? lmao
so, i gotta get rid of the EH and put the code, for example in the init.sqf, to make it scheduled?

A new script can be started by using spawn, execVM, exec and execFSM commands. The script started this way will be added into the script scheduler
so, basically just put the code in a spawn (or execVM it)?
yes
but not in the unit's init, right?
and not the whole code
the event handler code
Where code starts unscheduled
Object initialization fields
you're spawning it
do you even know what code is?
and when testing it, it still returned the position of the bullet when it left the gun
do you even read this?
the EH code is the whole code 
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?
i dont think i would have thought of that honestly
im still learning!
anyway, thanks 
works 
good. now try to learn it.
and if you're using my mod, you can do this to see the pos:
create two draw arrays, named pp and pp1:
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
oh, neat
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)
serverNamespace only exists in multiplayer, and only on the server
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?
¯_(ツ)_/¯
localNamespace will do imo
Hmm ok. Something for server EHs. Will try.
Is there any way to round decimals in a float to be a specific format of say 0.00 in script?
yes
May I know how?
_r = round (_num * 10^_decimals) / 10^_decimals;
I see. So you're making it a whole int and then rounding it and converting it back to a float?
if you want it for strings tho, you can use toFixed
there is no int in sqf
every number is float
ah. Alrighty. Never worked with SQF before so this is a new experience
Thank you very much
nope.
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
There is % and mod, see the wiki ;-)
Ok. I found two things saying a % b and a mod b. Will give mod a try
Didn't work with "mod" either.
what do you get as a result
I never checked. It just wouldn't run the code for the if statement it was inside
can you just try x % 20 with different values of x in the debug console
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
post the code
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
damage is a float
and _repairPercent has trailing decimals
you have to round it
also
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
gotcha. didn't know there was an sqf
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?
not really
if you have only a few objects, you can attach them to a reference object
but it's slow
It'll probably be close to a couple dozen objects
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?
that's… not really a scripting question?
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?
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
here is the good place
{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.
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'";
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
If the M119 is sling loadable you could use the “HOOK” waypoint
plz use https://sqfbin.com for big chunks of code
Thanks, I don’t think the M119 is sling loadable, so seeing if there is a way to script it?
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***
That could be complicated since you’d have to create ropes and set velocity and what not
Ok that makes sense, thanks again
having an underscore at the front of variables places said variable in local scope only, correct?
more or less but yes (use private to be sure)
https://community.bistudio.com/wiki/Variables#Scopes should be the link
You can attach it to a slingloadable object and slingload the object instead
It's a variable, and it's not defined there. so it's obvious why
post your script and what you're trying to do. we can't help you otherwise
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
Read the desc on the module. It should have the way to get the vehicle that has respawned
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"];
can action trigger a custom addAction?
if you bind your custom action to UserXXX action then you should be able to https://community.bistudio.com/wiki/Arma_3:_Actions#User
got it, thanks!
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’?
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
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
_this is not an object in this EH
ah whoops that's not going to work at all then lol. I'll have to find something else.
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?
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..
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
You did nothing in this script. The code is not even executed
Missing } before forEach, also ... Only villains indent like that... 
...[[getMarkerPos "marker_1" select 0 + DISTANCETOMARKER - random(DISTANCETOMARKER*2), getMarkerPos "marker_1" select 1 + DISTANCETOMARKER - random(DISTANCETOMARKER*2),0]...
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?
Customizable fog color you mean?
Yeaaaaa
yea thats what i'm asking is how to do it by script
Nope by script
Yes
You can play with post process effects on the fly to get post apocalyptic feel https://community.bistudio.com/wiki/Post_process_effects there are lots of example on the internet of people using them for similar purposes
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
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?
how do you take a flag? is it a CTF?
trying to make a ctf mission, using the default "take" action on an opposite side flag
okay since there is no eventhandler afai can tell, you can use flagOwner in a trigger condition
in script only, in order to notificate everyone once a flag is stolen, I need to check it every once in a while?
i only vaguely remember how ctf works. how did you set up so a flag can be captured?
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
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
wow thats very nice, thank you
what do you mean?
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
the way that it works is by changing what the Take action does or is it adding instead of changing??
this is in addition to what the take action does
ohh, got it
you could overwrite that by returning true instead of false
np
is event handler code still recompiled everytime before executing? 🤔 i know it was like that a while ago, wonder if it still is
Don't think so
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
find which cut they're drawing on and terminate it
using bytecode to test, it does 🤔
or well, it for sure does recompile once
whether it's done again and again, can't test 
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"
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?
¯_(ツ)_/¯
it's easy to test
...thanks
how can i delete an array
or clear its elements without using deleteAt for every single one
_array = []
It seems the answer is "no"; using getShotParents on a vehicle I applied setShotParents to returns an empty array.
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...
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.
post the whole script. without knowing what they are I can't help you
also I'm pretty sure the problem is not isServer
rather it's a locality issue
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
!code
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
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.";
use syntax highlighting
^ this is almost identical in reset.sqf and reset2.sqf, and the init.sqf calls on those
like I posted
Righto
https://community.bistudio.com/wiki/Initialization_Order
I never understood why but init.sqf applies to singleplayer only. I never understood why Im blind. 
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;
;
}
Indeed 🤔
no
so yeah initServer.sqf would fix your issue.
it applies to all
no
Oh well, I saw that coming, makes no sense. 
If only I had ability to post pictures...
scroll to the bottom
Ah, about halfway down the list it shows those two items as "Singleplayer"
Where is that even from, there is a tab called Applies To in my case ...
same page
bottom
So are we saying initServer.sqf won't fix the issue 😂
it only has a different priority in MP
What bottom are you talking about , there is like 1 giant list there lol
And there is clearly a missing column in your case.
it says this in green:
init.sqf is executed Singleplayer N/A Event Scripts Scheduled[1]
but then it says this in blue further down:
init.sqf is executed Multiplayer Ico ok.png Event Scripts Scheduled
Which makes it no less confusing 😄
Well yeah, good thing Im not a mission maker
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
why not use regex instead?
also you can just write: !(configName _x in _items)
what you wrote is a lot slower
especially now that you admit "string is too long"
huh i didn't know that the condition knows about variables from the current scope
but regex and hashmap are the faster options here
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.
Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems.
😂
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.
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
what do you want to do?
this?
I'll be checking to see if an item in a player's inventory is a weapon mag
anyone know where i can find a dev
why?
setting up a new server
like to setup atlas rp cause i thought it was gonna be ez but nope
I don't think devs can help you. also you should ask in #server_admins
so following question then. certain things such as the gbu can be detonated with set damage, however the hand grenade cannot and will detonate on its own when created and then theres the 30mm HE which nothing is created nor destroyed. is there a cfgAmmo value I should look to see if they detonate or not?
so you would stringify the array and then regex the item classname? but how would you utilize a hashmap?
kinda. for hashmap:
createHashmapFromArray (flatten _array apply {[_x, nil]})
for regex:
flatten _array joinString "|" //or some other invalid character
i have to sort the items afterwards by their displayname though
hmm but yeah that might still be faster
Yes, I'm roughing out a script for Exile that would allow ammo to be disassembled. I'd like to use the familiar crafting pipeline but don't want to create 400 recipes. The idea is to check if the item is a weapon mag and if so, redirect to the disassembly script. I'd welcome suggestions.
then just use cfgMagazines type I guess?
on the other hand the code is nice and readable rn, making it more complicated is going to make maintenance an chore
like I said your script has locality issues
Yeah but will setting init.sqf to initserver.sqf help? 🙃
depends where the objects are
I mean locality
Ok
not physical place
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
none of this information matters
where do you create the targets?
and how?
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
You just asked where I created the targets, sorry what was my assumption 🤣 yes via Eden
well then they probably will always belong to the server
so yeah, you can try initServer.sqf
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 😂
you sure you weren't testing "serverinit.sqf"
#arma3_scripting message
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 🤔
locality, not localization
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
}
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
That's my script 😮
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?
afaik no
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 😂
put that in init.sqf
You're sure, copy all of that into "initServer.sqf" and not the "reset.sqf"?
I mean just use init.sqf
not initServer.sqf
Righto will do that. Should I move/delete the reset.sqf and initServer.sqf for this
reset.sqf and reset1.sqf for two different areas on the map (they don't overlap at all)
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"
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
they are 
what laptops?
Oh
you didn't even mention laptops.
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 🤦♂️
you do
but if you use laptops to reset them it won't work then
uhhhhhhhh
I thought you only did that from init
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
nopop = true
what is this supposed to be anyway?
Stops pop up targets from popping up
it's set to both this way
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
it doesn't just " counter act itself". it does nothing
execVM runs the script scheduled
tell me. do you even use it anywhere besides there?
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...
Laptop, init, and reset.sqf are the only locations
So how would I keep targets down until the button is pressed?
I don't know. whatever you did before. that variable does nothing
just remove it and test
in SP
The whole serverinit.sqf? Ok will try...
no just nopop
nopop = true and nopop = false
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
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
I thought nopop=true would have stopped the targets popping up, don't we need that?
Ah ok one moment
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
;
well I'm tired, so just gonna tell you what to do:
- 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
- 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"
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?
both kind of targets?
I changed the one for "non-swivel targets"
both use the same code now
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?
yes
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?
No
Wdym?
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?
ok...
I need to touch the targets though
Well no actually I don't, I just need to shoot them 🙃
Change this line: (remove if)
_x setVariable ["BIS_poppingEnabled", false, true];
Ok will try that...
if it still doesn't work, it's the problem with that object
It probably uses a SP event handler
Like Hit
wait
currently you have...
if (_x getVariable ["BIS_poppingEnabled", true]) then {_x setVariable ["BIS_poppingEnabled", false, true]};
Yeah change it to that
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
This
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;
aww really? you got my hopes up 😂
Well you can still try
The old code was already correct
That's why
?
Oh
It's funny how it works fine for the guy who hosts but not for the clients 🤷♂️
Because the object is local to the guy that hosts
It's no different than SP for him
True
If you try on dedicated it won't work for anyone
Yeah that's the worry 😂
My guess is that the game is using an event handler to handle the pop up
You can just remove the EHs instead
So essentially I need to get the game to remove behaviour 😂
I'm on mobile rn so I can't write scripts anymore. Just look at removeAllEventHhandlers on the wiki.
put that before the part of the code where I add the event handler
remove Hit, MPHit and HitPart event handlers
Okay will try, thank you for your aid 🙂
Also put that immediately after the if then
Inside {}
You need 3 additional lines, one for each EH I mentioned
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 🙂
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
createVehicle
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?
setVariable
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;
You could, but the variable only exists where you run the command
depending on where you need this, you should either:
- run it locally
- make it run globally using the true flag
yeah I want these to be the equivalent of global variables, accessible whenever and wherever. so do I just use true to fix that problem?
Edit: nevermind, you pretty much already answered that question. Thanks.
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.
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
Oh thank you!
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 ^
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. :/
is it still returning the position?
Correct.
ok one sec
Thank you for the assistance. 🙂
can you show me where you test Bravo_2_CorpseEvacuated?
Sure thing, just in the debug console - can I share my screen with you real quick?
So I tried it two ways - initially I tried to do the trigger which is what the value above is;
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
Then I tried doing it as an areamarker in the same field with the name medevac_collectionArea;
now that I think about it, I can just do hint str Bravo_2_CorpseEvacuated;
lemme try that real quick
still getting true with this code. probably something else on your end. remember if you are using a map marker, you need it to be a string. If it is a trigger, then it is an object.
Dang... wondering what the problem is... alright, I'll do some digging. Thank you very much for all the help. Appreciate ya.
ill be here. lemme know if you figure anything out, I'm happy to help
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.
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
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.
ok
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
@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.
Wat?
= is not an operator. you never need parentheses
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;
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
Edit your previous message. Also read the bot message to learn how to do it
You don't need !code. It's a bot command
Ok so what do you need help with?
Oh the sound. Right
That function doesn't allow chnaging the sound. So you have to create your own function based on that one
You can view that function in function viewer
Just copy its code into a new sqf file. Then edit the part with the sound.
If you don't know how to make a function just execVM the file (instead of spawn in your code above)
Currently I have the code as a infoText.sqf within a trigger that ExecVM it
Ok but I mean the function you're spawning
The rest is irrelevant
BIS_fnc_typeText2
So change BIS_fnc_typeText2 to something else?
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.
Good day. Is there a way to check if object's variable is public or not?
that's not what playAction does
there's no "public" variable type. when you do publicVariable "var" it's simply broadcast over the network. if you change it on one client, it's not "public" anymore
but you can just check if the var exists on all clients (and it's very "network expensive")
@little raptor, may I ask how can I let AI paradrop a vehicle from a plane?
execute the script
how does that script work exactly?
using an action?
Ja, I know that , but I cannot write script
the "action" is already there , it works fine with player
Nah, what I meant is
_object setVariable ["%NAME%",%VALUE%,true];
But I got your answer, no way, ok.
same diff
Thanks
good. now just execute the action code
I can open ramp and then unload all vehicle using c130 mod and drongo logistic mod
but for AI ,no clue,
I already told you what to do like 3 times
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
what mod are you talking about?
C130 by SAB
what's the action called in the game?
"Open Ramp" and "Unload all Vehicles"
"Unload all Vehicles"
this is a vanilla action
so ?
"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]";
};
so you can do it using vanilla commands
thanks , I will try
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
you have a space in there
Even if I remove the space it gives me an error
I'm talking about this space: font='TahomaB '
Yeah I changed that still gives me errors
post the code
@little raptor it works now, vehicle will be paradropped in the air, but I failed to get the ramp open
Can i make a spark effect in Arma 3 using scripts?
myVehicle animate ["ramp_top", 1];
myVehicle animate ["ramp_bottom", 1];
what if i want to close them?
0
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
what? you don't need any
don't you use waypoints?
I have waypoints, but i put scirpt in the triggers
then you don't need triggers
waypoints have completion statements
ok , so instead of 2 trigger, I shall put scritpts in 2 move WP?
yeah
vehicle this is the vehicle
vehicle this animate ["ramp_top", 1];
vehicle this animate ["ramp_bottom", 1];
thanks, i will try that
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;";
};```
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
can i make an infantry unit appear bloodied without applying damage on them
how can I spawn a magazine with certain amount of bullets? unless I can't
https://community.bistudio.com/wiki/addMagazine alt syntax?
well setHit with damage 0.9 works in my case, it doesnt seem to kill the unit even if applied to every hitpoint
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.
go into editor, crouch. get crouching anim by executing
animationState player
use that animation with player switchMove <anim>
AmovPknlMstpSrasWrflDnon
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
for weapon down:
AmovPknlMstpSlowWrflDnon
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...
do you want to make the unit unconscious?
yes
setUnconscious
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
use it together with your current stuff
_unit setUnconscious true;
_unit switchMove "UnconsciousFaceUp";
_unit disableAI "ANIM"
i am using them togehter like that already
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
player switchMove "AmovPknlMstpSlowWrflDnon";
jsrs did not cause the problem
maybe try a different anim?
_unit setUnconscious true;
_unit switchMove "UnconsciousDefault";
_unit playMoveNow "UnconsciousDefault";
_unit disableAI "ANIM";
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
yes
ait cool
ok the sound appears only with a certain combination of uniform and terrain surface
lol
no wait that is false
hmm
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
You probably have an illegal character in there
I feel like I should know what that is, but I have no idea what that is
A hidden invalid character. e.g. Japanese space instead of normal space
fixed it, was to do with naming the hecking dog
Is it possible to add additional parameters to event handlers? I need to pass another unit to AnimDone event handler
no, but you can setVariable on the unit
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?
_unit1 setVariable ["theOtherUnit", _unit2]```
and get it from the EH
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
only when the body gets deleted
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
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"
maaaybe not ignore that no
but also, you are remote executing on only one machine
If you want to run the script on every machine, remove the remoteExec target
forgot to add that this is running on initServer
I want to run it on 2 machines, the one that controls character1 and the one that controls character2, ignore the other ones
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
it works, but only for the host machine
the 2 units are created in the editor, not by code
I know, you said it
I meant "if the unit only gets created if e.g disabledAI is set to 1 in description.ext
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
could you place that in initPlayerLocal.sqf for the function to run locally?
wouldn't that run for every player?
you can set conditions in there
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
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
if (player == theUnit1) then
Yeah
oh, I thought it only executed on the targets. But it'll keep executing everytime a player joins even on initserver?
the remote exec would end up getting called every time a player joined your mission
the code is on initServer
initServer only runs when the server starts
does that make sense @sacred turret
?
No, on the server when the mission starts
just tried it, even in this way it only works for the host
I do not understand the question
is the function itself checking "if isServer"?
I think youre confusing init.sqf with initServer.sqf
sorry, didn't get it
np
if the function itself has a "don't run unless you are the server", that could be the reason
usually to get stuff started at the beginning of a mission
could you perhaps try with a waitUntil not isNull player?
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
not the case if I understand it correctly
sure, but not quite sure what to do
could you try making a script that just hints something to just verify its nothing in your function and remote exec that?
waitUntil { !(theUnit1 isNil); };
so your not letting the code run until the unit exists etc
which if its AI should be very quick
wait, does the init server runs before units placed on the editor?
dont think so
did that already and it don't work, I would try it again to test but unfortunately my friend had to leave
Wrong code
ah, if the other script worked fine then its not your execution of the script but whats in the script your trying to run?
😬
sorry, I miswrote it
waitUntil { sleep 1; not isNull player };```
initServer or initplayerlocal?
Hey does ArmA have good networking eg strings are easier to send across network then arrays?
2nd one
it works well whatever you want to send
But are strings quicker then arrays like other engines?
idk, but I know this is not something that you should really worry about
actually I can't test it rn cause my friend had to leave, and locally even this first code works
Well do you have any tips for broadcasting variables for the most optimised way
because if you send 100 messages/second, that's the issue
so this will work either way, cant quite tell if it made a difference
shorter var names iirc are faster
ah yeah i know that
wait seriously?
« Premature optimisation is the root of all evil! » - Donald Knuth
yeah ofc
I mean, it makes sense, but wouldnt it be almost inconsiderate?
don't bother about it really
^
out of curiosity, is it a sqf thing or is it common amongst other languages?
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
you sacrifice code readability for barely any performance increase
However its for adding it to an inventory, I need to have it placed on the ground. But thanj you anyway, I'll try to mess with it a little and see if I can do something
So there's no way to modify magazine parameters that was placed on a ground like an object? Only player/container inventory?
remove the magazine, and readd it with wanted count? not sure i get what you mean
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...
Yes
magazines array in the weapon's config
getArray(configFile >> "cfgWeapons" >> _wpn >> "magazines")
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...
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
That't already super fast. Why does it need to be faster?
I'll check, thanks
You're absolutely right... oo Thanks a lot.
Maybe someone from the BI programming team knows.
@Dedmen (ง •̀_•́)ง maybe?
Basically my question is whether munitions (and maybe fuel) are added to the vehicles overall mass or whether its mass stays the same regardless of the armament.
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
can't get any faster than that in sqf
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?
scripted
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!
do you have a CfgDebriefing config class called "SideScore" defined in your description.ext?
oops no, Is there a page somewhere showing how to set this up? I've been looking through the wiki but can't see anything going into any kind of detail for setting this up.
or you can use one from the global configfile
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.
does anyone know what the script is to save mission progress on dedicated server
saveGame?
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;```
can i just type that in game?
type what, where
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
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.
cheers mate
["EndWin", true] remoteExec ["BIS_fnc_endMission", west, true]; // winning side
["EndFail", true] remoteExec ["BIS_fnc_endMission", east, true]; // losing side
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;
};
is this your server?
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...
it was in #arma3_feedback_tracker , no?
ah, thanks! forgot about BE 😁
ty veryMutch it works. i did small Change in line: cs private _totalNumberAlive = {alive _x && !(isplayer _x )} count _units; i added : !(isplayer _x ) just to check for player.
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;.
either use an event handler on each member and count the number of alive members when one dies,
or
use a loop, and check if any is alive:
if (units _grp findIf {alive _x} < 0) then { //all dead
}
it is
and by group, yes
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.
you are
the pos must be AGL
and the pos must be measured from the model center [0,0,0]
Well, yes, but how? I could get ASL pos, but 'worldToModel' requires object as a first argument, isn't it?
modelToWorld [0,0,0]
ASLtoAGL getPosWorld
etc.
Okay, thanks
why not just getposAtl Leopard20 ?
because ATL != AGL
yea i know, I mean why not any of the getpos commands
ic
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);
they're probably being created in the air 
do you see them up there?! 🤣
xD I'm sure I've tried that as well, but guess mistyped something, yes, with getPosWorld it IS working. Thanks a lot.
i dont 
does your code even run?
i hope
how 👀
systemChat
the land_documents thing?
yes
ok so put a sytemChat in your code to make sure it runs
systemChat str _documents1;
i get this 1bb11d11600# 164611: document_01_f.p3

if i do getPos _documents1 i get [4349.5,4353.5,0]
which means it doesnt get the third value from the array
createVehicle can change the spawn pos
it creates them under the building 
so use "CAN_COLLIDE"
that did it, thanks 
yes its my own server
See maybe with the mission creators/their Discord
ok thanks
Is it possible to get a list of all objects on a map?
Like, not all mission objects. All terrain objects
there's https://community.bistudio.com/wiki/nearestTerrainObjects, could I just do nearestTerrainObjects [[worldsize/2, worldsize/2], [], worldsize * sqrt 2 / 2, false];?
why not?
yeah, testing that now
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.
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?
everything in sqf is always by reference
the question is can you change it by reference. which you can cuz it's an array (using appropriate commands)
gotcha
id?
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;
looks like there's a code snippet here https://community.bistudio.com/wiki/nearestObject
can I get the reload duration for a certain weapon from the config files?
yes
ok. what is the command for that?
there is no command 
getNumber
ok
no it's not a direct number
...
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")
("magazines"? shouldn't it aim at magazineWells?)
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
yeah true
magazines is like default ones
actually, instead of getting the reload duration and using it as a delay, I can just make the unit do the reload animation
then use playActionNow
okay. what about switchMove?
no
configFile >> "CfgWeapons" >> _wpn >> "reloadAction"
it's an action
not anim state
ok. is there any way to get a number from parseNumber that's explicitly not scientific notation?
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..?
then what is it?
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
the number is good, the display isn't
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
use toFixed to see the actual number
that returns null...
you're using it wrong then
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
_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)
find
That number will be different every time the function runs, so I need a way to get whatever number is in that position.
I have no idea what you mean
also why don't you just use magazinesAmmo?
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.
then use regexFind
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
No, not using dev
_mag = magazinesDetailUniform player select 1;
_cnt = parseNumber (_mag regexFind ["(?<=Mag\()\d+", 0] param [0, [["", 0]]] select 0 select 0);
Any idea when the release date is?
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
I saw that
yeah sorry, I did not notice there was a conversation going on 😄
@grand idol corrected the code
corrected again 
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
};
};
_mag = magazinesDetailUniform player select 1;
_id1 = (_mag find "Mag(") + 4;
if (_id1 < 4) exitWith {1};
_id2 = _mag find ["/", _id1];
_mag select [_id1, _id2 - _id1];
diag_log format["%1",_mag]; ```
returns
`"9 mm 10Rnd Mag(10/10)[id/cr:10001197/2]"`
Let me play with the 2nd one for a bit.
you're diagloging _mag
what do you expect it to give you?
it gives you the original string
_mag = magazinesDetailUniform player select 1;
diag_log format["%1", _mag call {
_id1 = (_this find "Mag(") + 4;
if (_id1 < 4) exitWith {1};
_id2 = _this find ["/", _id1];
parseNumber (_this select [_id1, _id2 - _id1]);
}];
Awesome. That works perfectly. I appreciate it. I wouldn't have sorted that out any time soon.
if (_id1 < 4) exitWith {1};
this part returns 1 for stuff like grenades. if you don't want it you can change it to 0
or -1
Great, thanks.
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.
okay
@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)
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
Something I just discovered...
magazinesDetail
magazinesDetailVest
magazinesDetailUniform
magazinesDetailBackpack
All return the same array.
if I spawn code from initPlayerLocal, do I need to pass player?
That would be a problem.
you could e.g remoteExec a function with HC1 as a target
yeah I reported it:
#arma3_feedback_tracker message
So you did. Well, I hope that gets addressed. I don't think my script can function without the destinctrion.
I don't think it'll be fixed before v2.08
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"
back to the drawing board.
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;
};
};
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
oh im dumb nevermind
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?
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?
wat?
currentMagazineDetail player splitString "(/" select 1 == "0"
what on earth?
just use ammo
first of all, use lazy eval
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
oh yeah lmao a while ago I saw that and I was confused about the "muzzle" param so I just skipped past it
waitUntil {
sleep 0.25;
currentWeapon player != "" && {
player ammo currentWeapon player == 0 && {
magazines player - ["HandGrenade", "SmokeShellBlue", "SmokeShellRed"] isEqualTo []
};
};
};
what is lazy eval? ive heard the term before but i have no clue what it is or how to do it
&& {}
|| {}
what you put in {} is only evaluated if the condition is not satisfied already
player ammo currentWeapon player == 0
okay, thanks this is a big improvement. So, the "Muzzle" is just the classname of the weapon?
e.g.:
if (false && {blabla})
blabla is never evaluated
ohhh. So kind of like using exitWith if you have a bunch of conditions and only one needs to be evaluated
yeah
thanks
thanks
okay
only one needs to be evaluated
not exactly.
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 {}
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
it's an example
yeah
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
yeah
can u use custom images/icons in BIS_fnc_holdActionAdd?
not just likely, but also can be evaluated faster
yes
afaik
yeah
it has a param for that