#arma3_scripting
1 messages Β· Page 142 of 1
idt one created by server works cause when i use in script if isServer that one doesn't work
when i run command locally he works fine
makes sense
so there is no other way of doing it?
Not that I know of
this is what i've meant
that guy shoots you even without aiming π¬
yea but he won't shoot even like that if i don't shoot near him
i have no idea tf is going on w arma π
id start testing with clean scenario without mods
did already π₯²
post the script you are using to create the units?
Is there a way to script objects relative to each other without using variable names for individual objects? For example, if I want to attach a bunch of objects to a single vehicle, I am currently setting the variable name for the car to something like mainCar and then putting in the init field of each object: [this, mainCar] call BIS_fnc_attachToRelative;.
But if I want to turn this into a composition and place more than one down, it wouldn't work since the variable name isn't dynamically updated on each new instance of the composition. Is there any way to do this so I can attach the objects, make it a comp, and then place multiple down?
if (isServer) then {
mog_mile_ground_grp1 = createGroup EAST;
_unit = mog_mile_ground_grp1 createunit [selectRandom _myunitarray, [10545.8,7319.01,5.48363e-06], [], 0, "CAN_COLLIDE"];
_unit setSkill ["courage", 1];
_unit setSkill ["aimingAccuracy", 0.1];
_unit setSkill ["spotDistance", 1];
_unit setSkill ["spotTime", 1];
_unit setSkill ["commanding", 1];
sleep 0.5;
[mog_mile_ground_grp1, d1] spawn BIS_fnc_stalk;
};
yes:
1.) Select the base object in the editor
2.) Ctrl select the rest of the objects
3.) Build array using get3DENSelected "object"
4.) Save index 0 of the array as the base object
5.) Iterate through the other indexes of the array and collect the position data using worldToModel and save any directional data
Then to build, you basically do the reverse using modelToWorldWorld
if (isNil "COMPOSITION_markerindex") then {
COMPOSITION_markerindex= 0
};
_compositionMarkerName = format ["COMPOSITION_%1", COMPOSITION_markerindex];
COMPOSITION_markerindex= COMPOSITION_markerindex+ 1;
so my assumption is that it'll look something like this?
_objectArray = [2172cb0c080# 4004: apc_tracked_01_crv_f.p3d,21673794100# 3965: haultruck_01_abandoned_f.p3d,21674377580# 3966: miningshovel_01_abandoned_f.p3d,21674376b00# 3967: haultruck_01_abandoned_f.p3d, ... ]
_modelData = []
{
_modelData pushBack _x worldToModel [0,0,0];
} forEach _objectArray;
and then that _modelData array would have position data, then I would somehow copy it to my clipboard, paste it as a variable in the code, and then modelToWorld it? The steps are a bit fuzzy for me
this is a great idea, my only challenge with it is that if I apply this code to all the objects in the composition, it ends up incrementing COMPOSITION_markerindex each time to the number of objects there are in the composition (for mine it was 38). If I instead put that code in just one object (like the base), then I can't guarantee that code will run before any of the attachTo commands, so they don't have the variable name to go off of.
if (isNil "extractorBase_markerindex") then {
extractorBase_markerindex= 0
};
_compositionMarkerName = format ["extractorBase_%1", extractorBase_markerindex];
hint _compositionMarkerName;
extractorBase_markerindex= extractorBase_markerindex+ 1;
[this, _compositionMarkerName] call BIS_fnc_attachToRelative;
I'm trying to create a trigger to check if the mission fails, but it gives an error at createTrigger and says it's missing a ";"
_triggerMissionFail createTrigger ["emptyDetector", [0,0,0], true];
_triggerMissionFail setTriggerStatements
[
"(!alive objOfficer) && !(""task0a"" call BIS_fnc_taskCompleted);",
"[""task0"", ""FAILED""] call BIS_fnc_taskSetState;",
""
];```
use toString for your strings and write the code as normal
toString { (!(alive objOfficer)... },
toString { ["task0", "FAILED"]... },
""
That's not the problem though
The problem is the missing = between _triggerMissionFail and createTrigger
Yep, fixed. Thanks
its not but its so much more readable lol
Hello, the wiki page for Arma's vanilla Conversations system provides an example of using a Conversation Event Handler for a dialogue where the player is given multiple choices. I am a little unclear on how exactly to set this up, as well as how/if this could work in a co-op mission so that any player can initiate the dialogue and everyone could hear it. A little help understanding would be appreciated.
Just get rid of the pilot to do that?
what would be the best way to create airplane reverse script (when plane is on ground)? i was thinking of setVelocity but too much speed with that could destroy the plane
How am I able to close display below, i know in it's not closed because systemChat messages are no longer displayed when RscDisplayEmpty is created
works in sp, does not in mp (local hosted or dedi)
RscDisplayEmpty does not cover systemChat in sp, only mp as well
// creates an empty display
private _emptyDisplay = findDisplay 46 createDisplay "RscDisplayEmpty";
// does not work
_emptyDisplay closeDisplay 1;
_emptyDisplay closeDisplay 2;
i see we have a lot of questions and not many answers
its working for me. have you tried the creation line only without closeDisplays? (so you see what it does)
π
what's the issue/obscurity?
I've understood how I would set up a simple linear conversation. I'm not that experienced with coding/scripting in general, so I don't understand what exactly it is I need to do in order to set up the Event Handler for a multiple choice conversation. I'm also not sure on how/whether this would work in a co-op mission (ideally every player can talk to the NPCs and the player voice line would play from whoever initiated conversation)
usually, conversations in MP are not recommended because only ONE conversation can happen at all times, afaik
but if it's a close coop, it can do
Well it's a small co-op mission where all players are in a squad together and only a few NPCs have dialogue, so I think it should be fine?
I'd guess so yes
as long as they don't trigger another chat 2km away at the same time π
I'm sorry but I'm really not comprehending how to set up this Event Handler. What file does it go in, do I set up CfgSentences and the bikb files like normal, what is the variable I use so all players are able to call kbTell? Sorry if these are stupid questions, I'm not that good with code, I'm more of a story teller who sometimes has to write some scripts for his silly little missions.
could you test that it works when you run as multiplayer please, works in sp for me as well, just want to verify
editor-MP works also
baffling, never seen this, thanks i guess
dont you have the mouse cursor appearing when you run that creation code?
I do, disabled only in recording
ok
no problem at all, there are (in general but some make it a personal matter to bring them up) no stupid questions and not knowing is not a crime
soβ¦I wrote that page and I have no idea where it goes as of now π I actually missed the setup part, I will have to dig again
aaah yes it's in the kbAddTopic's last argument @leaden needle
thank you, i also realized that this forum post is linked on the Conversation wiki page, which looks helpful
https://forums.bohemia.net/forums/topic/107662-using-dialogue-system-between-player-and-ai/
Howdy all, Ive been reading up, in the thread at http://forums.bistudio.com/showthread.php?t=91875, but I cant seem to get it to work/understand it, even upon review of both the kbtell and kbWasSaid biki entries. Im wondering, if I want a simple conversation between the player, and an AI characte...
How to make FiredNear eventhandler to only activate when player is shot by the specific unit? i tried (isPlayer _unit) got no luck, though it's strange it works on other eventHandlers.
_unit addEventHandler ["FiredNear",
{ params ["_unit","_firer"];
if ((_this select 2) < 5 && (isPlayer _unit) then
{
systemchat "Your being shot at.";
};
}];
And 5m is a pretty short range.
the if statement is missing )
you can turn on script errors from the launcher if you havent already
I mean pilot disableAI "ALL"
pilot is the var name of the pilot
Is that in multiplayer?
ops i wrote it wrong here, when i tested it ingame it was full statement, my bad. but i will try Suppressed event handler for now
yea only on dedicated server
Thanks, for some reason it still doesnβt deploy landing gear.
Rewrote it for your specific use case
// name the specific unit you want to it to trigger for, someUnitVarName
// FiredNear is triggered only by nearby units, use Suppressed Instead
player addEventHandler ["Suppressed", {
params ["_unit", "_distance", "_shooter", "_instigator", "_ammoObject", "_ammoClassName", "_ammoConfig"];
if (_shooter isEqualTo someUnitVarName && {_distance < 50}) then {
systemChat "shot by specific unit "
};
}];
thanks this looks amazing, though the _shooter unit is local variable, so im trying to find a way to assign the event handler for the unit itself
_unit1 spawn {player addEventHandler ["Suppressed", {
params ["_unit", "_distance", "_shooter", "_instigator", "_ammoObject", "_ammoClassName", "_ammoConfig"];
if (_shooter isEqualTo _this && {_distance < 50}) then {
systemChat "shot by specific unit "
};
}];
};
this is what i did, doesnt work
What you want to achieve?
That your code will be executed if the shooter is _unit1 and distance is below 50m to player?
And on SP or in MP?
And where do you create your _unit1? Editor placed or via script?
in SP, also in a script i create a local unit named _unit1 , now if that _unit1 shoots near/at the player it would trigger some effect, so i add the event handler to that unit only
unit is created using createUnit
the idea is that when unit spots the player, thus after shooting towards him it spawns waypoints to chase the player further. basically just like BIS_fnc_stalk but its more like a chance for the player to escape
_shooter is a parameter that signifies the shooter that trigered the event hander on the _unit, i.e the player
rename the unit you want to stalk player to unit1, remove prefix
based on your requirement, you don't need to put event handler on shooter, just add it to player as described
player addEventHandler ["Suppressed", {
params ["_unit", "_distance", "_shooter", "_instigator", "_ammoObject", "_ammoClassName", "_ammoConfig"];
if (!isNull unit1 && {_shooter isEqualTo unit1} && {!(_shooter getVariable ["isStalking", false])}) then {
systemChat "shooter is now stalking player";
_shooter setVariable ["isStalking", true];
[group _shooter, group _unit] spawn BIS_fnc_stalk;
_unit removeEventHandler [_thisEvent, _thisEventHandler];
};
}];
edited per π
And you need to define that after you have created unit1 and remove eh if unit1 gets killed/ removed.
Or add check that !isNil "unit1" (so entity exists)
thanks this difinitely helps alot, i may use it in many ways, though
_group = createGroup [east, true];
_unit1 = _group createUnit ["vn_o_men_nva_43", getpos thistrigger, [], 0, "NONE"];
this is what im using, its local because it may spawn more units, and each spawned unit gets its own eventhandler, so if i name it unit1 it will be global thus it will cause some issues
Same or some other event?
same and lets say a repeatable trigger, so i cant repeat a global named unit each time
i see the edit, let me try, and many thanks also!
call the extractorBase_markerindex= extractorBase_markerindex+ 1; AFTER the composition is done or created.
Hello. I'm trying to do an "AAS" sector control style. I had some progress so far. In this video you can see a test on a local server. But when I try this on dedi server, it fails so bad, mainly functions are not working at all. Could someone take a time to see my mission files and test it out? Ty in advance
post the mission on github and post it here. easier for people to go through it
first time for everything
why are you keeping all of your functions local and not on the server?
How can I meak objects placed in eden undeletable for zeus? Like if a zeus uses "add Objects" they can delete objects mid op. How do I disable that for certain objects?
setCuratorCoef - https://community.bistudio.com/wiki/setCuratorCoef
// curatorObj setCuratorCoef [action, coef]
object1 setCuratorCoef ["Delete", -1e10];```
keep in mind, that is for every object. you will not be able to delete anything.
well actually, it could be for singular objects
It can be used for singular object though.
yea doing it in a object init could work with this instead of object1
if it is, we should update the wiki page for more clarification cause as it is written now, I could see it applying for the object or for the curator itself
yea it is kinda confusing there
Try it and let us know @wicked sparrow π
the reason I'm thinking its for the curator itself, is because "Place" is an option. An object can't have already been placed in order to place it. "Edit" would be movement of said object.
Available actions are:
"place"
"edit"
"delete"
"destroy"
"group"
"synchronize"
``` from https://community.bistudio.com/wiki/Arma_3:_Curator - So yes, it seems like that prevents you from deleting entirely.
I've already tried to setup cfgFunctions, it works on local but on dedi it doesn't.
because the functions don't exist on dedi with how you have it done now.
Honestly I recommend just running this as a spawn checking ever .5 seconds ( https://community.bistudio.com/wiki/removeCuratorEditableObjects )
either that, or detect when the curator has selected an object, and change the coef based on what object is selected.
got It, but It should work with cfgFunctions right?
yes, or put them in initServer.sqf. but, it looks like your functions modify triggers and such, so make sure you are only letting the server run them
well the triggers are from the sectors modules
wouldnt coef editing at that time be too much expensive or have big effect doing this everytime the person tries to delete / readd the object?
Plus, the setCuratorCoef only works when all the objects have a cost assigned to them which is 
don't know. would have to test it. for simplicity sake, the removal is probably the best bet.
I got started with this topic https://forums.bohemia.net/forums/topic/176089-unlocking-a-sector-when-another-sector-has-been-taken/
and it works on dedi (with function on initPlayerLocal)
Im making a mission that requires NATO to capture sectors in a sequential manner. I have no problem creating and placing the sectors, but I cant make the sectors show up sequentially. I am using the unlock game logic synced to a trigger then synced to the new sector. All the sectors show up at th...
Try checking if AI is actually disabled:
pilot checkAiFeature "Move"
Run it in debug console when the scenario is running. If it says true it's not disabled
Is there a way to execute a script for someone else
For example I am making a script that steals virtual items from a players virtual inventory, this virtual inventory is stored in a database and there a function that updates this database but it is run on the client.
I saw that but for some reason I can't make it work
_player = (player nearEntities 2 select 1);
["Hello1"] remoteExec ["hint", _player];
I tried something basic like that and I am still getting hints despite there being another unit right next to me
If you're testing in a scenario that's hosted on your machine, and the other unit isn't a player, then you'll still get the hint because the AI unit is local to your machine, and remoteExec targets the machine where the thing is local.
Also, your nearEntities is potentially unreliable because it doesn't specify that it should look for units. There could be another entity that's closer and not a unit.
Try this:
// only detect humans that aren't you
private _nearMen = (player nearEntities ["CAManBase",2]) - [player];
// safety: fail if there are no other near units
if (count _nearMen < 1) exitWith {
hint "No one here!";
};
// get the nearest remaining unit
private _nearestMan = _nearMen select 0;
["Hello1"] remoteExec ["hint",_nearestMan];```
...that's not quite right π€
Fixed
Without making a whole custom GUI, is it possible to make an image flash up on the screen of a player and be animated?
Ok so now I got my script in the server and its working but the issue is pulling another players inventory.
It's set with
player setVariable ["life_items",(life_gear select 16)];
but in my script which is called with an addaction on the player
player addAction ["Steal", { [cursorObject] spawn sal_fnc_openDialogStealMenu}, [], 1, false, true, "", "(cursorObject isKindOf 'Man' && stance player ==""CROUCH"")", 1];
and it should get the cursorObject, being the other player, life_items
params ["_target"];
source_life_items = _target getVariable ["life_items",0];
This works on a hosted server but on a dedicated server it's not pulling the cursorObjects life_items.
My own life_items is found and added but for some reason on the dedicated server this is not working when using getVariable
I think I found it after reading into it JIP setVariables are only synced if you use the alternate syntax and set public to true
Does anyone know if i can activate a trigger which would then be synced with an ordnance module so it can create an explosion with the AddAction line on an object ?
Eg. I want to have a radio which will have an action option "Call Barrage". I want the Action to activate the trigger and (i suppose) with it's activation the ordnance module would fire the artillery automatically
hi,
is there a way to control the flight time of under barrel flares, want them to last a bit longer then default
That's on the config side. Look at the ammo, there should be a property related to lifetime or whatever.
You'll have to make a mod
by config u mean its default and can't be changed, right?
Not by a script
So, the script is not calling the functions. But I got one of those functions and put in the debug menu and got it working (server exec).
So I think the problem resides on these codes like this. Is there something wrong with this remoteExec for example?
[currentWestSectors] remoteExec [ "PIG_fnc_updateSectors", west, "JIPWest" ];
I need to generate the minimum range value that the artillery computer outputs in script. The issue is how to calculate the true max elevation: maxElev and minElev in turret config seem to be relative to the "default" elevation in the model, but I can't see any way to extract that. selectionVectorDirAndUp might be a way to get the current elevation, but that's not ideal here because I'd need to spawn a dummy object. Any better ideas?
My game will be MP
So, INIT field of the object (radio) :
if (isServer) then {
this addAction ["Call for Barrage", {
missionNamespace setVariable ["BarrageCalled", true];
publicVariable "BarrageCalled";
}];
};
Now to the trigger's condition field :
this && (missionNamespace getVariable ["BarrageCalled", false])
Tell me if you see anything wrong in the script or i forgot something
It only adds current addaction on the server. It won't show up to clients.
Only if you are hosting a local, the host (server) will see action on the object.
You should take if isserver check away and add the same condition to your addaction. So if your actionCompeleted is false it shows your action on radio.
@trail shale βοΈ
Is there currently a way to detect if a unit has started to reload? Outside of using this mutex? https://github.com/acemod/ACE3/blob/be77ef233ee87e00cca6e71a2ae307c6b073c6ca/addons/common/XEH_postInit.sqf#L439
If not, I'll put in a request for it. Would love to have a "Reloading" event handler in addition to the "Reloaded" one
Thanks. One more thing is want to ask is about the Action itself. Have i set it correctly as a variable? I mean, the trigger shall activate when i press the action on the object, or should do something different? I haven't tested it yet.
Should i also put " ActionID " in the Init ?
You don't need it.
You could just add a condition to your action.
this addAction
[
"Call for Barrage",
{
params ["_target", "_caller", "_actionId", "_arguments"];
missionNamespace setVariable ["BarrageCalled", true];
},
nil,
1.5,
true,
true,
"",
"!(missionNamespace getVariable ['actionCompleted', false])",
50,
false,
"",
""
];
The mission namespace is global, so you don't need to broadcast that again with publicVariable method.
Thank you π
One Possible Solution:
[{
params ["_args", "_handle"];
_args params ["_unit"];
private _isReloadingMag = (weaponState _unit # 6) > 0;
private _isReloadingUnit = _unit getVariable [QGVAR(Client_IsReloading), false];
if (_isReloadingMag) then {
if (!_isReloadingUnit) then {
LOG_1(SCRIPTNAME + "Reloading Event:: " + "Unit [%1] is reloading...", _unit);
_unit setVariable [QGVAR(Client_IsReloading), true, [owner _unit, 2]]
};
} else {
if (_isReloadingUnit) then {
LOG_1(SCRIPTNAME + "Reloading Event:: " + "Unit [%1] reloading complete.", _unit);
_unit setVariable [QGVAR(Client_IsReloading), false, [owner _unit, 2]]
};
};
}, 0, [_unit]] call CBA_fnc_addPerFrameHandler;
You can use AnimStateChanged and GestureChanged event handlers
Just check the currentWeapon's reload action, and see which anim/gesture it maps to
No, it's not possible at all, not even with custom GUI (tho you can use r2t and spawn the unit in the middle of nowhere and render him to a texture)
You probably did it wrong, or a mod is interfering. It shouldn't become true on its own
Shame, I had the thought of using BIS_fnc_playVideo, but I cant make the background transparant
yes, detect the inputaction being executed. It really depends on what and where you specifically want to detect, doing so with input actions has to be the easiest, fastest and most performance friendly if the detection is local to a playable unit
Is there anything like #ifdef #endif preprocessing for Arma 3 functions, like in C.
hi,
i would like to edit the contents of the supply crate dropped using the supply drop module to contain exactly these items, what code to write in the crate init?
also i've tried using the virtual supply drop and entered the class name of the heli but keeps popping this error
["classNameAsString"]
thnx that worked
Okey yeah I got it.
I spawned 15k.
87% of frametime is taken up by sorting scripts by age.
It sorts ALL 15k scripts by age, and then only executes only 0.5ms of scripts, because the sorting already used up so much time.
So it only gets maybe a dozen scripts actually done.
So fix should be, only sort the first 512 or so scripts. And process them.
If after executing them all, there is somehow still time left in the 3ms window, it can just sort the next 512 chunk. But it probably won't get to that.
Before:
15k scripts: 150-200fps
18k scripts: 90-180fps
20k: 100-200fps
25k: 150-190fps
30k 140fps-ish.
Ugh I'm having a hard time testing this π
This sorting data seems to all fit in CPU cache, so its not much trouble at all.
But I can see that it takes up 60-90% of frametime.
20k After: 250fps-ish
30k: 250fps
51k: 250fps
And sorting now only 6% of frametime
It'll be more noticable on CPU's with less cache probably.
Also a probably bigger issue than this.
A newly spawned script has a "time since last execution" of zero.
And it sorts scripts and first executes the oldest ones. So the brand new script, will not execute for a long time.
Especially bad when you try to press the "Options" button in menu, when you have 15k scripts spawned. You press and nothing happens.
A newly spawned script has a "time since last execution" of zero.
set it toint.MAX, problem solved π
That would overflow next frame into negative π
Works β’οΈ
100k spawned scripts.
250fps. AND you can still access the options menu, if you know where the button that would fade in is at
I'll consider this fixed.
I'm now sorting in 256 script chunks.
π
pretty good
the overhead which came from the switching between the threads was massive in some scenarios
HIG (AI Can't See Through The Glass) caused the leakage with the 0 spawn {waitUntil {};}; 15-20k scripts executing simultaneously caused massive FPS drop from 90-ish to 10-15 with that mod. I patched it so it's ok now (always 1 thread) but we have a LOT of steam workshop content when mission makers cannot control their code.
The popular Asian WW2 mod also leaked a thread every time a unit was killed. I showed them the fix, they called me a nerd and told me to pound sand. Circa 1-2 years ago.
wow
so rude
Also I'm wondering which algorythm is used to calculate the distance between two points? The regular c = sqrt(x^2 + y^2 + z^2) or J. Carmack's? For the distance-family commands.
You mean for the square root?
yep
I'd be amazed if it wasn't the plain sqrt. It's pretty fast in SSE.
sqrtss is slower than rsqrtss
And in case you were wondering, a distance b < n is faster than a distanceSqr b < n*n. Language is slow.
I can't see any notable overhead of "switching" between threads
Its about the same as doing a call in a script. Even less actually
so, the main performance loss when the engine executes a lot of scripts comes from the sorting?
Basically all of it yes
FPS++;
isn't there a risk of always running the same scripts?
If you spawn spawn so many scripts that the scheduler is overloaded by them, every frame, yes. But you are already F'ed at that point anyway
From the wiki article it's useful in case of distance comparison, something like
(a distanceSqr b) < (c distanceSqr d)
squareSize / sqrtss(squareSize)
currently.
Ty, good to know. rsqrtss (or even vectorized version rsqrtps) is significantly faster if we're satisfied with 11 bits accuracy.
We're not
compiler switch recently changed that code, causing us to be off by one bit. And that already broke mods
You wouldn't notice a performance benefit as you're memory bound anyway
Interesting. So I can precalculate the const variable with the pow() and use it like it is the first use case:
// init
private _distanceSqr = 1000 * 1000;
// time critical code
if ((player distanceSqr _object) < _distanceSqr) then {};
or even use preprocessed constant
Appreciated for the clarification. This is one of your strong side as a user-oriented company.
The reason I stopped to buy anything from EA or GGG - they don't give a ... about anything related to the modding / API / features / feedback
[false, _name, 1] remoteExecCall ["life_fnc_handleInv", cursorObject];
I'm trying to remoteExecCall on the cursorobject the rest of the script works fine but for some reason this script isn't being called on the other client
Any Insight?
Is it because he's not local? and if so how would I go about executing a script on a specific client machine from another client
is cursorObject's object local to that player?
cursorObject is another player infront of him
is life_fnc_handleInv properly defined on the client side?
the function might not exist on the client depending on how you have it defined
Essentially how the script works, life_fnc_handleInv is definied for all players
If he steals from me it adds the items to his inventory but I never get the remoteexec to remove them from mine
Is your CfgRemoteExec (server or mission) blocking it? https://community.bistudio.com/wiki/Arma_3:_CfgRemoteExec
someone made a whole fallout conversion? lol
Working on it
to expand on nikko's comment, if it is blocked by CfgRemoteExec (and you want to keep it locked down), then use the CBA_events (I see you have CBA enabled). They bypass the CfgRemoteExec by using the old way of remoting things via public variables.
I don't have that
Potentially, but it's very slight, and inArea is likely faster if you're pre-prepping. inAreaArray is massively faster in most cases where it matters.
["test", ["target"], cursorTarget] call CBA_fnc_targetEvent;
This correct?
Yeah. Unfortunatelly inAreaArray doesn't work for the spheres
there's more to that as you have to define the event as well before you use it with CBA_fnc_addEventHandler. they are essentially scripted event handlers. But you said you don't have anything blocking your remoteexec so its probably not the problem.
did you do the test that kat suggested above?
About to test
yeah, just simple test with the hint
He did not get a hint
interesting
Wait there is a cfgremoteExec
Sorry
Adding it to the list of functions and I'll try it out
remoteExec is the same as remoteExecCall but executes the code in the scheduled environment.
oh
probably your command not whitelisted
i would think any pvp type mission would run it for safety
It's life
every single player on the Life server wants to hack
as a developer he has to deal with it π
tried the following but gave me an error:
clearMagazineCargo _this; clearItemCargo _this; clearWeaponCargo _this; _this addWeaponCargo ["launch_RPG32_F ", 10]; addMagazineCargo [["RPG32_F", 31], ["DemoCharge_Remote_Mag", 10]]; addItem [["Binocular", 10], ["FirstAidKit", 30], ["Medikit", 10], ["U_I_C_Soldier_Bandit_2_F", 10], ["ItemGPS", 10]]; Signal = "SmokeShellYellow" createVehicle position _this; this allowDamage false;
_this vs this confusion, plus incorrect syntax on addMagazineCargo and addItem.
wut wud be the correction for addMagazineCargo and addItem?
you don't have any left arguments for them
also, you are passing a wrong right argument
basically, everything is wrong lol
ok
always filter in the init box:
// for local arg commands
if (local this) then {
// blah
};
examples:
this addMagazineCargo ["RPG32_F", 31];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
or
private _mags = [
["RPG32_F", 31],
["DemoCharge_Remote_Mag", 10]
];
{
_x params ["_mag", "_count"];
this addMagazineCargo [_mag, _count];
} forEach _mags;
or
for "_i" from 1 to 30 do {
this addItem "FirstAidKit";
};
if (local this) then {
this addWeaponCargo ["launch_RPG32_F ", 10"]
this addItemCargo ["Binocular", 10"]
this addItemCargo ["FirstAidKit", 30"]
this addItemCargo ["Medikit", 10"]
this addItemCargo ["Medikit", 10"]
this addMagazineCargo ["ItemGPS", 10];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle position _this; this allowDamage false;
};
full code, would this work if i wanted to add those items and a smoke signal where the supply gets dropped at?
kinda read it outloud. you know this is all going to happen immediate as the box is created.
add stuff
create a smoke shell at its current position (wherever it is created), physics is applied (falls at its own rate)
make invulnerable
and I'm assuming you don't want the smoke signal to start until it reaches the ground or have it fall at its own speed. that is where you need to work on then.
If it's created immediately that's fine too
then try it
_this replace to this
KOMOD_Signal = "SmokeShellYellow" createVehicle (getPos this);
_this is not defined in that scope. Personally I don't like the idea of using the same variable name for the two different purposes.
BI at least could use _args or something like that π
gave me this error
You need ; after each instruction. The first 5 lines (inside the {}, don't put one on the actual first line) don't have it.
used this:
if (local this) then {
this addWeaponCargo ["launch_RPG32_F ", 10"];
this addItemCargo ["Binocular", 10"];
this addItemCargo ["FirstAidKit", 30"];
this addItemCargo ["Medikit", 10"];
this addItemCargo ["Medikit", 10"];
this addMagazineCargo ["ItemGPS", 10];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle (getPos this);
error
you're missing the closing } on the then
You've removed the last two lines, which includes the closing }; (and the allowdamage false, which might be important)
if (local this) then {
this addWeaponCargo ["launch_RPG32_F ", 10"];
this addItemCargo ["Binocular", 10"];
this addItemCargo ["FirstAidKit", 30"];
this addItemCargo ["Medikit", 10"];
this addItemCargo ["Medikit", 10"];
this addMagazineCargo ["ItemGPS", 10];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle position _this; this allowDamage false;
};
The format of your addItemCargo are wrong
hey is it possible to just constantly play an ambient sound at a position? i want players to spawn in a static C-130 and then paradrop into the AO but the c-130 has no sounds which just doesnt feel right. what would be the best way to add an engine hum sound whilst inside the c-130?
10" <- ?
this addItemCargo ["Binocular", 10"];
this addItemCargo ["FirstAidKit", 30"];```
`" "` denote the ends of a string. You can't put single `"` in random places, it will confuse the game.
Corrected format:
```sqf
this addItemCargo ["Binocular", 10];```
Also, there's an extra space in the RPG32 classname string - spaces do matter in strings, you need to get rid of that
did those changes (thnx for pointing them out) code as follows:
if (local this) then {
this addWeaponCargo ["launch_RPG32_F", 10];
this addItemCargo ["Binocular", 10];
this addItemCargo ["FirstAidKit", 30];
this addItemCargo ["Medikit", 10];
this addItemCargo ["Medikit", 10];
this addMagazineCargo ["ItemGPS", 10];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle position _this; this allowDamage false;
};
still getting an error
Okay, in what context is this code being run? Object Editor init field? Some other script?
in the Crate init of the Supply Drop Module
want to customize the crate paradropped rather than the default items in it
Hover over the title of that field and see if it describes what variables are available
hey is it possible to just constantly play an ambient sound at a position? i want players to spawn in a static C-130 and then paradrop into the AO but the c-130 has no sounds which just doesnt feel right. what would be the best way to add an engine hum sound whilst inside the c-130?
change this to _this
for all instances of this
if (local _this) then {
_this addWeaponCargo ["launch_RPG32_F", 10];
_this addItemCargo ["Binocular", 10];
_this addItemCargo ["FirstAidKit", 30];
_this addItemCargo ["Medikit", 10];
_this addItemCargo ["Medikit", 10];
_this addMagazineCargo ["ItemGPS", 10];
_this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle position _this;
_this allowDamage false;
};
like that
yea try my code above, should work with _this
gave an error
its saying "itemGPS" doesnt exist, is that the actual class name for the gps?
youre also trying to add it as a magazine for some reason?
hold on
i got it from the crate items "Export to SQF" in 3den
hold on
_this addItemCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
};
``` try this.
if that doesnt work, try this
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
};
isnt there supposed to be few lines that preceed this that clear the default supply drop crate contents?
you can just do that in the editor
right click the crate > attributes > object: Equipment storage > clear
yeah i get that i meant in the Supply Drop Crate init
unless i'm missing something like synching an existing crate to the Supply Drop Module that will replace the default (which i tried and didnt work)
if you delete everything in the crate in the editor, there should be no need to delete anything because theres nothing in the crate
@little raptor how can I bring down this menu to default once it was accidentally maximized? I don't see an option and the sides don't drag lol
you already had those earlier. not sure why you took them out
clearMagazineCargo _this; clearItemCargo _this; clearWeaponCargo _this;
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
};
clearMagazineCargoGlobal _this;
clearItemCargoGlobal _this;
clearWeaponCargoGlobal _this;
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
};
its not required but its good practice to always start a new line after a ;
oh also
making things globally will execute the code on every client so its sycronised
my bad, shouldnt have a }; at the end.
clearMagazineCargoGlobal _this;
clearItemCargoGlobal _this;
clearWeaponCargoGlobal _this;
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
thank you, this worked
no worries! just as a quick tip btw, assuming this is for a multiplayer scenario, do try and open a local hosted server and connect a second client to it and see if it works in multiplayer
ill do that but its for solo play
last thing, any idea to have the smoke grenade stick to the crate?
ah ok no problem then, its just that singleplayer and multiplayer coding works differently, something that works in singleplayer might not work in multiplayer.
attachTo kinna perhaps
at the end of the code block, add Signal attachTo _this
consider checking out my mod Modules Enhanced for additional paradropping of supplies and even vehicles
tried the following but the box detached from the chute but smoke nade was attached:
clearMagazineCargoGlobal _this;
clearItemCargoGlobal _this;
clearWeaponCargoGlobal _this;
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
Signal attachTo _this;
_this allowDamage false;
ty i'll give it a spin
Local Handle Damage Expert, @meager granite, what do you use to detect only the first instance of direct or indirect damage? I get multiple entries on both for a single hit. Do you save the frame and filter out things only on that frame? I just need to know if the thing was hit, and what by. nothing more.
might be a stupid question but couldnt you sort the list by time added and then select the first index in that list?
there is no list, unless I collect in a time frame, then execute a few frames later. say you hit something with a rocket, you might get 6-8 firings of the handle damage event which can mess that up
handle damage, because I do have to return 0 damage at the end after my custom work
This is one rocket hit:
each trio of messages is 1 firing of the event handler. only fired 1 rocket
the BI Wiki updated, HandleDamage now has additional arguments
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];
context: Number - some additional context for the event:
For AoE damage it's called multiple times
It would be nice to see that additional information here
LastHitPoint - the last hitpoint from iteration is processed
it's definitely called for the each part of the body
you need _selection, _hitIndex and _hitPoint. These vars contain exact part of the body which was processeed by the engine
I don't even see any hitpoints/selection in the config for "Land_Device_disassembled_F"
it has some simple object animations though for the damage LOD
I think what I'll do is make two handlers. one handle damage to remove engine damage, then use the hit to detect the hit for the custom one
well... maybe... I still need the projectile which hit doesn't give
hmm lets see what hitPart gets me
if Selection is empty ("") the damage considered over-all structural
so techicanlly you can filter the damage by ignoring the other damage events with non-zero context
what about using a fired event, grabbing the projectile, using the projectile hitpart event to grab the thing it hits, then do the calculation from there. I just need to know if the main projectile hits the object
you can store proj name into object-specific variable and grab it from the Hit
Fired EH is only reliable if fired locally
yeah doesn't track explosives either. nvm
so you can store projectile to the var
// HandleDamage EH
// ----------------------
if ((_unit getVariable ["projectile", ""]) isEqualTo "") then
{
_unit setVariable ["projectile", _projectile];
};
// ----------------------
// Hit EH
// ----------------------
private _projectile = _unit getVariable ["projectile", ""];
// process...
// Allow overwrite
_unit setVariable ["projectile", ""];
// ----------------------
gotcha i'll try it out
Hey, Iβm trying to create a new faction in arma 3, but I havenβt done scripting before. I wanted to know if there was a good video/guide for creating factions without using ALIVE that helps me learn from scratch.
Also wanted to know if there was a way to add patches onto my faction. Thanks.
are you going to be making custom uniforms? or just making new units that are wearing already existing stuff
moreover you can completely ignore all the damage events which have empty _projectile variable
Hit is not fired on minor damage, keep in mind
I just want to make new units using existing stuff. I wanted to make a US Army faction using the W28 mod as a dependency, just so I start understanding how scripting works.
surprisingly, it fires when i shoot small arms where the damage is something like < .0003
okay so this will be a config thing, so meet me over in #arma3_config
Thanks
try to test Hit on the tank or wall by shooting at it with the pistol
17:33:39 [CARRIERSTRIKE] (Mission) LOG: Reactor Damage Handler:: Projectile: R_PG32V_F
so currently this way, if you stack multiple explosives and detonate them all at the same time, it can't differentiate against the different explosions. it works as long as the explosions don't explode together faster than the variable update happens
_view = floor(_object getDir player);
_objectView = floor(getDir _object);
_distance = _view - _objectView;
for "_i" from 1 to _distance do
{
_object setDir (_objectView + _i); sleep 0.001;
};
I'm confused for some reason when I do this script it works fine, the object turns towards me, but everytime after it simply stops working
The rest of the script after this works it's just after first use this part no longer functions
It's because it can bark a negative number
Rotate an object towards the player smoothly
like make it the objects face each other?
Just gonna create a separate variable for the for loop that will be positive and just do an if statement for two different equations one to add to the degrees and one to subtract from it
Like an object is facing away from you and then it slowly turns towards you when you execute this script
This worked
_view = (_object getDir player);
_objectView = (getDir _object);
_distance = _view - _objectView;
_forDistance = _distance;
if (_distance < 0) then
{
_forDistance = _forDistance * -1;
};
for "_i" from 1 to _forDistance do
{
if (_distance > 0) then
{
_object setDir (_objectView + _i); sleep 0.001;
}else
{
_object setDir (_objectView - _i); sleep 0.001;
};
};
_object setDir (_object getDir player);
there is a abs for absolute value command btw
Ah didn't know that lmao
That won't necessarily take the shortest rotation direction, btw.
@hasty violet No, but there is a group cap
Hi. From HitPart?
There is no way to tell if its direct or indirect damage from HandleDamage
Only assume by shot class that its an explosive
I think you can now, parm 8.
but my issue is just trying to grab the first instance of damage and the projectile and skip all the others. I currently have this:
https://pastebin.com/JX093WkZ
which works, except for when you stack a few explosives on top of each other and detonate them all at once. but that seems to be firing all within one frame then.
Oh yeah, I even wrote that explanation for the flag myself.
I didn't read the chat further, what's your general goal? Count number of direct hits?
end goal is I have some reactors on the carrier that I want to handle with my own damage scale depending on the simulation of the ammo that hits it. so I need to grab the first shot that hits the reactor and skip the event from firing on all the other hits since that handler can fire 8 or so times for a single ammo hit, multiple for direct and indirect damage.
with my pastebin above, I have gotten it down to only working on the first firing of the handle damage by collecting all the handle firings, and processing them next frame to grab the first instance
only issue is now, if you place down multiple satchels or whatever, and remote detonate them all at the same time, it won't pick up the different instances of the explosives, as they both apparently hit in the same frame
Yeah this can also happen with other shots too
Any network hiccup and damage messages will arrive and process in same frame
even if firing client did sequential hits
So checking frames is very unreliable
What you need is to only consider events with _context = 0
Say your hit does 8 HD calls, two hits will be 16 HD calls, you can tell when next projectile handling starts when _context is 0
It will be like 0 1 1 1 1 .. 2 0 1 1 1 .. 2
Or just 0s if entity has no hit parts
I'm sometimes getting more 0s in an instance #arma3_scripting message
that text paste is all from one rpg hit
Hmm, looks like there is HandleDamage cycle for each penetration
Yeah, just double checked that
Well, there is no reliable way to say if that was same projectile or not
Only possible on shooter side with HitPart
What do you want to change depending on simulation btw?
Also your simulation checks are case sensitive
so I'm making it so that each reactor has 100 hp for now and I'm handling what things do how much damage. so for example
10 rockets || 30 grenades || 1000 bullets || 4 satchels
etc
when reactor dies, carrier lose 12.5% hp. reactors become attackable at 50% carrier hp
If you want it 100% reliable you'll need to count from shooter side
HitPart has projectile entity so you can easily count exactly how many projectiles hits there were
You can track penetrators with SubmunitionCreated
You can save variables on shots now so you can easily pass a flag to submunition/penetrator that hit was already registered on certain object
There is no damage info on shooter side though
Only a fact that some hit was done or not
submunition like pellets also casuing to fire the HD multiple times from the single shot
as @meager granite told, in addition to the netwok hiccup / lag, the possible low server FPS will lead to situation where HD EH will be fired a lot of times in the one frame if the target received more than one projectile.
to resolve this, we need additional argument in EH which is not implemented
the shot identifier. So each HD EH called with the same ID are fired from the certain shot.
Also as @meager granite proposed to use client-side FIred EH to count actual shots (and probably mark them with the ID) is also unreliable if the client has FPS < fire rate.
For this case you don't even need Fired, just HitPart on target
Actually no, for SubmunitionCreated you will need Fired
So you don't register two hits from RPG and its penetrator
There is no problem with FPS though, shots are proper entities, you just carry a flag that certain objects were hit already and there is no need to report to server/do the calc again
I think HitPart is called before SubmunitionCreated?
it should)
but the network traffic will increase if client will report to the server each shot
Oh there is also a bug where there is no projectile in HitPart for shotRocket/shotMissile simulation shots, its fixed in 2.18 though
Only report hits to relevant targets with HitPart on them
But it's still a lot even if you report one hit
I don't like that idea... it's... ehm duct tape - like solution
It shouldn't be much, even if you reported like 30 hits from 30 DAR shots within 1 second, its very little traffic
Wish we had PreHandleDamage on shooter side or something
With more info in it
_shotID parameter.
since its something that determines win/loss and gameflow of the round, I need to keep it server side. can't rely on a client and its fps/lag
Becuause right now the victim client only gets a sum of the damage with very little damage information, pretty much only: source, instigator, shot class string, damage, hit parts damage, that's it
multiple EHs fired with the same _shotID came from the single shot so we can filter the events with the same ID
Even if HandleDamage had something like shot's previous netid (many shots don't have it like bullets), you still won't be able to tell if that penetrator belonged to previous RPG explosion or not
I am talking about the identifier of the shot, not net ID
You can do it reliably with HitPart
But its complicated
If you aim for 2.18 the its less complicated because it has null entity bug fixed
I don't like that idea because engine already knows who and what was the source of specific submunition / penetrator. By adding HitPart EH on the clients basically we have to duplicate the information sent to the server about the shots.
This is the only way, engine itself only sends very brief damage info to the target which is why HandleDamage is so barren with damage source information
could the EH be extended further still? or is it at its limit under the hood
I don't think there is anything else to add, only extend network messages content to include more stuff about the shot
I've been trying to ask to add some kind of "damage kind" enum/value so you could distinguish nameless damages apart easily (drowning, fire, fall damage, collision damage, etc-etc) to no success
Not sure what could be added to HandleDamage to solve your particular goal
As workaround you can filter everything related to the submunitions, but in this case you have to make a whitelist of your _projectiles.
It is solvable on shooter side already right now though
Btw I was working on connecting HitPart/Explosion with HandleDamage so you could get exact hit info for each damage cycle. Its a huge pain in the ass but possible to some extent
HitPart/Explosion order corresponds with HandleDamage order, but only server is able to build full picture because RE is always 1-2 frames late from engine-driven messages
are you saying use the projectile hit part from fired client side?
Like you can't use this info to adjust damage/do decision exactly on moment of HandleDamage due to scripted messages always being frame late, but can end up with whole picture on server side and then send that picture to either target or shooter
For your task? Yes.
for bullet then, I'd probably have to do it the old way cause every bullet hit would be a network nightmare
There you have shots as proper projectiles, you can filter out repeated penetrations, submunitions and only count them as single hit
I am just wondering what happens if the client will drop the bomb on the enemy position with 20-30 units / objects in the area.
that's tons of network spam
I don't think it will be much
Having your EH code as optimized as possible is more important than amount of data you send
Traffic itself is not really an issue, serialization of it usually is
Serialization is CPU time just like EH code, traffic volume is a drop in the ocean nowadays
it's another issue
You don't need to send entire HitPart arrays either, just check the first entry, see if its same shot entity, if it is, skip
What you can do is assign same array into each shot and submunition so it doesn't delete along with projectile
having the attached EH callback which will be called on the client side, then sent to the server via the RE and fired second time to process. And sure, if the victims were local to the server HandleDamage will be fired too.
Its only 4 reactors per carrier, so it shouldn't be too bad for explosions and rockets. bullets will be problematic though if players damage with LMGs
Yeah, I understand. I just don't like that idea which basically duplicates the data sent and adds additional load to the CPU.
Well, its the only way to expand this engine, add slower scripted layers on top of existing engine events and data
Fired:
_shot setVariable ["reactors_hit", []];
_shot addEventHandler ["SubmunitionCreated", ...];
SubmunitionCreated:
params ["_shot", "_subshot"];
_subshot setVariable ["reactors_hit", _shot getVariable "reactors_hit"];
_subshot addEventHandler ["SubmunitionCreated", ...];
HitPart on reactors:
if(_this select 0 select 2 getVariable "reactors_hit" pushBackUnique (_this select 0 select 0) >= 0) then {
// First time this projectile or its children hit this reactor, send the data to server!
};
This is for 2.18, bit harder in 2.16 as projectile will be null in HitPart
I solved this by adding hit stack on relevant targets and projectile HitPart part adding to stack while entity HitPart pop'ed the stack
I only added this workaround for bugged simulations, other simulations don't need that
This can be solved a bit easier but less optimized by doing the check right inside the projectile HitPart. It will fire for everything it hit though.
// SubmunitionCreated
_subshot addEventHandler ["SubmunitionCreated", ...];
Does submunition create new "sub-" submunition in some cases?
Yes
I think arty mine shells do?
But its possible in the engine for sure
class AT_Mine_155mm_AMOS_range: SubmunitionBase
{
submunitionAmmo = "Mo_ATMineRange";
class Mo_ATMineRange: ShotDeployBase
{
submunitionAmmo = "ATMine_Range_Ammo";
Double submunition creation from same arty shot
yeah, I see
Just give us _shotID or _triggerID so we can identity all EHs fired from the single shot (including children submunitions) π
just one size_t / long variable π
Yeah, would be very useful to not jump through such hoops with shooter-side projectile and HitPart event handlers
@fair drum if you're going to do this client-side approach I can help with that 2.16 null entity bug fixed easier without any complicated stacks
can anyone advise on how to remove unlocked items from my antistasi arsenal?
Is there a way to detect when a player is talking in game with the microphone hotkey? Maybe input detecting the hotkey for speaking?
My goal is to make a draw3D a speaker above the player, but first step is figuring out how to detect VoIP activation.
https://community.bistudio.com/wiki/addUserActionEventHandler
The link above contains a link to a list of event handlers
voiceOverNet user action probably does what you want
But its more of a UI thing
So you might want to broadcast local talking state to others
alternatively if you have to detect the mic key, use key handler and inputAction
Hey, I am trying to create a script that physicalizes vehicle ammo(So you have an item for rounds and magazines). This is working quite well so far, however I seem to struggle with the vehicle smokescreens. The reloading itself works kind of wobbly with the addMagazineTurret-command. The HUD shows the added ammo only after reentering the commander seat, the reload-time is about 1 minute and it breaks it if you do anything.
When going near a rearmtruck the reload process only takes a few seconds and shows up just fine. Any idea why this happens?
PS: I only tried smokescreens yet, countermessures from planes/helicopters havnt been tested yet.
Do you guys have a suggestion for the sensible use of remoteExecCall ? E.g. is it already too demanding for this command the spawn a composition of about 20 objects?
Delete and add the weapon again for instant loading
Smoke screens usually take a long time to reload in the game
I guess it assumes your guy gets out to put the grandes into launchers or something
what's the fastest way to access specific array value (1-dimensional array) and increment it (without using select)
C++
++someArray[idx];
_arr set [idx, (_arr select _idx) + 1]; // <- garbage
Or ist this actually only usefully for really small operations like "hint" or "a+b"
garbage seems right π
we have vector commands but they require the array to have 2 or 3 elements
if you want to have fun, vectorAdd [0, 0, 0, 0, 0, 0, 1, 0, 0, 0] π€£
(Executed only on server)
well, vectorAdd produces new array instead of changing the old one π¦
PRO_arr = PRO_arr vectorAdd [1]; // 0.0009 ms
PRO_arr set [0, (PRO_arr select 0) + 1]; // 0.0011 ms
Same result with
PRO_arr = PRO_arr vectorAdd [PRO_arr select 0)+1];
Or to 1st
PRO_arr set [1,1];
You cannot compare diag time because using different solutions
the second line doesn't do anything, I need to increment the value
this is exactly what I need, it won't copy array to the new one with incremented (changed) value
set can be used but not without select
vectorAdd can be used but it makes a copy of array. Also for the big arrays you have to fill the vector with the zeroes:
private _arr = [1, 1, 1, 1, 1, ...]; // 1000 elements
_arr vectorAdd [0, 0, 0, 0, 0, ... 2, 0, 0, 0, ...] // add 2 to index 700
Or just ARRAY add INDEX
maybe ARRAY inc INDEX and ARRAY dec INDEX
Wanted that for a good while
Gonna use this moment to advertise my setN idea: https://feedback.bistudio.com/T178841
Several set in one call, also return array it operated on
private _pos = getPosWorld player;
_pos set [2, 0];
_obj setPosATL _pos;
```=>
```sqf
_obj setPosATL (getPosWorld player setN [2, 0]);
not sure about the syntax
ARRAY = ARRAY setN [INDEX_1, VALUE_1, ..., INDEX_N, VALUE_N, (BOOL insertOnly)];
But I understand the idea, with this setN is compatible with the regular set
I dont care about insertOnly flag to be honest, but its there by analogy with normal set's insertOnly flag for hashmaps
Array is flat to skip on creating arrays
Wish you could createHashMapFromArray with flat array like that too
muh microseconds
I mean, probably this one will be more consistent
ARRAY = ARRAY setN [[INDEX_1, VALUE_1], ..., [INDEX_N, VALUE_N], (BOOL insertOnly)];
or
ARRAY = ARRAY setN [[INDEX_1, ..., INDEX_N], [VALUE_1, ..., VALUE_N], (BOOL insertOnly)];
similar to getMagazineCargo format
the second option is good if in and/or find commands are used
The idea was to set many values in one go AND have set command that returns the array it operates on
Setting Z to position array is most used case, if array was two-dimentional, you'd have to do getPosWorld player setN [[2, 100]], extra array
Sure new arrays are fairly fast, but I was looking at most optimised way for both goals
Some existing command already use flat arrays too: https://community.bistudio.com/wiki/setAttributes
hey, the instance loading was a great tip. But I am not sure about the reloading duration. If you move up to an ammo truck it reloads within seconds. Also using my script the vehicle displays a reloaded state.
Ammo trucks reload existing mags (include empty ones)
So it reloads already loaded one
Interesting, good to know
thanks ^^
setVehicleAmmo also does that
But unlike normal spending while shooting which leaves the mags empty in the vehicle, the command deletes them
Doing setVehicleAmmo 1 will full up empty mags though
Well I "remoteexec"-ed the creation of a composition. Unfortunately it went really slow. Like one min for 20 objects. So I thought maybe it will be faster when I remoexeccall them. Or did I get the concept of using them wrong.
Since 2.14 they support all sizes. #community_wiki message
Drag it from the top until it becomes loose 
Then you can move/resize it freely
yep, that's good. But still not suitable for my approach though.
how do i cancel the Amb animation? whenever i [_unit, BIS_fnc_ambientAnim__terminate] remoteExec ["call", 0]; it stops animation for like 5 seconds then he goes into animation again
1- dont remoteExec calls
2- switchmove
nvm got it to work i anyways i just needed to use script instead setting anim from editor
If you use the 3den Enhanced animations you need to call a special function.
didn't know that
btw can u send me a function just in case im gonna need it?
ENH_fnc_ambientAnimations_exit
I wonder if I forgot to document that. Does it not show in the tool tip?
not sure but ty
any tips on using "user actions" with addaction?
like how am i supposed to tell player to use those π
You mean UserActions in vehicle class?
wdym?
the custom key bindings thing. like im supposed to let player know he can bind keys to the user actions number, that will trigger the addaction
Why not use modded keybinding instead?
user actions seemed more simple
yeah but modded keybinding is better :P
Get it working once and then it's easy to add stuff.
At least you know there's no conflict. How many user actions were there? 20?
so with modded keys can they trigger the addAction?
thx but i dont use CBA π
i just want to do this simple thing XD not become mod depend
it's good approach, less code -> less dependency and less errors
if someones modpack doesnt already have cba then theyre using exclusively shitty mods 99.99% of the time
don't need to be so rude π using framework(s) have its own pros and cons
CBA is not ideal, it has some legacy and slow code
prs welcome
binding some actions to the User Keys is not so bad
If someone doesn't want to use CBA just let them not use it. Everything can be done without it.
so i take modded keybinds wont work with addAction?
me watching the entire mod grind to a halt the moment i start using the scheduler
certain gamemodes just hanging because theyve run out of scheduler lenience
anyway what flavour crisps should i buy
I'm pretty sure modded keybinds will work as addAction shortcuts, although I haven't tested it.
shortcut: String - (Optional, default "") one of the key names defined in bin.pbo (e.g. "moveForward"). Adding available shortcut will bind corresponding keyboard key to this action. Shortcut availability can be tested with inputAction command
I'd definitely suggest using modded keybinds rather than using the pre-existing custom action keys if you can - it's much more cross-compatible with other mods. (If you're not making a mod then unfortunately you can't make modded keybinds)
It looks like modded keybinds are detected by inputAction, so they should also be detected by addAction - same system
great going to try that, thx all!
@lucid hill
don't let your users to use your custom settings as raw scripts!!!
it's huge security hole
by call compile <option> you basically let them execute the code via console
you're supposed to parse the string, filter all characters / symbols and assemble the structures rather than compiling number or the string into the code
_string = toArray _string;
_string = toString (_string - (_string - ((toArray "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.") + (toArray _separator) + (toArray _separator2))));
if it's an array split the string
private _result = if (_separator isEqualTo "") then {[_string]} else {_string splitString _separator};
if it's nested array(s) then call the split function recursively
I strongly recommend you to use the counter to control the call stack size
do not ever trust the user even if he plays ArmA π
(we're supposed to trust him)
I have 2 questions:
1- init vs postinit: What is essentially the practical difference (Both seem to do the same thing)?
2- Does having a script file that is triggered by an event handler have different behavior than code executed directly by the event handler?
yep confirmed
@shrewd nebula 1: https://community.bistudio.com/wiki/Initialisation_Order
- init is a stage where code in the init fields of the objects are executed
postInit is useful if you want to execute code if you want to be sure everything related to the specific object is up. For example you have object named "object":
// init. Set the flag which indicates not to move this object
this setVariable ["doNotMove", true];
// postInit. The code which moves the objects grouped in the array
// but only if an object doesn't have a flag set to true
{
if !(_x getVariable ["doNotMove", true]) then
{
_x call fnc_doMove;
};
} forEach allObjects;
2 - yes, there is slight difference between these two methods of using scripts. When you "trigger" a file (actually you're executing it) it reads from your drive, preprocesses, compiles and then executes. When you call a code directly, the function is already preprocessed and compiled. So it's about performance.
preInit stage is a good place to define your functions. But sure, you're not limited. You even can define the functions sent by the server via the network if you want to counter the thieves. Not very efficient but it can be useful for the events.
For example you're running something like Weekly Opene Games or Tushkino. You don't want to publish the mission file with the spawn points, mission tasks and other stuff. so people on the briefing time (10-60 minutes) could not unpack your mission and gain the advantage over others. You start the mission and all stuff, coordinates, tasks, objects, etc are loaded dynamically. Profit!
Also some script-based anti-cheats are loaded dynamically after mission start.
You have a choice.
if you're talking about init.sqf - it's just an option to use it or not
Oh, object event handlers.
Vanilla vehicles don't even agree on which one to use there :P
So, if I understood correctly, if I'm working on some gear randomization script/code, it would make more sense for it to be triggered by the postinit event handler correct?
I think you can do it even at init stage
keep in mind init code is executed on all machines, including JIP
I did some testing and it worked with both, but I was wondering if there would be some weird multiplayer interactions.
yes, it's possible. For example if you're randomizing the ammo box content using global commands. Each time someone (re)joins the server - the ammo boxes will have the different content
it will affect the whole server
in this case it's good to execute the code strictly on the machine which always persists inthe network - The Server.
for example
// init field, executes only on the server
if (isServer) then
{
// clear the cargo space of the object
clearWeaponCargoGlobal this;
// select random magazine classname from the list
private _randomMag = selectRandom ["magname1", "magname2", "magname3"];
// select random amount of the mag. From 1 to 6.
private _randomCount = ceil (random 6); // from 1 to 6
// Add the magazines to the object's cargo space globally
this addMagazineCargoGlobal [_randomMag, _randomCount];
};
so even if the player will rejoin, the ammo box won't have different content. The magz will be preserved because the content is under server control.
But if you remove the if (isServer) block, the behaviour of this script may lead to the problems
But sure you can intentionally randomize the content locally, just remove the isServer check and use local commands instead of Global ones
Alright, thank you. I may have learned quite a few things from this.
Will config.hpp be loaded automatically from the root of the mission folder?
No. Only description.ext. Config.cpp is for mods.
What is the difference beetween .cpp .hpp in context of Arma?
None
The extension just tells your code editor what language to do syntax highlighting for
Yes
.cpp and .hpp typically indicate C++ code (they're slightly different variants for different contexts in a C++ project - the difference is not important in Arma). Arma config isn't actually C++, but it's close enough that C++ highlighting will work fine.
Is it better to have config values which are usually constant in .sqf or in a config file? Is there any rule of thumb/common practice?
Depends if you need them in config.
Note that the preprocessor is (nearly?) the same for both, so it's common when writing UI to have files with just #defines that are included from both SQF and config files.
Currently, I use a single .sqf file which initializes all vars as global on the server, like this:
STMOD_CFG_spotAngle = 62.5;
STMOD_CFG_headVisTreshold = 0.50;
STMOD_CFG_bodyVisTreshold = 0.55;
STMOD_CFG_visionDetectCoef = [[20, 1],[500, 0.15]];
STMOD_CFG_detectMeterTimeout = 8;
STMOD_CFG_detectMeterStep = 0.20;
That's perfectly fine as long as you're certain they're initialised before they're needed.
Having them in SQF means they can be co-located with all your other scripts, and makes them easier to change later if you do need to do that. Having them in config means all the config stuff is in the config, and you can do things with inheritance and stuff like that.
There's not really a "one's better" AFAIK, it's just whichever suits your purpose or preference.
defines in include file is one way to go as well
just so that i do not have to write this ...
anybody already has a function which gets me the complement of an array?
Hi guys im trying to find a script that counts the amount of alive enemy units of a certain type are in the map. My goal is to adjust the amount of reinforcements to the number of HTV's alive in the map, to give the snipers a valuable objective that can change the course of the battle
For example: if there are 15 "B_support_AMG_F" then [ALIVE_globalForcePool,"BLU_F",2000] call ALIVE_fnc_hashSet;
if there are 10 "B_support_AMG_F" then [ALIVE_globalForcePool,"BLU_F",1700] call ALIVE_fnc_hashSet;
and so on
What's the definition of "enemy"?
And does it matter or is it fine to just count the types?
If I create an empty helipad (invisible) with this in the init field:
player createDiaryRecord ["Diary",[
"Mission Intel",
"some mission intel here"
]];
and then save it as a composition and place it in a public zeus session, why is it that only I get the briefing added to my player? My assumption was that when the helipad is placed in the world and synced with all clients, the init code runs on each client machine and therefore player belongs to each player's instance. I can't use remoteExec on pub zeus due to security limitations (it kicks you when you try), so is there a good workaround to adding intel via script mid-session?
init code of objects placed in Zeus, only fire on the Zeus machine
As opposed to all machines like the normal editor/game start
remember to remove the old empty magazine
I ran into this issue too
use:
removemagazineturret
addmagazineturret
loadmagazine
in this order
is there a script that will add custom unit patches to gear, or you have to mod each pack/uniform/vest?
for example, have someone looking to add unit patch to backpacks. would we have to mod each pack texture or is there a script?
Sorry, I meant "the amount of alive units of a certain class"
hey guys, is it possible to use volumetric fog in a specific area of the map only?
I am trying to imitate a zeus module with self-deleting helipad compositions. Does that mean that compositions like Enhanced Zeus Modules only creates modules that run on the zeus' machine as well? https://github.com/expung3d/Enhanced-Zeus-Modules
I can add my own custom modules to a fork of that project, but it will probably yield the same outcome and kick me from the server. I wonder if there is a way to achieve these without remoteExec
the old way of doing remoteExec before remoteExec was a thing, was to use a publicVariableEventHandler and sending public variables (this is what the CBA event handler system does)
https://community.bistudio.com/wiki/addPublicVariableEventHandler
{ alive _x and typeof _x == "unitClassname" } count allUnits;
through description.ext for your mission you do not need to have a mod. if you want it for every mission, you either have to put it in for each one, or make a mod
Thank you!
Ill test it in a couple of minutes
Doesn't apply to backpacks, vests, or any uniform not set up with insignia selections at the model level
I'm trying to figure out what to replace on this script `_o = _this select 0;
_o setVariable ["running", 1];
while {(_o getVariable "running") == 1} do
{
sleep 0.5;
_o animateSource ["motor_source", 1];
sleep 14.6;
_o animateSource ["motor_source", 0];
sleep 14.6;
};` I've tried to replace "_o" with my object's variable name but no animation starts or stops
I don't know if backpacks and vests support the insignia system at all, and I'm going to guess "probably not". Backpacks might support manually scripting a texture onto a patch-shaped selection, but most don't have one set up. Vests can't be retextured through scripting. Adding selections to any item requires changes to the model, which requires a) a mod and b) having access to the model.
You shouldn't replace anything. This script is designed to be "generic" and can be applied to any object (that has the animation sources in question).
The most efficient way to use it would be to make a function, but let's skip that for now
The script is meant to be used like this:
[object] spawn {
// insert all of that code here
};```
This creates a scheduled script thread (so sleep can be used), and passes your object reference into that thread. The script receives the object reference and turns it into _o.
oooh okay, I had a laptop with this addAction ["Start Mover","TargetMove.sqf",nil,1.5,false,true,"","",3,false,"",""]; Do I just scratch that and insert the script you pasted?
No. If you've already got it in a separate script file, then you can use that like a function (reusable piece of code called by name rather than typing the whole thing out each time)
So, there's a couple of ways to make this work in this context
Works perfect now thank you!
The first way would be to use addAction's arguments parameter (currently nil in your code)
Oh, okay then
but I think it could use a little cleaning up because I copied this this addAction ["Call Artillery","scripts\arty.sqf",nil,1.5,false,true,"","",3,false,"",""]; no clue what if the rest of the stuff is good
https://community.bistudio.com/wiki/addAction
Each of the elements of that array corresponds to one of the parameters mentioned here, in order
You probably don't need any of the ones after 3 (radius) because they're all optional, they're all currently set to their default values, and I don't think you need to use them for this purpose. But, since they're set to the default values, they're not hurting anything by being there.
I appreciate your help man, I told myself I'd give it a week and just an hour ago I figured out the sqf was in the pbo lmao
Thanks for the hint. This doesn't seem to have any impact on my issue though. Reloadtime is still around 70 seconds.
yeah I dont think the readding the weapon thing works for vehicles
is it possible to turn the keyboard code/number to the letter (string)?
sorry what?
like you have DIK_K for example which represents a number but can you turn it to "K"
well yes of course, see https://community.bistudio.com/wiki/keyName
nice , ty π
The reason CBA keybinding exists, is because the game itself didn't allow adding keybinds.
But now the game does support modded keybindings.
I have a question, this code below deletes a vehicle when player is 2000m distance away, but I don't want the vehicle to get deleted if any blufor unit was a driver of this vehicle. I tried changing the variable name of the vehicle setting it to "nil" but it still gets deleted, obviously this is a local variable. so How can I achieve this?
_vehicle spawn { waituntil { {_x in _this} foreach (allunits select {side _x == Blufor}) };
missionNamespace setVariable ["_this", nil, true]; hint "blufor driver";
waituntil {player distance _this > 2000}; deletevehicle _this; hint "delete vehicle";};
Your forEach there is nonsense.
waituntil { {_x in _this} foreach (allunits select {side _x == Blufor}) };
is equal to
waituntil { ((allunits select {side _x == Blufor}) select -1) in _this };
which doesn't seem like you intended that.
missionNamespace setVariable ["_this", nil, true];
_this is a local variable, you cannot set local variables with setVariable.
And you can especially not make local variables public (with that last true)
So you want
if (player is > 2000m away AND the vehicle does not have a blufor driver inside it) then delete the vehicle
right?
yes exactly
instead of going through every unit that exists, and checking if they are in the vehicle.
Which might be hundreds of checks when only one unit is in the vehicle.
You can instead go through every unit in the vehicle, and check if they are blufor. Which would only be one check, instead of hundreds
you specifically only want the driver seat? Your old in code would check any seat
any seat, doesnt matter if driver
waitUntil {
(player distance _this > 2000) && (((crew _this) findIf { side _x == blufor }) == -1)
};
deleteVehicle _this;
Wait until:
- player has more than 2000m distance to vehicle
AND - trying to find a bluefor unit, inside the vehicles crew/passengers, doesn't find anything.
I would also recommend adding a sleep 5; into the top of the waitUntil, so it only checks every 5 seconds and doesn't waste as much performance
(and deleteVehicleCrew?)
thanks i didnt think of "findIf" , let me try it
alternative to findIf would be count.
Count number of blufor units in the crew, and check if the count is zero.
But if there is blufor unit inside, findIf is more efficient
thanks really nice explanation
if i use switchMove on if isServer do i need to remoteExecute it?
switchMove takes local argument, so if its player unit run switchMove on client, if the unit is local to the server then run switchMove on server
oh that's why i didn't see animation on player gotcha now so if i spawned createUnit on server i don't need remoteExec switchmove
yes just run all the code in server
Accessing "Options" is not so critical as having FPS drops playing badly coded missions. I prefer to have better Quality of Life (FPS) than having instant access to the menu which used in ~1% of my playtime.
or even less
Hello. What is the right way to remote call a function? Let's say, remote call to a side or group in specific
Okey but you can get both, access to menu and fps..
[_unit, _group, _height] remoteExecCall ["PIG_fnc_haloJump", _group];
like this for example?
so no sleep, etc?
yes, no sleep, no slow code
damn it... is there another way?
remoteExec
remoteExec
well, I tried that but seems it doesn't work
as a test use old good hint
"Hello, World!" remoteExecCall ["hint", _group];
"Hello, World!" remoteExec ["hint", _group];
It should work
also
Group - the order will be executed on machines where the player is in the specified group (not where said group is local!)
if the specified group is local to some player but the player is NOT in that group, the order will not be executed
assuming, the _group has at least one real player
yes
on host it's working just fine, this problem I have on dedi
If you just want something remoteExec'd once at group locality, you can use groupOwner _group
if you're using CfgRemoteExec, make sure the function is whitelisted
i'm using CfgFunctions
So what exactly are you trying to do?
i'm gonna put it on github
Hey, I am trying to get the initial Speed of a magazine. However, the hint shows me the Path instead of the value. Why is that?
Thanks for helping ^^
private _currentMagazine = currentMagazine _vehicle;
private _muzzleVelocity = (configFile >> "CfgMagazines" >> _currentMagazine >> "initSpeed");
hint str _muzzleVelocity;
getNumber
jup, was missing that >.<
Do not use getNumber π
thanks a lot^^
some values in the config can be presented as a plain text, then evaluated to the code which return the NUMBER. It mean if you will try to extract the value with getNumber, it will throw an error, "String blah-blah-blah... expected Number blah-blah-blah". In this case it's better to make a small function which check the type of the value and then extracts it converting to number if it's text. Something like this:
fnc_GetConfigValueAsNumber =
{
if (isNil "_this") exitWith {-1};
call
{
// If config value is number - just extract
if (isNumber _this) exitWith
{
getNumber _this;
};
// if config values is text - extract and compile
if (isText _this) exitWith
{
call compile (getText _this);
};
-1;
};
};
Here is example where numbers are replaced by the text:
ACE Realistic Dispersion mod / component:
// GM6 Lynx
class GM6_base_F: Rifle_Long_Base_F
{
class Single: Mode_SemiAuto
{
dispersion = QUOTE(MOA_TO_RAD(0.45));
};
};
That mod is garbage, don't use it :P
it doesn't matter, I only show it as a sample. Jeroen's Arsenal has the same issue. He extracts numeric values as text and the game throws an error.
Antistasi still affected by that
You have to be sure you're extracting number when using getNumber.
Is there any actual reason why they're using QUOTE there though?
No idea
I'm not sure if you can trust the game to process those correctly.
It's often done with UI stuff because you need dynamic commands like pixelW
but this is just constants.
well, for example I'm using text instead of number in one of my projects:
// M200 Intervention
class LRR_base_F: Rifle_Long_Base_F
{
class Single: Mode_SemiAuto
{
dispersion = MOA_TO_RAD(0.50);
aiDispersionCoefX = "(1.4 * 0.00018) / (0.5 * 0.00029088)";
aiDispersionCoefY = "(1.7 * 0.00018) / (0.5 * 0.00029088)";
};
};
It's just better to understand for me what I am doing π
sure, it's just a constant
shouldn't you use __EVAL?
btw the aiDispersionCoefs are only read from the weapon config, not the fire mode.
Yeah, I tested it once.
And made notes for a change.
Dispersion is read from the mode, aiDispersion is read from the weapon.
hm
Set high enough values and the effects are pretty obvious :P
Okay, good to know. I'll take a look.
is it possible to use createUnit to spawn unit with exact name for exp his name is John Johnny without using setIdentity or set name after spawning him?
If you created a unit config with that name, I guess.
seems weird to ask that in a scripting channel though :P
if it's related to speed of execution you can use critical section
i've created identities in desc.ext but they only work in sp
isNil
{
...createUnit...
...change name, identity, sex, habits, favourite music and movies...
};
I don't what I did, but my function is now working on dedi π it's arma
setIdentity is local-effect so you need to run it everywhere, including JIP.
i've used this [u64_maddox, "Maddox"] remoteExec ["setIdentity", 0, u64_maddox];
the exact code you posted on git hub?
yep
but yea nvm i think it's probably due to DUI radar not reading the names cause i think code is correct
see if you can find anything weird
ACE name needs to be set separately. Not sure what DUI uses.
ik it works in SP i've delayed spawns on each units cause when they spawned all on same time nobody recived name so i delayed a lil bit and i can see names in SP but when im playin MP i haven't seen any names, but i do see name i've set when i go edit unit with zeus
Where are you looking?
when you dobule click on unit u want to edit in zeus u can see his name is correct as i set it but im seeing different on DUI radar
make all local variables private and add prefix to all globals
what do you mean by prefix ?
Global variable without prefix: myVariable = 1;
Global variable with prefix: PiG_myVariable = 2;
PiG_ is your prefix
Ah okay
if you don't do that there is a high risk of intererring the same named vars
but the rest of the code is okay?
this type of errors is very hard to debug
use private keyword when you define your local variable, for example
Looks like DUI has its own name variable that gets set on unit init.
scripts/PiG_halo.sqf
_teltime = 5
// must be
private _teltime = 5
why do mods do this :/
but idk hows it working on SP but not on MP π
timing.
anway i can change it?
lol
btw u said timing u mean i need to spawn them in same time to see name i want or?
pronounced as "Kugvar"
actually there might be at least two different vars you need to set.
thank you @bleak gulch
I mean you're fighting against a mod that's doing something at a time that Arma doesn't define.
wait, it also has a loop over allUnits setting this shit?
are you talking about DUI?
yeah
the nametags PBO specifically, which I'm not sure is even the one you care about :P
_x setVariable [QGVAR(name), _x getVariable [QEGVAR(main,customName), _x getVariable ["ACE_Name", name _x]]];
...beautiful
Maybe you can just set ACE_Name.
yea
I mean i just don't understand how it works in SP but not MP π
yea after seeing this i think i'll just leave them as they are i mean nobody's gonna look at names really it's just some details i wanted to include
Are you running ACE btw?
yea both ACE and DUI
Ok, worth a shot to just _unit setVariable ["ACE_name", "whatever", 0]
the names make sense if you're running campaign
Although that's faster than remoteExec timing so it might not work.
i mean im making BHD based on movie and i wanted to add some details like unit names for crucial Units
that's good approach.
some that are made in editor have names so i wanted to make them then all have names ik were said in movie
Actually better:
_unit remoteExec ["ace_common_fnc_setName", 0];
actually, make your own function that runs setIdentity locally and then the ace function.
Otherwise you can't guarantee the order with setIdentity.
but try that remoteExec as a test first.
Not really clear whether DUI will pick up on it or not.
so how do i include it then in my script im kinda lost tbh π
Needing some help with positions and stuff, Currently doing some floaty BS and its grabbing the player's model to world with an offset to set a positon to where the player moves, Currently it only functions with 6 positions all relative to the map [x,y,z], And with it being static directions diagonals work fine, But now after swapping back to modelToWorld X isnt always X relative to the player and diagonals wont work because of that. Anyone have ideas on how I could fix that?
findDisplay 46 displayAddEventHandler ["keyDown",{
params ["_ctrl","_key"];
_posArrow = getPosATL arrow;
_pos = getPosATL player;
newPos = _posArrow;
newPosX = _posArrow;
newPosY = _posArrow;
newPosZ = _posArrow;
if (_key == 42) then {
WBK_Boost_Capacity = player getVariable ["WBK_Boost_Capacity", 1000];
if (WBK_Boost_Capacity <= 0) exitWith {WBK_SpeedFloat_Acc = 6};
WBK_Boost_Capacity = WBK_Boost_Capacity - 10;
player setVariable ["WBK_Boost_Capacity", WBK_Boost_Capacity];
player setVariable ["WBK_IsBoosting", true];
WBK_SpeedFloat_Acc = 12;
};
if (_key == 57) then {
//arrow setPosATL [_pos select 0,_pos select 1,(_pos select 2) + 6]; Up
newPosZ = [_posArrow select 0,_posArrow select 1,(_pos select 2) + (WBK_SpeedFloat_Acc / 2)];
};
if (_key == 46) then {
//arrow setPosATL [_pos select 0,_pos select 1,(_pos select 2) - 6]; Down
newPosZ = [_posArrow select 0,_posArrow select 1,(_pos select 2) - (WBK_SpeedFloat_Acc / 2)];
};
if (_key == 17) then {
//arrow setPosATL (player modelToWorld [0,WBK_SpeedFloat_Acc,0]); Forwards
_vel = (player modelToWorld [0,WBK_SpeedFloat_Acc,0]);
newPosX = (player modelToWorld [0,WBK_SpeedFloat_Acc,0]);
};
if (_key == 31) then {
//arrow setPosATL (player modelToWorld [0,-WBK_SpeedFloat_Acc,0]); Backwords
_vel = (player modelToWorld [0,-WBK_SpeedFloat_Acc,0]);
newPosX = (player modelToWorld [0,-WBK_SpeedFloat_Acc,0]);
};
if (_key == 30) then {
//arrow setPosATL (player modelToWorld [-WBK_SpeedFloat_Acc,0,0]); Left
_vel = (player modelToWorld [-WBK_SpeedFloat_Acc,0,0]);
newPosY = (player modelToWorld [-WBK_SpeedFloat_Acc,0,0]);
};
if (_key == 32) then {
//arrow setPosATL (player modelToWorld [WBK_SpeedFloat_Acc,0,0]); Right
_vel = (player modelToWorld [WBK_SpeedFloat_Acc,0,0]);
newPosY = (player modelToWorld [WBK_SpeedFloat_Acc,0,0]);
};
newPos = [(newPosX select 0) + (newPosY select 0) - (newPos select 0), (newPosX select 1) + (newPosY select 1) - (newPos select 1), (newPosX select 2) + (newPosZ select 2) - (newPos select 2)];
arrow setPosATL newPos;
}];
kek
i can send you the script file if u want
Don't. Just try it in the console
Question is whether the method can work at all. It'd take me a full day to disentangle DUI to be sure otherwise :P
You can tell whether the command worked by what name is shown in the ACE medical display, but then it's an open question whether DUI picks it up.
unpack DUI and find where it picks the name, from which variable and / or command
yea i think neither ACE picked it up in MP cause as i said i see name i've set when i open unit in zeus editor but when i killed it and picked up dog tag it was different
Yeah, that's normal.
Why don't you use vectorized commands?
newPos = [(newPosX select 0) + (newPosY select 0) - (newPos select 0), (newPosX select 1) + (newPosY select 1) - (newPos select 1), (newPosX select 2) + (newPosZ select 2) - (newPos select 2)];
It's basically adding / subtracting the vector components
I didnt think of useing vectors, good call. Got an idea on implementation im stumped on vector stuff tbh
alr so u said to make it locally how do i do that? my command is ran on if isServer
You know how to use the debug console, right?
yea nvm i tought u said to make script to only run locally
I'm just telling you to test whether changing the ACE name (locally) also changes the DUI name.
The ace function, run as local is just _unit call ace_common_fnc_setName;
but you'd need to identify the target unit somehow.
cursorObject if you can walk up to them.
i'll spawn unit on me w name so i'll try that
getNumber would evaluate the string to a number, not throw an error.
weeeell, c1_steele setVariable ["ACE_name", "Steele", 0]; works
IIRC there is a good reason to call the ACE function instead :P
but I guess you have a potential solution now
just tested, it works for some reason, weird.
I bet in the past I had bad experience with the numbers coded as strings in the config!
That code in the wiki comment for getNumber would break, I guess, because it checks isNumber.
I wonder if the engine ends up running multiple SQF snippets to fire each bullet.
yep
// a text
// aiDispersionCoefX = "(1.4 * 0.00035) / (1 * 0.00029088)";
isNumber (configFile >> "CfgWeapons" >> "srifle_GM6_F" >> "Single" >> "aiDispersionCoefX");
returns: false
case (isNumber _cfg): { getNumber _cfg };
just won't work
No because its loaded once and cached
BIS_fnc_getCfgData does the same thing and would return a string.
you a legend love ya it's working
exactly, user has to "type cast" the extracted value explicitly
Or you just use getNumber because it's supposed to be a number :P
For some reason it didn't work for me year or two ago. I see it works fine for now. What happened?
shrugs
Its been like this since ofp
or arma 1.. whenever configs were introduced
Can you clarify what's the best practice?
// CASE 1: contains variable, which initialized at runtime
x = "3.14 * r * r / 2";
y = __EVAL(3.14 * r * r / 2);
// CASE 2: no variables, just expression
w = "3.14 * 1 * 1 / 2";
h = __EVAL(3.14 * 1 * 1 / 2);
Eval will evaluate it at game start when config.cpp is loaded.
For config.bin it depends on what the Tool binarizing the config does.
The other is executed on access
Eval is config parser so it would run at parse time.
If you have a binarization tool like CfgConvert, that can execute the script when it packs it to config.bin. that's the best way.
With variables it cannot pack it into bin and I don't know if it will do a eval at load or at access then.
Your w and h example though looks like it's for a UI.
And these usually depend on uiSize and screen resolution.
So if you pre-evaluate these offline, or at game start. Your UI will get messed up when user changes resolution or UI scale
__EVAL works good in mission (also mis configs) #defines
Eval has nothing to do with preprocessor and #defines
Also you must use eval if you want to script a string entry.
dunno, i just do #define CALC_PRICE(p) __EVAL( ceil (p) ) for mission config stuff etc
@winter rose I think @still forum answers should be placed somewhere in the BI Wiki, because it's a bit confusing when you have two ways to use expression in config.bin but has no clear way to do that.
IDK, we have this? https://community.bistudio.com/wiki/PreProcessor_Commands
we have, but there is no use-case examples for the __EVAL vs " "
pls provide, I don't know these things π¬
oh... it was Mikero responsible for the __EVAL, okay)
Only usecase I've seen is random loading screen in description.ext
why would you remoteexec it?
so as I understood for the config.bin, at runtime it's better to use TEXT if there is/are variable(s) involved into expression. And __EVAL if expression is not dependent from the variable(s) (or any data which can be aquired at runtime) and it's just a constant, because that expression can be evaluated by the PBO packer saving some CPU time on game load?
(for info, his edits were reverted in this section)
link for quick reference: https://community.bistudio.com/wiki/remoteExec
I am currently having an issue with remoteExec jip.
Case 1: I call a remoteExec spawn that adds multiple actions to a data terminal object.
fnc_function = {
params ["_terminal"];
_reString = [[_terminal],{/*Add Actions and hint 'hello world' for testing*/}] remoteExec ["spawn",0,_terminal];
hint _reString; // Hints "2:6899"
};
[_terminal] call fnc_function;
This is not JIP as when I connect a second client, it does not run on and does not hint a jip player.
This is ran in debug console using local exec.
Case 2: I run the remote exec directly in debu
_reString = [[terminalObject],{/*Add Actions and hint 'hello world' for testing*/}] remoteExec ["spawn",0,terminalObject];
hint _reString; // Hints "2:6899"
This is JIP.
Both return a jip string, but only case 2 works.....
Does anyone know why?
[_terminal] call fnc_function;
is _terminal defined in this scope?
probably should be
[terminalObject] call fnc_function;
A limitation of remoteExec JIP using the object as JIP ID is that you can only do it once. If you have any other code that uses the same object as JIP ID then only the last one executed remains in the JIP queue.
Typo in the retype there. Its defined.
Figured that out. Working around.
Hello, Iβm working on a single player campaign.
Iβm having trouble saving the inventory of a crate and loading its inventory in another mission. Does anyone know how to do this by chance?
I got it to work with the playerβs inventory, but canβt seem to get it with a weapon crate
You can:
- Save it to the players profile namespace.
- save it to the servers profileNamespace (if its persistent through resets.)
Save it to campaignNamespace.I thought i read something about there be campaign something namespace, maybe not?- Save it to missionProfileNamespace https://community.bistudio.com/wiki/Description.ext#missionGroup
^
Thanks!
@nocturne bluff: Not sure if I ever showed you this: https://forums.bistudio.com/topic/185591-end-game-spectator-feedback/#entry2932360
Does anyone know how to use Jeroen-Notenbomer/Limited-Arsenal? Like adding it to a mission? Read the readme and still having issues
Server-side init:
["Preload"] call jn_fnc_arsenal;
arsenalBoxObject call jn_fnc_arsenal_init;
Then to add the action on clients:
arsenalBoxObject addAction ["Arsenal", jn_fnc_arsenal_handleAction];
This assumes that you have it registering the functions already.
Thank you, got it working. Just need to figure out where to add stuff in at
Didn't mean to ask the question here <.<
RopeCreate implies that it has to be a transport vehicle that you spawn a rope from. Is there any way to spawn a rope dangling from an arbitrary item / connecting two arbitrary items?
huh, they don't even define transport vehicle. They just give a list...
Yeah, the wiki's vague, and I just want a rope dangling off of a ledge.
I guess you could attach one of the smaller objects there and hide it.
this list is hurting my soul
@hasty violet yes, the group will have additional calculations
but those are async anyway and you do not rly need to care about em as they are no massive performance impact
write your scripts nice
that will affect the performance more then some additional groups running native code
That list smells like such BS. The broken wave power buoy is counted? Helipad lights? Sound set sources? And this was updated somewhat recently too since it's got Contact stuff. Someone's been actively checking this.
There must be something, config probably, that actually controls this, and they just haven't figured out what. Or it's actually just any PhysX object and the person who wrote this is an idiot.
itβs bothersome to not have some invisible helper objects
like rope attach point objects with good simulation
mods like CBA add these, but they should be in vanilla
same with things like invisible AI targets
My educated guess would be that more groups require more computing time.
I have faked an underground chamber during a night mission. Problem: the moon is reflecting on the water. Figured I could hide it using setDate in a trigger when players enter/exit. But I read that date values are periodically synchronized with the server. What would you recommend as a solution?
Maybe weather is a workaround
I tried setOvercast, and it sortof works. Will have to disable environment sounds as well. But isn't that also synchronized?
Ah I see the situation. Honestly quite a very hacky workaround I could think is just this: https://community.bistudio.com/wiki/diag_setLightNew
Very cool. Can you recommend/link me some default values?
An example would be located in configfile >> "CfgWorlds" >> "Stratis" >> "Weather" >> "LightingNew" >> "Lighting0" and other classes. Since it should have completely different lighting in and out, you can re-write the lighting I guess?
It would require a bit to get the desired result though
if __EVAL cannot be evaluated, it will probably be turned into text and doesn't matter as the end result is same as if you used text right away.
Rather the difference should be __EVAL for everything that is constant at game start.
and text for everything you want to be evaluated on every config read. That's probably a better definition
__EVAL shows error if something goes wrong
but sometimes it fails silently and config variable when obtained with getText will be "scalar NaN". or "any" in some cases
waitUntil {isTouchingGround player}; hint "Player on ground";
why does this not work? even if player is in some height it still triggers
where you run that?
in an active trigger
does the player start in air?
Why you're using waitUntil within a trigger?
yes
just testing
Even if it is a test, what is the concept you want to achieve
Because a trigger already waits the condition to filfull
the script should work probably issue is where its being run
its for an enemy group that spawn dropped by helicopter, once they are on ground they start hunting/ moving to player
but dont you need to check the enemy soldiers rather than player in that case
true, but i always like to test before creating a whole code
oh ok
The point still stands. You can use a Trigger or waitUntill, not both
Also you can't even use waitUntil within Trigger's onActivate too
I am trying to get players to teleport between ladders, in order to make a tunnel entrance sort of seamless. See picture. Problem is that I don't know how to teleport players between ladders (the dotted arrows). The command-
player action ["ladderUp", ladder_1, 0, 1];
Will move players unto ladders, but not if they are currently climbing one. In that case, the command will execute once the player steps off their current ladder. I tried using actionNow, but am getting a syntax error. Does anyone have experience with this?
PS please don't make fun of my colonoscopy sketch.
Unfortunately you can't. Ladders are one of the most not loved feature
Also actionNow is a 2.18 command
i just tested the code in an eventhandler in sqf file, but still triggers even if units in air
if ({isTouchingGround _x} foreach units hunt_group1) then { hint "hunting group"; hunt_group1 move position player;};
Wait you're not using a Trigger?
foreach doesnt go to if use count instead
And what is the eventhandler you mean here
"foreach" is working, "count" not working, also its an eventhandler "suprressed" that runs everytime an enemy shoots towards player, in conclusion everything is running smooth, only the "isTouchingGround" doesnt work properly, it triggers even if units in air
if ({isTouchingGround _x} foreach units hunt_group1)
That code is equal to
if ( isTouchingGround ((units hunt_group1) select -1) )
You are only checking the last unit in the array
still same issue, even if units in air it still runs the code
How does the unit get into the air?
it was spawned in air originally
by itself without any vehicle?
by itself then using the code "moveInAny" to get it into vehicle
So by the time you call isTouchingGround, its in a vehicle?
yes also in air
https://community.bistudio.com/wiki/isTouchingGround The comments at the bottom say it won't work when inside a vehicle.
You need findIf
It works for me if unit is not in vehicle
if (isTouchingGround player) then {hint "Player on ground";};
but even the simplest codes like this wouldnt work why?
units hunt_group1 findIf {!isTouchingGround _x} == -1
It means all units are touching the ground
Just testing in debug console, it works for me there
Are you in a vehicle?
If units are in a vehicle you need to check if the vehicle is touching the ground:
units hunt_group1 findIf {!isTouchingGround vehicle _x} == -1
For that one:
if (isTouchingGround vehicle player) then {hint "Player on ground";};
seems like this one is working perfectly, let me do some more tests on it, thanks all for the help as well
Is it possible to set custom AI Interact actions for objects? Like how you can point to a vehicle and have the contextual interact option "get in"
They mean the AI command menu
Ok, but how? At the moment I can only get a unit to execute a custom action if the action is added to the unit, not the target object, and it shows up in the unit command menu 6, not as the contextual interact action like "Get In" does, for example.
Afaik no. But you can check for yourself
iirc the class name was RscMenuRoot or RscMenuGroupRoot (or maybe main instead of root)
In config
You can probably add your own items to it, but not sure if you can interact with an object with it (i.e. whether it's context aware and whether it passes the context object to the script)
Thanks for answering, that seems more complex than the addAction option so I'll go with that. Do you know if it's possible to order AI to execute an action set on an object or does the action need to be set on the AI?
addaction is something used by the player
Depends what action
It is but you can execute its code and pass your own parameters to it
But it depends if the script handles it correctly (e.g. does it correctly use "_caller" or does it just use "player"?)
Hey there, Im looking for a script that allows for ambient AA fire in the backround. Burst of like 3 seconds then a pause for 5 etc and rearm script if possible
you have any scripting skills?
well i hope you find what you are looking for

Your requirements do not a highly experienced scripter. Here's a couple of links. Have at it:
https://community.bistudio.com/wiki/forceWeaponFire
https://community.bistudio.com/wiki/setAmmo
https://community.bistudio.com/wiki/sleep
https://community.bistudio.com/wiki/Control_Structures#Loops
- lockCameraTo if you want to fire at dummy targets
appreciated
not sure where to ask but, prob asked before too, any suggestions how to prevent videos from having delayed sound when played with BIS_fnc_playVideo? Idk if that's due to my recording software or it's just arma being arma
thanks ian but I was hopng for a proper formula rather than another loop
I was thinking 70/distance should cut it
have you checked this https://community.bistudio.com/wiki/OGV_File_Format ? i dont know if that helps
will check
@tranquil nymph lets hope, the next best solution is selectplayer into the unit
You can check whether it's your recording software by playing the video in a normal media player outside of the game. If it's also desynced there, then it's your recording software.
Has anyone got a KAT class name list?
For whitelisting in the arsenal, just to save time
What's the best way to convert an object to a simple object in place for MP? Can I do something with the init fields in a way that holds up if I need to copy and paste objects a lot?
Some way that scales into the low hundreds would be ideal.
I'm trying to make a vehicle destroy if it receives greater than or equal to 0.5 damage, can someone fix this?
{this addEventHandler ["Dammaged", {if ((_this select 2) <= 0.5) then this setDamage 1;}];}
Hello guys, does any of you know how I can, roughly speaking, synchronize all events which fired in a single frame. I mean, how I can be sure, that all the EHs in that frame has already been executed before I execute a follow-up function which would do something based on those events, like solve a conflicting situation, etc. The only thing I came up with is to do the generalizing operation in the frame right after. What do you think? Thanks
Like this:
EH1,
EH2,
MyFunction.
Not like this:
EH1,
MyFunction,
EH2.
probably recreate it with createSimpleObject
Yeah, my question is more like "should this just be run in the init field"
i.e. how do I properly do this in a way that's JIP friendly
this addEventHandler ["HandleDamage", {private _damage = _this select 2; if (_damage >= 0.5) then {1000} else {_damage}];};
or [_damage, 1000] select {_damage >= 0.5};
you have to experiment, extract object's classname, vectors, position, variables, hp, animations. Delete object and then recreate. Should be possible from the init.
I think you intend on these being flipped?
[false, true] select (bool)
ah.. yeap... have to fix
gets me every time. you'd think it would be [true, false] intuitively
Is there a way to get both the vector dir and up in a way that enables one to run setvectordirandup safely?
