#arma3_scripting
1 messages Β· Page 621 of 1
100%
Just make a script modual
P l e as e like just make a trigger that triggers at the game starts
You're using it wrong
Highly likely
So I'd like to get all unit type names from Zombies -> Medium Zombies and Zombies -> Slow Zombies
so basically I want to find all units under Zombies and then filter based on subcategory
So look up the zombie in the config and learn their editor cats
but editorCategory does not give me those names
Problem solved
It's just either empty or EDCAT_THINGS
Since the editor can display the units just fine I really feel I should also be able to
What does the editor use to categorize units?
some editorCategory config something
"true" configClasses (configFile >> "cfgVehicles") select {_name = configName _x; "RyanZombie" in _name && "Opfor" in _name && ("slow" in _name || "fast" in _name)} apply {configName _x}
That's the best I could come up with
you could move the conditions in the "true" string, but it works yes
Changed, thanks
Another thing I'm trying to do is spawn vehicles around buildings
[] spawn
{
_houses = nearestTerrainObjects [[9000, 9000], ["House"], 13000, false];
for "_i" from 0 to 100 do
{
_pos = getPos (selectRandom _houses);
_safe = _pos findEmptyPosition [3, 25, "C_Offroad_01_F"];
createVehicle ["C_Offroad_01_F", _safe, [], 0, "NONE"];
};
};
But this sometimes blows up the vehicles ":D"
even if there's plenty of space around the building, ie findEmptyPosition somehow fails to get a position where the vehicle doesn't clip
Yep, had that issue too
Because you need quite the checks to find a proper position - I had it sometimes find empty space in a house
yeah same
use the BIS_fnc
you mean findsafepos?
but that doesn't take into account the to be spawned item size
hmm I would need to convert the size of the spawned item to objdist
oh well yeah sizeOf works
spawn some place safe ([random 1000, random 1000, 5000+random 5000]) then use sizeOf or boundingBox π
What's annoying though is that the search starts away from the building instead of close to it
and then you spawn a car on the middle of the road, yep
What's the generic error here?
(( count (( units survivors) select { !(_x in thisList) })) + 1 ) >= ( count survivors)
ah
it's count units survivors of course
you could simplify that a little. dont need select
(({!(_x in thisList)} count units survivors) + 1) >= (count units survivors)```
oh cool
I also need to play with the logic a bit
_playing = count (units survivors);
_escaped = {!(_x in thisList)} count (units survivors);
_escaped >= 0.75 * _playing
wtf BIS_fnc_findSafePos can be returning a single value π
it always returns a single value, it's either the position it found or the default position π€ although the value is always an array with x and y
Hey guys, what's the best way to just mess around with scripting? Just the debug menu in game?
"mess around" as in, test different commands, test syntax etc
I have another mission I Want to make but I have zero idea where to start so I gotta do some testing. Going in and out of the editor is getting annoying to change one thing and test -.-
@exotic flax _safe = [_pos, 0, 15, (sizeOf "C_Offroad_01_F"), 0, 1, 0, [], _pos] call BIS_fnc_findSafePos;
literally returning a number instead of an array π
(well a scalar according to typename)
whatthefuck
Is there a "Gettype" style function for this?
if _pos is a single number instead of a position array, than it works like that
Test the code speed in Debug Console.
Use an action menu to test sqf
@exotic flax according to the documentation it will always return an array
so something really fishy is going on
Is it an array of tuples?
Or just ints?
I just ran it using a player and it returned a single number for me as well.
3 to be exact.
If I run the following in the debug console:
_pos = getPos player;
_safe = [_pos, 0, 15, (sizeOf "C_Offroad_01_F"), 0, 1, 0, [], _pos] call BIS_fnc_findSafePos;
_safe;
The result is [2903.4,5407.24] (random pos in VR)
Can you do like _safe[0] or whatever the equivalent syntax is
@exotic flax try
[] spawn
{
_houses = nearestTerrainObjects [[9000, 9000], ["House"], 13000, false];
for "_i" from 0 to 100 do
{
_originPos = getPos (selectRandom _houses);
systemChat (format ["%1", typeName _originPos]);
_safePos = [_originPos, 0, 15, (sizeOf "C_Offroad_01_F"), 0, 1, 0, [], _originPos] call BIS_fnc_findSafePos;
systemChat (format ["%1", typeName _safePos]);
createVehicle ["C_Offroad_01_F", _safePos, [], 3, "NONE"];
};
};
(I tried renaming to see if there would be some freaky collision, nope)
The map is virolahti
@quasi cobalt _safe select 0
and to filter _safe select {condition}
hmm... it does sometimes return a single number (float), but it's really random
It seems someone else has noticed it also
but no response
so this be a bug!
Hmm seems like short circuiting isn't a thing either
I see...
defaultPos needs to be a double array
_safePos = [_originPos, 0, 15, (sizeOf "C_Offroad_01_F"), 0, 1, 0, [], [_originPos, _originPos]] call BIS_fnc_findSafePos;
because if it can't find any position, it will return either the landPosition (1st) or seaPosition (2nd)
so wiki is correct, just a bit unclear
@amber lantern ^^
checking the code of bis_fnc_findSafePos and re-reading the wiki π
example 2 on the wiki page is the correct way to use defaultPos
Is the code available to everyone?
you can use ArmaTools (or better Mikero's Arma2P) to setup a P drive with all Arma 3 PBO's extracted, which contains all functions
Is there a way to cancel a camCommit?
For example. The camera will instantly change to _target2 as expected but the camCommited command will not return true because the first camCommitPrepared is still running.
_cam camPrepareTarget _target1;
_cam camCommitPrepared 30;
_cam camPrepareTarget _target2;
_cam camCommitPrepared 0;
waitUntil {camCommitted _cam};
I was expecting running camCommit or camCommitPrepared being ran a second time to reset camCommited. This is important to me because I have a function that creates a camera that orbits around a target and I gave the function the ability to change variables such as target and rotation speed. So going from a close in camera with a slow camCommit speed to a far out faster camCommit speed is an issue.
To be clear I do have a waitUntil that checks for the camera to be updated and skip the camCommitted.
while {true} do {
ZKB_MenuCam_CamUpdated = false
_camPos = ZKB_MenuCam_Target getPos [ZKB_MenuCam_Radius, _camAngle];
_camPos = (AGLtoASL _camPos);
_camPos set [2,ZKB_MenuCam_Height+ZKB_MenuCam_HeightAdjust];
_camPos = ASLToAGL _camPos;
ZKB_MenuCam camPreparePos _camPos;
ZKB_MenuCam camPrepareTarget ZKB_MenuCam_Target;
ZKB_MenuCam camCommitPrepared ZKB_MenuCam_Speed;
waitUntil {camCommitted ZKB_MenuCam or ZKB_MenuCam_CamUpdated};
};
so you want to have the camera at target1 which takes 30sec to get there, and only after you set a variable it should go directly to target2
tbf... I'm not familiar with the difference between cam* and cam*Prepared, but as far as I can tell it works exactly the same π€
and I wouldn't be surprised if camCommit takes all active (and running) commands since the last commit
@exotic flax I have a function that creates a camera that orbits around a target at a set speed and within that function is the ability to change parameters such as the target, height, radius, and rotation speed.
So lets say It is currently focused on target1 at a speed of 10 seconds (very slow rotation speed) and I want to move that camera to target2 at a speed of .1 (fairly quick rotation speed), while the function see's I've updated the camera parameters and continues the while loop and updates the camera with the new parameters as soon as it gets to waitUntil {camCommited... it will still be waiting for the original delay of 10 seconds to finish. Because the camera updated to the new parameters in .1 seconds the longer delay of 10 seconds is being waited on to commit so the camera stops rotating until that happens.
although you could simply have the while loop to rotate around target1 until it needs to switch to target2
while { !ZKB_MenuCam_CamUpdated } do {
// keep rotating target1
};
// switch to target2
This way it just keeps rotating till you set the variable.
or you can have a timer in there, so it will switch when the var updates OR the time has ran out
https://pastebin.com/1SMghchV
The function will change targets and do everything exactly how I want, the problem I'm trying to solve is how to either cancel a camCommit or get camCommitted _cam to only look at the last camCommit command all without destroying the camera and recreating it.
You can't cancel camCommit (or camCommitPrepared ) except by overwriting the camera and committing again. Same should apply to camCommitted, but I have no idea how this reacts with camCommitPrepared (which obviously takes all prepared stuff in account).
That's what I figured, just curious if someone may have had a workaround.
Hi, so I'm trying to set up the SimpleShops script (adds money and shops) for Zeus compability, and I'm stuck on trying to make it affect every unit on the map so that the Zeus can spawn AI enemies and players can kill them for money. I'm going off of this page on the SimpleShops github (https://github.com/Ppgtjmad/SimpleShops/wiki/Kill-Rewards) where it says to call a function "[this] call HG_fnc_aiUnitSetup;" from a map editor unit's init box, but I need to extend this to work on all newly spawned units since it'll be for Zeus.
I have a thread going on the Bohemia forum (https://forums.bohemia.net/forums/topic/230885-calling-a-function-on-all-units-on-the-map/) to try to get this working using a repeating trigger that encompasses the whole map, but so far I haven't had any luck.
it also can only run once on each unit, because if the function is called more than once on a unit the cash rewards stack so the longer the unit's alive the more money you'll get. so this is the code in the trigger that I'm trying to get working:
`{
if(!(_x getVariable ["aiSetupDone",false])) then
{
_x call HG_fnc_aiUnitSetupο»Ώο»Ώ;
_x setVariable ["aiSetupDone",true];
};
} forEach thislist;`
Firstly: I suspect it's not a great idea to use a map-wide trigger. It's an innovative solution, sure, but I suspect it would absolutely hammer performance.
Secondly: Try this for placed units. This is fired whenever Zeus puts down a unit or a group, and should be perfect for running that code on them:
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#CuratorObjectPlaced
Bear in mind that only applies to placed objects in Zeus, not existing ones on the map.
Thirdly: make sure you run HG_fnc_aiUnitSetup on the server. Yes. It's filed under the client folder for some reason. But it'll only work on the server.
Fourthly: If you want to apply a function to all units, try something like:
allUnits select {side _x == east}
@undone dew
Not sure you were getting the semicolon error on the forums though. Could be you need a space between if and the first bracket? Pure speculation though.
thanks, i'll check that out tonight
@cold glacier I think that might be a perfect solution, but where should I add the eventhandler for it to work? would putting it in my init.sqf do the trick?
I am trying to use the command addMagazineTurret to add magazine to an empty mortar/artillery piece but it is not doing anything, am I using the wrong command or doing something wrong?
D1 addMagazineTurret ["ML700_M_32Rnd_260mm_Scattershot",[0,31]];
Also is there any script or command that forces the AI to reload?
reload maybe
Hey, can someone point me in the right direction for setting up a "lout out" screen before the mission starts?
I've seen it done on a few missions, you get an arsenal screen before the mission deploys.
@winter rose works on units, not vehicles
Unless I am doing something wrong, which is very possible
Vehicle weapons reload only when empty I think
you can add a full mag, remove/add weapon - it should do the job
A'ighty will try
is there a built-in function to pass a number like 10000 and it returns "10 000" ?
none I know, but it is doable
isnt that what https://community.bistudio.com/wiki/BIS_fnc_numberText is for?
eey thank you π
Is there a script that I can use to delete all objects/units in a radios of a point without having to have a delete command for every single object?
nope, but you can deleteVehicle forEach
Oki doki, thanks
Heya everyone, is there a script that changes spawned units from Independent to OPFOR?
For example: We have the Project OPFOR mod with the Iranian Army, and I want them to be OPFOR (Red guys) instead of Independent, but only the Iranian Army
If you can use createUnit or such, you can use the desired side's group via createGroup, that'll help, maybe
Hello, is it possible to insert buttons in the listBox? I need to insert 2 buttons on the right and left (- and +)
Just like Arsenal?
Yep
How about to use ListNBox?
Can I change the text from < > to + and - ?
ok thanks
I have a position, and I have a 3D vector from that position. I want to find the coordinates of a point x metres from that position, along that 3D vector. How would I do this?
vectorNormalized and vectorMultiply?
And that would return a usable world position?
well, yes
sorry, I'm just having a lot of trouble getting my head around this
I think there may be multiple problems, too, which isn't helping
private _oneMeter = vectorNormalized _vectorDirection;
private _threeMeters = _vectorDirection vectorMultiply 3;
startPos vectorAdd _threeMeters;
```π
What I'm trying to do is force a searchlight turret (the GM one) to look at the same place the player (a vehicle gunner) is aiming at (well, a point 600m in the direction the barrel is pointing).
I have:
// this bit works, verified by other means
_dir_gun = [_veh_armed selectionPosition _veh_turr_beg,_veh_armed selectionPosition _veh_turr_end] call BIS_fnc_vectorFromXToY;
// ???
_normgun = (vectorNormalized _dir_gun) vectorMultiply 600;
_lightTarget = (_veh_armed selectionPosition _veh_turr_beg) vectorAdd _normgun;
if (_veh_armed in [vehNATO_IFV1]) then {
[unitNATO_SL1,_lightTarget] remoteExec ["doWatch",unitNATO_SL1];
[unitNATO_SL1,_lightTarget] remoteExec ["lookAt",unitNATO_SL1];
End result: the spotlight doesn't move, and I can't tell why
so...I need to run it through modelToWorld or something first?
if you want to watch 600m away, the position can be the vehicle itself, it wouldn't matter that much, right? π€
....I....maybe? I don't know.
I think I want to try to reduce parallax as much as possible, because the searchlight turret and gun turret are a bit offset, and the player will want to also aim at things that are closer than the 600m convergence point
the more I look at this problem the less my head works, so...
don't look at it!
I added:
_lightTarget = (_veh_armed modelToWorld (_veh_armed selectionPosition _veh_turr_beg)) vectorAdd _normgun;```
the searchlight still doesn't move. If the vector/position is wrong, it should still move but the aim point would just be wildly wrong, right? So if it's not moving maybe the problem is also with some kind of refusal to behave on the part of the searchlight AI
Create some object at the destination position so you can debug visually
it seems that not only is the vector still wrong, it is moving with the gun direction as expected but the searchlight isn't following it
Here's the relevant mission parts, as I have them now, separated out into a VR mission (requires GM) https://drive.google.com/file/d/1R9YKMpvHTEEmBXZNSsBe1ksvcatDXudc/view?usp=sharing
it's based on ALIAS' searchlight script (https://www.armaholic.com/page.php?id=31779), but I realised that that was a bit too hacky and not quite effective enough for my mission needs, and long story short now I'm here with something that's even more hacky and also doesn't work properly
@hallow mortar First of all, what are _veh_turr_beg and _veh_turr_end?
second of all, the resulting direction vector is in model space. I don't know what you're trying to do with it
You said you wanted to specify a position for the AI to watch?
Try this
_dir_gun = _veh_armed vectorModelToWorld ((_veh_armed selectionPosition _veh_turr_beg) vectorFromTo (_veh_armed selectionPosition _veh_turr_end));
// ???
_normgun = _dir_gun vectorMultiply 600;
_lightTarget = (_veh_armed modelToWorld (_veh_armed selectionPosition _veh_turr_beg)) vectorAdd _normgun;
if (_veh_armed in [vehNATO_IFV1]) then {
[unitNATO_SL1,_lightTarget] remoteExec ["doWatch",unitNATO_SL1];
[unitNATO_SL1,_lightTarget] remoteExec ["lookAt",unitNATO_SL1];
}
This should work
Test it
First of all, what are _veh_turr_beg and _veh_turr_end?
Config selections on the vehicle model. That part is retained from the original script and does work.
Ok. I think I got it right then
as far as I can tell, the debug objects are now being created almost (but not quite) directly behind the player's aim....and the searchlight still doesn't move
To summarise (and I do recommend checking the example mission, I think it will help):
- player M113 with a searchlight turret strapped to it
- the searchlight should aim at the same position, approximately, as the vehicle's gun is pointing
- this is a hack to get around the inability to simply spawn a searchlight light cone and directly attach it to the gun
so try this
//_dir_gun = _veh_armed vectorModelToWorld ((_veh_armed selectionPosition _veh_turr_beg) vectorFromTo (_veh_armed selectionPosition _veh_turr_end));
// ???
_normgun = getCameraViewDirection gunner _veh_armed vectorMultiply 600;
_lightTarget = (_veh_armed modelToWorld (_veh_armed selectionPosition _veh_turr_beg)) vectorAdd _normgun;
if (_veh_armed in [vehNATO_IFV1]) then {
[unitNATO_SL1,_lightTarget] remoteExec ["doWatch",unitNATO_SL1];
[unitNATO_SL1,_lightTarget] remoteExec ["lookAt",unitNATO_SL1];
}
I don't want it to be affected by free look. And that might break if the gunner gets out.
so try this
//_dir_gun = _veh_armed vectorModelToWorld ((_veh_armed selectionPosition _veh_turr_beg) vectorFromTo (_veh_armed selectionPosition _veh_turr_end));
// ???
_normgun = (gunner _veh_armed weaponDirection "") vectorMultiply 600;
_lightTarget = (_veh_armed modelToWorld (_veh_armed selectionPosition _veh_turr_beg)) vectorAdd _normgun;
if (_veh_armed in [vehNATO_IFV1]) then {
[unitNATO_SL1,_lightTarget] remoteExec ["doWatch",unitNATO_SL1];
[unitNATO_SL1,_lightTarget] remoteExec ["lookAt",unitNATO_SL1];
}
if you have specified your _veh_turr_beg and _veh_turr_end correctly, it should've worked with the first code. If it was reversed, reverse the vectors
_dir_gun = _veh_armed vectorModelToWorld ((_veh_armed selectionPosition _veh_turr_beg) vectorFromTo (_veh_armed selectionPosition _veh_turr_end));
// ???
_normgun = _dir_gun vectorMultiply -600;
_lightTarget = (_veh_armed modelToWorld (_veh_armed selectionPosition _veh_turr_beg)) vectorAdd _normgun;
if (_veh_armed in [vehNATO_IFV1]) then {
[unitNATO_SL1,_lightTarget] remoteExec ["doWatch",unitNATO_SL1];
[unitNATO_SL1,_lightTarget] remoteExec ["lookAt",unitNATO_SL1];
}
Maybe this will work? (I just reversed the vector)
if you have specified your _veh_turr_beg and _veh_turr_end correctly
They appear to be correct. Like I said, this was part of the original searchlight script from ALIAS and worked correctly in that context, where it was used for...approximately the same thing
What about the new code? You said the target was "behind" you now right? So it must've been a reversed vector.
I mean, I guess, I just don't see how that could have happened.
switching to weaponDirection now has the correct position. I'm just left with the problem of the searchlight not moving.
Does the searchlight have an AI?
Yes. The AI is set to:
Hide model
Do not allow damage
Careless
Forced Hold Fire```
Also, by strapped to, do you mean attachedTo?
Yes
That's a little odd, because I've attached static weapons to other vehicles before and been perfectly able to use the gun
Try detaching the searchlight, see if it works
Detached; no change.
I think what I said is only true about men (I'm sure if you attach a unit to another object, they cant rotate)
Ok I was wrong about that
turrets can rotate, not objects
Can the spotlight even watch a direction normally?
a guy can aim left/right if he has a deadzone
Like spotLight doWatch player
a guy can aim left/right if he has a deadzone
Yeah, I realized it later
a spotlight should doTarget I believe
hi guys,
sorry for interrupting, is there a function or command that add an item in the inventory that has 0 (noSlot) as type ?
addItem?
already tried, it doesn't work
Now let me ask a question:
Does anyone know where you can get the list of all commands and their syntax in the game?
Basically, I want to know where the debug console autoComplete feature gets those parameters from.
Like:
createVehicle [type, position, ...]
the wiki?
utils 5 iirc
Mondkalb 27/05/2019
a addWeaponTurret ["fakeweapon", [0]];
a dowatch playerdoWatch doesnt work normally because the AI needs some weapon assigned to the turret. Adding a fakeWeapon enables this.
I would like to purchase a larger screaming emoji to properly convey my state of mind
no accessible commands Config as far as I know
There should be something...
When you get an autocomplete hint, and press F1, you get a dialog that shows you the command, plus a description
I know that
Most of the time, dialogs are filled by functions...
but you don't want to reverse-engineer anything π
it's somewhere, but not in config
Yeah. I was hoping I could find a function or something
I already did with utils 5
I've added the SEARCHLIGHT weapon to the Searchlight and now the AI can use doWatch properly. Problem solved!
yes, I assume it's used by the Hellcat turret in vanilla. When I saw it earlier I figured it was just for the UI or a remnant of an older system, but now I know why it's actually needed.
It's mildly aggravating that GM searchlights don't have it by default, but that's not a scripting problem.
@torpid quartz Try:
this addAction ["Full Heal", { [player, player] call ace_medical_treatment_fnc_fullHeal; }];
so i was trying to make a medical/healing tent... i used this and it works perfect.
I was wondering if there is a way to alter it so it heals people if they are carried or dragged into the tent?
Use a trigger.
if i spawn Item_money on the ground using createvehicle
pick it up
backpackitems returns "money"
a string
doing it again now
It returns an array (?!)
well yes.. an array of strings rather than an aray of classnames

ok.. spawned "Item_SmartPhone"
on the ground
pick it up, in the inv screen, drag it to my backpack
baclpackitems player returns
["MineDetector","Binocular","SmartPhone"]
this is to do with groundweaponholders and stuff isn't it?
It's because it was a "vehicle" (object) before
yeah
Now it's an item (probably a mag)
yes, an item
i wanted to get classnames of the contents of a backpack
--- lokking in the config
its not displayname
no
It's the classname of the mag
isClass (configFile >> "cfgMagazines" >> "smartphone")
Return true
yes, i see that now
configfile >> "CfgVehicles" >> "Item_SmartPhone" >> "TransportItems" >> "SmartPhone" >> "name"
Exactly
returns the text
Remove everything after smartphone
yes
It should be:
"true" configClasses (configfile >> "CfgVehicles" >> "Item_SmartPhone" >> "TransportItems")
I'm not sure if you can do the reverse (get vehicle className from mag)
its not a problem, i can workaround, thanks for help
no problem
what does thonk mean? was dedmen talking to us?
He was confused by what you wrote
hes not the only one lol
well yes.. an array of strings rather than an aray of classnames
ah yes
It was classnames
ive had some beer
the text backpackitems returns is basically the classname minus the characters "Item_"
so I can take that text, add "Item_" to the front of it and get the classname back
not always true
it is for the items im using
ok
ive checked
But if you use mods it wont be
good point, though I'm only using items and I'll only be using vanilla ones at that
Item_AntimalaricumVaccine
Item_ChemicalDetector_01_watch_F
Item_SecretFiles
Item_FlashDisk
Item_Keys
Item_Laptop_closed
Item_SmartPhone
Item_Money
Item_SatPhone
Item_C_UavTerminal
players have to ninja into an enemy town and deliver one of these
Anyhoo, thanks @little raptor , you're a gent π
Does anyone know if it's possible to get a list of files in the mission path?
i was convinced killzonekid had done something similar but can't find it
It might be possible with extensions, but I was trying to avoid that
there are commands to list files
there will be
not sure if they work right for missions tho
In 2.0?
ye
great
mmmm
addonFiles or what its called
i was looking at that just now
Yeah I know that one
addonFiles [""] or addonFiles [getMissionPath ""] dont work (for missions)
just to be sure I'm not going insane, this:
!(o_tower1 getVariable [""stage2"",false])
should return true if the variable stage2 is false or undefined, right?
To Dedmen
I know, I thought you meant it works!
Why two "?
It's wrong
You can even see it!
it's in a holdAction condition which is passed as a string, so I have to escape the quotes
so I'm trying to get a unit (M1) to fire on the location of a trigger (arty1) via a mortar but he won't fire off any rounds
M1 doArtilleryFire [position arty1, "8Rnd_82mm_Mo_shells", 8];
Try using inRangeOfArtillery to make sure the unit can hit that target
Its saying false when the default range is set to short
Not sure, but it's on Release Candidate branch and Dev branch if you want to test @ebon citrus
is there anyway to make particle effect come out smoothly not pop up??
Put an element with 0 alpha to the color section
@daring sentinel Show me your current ParticleArray BTW
And what do you mean by pop up?
it just pop out instantly
looks doesn't like blow by the wind
It doesn't seem so
πΆ ??
Because I just tested
I want to make dust effect under the Jets
and I did it
but it looks not good enough for me
like this
My test never behaves like that. Show me your entire script
No. Because you literally throw me the wrong script to investigate
I changed every 0.12 alpha to 0.0 at every particle effects' color's first element, and works fine
are artillery shells actual objects when they are fired? Like I can try to see if a fired shell enters a trigger zone?
Yes
https://youtu.be/ph1mm2KKSv0?t=478
Enjoy the Jay's beautiful voice, with the great artillery shell's journey
Welcome to 33 Things About Arma 3!
http://www.arma3.com/
Exploring the gameβs core components, such as the 270 kmΒ² terrain, its selection of weapons and vehicles, and the in-game scenario editor, this video also takes a closer look at some of the more hidden details, such as ...
hey, I found this script to spawn a group in a random spot around a map editor marker, but I'm getting "Error Zero Divisor" when I try to implement it. I've got a map marker called zuluMarker and am calling the .sqf with a trigger.
zuluDefense.sqf:
`_spawnCenter = getmarkerpos "zuluMarker";
_radiusX = 100;
_radiusY = 100;
_randomX = random _radiusX;
_randomY = random _radiusY;
_randomPositionSelect = random 9;
if (_randomPositionSelect >= 5) then {_randomX = _randomX; _randomY = _randomY}else {_randomX = _randomX - (2*_randomX); _randomY = _randomY- (2*_randomY);};
_spawnPos = [_spawnCenter select 0 + _randomX , _spawnCenter select 1 + _randomY, _spawnCenter select 2];
_group = [_spawnPos, EAST, "NVA_68heavyweaponsquad1"] call bis_fnc_spawnGroup;
_waypoint = [_group, _spawnCenter] call BIS_fnc_taskAttack;`
The error is:
_spawnPos = [_spawnCenter |#|select 0 + _randomX, _spawnCenter selec... Error Zero divisor
thats a precedence issue. it is basically reading that element as _spawnCenter select (0 + _randomX).
change the line to _spawnPos = [_spawnCenter#0 + _randomX , _spawnCenter#1 + _randomY, _spawnCenter#2];
or wrap your selects like this _spawnPos = [(_spawnCenter select 0) + _randomX , (_spawnCenter select 1) + _randomY, _spawnCenter select 2];
so I'm trying to make these newly spawned units editable by Zeus, I've added this line at the end curatorMod addCuratorEditableObjects [[_group],true]; (with the Zeus game master module named curatorMod) but I'm getting Error Type Group, expected Object. How do I refer to the curator object properly?
(https://community.bistudio.com/wiki/addCuratorEditableObjects)
is it that _group shouldn't have the extra [ ]? I tried without already but it didn't work either, I just added it since they do so on the wiki page
You need an array of objects
curatorMod addCuratorEditableObjects [units _group,true];
ohh I see what you mean now
yea cause the wiki says units "returns an array with all the units in the group or group of the unit"
so that would be sense if it's looking for that array.. man this stuff gets so complicated xD
You will get better at it, don't worry
hey, I'm getting better already. I just figured out how to add a function to each of the units as well (that makes it so players earn the kill reward from SimpleShop's exp/money system)
{_x call HG_fnc_aiUnitSetup} forEach units _group;
I'll call this a success for tonight, I got everything set up how I want it, thanks a ton guys
Any eta on 2.0 yet?
yes, but not for you muhahahahahahahaha
I actually never tried, does someone know if an exitWith will simply leave the then-block it is in, or one level above? e.g
if (alive player) then
{
if (damage player == 0) exitWith {};
};
// will it continue here?
think it will simply leave the then scope, because I had to do _exit = true inside the exitWith{} then check for _exit value in some scripts
thanks - I will test it soon, will let you know
I'll give it a try rn :p
systemChat "0";
if (alive player) then
{
systemChat "1";
if (damage player == 0) exitWith {};
systemChat "2";
};
systemChat "3";
// displays 0, 1, 3
if (true) then {
if (alive player) then {
if (damage player == 0) exitWith {};
systemChat "foo"; //doesnt show
};
systemChat "bar"; //shows up
};
hey how do I make it so when a player kills someone it executes this script
life_cur_task setSimpleTaskDescription [format ["You have killed a player"],"Kill",""];
life_cur_task setTaskState "Assigned";
player setCurrentTask life_cur_task;```
add a "Killed" event handler π
yeah i looked into it but i dont understand how too
the wiki explains it all
to the init.sqf?
wherever - this kind of question is best asked on the L*fe Discord
why the l*fe_ variables then?
probably thought all script variables have to be prefixed with life_ to work
hahaha
so i just remove life_
cur_task = player createSimpleTask [format ["Kill"];
cur_task setSimpleTaskDescription [format ["You have killed a player"],"Kill",""];
cur_task setTaskState "Assigned";
player setCurrentTask life_cur_task;
so would i put this in a script
and then on the init say
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
}];
bro arma confusing as fuck someone please help
Is there any way to force vanilla AN/MPQ-105 radar to scan horizon (rotate the radar block)?
what do you want to achieve?
you could disable its simulation, or place it empty
params ["_unit", "_killer", "_instigator", "_useEffects"];
}];
cur_task = _instigator createSimpleTask [format ["Kill"];
cur_task setSimpleTaskDescription [format ["You have killed a player"],"Kill",""];
cur_task setTaskState "Assigned";
player setCurrentTask cur_task;```
this is what i ran
in a onPlayerKilled.sqf
then in the init.sqf i called onplayerkilled
i doesnt work
please help me
nevermind, i already found the code on BI forums, in case if anyone need it:
0 = [] spawn {
while {alive radar} do {
{
radar lookAt (radar getRelPos [100, _x]);
sleep 2.45;
} forEach [120, 240, 0];
};
};
https://forums.bohemia.net/forums/topic/218562-neat-little-rotating-radar-script/
what's the difference between an idc and a control?
the wiki isn't exactly clear on that datatype
idc is the id of the control (id-control), scalar, a control is a control
the wiki isn't exactly clear on that datatype
π
idc: Number
ctrl: Control
you can click on types to get a definition π
What did you expected? 
but no seriously, the idc is an idc of a ui component, what value is control?
as in idc is defined in an hpp file as idc=2481859459
What do you mean?
idc is a defined number in an hpp file
how do you refer to a control? Is it the name of the UI class or?
_ctrl = _display displayCtrl _idc
So basically you shouldn't have the same idc for more than two controls
I figured that out yes
its the most obvious part of this
the part i was confused about is how do you get a control instead of the idc
that answers it ty
is it possible to store code in a listbox?
Use lbSetData
problem is, it's string
I'd need to store some variables in it aswell
which i'm not sure if its possible
Just need to compile it
What?
i'd guess not because it doesn't make sense
call compile "smth = 1;"; will make smth 1
"[45, 71] call function"
"[_variable, 71] call function"
this i what I mean, how would I go around doing this? @warm hedge
What is _variable?
its just an example
what I need to do is put a variable in a string
thats the problem
Not sure what you wanted to achieve
Just trying to proofing concept, is there any EH to get if an object's parent has changed? The thing I wanted to do is, check if a backpack (which is a vehicle)'s owner has changed (= detects if an unit has picked up/dropped), and add the EH to the backpack, not an unit
Looking for some assistance, wanting to create a script for a Milsim where players can go up to an object and use the scroll menu to select a kit from the available options, I have folders with the kits already made but unsure of how to set up an object with the loadout list.
The loadouts are exported from the Virtual Arsenal and are all put into a main "Loadouts" folder to go into the mission file for the server.
https://community.bistudio.com/wiki/addAction
https://community.bistudio.com/wiki/setUnitLoadout
i think these 2 should help you out
@warm hedge Nope. You might be able to use put/take event handlers (but it requires adding this to all units, and I'm not sure if it triggers if you use addBackpack)
Hmm, thanks
Can anybody assist me with getting textures to display on a Rugged Large Screen?
So I am able to get the textures to display and show up on the screens... only if I have the image placed in the editor on a photo first. Without a photo of these textures, it simply won't render. Whether it be via the init.sqf or the object's init itself. Do they have to be "cached" first or something? I am grabbing the images from an images folder inside the mission's root
I'm not sure, but maybe try:
getMissionPath "myfolder\myimage.paa"
To get the texture
Ok I will give that a shot and see, thanks.
@rain mural If it's in the mission root, it's simply:
getMissionPath "myimage.paa"
It is in a sub-folder. I think that worked. I am going to try it for the other 3 images quick and see
Ok I think that solved it. Thank you π
np
Need helo
Help
I have followed a tutorial on adding a script that would spawn a random injured person however I don't know where I should be putting the the SQF file
Its to be used I'm multiplayer
And I cannt find the answer anywhere
It's hard to say without seeing the script. There's no universal "this is where you put scripts that spawn random injured persons" answer.
@neon wind usually the main directory of where the mission is saved
Iit keeps saying not found script folder or summit about bios
I'll screen shot it in a bit
Just about to eat
Doing my head in haha
send a screenshot of it then mate
Will do give me a a bit Sunday dinner time
anyways, how would go about using the define macro for IDCs?
I've tried doing it in the description.ext file, however they still get identified as unknown variables
use a macro parameter
@winter rose ^what i said second
and also is it possible to use the macros themselves in code?
instead of the idc values themselves
@tough abyss
and also is it possible to use the macros themselves in code?
Yes.
Where do you even put the defines?
defines file i used for the gui control types and shit
so I have the menu popping up via scroll menu but when used it doesn't give the loadout, anyone know how to fix it?
Init:
this addAction ["Officer Commanding", {"/PWRR-Loadouts/Blue-Tiger/PWRR-BT-Coy-OC.sqf"}];
@knotty kayak Remove the { } (provided everything else is set up correctly)
hello everyone, I am trying to pass along variables to a different SQF but get a return value as error in expression and error position, would anyone know what I might be doing wrong here?
here is the RTP error
10:14:31 Error in expression <t ("Stress = " + (str _stress));
_nil = [_lowerstress, _stress, _maxstress] ca>
10:14:31 Error position: <= [_lowerstress, _stress, _maxstress] ca>
10:14:31 Error Generic error in expression
SQF
// Compile
cheif_stressCheck = compileFinal preprocessFileLineNumbers "APT_Adapt\stress.sqf";
//Parameters list
isMusicActive = 1;
debugging = 1;
//Stress modes
//stress represents min and will be main changer
private _stress = 0;
private _maxstress = 100;
//How much is lowered each second.
private _lowerstress = -1;
private "_nil";
//Every second
while{true} do
{//Main Loop
if(isMusicActive isEqualTo 1) then
{
//debug - show stress
hint ("Stress = " + (str _stress));
//lower stress and pass values
_nil = [_lowerstress, _stress, _maxstress] call cheif_stressCheck;
};
sleep 0.2;
};
What is the contents of the other file?
Give me a sec. apparently it is too long for discord
you can use sqfbin
stress.sqf
forgot to remove the old comments from this so excuse the commented sections
_stress is not changing in the current script
Due to params
why do you use uiSleep
It's pointless
i honestly forgot
You've already used the command
it was left over from an old loop i removed
_enemy = ((getPosATL player) nearObjects ["AllVehicles",30]) findIf {
_relation = (side player) getFriend (side _x);
(_relation < 0.6)
} != -1;
Like this
And you don't need all vehicles
DANG MISSED ONE
And last, return _stress in the end to use in the other code
while{true} do
{//Main Loop
if(isMusicActive isEqualTo 1) then
{
//debug - show stress
hint ("Stress = " + (str _stress));
//lower stress and pass values
_stress = [_lowerstress, _stress, _maxstress] call cheif_stressCheck;
};
sleep 0.2;
};
put a _stress in the end of stress.sqf
@little raptor hasn't changed anything removing the {} any ideas?
Is everything else set up properly?
Are you sure the path to your script is correct?
Are you sure the script works?
it should be, testing on a server with the loadouts in the pbo, file paths are correct
does it throw any errors?
No errors, just doesn't do anything
then your script path might not be valid
im not good lol you should post the screenshot to someone else
Oh lol
I just need to know where I'm putting it to be honest
@here anyone able to chat though with me scripts
I'll screen share
@knotty kayak Try:
this addAction ["Officer Commanding", {_this execVM "PWRR-Loadouts/Blue-Tiger/PWRR-BT-Coy-OC.sqf"}];
Let me know what errors you get
@neon wind You can just ask your question here
{if ((typeOf _x == 'b_survivor_F') && (!isPlayer _x)) then {deleteVehicle _x}} forEach allUnits;
[MedicalData,3] call BIS_fnc_dataTerminalAnimate; //activates the animation for opening the terminal.
sleep 5;
_group1=createGroup west;
'b_survivor_F' createUnit [getmarkerPos 'Patient1', _group1,'pat1=this; dostop pat1'];
[pat1, selectRandom[0.3,0.5,0.7,0.9], "leg_r", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "leg_l", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "body", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "head", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "hand_r", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "hand_l", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1] call ace_medical_fnc_handleDamage_advancedSetDamage;
[MedicalData,0] call BIS_fnc_dataTerminalAnimate; //activates the animation for closing the terminal.
hint 'Your patient is ready';
//the first selctrandom chooses a random damage from a small one to a large one, the second selectrandom chooses the type of damage.
thats the script but i have no clue why its not working
is there a way to detect if its raining or not?
@little raptor no errors but still not working
@smoky verge overcast > 0.7 && rain > 0 I believe
oh thanks
@little raptor I believe this is what you meant?
Parameters.sqf https://pastebin.com/hKgHK1qc
Stress.sqf https://pastebin.com/Cg5AhFS9
Still gettting the same error
14:43:52 Error in expression <"Stress = " + (str _stress));
_stress = [_lowerstress, _stress, _maxstress] ca>
14:43:52 Error position: <= [_lowerstress, _stress, _maxstress] ca>
14:43:52 Error Generic error in expression
That is the whole error? nothing else?
that is the whole error
what is in "cheif_stressCheck"
ah nvm
cheif_stressCheck never returns anything
you are assigning the result of cheif_stressCheck to _stress
but cheif_stressCheck doesn't have any result
put
_stress at the end of Stress.sqf, into the last line
so just put _stress at the very end
Yes, and that's also what @little raptor already told you
put a
_stressin the end ofstress.sqf
i didn't understand what that ment exactly at the time
wow, that actually fixed it. I guess I have to remember to return the value now on the next portion
thanks @little raptor @still forum
How do I get the reveal function to constantly update the known position of a unit?
I'm trying to make a mission where I constantly have to outrun an enemy vehicle in a high-speed chase
loop it
I tried that on a trigger (should repeat every 0.5s, yeah?)
aaf forgetTarget fia;
fia forgetTarget aaf;
aaf reveal [fia, 4];
fia reveal [aaf, 4];
no
oh
how did you set up this trigger?
Set up a repeatable trigger and put the above code in On Activat-
oh, i need to set it to actually trigger...
π¬
yup π
Thanks, im just a fool
nope, sometimes more eyes are helpful. google rubber duck debugging π
Oh yeah
Do I need to sleep between these commands, since it still doesn't work how i'm expecting it to
Since in Spectator, it shows that known position of the unit doesnt change
note to self.. dont misspell Lou's google search suggestion
@keen folio no sleep possible in triggers
Oh, hecc
you could have a trigger that trigger once (or better, a script)
and have```sqf
while { sleep 1; alive aaf && alive fia } do
{
aaf reveal [fia, 4];
fia reveal [aaf, 4];
};
Ohhh that makes sense
hey guys, I'm trying to adapt the script I got help with yesterday to spawn vehicles as well as infantry. It's spawning the vehicle fine, but I'm getting an error on the last two lines because of "units _group3", which works on infantry but not on a vehicle. I'm just not sure what to change this to, I tried crew and didn't have any luck.
`_group = [_spawnPos, EAST, (configfile >> "CfgGroups" >> "East" >> "UNSUNG_E_NVA" >> "NVA68Infantry" >> "NVA_68heavyweaponsquad1")] call bis_fnc_spawnGroup;
_waypoint = [_group, _spawnCenter] call BIS_fnc_taskAttack;
curatorMod addCuratorEditableObjects [units _group,true];
{_x call HG_fnc_aiUnitSetup} forEach units _group;`
----This one does not work (yet) check the last two lines where I tried using "crew"
`_group3 = [_spawnVehPos, 293, "uns_Type63_mg", east] call BIS_fnc_spawnVehicle;
_waypoint3 = [_group3, _spawnCenter] call BIS_fnc_taskAttack;
curatorMod addCuratorEditableObjects [crew _group3,true];
{_x call HG_fnc_aiUnitSetup} forEach crew _group3;`
how do I turn something like this [[5072.01,755.634,7.03117]] into something that can be accepted by something that expects three parameters, like this [5072.01,755.634,7.03117]?
[[5072.01,755.634,7.03117]] is a known as a nested array
its an array that contains another array
[5072.01,755.634,7.03117] looks like it is a position array - the position of an object in the game world
[5072.01,755.634,7.03117] select 0
will return 5072.01
it selects the first element of the array (arrays are zero based, the first element is called 0
the second is called 1
so with your original array,
[[5072.01,755.634,7.03117]] select 0
will return
[5072.01,755.634,7.03117]
i see, that is indeed a game world coordinate, thanks
in your case, element zero of your original array is another array
Hi all, I'm trying to get a fired near player script to change the value of _stress for the player. Getting this error on RTP. Any suggestions?
RTP
16:21:17 Error in expression <s"];
_unit = _this select 0;
_unit addEventHandler
["firedNear",
{
_unit = >
16:21:17 Error position: <addEventHandler
["firedNear",
{
_unit = >
16:21:17 Error addeventhandler: Type Number, expected Object
16:21:17 File APT_Adapt\firenear.sqf..., line 10
parameters.sqf
// Compile
APT_stressCheck = compileFinal preprocessFileLineNumbers "APT_Adapt\stress.sqf";
APT_firenearCheck = compileFinal preprocessFileLineNumbers "APT_Adapt\firenear.sqf";
//Parameters list
isMusicActive = 1;
debugging = 1;
//Stress modes
//stress represents min and will be main changer
private _stress = 0;
private _maxstress = 100;
//How much is lowered each second.
private _lowerstress = -1;
private "_nil";
//Every second
while{true} do
{//Main Loop
if(isMusicActive isEqualTo 1) then
{
//debug - show stress
hint ("Stress = " + (str _stress));
//fired near player
_stress = [_stress] call APT_firenearCheck;
//lower stress and pass values
_stress = [_lowerstress, _stress, _maxstress] call APT_stressCheck;
};
sleep 0.2;
};
firednear.sqf
//To elivate stress if you are being shot at.
params ["_stress"];
_unit = _this select 0;
_unit addEventHandler
["firedNear",
{
_unit = _this select 0;
if ((_unit getVariable "_stress") < 100) then
{
_unit setVariable ["_stress", (_unit getVariable "_stress") + 1];
}
}
];
_unit addEventHandler
["hit",
{
_unit = _this select 0;
_unit setVariable ["_stress", 100];
}
];
_stress
@ashen warren In this line
//fired near player
_stress = [_stress] call APT_firenearCheck;
you pass the number _stress (which is 0) to the script, which you then try to use here
_unit = _this select 0;
to get a unit. The end result is you attempting to execute ```sqf
0 addEventHandler [...];
ok, I guess im confused on how to correct that
what was unit to begin with?
apparently nothing if i look ait it.
Write
player addEventHandler [...];
Only outside of the Event Handler code.
I also suggest using
_unit getVariable ["_stress", 0]
because right now, that variable should give you errors.
Very dumb question here: My hold action is showing twice in the scrollwheel, I had no success using "isServer" or "hasInterface" yet
We'll need some more context to aid with that.
@willow hound this what you mean?
//To elivate stress if you are being shot at.
params ["_stress"];
_unit = _this select 0;
_unit getVariable ["_stress", 0]
player addEventHandler
["firedNear",
{
_unit = _this select 0;
if ((_unit getVariable "_stress") < 100) then
{
_unit setVariable ["_stress", (_unit getVariable "_stress") + 1];
}
}
];
player addEventHandler
["hit",
{
_unit = _this select 0;
_unit setVariable ["_stress", 100];
}
];
_stress
Yes
ok
@brave jewel
use a variable to avoid that.
Like:
if (_unit getVariable ["MyActionAdded", false]) exitWith {};
_unit addAction [...];
_unit setVariable ["MyActionAdded", true, true];
In general you should be careful where you execute your code. If you don't know how, just use this for now.
I also suggest using
_unit getVariable ["_stress", 0]because right now, that variable should give you errors.
Don't forget this or you'll probably get different errors.
Well I fixed it @little raptor. Seems like I've just been misspelling "hasInterface" 
Still it depends on where you execute your code. hasInterface doesn't necessarily avoid that.
And use an editor with syntax highlighting. That way you won't misspell
Roger Roger
@willow hound it didn't work. I feel like _stress is fighting the other document that manages stress. I feel like I should of merged Firenear.sqf and stress.sqf
RTP
https://pastebin.com/pKMWy99p
Parameters.sqf
https://pastebin.com/ZrWgV0tb
stress.sqf
https://pastebin.com/mjAP2yED
firenear,sqf
https://pastebin.com/pzi1kW5S
Fixing firenear.sqf is easy:
//To elevate stress levels if you are being shot at.
player addEventHandler
["firedNear",
{
_unit = _this select 0;
if ((_unit getVariable ["_stress", 0]) < 100) then
{
_unit setVariable ["_stress", (_unit getVariable ["_stress", 0]) + 1];
};
}
];
player addEventHandler
["hit",
{
_unit = _this select 0;
_unit setVariable ["_stress", 100];
}
];
Fixing the whole system is not so easy, it needs a healthy amount of redesign.
so I don't need to send a return value?
yea, im completly redoing this from scratch with limited knowledge.
hi everyone, is it possible to script loading a vehicle into a vehicle (VIV) by adding an action?
i want to create an action so i dont have to get into the vehicle driver seat
so error is gone but adds +1 every second rather than reacting to fired near
i'll have to look into this
@ashen warren Without trying to offend you, I believe this project is a bit too much for your current level of knowledge. We could spend the night fixing the code until it stops throwing errors but then you will probably discover that the code does not do what you want it to do. I recommend getting more practice with SQF files, functions, scopes and namespaces before revisiting this.
@mortal steppe Try combining the addAction command with the setVehicleCargo command.
cheers il start doing some reading
so im new to running a server and the web console says theres a cfg error after i added a custom difficulty script to it. can someone please help me, i have no idea what im doing here
@willow hound I believe I found the issue. Looking over some other projects of mine that worked before, don't like how it operates cause its not as optimized but I think it will do the trick. I appreceiate your assistance as much as you have provided
@restive shadow try asking with a formatted config in #server_admins π
will do thank you
lets say you have a flag with the variable flag1 how would you go about creating a new flag with the variable flag2 etc etc if the previous exists?
trying to figure out some sort of rally system that you can spawn additional flags for different squads and delete the previous ones, all in one script
something like this perhaps. in this example you might have up to 10 flags
private _prefix = "flag";
for "_i" from 1 to 10 do {
private _var = _prefix + str _i;
if (isNil _var) exitWith {missionNamespace setVariable [_var,_flagObj]};
};
another way that removes the loop
// _flags = array of flag objects
private _index = _flags pushback _flagObj;
missionNamespace setVariable ["flag" + str _index,_flagObj];
if it is in an array you probably wouldnt need the individual variable though.
can do it a few ways.
well I have 3 flags at base which are the base of the teleport script. flagA,flagB,flagC which I can then plug into the script... this is what I have so far...
params ["_squadLeader","_initalFlag"];
if (isNil "rallyTimer" || {!rallyTimer}) then {
if (isNil ("flag" + str _initalFlag)) then {
private _rallyFlag = createVehicle ["flagClassName",_squadLeader,[],5,"NONE"];
missionNamespace setVariable ["flag" + str _initialFlag,_rallyFlag];
};
};
rallyTimer = [60,false] call BIS_fnc_countdown;
basically I hope this makes a variable of flagAlpha, flagBravo, flagCharlie, so the rally script can keep track of them all individually without me having to write a new script for every single base flag.
the above would be on a addaction for a SL
how do I turn the total amount of listbox entries into an index array? Something like lbSelection but for every row of a listbox?
!rallyTimer || isNil "rallyTimer" should be isNil "rallyTimer" || {!rallyTimer} otherwise it will error on the first condition when rallyTImer is nil
lbSize just gives a number of how many
like this?
private _sel = [];
for "_i" from 0 to lbSize _ctrlListBox - 1 do {
_sel pushback _i;
};
ye thats it thank you man
@fair drum !rallyTimer needs the {} around it so it doesnt evaluate if it is nil.
@robust hollow One more question, how do i get the value off of an editable textbox?
ctrlText _ctrlTextBox
ty
@fair drum as for the rest of the script the only issue i see is you use rallyTimer as a bool in the if statement, but that usage of bis_fnc_countdown returns a number (i think)
Is there a way to check who placed a UAV?
I tried owner but it returns 0 for UAVs I placed and also UAVs teammates placed.
I don't immediately see an event handler I can use to assign it myself.
I saw that but wasn't sure.
Thanks. I'll give it a whirl and post back.
Sure wish I could just check it live, though...
Wishful thinking, I know.
player addEventHandler [
"WeaponAssembled",
{
params ["_unit","_assembled"];
if (typeOf _assembled == "UAVClassHere") then {
blah blah blah
};
}
]
@robust hollow
and if I wanted to delete the previous flag, would I use getVariable in this way?
params ["_squadLeader","_initalFlag"];
if (isNil ("flag" + str _initalFlag) || placeAgain) then {
placeAgain = false;
private _oldFlag = missionNamespace getVariable ["flag" + str _initalFlag,objNull];
deleteVehicle _oldFlag;
private _rallyFlag = createVehicle ["Flag_AAF_F",_squadLeader,[],5,"NONE"];
missionNamespace setVariable ["flag" + str _initialFlag,_rallyFlag];
private _time = time + 60
waitUntil { time >= _time };
placeAgain = true;
};
I got it working. UAVs are now deleted per player upon respawn. Thank you, @fair drum.
@fair drum yes that is correct
you'd just need to make sure placeAgain is defined somewhere before evaluating it in the if statement, or use getvariable to define true as default. it will most likely error if nil.
yeah i typically do a preinit function of all the t/f variables I end up using
Is it possible to have a mission function that runs on init on every man unit? I only did something like that a couple of times in a mod using configs and Extended_InitPost_EventHandlers.
Would it be possible to add an init function to all units using description.ext or something? I'm not familiar at all with using description.ext for stuff like that
@thorn saffron
//Place in your init.sqf
{
if (_x isKindOf "Man") then {
[] call yourfunctionhere;
};
} forEach allUnits;
CAManBase* no? I don't remember why but it's "closer" to soldiers, and "Man" could return some unwanted things
Where would I have to put the command finishMissionInit for it to work and also what exactly does it do, what are the benefits?
Hi all so I managed to get the script working but need some advice is there way to edit this script so it edit a type of AI id spawned example a Civilian
@neon wind ```sqf please (see pinned message)
@fair drum Not gonna work for what I want. I have units getting spawned during the mission. What you posted will only run once at start
that is why I want something that runs on init of every man, that spawns during the mission
@thorn saffron - If they're Zeus'd in, you can hook into the CuratorObjectPlaced event handler.
If they're spawned by your code in your mission, you can create a custom function that spawns a unit, then runs the initialisation you want.
If they're spawned by someone else's code, you need an infinite loop that checks all the units, and inits any that haven't been initialised, then marks them as initialised so they get ignore on the next loop.
Because Arma doesn't have an 'Object spawned' event handler, tragically.
I was suggested to use this:
// init.sqf
["CAManBase", "Init", {systemChat str _this}, true, [], true] call CBA_fnc_addClassEventHandler;
Need help with this script. It spawns a casualty with random injury/injuries. How do I have it so the casualty is a set model. For example a Civilian
{if ((typeOf _x == 'b_survivor_F') && (!isPlayer _x)) then {deleteVehicle _x}} forEach allUnits;
[MedicalData,3] call BIS_fnc_dataTerminalAnimate; Β //activates the animation for opening the terminal.
sleep 5;
_group1=createGroup west;
'b_survivor_F' createUnit [getmarkerPos 'Patient1', _group1,'pat1=this; dostop pat1'];
[pat1, selectRandom[0.3,0.5,0.7,0.9], "leg_r", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "leg_l", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "body", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "head", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "hand_r", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1, selectRandom[0.3,0.5,0.7,0.9], "hand_l", selectrandom ["stab","bullet","falling"]] call ace_medical_fnc_addDamageToUnit;
[pat1] call ace_medical_fnc_handleDamage_advancedSetDamage;
[MedicalData,0] call BIS_fnc_dataTerminalAnimate; Β //activates the animation for closing the terminal.
hint 'Your patient is ready';
//the first selctrandom chooses a random damage from a small one to a large one, the second selectrandom chooses the type of damage.```
which command should I use to kick a player from the server (i.e he's afk too muchtime)
@compact maple https://community.bistudio.com/wiki/serverCommand serverCommand #kick
@neon wind change B_survivor_F to the class you want. also, try formatting with ```sqf thanks
Thanks, seems it has to be executed on the server
everything sensitive should be done server-side yes π
the server is the main referee of the game!
Y Im trying to write sensible things server-side, always.
btw, if the client call the server function to be kicked, isn't it "hackable" ? could he kick someone else by sending false information ?
alright
although, even then, I don't think so
instead of sending the player object to the server, I remember there is a command server-side to get who called the server function, right?
remoteExecutedOwner (or something like that)
thats its, thanks (https://community.bistudio.com/wiki/remoteExecutedOwner)
I got a broblem, the state of a checkbox doesn't change when ticked
do I have to add something to the header file?
@tough abyss what do you mean? the tick mark doesnβt stay?
it does, but when I do
hint str (ctrlChecked UNCONCHECK);
it always returns false
even when ticked
UNCONCHECK is just a macro
(what is the macro you are using?)
there are 2 types of checkboxes you might use wrong command for yours
class cbSetUncon: RscCheckbox
@compact maple
#define UNCONCHECK (MENUDISPLAY displayCtrl IDC_IM_SETUNCON)
what type is it?
what type rsccheckbox is?
you have to use cbChecked with type 77
yep didn't know there was a different function
is there something akin to a return statement in sqf?
so I don't need to put an entire statement within brackets if I want to check a few things before continuing
breakOut may be the closest you can get, along exitWith @tough abyss
hm ok, thank you
is there any way to add to existing params or do I have to redefine each param every time I use params?
@robust brook unsure what you mean?
// This Works
["_testNumberCase"] spawn {
params ["_testNumberCase"];
switch (_testNumberCase) do {
case 1: {
params ["_testNumberCase", "_playerObject"];
};
case 2: {
params ["_testNumberCase", "_vehicleObject"];
};
};
};
// Dosen't work (messes up order of params)
["_testNumberCase"] spawn {
params ["_testNumberCase"];
switch (_testNumberCase) do {
case 1: {
params ["_playerObject"];
};
case 2: {
params ["_vehicleObject"];
};
};
};
@winter rose
but what If I want to have different types of variables being passed through each case?
specific to each case
just wanting to add params to already existing params instead of redefining them all again in each case
// first
params ["_testCase"];
// then
params ["", ["_valueNum", 0, [0]]];
// or
params ["", ["_valueStr", "", [""]]];
or better, make the second variable an array - and use```sqf
params [
["_switchStuff", "", [""]],
"_data"
];
// and then
_data params [/* the formats you want */];
ty
possible to hide all vanilla assets in Arsenal but keep the modules?
Modules?
IDK if this question belongs here, but im curious on mods used by a Specific unit. Their gear (Mostly RHS) all has maxed storage space, allowing for them to look proper but also not be limited on having a full kit. Im just wondering if there is a way to mimic that without completely configing the gear and needing to know how to script it, or if rescripting and posting a unit mod is the only way
Or if one already exists publicly, instead of their private mod, it has RHS backpacks and many other mods
I should make a correction, its not the weight, but the phsyical room in their gear is maxed
ok
Wonder if you can script it to give backpacks infinite capacity. You can definitely overload backpacks with gear using scripts, trick would be hooking it into the inventory UI...
hey guys i have a problem
so basically i have one headquarters entity named DFDD
and i sync it to a trigger
and on the activation pannel i write this
variable1 sideChat "hello there";
sleep 5;
variable1 sideChat "nono not like this"
is this correct?
what is variable1 ?
@tough abyss and don't crosspost π
yeah sorry for that sorry
you cannot use sleep in a trigger directly
0 = [] spawn {
variable1 sideChat "hello there";
sleep 5;
variable1 sideChat "nono not like this"
};
```should do
oh so that's how it is done
trying it now
yes it works like a charm
thank you for this, i'm new in scripting
hi new, I'm dad!
@velvet merlin
possible to hide all vanilla assets in Arsenal but keep the modules?
If you mean Zeus, yes
how do i refer to a player that intered a trigger area? say to make a teleporter or instant kill zone
thisList
Or
list _trigger
Gives all units that have activated the trigger
thisList must be used in trigger statements and not in other scripts
is it an array, do I need to use a for loop to access everything in it?
yes, array
use forEach
got it thanks
Does a serverside Dual-primary script exist?
like not a mod, can it just be done with scripting in a mission file
wat
check out https://github.com/Andrew-S90/DualArms/tree/master/Exile.Altis (which is a mission with Dual Arms script)
Is it viable to place units, setup the variable names, camps, makers, etc and then script an entire mission?
why not?
Do you have as much flexibility with triggers if you are purely scripting?
MUCH more
I guess you'd be using EH mostly.
Ok, awesome. New challenge for myself π
Thanks guys β€οΈ
@warm hedge @little raptor sorry meant Zeus (not Arsenal)
There's attribute "Default addons" in Game Master module which is now set to "Addons present in the scenario".
However when I disable/restrict vanilla content I've noticed that it'll hide all modules from Zeus panel but I have no idea how to add them back.
@karmic spade
Does a serverside Dual-primary script exist?
like not a mod, can it just be done with scripting in a mission file
I think you mean dual primary weapons, as in having two primary weapons where one goes in launcher slot?
If you intend to script it without modding, it requires awkwardattachToandonEachFrameto work, and you'll have to fake the inventory menu to look like you have a 2nd primary weapon there. The alternative method is to create a list of weapon duplicates that go into the launcher slot, which obviously needs a mod.
I don't know about existing scripts. You can google. It's not hard to make one yourself (at least a basic version)
@velvet merlin I recommend a script:
this addEventHandler ["CuratorObjectRegistered", {
_cfgVeh = configFile >> "CfgVehicles";
_this#1 apply {
if (gettext(_cfgVeh >> _x >> "vehicleClass") == "modules") then {[true,0]} else {[false, 0]}
}
}]
You can restrict addons using:
removeAllCuratorAddons _curator;
_curator addCuratorAddons _allowedAddons;
I'm not sure if the removing addons part is needed. I just put it in case
What would be the best way to make the player who launched this script below to appear on screen using %1? Currently this is what i have made up so far, using the method its displaying the player who sees that as their own name, and not the person executing the script. I tried making "name player" private and outside of the bis_fnc_mp but it displayed "any" on other machines other than the person executing it.
[{titleText [format ["<t color='#OAOAOA' size='3'font='RobotoCondensed'>%1 has saved their character!</t>",name player
], "PLAIN DOWN",-1, true, true];
},"BIS_fnc_spawn",true,true] call BIS_fnc_MP;
[
[name player],
{titleText [format ["<t color='#OAOAOA' size='3'font='RobotoCondensed'>%1 has saved their character!</t>",_this#0], "PLAIN DOWN",-1, true, true];}
] remoteExec ["BIS_fnc_spawn",0];
give the unit name as a parameter before remote executing
also use remoteExec instead of BIS_fnc_MP as it is old and obsolete.
i had remote before funny enough but that bis_fnc_mp seemed shorter to remember lol thanks for the help i'ma try it out
i believe the function uses remoteExec in the end. the wiki says it only exists for backwards compatibility.
interesting well thats good they left it in there
but this functions flawlessly, just need to have another player execute it to see it from my end
thanks m8 @robust hollow
so is it _this#0 that's differentiating which player called it?
or is it the name player grabbing it correctly? i guess i'm confused, is that the remoteexec storing it or how does that function exactly for future refrence?
NVM i got it figured out by playing around with it. I was trying to do a secondary %2, i now understand that the first bracket are params or sorts, and i was able to figure it out.
[
[name player, player getVariable ["killstreakcountSTREAK",0]],
{titleText [format ["<t color='#OAOAOA' size='2'font='RobotoCondensed'>%1 has a killstreak of %2</t>",_this#0,_this#1], "PLAIN DOWN",-1, true, true];}
] remoteExec ["BIS_fnc_spawn",0];```
Does anyone know what exactly finishMissionInit does, what the benefits are and where I would have to put the command for it to work?
Also can I use format together with preprocessFileLineNumbers?
BIS_fnc_function = compileFinal preprocessFileLineNumbers format ["functionslibrary\%1\fn_function.sqf", missionName];
Latter, true. The string is just a string
Ok, thanks.
Is it possible that BIS_fnc_typeText2 has a length limit ? For me it looks like that since after a certain message length an error appears
"font/" is not a class ("fonts" accessed)
technically yes on two points. strings are limited to 9,999,999 chars (unlikely you are reaching that), and typeText2 uses format which is limited to output ~8Kb (i believe thats per line in this function). can you share the strings you are trying to use?
if the latter is the case, you can break the string into multiple parts and after modification combine them using joinString.
https://gyazo.com/dae78f51d6c90fa9805d5aa8ba4f8188 @robust hollow
https://gyazo.com/03e30e39e004ae18a3cb05ce9fa9a42b displays like that (no error)
if you add another line with text (like 5-10 more letters it breaks depending on the length of the location name)
probably due to my horrible formating π
That is far from 9,999,999 characters (even with markup), and shouldn't be close to 8Kb (can't remember this limit, but could be). So either there is something wrong with your coding, or something wrong with the BIS function.
there is a lot of XML parsing error... logs when you use this function π€
i just reduced it (HH:MM instead OF HH:MM:SS) "Days alive" instead of "Days survived" and BIS_fnc_trimString for the location name and no error anymore
it is the format limit
after adding all the structured text formatting (which is done for every character) the last line ends on this
...<t color = '#00000000' shadow = '0' align = 'center' size = '0.45' font='PuristaSemibold'>r</t><t color = '#00000000' sha"
and is 8191 characters long
i'd say your options are to have less characters per line, or to duplicate the function and modify it to not use format. or write your own replacement function of course.
should have asked ealier. was debugging for two hours π
the function is really quite unoptimized. it appears to add the attributes you provide on every character individually, instead of the line as a whole. would make much more sense to have it like <t provided attributes + shown char color>abc<t hidden char color>xyz</t></t> or something like that.
Hey is there a really simple script to change the radio communication to carrier pigeons?
hey guys, I'm trying to write a script to add random inventory items to Zeus placed units using the eventhandler "CuratorObjectPlaced". I'm calling the script like so
this addEventHandler ['CuratorObjectPlaced',{ { [_x] remoteExec ["HG_fnc_aiUnitSetup", 2] } forEach crew (_this select 1); {0= [] execVM "randomItem.sqf";} forEach crew (_this select 1); }];
randomItem.sqf:
`private ["_unit", "_items"];
_unit = _this select 0;
_items = ["uns_item_bugjuice","uns_item_bugspray","uns_item_dong", "uns_item_P38", "uns_item_smokes","uns_item_zippo"];
//_pItem = _items select (random (count _items - 1)); example1
//_pItem = _items select floor random count _items; example2
_pItem = selectRandom _items;
_unit addItem _pItem;`
Problem is, I'm getting an error saying _unit is an undefined variable. How do I fix? π¦
[_x] execVM "randomItem.sqf";
you could put that execvm in the same loop as the remoteexec to make it a little cleaner.
also dont need 0=
replace private with params in randomItem.sqf
awesome I think those two things did the trick, gonna test some more
tyvm
also if I want there to be a random chance to find something, would adding some empty "" work for the _items = array?
like
_items = ["uns_item_bugjuice","uns_item_bugspray","uns_item_dong", "uns_item_P38", "uns_item_smokes","uns_item_zippo", "", "", "", ""];
that is one way. another would be to do a percentage check first. eg 70% chance of finding an item
_item = if (random 1 <= 0.7) then {selectRandom _items} else {""};
awesome, it's working great
Hey is there a really simple script to change the radio communication to carrier pigeons?
wat?!
{
_x setObjectTextureGlobal [0,"icon\s1.paa"];
[
_x, // Object the action is attached to
"Scavenger Contract", // Title of the action
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", // Idle icon shown on screen
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unloaddevice_ca.paa",// Progress icon shown on screen
"_this distance _target < 3", // Condition for the action to be shown
"_caller distance _target < 3", // Condition for the action to progress
{}, // Code executed when action starts
{}, // Code executed on every progress tick
{
player playActionNow "PutDown";
[] execVM "ContractSearch.sqf"; // Code executed on completion
deleteVehicle _x;
},
{}, // Code executed on interrupted
[], // Arguments passed to the scripts as _this select 3
1, // Action duration [s]
10, // Priority
false, // Remove on completion
false // Show in unconscious state
] remoteExec ["BIS_fnc_holdActionAdd", 0,_x]; // MP compatible implementation
} forEach [scav1,Scav2,scav3];
Is it possible to just remove the one that has be interact with for example: if i interact with "scav1" it will just delete that one... i dont want to make the same script for each of them just to add the deletevehicle part.
for where you have deleteVehicle _x;? change it to deleteVehicle (_this#0);
_x is not available in the code completed scope
thanks mr connor ...π every thing is possible in arma 3
is # faster than select ?
i dont believe so. it is higher in precedence though, so you can sometimes go without () around it.
as an example
[1] select 0 * 2; // 1
[1] # 0 * 2; // 2
Thank you.
can also work like this ?
[[0]] # 0 # 0 // 0
yes
ok, ty !
sav_id = findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",
{
{
_this select 0 drawIcon
[
MISSION_ROOT + "icon\s.paa",
[1,0.804,0, 1],
getPos _x,
25,
25,
0,
"",
1,
0.05,
"TahomaB",
"right"
]
}forEach [sav1,sav2,sav3];
}];
findDisplay 12 displayCtrl 51 ctrlRemoveEventHandler ["Draw", sav_id];
same concept like the pervious one i dont want it to remover all on the map icons just the one being interact with ...or am i gonna have to make a special id for each??
sav1,sav2,sav3 these are objects?
yeah little tablets
could put a if (!isNull _x) {...} inside the foreach
and the drawicon would go inside the if
each time you'll be drawing, icons will be created ?
sav_id = findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",
{
{
if (!isNull _x) then {_this select 0 drawIcon
[
MISSION_ROOT + "icon\s.paa",
[1,0.804,0, 1],
getPos _x,
25,
25,
0,
"",
1,
0.05,
"TahomaB",
"right"
]}
}forEach [sav1,sav2,sav3];
}];``` tbh im pretty sure it was working, then i reloaded the mission and it wasn't anymore...or maybe im just imagining things
looks correct to me.
@harsh vine is MISSION_ROOT getMissionPath-related?
MISSION_ROOT = call {
private "_arr";
_arr = toArray __FILE__;
_arr resize (count _arr - 8);
toString _arr
};
```guess there is no need for this anymore π
// i would like to get a scatter effect by using this, but if i use this method they all spawn at one location.
randomLocation_mw0 = selectRandom["b1","b2","b3","r1","r2","r3","s4","s5","s6","s7","s1","s2","s3"];//map markers
Sav1 = createVehicle ["Land_Tablet_02_sand_F", getMarkerPos randomLocation_mw0, [], 1, "none"];
sav2 = createVehicle ["Land_Tablet_02_sand_F", getMarkerPos randomLocation_mw0, [], 1, "none"];
sav3 = createVehicle ["Land_Tablet_02_sand_F", getMarkerPos randomLocation_mw0, [], 1, "none"];
```i knw i can make another select random ...but i just wanna see what can be done π
Isnt the selectRandom only executed once at the start?
that then sets the randomLocation which is used by all three commands
@harsh vine do you want the chance the next random might be the same?
private _markers = ["pos1", "pos2", "pos3"];
Sav1 = createVehicle ["Land_Tablet_02_sand_F", getMarkerPos selectRandom _markers, [], 1, "none"]; // etc
// OR:
(_markers call BIS_fnc_arrayShuffle) params ["_marker1", "_marker2", "_marker3"];
private _markers = ["pos1", "pos2", "pos3"];
Sav1 = createVehicle ["Land_Tablet_02_sand_F", getMarkerPos selectRandom _markers, [], 1, "none"];
```i think this one works fine ...thanks again π
Why aren't we required to declare the length of an array in sqf? The few "real" programming languages I've used* force you to, so the computer knows how much memory to allocate 
*Used meaning done a university course
js doesn't need either
but again, is js a "real" languageβ¦
@jolly bone see Arma arrays more as C# Lists
The answer to your question lies in understanding why you need to specify array size in languages like C
Why aren't we required to declare the length of an array in sqf?
its a vector, or dynamic array. not a static array
Alright thanks. I just got interrested in this question recently after hearing a drunk dicussion between some programmer friends and that'll tell me what to look up for reading. (I'm afraid I have never used JS π )
hey lou is there a work around this...if position is already taken then find another selectrandom position, just so they dont stack on each other ...
that's why I asked that
do you want the chance the next random might be the same?
use the second solution then
Why aren't we required to declare the length of an array in sqf? The few "real" programming languages I've used* force you to, so the computer knows how much memory to allocate
*Used meaning done a university course
@jolly bone Lots of modern languages have dynamic arrays. Some have both dynamic and static.
Yeah sorry if I spoke too decisively, I'm very much feeling my way forward through the dark when it comes to computer science
It's all right. Static array size is preferable if you know the array size and it will be fixed, because then it can be allocated on stack and not heap. Dynamic arrays are heavy since they allocate on the heap, and need to resize and thus reallocate once in a while if they grow larger and larger.
Although, dynamic vs static allocation... if it heap allocation happens only once then it's irrelevant
that's not #arma3_scripting though
where should I post it ?
I don't know, maybe #arma3_questions or #server_admins
done ty !
Yup π
Does anyone know if sqf BIS_fnc_UnitPlay is working on dedicated server by now? Or is it still crap?
anyone experienced in altis life development?
because im getting this error when i tried to add the opfor faction
18:48:22 Error in expression < displayCtrl 38502),1,0.1,getMarkerPos (_sp select 0)] call life_fnc_setMapPosit>
18:48:22 Error position: <_sp select 0)] call life_fnc_setMapPosit>
18:48:22 Error Undefined variable in expression: _sp
18:48:22 File dialog\function\fn_spawnMenu.sqf [life_fnc_spawnMenu]..., line 34
[((findDisplay 38500) displayCtrl 38502),1,0.1,getMarkerPos (_sp select 0)] call life_fnc_setMapPosition;
this is the line of code
anyone got any ideas?
@oak peak try their Discord server (listed in #channel_invites_list)
hi,
I cant add BIS_fnc_holdActionAdd to flag pole while addAction works fine. Any Idea?
a mistake in your arguments most likely @delicate maple
Hey all...I've never really coded, so I'm trying to learn.
So I'm writing a scenario using ALiVE. I'm incorporating Drongo's Air Operations, which I love. The only problem I'm running into - the aircraft I put down like to start rolling forward and taxiing toward the runway before the mod gets control of them. Then they stop, canopies go up, etc, until they get orders. Then the taxiways are blocked by shutdown aircraft which are now arrayed in a nice straight lien.
I put some concrete barriers in front of the planes to just keep them in place, which worked, but then I want them to despawn after 30 seconds or so.
I tried putting
if (time>=_future) then (deleteVehicle BARRIER1)
into the barrier init field, but it doesn't do anything. I realize this is basic and stupid, but when it comes to scripting, I'm basic and stupid.
this spawn {sleep 30; deleteVehicle _this}
will delete the barrier after 30 seconds
And obviously, this goes into the init field
this spawn {sleep 30; deleteVehicle _this}will delete the barrier after 30 seconds
And obviously, this goes into the init field
@little raptor Son of a bitch. That worked like a charm. Thank you so much
Anybody able to help me out with this error please? No clue what is causing it. I'm pretty sure the syntax is correct and I have checked the wiki. Tried using the stackable version of the EH as well as the non-stackable version and get the same error each time.
This is my code activated by an addAction:
_casReq = player addEventHandler ["onMapSingleClick",{
openMap true;
params ["_units","_pos","_shift"];
addMissionEventHandler ["Draw3D", {
drawIcon3D ["\A3\ui_f\data\map\markers\handdrawn\objective_CA.paa", [1,0,0,1], _pos, 1, 1, 45, "CAS REQUEST", 1, 0.05, "TahomaB"];
}];
player removeEventHandler[_casReq, 0];
}];
openMap false;
The error is:
_casReq = player [#]addEventHandler ["onMapSingleClick", { Error Foreign error: Unknown enum value: "onMapSingleClick"
and with the other EH it is the exact same just with MapSingleClick in the error
You can't add that to player
And it is not onMapSingleClick, it's mapSingleClick
When using event handlers outside configs, remove "on"
The stackable version is different
The wiki says the difference is one is stackable (MapSingleClick) and the other (onMapSingleClick) isn't stackable.
I'll amend it now
Other way round, my bad
The wiki says the "command" is not stackable
Not the event handler
All event handlers are stackable
Oh right ok. I am getting confused π
onMapSingleClick itself is a command. Command versions are not stackable
Use event handlers instead
And the event handler can only be added to controls and displays
If you want to add it to the main map, use BIS_fnc_addStackedEventHandler
Right ok. If I add it to the map will it be run on all clients or solely the client which runs the addAction?
You can also use the mission variant:
addMissionEventHandler ["MapSingleClick",{}]
Which is why I wanted to just use addEventHandler. I thought that was the case with missionEH. Ok thanks for clarifying
@rain mural * corrected the code
seen, thanks π
@little raptor mission EH are local, no? π€
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler
Yeah I was just having a look and tripping up on it π
Are they
yep, afaik
I figured since they are "mission" event handlers they affect all clients
The wiki doesn't say anything
eL
yep π
maybe I should add it to addMissionEventHandler as well
Ah sweet. I know how to use missionEHs then
addMissionEventHandler ["MapSingleClick",{}]
Yup nice and easy! π
So I am guessing I can't parse down _pos from the above EH into the Draw3D EH at least not directly? Is there a work around for this or am I being dumb again?
addMissionEventHandler ["MapSingleClick",{
params ["_units","_pos","_shift"];
addMissionEventHandler ["Draw3D", {
drawIcon3D ["\A3\ui_f\data\map\markers\handdrawn\objective_CA.paa", [1,0,0,1], _pos, 1, 1, 45, "CAS REQUEST", 1, 0.05, "TahomaB"];
}];
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#MapSingleClick
_unit, _pos, _alt, _shift
(but you only need _pos anyway)
@rain mural nope, you have to work with global variables or set variables on a certain object
it's a new scope every time
Ugh that sucks, thanks!
So drawIcon3D recognizes that it is an array but apparently it is providing 0 elements when 3 is expected. I am in over my head π
you can use string for code then format position in but you will create EH every time you click on map
Ah ok. That would cause performance issues down the line, no?
what adding new event handler with every click? obviously
no, _pos simply doesn't exist in onDraw3D EH
I have made it a global variable. Even when I hint str _pos in the MapSingleClick EH it is an empty array
now that's weird
Yeah π
openMap true;
addMissionEventHandler ["MapSingleClick",{
params ["_pos"];
markerPosition = _pos;
hint str _pos;
addMissionEventHandler ["Draw3D", {
drawIcon3D ["\A3\ui_f\data\map\markers\handdrawn\objective_CA.paa", [1,0,0,1], markerPosition, 1, 1, 45, "CAS REQUEST", 1, 0.05, "TahomaB"];
}];
openMap false;
removeMissionEventHandler ["MapSingleClick", _thisEventHandler];
}];
of course
you are taking the first param, not the second
params ["", "_pos"]
with that done, you're good
@rain mural β
donβt need params
Ah that makes sense. Thanks both of you!
Or even better:
addMissionEventHandler ["Draw3D", {
{drawIcon3D ["\A3\ui_f\data\map\markers\handdrawn\objective_CA.paa", [1,0,0,1], _x, 1, 1, 45, "CAS REQUEST", 1, 0.05, "TahomaB"];
} forEach ICON_POS;
}];
You can draw multiple icons now
Obviously, ICON_POS is an array, so on click:
ICON_POS pushBack _pos
This one doesn't throw errors about undefined vars either
If pos wasn't defined like previous case
Ooh thanks! I'll have to save that one for a rainy day. I feel the feature is already pretty OP if used correctly.
Then again, the marker is only a rough idea for the CAS pilot π€
if it is for another player, make sure to publicVariable
(or missionNamespace setVariable with a target parameter)
if player A clicks the map for player B, the pos has to be transferred
with a parametered function, it's doable
I only need the Draw3D marker to be shown by all so I could just move all the executed code out to a separate function.sqf and remoteExec it
Boom!
Hi all,
Would anyone happen to know what the right way is to make an array based on a sub array parameter?
config.cpp
class CfgMusic
{
class Track1
{
sound[] = {"APT\Music\track1.ogg",1.0,1.0};
duration = 100;
parameters[] = {"day", "rain"}; //I want to put each track into arrays specified by parameters
};
class Track2
{
sound[] = {"APT\Music\track2.ogg",1.0,1.0};
duration = 100;
parameters[] = {"night", "fog"};
};
class Track3
{
sound[] = {"APT\Music\track3.ogg",1.0,1.0};
duration = 100;
parameters[] = {"rain"};
};
class Track4
{
sound[] = {"APT\Music\track4.ogg",1.0,1.0};
duration = 100;
parameters[] = {"fog"};
};
};
I know how to pull the duration but unsure on what method I should use?
what should the array look like?
So the way that the array should look.
For all songs with parameter say "rain", it gets categorized as rain, some audio files might get classified as "day" and "fog" based on what is listed in parameters.
It is to autoselect from an array at random if the contitions are met in the ifthen statement
So im redoing this completely cause it was very tedious to setup 400 sound files and have to type in the duration and class ID a second time.
For example, this is what the old version would look like since it was defined in the same sqf a second time with the fogtracks and duration specified
if(fog >= 0.3) then
{
//playing fog music
wasInCarBefore = 0;
_selecter = floor(random count _fogTracks);
playMusic (_fogTracks select _selecter);
duration = (_fogDurations select _selecter);
currentTrack = (_fogTracks select _selecter);
if(debugging == 1) then
{
hint format ["Changed music to Fog Music Trackname: %1", (_fogTracks select _selecter)];
};
};
if you are hardcoding it like that you could just do
"'rain' in getArray(_x >> 'parameters')" configClasses (configFile >> "CfgMusic")
ok, I tried that but didn't do that correctly apparently if thats what that is, Think i was using isarray
@robust hollow is this what you mean
_raintracks = "'rain' in getArray(_x >> 'parameters')" configClasses (configFile >> "CfgMusic")
//=======================================================
if(rain >= 0.3) then
{
//playing fog music
wasInCarBefore = 0;
_selecter = floor(random count _rainTracks);
playMusic (_rainTracks select _selecter);
duration = getNumber (configFile >> "CfgMusic" >> _selector >> "duration");
currentTrack = (_rainTracks select _selecter);
if(debugging == 1) then
{
hint format ["Changed music to rain Music Trackname: %1", (_rainTracks select _selecter)];
};
};
you could do something like this:
_fogTracksObjects = "'fog' in getArray (_x >> 'parameters')" configClasses (configFile >> "CfgMusic");
_fogTracks = _fogTracksObjects apply {
[
getText (_x >> 'name'), // track name
configName _x, // classname
getNumber (_x >> 'duration') // duration
]
};
i just copied fog when u put in rain lol
you would need to use configName and could simplify it a bit but yes pretty much
_selecter = configName selectRandom _fogtracks;
playMusic _selecter;
duration = getNumber (configFile >> "CfgMusic" >> _selector >> "duration");
currentTrack = _selecter;
if(debugging == 1) then
{
hint format ["Changed music to Fog Music Trackname: %1", _selecter];
};
ok
getarray BI page was vague on this subject, Thanks. didn't think you could skip a layer to find a parameters. thought it had to be Configfile >> cfgmusic >> and some sort of black magic after it
@robust hollow _selecter/_selector* π
BI source?? π
oh π
is it possible to include a file before the folder where the script is defined?
/folder1/folder2/script.sqf
/folder1/headerfile.hpp
something like this
../ will move one directory back
#include "../GUIdefines.hpp"
I get this error:
Error missing ;
On line 138 in the defines file
Line 138 is
class RscText
am i not able to include the file with gui defines?
you wouldnt include a config into an sqf script
maybe with createDisplay
the first display you create is the parent, the second the child
@winter rose oh createdisplay ontop of the createdialog?
I believe so (not too sure about UI stuff)
but only one can be active at a time - the parent won't be accessible as long as the child is open