#arma3_scripting
1 messages · Page 123 of 1
because you're comparing Number to Bool
you probably meant switch true do ...
_array select {!isNil"_x"}
but yeah, fix the original issue that puts it there in a first place
In the actual script, "_var" will be an integer that is derived earlier. That integer can be between 0 - 100 .
if you'll have your cases returning bools, switch true do will work fine
Ok, thanks.
NaNs aren't nils. You'd probably have to use finite
Is there a script or code that can be put in a vehicle init in EDEN to prevent players from switching to the gunner's seat of a vehicle, but still allow them to switch to other seats in the vehicle? Ideally one that removes the listing of the gunner position from the command menu / scroll menu entirely when boarding or inside?
Anyone know some good guides for using what little I remember of high school vectors to learning how they work in arma? I'd like to start out knowing just how to create the XYZ lines that come out of an object and then work from that to get a position like [1,0,1] away from that object kinda like modelToWorld but also taking the objects rotation into account
Thanks!
modelToWorld does take the object's rotation into account.
If you want to ignore the object's rotation, and work entirely in world space, then get the object's position with getPosATL / getPosASL and then use vectorAdd to apply your offset.
oh my test was bad that's why I thought it didn't take rotation into account
Is there a script that I can use to respawn AI and players into the same vehicle? I'm making a mission using tanks with AI crews and a player as the tank commander. Is there anyway I can have the tank respawn with the crew and player in it?
When you say respawn.. respawning at the start of the mission? Or each time someone dies?
When someone dies
Because I can respawn the vehicle with a crew using the vehicle respawn module and the expression to respawn a crew but I can't figure out a way to get the player back in the tank as the commander
you can either save the current player to the tank's variable namespace and reference it using the old vehicle argument that is passed on the vehicle module respawn expression, or you can forgo the vehicle respawn module all together and just build the tank with a respawn event handler or onPlayerRespawn.sqf, move your player, then add the crew
I'm trying to have a script where the subject object will first store the relative values of position and rotation to the origin object and then try and make it so they stay the same no matter the future position or rotation of the origin. The positioning seems right but the rotation math is wrong somewhere and I'm not sure as to why.
params ["_originObj","_subjectObj"];
//-- Relative Positioning
private _relPos = _originObj worldToModel getPosATL _subjectObj;
//-- Relative Vector Dir and Up
private _originVecDir = vectorDir _originObj;
private _subjectVecDir = vectorDir _subjectObj;
private _diffVecDir = _originVecDir vectorDiff _subjectVecDir;
private _originVecUp = vectorUp _originObj;
private _subjectVecUp = vectorUp _subjectObj;
private _diffVecUp = _originVecUp vectorDiff _subjectVecUp;
while {alive _subjectObj} do {
//-- Set Relative Pos
private _newRelPos = _originObj modelToWorld _relPos;
_subjectObj setPosATL _newRelPos;
//-- Set Relative Vectors
private _originVecDir = vectorDir _originObj;
private _originVecUp = vectorUp _originObj;
private _addVecDir = _originVecDir vectorAdd _diffVecDir;
private _addVecUp = _originVecUp vectorAdd _diffVecUp;
_subjectObj setVectorDirAndUp [_addVecDir,_addVecUp];
sleep 0.001;
};
Have you considered just using attachTo?
this is practice for a mod I'm making where I need to store these relative values so when something gets built all the objects are in the correct locations if that makes sense
Hey, I'm trying to use init eventhandler to execute a script on vehicles that were already present in Eden editor or added later in zeus session though I'm not sure I understand how this particular EH works. I put this in description.ext like this
{
class DNTcargoSize
{
class SetCargoSize {
init = "[(_this select 0)] execVM ""DNT_supplies\DNT_setCargoSize.sqf;""";
};
};
};```
Is it a correct way of using this EH? Also does '_this' in this case refer to created object?
Do you mean it does work or not? I'm not a CBA user so can't tell how it should be but according to some documents I'm doubting it will work as you intended
Yeah it doesn't work. I never really used EH that require being used in configs that's why I'm looking for pointers where should I put it so it "fires" as expected
What is your actual intention then?
Script should fire whenever an entity is created during zeus session (for example zeus places a vehicle, script executes on this vehicle)
Then I guess cpp class Allinstead of cpp class DNTcargoSize
Ah I see didn't realise class name was important. So putting this in description.ext is a valid way?
Probably
Cheers going to give it a shot ;)
Anyone able to help with this? 
omfg I figured it out
you can literally just check if the vehicle you're executing on is local, and if it is, run the code
that way nothing gets messed up by being local to server and still spawns only once
I will never mentally recover from this
I am trying to add a line of code that teleports the player to the officer (Which Is a player) and If the officer Is In a vehicle with seats place the player In one of the seats.
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
this addAction ["Teleport to Officer", {
params ["_target", "_caller", "_actionId", "_arguments"];
if !((incapacitatedState BlueForCommander)== "UNCONSCIOUS") then{
_caller setPosASL (getPosASL BlueForCommander);
};
}, nil, 1, true, true, "", "true", 5];
I'd structure it like:
If (BluForCommander unconscious) exitWith {too bad};
if (vehicle BluForCommander != BluForCommander && (vehicle BluForCommander emptyPositions "") >= 0) then {_caller moveinany vehicle BluForCommander}
else {_relpos = BluForCommander [.5, 180]; _caller setpos _relpos}
I will try this line of code. Thank you for the response.
Will need some cleaning up, probably, but it should be straight forward enough XD
Hey I'm just making a little thing where all the players on the server are going to be teleported to a new area after their screens fade to black.
This is on a trigger set to server only, just I'm not sure what I should be setting the "Player" variable to in this case to get it to work.
The fade in and out is done on another script that works fine for now.
{
player setPos (getPos TP1);
player setUnconscious true;
} forEach allPlayers;
player here only points one unit, I'm not sure the context how you've run this script but I assume you want _x
probably that's it I'll give it a test. This is just on a trigger set to server only, the players enter it while flying through it in a vehicle and it teleports them to a crash site after a fade out done on another script
there's also the slight problem of teleporting everyone to the exact same location.
is there a way to make it teleport people between one location and another like [1000,1000,5] to [1010,1010,5]?
[1000,1000,5] vectorAdd [random 10,random 10,0]```
awesome thanks Polpox, not getting any errors with this,
x_ setPos ([1000,1000,5] vectorAdd [random 10,random 10,0]);
x_ setUnconscious true;
} forEach allPlayers; ```
though just testing it by hosting a MP session on my computer and nothing is actually happening. I'm assuming this issue is because it's not being run on a dedicated server?
Not x_, it's _x
oh my god lol
one sec
Hell yeah that works perfectly thanks Polpox! That makes a lot more things possible thanks so much!
There is no vectorSub and that's not what this is doing
That is adding a randomised amount, up to 10 metres X and Y, to the destination position each time the teleport is run. It is a position randomisation to spread out the players when they're all teleported at once.
It has nothing to do with finding vectors between two points.
If you need to find a vector pointing from one point to another, just use vectorFromTo.
-number is fine, -array is invalid.
Good thing we have vectorDiff for if you want those then
array1 - array2 is also valid but isn't gonna do vector stuff :P
What about how to make this an option that players can select by scrolling the wheel button?
We have the action on the Item. I am trying to figure out how to add the action In the top left hand corner of the screen when players hit the scroll wheel.
How do you use addAction and its code
The menu that's on the scroll wheel (by default) is the action menu. Things are added to the action menu using addAction. If you want the action to always be available without having to look at a particular object, try using the player as the object to which the action is added.
is it just me or is lineIntersects a piece of shit?
but... arma 2 D:
huehuehuehue you're screwed
http://i.imgur.com/hYHTL4e.png says false for this >.>
enjoy this glory (source: voiperr) https://www.youtube.com/watch?v=QLBwOaeaVxg
what is this?? a functional game engine??
huehuehue
I'm still waiting to be able to lock ground holders and have an attachTo that follows the orientation of the memory point or selection it's attached to.
gee i think that's a bit too advanced for RV
Hey we got bipuuuuuurds, we can get that..... eventually......
Hey I know I can use nearestObjects [player, ["house"], 200]; to get all houses with a 200m radius of the player, what about all houses within a marker that isn't necessarily circular?
use a larger radius and then _array inAreaArray "marker"
And then if the building in the larger radius isn't in the marker rinse and repeat?
inAreaArray will filter the whole array from nearestObjects with one command.
It's also quite fast.
Hey guys, is there a way to optimize an init.sqf with this in it?
this?
cutText ["", "BLACK FADED"];
0 fadesound 0;
sleep 2;
10 fadesound 1;
[0,0,false] spawn BIS_fnc_cinemaBorder;
sleep 5;
titleCut ["", "BLACK IN", 12];
[["26 - February - 2025", 4, 3], ["Central Niakala, Somewhere in Africa", 4, 3], ["75th Army Ranger, Callsign 'Granite 4-6'", 4, 3] ] spawn BIS_fnc_EXP_camp_SITREP;
sleep 8;
[1,1,false] spawn BIS_fnc_cinemaBorder;
Sleep 10;
["Lifter 5-1", "One Minute to LZ."] spawn BIS_fnc_showSubtitle;
sleep 7;
["Watcher", "All units, search and detain our HVT. Intel suggest he is between the two points."] spawn BIS_fnc_showSubtitle;
sleep 6;
["Watcher", "Reminder, the individual must be taken alive. We need him for questioning. Good hunting, squads."] spawn BIS_fnc_showSubtitle;
sleep 15;
A2 setrandomlip true;
["Granite 4-2", "Hey boss, i hear gunfire near our AO. Should we be worried?"] spawn BIS_fnc_showSubtitle;
sleep 6;
A2 setrandomlip false;
A1 setrandomlip true;
["Granite 4-1", "The whole region is a wild west. As long as we don't stray too far from our target location, we should be fine."] spawn BIS_fnc_showSubtitle;
sleep 4;
A1 setrandomlip false;
For some reason it lags my mission if an init file with this was in the mission folder
Took it out, and it'll work like nothing
i'm a very newbie in coding so i don't undertand lol
It doesn't really matter if it is called already
can you make an example for like 3 subtitle lines please
with the forEach
I need to see how it's done
I've just tried your code. At least in VR but doesn't really feel a big lag
Are you sure this part of the code is the faulty
Not lag, but the surrounding trees and building gets low in quality
Quite confusing symptom actually
Lemme take a screenshot then
It shouldn't do anything with visuals
With init file
No Init file
so just use the black fade in one then?
ditch the border
that's the mission detail on the bottom right one
it's just a fade in text compared to the other ones
Alright lemme test it out
Changed it into infotext
works like charm
WTF
So what's the issue with it?
The wiki says spawn so..
Aight, i'll try both
yeah, i choose the sitrep one because it looked simple
Call work like the spawn
no difference
It does actually make nearly zero sense BIS_fnc_EXP_Camp_SITREP can change how an object LOD work
Error
spawn {[["26 - February - 2025", 4, 3], ["Central Niakala, Somewhere in Africa", 4, 3], ["75th Army Ranger, Callsign 'Granite 4-6'", 4, 3] ] call BIS_fnc_EXP_camp_SITREP;};
Guess i'll stick to info text future on
We're not talking about ArmA logic or something. We're playing Arma and GUI cannot influence LODs
Well anyways, thanks guys
I'll just use info text from now on
[
["Speaker1", "Subtitle1", 0],
["Speaker2", "Subtitle2", 5],
["Speaker3", "Subtitle3", 10],
["Speaker4", "Subtitle4", 15]
] spawn BIS_fnc_EXP_camp_playSubtitles; // displays 4 subtitles with 5 seconds between them
sleep 7;
BIS_fnc_EXP_camp_playSubtitles_terminate = true; // closes subtitles;
i found this
Might overhaul my dialogue with this
it maybe the sleeps that impacted it
what's a "map point" ?
honestly idk if its even possible to draw pixels/dots
ok
how many doughnuts?
ok ic
well i bet DrawLine3D is so slow
so good luck with that 😐
is there a way to overwrite a function from a mod in a mission file?
Just make sure that the addon/ function is loaded before you overwrite it.
it is loaded but for some reason it isnt registering for me
theres a mod called arpi which has some functions it executes when consuming items through ace
and i wanted to overwrite them in a mission by doing this
ar_medical_fnc_interaction_useInsectrepellent = compileFinal preprocessFileLineNumbers "fn_insectRepell.sqf";
ar_medical_fnc_interaction_usePillMalariamedi = compileFinal preprocessFileLineNumbers "fn_malariaPill.sqf";
and putting it in init.sqf
but it didnt work
and the way i found the functions im trying to overwrite was by finding how it was being executed in the ace self interact menu
class ar_Use_Paste_Desinfection_apply_other
{
displayName="$STR_ar_medical_INTERACTION_USE_PASTE_DESINFECTION_APPLY";
condition="call ar_medical_fnc_interaction_canUse_Paste_Desinfection";
exceptions[]=
{
"isNotSwimming"
};
statement="call ar_medical_fnc_interaction_use_Paste_Desinfection_apply_other"; // here
};
...
you sure the function you are trying to overwrite isnt compile final already?
i have no idea honestly
if it is, what do i do?
then it cant be overwritten
you can check it by ```sqf
isFinal ar_medical_fnc_interaction_useInsectrepellent
np
You might wait until it is final / is not nil.
Dialog that variable , what that return in init , and what that return when you are in game (when all post init etc stuff is initialized)
so you're saying i should load into the game, let everything load and check again?
it gave me true again
Where did gave you true, in init or in debug when you are in game
since the function is final already there's nothing you can do via missions
you can overwrite them using mods tho
then i might look into this later i guess
I'd like to let player enable and disable thermal vision with an addAction but without giving him any head mounted device. Is it possible? setCamUseTI doesn't work with the default "internal" unit camera and I don't see anything else relevant on the biki
Greetings, just a quick question - is there any script, that would put weapon on the back? I know i can put away (holster) gun using ace mod, but can i do it by a script? Thank you.
use the action command. iirc it was called "SelectWeapon"?
switchweapon
player action ["SWITCHWEAPON",player,player,-1];
@jade acorn @little raptor thank you for your tips!
what lod is lefthand usually defined in? cant seem to get selectionvectordirandup for it
allLODs player select {"lefthand" in (player selectionNames _x#2)}
thank you leopard
I've read before that using ambient animations in multiplayer isn't great because it creates multiple logics or something like that.
Does that include after they break out of the animation? For instance if I'm using a script to spawn AI and give them ambient animations will I take continuing performance hits from that when the units are dead or deleted?
My guess is yes. But you have to read the function and see if it accounts for unit getting killed/deleted
Which is probably either checked via a loop or killed/deleted event handlers
It seems like the logics are probably not cleaned up afterwards (https://feedback.bistudio.com/T177680) - anecdotally, I recall noticing this myself
Cool thank you
Is there any way to alter the location of the subtitle given by BIS_fnc_EXP_camp_playSubtitles?
It's low enough to conflict with DUIHud, which is standard for our modpack....
I have a script that generates map markers for vehicles when a UI button is clicked. Another click deletes all markers. The marker names are entered into a hashmap so that they can be selectively deleted later on. Another part of this script turns markers on and off for individual vehicles. I believe that a hashmap is the appropriate way to store these. This is the creating part:
{
_thisVehicle = BSF_PlayerVehicles get _x;
_thisVehicle params ["_vehID","_vehClass","_territoryID","_vehObject"];
if (typeName _territoryID == "String") then {
_markerName = format["%1_%2", _vehID, _vehClass];
_markerPos = position _vehObject;
_markerDir = direction _vehObject;
_marker2 = createMarkerLocal [format["%1_2",_markerName] , _markerPos];
_marker2 setMarkerShapeLocal "ELLIPSE";
_marker2 setMarkerColorLocal "ColorBlack";
_marker2 setMarkerSizeLocal [300,300];
_marker2 setMarkerAlphaLocal 1;
_marker2 setMarkerBrushLocal "Border";
_marker3 = createMarkerLocal [format["%1_3",_markerName] , _markerPos];
_marker3 setMarkerShapeLocal "ELLIPSE";
_marker3 setMarkerColorLocal "ColorOrange";
_marker3 setMarkerSizeLocal [300,300];
_marker3 setMarkerAlphaLocal 0.5;
_marker3 setMarkerBrushLocal "SolidFull";
_marker = createMarkerLocal [_markerName, _markerPos];
_marker setMarkerDirLocal _markerDir;
_marker setMarkerTextLocal _vehName;
_marker setMarkerTypeLocal "mil_dot";
_marker setMarkerColorLocal "ColorBlack";
VehMarkers set [_vehID, _markerName];
_vehObject setVariable ["BSF_MarkerOn", 1];
};
} forEach BSF_PlayerVehicles;
diag_log format["ToggleMarkerAll: VehMarkers %1 - %2",VehMarkers, typeName VehMarkers];
The log yields:
18:33:14 "ToggleMarkerAll: VehMarkers [[9,"9_Exile_Car_Lada_White"],[11,"11_Exile_Car_Offroad_DarkRed"],[12,"12_Exile_Car_Golf_Red"],[14,"14_Exile_Car_SUV_Rusty1"],[18,"18_RHICC_GREY"],[8,"8_Exile_Car_Hunter"]] - HASHMAP" (Double quotes removed for legibility).
The "delete all" code:
{
VehMarkers deleteAt _x;
deleteMarkerLocal _y;
deleteMarkerLocal format["%1_2",_y];
deleteMarkerLocal format["%1_3",_y];
} forEach VehMarkers;
When the deletion code is run, only about half of the markers listed in the VehMarkers hashmap are processed. If the same code is run again, about half of the remaining markers are deleted. Eventually, they are all gone. So it doesn't seem to be a formatting issue.
Why don't all of the hashmap entities get processed in the forEach loop? Is there a better way of iterating through a hashmap?
There is forEachReversed but I'm not sure if that works for hashmaps.
Check whether it works if you just clear the hashmap outside the loop, like VehMarkers = createHashMap;
I've tried that and the hashmap clears out fine. The problem is that the markers don't get deleted. The iteration is skipping over the entry entirely.
I mean if you do the forEach first but without the deleteAt line.
How would I delete that markers that correspond to the names in the hashmap?
The same way you wrote, except without the deleteAt line :/
A marker name is just a string. Its existence is independent from the marker itself.
I get that about the name. What I mean is I don't see how if I just delete the hashmap entry in a separate scope, then delete the marker later using what to reference it's name?
Why do it in that order?
Delete the markers using the hashmap, then clear the hashmap?
Ah, got it. I'll give it a shot. Thanks
That did it. Thanks again.
Good idea. Thanks.
Do you mind elaborating on this? How would it be implemented in my examples above?
If count gives you _y then that's an undocumented feature.
looks like {condition} count array only exists for arrays anyway.
In some cases you can use count instead of forEach and it's fractionally faster. Maybe.
is it a problem or only bad practice to have a semicolon on a condition in an waitUntil?
waitUntil {condition;};
AFAIK strictly speaking ; defines the statement. so the return/condition would come after it, no?
No
You can place as many ; as you want
The scope returns its last evaluated expression
I find that skipping the ; helps me to visually parse it as a final return, making it slightly easier to read. Game doesn't care though.
fom addAction
radius: Number - (Optional, default 50) maximum 3D distance in meters between the activating unit's eyePos and object's memoryPoint, selection or position. -1 disables the radius; hardcoded limit is 50
is it more efficient to reduce the radius if the action doesnt need as much?
(aka engine checks distance first before action condition, etc)
yeah, the period of check will still be the same, but reducing the distance will help it reduce performance drag if thats what you are looking for
well this was more directed to Leopard20 / BI people with source access - you would assume distance is the first check by the engine, but we cant tell
yes. in that case it won't run the condition code
addAction at the end of the day it's an engine side solution that grants a convenient GUI addition, if you want to optimize even further you can instead use shortcuts by doing checks on keypresses for example, or even better, create your own action manually by using https://community.bistudio.com/wiki/inGameUISetEventHandler.
As long as you need to constantly verify something, either a OEF or a loop will be required.
that makes wonder, how often does the addAction actions check for their condition to be fulfilled 🤔
every frame
anyone know why airportvehTrigger == 1; is giving me Generic error in expression
I'm activating a trigger within a trigger setting its value to 1
Whats its value before it is set to 1?
isn't it 0 if its not activated?
I thought that's how booleans worked, if False = 0 if True = 1
you are trying to check if an object is equal to a number; not happening
== is for comparison, = is for setting. airportvehTrigger == 1 is a check, to determine whether the variable airportvehTrigger contains the value 1. It doesn't, it contains an object (the trigger), so it causes an error because == can only compare the same type.
Doing airportvehTrigger = 1 would set the variable airportvehTrigger to contain the value 1. It would not change the state of the trigger previously associated with that variable, because that's not how triggers work; it would just replace it, leaving the trigger with no variable referencing it.
To check if a trigger has been activated, use triggerActivated. There's no specific command for activating a trigger, but you can use setTriggerActivation to set its conditions to something you know will be true.
(such as true, for instance)
how easy would it be to make a script for a life server to do a driving test to get the license ? ?
easy for experienced scripters, not easy for unexperienced ones, close to impossible for someone not having a PC
i have a few years in arma scripting but i left arma for like 3 years so i am getting back to it
it really is as complex as you want the system to be in the end of the day
basic really like click buy and then will spawn car with and it puts waypoints down to follow in a timer counting down
well, the hard part is already figured out then, which is what and how to do.
Translate that into code now, Its simple enough as you describe it
Hey! I'm having this script that runs when player uses action assigned to an item. I wanted to additionally to add an animation on player unit for duration of script execution - something like [_caller, "REPAIR_VEH_KNEEL", "ASIS"] call BIS_fnc_ambientAnim; though I read this function is not recommended for MP as it creates a logic each time it's assigned on a unit. Could anyone give me a piece of advice on how to approach that?
https://community.bistudio.com/wiki/switchMove
Some actions also work https://community.bistudio.com/wiki/playAction
hey guys, might need a hand here. anyone having issues with the "put" event handler? trying this so far yields no results:
_ipos1 = getPosATL player;
RPR_itemBox = "Land_PlasticCase_01_medium_black_F" createVehicle _Ipos1;
RPR_itemBox setPos _Ipos1;
RPR_itemBox addEventHandler ["Put", {
params ["_unit", "_container", "_item"];
systemChat format ["%1", _item];
}];
executed on console for quick testing
self hosted
Q: about the default baked in map control... not available during the mission postInit, is it? is there a better mission event we could listen toward? Or just spawn a wait for the instance to become available?
If um anyone would like to help me with the Playscriptedmission Command.... I would post the full code here but... its 14000+ characters. Helps...
Is there any scripting command that increases brightness of terrain and objects during night? WITHOUT affecting brightness of sky or size of stars?
You can get decent results with setApertureNew. It does have a certain effect on the sky as well, but with some tweaking it's possible to get it nicely calibrated so it doesn't get too bright.
Otherwise, you could try using local lightpoints set to a faint blue-grey with no ambient colour. That can help with the near area.
I don't suppose there's a way to just add some amount of light globally to the world
hey anyone now a good script for a vendor
well i guess the wiki is wrong then? "put" event handler does NOT work if added to the container. (does work if added to unit)
what a let down 😦
"take" event handler however works fine if added to container.
that's what I ended up doing, basically spawn { waitUntil { ... } } did the trick after all.
working on a mission that my buddies all love to play but i keep getting a wierd bug where when i use UnconsciousReviveMedic_B animation, the player randomly appears lying on their back for both the person being revived and the person doing the reviving
heres my code:
Hello i am kinda new to arma scripting and i have a question that someone would be maybe kind enough to answer 🙂
Is there any way to stop a BIS function that was called by a trigger? In this particular case its the call BIS_fnc_music, which i want to play some nice ambient tracks TILL another trigger (BLUFOR spotted by OPFOR) launches and terminates it. I have tried it several ways, but sadly none of them stops the actual music played by the function.
Thanks in advance for any kind of information or advice.
[player,
"Revive",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
"vehicle _this == _this && alive _this && lifeState cursorObject == 'INCAPACITATED' && group _this == group cursorObject && _this distance2D cursorObject <= 2.5 && !('Medikit' in itemcargo _this && _this getvariable ['CustomMedic',false])",
"alive _caller && _caller distance2D uncpatient <= 2.5 && lifeState uncpatient == 'INCAPACITATED'",
{
uncpatient = cursorobject;
switch (stance player) do
{
//UnconsciousReviveMedic_B
case "STAND": {[_caller,'UnconsciousMedicFromRifle'] remoteExec ["switchmove", 0, false];
[_caller,'UnconsciousReviveMedic_B'] remoteExec ["playmove", 0, false]};
case "CROUCH": {[_caller,'AmovPknlMstpSrasWpstDnon'] remoteExec ["switchmove", 0, false];
[_caller,'UnconsciousReviveMedic_B'] remoteExec ["switchmove", 0, false];};
case "PRONE": {[_caller,'AmovPpneMstpSrasWrflDnon_AmovPknlMstpSrasWrflDnon'] remoteExec ["switchmove", 0, false];
[_caller,'UnconsciousReviveMedic_B'] remoteExec ["playmove", 0, false];};
default {[_caller,'AmovPknlMstpSrasWpstDnon'] remoteExec ["switchmove", 0, false];
[_caller,'UnconsciousReviveMedic_B'] remoteExec ["switchmove", 0, false];};
};
},
nil,
{
[uncpatient, false] remoteExec ["setUnconscious", 0, false];
[uncpatient, 0.4] remoteExec ["setdamage", 0,false];
[uncpatient, false] remoteExec ["setCaptive", 0,false];
[uncpatient, true] remoteExec ["allowdamage", 0, false];
[_caller,'AinvPknlMstpSlayWrflDnon_AmovPknlMstpSrasWrflDnon'] remoteExec ["switchmove", 0, false];
private _string = format ["%1 was revived by %2", name _unit, name _caller];
[_string] remoteExec ["systemChat", 0, false];
},
{[_caller,'AinvPknlMstpSlayWrflDnon_AmovPknlMstpSrasWrflDnon'] remoteExec ["switchmove", 0, false];},
[],
11,
999,
false,
false,
true
] call BIS_fnc_holdActionAdd;
I'm not sure what BIS_fnc_music uses, but if it's playMusic you can stop it by simply executing: playMusic ""
that worked!
i used [] call bis_fnc_music and it started playing EVERY TRACK IN THE GAME playmusic ""; shut it up immediatly
uh.... unhinted side effect, it shut up that reack, but not the others
basically works like a skip track that way
terminate should work
it's called and it returns bool. there's no way to terminate it
but targeting what script tpo terminate is the hard part
i get this when i ran ```sqf
diag_activesqfscripts
```sqf
["<spawn>
_trackList = _this select 0;
_trackCount = count _trackList;
_durationList = _this select 1;
_d","/temp/bin/A3/Functions_F/Misc/fn_music.sqf",true,77]
yes but it's useless. you can't terminate it without the handle
I feel like BIS_fnc_music should have a way to stop it, and it probably wouldn't be hard to add one
instead of remoteExecing switchMove, write a function that does this:
params ["_unit", "_move"];
_unit switchMove _move;
_unit playMoveNow _move;
and remoteExecCall this fnc instead
an easy way would be saving the handle into a global var. but maybe it already does this
returns nothing
wiki says it returns bool
returned true for me, but you cant target a bool?
like I said it either should return the handle, or save the handle into a global var
its return won't be changed due to backward compatibility
In the Editor, you can go to Tools(?) in the top bar and select Function Viewer. In there, you can find the function and see its code and find out if it does save the script handle into a global variable.
Just use playMusic and set a https://community.bistudio.com/wiki/setMusicEventHandler
That way you can easily script a jukebox that continues playing and can be stopped or even change volume etc.
/*
File: fn_music.sqf
Author: Karel Moricky
Description:
Jukebox
Parameter(s):
_this: ARRAY - list of used songs (Optional)
NUMBER - delay between tracks (Optional)
Returns:
Nothing
*/
<<< from functions viewer
i found the key!
terminate bis_fnc_music_spawn; playmusic "";
That's just the header, a little bit of in-file documentation that someone wrote about it. You can usually learn more about how functions actually work by reading the full code; the header is rarely comprehensive.
terminate bis_fnc_music_spawn; playmusic "";
would be handy to be able to terminate scripts for security reasons. like having script whitelist
i imagine a server event handler to detect new scripts (spawn and execvm)
Having Issues with a script. Every time the player dies the script no longer shows the option to teleport to officer In the top left hand corner. I am hoping someone will help with telling me what might be wrong.
this addAction ["Teleport to Officer", {
params ["_target", "_caller", "_actionId", "_arguments"];
if (vehicle OpforCommander != OpforCommander) then{
_caller moveInAny (vehicle OpforCommander);
}else{
_caller setPosASL (getPosASL OpforCommander);
};
}, nil, 1, true, true, "", "true", 5];
It It located on the Init on the player located In EDEN editor.
addActions don't move to the new unit on respawn.
You'd have to re-add them on respawn.
Brother you don't know how grateful i am for this. I've spend the last 3 nights to figure out how to terminate that function 😄
Thank you so much! Works like a charm of course.
So I'm doing some scripting for a dedicated server and it works fine everywhere else I test it like usual and the proceeds to break when using it on the dedicated server like usual. I'm working with respawns, I've tried both the onPlayerRespawn.sqf and the Respawn event handler. I've done some browsing and it seems this is an issue for others as well. Is there a way to fix this, is it just me, or is there a way around this?
I'm trying to switch the players side when they die
private _grp = createGroup east;
[player] joinSilent _grp;
Where are you running that code?
And does everything else work on the respawn handler, or are you not doing anything else?
is there an in-editor solution to respawning players in the air? markers dont seem to have a Z coord and respawn modules place them at ground level regardless of the Z coord.
Hi guys, how to detect when some player (not just local Player), opens his inventory. I tried:
unit addEventHandler ["InventoryOpened", {
_opened = true;
]};
but its not detecting. Or im doing smth wrong?
And i declare this _opened variable before event handler as false
and put all that in While loop with sleep 1;
unit is some player, whos name i get in code
As per the page KJW linked (do read it), _opened is a local scope variable. When used in the event handler scope, it's separate from any other instance of a variable called _opened, and ceases to exist when the EH code completes.
so i need to pass somehow these variable through parameters?
ok i tried this:
unit addEventHandler ["InventoryOpened", {
[some args] call func;
]};
and still dont work. Do i need to pass through params these func and args variables?
If we're talking about security it's better that you don't have access to it
I have other question about optimising: How to optimise variables in MP. I do setVariable with public to true, but i do it very often, and there is a big array, this script executes on every machine. And i set and get these variables in functions which i call in this script. How to make that if some local player calls these functions (do smth) , it wont just setVariable publicly but when i need to get it on other machine ill get it right
You cannot get it right on a different machine, without sending it to the different machine
Instead of sending the whole array. You could implement your own system that only sends changes to the array
aha, do you know how to make it?
Yes, I could build something like that
Am I going mad or is it impossible to visually remove rotors on a helo by setting their hitpoint damage to 1? I specifically remember that being possible before.
wait. if i in some func which spawned on every machine setVariable in some varspace for exemple some object, will it be updated for every one?
If you set the variable on every machine. It will be set on every machine.
yes, im asking if there varspaces which are global (they are on server) for every machine. so i can set there var and then get without doing it publicly
thanks
thats might be what i need
I wonder how this function works. I guess it remote executes code on the server which sends the variable back to the client who executed the function. I need to check the code later.
Probably works in SP too. Check the code in the functions viewer to be sure.
So you mean a varspace that is implicitly public... But that means you're doing it publicly always.. Same thing
Yes would expect the same. Thats because it needs to be scheduled
i might explained wrong what i thought
getServerVariable would work. But its really inefficient.
Basically that transfers the full array on every get.
Instead of transferring it on every set
If you set many times and only very rarely get, that might make sense. But I don't think thats the case?
i set it and get it when func executes. I just make some changes in array, and they are very little
Maybe you can change your architecture to not use that array somehow.
i have no idea how. I store in this [_thing, _amount] and there many of that things
arrays*
is _thing a string?
yes
just post the script
Then you could use a object to set the variables on
instead of array of _thing
You can do
object setVariable [_thing, _amount, true]
Instead of sending whole array, you only send the updated _thing value
CBA/ACE use that method.
https://github.com/CBATeam/CBA_A3/blob/master/addons/common/fnc_createNamespace.sqf#L32
They spawn a simple object (that is network shared), and then you can post public variables using that
ok. how do i implement it? i make this big array from other array:
{
_ArrOfThingsAndAmount append [[_x, 0]];
}forEach _ArrOfThings;
then in code i change it:
{
if ((_x select 0) == _item) then {
_element1 = _x select 1;
_element1 = _element1 + 1;
_x set [1, _element1]; //here
_items pushBack _item; //other array i need in code
};
}forEach _ArrOfThingsAndAmount;
y u no use hashmap
{
_ArrOfThingsAndAmount append [[_x, 0]];
}forEach _ArrOfThings;
That, with an object would be
// Initialize all things to zero
{
Vaz_ThingsObject setVariable [_x, 0, true];
} forEach _ArrOfThings;
{
if ((_x select 0) == _item) then {
_element1 = _x select 1;
_element1 = _element1 + 1;
_x set [1, _element1]; //here
_items pushBack _item; //other array i need in code
};
}forEach _ArrOfThingsAndAmount;
That with an object would be
// Increment _item amount by one
Vaz_ThingsObject setVariable [_item, (Vaz_ThingsObject getVariable _item) + 1, true];
_items pushBack [_item, Vaz_ThingsObject getVariable _item]; // Other array, that is not network synced?
because when i wrote this i didnt know about it
here is your reward: a handcrafted custom meme 😄
other array sinced too
Then you probably want a second object for the other array
wait aint it like i would have many arrays with same name?
I don't understand its purpose so 🤷 Why would you need twice the same info
Assuming every thing only exists once.
So you don't have two of the same in your array?
to be fair your increment code seems to expect that there are two of the same
But I just assumed that is because its badly written
no they arent.
its like i just store the name of object i used
so then i can show it
whats this Vaz_ThingsObject its just object i work with?
im not sure hashmap is best solution for data that needs to be changed over network
That would be some object you create.
Probably a simple object
ok
CBA would use CBA_NamespaceDummy. Thats just a model-less object thats cheap to create.
But if you don't have CBA you can't use that
Don't know what a vanilla one would be
the undeletable object is pretty good ... bis_functions_mainscope or whatever it is
Yeah that should work, if the _thingy names don't conflict with anything on it
But we need two for two arrays.
So probably create a new one.
But I think the functions mainscope uses Logic, which is not very efficient as it ticks
like in my script i always setVariable in drone (thats what im working with)
i still havent seen his script so still not worth helping
You need some object. That exists the whole mission and is never deleted
and still dont know the actual purpose of the script, as probably there is a structural solution
ok here is it. dont judge very strictly its my first real struggle in scripting)
no one is judging
there are some parts where i tried detecting when player opens inventory, but i dont know how to make it work with event handler
Do you have CBA mod?
That has eventhandler for inventory open
Or atleast in config they have it, I don't know if also accessible scripted (easily)
so its like a drone that anyone can use (not at the same time) which has some cool abilities
and you need each client to have the correct state of the drone
@delicate hedge ?
yes
the client doesnt actually need the correct state of the drone until they are "taking control" of it then
taking control?
i made that any player can attach this grens in any moment
Is it a mod, or a mission script?
its mod
Mh.. Yeah CBA has display open eventhandler, but its config only.
Bah CBA documentation is oof
https://github.com/acemod/ACE3/blob/master/addons/inventory/CfgEventHandlers.hpp#L19
Here is a macro'ed example on how to detect inventory open.
So you would do something like
class Extended_DisplayLoad_EventHandlers {
class RscDisplayInventory {
Vazar_Drone = "_this call Vazar_OnInventoryOpened";
};
};
in your config.cpp
Then that function is called everytime the player opens inventory. Everytime RscDisplayInventory is loaded
but how do i close my menu then?
if you look in script
it seems you might be able to just manage the grenade slots with attachedObjects _drone
instead of with variables
In that script that is called everytime on inventory open.
You could trigger a event for example. And then use that event in your script (CBA_fnc_addEventHandler)
but i attach not all grens, and not always. there is func for detecting if its need, it depends on drone type
Btw line 445
_drone = (_this select 3) select 0;
_num = (_this select 3) select 1;
_attachGren = (_this select 3) select 2;
_grenades = (_this select 3) select 3;
_closeMenu = (_this select 3) select 4;
_start = (_this select 3) select 5;
==
_arguments params ["_drone", "_num", "_attachGren", "_grenades", "_closeMenu", "_start"];
Same in Line 371 but bigger
thanks didnt know
Your code could be quite a bit simpler if you just used global variables for your functions.
No need to pass _attachGren around all the time, when you can just call it Vaz_drone_fnc_attachGren and then refer to it by global variable
_ItemCount = 0;
{
if (_x == _item) then {
_ItemCount = _ItemCount + 1;
};
}forEach _inv;
That is
_ItemCount = _inv count {_x == _item};
Count how many times the condition is true. Just count
yep
And yeah you could use the drone for your namespace for the thing variables. Looks fine.
But if you need second array.
Maybe you could just give them a prefix
Like instead of
Vaz_ThingsObject setVariable [_item, (Vaz_ThingsObject getVariable _item) + 1, true];
do
Vaz_ThingsObject setVariable ["prefix_" + _item, (Vaz_ThingsObject getVariable ("prefix_" + _item)) + 1, true];
That way you can just use a different prefix for your second array, and they won't conflict
You can use allVariables and filter by the prefix, to find all items that exist on it.
Though the allVariables is somewhat inefficient if you need to do it often. Would be simpler if the object doesn't have ANY variables except the ones you want on it, then you don't have to filter
{
_elcfg = _x;
_el = configName _elCfg;
_ammoCfg pushBack _el;
} forEach _ammoCfgEnt;
==
_ammoCfg = _ammoCfgEnt apply {configName _elCfg};
addEventHandler ["XXX","code"];
addEventHandler ["XXX",{code}];
addEventHandler ["XXX",TAG_fnc_function];
addEventHandler ["XXX",{_this call TAG_fnc_function}];
is there any speed difference with these? i think to recall some talk it recompiled(?) on each execution(?)
In the past it did
Nowadays (almost?) all eventhandlers are stored as code.
The first 3 are equal when the EH triggers.
The last one has performance overhead because the extra call
The first one will compile the code when you add the EH (Or when its first triggered).
Whereas the other two compiled it already earlier
@delicate hedge what are these vars doing
[_drone, AttNumG, _AttNum] call BIS_fnc_setServerVariable;
attnumg, attnum
Looks like a typo. Should be "AttNumG"
i can make it for every addaction?
For everywhere where you do lots of select 0, select 1, select 2...
attnumg just global name of attnum. attnum is a big array where i store every grenade and its amount
You can still chop them off by collision. >_<
i just wrote when i started, cuz i thought i shouldnt write same names)
perhaps a structural issue with the script is that there seems to be no oversight by the server, so clients are able to SET without an accurate GET (perhaps by latency of two clients performing an action at the same moment)
well, i need to rewrite it all
if i was to do a script where multiple players are allowed to make changes to an entity, i would have all the SET done on the server, players would use GET to update their lists and enable/disable buttons and show/hide actions
player can then use the buttons/actions to request server to make changes, server then checks to see the change makes sense before new SET
yea, but i get it only now
and still, i have no idea how to do such scripts
it might not be necessary, as long as your script is doing as you want it to
i satrted writing it just as mission script and then wanted to make mod
but it does it very unoptimised
does it work?
yes
as i understand now
and the only thing is optimise?
i would like to, cuz i want to use on big servers where many players
can you just give method how it could work, so script executes on server and players get results, as i understand it would be really good for MP servers with many players
You need to split your functions into real functions. Not local variables.
Then player can remoteExec to the server, to execute a function on the server.
Then the server makes the changes to the variables and broadcasts them
you need to also weigh up the time cost of both learning how to do it, doing it, and bug fixing/debugging it ... compared to just going with what you already have working
So instead of a player making the change locally and broadcasting the result.
The player instead tells the server "please do this for me"
Would somone please be able to help me with a config for a mod?
@delicate hedge also it would be good for you to learn data structures like this, to help organize your data. a little table like this means you could remove at least one of those variables you are setting... you can see "i_uav_03" has 3 slots, while "b_uav_01" has 1 slot
drone_data = [
['b_uav_01',[[0,0,-0.1]]],
['o_uav_02',[[0,0,-0.1],[0,0,-0.25]]],
['i_uav_03',[[0,0,-0.1],[0,0,-0.25],[0,0,-0.4]]]
];```
People in #arma3_config probably can help with configs
Ah thank you
thanks
so i just: [params] remoteExec [func] and target... what i set there?
[params] call MyFunction
becomes
[params] remoteExec ["MyFunction", 2];
The 2 stands for "send to the server"
Then MyFunction will run on the server, with the passed arguments
I would say first change your code locally to use proper functions.
And after that is done switch to remoteExec
ok
Also recommend a github project to keep track of your changes.
Also makes it easier for other to look at
so it run ON server and whats next? It will globaly update vars?
Yeah the server will update the variables and stuff
so all what players will do is just send remoteExec request and get vars?
The server can also reply back.
Using
[params] remoteExec ["MyFunction", remoteExecutedOwner];
That will execute the function with parameters. On the machine that originally sent the request.
So you can directly reply back to for example open some UI
Thanks!
and as i understand it would load only server that much.
Do i need to set public true in setVariable, if func executes on server?
yes
because every player needs to know about it
(atleast until you implement an optimization to only send it to the player that need it, which could be done later)
thats could be made with remoteExecutedOwner?
Yes.
But what about other players?
I assume they also need to know about stuff.
In case the "user" of the drone changes to someone else
You would need to handle that "ownership" change
Which you could do, send server "RequestTakeOwnership" server then handles stuff, sends all variables it needs and replies to it that it has received ownership
But you shouldn't do that now, don't do too many things at once
but i can just not to send them stuff they dont need until they execute func where they need
yeah. You can
so thats the best optimisation for now for both player and server side i can do?
That's how I would do it.
And that's also how the game does it with vehicles for example. Stuff is sent to server, some things are broadcast if all need to know. There is an owner, on ownership change request extra data is transferred.
ok, thank you!
last question: i dont get it)
Inside the inventory open script.
["Vaz_InventoryOpened", [arguments]] call CBA_fnc_localEvent;
Inside your handler script
["Vaz_InventoryOpened", { code here }] call CBA_fnc_addEventHandler;
Vaz_InventoryOpened whats this?
Its the name for your "event"
func?
can be anything really
oh ok
Its just a global identifier. So that the addEventHandler knows what you mean
code here - is where i do what i need
Yeah. The thing where you close some UI thing, what you did in your script there
Basically does what you had commented out with the "InventoryOpened" eventhandler
so this " inventory open scrip" will have one line?
yeah
what about this Vazar_Drone ?
or this class added to drone class?
thats an example of how to structure your script
or at least, how i like to structure mine
its missing a couple things like a server queue, unnecessary and easy to add later
Also again arbitrary name. But it needs to be globally unique.
So I gave it a prefix, and the name of your mod.
That's the standard, prefix_modname
ok
thanks i'll look at this
When you make full functions, you'll also have to decide for a prefix. I used Vaz as example above
i have my own
dont worry
whats the server queue?
it just stops spam, so requests are called sequentially, but in that script we put a little cooldown which also stops spam
just read it a little, it shows how script can be executed with an add action to send a message to server for server to do something
with a couple fixes
well, for now i dont get many things there...
like whats that INIT_SERVER , INIT_CLIENT and other. Thats like states of mission?
nah it is just instructions sent to the function. what you are trying to accomplish
oh i get it now
He basically put what multiple functions would do, into just one function.
So instead of
[params] remoteExec ["FunctionName", 2];
you'd do
["FunctionName", params] remoteExec ["TAG_drone", 2];
And then you'd implement all your code in one single giant file
ok
That's a way to do it.. but I wouldn't recommend that.
thats nice
?
you say it would be better to break it in many scripts?
but the point is you asked to see how a scripted system could be structured so that client is requesting server to make changes, instead of directly making changes
Wish you could hashValue HASHMAP a hashmap (its values) to avoid creating intermediate array with hashValue values HASHMAP. Got so used using arrays as keys and kinda expected hashmaps to also be usable as keys.
yep understand
muh microseconds moment again
in fact the way i shown is the way Bohemia does it ... review BIS_fnc_arsenal, BIS_fnc_dynamicGroups, BIS_fnc_garage, etc.
hashValue on hashMap should hash the keys and values together. Does that not work?
hashValue should work on every data type
Perhaps, just looking at a way to turn data into hashmap key the quickest way
That is due to how display init scripts work
"Wish you could hashValue HASHMAP a hashmap"
indeed you cannot, I'll fix that
Sure I can hashValue anything, just wanting to be able to do
HASHMAP set [HASHMAP, VALUE]
```the same way I'm doing
```sqf
HASHMAP set [ARRAY, VALUE]
Thanks, would be very cool!
That's annoying because the map needs to be copied and made read only, but would be doable
so with that structure i would need to make one big script (server side) where i define modes and what they do. Then other script (player side), where i call all of them?
oh yeah, when you use arrays as keys, they're actual arrays and not just string hash of it
Maybe I actually don't want the whole hashmap stored
personally I think you should continue with your existing script, while also taking some time to learn how to structure data into arrays, and learning how to call function on server from client
ok, if that, i just need way to optimise my big array, and implement there the openInventory handler...
Making hashValue HASHMAP possible would be perfect for me, no need for set [HASHMAP, VALUE] really
i never saw the big array in that file
{
_AttNum append [[_x, 0]];
}forEach _grenades;
thats _AttNum
line 154
or somewhere there
Oki I'm doing that now. Maybe dev branch tomorrow. Don't know which stable it might be
The hash quality isn't very good though
It just forEach overall
and then combines hashValue _x, hashValue _y
together. So it hashes a bunch of hashes.
Should be okey though 🤷
hs1 = createHashMap;
hs2 = createHashMap;
for "_i" from 1 to 1 do {hs1 set [_i, _i];};
for "_i" from 1 to 100 do {hs2 set [_i, _i];};
[
diag_codePerformance [{hashValue hs1}]
,diag_codePerformance [{hashValue [keys hs1, values hs1]}]
,diag_codePerformance [{hashValue values hs1}]
,diag_codePerformance [{hashValue hs2}]
,diag_codePerformance [{hashValue [keys hs2, values hs2]}]
,diag_codePerformance [{hashValue values hs2}]
]
```Can you run this to see how faster it is?
private _position = vehicle player getRelPos [900,180];
private _newPos = _position vectorAdd [0,0,1000];
Would these lines make the _newpos be 1000m above and 900m back where the player vehicle is
btw is it possible to run triggers as zeus. The triggers are part of a composition I made
I dont believe so, you could just spawn a unit into the trigger to activate it though
I have a question for you, I have a script that will spawn a bomb in the air and drop it to the target [[8132.62,4392.19,1110.44], "ammo_Missile_Cruise_01", car1, 180, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile; . but I would like her to spawn on an object (plane), do you know how to write it?
Just use the position of the plane instead of the hardcoded position you entered there
look at getPos and its alternatives
Ok i Will try ,thx mate
[
[0.000261727,100000],
[0.0047456,100000],
[0.000369346,100000],
[0.00401492,100000],
[0.00947244,100000],
[0.00444541,100000]
]
If I add my script in the init of an object will it run for all my players
ye
how do I write the condition
this && ((vehicle player in thisList) && {vehicle player iskindof "Plane"})
Where this is BLUFOR, Present
I guest it's if(((vehicle player in thisList) && {vehicle player iskindof "Plane"})&& ("The blufor present condition")then{
would this work
null=[]spawn{
if((vehicle player in thisList) && (vehicle player iskindof "Plane") && (side player == west))then{
in an object's init
I doubt thisList exists in object's init
what are you trying to do?
It's to simulate the condition if blufor player present and in plane to do my code
ok well I guess it would work then
ill give in i guess. how would i handle REspawning a player in MP in the air (like on a carrier deck) with a script? i found
[west, [3560,1128,5204], "West Respawn"] call BIS_fnc_addRespawnPosition;
on google, so i threw it into an SQF, what else should i be doing?
this && { side group player == west && {vehicle player != player && { vehicle player iskindof "Plane"}}}
In condition of trigger
That should be correct, as long as:
- the SQF file is being run (just putting code in a random SQF file does not guarantee it gets run, only specific files are automatically run and the rest you have to execute somehow)
- the SQF file is being run on a single machine (e.g. the server)
- the Z coordinate in that position is on or above the deck of the carrier (in ATL, not ASL)
did u mean vehicle player != player
Yes. Edited. Thanks
Ooof, I messed up with second diag_codePerformance, had hs2 instead of hs1
Either way looks to be slightly faster than pulling values first
Is it possible for the unit caputre script to also record the movements of the tank's towers and guns?
no
ok thx 🙂
This is probably it, I messed up the SQF name. I took the coords from a module I placed there and added .1 meters to the Z height so that should be fine.
So the event handler was on the initPlayerLocal. The killed eh works but not the respawn. It doesn’t even seem to run
hey man @still forum , are you there? I have question about this. What do you mean "Inside your handler script" , and how do i get these "arguments" what i need (exactly name of some _function in main script)?
Hello. Im trying to make a Rally raid (navigation with roadbook) for Arma reforger.
But what I need is a tripmeter, a display that show distance traveled. Is this somone inow how to make?
if(_targetType in gargantuanCargoSize) then {[_entity, 1000] call ace_cargo_fnc_setSpace;
_entity addEventHandler ["Killed",{params ["_unit", "_killer", "_instigator", "_useEffects"];
_unit removeAllEventHandlers "Killed";
[_unit, "scrap", 0, 25] execVM "DNT_supplies\DNT_createSupplies.sqf";
}
];
};
}];
}forEach allCurators;```
Could someone help me and explain why this piece does not works as intended on dedicated server? Script is run from initServer.sqf like this
```null = execVM "DNT_supplies\DNT_setCargoSpace.sqf";```
My intention is that whenever a curator spawns a vehicle that is in global array "gargantuanCargosize" this vehicle should have assigned ace cargo space and added action by running another script
```[_unit, "scrap", 0, 25] execVM "DNT_supplies\DNT_createSupplies.sqf";```
script using execVM. It works locally but when added to server it does neither.
Similar problem with this piece of code
```{
if(typeOf _x in tinyCargoSize) then {[ _x, 2] call ace_cargo_fnc_setSpace;
_x addEventHandler ["Killed",{
params ["_unit", "_killer", "_instigator", "_useEffects"];
_unit removeAllEventHandlers "Killed";
[_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf";}];};```
I've also tried using "MPKilled" instead but no effect on server and it threw error locally.
I was also thinking of trying using remoteExec but I'm getting confused on how should syntax look for example for
[_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf";
@proper sigil have you checked server RPT output? Is e.g. gargantuanCargoSize variable defined on server?
I'm looking to have custom black bars like the cinematic ones creep up from the outside of the screen for a mission title. Is there any way to animate a cutRSC with like, scale, or moving a pair of them up from the bottom and top of the screen?
The existing cinematic mode function kills access to controls and the bars are too big.
Where on earth is the missing semicolon in this statement?
private _sgroup = [opfor_spawn_0] remoteExec ["TAG_fnc_spawnSquad",2];```
the function being used should return a group object
in any case, I'm getting an error that this line is missing a semicolon
I have poobrain, though
I should just call instead of remote-exec
....nevermind. The missing ; was on line 1, the params
not 12
there's just a comment in the way
won't work like that
the group will be created, but the group's variable is not sent over the network
It's executed on the server, fortunately
private _sgroup = [opfor_spawn_0] call SWS_fnc_spawnSquad;
_sgroup addWaypoint [_dest,10];
_sgroup;```
still, remoteExec returns a string, the JIP id
Thank you for the important information
that is going to save my ass when I code the next function
Because that legit would have been like stepping on a rake
Does anyone have any experience with using the following?: https://forums.bistudio.com/topic/175154-functions-unitcaptureunitplay-for-infantry-units-in-arma-3/
I have used the author's test mission to play back his sample data to make sure it works and it works great. The problem is that when I record my own data and replace the original with mine, the AI does nothing. Anyone have any idea what's going wrong?
speaking of stepping on rakes...
i am tring to get a custom revive script working but now everything seems to be borken
i had a chat earlier about it and during testing discovered that the command is created on the local machine and is not available for the unit actually trying to use the action unless i used [holdactionparams, ... ]remoteexeccall ["bis_fnc_holdactionadd", -clientowner, true];
[player,
"Revive",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
"vehicle _this == _this && lifeState _this != 'INCAPACITATED' && lifeState _target == 'INCAPACITATED' && group _this == group cursorObject && _this distance2D _target <= 2.5 && !('Medikit' in itemcargo _this && _this getvariable ['CustomMedic',false])",
"lifestate _caller != 'INCAPACITATED' && _caller distance2D _target <= 2.5 && lifeState _target == 'INCAPACITATED'",
{
params ["_target", "_caller", "_actionId", "_arguments"];
switch (stance _caller) do
{
//UnconsciousReviveMedic_B
case "STAND": {
_moves = ["UnconsciousMedicFromRifle","UnconsciousReviveMedic_B"];
};
case "CROUCH": {
_moves = ["AmovPknlMstpSrasWpstDnon","UnconsciousReviveMedic_B"];
};
case "PRONE": {
_moves = ["AmovPpneMstpSrasWrflDnon_AmovPknlMstpSrasWrflDnon","UnconsciousReviveMedic_B"];
};
default {
_moves = ["AmovPknlMstpSrasWpstDnon","UnconsciousReviveMedic_B"];
};
};
_caller switchmove _moves select 0;
_caller playmove _moves select 1;
},
nil,
{
[uncpatient, false] remoteExec ["setUnconscious", owner _target, false];
[uncpatient, 0.4] remoteExec ["setdamage", owner _target,false];
[uncpatient, false] remoteExec ["setCaptive", owner _target,false];
[uncpatient, true] remoteExec ["allowdamage", owner _target, false];
_caller switchMove "AinvPknlMstpSlayWrflDnon_AmovPknlMstpSrasWrflDnon";
private _string = format ["%1 was revived by %2", name _target, name _caller];
[_string] remoteExec ["systemChat", -clientowner, false];
/// [uncpatient, "AinjPpneMstpSnonWnonDnon_rolltofront"] remoteExec ["switchmove",0,false];
},
{_caller switchmove "AinvPknlMstpSlayWrflDnon_AmovPknlMstpSrasWrflDnon";},
[],
11,
999,
false,
false,
true
] remoteexeccall ["BIS_fnc_holdActionAdd", -clientowner, true];
i am getting NO ERRORS in the report file, but neither the animations or the uncpatient remoteexec commands are yielding any results, but oddly the remoteexec for system chat IS working.
i have no errors to go off of
as per leopard i did try making the animations into a function and properly setup the config.hpp with the classes to to call the animations with [_caller] remoteexeccall ["DES_fnc_medicStance", owner _caller, false]; and i could see the diag_log results from that script running but still no animations were played
so i ended up restructuring the params passed to reflect what the wiki "says" is passed to the condition statements(Special arguments passed to the code: _target (action-attached object), _Caller (caller/executing unit)) and now this whole thing is falling apart and i need some help
as it sits right now somethign appears to be jammed in the progress condition but according to the wiki the format is correct, but no progress is made
These lines are not going to work as intended due to precedence:
_caller switchmove _moves select 0;
owner _target also won't work there because owner is server-only and the code here is all running on the client.
You can just use _target instead.
dumb it down for a plebian like me?
switchmove and select are both standard binary commands, so that line will do this:
(_caller switchmove _moves) select 0
The game reads left-to-right (plus some other rules). It will see this:
_caller switchMove _moves
and then this:
select 0
and that don't make no sense to it.
You need to write either this:
_caller switchmove (_moves select 0)
or this:
_caller switchmove _moves # 0
fuck discord
HUH?
Use \ to escape characters
Discord uses Markdown formatting, so # at the start of a line makes it into a header
Further details: https://community.bistudio.com/wiki/Order_of_Precedence
Hello im trying to reference a video to play from my modpack unsure if im doing referencing it wrong or just doing it wrong. Would very much appreciate some help heres my code
[
"!Workshop\Wolfysmod\addons\Sequence-01.ogv",
[
safezoneX + 0.5,
safezoneY,
37 * pixelGrid * pixelW,
21 * pixelGrid * pixelH
]
] spawn BIS_fnc_playVideo;
The location of the file is very wrong, if the OGV file is in a PBO
it is
Specify the location in the PBO then
This is where it is but still not working. This mod is also uploaded to the workshop so not sure if i need to reference my arma3 folder before the workshop one. Also Do i need to reference it with the file type like .pbo or does that not matter?
"!Workshop\Wolfysmod\addons\media.pbo\Sequence-01.ogv"
ok so i made those changes and now the error im getting is:
19:36:50 Error in expression <edic"];
_moves = [];
_ismedic = _caller getvariable ["CustomMedic", false]; <<<<<<<<<<<<<<<<<<<<< this is line 11;
if (>
19:36:50 Error position: <getvariable ["CustomMedic", false];
if (>
19:36:50 Error getvariable: Type String, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location
19:36:50 File C:\Users\isass\Documents\Arma 3 - Other Profiles\Full_Metal_JackOff\mpmissions\co10_Escape_DES_NATO_vs_CSAT.Altis\functions\DES\fn_medicStance.sqf..., line 11
Arma 3 does not recognize your file in this way. Use relative path from your PBO, not from the EXE
but thats in the report file though. this script is getting called from a bis_fnc_holdactionadd in the starting code block from this command: ["_target", "_caller", "_actionId", "_arguments"] remoteExec ["DES_fnc_medicStance", 0, false];
which is defined in funcitons.hpp via:
class CfgFunctions
{
class des
{
class DES
{
class medicStance{};
};
};
};```
I don't think _caller is defined in most of those code blocks.
My last post was not a reply to you
my bad
should i not be useing params again? is it already predefined and im just overwriting the variables with this:
shrugs
You're trying to throw a string into the function, not the variable. Remove brackets for remoteExec's arguments
other people's holdActionAdds are unreadable without good formatting. It's like reading assembler.
is mine readable?
That doesn't have the failing code in it.
ah, because it's from the medicStance function that you never pasted.
this is frustrating (╯°□°)╯︵ ┻━┻
You remoteExec DES_fnc_medicStance from the progress condition code, right
So I guess you're using _caller there but not defining it.
It doesn't inherit the previous local vars because it's a remoteExec.
runnning from start code section
let me get a shot without word wrap.
You haven't pasted medicStance at all, have you?
You only pasted the holdActionAdd call.
That's the holdActionAdd for like the third or fourth time.
yes medic stance is inside a function defined in the replied message
heres the code from it:
params ["_target", "_caller", "_actionId", "_arguments"];
private ["_moves","_ismedic"];
_moves = [];
_ismedic = _caller getvariable ["CustomMedic", false];
if (_ismedic) then {
switch (stance _caller) do {
case "STAND";
case "CROUCH": {
_moves = ["AinvPknlMstpSlayWrflDnon_medicOther"];
};
case "PRONE": {
_moves = ["AinvPpneMstpSlayWrflDnon_medicOther"];
};
default {
_moves = ["AinvPknlMstpSlayWrflDnon_medicOther"];
};
};
} else {
switch (stance player) do
{
//UnconsciousReviveMedic_B
case "STAND": {
_moves = ["UnconsciousMedicFromRifle","UnconsciousReviveMedic_B"];
};
case "CROUCH": {
_moves = ["AmovPknlMstpSrasWpstDnon","UnconsciousReviveMedic_B"];
};
case "PRONE": {
_moves = ["AmovPpneMstpSrasWrflDnon_AmovPknlMstpSrasWrflDnon","UnconsciousReviveMedic_B"];
};
default {
_moves = ["AmovPknlMstpSrasWpstDnon","UnconsciousReviveMedic_B"];
};
};
};
spawnparams = [_caller,_moves];
movement = [spawnparams] spawn {
params ["spawnparams"];
_caller = spawnparams select 0;
_moves = spawnparams select 1;
_caller switchmove (_moves select 0);
if (count _moves == 2) then {
_caller playmove (_moves select 1);
};
};
true;
Dunno then. Maybe the documentation is wrong and it doesn't actually pass anything in _this.
In which case removing the params line should fix it.
you can check using diag_log or systemChat. Normally I'd say read the code, but holdActionAdd is probably quite hard.
_caller ending up with a string in it is rather baffling though.
revised code:
{
diag_log format ["_caller = %1",_caller];
["_target", "_caller", "_actionId", "_arguments"] remoteExec ["DES_fnc_medicStance", 0, false];
},
report file returns with
20:11:50 "_caller = p6"
20:11:51 Error in expression <edic"];
_moves = [];
_ismedic = _caller getvariable ["CustomMedic", false];
if (>
20:11:51 Error position: <getvariable ["CustomMedic", false];
if (>
20:11:51 Error getvariable: Type String, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location
20:11:51 File C:\Users\isass\Documents\Arma 3 - Other Profiles\Full_Metal_JackOff\mpmissions\co10_Escape_DES_NATO_vs_CSAT.Altis\functions\DES\fn_medicStance.sqf..., line 11
So something like "D:\@Wolfysmod\addons\media.pbo\Sequence-01.ogv"
Is p6 the editor var name of that unit?
yes. i think i just found the issue and its been in my face this whole time
i put the same diag_log command in from of the erroring code in the called function:
diag_log format ["_caller = %1",_caller];
_ismedic = _caller getvariable ["CustomMedic", false];
and i get this:
20:15:56 "_caller = p6" <<<<<<<<< before remoteexec
20:15:57 "_caller = _caller" <<<<<<<< inside called function
20:15:57 Error in expression <ller = %1",_caller];
_ismedic = _caller getvariable ["CustomMedic", false];
if (>
20:15:57 Error position: <getvariable ["CustomMedic", false];
if (>
20:15:57 Error getvariable: Type String, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location
20:15:57 File C:\Users\isass\Documents\Arma 3 - Other Profiles\Full_Metal_JackOff\mpmissions\co10_Escape_DES_NATO_vs_CSAT.Altis\functions\DES\fn_medicStance.sqf..., line 12
It'll return the same "p6" string, but I have no idea how that gets into _caller in the first place. It's supposed to be an object.
oh wait
oh lol
i put the variable name in quotes
because i copied and pasted from the line above with params
Yeah, it returns "p6" anyway because that's how str _unit translates units that have var names.
right but wouldnt i be passing the literal interpretation of "_caller" and unpacking the variable through params which would then result in the variable being just _caller instead of a refference to an object
yeah you identified the problem correctly
ok so the whole reason why i broke this working function in the first place is because i was having this problem:
as per leopards instruction made this function that has been a nightmare for me,
and the issue of the person randomly appearing in the unconscius position is still persistant
You'd want to demonstrate that in a much simpler and more replicable context.
The answer is probably staring me in the face but I can't see it. I currently have the following code```SQF
params ["_colour","_startLoc","_finishLoc","_indexAddition"];
private _route = [];
(calculatePath ["wheeled_APC", "careless", _startLoc, _finishLoc]) addEventHandler ["PathCalculated", {
{
_markerNumber = _forEachIndex + _indexAddition;
private _marker = createMarker ["marker" + str _markerNumber, _x];
_route pushback _marker;
_marker setMarkerTypeLocal "mil_dot";
_marker setMarkerColorLocal str _colour;
_marker setMarkerSizeLocal [.5, .5];
} forEach (_this select 1);
}];
But at the end when I check `_route` it's empty. What am I missing to add every marker created into the array?
I'm not sure that switchMove _move1; playMoveNow _move2 is legitimate in MP anyway. Leopard's example uses the same move for both.
I guess you want a hard transition to move1 and then a proper one to move2, but I'm not sure that's actually supported by the networking.
I don't really understand Arma's animation system well enough to help anyone else with it though.
using the animation UnconsciousReviveMedic_B in a multiplayer environment randomly results in the player randomly apearing to be laying on the ground as if they are unconscious like the person that they are trying to revive, and then poof, carries on with the animation they were doing as if nothing happened.
No. This is only assumption because don't know what PBO it is and where it is but media\Sequence-01.ogv
yes thats what i desire. will try changing the animations commands
Neither _indexAddition nor _colour exists inside your event handler.
Oh I thought they would from the params, that always trips me up how can I fix that?
@grim cliff Maybe:
_unit switchMove _move1;
_unit playMoveNow _move1;
_unit playMove _move2;
Assuming that there is a valid transition from move1 to move2.
just tried playmove now, character pulls out launcher, sticks his hands between his legs and inverts himself into a donut, and then stands up as the action completes
injecting
It sounds like "valid transition from move1 to move2" might be an invalid assumption :P
that was with just the last tow commands that you posted
Tricky there without using global vars. Maybe store the temporary agent object into a var and then setVariable those parameters to it.
Something like this:
params ["_colour","_startLoc","_finishLoc","_indexAddition"];
private _route = [];
private _agent = calculatePath ["wheeled_APC", "careless", _startLoc, _finishLoc];
_agent setVariable ["pathColour", _colour];
_agent setVariable ["indexAdd", _indexAddition];
_agent addEventHandler ["PathCalculated", {
private _agent = _this select 0;
private _indexAddition = _agent getVariable "indexAdd";
private _colour = _agent getVariable "pathColour";
{
_markerNumber = _forEachIndex + _indexAddition;
private _marker = createMarker ["marker" + str _markerNumber, _x];
_route pushback _marker;
_marker setMarkerTypeLocal "mil_dot";
_marker setMarkerColorLocal str _colour;
_marker setMarkerSizeLocal [.5, .5];
} forEach (_this select 1);
}];
I haven't checked the RPT but it should be. I declare public variables in initServer.sqf so I assume they are available globally at the mission start, right?
Also on server in debugconsole I just hinted the first element of the array and it showed up so I'm pretty sure the array is declared.
Wow thanks for that
I notice if I hint str _route;` at the end it comes back an empty array, do I need to do more magic to get it OUT of the eventhandler?
If you need it out of the event handler, yes.
Yeah I need to return it
Not sure where you'd do that because PathCalculated doesn't fire immediately.
and the agent might not exist after the event handler completes.
So I guess you'd have to use a global var, but the method would depend on the use case.
Looks like you're only calling one of these at a time given the marker naming?
otherwise overlapping calls would fail anyway.
So you could just set a global var and then wait until it exists.
Basically I'm looking to call this function 3 times. And "out Route", "transit route" and then an "in route" to form a patrol route out of base to 2 map locations and back
So it plots a road route from base to A then runs again to plot a to b then finally b back to base and each time the markers get added to _route and then returned so I end up with an array of markers making up the entire patrol route (if that makes any sense)
I suppose route could be a global variable and then after the patrol I just empty the array 🤔
you have a marker name overlap problem then.
oh, I guess that's what indexAddition is for.
Anyway, the PathCalculated EH can easily take five seconds to fire.
so you'll need some scheduling shenanigans to deal with that.
OK I'll have a play around, thanks for your help
hi question anyone know if it's possible to have a terminal assign which side a player is on?
Hi guys.
Please tell me, I'm trying to restart the server via
"password" serverCommand "#restartserver"
But for some unknown reason, the server only stops and does not restart.
What can be wrong?
How would I execute below script using remoteExec? I'm unsure what a correct syntax would be?
[_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf";
remoteExec syntax is explained in the pinned
hello I am working on my burst missile script and have this code here. Where it takes the player position and adds 200m front of their plane and then sets the point at 750m altitude
private _position = vehicle player getRelPos [200,0];
private _newPos = _position vectorAdd [0,0,720];
_missile = createVehicle [_bomb, _newpos, [], 0, "CAN_COLLIDE"];
I want to make it so this line here where it spawns stuff in an entity to kill it it just nudges it like 200m forward
{_missile = createVehicle [_bomb, vehicle player, [], 0, "CAN_COLLIDE"];
so I want my second piece of code to spawn the _bomb (a preset bomb in code) 200m infront of the vehicle of the player
Is this your server, or one run by a server provider?
question is if I just add
private _position = vehicle player getRelPos [200,0];
{_missile = createVehicle [_bomb, _position, [], 0, "CAN_COLLIDE"];
triggerammo _missile
Will it blow up at the same altitude at 200m front of the plane or should I use getPosATL
like:
private _newPos = _position vectorAdd [0,0,(getPosATL player)];
This is my server. OS: Windows Server 2022
@polar belfry Just test it with the debug console. If the Z behaviour's not documented on the wiki then you'll be lucky to find someone who knows the answer.
Given that it shuts down, I'd guess that Windows is simply blocking the method Arma uses to do the restart for security reasons.
Is there a solution? Or maybe you can tell me where to dig to figure out what exactly and how it can block?
No idea. Arma doesn't document what it's using for the restart.
i thought it was #restart not #restartserver?
Arma moment
#restart just restarts the mission.
#restart - restarts the mission
#restartserver - restarts the server (at least it should do so)
Cheers,
So just to make sure I got it right remoteExec here would be:
[[_unit, "scrap", 0, 1], "DNT_supplies\DNT_createSupplies.sqf"] remoteExec ["execVM"];
Am I right?
Should do
btw on getrelpos
90 is right
_relpos = player getRelPos [100, 90];
so would 180 be back
270 be left
and 0 be front
yes. You could probably do -90 for left as an alternative.
Thanks
@tough abyss What about https://gist.github.com/ it's the same Idea as pastebin
found how to do my thing
get the altitude first and then do getrelpos
private _position = getposatl vehicle player;
private _newPos = _position vectorAdd [0,-500];
for anyone who wants it (Altitude with offset)
Tell me please. After restarting the mission using #restart - do all namespaces reset their variables?
https://community.bistudio.com/wiki/Namespace
Only those with Mission duration in the Lifetime column of the table.
Thanks
You had a addEventHandler for InventoryOpened in your original script. Commented out.
Now you have a addEventHandler, that will work. Just replace one with the other. (Remember to remove the eventhandler again once you don't need it anymore https://cbateam.github.io/CBA_A3/docs/files/events/fnc_removeEventHandler-sqf.html)
As I said before, turn your functions into real global functions, so you don't need to pass them around as local variables.
Then you also won't need to get some _function into your eventhandler
would this save a random int to the variable?
private _rand_num1 = [100, 300] call BIS_fnc_randomInt
of course
hello guys, please can someone explain me how to use event handlers in mod scripts. This scripts get spawned. I just write there addEventhandler set some code there and its just not triggers any events that i add to player
Post your code and what you actually wanna do.
player addEventHandler ["VisionModeChanged", {
params ["_person", "_visionMode", "_TIindex", "_visionModePrev", "_TIindexPrev", "_vehicle", "_turret"];
hint "changed";
if (_vehicle == _drone) then {
player setVariable ["pilotNow", true];
};
}];
i get this hint "changed" only when i start game, and then when i try to take control of any drone its not hinted
Because the "unit"s visionmode doesn't change
You actually look through a different unit
You want to detect when someone starts controlling the drone?
mh
actually yes
I don't know how to solve that 🤔
Maybe VisionMode on the drone could work, but probably not.
https://community.bistudio.com/wiki/isRemoteControlling + https://community.bistudio.com/wiki/remoteControlled
in a while loop, but thats shitty. Just keep checking
ill try this
works! thanks!
Is it possible to get the ammo count of a magazine from its classname?
You can look up anything that's defined in a thing's config (which default ammo count is) using commands like getText, getNumber
private _magAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magClass >> "count");```
neat, cheers
🍞
@still forum i finally made it, thank you!
does addaction work if I'm inside a vehicle for example I want some actions if I'm inside a SDV
Yes, provided:
- your position in the vehicle allows you to look at the thing the action is added to (doesn't matter if the action is added to you or the vehicle itself)
- the action condition doesn't contain any requirements about what vehicle you need to be in
I see
I try to get all my recent scripts as actions in a sdv to emulate the schinfaxi battle from AC5
if i get machine network ID of some player from this :
id = owner player
will i be able to execute in right way:
remoteExecCall [func, id]
????
Well you can, but you don't need to. If you have a reference to their player object, you can just use that as the remoteExec target and skip the owner step
so i can just write this "player" instead of its id?
They are repeatable by default unless whatever they do makes it impossible for their condition to be true
I am trying to find a spectator script I can add to player Init that will allow specate mode as If In Admin mode. Is there anyone with a script for this?
someone can help me how to write this script to convert Asl coordinates into the location of an object (plane) [[8132.62,4392.19,1110.44], "ammo_Missile_Cruise_01", car1, 180, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile; Please.
Replace the coordinates with getPosASL _plane, where _plane is whatever variable refers to the object you want to use.
If using the exact position results in the missile instantly hitting the plane and exploding, try (getPosASL _plane) vectorAdd [0,0,-3]
Thank you very much
Please don't DM me with scripting problems. Use this channel so everyone can see and help.
getPosASL returns a 3D position, which is a valid input for the function - it's exactly as if you'd written out the position coordinates yourself, just with the values automatically filled in with the object's position. I think you've probably typed something wrong.
It should look like this:
[getPosASL _plane, "ammo_Missile_Cruise_01", car1, 180, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile;```
or like this:
```sqf
[(getPosASL _plane) vectorAdd [0,0,-3], "ammo_Missile_Cruise_01", car1, 180, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile;```
If there are differences other than the name of the plane variable, that may be the source of the issue. For example, if you did `[[getPosASL _plane], "ammo_...` that would be wrong.
i want to use drawlaser to make lasers actually work during the daytime. is there a way to get the position & vector of the units rifle attached laser pointer?
Yes. But it requires a lot
how much is alot?
- Get weapon proxy pos/dir depends on the current weapon
- Create weapon Simple Object to get where should the laser pointer go
- Create laser pointer Simple Object to get where should the laser starts
- Sum them all
i want to use the drawlaser command compatible with missioneventhandler: "draw3d"
i just want to get the direction the players rifle model is pointing, and the attachments relative position, to use in `drawlaser [ positionasl, directionvector3d, . . .]
Pretty much what I told you is the way
That's what POLPOX is talking about too. The problem is that getting the (attachment) proxy position and direction is not a "just" problem. It's complicated.
well that sucks. how does arma do it?
It's Engine thing. None of our business
selectionPosition and selectionVectorDirAndUp surely can handle this situation
okay, sorry, mate. I will only write here. thank you for helping me with my problem. Regards.
can someone point me in the right direction I am working on a scrip and I am having a bit of a hang up
I am trying to make a function to teleport a player to the cosset point on a surface/roadway lod (like how getting off ladders works)
I was trying to use something get/set postion but the only way I have found is to just to brute force it by manually setting an offset unless I am trying to overcomplicate it or overlooked something simple
lineIntersectSurfaces (IIRC) to detect such case
thank you looks perfect for what I need ❤️
shield = createSimpleObject ["lxws\shield_f_lxws\shield.p3d", getPosWorld player];
{
shield animate [_x, 1,true];
}foreach animationNames shield;
shield attachto [player, [0,-0.125,-0.7],"spine3",true];
shield enableSimulationGlobal false;
i have this script to try to create a shield Ghost on the players back and im trying to figure out how to make it just a ghost that doesnt deflect bullets.
any idea ho i can do that?
Simple objects have physical world properties in them too, you'll need to make a special version of the model that doesn't have any FIRE geometry.
can i disable the fire geometry?
its from the western saharah DLC, as far as i know, those assets are encrypted
WS shield already is a vehicle. You can just spawn it and disable damage
i want it to not BLOCK damage
Ah well
I'd try something crazy like spawning it as a particle, but its gonna require some crazy scripting and I'm not sure if it will even work reliably
its getting attached to the players back as a prop
Spawn a dummy entity, have it drop a particle of that shield with exact orientation (you can do that since recently) with dummy as parent and infinite life time, attach dummy to player's bone
Not even sure if particle will follow dummy orientation at all
You can get selection vectorDir/Up directly now
Yeah but you can't operate particle once its dropped, this crazy idea will work only if particles follow parent entity orientation
can i create a proxy and attach that to the player?
No
If I do that, I only spawn the particle that lasts a frame
Huh, I wonder if that's doable
So many crazy crutches for a seemingly simple task

yeah...
wierd part is that the backpack version has no collisions when its in the backpack slot of the player
Probably because the model doesn't have fire geometry
Guns do, I think you can hit the gun specifically even when its a proxy in players hands
Now we need createSimplestObject command that would create particle-like model
how can i get the model of thebackpack that the player currently has on?
getText(configFile >> "CfgVehicles" >> backpack player >> "model")
or createReallySimpleObject by analogy with boundingBoxReal and boundingBox 
Being able to turn off specific LODs on an object would be my preferred solution to this issue since it would create many other opportunities
Not sure if engine allows something like that. If it doesn't it could be done as a way of procedural models modifying existing models.
private _model = createModel ["a3\...\model.p3d", ...];
"a3\...\model.mod1.p3d" or something, which you can later use for simple objects
- This post was made by no mods gaming gang
I did in Star Sphere Mod
To add: it even possible to delete a very certain particle drop using deleteVehicle
Oh yeah, by deleting the parent
No
The dropped particle
private _particles = (-1 allObjects 3) ;
_particles apply {
if (
getModelInfo _x#0 == "brabra.p3d"
) then {
deleteVehicle _x ;
} ;
} ;```A snippet, nothing to see here
Efficiency? dunno
oh wow, didn't know allObjects returns that
I wonder if deleting the parent deletes the particles, iirc it does but I'm not sure
if it does, deleting the parent might be more efficient
I don't think it should, I've never seen such instant delete
still trying to get the backpack shield asset working, but in getting an error saying im issing a ; somewhere in this:
deletevehicle shield;
shield = createSimpleObject ["lxws\shield_f_lxws\shield_backpack_black.p3d", getPosWorld player];
shield attachto [player, [0,-0.125,-0.7],"spine3",true];
shield setvectodirandup [[1,0,0],[0,0,1]];
setvectodirandup is not a command, do you mean setVectorDirAndUp
The syntax highlighter cleary said so too
wierd. that was arma autofill
I think it adds new words as you go so maybe you had it with typo before and it thinks its a variable name
thats really interesting I needed something like that a long time ago - wish there was a way to get it from the parent itself instead of filtering allObjects like that though
can someone explain how to use setvectordirandup becuase it seelms like the higher i push the number the less the object moves
what number?
not good at math just trying to rotate something attached to another object 180 degress
i understand none of that
im trying to make it make sense by testing different numbers in the debug console but it seems to be inneffective
you can easily get correct dir etc with
private _shield = createSimpleObject ["lxws\shield_f_lxws\shield_backpack_black.p3d", getPosWorld player];
private _shield attachto [player, [0,-0.125,-0.7],"spine3",true];
private _yaw = 45;
private _pitch = -180;
private _roll = 90;
_shield setVectorDirAndUp [
[sin _yaw * cos _pitch, cos _yaw * cos _pitch, sin _pitch],
[[sin _roll, -sin _pitch, cos _roll * cos _pitch], -_yaw] call BIS_fnc_rotateVector2D
];
does playsound3d need me to make a cfgsounds thing on description.ext
playSound3D does not require CfgSounds entry
thanks
is there a character limit in the init. I ask in case there is I should make my scripts for addaction in sqf files
afaik no, but it's better not to use the init at all if you have a lot of code (except for calling stuff)
If there is that would mean 2^8 or 2^16 or 2^32 characters... I guess?
I will make it then for my sake in two sqf files
It is more of a matter of readability and maintenance
and do this
player addAction ["<t color='#FF0000'>Burst missile Launch</t>", "sub_missile_burst.sqf"];
I think its not perfect. Others have made better versions of the same
Where do you execute it ?
Corpses are in a weird state after dying, very often it doesn't work.
Was just gonna ask that. You need to call the code on the client where player is local
ah the joys of this project, where deadlocking is an improvement :D
I have a list of items and count of them.
Is there a fancy function that I can use to compare count ( numbers ) of each item and check, if there is tie between any of them ?
Trying to prevent a tie before using selectMax to get always some winner from list.
private _list = [ ["land", 15], ["air", 12], ["sea", 15] ];
private _tie = _list findIf { ... } isNotEqualTo -1;
You mean if any two elements have the same number?
Can you sort the list by the count?
If the list is sorted
private _lastCount = -1;
private _tie = _list findIf { private _result = (_list select 1 == _lastCount); _lastCount = _list select 1; _result } } isNotEqualTo -1;
if there is a winner ( item with highest number ) return true
if there are 2+ elements with highest number and are same, return false --> need to recreate list
_list can have more entries
hashmap and foreach 😎
I bet under 5min and sa mantra has made an example with hashmap 😃
#arma3_scripting message
selectMax and get max amount, select the arrays that have max amount, selectRandom?
private _list = [ ["land", 15], ["air", 12], ["sea", 15] ];
private _winner = [-1, []];
{
if (_x select 1 >= _winner select 0) then {
if (_x select 1 != _winner select 0) then {_winner = [_x select 1]};
_winner pushBack _x;
}
} forEach _list;
At the end you have either
_winner = [12, ["air", 12]] have a winner
_winner = [15, ["land", 15], ["sea", 15]] Have multiple winners
Check how long the array is to find out if there was a tie on the top
You can also do it in one array
private _list = [ ["land", 15], ["air", 12], ["sea", 15] ];
private _winner = ["", -1];
{
if (_x select 1 >= _winner select -1) then {
if (_x select 1 != _winner select -1) then {_winner = []};
_winner append _x;
}
} forEach _list;
_winner = ["air", 12] have a winner
_winner = ["land", 15, "sea", 15] Have multiple winners
boom, fixed
50 threads all accessing the SQF engine with no crashing or deadlocking
:D
that was fun
Performance of both of these probably not too great.
But they can both use SimpleVM
if I want to make a for loop that works as long as something is alive
do I write this
for (alive sub) do{
while {alive sub} do{
with {}
With private _list = [ ["air", 12],["air", 12],["air", 12],["air", 12],["air", 12],["air", 12],["air", 12],["air", 12],["land", 15], ["air", 12], ["sea", 15] ];
to create some load.
Normal / SimpleVM
Top one
0.107191 ms / 0.109667 ms
bottom
0.105697 ms / 0.108428 ms
Huh.. SimpleVM actually does make it worse.
private _list = [ ["air", 12],["air", 11],["air", 11],["air", 11],["air", 11],["air", 11],["air", 11],["air", 11],["land", 15], ["air", 11], ["sea", 15] ];
0.0765079 ms / 0.0772897 ms
and
0.0799486 ms / 0.0833709 ms
mh. Welp
Ah duh. SimpleVM doesn't work because theres a variable assignment. So it tries to build it and fails. ofc
private _position = vehicle player getRelPos [900,180];
private _newPos = _position vectorAdd [0,0,1000];
_missileDir = _newpos vectorFromTo getPosATL vehicle player;
_missile = createVehicle ["ammo_Missile_rim162", _newpos, [], 0, "CAN_COLLIDE"];
_missile setVectorDirAndUp [_missileDir, [0,0,-1]];
This is in one of my scripts I want to make it so the missile spawns 1km above the plane is this ok?
can I only get the Z(altitude) by any commands and do Z+1000 in vector add
nice
I get this error with this here code
null=[]spawn{
_i= 1000;
_bomb = "FIR_GBU24A_BLU118";
_degree = 0;
for "_i" from 0 to 3 do{
private _rand_num = [10, 250] call BIS_fnc_randomInt;
private _position1 = p3 getRelPos [_rand_num,_degree];
private _newPos1 = _position1 vectorAdd [0,0,500];
_missile = createVehicle [_bomb, _newpos1, [], 0, "CAN_COLLIDE"];
triggerammo _missile;
_degree = _degree +90;
};
playSound3D ["burst_missile_global_sfx.ogg", _newpos1];
deletevehicle p3;
}```
should I make a variable out of "for"
like ```sqf
private _newpos2= _newpos1;
the coordinates of the last bomb that got spawned
I want the sound to start from there
It looks better to execute playSound3D if _i == 0 instead
if _i ==0 then{
playSound3D ["burst_missile_global_sfx.ogg", _newpos1
}```
In the for loop?
I guess
ok will test
Also for Miller's sake, you SHOULD to use indent and spacing wisely or you will lose some sanity afterwardssqf [] spawn{ private _bomb = "FIR_GBU24A_BLU118"; private _degree = 0; for "_i" from 0 to 3 do { private _rand_num = [10, 250] call BIS_fnc_randomInt; private _position1 = p3 getRelPos [_rand_num,_degree]; private _newPos1 = _position1 vectorAdd [0,0,500]; if (_i == 0) then { playSound3D ["burst_missile_global_sfx.ogg", _newpos1]; }; _missile = createVehicle [_bomb, _newpos1, [], 0, "CAN_COLLIDE"]; triggerammo _missile; _degree = _degree +90; }; deletevehicle p3; };
In my files in notepad ++ it has indent it's just the init messes it up
In my files it has indent
and
it's just the init messes it up
My language processor failed to connect these two sentence and its meanings
sorry I wote it quickly
I wanted to say that when I write it in notepad++ I give it indent but sometimes init with the way it treats lines moves it
but thanks for the advice
Visual Studio Code entered the chat
30 threads pulling back player pos every 10ms and spitting it to a log file
no FPS impact
fucking right fucking on
hey, I have a question for you. I noticed that some commands entered in the int of the Eden unit do not want to run, but if I enter the same commands using the sqs file, they work. anyone know why this is happening?
- What is the commands you mean
- Why an SQS is still used on your end
- And what have you done actually
"true", // condition
//change to
driver _target isEqualTo _this // check if player is driver of current vehicle
//_target: Object - The object to which action is attached or, if the object is a unit inside of vehicle, the vehicle
//_this: Object - Caller person to whom the action is shown (or not shown if condition returns false)
Too fast delete
XD
Setvariable for lightbar. If writte in init line not start but when i use exec sqs is ok
Well what is the code, and still doesn't answer my question 2
@warm hedge give me sec i start pc 😀
it's about a script to make the car's lightbar work for AI. When I enter this command in the init of the Eden unit, nothing happens. but if I create a sqs/sqf file (with this command) and add exec to the car's init, then it works. this setVariable["ani_lightbar",1]
the same thing happens when, for example, I want to use the player enableStamina false command
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
Also, SQS and SQF are not the same thing too. SQS is very obsolete and deprecated for like more than a decade
when I enter it in a text file and save it as sqf and then add exec name.sqf to the car's init, then the lights work. But when I enter this script directly into the unit's init without using exec sqf, it doesn't work. this is this command: this setVariable["ani_lightbar",1];
yes, yes, I know, I wrote sqs only out of curiosity, I meant sqf
Besides I can't really express how I am confused with out of curiosity can happen in this context, but anyways, are you actually sure it is not working? Error messages?
Yes, I'm sure and I'm also very surprised because everything has always worked. There are no error messages. Could this be an error caused by the presence of some mod that prevents the engine from completing scripts (some of them) after entering them directly into the unit's init?
I also noticed that when I type "player enableStamina fales;" in the soldier's init; this doesn't work either. But when I put it in the sqf file and execute it using this exec then it works, strange
prevents the engine from completing scripts
Nearly 100% sure this cannot be the reason. I'm thinking that because the code has been overwritten by some Mod or function else other than yours because your code does it before the first frame, and within next frames yours is somehow overwritten
I also tried replacing "this" with the unit name in the unit's init and it didn't help either. Okay, thank you for your help. It is important that the script is run using "exec.sqf". Regards
I would blame how the Mod is made instead of your code or how you execute them
I see. I can somehow deal with this by simply writing it using sqf . Thanks and have a nice evening 🙂
Even though I'm not saying it is the 100% reason but since how execVM works it could happen a bit of delay
this setVariable ["varname", 1]; should work fine in an init box.
whether it has the knock-on effects you expect is another matter.
well, it doesn't work. and once it worked without any problem, I have the same problem with the command "this enableStamina true; But I'm just asking out of curiosity
Are these commands on their own in the init box?
execVm and regular exec work without any problems. Ok, topic closed, no point in wasting your time. The important thing is that this can be bypassed with sqf files
yes, all others work normally. And these two don't want to and that's what surprises me
how to calculate difference from sea level and point underwater?
I am using it for a cruise missile I want to spawn from a sub. I got the over the water part but need to now make it underwater
I also tried in eden using triggers and game logs and still nothing. And when I use the sqf file with this command then it works
I'm closing the topic. Thank you for your help
I tried both the setVariable and enableStamina just now and they work.
thanks
Well, everything has always worked normally for me. And now no, maybe it's the fault of some mod and I have a lot of them and I don't want to look for the reason eheheh. Thank you for your help 🙂
har har harrr
Hey guys, i got a question about APCs.
Why does the player control an AI mounter APC even though the Player is the passanger
Is there a remedy or a script that makes the AI just move towards their set waypoints
if (( getposasl vehicle player) select 2>=-3) then{
private _pos = launch modelToWorld [0,2,1.6];
private _missile = createVehicle ["ammo_Missile_Cruise_01", [0,0,0], [], 0, "none"];
_missile enableSimulation true;
_missile setPosASLW _pos;
_missile setVectorDirAndUp [[0,0,1], [1,0,0]];}
else{ _seaDepth = abs (getTerrainHeightASL getPosATL launch);
private _pos = launch modelToWorld [0,2,1.6];
private _missile = createVehicle ["ammo_Missile_Cruise_01", [0,0,0], [], 0, "none"];
_missile enableSimulation true;
_missile setPosASLW _seaDepth ;
_missile setVectorDirAndUp [[0,0,1], [1,0,0]];
}
Here's my idea to run it
and is it possible to write in an sqf document so that I don't have to enter the name of the unit and just use "this"?? Because I write it into sqs "this setVariable["ani_lightbar",1];" and in the unit init I enter "this exec "light.sqs"; and then it doesn't work. And I don't want to have to enter the name for each unit
In add action?
You can add that if condition in addaction condition, so it won't show up if vehicle position z is not > -3
I need to fire it from underwater
so the thing I want to do is when the sub is underwater to spawn the missile where the launch (reference point on the sub with a prop) is but on the water surface directly above it
first of all, use .sqf
second of all:
this execVM "light.sqf"
params ["_obj"];
_obj setVariable["ani_lightbar",1];
if you always do this execVM "light.sqf" you can also just write: _this setVariable["ani_lightbar",1]; in the SQF file
Thank you very much 🙂
I need to find a way to put the missile on the water surface
I wrote you a private message because I sent you a photo, can you reply please?
Does BIS_fnc_setServerVariable and BIS_fnc_getServerVariable work in SP?
probably a lot better than they work in MP...
On MP it uses a waitUntil without sleep for the request, so it's a major performance drain.
ok, but how do i get them on needed machine? By remoteExec?
and publicvariableclient?
hmm. I guess it's only a couple of statements per frame.
ok, but how do i get them on needed machine? By remoteExec?
In SP there is no server. The variable are then just available in whatever namespace they were set to
you say its better just to setvariable with public true?
but i need it in MP
Uh, what's your actual use case?
i got mod for sp and mp
The BIS function there is for if you want a return value. Hence it's complicated.
i set some variable quite often
If you don't want a return value then don't use it.
It's certainly not a general replacement for setVariable or publicVariableXXX commands.
Does it need to be set so often?
and what i think would be best, is to set it on server and then needed player will get it when he calls for that
but thats not only for mp
like, some player sets it
and other get
Questions is, how frequent do they set it. Is there no event handler that could cover that?
it depends on how do they play with that
if possible how can I offset the missile to spawn 45m above it's spawnpoint for else{