''' _rnd1 = floor random 4;
if((typeOf cursorTarget == "Obj1") || (typeOf cursorTarget == "Obj2") || (typeOf cursorTarget == "Obj3") || (typeOf cursorTarget == "Obj4") && (player distance cursorTarget < 7) && ( _rnd1 == 0 )) then {
action1 = player addAction ["Knock Knock", {deleteVehicle cursorTarget; player removeAction action1; removeAllActions player; hint "Who is there!";}];
} else {
player removeAction action1;
removeAllActions player;
};'''
#arma3_scripting
1 messages · Page 150 of 1
(https://community.bistudio.com/wiki/Arma_3:_Functions_Library)
// fn_addMyAction.sqf
params ["_target"];
private _actionID = _target addAction [ ... ];
_target setVariable ["my_var_actionID",_actionID];
// fn_removeMyAction.sqf
params ["_target"];
private _actionID = _target getVariable ["my_var_actionID",0];
_target removeAction _actionID;
// when you want to add the action
[_target] remoteExec ["my_fnc_addMyAction",0,"myActionJIPID"];
// when you want to remove the action
[_target] remoteExec ["my_fnc_removeMyAction",0,"myActionJIPID"];
test
However, for your specific system, it might be better to make it so that both actions are actually present all the time, and each one has a condition that only makes it visible when the cargo is loaded or not loaded, as appropriate. This is often simpler than doing add/remove action all the time.
if((typeOf cursorTarget == "Obj1") || (typeOf cursorTarget == "Obj2") || (typeOf cursorTarget == "Obj3") || (typeOf cursorTarget == "Obj4") && (player distance cursorTarget < 7) && ( _rnd1 == 0 )) then {
action1 = player addAction ["Knock Knock", {deleteVehicle cursorTarget; player removeAction action1; removeAllActions player; hint "Who is there!";}];
} else {
player removeAction action1;
removeAllActions player;
};```
Thanks a lot)
so I can't figure out why it always allows it, as _rnd1 can't always == 0
secondly, I'm trying to turn that into a waitUntil, so it can run and the addaction will come up when the conditions are met (random = bla) (cursorTarget = bla) (within 7m)
_objects = ["Obj1","Obj2","Obj3","Obj4"];
waituntil {typeOf cursorTarget in _objects && player distance cursorTarget < 7 && _random == 0};
action1 = player addAction ["Knock Knock", {deleteVehicle nearestObjects [player, [_objects], 15]; hint "Who is there";}];
waituntil {!typeOf cursorTarget in _objects && player distance cursorTarget > 7 && _random != 0};
player removeaction action1;
removeAllActions player;```
but that doesn't seem to work
any help?
I am trying to fire a trigger when any player gets in a vehcile. Right now I have this but it only works in SP not MP:
player in (crew ptboat);
or just add
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn
and check if unit is player who enters in vehicle and execute your code and remove event
I found this one on reddit too:
(allPlayers - crew ptboat) isEqualTo []
Now I know there lots of ways to do the same thing but which is optimal?
Or rather what considerations should I be thinking of?
This line returns true when all players are in vehicle, not just any player.
Actually was a pleasant surprise for me. I hadn't considered doing it that way but it would actually probably make the mission progress smoother since it forces players to all be on the same page before the next task is created.
@timber shore have you swapped out actual classnames for Obj1,2,3,4 in that script?
But to ask from a performance perspective. If I used a if statement, does that mean its constantly being calculated? If so, does that inhibit performance?
cos typeOf returns a classname
If I used a if statement, does that mean its constantly being calculated?
No. Yes, if it was placed in a loop.
If so, does that inhibit performance?
Same as above.
I racked my brain trying to find a solution to this JIP issue:
-
I want the mission to start with a black screen, run some type text, then fade in. The only way I've been able to get it to work seemless is placing the code into
init.sqfbecause that gets ran before the briefing screen. Otherwise the mission starts without a black screen for a second then flashes to black screen and then back in. Unfortunately though, this meathod this means that any JIP has to sit through this intro because theirinitwill run again when they JIP. -
So then I tried
remoteExeca SQF with the code at the start of the mission with a BLUFOR present trigger. This works good for JIP because I can set the trigger to Server Only so it wont run again for JIP players. But I still get that brief second before the code runs and turn the screen to black.
What would be a good workaround for this?
Use a variable to detect whether the intro has already been run
For example:
if !(missionNamespace getVariable ["my_var_introdone",false]) then {
// insert intro here
};
// on the server, some time later:
missionNamespace setVariable ["my_var_introdone",true,true];```
JIP clients will receive the variable broadcast from the server before they run init.sqf. The variable being set to true will tell them the intro has already happened and they can skip running it.
Hmmm. Okay this kinda makes sense to me but I'm struggling a little bit with the if portion.
So the if is looking for just my_var_introdone right?
And if it see it then it wont run the code?
If the variable is false it will run intro, otherwise not
Since the false is "default parameter" this will be also the case if the var is not set
Is that what the ! is?
if(alive player) then {systemChat "Player Alive"};
if!(alive player) then {systemChat "Player Dead"};
Whould this be the same?
if (isNil "my_var_introdone") then {};
We will have a chat tonight @blissful current when I get home
Thank you Nikko, it works great! Question is this if statement a loop? If so should I worry about performance?
No, things are not just automatically a loop.
Your condition may be checked in a loop, depending on how you're implementing it.
This is my first time writing a Fired event handler. The hint message doesn't print so I've done something wrong.
if (triggerActivated ExtractConvo) then {
_player addEventHandler ["Fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
if ("vn_m18_purple_mag" in _magazine &&
(_unit inArea "Grenade_Marker" || _unit distance markerPos "Grenade_Marker" < 100)) then {
hint "Purple Seen";
};
}];
};
You'd have to show more of your code, if that is your entire file then _player is undefined when trying to add the event handler.
I do have _player defined several lines up do I need to define it multiple times in the SQF?
No, but I don't know the context of your code
this is directly above it (and works)
params ["_player", "_didJIP"];
if (isNil "mission_SmokeThrown") then {
_player addEventHandler ["FiredMan", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
if !isNil "mission_SmokeThrown" exitWith {
_unit removeEventHandler [_thisEvent, _thisEventHandler];
};
if ("vn_m18" in _magazine && {_unit inArea "marker_1_LZ" || {_unit distance markerPos "marker_1_LZ" < 100}}) then {
missionNamespace setVariable ["mission_SmokeThrown", true, true];
};
}];
};
I used it as a guide to write the other one I posted.
if !isNil "mission_SmokeThrown" exitWith
Missing parenthesis
Oh wow. And that one works fine without any error codes too. Good catch. But it doesn't explain where I've gone wrong in the first example.
Are you using the Advanced Developer Tools mod?
I would definitely recommend it, it has much better tools compared to the vanilla ones.
Mainly for this, it's debug console has proper syntax checking before it is executed:
https://steamcommunity.com/sharedfiles/filedetails/?id=2369477168
Will it add any dependencies to my mission?
Nope
Nice. I just asked ChatGPT to check mine for errors and its say its fine (I know chat GPT can be wrong)
It will almost certainly be wrong
especially with SQF
also, remember to make threads @blissful current . you have a lot of questions independent of each other
I can't stand any sort of AI assistant. Especially for programming.
i think its pretty good at teaching human languages though. possibly better than duolingo
Im sure it gets me in trouble. But its been a quick way to help me find my beginner mistakes.
That's what a debugger is for
vscode i like better. especially when you start integrating with github
No, SQF is a scripting language for arma. No text editor is going to have built in support for it. You'll be mostly fine with writing and/or testing your code in ADT's debug console
Event Handler Advice Needed
Actions can also be used by AI units. Which do exist on servers.
Though I would hope no one does that, and I don't know how you would do it.
VSCode also has a SQF debugger that functions like any other debugger
can AIs trigger addAction actions through action?
Eject, getout, rearm are also the mouse wheel actions, that can also be triggered by action command.
Same system.
If anything then that
But addAction doesn't have a unique name.
I might look it up later
If I were wanting to make a script so people who disembark from a boat near a dock gets placed on the dock, would it be best to have a trigger at said dock, and then somehow capture the disembark event, and if the disembark comes from a boat object, then run the teleport to ontop of the dock?
that's new to me. still for player he can probably only use local addActions
true. but personally I wouldnt put anything on server that doesn't belong there, even if it fails silently
yeah actions are local
Wiki says addAction is ignored on server. But.. Its not.
There isn't any server check there in the code.
The type for the action command is "User"
And then you have to use the actions id/index
That's even documented https://community.bistudio.com/wiki/Arma_3:_Actions#User
So with that, you can addAction on a server, and let server-side AI units execute it
interesting, I wonder what are the use cases for that
Seems stupid and backwards for me.
Why run a script to run a action that runs a script.. If you could just.. run the script
Do I define functions that my module(s) will use in the pre-init?
or just CfgFunctions
anything in mind? 😋
No, I hope noone uses that
Ok if I were to have multiple functions defined in CfgFunctions e.g. function1, function2 and a module module1.
Would it be a problem if module1 called function1 which then called function2?
I'm not sure if I'm overthinking it but would there maybe be a problem where a function calls another function before it exists?
Ok so functions defined in CfgFunctions are created before the init of a module for example is executed?
yes
Thank you, think I'm beginning to understand it
How to make Get in task?
Ok, so first, I have this script for my scenario,
https:/ibb.co/J7y72Xn and this script was working
but not the way I wanted it to, so in the opening of
my scenario, I was already in the car, so the problem
here is that the task that was supposed to show
later when I enter the vehicle was already showing
in the opening, so the problem here is that the task that was supposed to be later was already showing up because I have this task where I need to get in the vehicle, so that mission needs to show up, but italready shows up because I was already in the car.So what I wanted is that there's a different car that
will activate the mission, but I don't know how. I'm
sorry if this is confusing. I don't know how to explain
it properly.
Just wanted to say everything works so much better now and my code is so much cleaner, thank you very much!
I didn't even do anything, its all you
Thank you anyways
Might've seemed simple but it helped alot.
If you have some specific car.
You can add trigger and condition
player in yourCarVarName
that's possible with the https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetOut event handler
Hi guys!
Does an AI unit become removed from the server if it joins a player's group?
Its locality switches to the player's client, if that's what you mean.
But unit become removed to the server, right ? For player - local, for server - removed
After join
"removed" is an odd word to use.
With CBA Settings is there a way to make a settings hidden, aka you can only view the contents of the setting if you are logged in as an admin/able to change it. I want to store a password and for obvious reasons want it to remain secure
"NOT LOCAL" is better ?
"remote" if you like.
Well ? remote or still local ?
A unit is only local on one machine at a time.
So yeah, if the locality switches to a client, it's no longer local where it was local before.
Thanks)
Unitcapture isn't firing, for a reason I can't see
Both are capped with ]];, so that shouldn't be a problem.
There is no BIS_fnc_unitCapture* in that screenshot 🙃
Other than that it looks good. What does systemChat str [_v1_2dothings, _v1_1dothings, _V2dothings] give you?
my bad, I mean I've captured the units already haha
Dothings is working correctly, it's the playFiring that isn't working properly
That's weird. systemChat str [_v1_1pewdata, _v1_2pewdata]; returns [any,any]
The sample output on https://community.bistudio.com/wiki/BIS_fnc_unitCaptureFiring has three elements per array, yours only has two. Wiki could be outdated tho 🤔
That is odd. Mine only has 2 elements in each array. [213.368,"UK3CB_BAF_CannonM621"]
Let me check my previous scripts
Nope, apparently my last working scripts have 2 elements. Huh.
Oh that's *pewdata, I thought it was the result of BIS_fnc_unitPlayFiring.
In that case, are you sure that all *pewdata array brackets match?
Maybe check systemChat str [count _v1_1pewdata, count _v1_2pewdata] too.
yes
I have a problem, when the gunner's sight is aimed as low as possible, the bullets fly above the sight, when the gunner's sight is aimed as high as possible, they fly below the sight, how can I make it so that they always fly to the center?
Unless this whole thing is somehow being controlled by scripting, this is a problem with the vehicle's animations/config, not a scripting issue - the gunsight and the guns themselves aren't properly aligned.
add the setting only on specific clients is only thing i can think of
Has anyone had success with:
https://community.bistudio.com/wiki/land
My helicopter lands but then immediatley takes off. I need it to stay landed (with engine on) until I trigger it to move to the next waypoint.
What waypoint is it on when you order it to land?
for the general case, lockWP should work.
I am trying to use scripting to do the waypoints because the in editor stuff wasn't doing what I wanted.
This is the first waypoint that get the helicopter to the area and loiter through an addAction. Works perfect.
_group = ExtractHeli; //names heli group
_markerName = "marker1"; //name of marker
_waypointPosition = getMarkerPos _markerName; // adds waypoint to marker
_waypoint = _group addWaypoint [_waypointPosition, 0]; //moves group to waypoint
_waypoint setWaypointType "LOITER"; // group loiters waiting for my next addaction
Once it gets to the area the idea is to use an addAction to have it land on a specific marker. I haven't tried using markers yet for the next waypoint because I haven't gotten it to stay landed. First I gotta do that then I'll try to incorporate markers.
ExtractHeli land "LAND"; //immediatley takes off and hovers after landing. DOH!
You're adding a move waypoint after the loiter waypoint as well though?
I tried to do that then set the waypoint type as land but it gave a foreign error.
If thats what you are getting at
There is no "land" waypoint type.
I found that out the hard way. lol
I need it to stay landed (with engine on) until I trigger it to move to the next waypoint.
So there is no other waypoint at the moment? There's just the loiter?
Correct. I'm trying to build it one step at a time. Ive got it to loiter in the area. Next step is to get it to land.
But you did get it to land?
You could just delete the loiter waypoint when you give the land command. Probably works.
Yes. What I am saying is helicopter land mode lets the helicopter land then it immediatley takes off. I want it to STAY landed.
If it's still in the loiter waypoint then that wouldn't be surprising.
Not gonna loiter on the ground :P
Okay I will try to delete the waypoint. I suppose the best time to do that is right before I issue that land in the script.
setCurrentWaypoint to one beyond the loiter might also work.
I assumed that if you used addWaypoint it would cancel out the last assigned one.
addWaypoint never overwrites. Default behaviour is to add the new waypoint at the end. You can also insert with the third parameter.
but you only have one waypoint anyway.
What am I supposed to put in the index? deleteWaypoint [group, index] The in editor tells you a number but since I am using script should I just count in my head? If so, does that mean the first one is 0 like in the editor or would it be 1?
you should check what waypoints you actually have using waypoints
Sometimes groups get a default move waypoint on creation, so the first one you add is actually index 1.
Never pinned down the logic there.
(might also have been a local bug. I figured more shit out since)
Does this happen each mission start?
first waypoint is [group, 0] anyway. Second is [group, 1]
unconfirmed. Just check what's actually happening with waypoints and currentWaypoint
Also forward-deleting multiple waypoints was buggy IME.
Oh wow so basically for any waypoint I need to use waypoints then somehow script it to grab the value?
Probably not. I just don't remember the exact behaviour off the top of my head.
Waypoint scripting is extremely poorly documented, and quite buggy. You have to do your own research to a degree.
I guess that means most people just use the in editor one then? I found that to be quite restrictive on what I wanted to do.
For example if I wanted to have a ANY waypoint AFTER the loiter one (which I would skip with a waypoint trigger at the appropriate time), the helicopter would no longer do circles but would just hover in place.
That's what led me down this rabbit hole of waypoints in scripting.
I think that's normal for loiter waypoints, regardless of whether you script them or not.
There is an argument with scripting for dropping waypoints entirely, given that they're a buggy black box full of shit, but that's rather more work and you're still quite limited with what you can do with the AI.
Well I tried the deleting waypoint and it worked. 1/5 times. LOL. the time it did work it turned the engine off too . DOH!
If you make a simple mission demonstrating the issue then I can look at it.
And just as you have said waypoints is returning 2 different ones even though I only have one at the moment. So its creating one on spawn.
For sure I always build and idea in a test mission first before then integrate it when it actually works.
do you want PBO or just the files?
Heyo, I'm trying to run a multiplayer operation of a steam workshop mod, but we're instantly dying, respawning, and Game Over-ing at grid 000000 like the mission maker didn't add respawnOnStart = 0; to description.ext. Is there any way I can correct this to allow the mission to play in online multiplayer as somebody who does not own the mission?
is it possible to have a tv on the ground to emit light in a room?
Helpful answers also work too, gonna try and PBO manage it back into a mission file and add the appropriate scripting. (P.S. That did the trick!)
Hey I am new to scripting on Arma 3 and I am trying to learn some basics, any tips are welcome. I am having an issue with saving custom loadouts from arsenal this is for players,
My code for onPlayerRespawn.sqf:
removeAllweapons P1;
removeAllweapons P2;
removeAllweapons P3;
removeAllweapons P4;
removeAllweapons P5;
removeAllweapons P6;
removeAllweapons P7;
removeAllweapons P8;
removeGoggles P1;
removeGoggles P2;
removeGoggles P3;
removeGoggles P4;
removeGoggles P5;
removeGoggles P6;
removeGoggles P7;
removeGoggles P8;
removeHeadgear P1;
removeHeadgear P2;
removeHeadgear P3;
removeHeadgear P4;
removeHeadgear P5;
removeHeadgear P6;
removeHeadgear P7;
removeHeadgear P8;
removeVest P1;
removeVest P2;
removeVest P3;
removeVest P4;
removeVest P5;
removeVest P6;
removeVest P7;
removeVest P8;
removeAllAssignedItems P1;
removeAllAssignedItems P2;
removeAllAssignedItems P3;
removeAllAssignedItems P4;
removeAllAssignedItems P5;
removeAllAssignedItems P6;
removeAllAssignedItems P7;
removeAllAssignedItems P8;
removeAllItemsFromBacpack P1;
removeAllItemsFromBacpack P2;
removeAllItemsFromBacpack P3;
removeAllItemsFromBacpack P4;
removeAllItemsFromBacpack P5;
removeAllItemsFromBacpack P6;
removeAllItemsFromBacpack P7;
removeAllItemsFromBacpack P8;
removeBackpack P1;
removeBackpack P2;
removeBackpack P3;
removeBackpack P4;
removeBackpack P5;
removeBackpack P6;
removeBackpack P7;
removeBackpack P8;
P1 setUnitLoadout (P1 getVariable["Saved_Loadout_P1",[]]);
P2 setUnitLoadout (P2 getVariable["Saved_Loadout_P2",[]]);
P3 setUnitLoadout (P3 getVariable["Saved_Loadout_P3",[]]);
P4 setUnitLoadout (P4 getVariable["Saved_Loadout_P4",[]]);
P5 setUnitLoadout (P5 getVariable["Saved_Loadout_P5",[]]);
P6 setUnitLoadout (P6 getVariable["Saved_Loadout_P6",[]]);
P7 setUnitLoadout (P7 getVariable["Saved_Loadout_P7",[]]);
P8 setUnitLoadout (P8 getVariable["Saved_Loadout_P8",[]]);
My code for onPlayerKilled.sqf:
P1 setVariable ["Saved_Loadout_P1", getUnitLoadout P1];
P2 setVariable ["Saved_Loadout_P2", getUnitLoadout P2];
P3 setVariable ["Saved_Loadout_P3", getUnitLoadout P3];
P4 setVariable ["Saved_Loadout_P4", getUnitLoadout P4];
P5 setVariable ["Saved_Loadout_P5", getUnitLoadout P5];
P6 setVariable ["Saved_Loadout_P6", getUnitLoadout P6];
P7 setVariable ["Saved_Loadout_P7", getUnitLoadout P7];
P8 setVariable ["Saved_Loadout_P8", getUnitLoadout P8];
I keep getting error unidentified variable p2
!code
How to use SQF syntax highlighting in Discord
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
I don't think you really need to do that for every single player each time somebody dies or player respawns
Also you don't need to remove stuff before using setUnitLoadout as it already deletes everything first
All you really need is:
onPlayerKilled.sqf:
params ["_oldUnit", "_killer", "_respawn", "_respawnDelay"];
if(_oldUnit == player) then { // I don't remember if this script is global
_oldUnit setVariable ["Saved_Loadout", getUnitLoadout _oldUnit];
};
onPlayerRespawn.sqf:
params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];
_newUnit setUnitLoadout (_newUnit getVariable "Saved_Loadout");
Thanks so much man! Worked like a charm been trying to figure out this for to long lol your a life save. Thanks for the link too going to come in handy, have a goodnight or day depending on where you are in the world!
Since introduction of cursorObject many years ago typing curs autocompletes into cursorObject instead of cursorTarget and you end up with random crap instead of relevant objects:
Unplayable 😡
(Disclaimer: This is a joke rant about writing quick test scripts and them failing because of autocomplete to command you don't want)
i dont remeber the last time I wanted cursortarget over cursorobject
cursorObject picks all entities, even proxies
For example looking at soldier and cursorObject can return proxy weapon in their hands
cursorTarget likes to ignore unrevealed objects though and revealing can take unreasonable amount of time for something in front of you in a real game
I don't use either for anything serious
true but cursorTarget for example will change when using a lock on launcher to whats locked onto despite the player not looking at it
or at least it used to
I think it still does, yeah
Other cursor targets in command mode, main map cursor, etc.
No, but you can additionally place a light
Hi guys!
I have many addAction commands in my "init" file. Would it be a good idea to put these commands in a separate file for loading them, or in "initPlayerLocal" for example?
And in general, what is correct to place in the "init" file?
And if place them in a separate file, what file should this be? Function or .sqf ?
Many places are correct, depends on what you're trying to do. Its better to keep editor fields small and put bigger stuff into files.
So, if I put some big code in separate file, will be it better ?
Up to you for it being a file or a CfgFunctions. First one is quicker, second is more organized and if you want to use it later elsewhere.
Performance-wise it will be the same, its just more convenient and organization matter in your case.
If you add same actions to lots of objects, either do call compile preprocessFileLineNumbers "" or lazier execVM with your entity as arguments for each object. Or call to CfgFunctions.
initPlayerLocal can work too but this is somewhat different context, it executes much later than init fields of objects
For example if you'll have your stuff there it won't execute on say dedicated server because there is no player
You need to understand context for your code to decide where to put it better
I can advise if you can give more details. If its just add actions, you can just move them into files so its easier to manage
I have some code in my init file which add action menu for supply objects ( boxes ) and for AI units
I saw or read somewhere that a function with calling "spawn" is much better, than a .sqf file with calling "execVM". The first reason, you don't need to constantly enter the path to your file, another one - performance or call speed
Its a better habit to put your stuff into functions indeed. Performance difference is drop in the ocean if you do it on mission start.
So, in my addAction I use exactly functions with "spawn" command
That is, will be better to load something "big" while loading a mission, than load this in during the mission, right ?
Yeah, that's what initial loading is for, preload as much as possible.
There is also a matter of scheduled and unscheduled environment. Engine events like init field in editor, events like Fired all execute in unscheduled (everything is halted until script finished execution), so if you want do so something instant like say delete the bullet right in the Fired event handler by some condition, neither spawn nor execVM will do. Even call compile ... is a terrible fit because it will read and compile the function each time something fires a bullet. For such cases the only correct way is to preload the function (call compile ... on load or CfgFunctions) and then call it
Another upside for editor init fields is that you don't need to assign variable names to stuff as you can easily refer to the object with this magic local variable (no _), while if you'd put your stuff into say init.sqf, you'll need to find the object somehow (refer by variable name which is rather ugly if you have lots of them)
For example, you have 10 boxes in the map, with 3 of same actions on each, you can:
- Add 3 actions right in init field in each:
this addAction ["Action 1", ...]; this addAction ["Action 2", ...]; ...and copy-paste it into each of 10 boxes. Huge pain, when you'll want to change something in one action you'll need to change it in each 10 boxes and I guarantee you'll forget something somewhere - Name each box
box1,box2, etc. Then ininit.sqfdo:
{
_x addAction ["Action 1", ...];
...
} forEach [box1, box2, ...];
```This is a better approach but later if you add more boxes or delete some you'll mess up variable names, forget to remove some variable from this array, get undefined variables error, etc. Better but still plenty of ways to mess up.
- Declare your function with actions addition in `CfgFunctions`, then add init field for each box: `this call TAG_fnc_addBoxActions`; And have that function do
```sqf
_this addAction ["Action 1", ...];
...
```which is easy to edit, no need to mess with box variables, you can easily delete, copy boxes to any amount without a worry.
There are variations to these approaches but the last one is defeinitely the best one by all means, except having to learn how CfgFunctions work but you do that once and you're good forever.
Honestly I remember being confused about script entry points quite a lot back when I started in 2012, there were a lot of options and not much info, small bits all scatered everywhere. Maybe we could use an article like this on wiki.
I probably should have added execVM way between approach #2 and #3 as a lazier solution without CfgFunctions too
this execVM "addBoxActions.sqf", you get the idea
Do you mean make a one function, inside which will be actions for each box ? And then just call this function... ?
addAction in my case
Then you can either have code for actions right inside addAction or call another function
_this addAction ["Action 1", {systemChat format ["Box action one for %1", _this select 0]}];
vs
_this addAction ["Action 1", {call TAG_fnc_boxAction1}];
```TAG_fnc_boxAction1:```sqf
systemChat format ["Box action one for %1", _this select 0];
Second approach is better if you want to use that action elsewhere, in other actions, functions, etc.
But for small one-time actions you can just inline it all
Up to you again
Does ⬇️ still function in Current Arma?
"password" serverCommand "#restartserver";
Dedicated server only
Unless you mean #restartserver specifically, didn't use it
If I have a script ran server sided, would it function that way?
(I haven't tested it)
serverCommand only works on dedicated server, not player-hosted server
Thanks a lot for a great explanation )
But it works, we actively use it in our servers
Thanks, I was going to make a restart script. My thoughts were having it count up every hour, then when it counts to 12 runs that snippet among other things to restart it.
for a 12 hour restart.
https://community.bistudio.com/wiki/BIS_fnc_wpLand or
_waypoint setWaypointType "SCRIPTED";
_waypoint setWaypointScript "A3\functions_f\waypoints\fn_wpLand.sqf";
Also, you shouldn't delete LOITER waypoint before or after adding MOVE, you can just set MOVE waypoint as current.
// actionsLoad
[hostage_1] spawn GM_fnc_addActionHost;
// addActionHost
params["_hostage"];
_hostage addAction
[
"Follow me",
"[_hostage] spawn MEC_fnc_hostageFollow",
nil,
1.5,
true,
false,
"",
"true",
2.5,
false,
"",
""
];
// hostageFollow
params["_hostage"];
private _hostageGroup = group _hostage;
private _playerGroup = group player;
if(_hostageGroup != _playerGroup) then
{
switch (_hostage) do
{
case hostage_1: { _hostage say3D "HostageReplic_one"};
case hostage_2: { _hostage say3D "HostageReplic_two"};
case hostage_3: { _hostage say3D "HostageReplic_three"};
};
[_hostage] joinSilent player;
} else
{
hint "You already taken a hostage";
};
I missed something ?
You don't need spawn your events (functions) , no needed scheduled event.
So you can just
// Hostage follow me action
..
{
params ["_target", "_caller", "_actionId", "_arguments"];
_target call MEC_fnc_hostageFollow;
}
..
Target is the unit where the current addAction is added.
See
You don't need spawn your events (functions) , no needed scheduled event.
But according to BIKI:
The script, whether it is a file or a code, will run in scheduled environment
I.e. it will be spawned.
Why do I need call in this case ?
You can't since it's impossible.
What is impossible?
And you cannot call your function in spawn?
https://community.bistudio.com/wiki/spawn
It just spawn addAction statement.
Why? What's the difference?
"[_hostage] spawn MEC_fnc_hostageFollow",
_hostage is undefined in your addAction line. It cannot see variables outside.
The variable name there should be _target
in
"[_target] spawn MEC_fnc_hostageFollow",
running a piece of code that only contains spawn in scheduled environment is kinda pointless and can be viewed as a code smell
call should work just as well without creating an extra task/thread/whatever is the proper name of a piece of scheduled code
This.
Thanks 🙏
Pro-tip of the day: FUCKING USE PARAMS FOR THE LOVE OF GOD, there's still too many people using select when it's not needed. https://community.bistudio.com/wiki/params
Code passed to addAction will already be spawned (according to BIKI). No one suggested to add extra spawn. But looks like @stable dune suggested to add call ( #arma3_scripting message ). Why? Does this code make much sense:
[] spawn {
call {
...
};
};
?
I think no.
i believe it was about this part
If so, then I am all for this.
But
[] Spawn {
[_target] spawn function;
};
Make sense?
No, as I wrote. Who suggested this?
I mean,
It can
"_target call MEC_fnc_"
@stable dune your point no need for nested spawns, Schatten's point i don't see where nested spawns were proposed 
Understood, I got it wrong, sorry. I thought you talked about the action script itself, not custom function.
so, abit of an extended question. ive written up some stuff to turn the USS freedom into a flying carrier for sci fi alternative history shenanigans, it works perfectly in singleplayer but on dedicated it doesnt seem to be firing the functions properly,
[] call CBB_fnc_init;``` is inside the initserver.sqf
```sqf
carriervelocity = [0,0,0];
carrierthrust = 0.01;
carrierdrag = 0.995;
carrierRotVelocity = getDir carrier_phys;
carrierRotThrust = 0.05;
carrierBank = 0;
carrierBankSpeed = 0.1;
carrierBankDrag = 0.99;
carrierPitch = 0;
carrierPitchSpeed = 0.1;
carrierPitchDrag = 0.99;
[] call CBB_fnc_carrier_Move; /// initialises the handler
``` is the fn_init.sqf
```sqf
carriermove = addMissionEventHandler ["EachFrame",
{
carrier_phys setPosWorld (carrier_phys modelToWorldWorld carriervelocity);
carrier_phys setdir carrierRotVelocity;
carriervelocity = carriervelocity vectorMultiply carrierdrag;
[carrier_phys, carrierPitch, carrierBank] call BIS_fnc_setPitchBank;
carrierBank = carrierBank * carrierBankDrag;
carrierPitch = carrierPitch * carrierPitchDrag;
is the fn_carrier_move.sqf
the values are adjusted by keybindings setup in the init.sqf for the players to adjust as such.
any idea why it works in singleplayer but not MP?
i can brute force the scripts to run if i execute it globally in the debug console but that leads to unfavourable behaviours such as moving too fast and jittering, presumably from the global execution screwing with it. I have tried various things such as checking the executing machine is the server -sqf if !(isServer) exitwith {}; but to no avail
im assuimg its a locality thing but its the first time ive attempted something of this scope. any help would be appreciated
i even attempted
publicVariableServer "carrierPitch";
in the keybindings to make sure the server is aware of the updated variables, but has no effect leading to the conclusion the issue is how its executed / handled
idk much about moving carriers but your right that you probably must run the code in server (appart from those keybindings) so make sure "EachFrame" is ran in server
make sure clients doesnt run anything
all they run are the keybinds which in turn pokes the server with the new values to then pass into the handle. i might just rip apart the current structure of locality and put it back together again
ok, what about those CBB_ functions, are they defined in server?
class CBB
{
class carrier
{
file = "scripts\functions";
class init {};
class carrier_Move {};
};
};
the functions cfg
well id put some diag_log debugging in the code to make absolutely sure the code is running and variables are defined
Does anyone know how to disable the capacity of supply or ammo boxes?
that would empty it, but to disable it, it's something else
define "disable". Unlimited mags can be taken out? Unlimited mags can be stored by players? Nothing can be stored (storage disabled)?
hi, is it possible to limit what weapons can be loaded onto a helicopters pylons and/or allow none to be carried?
Yes, see the various pylon commands on the wiki
already searched there but it seems like while we are able to getCompatiblePlyongMagazines, we arent able to setCompatiblePylonMagazines
And because if you don't I'll take it personally.
wat
Restricting the pylons depends on the system that's being used to change them.
If they're being changed by someone with direct access to script commands, then they can do whatever they want and you can't stop them.
If it's via a particular mod or scripted customiser system, then how or if the loadout can be restricted depends entirely on which one and how it works.
nvm, i had worries about something that doesnt even need to happen. I forgot that the ace pylon menu can be disabled and isnt needed for rearming pylons... I feared that players could mount weapons I didnt intend for them to have access to and on pylons they shouldnt be able to. But that worry was unfounded. Thanks anyway
Thanks for the suggestion Schatten. I've had some success now using the BIS_fnc_wpLand . Setting the waypoint after adding it did indeed allow the helicopter to land and stay on the ground with the engine running.
I'm gaving an issue creating a smoke module in Multiplayer. The following works in SP only:
_smokeEmitter = "ModuleSmoke_F" createVehicleLocal getPos _thrownSmoke;
After looking closer I see that createVehicleLocal is indeed a local effect. So I changed it to createVehicle which is MP compatible. But it wont create the smoke in MP like that. Here is the full code for reference:
[_projectile] spawn {
params ["_thrownSmoke"];
waitUntil {uiSleep 1; abs speed _thrownSmoke == 0}; //unsure what this does
if !(_thrownSmoke inArea "Smoke_Marker") exitWith {}; //run code below when smoke thrown
_smokeEmitter = "ModuleSmoke_F" createVehicle getPos _thrownSmoke; //creates smoke
_smokeEmitter setVariable ["repeat", 1]; //makes smoke never stop
_smokeEmitter setVariable ["type", "SmokeShellYellow"]; //yellow smoke
};```
modules and emitter only work with the local version fo the command iirc.
Create a function and remoteExec to the necessary clients.
Or try to broadcast values using 3rd param.
I think you are right. I replace smoke emitter with a car and it spawned fine.
I haven't made a function before so that seems overwhelming. But I have used remoteExec. Could I just use that without the function?
This means the 3rd index on the remoteExec command right?
setVariable
Now that I think about it. Since createVehicle wont even work in SP with the smoke module, that means it doesn't really have to do with MP issue right?
IDK my head hurts.
Use my smoke module in modules enhanced
Don't know, I've never worked with this module. I just assumed.
Also if using modules via script, you don't create the module, you call the function that the module points to.
If possible I want to do this without adding mods but I'm glad to have it as a backup.
So this means I need to find the function name, right?
If you are doing particle stuff, skip the module and create your own particles. There is a full wiki page on this.
And yes you have to find the function name and read how it works.
Use the in game function viewer or with ADT
What I have is when a player throws a smoke grenade it turns it into the smoke module. The result and goal is infinite smoke.
Works great in SP but since "ModuleSmoke_F" doesn't work with creatVehicle I now search for a workaround. @kindred zephyr says to create a function. Maybe it's time to learn that. Is it hard to do? Any tutorials out there on it?
There are infinite smoke grenades -- SmokeShellXXX_Infinite, e.g. SmokeShellGreen_Infinite.
Remove general smoke grenade and create the infinte one on its position.
Oh really? Interesting! Are those the class names?
Yes, SmokeShellGreen_Infinite is class name.
I will try this at once!
You can look for other class names for other colors in Config Viewer.
is it possible to have the police lights for the offroad actually lighting up the area instead of basically being blue lights that turn on and off
Hey, guys, i make tank, when i as commander vehicle i chose Manual fire control, to get control of gunner gun/turret, i can`t move gunner turret, only stuff i can do is shoting and swap ammo. Whats the problem? What parameters are responsible for manual fire control?
Do i need use
isManualFire "vehicleName"? And sqf stuff?
Works awesome! TYVM!
can anyone assist me in making a simple tdm 1v1 gamemode for me and my friends to play together. I am new to arma and dont know anything about scripting it. I tried respawn tickets but dont understand how to do it.
you have to turn on the vehicle's lights rather than just the emergency lights. if youre talking about in daytime though, no there is not.
Is there a way to put quotations within the addAction description?
You have to use quote escapes, or use single quotations as your outsides for the string
'He said, "I like big butts!"'
"He said, ""I like big butts!"""
format["He said, %1", str "I like big butts!"];
I chose the second one cause. it was the easiest to edit. Thank you!!
Im trying to get this to activate in init on MP but it only works in SP:
if (hasInterface && !(missionNamespace getVariable ["MissionIntro", false])) then
I thought the hasinterface would do the trick but it appears not
It might had to do with the varible. I tried true and tried false in the initserver and it triggers either way. so I might have an error there
remember that logging I told you about? do you know if MissionIntro is true, false, or nil?
My understanding is that the default is false so originally I have nothing in the initserver.
yes, but are you sure that its not being modified elsewhere, so that at that moment in time, its different
Hmm I'll admit I got overwhelmed with the debugging options. I need to learn those for sure. I'm afraid Id need a hand hold though.
this is supposed to happen on mission start so im pretty sure its not modified anywhere else
its the first line in the init
Replace in your Init.sqf for this
Then check the RPT folder
private _missionIntro = missionNamespace getVariable ["MissionIntro", false];
diag_log format["Frame: %1 - Mission Time: %2 - Multiplayer: %3 - MissionIntro - %4", diag_frameNo, serverTime, isMultiplayer, _missionIntro];
if (hasInterface && !_missionIntro) then {
// something
};
where else are you changing MissionIntro?
It gets turned to true... wow, idk lemme see
its appears no where.
but that would just mean a JIP player would always run the code below. So it shouldnt explain why it isnt run in MP if my logic is correct
if your logic is correct. did you apply the above code and start the mission?
it should appear like this
Im having a brain fart. Lemme plug that in again.
20:52:23 "Frame: 529601 - Mission Time: 0 - MissionIntro - false"
interesting that it doesnt say multiplayer true. Thats different than yours
send me your mission again
0:52:26 [CBA] (xeh) INFO: [530415,9909.58,0] PostInit started. MISSIONINIT: missionName=ORB%20-%20COOP, missionVersion=54, worldName=Cam_Lao_Nam, isMultiplayer=false, isServer=true, isDedicated=false, CBA_isHeadlessClient=false, hasInterface=true, didJIP=false
also, did you start using vscode yet? it has a remote feature where i can hop in and look at stuff while you work on things too. its pretty cool
interesting that it says ismultiplayer=false
Thats my to do tomorrow.
send me your mission again and i'll look through it
and it says false, because you aren't in multiplayer lol how are you previewing it?
joining on dedicated server.
I dont have a test mission for this portion yet. It my huge file. Wait...
are you sending your RPT of your client or server... or the right RPT current file
if im the only player connect to the ded server will it count that as multiplayer false?
rpt is different for both
Dang I did't know. Okay. I gotta go in a couple minutes. I'll pick this back up tomorrow. Thanks for the help. I'll get that vscode working tomorrow.
also, no more "test missions" just send the full package. you probably are testing right, but when you put everything together, you are messing up somewhere
I kinda have to because if I want to test something at the end of the mission after its implemented I was tired of wasting time teleporting through triggers for 5 mins just to get to that one spot.
you'll eventually want to program in skips. if you take a look at the BI missions, you'll notice they have skips to skip past areas for debugging
Are those missions not encrypted? How do you unpack the pbo to look at them? And that sound like an amzing idea.
I restarted ARMA and now its working as intended... Im done lol. Ill look at this tomorrow.
stop using the dedi to test lol. do the host + client way with 2 arma clients 😛
So correct me if im wrong but the problem with that is I can only really trust the client one for true behavior. Sometime I need two clients right? like when I was testing to make sure the 3d position audio was working. Or is the thought process if it works on one client it works on all I guess.
nah you just need the server host, and a client. then view as the client to see if things work
https://medal.tv/games/arma-3/clips/ilMhCvBwYL2oV0zFl/d13374QUttP5?invite=cr-MSxKRE0sMTYwOTQ0NjkzLA
anyone know why this is sped up? Like I could work with it but kinda annoying
Watch why and millions of other Arma 3 videos on Medal, the largest Game Clip Platform.
ogv? Wrong encoding parameters probably
Bitrate something-something, there should be exact settings on the wiki something
Does anybody know what scope of execute this command is as it doesn’t state in the wiki is it Local, Server or Global
https://community.bistudio.com/wiki/enableDynamicSimulationSystem
i think its explained at the bottom of this page: https://community.bistudio.com/wiki/Arma_3:_Dynamic_Simulation
"Effect of the manager - the entity simulation change - is global."
Perfect thanks might be worth updating that wiki page if that’s possible. But I’ll use it like it’s a global effect and just run it on the server. I will also test that theory when I have some time.
yea that page states server is best place to run those commands
"To achieve best results it is suggested to manage dynamic simulation on one place - ideally on server."
Hey guys, does anyone know what is the problem: player can attach to oneself a hostage to lead him along. My idea is to bring a hostage into the building and leave it there ( leave - detach a hostage ). So, to bring a hostage, player should choose one menu item ("Lead"), after that, hostage attach to player, and to leave him somewhere, player need again choose one menu item ( "Stop lead" ). But the problem is when I am in the building and my sight is aim at any parts of building, player doesn't see a menu items, but when my sight is not aim at any parts of building, player see a menu items and can choose something
I will toooo.
I want to make sure I'm understanding this logic correctly. This if statement will only return true if Trigger 1, 2, and either 3 or 4 are activated right? Would it be possible for it to return true if ONLY trigger 1 and 2 are activated?
(triggerActivated Trigger3 || triggerActivated Trigger4)) then{
//stuff
}```
That is 1 & 2 & (3 or 4), so it requires 1 and 2 to be activated, and one of 3 and 4
This isn't special SQF logic, just normal logic :U
when you have ATL position and you need to get objects at sea is this the proper thing to do (turn to ASL)? ```sqf
if(surfaceIsWater _aroundpos) then
{
_aroundpos = atlToAsl _aroundpos;
};
private _wrecks = _aroundpos nearObjects .....
I'm not sure whether nearObjects uses 2d or 3d. Would need to check.
from wiki: "position: Array format PositionAGL, Position2D or Object"
Yeah, it's wrong.
It's 3d and uses ATL not AGL.
So you can skip the first four lines.
_pos nearObjects _radius form is the same. 3d & ATL-based.
Is it possible to put a script on a vehicle to have its turret pointed a certain way like the m2 on a offroad or the main turret of a MNT
MBT*
for what it's worth, if you really needed AGL from ATL, you'd need to do ASLtoAGL ATLtoASL _posATL
odd i just "fixed" my code with that ASL conversion
Busted test case or bug. You'd need to check.
You're checking what, undewater terrain objects?
hmm the wrecks get deleted with my current code, it didnt work before
wrecks on carrier deck
lockCameraTo
theoretically thinking if nearObjects would take AGL would my code then be right?
I don't think there's any useful theory here. It seems to be using different coordinate systems for different object types.
i just wonder if i get AGL right?
I want my players to be able to fire a rocket Launcher 3 times in quick succession. I don't care about them having ammo for it, its not a serious Mission.
I currently have the following event handler:
player addEventHandler ["Fired",{ params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; if (_weapon in ["launch_MRAWS_sand_rail_F", "rhs_weap_maaws"]) then { _shots = _unit getVariable ["rocketsShot", 0]; if (_shots < 2) then { _unit addSecondaryWeaponItem _magazine; _unit setWeaponReloadingTime [ _unit, _muzzle, 0]; _unit setVariable ["rocketsShot", _shots + 1, true]; } else { _unit setVariable ["rocketsShot", 0, true]; _unit setWeaponReloadingTime [ _unit, _muzzle, 1]; }; }; }];
This "works" but the problem is that the launcher is in a reloading state after adding the ammo with addSecondaryWeaponItem, and therefor can't be fired for some seconds.
Using setAmmo with _weapon or _muzzle just does nothing (I assume thats because there is no empty magazine in the launcher after a shot)
for what it's worth, if you really needed AGL from ATL, you'd need to do
ASLtoAGL ATLtoASL _posATL
but just ATLtoASL _posATL should work for stuff that's over water.
great, thanks
Looks like nearObjects uses ATL for flying vehicles and AGL for floating ones.
which I'm pretty sure is a bug.
weird
Isn't that the same as createVehicle?
and why dont we have ATLToAGL or is that not doable?
I doubt it, otherwise we'd be spawning helis underwater in Antistasi :P
ah, I guess FLY overrides anyway
That was reported as being the case in 2017. Perhaps it's changed since then 🤷
would there be a way to start an animation (cutscene) at a specific time (seconds) of it?
Some cutscnes are too long and the "Interesting" part are only some seconds of it
i'll update the page, however, its a local/global combo. every client can have their own manager but it is suggested that you only have it managed in one place. let me know the results of your tests
I've got a helicopter (group behavior set to careless) that likes to avoid my landing zone and try to hunt a tank if he see's it. If I remove the tank from the mission he will land no problem, even if under infantry attack. Is there a way to script him to avoid the armor?
careless should avoid everyone and everything. are you running anything that modifies the behavior/AI mods? when is the group being switched to careless? units themselves in a group can also have different behaviors, check those?
- No
- Editor - doublle click on group
- I didn't know that. There isn't a behavior drop down when I double click on the pilot.
I think I remember a setbehavior command now that use mention it.
- its done via script via
setCombatBehaviourso you won't see it in editor. that's why i asked AI mods
Are AI mods effective at disabling the AI wall hacking me through vegetation? That would be pretty cool.
ai isn't wall hacking through veg. it finds your last seen + last velocity and predicts where you will be behind veg and fires
so if it catches a glipse through a gap, it redoes that calc
check this out @blissful current https://forums.bohemia.net/forums/topic/223493-ai-facts-myths-compilation-list/
Oh clever. It's very effective. If I lowered one of these would it make it less effective?
skill is how they move, flank, outsmart you etc. precision is their ability to hit you
a decent setting for difficult but giving some time to react is 1.0 skill, 0.3 precision
the greater the group count, the more stupid the AI get so keep that in mind.
the inverse is true as well
as in the more ai with a group. or the more groups on the terrain?
more groups on the map, the unit count doesn't matter as much. its the group count that makes a big difference
which is why if you have a bunch of civilian units all in their own groups, performance can take a hit. instead for ambient things, you use agents which are AI that lack a lot of the AI features and aren't in the group system. (you can't use waypoints with them for instance, you have to use setDestination)
Is there a ball park figure on when you would notice such an increase/decrease? I probably have 15 groups.
I definitely noticed now AI impacts performance. I have an area that runs around 54fps. I have like 200 dynamic simulated objects in the area. If I delete all of them I get no improvement on fps. But if I delete the 10 groups in the area I get 10 fps more.
Anyway to lower audible fire and visible fire when using suppressors ? If so please help. Thanks
through mods and configs
Is it complicated ?
Are there any mods that assist with this or is it something I would need to do?
you need to do it
head over to #arma3_config
Ok thanks man
life_actions pushback (player addAction["Push","player action [""getOut"", vehicle player];","",999,false,false,"",'(vehicle player isKindOf "helicopter" && (assignedVehicleRole player) select 0 in ["driver","Turret"] && locked vehicle player isEqualTo 0)']);
Can I add other code to this code?
life_actions pushBack (player addAction["In Drive", "player moveInDriver _x; closeDialog ;"];
How to use SQF syntax highlighting in Discord
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
Add what into where
life_actions pushBack (player addAction["In Drive", "player moveInDriver _x; closeDialog ;"]; this
life_actions pushback (player addAction["Push","player action [""getOut"", vehicle player];","",999,false,false,"",'(vehicle player isKindOf "helicopter" && (assignedVehicleRole player) select 0 in ["driver","Turret"] && locked vehicle player isEqualTo 0)']);
I want to adapt the upper one according to the lower one and add it
Let me rephrase my question. What is your goal
I want to turn driving into code player moveInDriver
And what is your problem you got
I am adding this code but it is not working, I cannot interact, can you help me edit it?
life_actions pushBack (player addAction["In Drive", "player moveInDriver _x; closeDialog ;"];
It still is taking quite a big effort to understand what you want to tell
I guess state your current code that doesn't work and error you got makes it easier to understand
life_actions pushBack (player addAction["In Drive", "player moveInDriver _x; closeDialog ;"]; I can't run this code
- Missing bracket
) - Missing
closeDialogargument _xis not defined there
Is there any chance you can help me with proper code?
life_actions pushBack (player addAction["In Drive", {player moveInDriver whateverYourVehicle; closeDialog 0;}]);```
The option came, but it comes not only when looking at the vehicle, but also all the time, and when I say in drive next to the vehicle, it does not get in.
Because... I guess, the script doesn't know what is the vehicle you want to use?
Trying to find a correction to this script. Meant to create a timer for 15 seconds and then the option vanishes.
player addaction [
"Server Information and Discord",
{
0 spawn MRTM_fnc_MRTM_welcome;
},
[nil, 1, true, true, "", "true", 5]; sleep 15;
player removeAction actId;
nil,
1.5,
false,
];
;cannot be used to interrupt a script within a script,mismatch
Where can I write the tools?
...Write what?
Vehicles
How could this be writting?
If you mean how do you change the vehicle to use, whateverYourVehicle is the variable used there
Depends on your goal and intention I guess
just need the message to fade away after 15 seconds
What message
We have something similar to that line of code. The player on death can scroll the wheel button and at the top left hand corner the menu for "Server Infor and discord" pops up and will only be avlb for 15 seconds
something like this...
switch (side group player) do
{
case west: { // WEST SIDE CODE
actId = player addAction ["Teleport to Nato Base",
{
params ["_target", "_caller", "_actionId", "_arguments"];
if !((incapacitatedState b_tele)== "UNCONSCIOUS") then {
_caller setPosASL (getPosASL b_tele);
};
}, nil, 1, true, true, "", "true", 5]; sleep 15;
player removeAction actId;
Do you mean you just want to use removeAction?
we have that due to players during sessions accidently opening this menu every time they use space bar to set down a turret or something.
Yes we want the menu to be removed after 15 seconds
Does this work?
life_actions pushBack (player addAction["In Drive", {player moveInDriver ["C_Kart_01_Blu_F","C_Kart_01_Red_F","C_Kart_01_Fuel_F","C_Kart_01_Vrana_F","C_Offroad_02_unarmed_F","B_T_LSV_01_armed_F","B_T_LSV_01_unarmed_F","O_T_LSV_02_armed_F","O_T_LSV_02_unarmed_F","B_T_UAV_03_F","C_Plane_Civil_01_F","O_T_UAV_04_CAS_F","B_T_VTOL_01_armed_F","B_T_VTOL_01_infantry_F","C_Van_02_vehicle_F","C_Van_02_transport_F","C_Tractor_01_F","C_Offroad_01_comms_F","C_Offroad_01_covered_f","O_LSV_02_unarmed_F","B_GEN_Van_02_transport_F","O_T_VTOL_02_infantry_F","I_C_Boat_Transport_02_F","C_Scoooter_Transport_01_F","B_Heli_Transport_03_unarmed_F","O_Heli_Transport_04_F"]); closeDialog 0;}]);
No
private _action = player addaction [
"Server Information and Discord",
{
0 spawn MRTM_fnc_MRTM_welcome;
},
nil,
1.5,
false
];
sleep 15;
player removeAction _action;```
player addaction [
"Server Information and Discord",
{
0 spawn MRTM_fnc_MRTM_welcome;
},
nil,
1.5,
false,
nil, 1, true, true, "", "true", 5]; sleep 15;
player removeAction actId;
];
@warm hedge
I said no
Hey guys, just wondering how do I initialise a disableAI script for ALL units within a mission?
I wish to apply disableAI "SUPPRESSION";
but currently only figured out how to apply it to individual groups, is there anyway to apply this globally to every single unit within the mission?
{_x disableAI "SUPPRESSION"} forEach allUnits;```
So how can we do it? can you help me?
No idea what your idea is, so right now, no
I have no reliable crystal ball to see through your mind
I want you to be able to ride the vehicles I mentioned there when I say in drive.
If this is unclear just say so
thank you so much for this, and I can apply it under Attributes->General->Init right?
not
Or anywhere else, yes
I see thanks! where do people usually put there scripts in?
whateverYourVehicle in this code represents which vehicle to be used @dim kelp
Somewhere. I can't say. Because a script can work anywhere if it is coded properly
As for me, Where would I put the line of code to cause the menu to sleep? This Is the last thing I do and Arma3 can suck It. Im going to bed.
What do you mean cause the menu to sleep?
thanks, appreciate this!
life_actions pushBack (player addAction["In Drive", {player moveInDriver life_vInact_curTarget; closeDialog 0;}]); Does this work?
Maybe
I was able to get it to work but every opportunity comes up just when I look at the vehicle, how can I get it working?
"help, i've added an action to be displayed when i look at the vehicle and now it gets displayed when i look at the vehicle" 
I want to add this to altislife can you help me?
in which situations local player may return false?
On a dedicated server, where player is objNull.
Or in the main menu with -world=empty
Commie give urself a picture.
That would mean I'd have to register.
agree but here is something new: when a player goes back into the lobby (on dedi) and rejoins the owner of his player is the server
and local playeris false
If you can see pictures you need to switch to compact mode.
I hope that changes as soon as you rejoin the mission.
But rejoining the mission will force a locality change no?
Also I'm pretty sure that player IS objNull in that scenario.
i think the state is during the briefing screen
Is it only set there?
and no player is the same unit you had before
So there you go. You have your scenario.
now tell me how to do some fancy publicVariableClient stuff when i am unable to get the clientID with owner serverside
is there something other than player which is ALWAYS local to the client?
Send it together with the object to the server and do publicVariableClient from there.
thats what i am currently doing
Or use the local eventhandler?
but in the scenario is described it fails
So wait. the object is local to the server , but the server is not the owner?
server is the owner
So where is the problem?
i thought that the client is always the owner of its player object (when its not objNull)
Apparently not.
Hey guys, I'm hoping to initialise some disableAI commands via a "behaviour.sqf" script, hoping to disable cover, suppression and fleeing for some units.
I'm able to call up the "behaviour.sqf" script in the unit Init box, however it's giving me this error regarding my script" "Error Undefined Variable in expression"
I'm wondering how should I initialise the following parameters via SQF scripts?
this disableAI "COVER";
this disableAI "SUPPRESSION";
this allowFleeing 0;
I'm really new in scripting so would appreciate any guidance on this!
i wonder if that is on purpose
Can you show us the current sqf file?
you can't just keep it simple and wait until the client is the owner?
Probably not.
this is not a valid variable within an SQF file. It is only available for some context
Yeah I was going to explain it once I’ve got that
Yeah haha, this is actually what I wrote within the SQF 😁
this disableAI "COVER";
this disableAI "SUPPRESSION";
this allowFleeing 0;
What should be the SQF equivalent of these parameters, that's applying to the whole group?
I don't get where the issue is.
{ ... } forEach (units (group _this));
I would recommend to read this: https://community.bistudio.com/wiki/Arma_3:_Writing_a_Function
thank you this is exactly what I'm looking for, will have a read through this!
_marker = createMarkerLocal ["DeploymentPosition", _pos, 1, player];
_marker setMarkerTypeLocal "b_installation";
_marker setMarkerText "Allied Installation";
this results in a translucent marker, does anyone knows why?
The marker was created in another channel.
If the player object is local to the server and you send the object already to the server first, then you can do from there whatever you want
setMarkerText <--- seems to be missing "local"
Important note for multiplayer mission.
the wiki says that in order to reduce network load, one can perform only the last operation and the entire marker state will be propagated
Multiplayer optimisation: Global marker commands always broadcast the entire marker state over the network. As such, the number of network messages exchanged when creating or editing a marker can be reduced by performing all but the last operation using local marker commands, then using a global marker command for the last change (and subsequent global broadcast of all changes applied to the marker).
I've tried to make every operation global too and it didn't work, seems to be the channel indeed
oh ok so its a optimization
Since I'm playing in singleplayer, I can't change channels, right?
Don't remember. But you passed the channel to createMarkerLocal.
Even in SP, they have channels that the marker belongs to
removing the last two arguments from createMarkerLocal fixed it, but I assume the marker now is visible to everyone and not only it's own side
If I were in MP and used the '.' to change channels to side, would the marker be fully opaque?
I think so. Then use the right channel.
Yes.
Ah, ok. Thanks
Fake debug console :^)
quick n easy way to figure out if a mission has proper started?
(after or during postinit)
missionStart sounds like a solution but according to the https://community.bistudio.com/wiki/missionStart, it might be available during preinit, which is something I don't want. It needs to be something unavailable during preinit but available in postinit
did KK reveal if this changes during mission?
looks like it doesnt (as he is ingame)
I never had issues with player not being local during a mission, You are probably overthinking something
If the player wouldn't be local it would be a PITA to control him.
You probably couldn't
how can i get the id of a client on the dedicated server if the player of that client is local to the server?
and just wait is not an option - createVehicleLocal may be but it seems dirty
It certanly doesn't make much sense for a player to be remote
Could get it on connect, with the connected eh
getClientStateNumber
getClientStateNumber >= 10 on server
then broadcast a flag to clients
Use a local eventhandler on the dedicated server.
@sullen marsh but i would lose it if he goes back to the lobby
And setvariable public
But wth are you trying to do?
basically i just want to transmit some stuff to the client on mission start
To all or to one?
one-by-one
And what exactly?
or "not to JIPs"
Can't you use didJIP
if (didJip) exitWith {}
no i just stated this to throw publicVariable out of your mind
I don't see why you need the client to know it's own id if you're just transfering stuff from the server to the client
^
no i need the server to know the client id
owner _unit
thats why i send the player with publicVariableServer to the server and then i do _clientID = owner _recievedPlayer;
@meager granite allow me to DM you about a predicament sometime
My understanding of triggers in the editor was tested and broken last night. One thing that might help me is to know where that code in the on activation field is ran? Like, is it the same as placing it in initPlayerLocal or maybe its more like init. Just where is this code?
Here is my now current level of understanding regarding in editor triggers, please let me know if any of these statements are incomplete or flat-out false:
-
(Server Only unchecked) Trigger activation is global. The code in the On Activation field is ran on every client. This means that even if something that is normally local effect like side chat is ran, it will still go to every client. Additionally, every client is updated that the trigger state was activated.
-
(Server Only checked) Trigger activation is not global. Whatever code is ran happens only on the server unless there was something to send it to the clients like
remoteExec. However, the clients don't receive ANY info that the trigger was EVER fired. This means that if you have a trigger in this style and try to useif triggerActivatedininitPlayerlocalthe if statement will never fire because the server didn't broadcast its activation state, just potentially the activation code. -
JIP players bring
every triggertheir local copy of the trigger back to their inactivated state. This means if a player enters a trigger zone with a hint it will fire like normal and never again (repeatable unchecked). Unless a player JIP. In that case the trigger can fire again if the conditions are met.
but when the client rejoins from the lobby the owner is 2 (which is the server)
i hope you got it now
Yeah I get it
Do you have AI enabled?
Have you tried waiting a few seconds
To make sure the server isn't in the process of transferring locality back to the player
i tried waitUntil {!isNull player && local player} on the client. looks like this s never true
that can't be
It just doesn't make sense for the player object to not be local to the player
Do you have AI enabled in your mission?
no AI disabled
Is there a way how to set a vehicle to play a specific animation, e.g. heli rotor rotating with disabled simulation? And where would I find the anim name? Thanks
When placed in the Editor, a separate copy of the trigger exists on every machine. The condition is checked locally on every machine, and the activation code is run on every machine where the condition is satisfied. Which machines the trigger activates on depends on which machines satisfy the condition; a any BLUFOR in this area will be satisfied on every machine at the same time because that's globally detectable, while player in thisList will only activate on machines where their player is in the trigger area, because player is machine-specific.
When Server Only is checked, the trigger only exists on the server.
The trigger is "reset" when a player joins because their local copy of the trigger is newly-created according to its Editor attributes.
The player has to be local.
is private necessary for initializing private variables or just starting with an underscore will do? Just got confused on it
Underscore indicates a local scope variable. A private variable is an even more restricted type of local scope variable.
Technically, private is not always necessary to make a private variable, because params also does it
Check what getPlayerUID returns on the player object when it's saying it's not local
(and in 2.18 we'll have privateAll)
If it returns the correct UID that's fucked
sorry, but I just got even more confused; is
_myVariable = 5;
the same as
private _myVariable = 5;
``` or is the underscore just a convention? Does the former declares a global variable, or does the former declares a **local** variable with the latter declaring a **private** variable?
you should be able to reproduce it if you put
hint "TEST";```
in your init.sqf
^
You got it the second time. The underscore isn't just a convention.
my_var_name = 1; // global scope variable
_my_localvar_name = 2; // local scope variable
private _my_privatevar_name = 3; // private local scope variable (global variables can't be private)```
@sullen marsh execute it on client or server?
client when it's saying player isn't local
Have got some weird fuckiness happening and I suspect it could be playSound3D recycling IDs when local
In object's init, I have:
if !(isNil "zp_opflow_radioEH") exitWith {};
this addEventHandler ["HitPart",{["zp_opflow_radioHit",[]] call
CBA_fnc_globalEvent;}];
zp_opflow_radioEH = [{_this#0 params ["_obj1"]; zp_opflow_radioSound = playSound3D [getMissionPath "sfx\carmen.ogg", _obj1, true, getPosASL _obj1, 0.5, 1, 0, 0, true];}, 270, [this]] call CBA_fnc_addPerFrameHandler;```
in `initPlayerLocal.sqf`, I have:
```sqf
["zp_opflow_radioHit", {
stopSound zp_opflow_radioSound;
[zp_opflow_radioEH] call CBA_fnc_removePerFrameHandler;
//systemChat "hit";
}] call CBA_fnc_addEventHandler;```
Works fine in SP, doesn't work in Dedi, cannot figure out why for the life of me
ok
stopStound is a command despite what the discord syntax highlighter says (https://community.bistudio.com/wiki/stopSound)
...nvm... works fine now??????
so confused
i had it being inconsistent in SP too before but never really figured out why
Are you saying that owner returns 2 on server even though client already has their unit local to them?
Also there is clientOwner command coming that returns own owner id on clients
what i do is: connect -> lobby -> briefing -> lobby -> briefing (here player is not local anymore)
what's best way to detect if player respawned by clicking the respawn button?
Briefing? Are you restarting the mission?
Did you mean in-game?
Anyway its normal for player not being local after you join, server creates unit for client the first time, then waits till client loads (downloads mission, clicks through error messages) and then transfers locality to them
Player unit might even be isPlayer => true and return uid while still being owned by the server
@sullen marsh getPlayerUID player is always the correct value
lol that's retarded
At least it lets you do a workaround
Get the ownerid when they connect and store it somewhere
connect -> lobby -> briefing (player IS local) -> lobby -> briefing (here player is not local anymore)
Probably onButtonClick 🙂
So you mean that game isn't started at all and still in briefing stage?
You simply back out from briefing and join again?
i think something like _receivedPlayer setVariable ["clientID", owner _receivedPlayer, true] at the first briefing
gui hax only way?
"i" before "e" except after "c"
@meager granite there is no difference if i start playing or not before gettin back to the lobby
Then I still don't get what's your issue
Player unit is created by the server when client starts playing and owned by the server for some time before transferring locality to the client
ok then some time has passed and i is local to client now
then the client goes to the lobby
and the unit gets transferred to the server again
then the client joins again
and the unit will never be transferred again
Did you say you had AI disabled?
yes
you broke it.
Then you would spawn as different unit
I've got a high level question.
I've got an important script running throughout a mission. A complex one. I thought I tested it thoroughly enough, since it was working in these cases:
- SP - Works fine ✅
- Local MP - Works fine✅
- Dedicated with 1 player - Works fine✅
- Dedicated with 3 players(!) - Works fine✅
- Dedicated with 8 players - Everything broke ❌
Worst thing is the last scenario happened during our scheduled op.. I had to shamefully tell all the players that the op is not gonna happen today, which sucked.
So my question is.. how do I even approach debugging this? How can I reproduce a bug that only happens when 5+ people have joined the server? Do I just casually ask 8 people to join and hang around for a few hours? Are there any best practices for such a situation?
This sounds like something (scheduled script probably) being multiplied by the number of players. I'd look for remoteExecs and "forEach allPlayers" type stuff, as well as while loops with no sleep to keep their pace controlled.
does it even matter if its the same unit or not?
As stated above this sounds like a scaled locality issue. Being very careful with your locality and following best practices should help prevent these issues from occuring. Ensuring you are understanding what context each function is called in be that local, global, server etc it's the hardest part to get right unfortunately, experience is king
Units are different, you get second player unit with same vehicle var name you set in editor
^
It was my suspicion at first and to try to remedy that I moved initialization of my script to initServer. Does it not guarantee that the code won't be executed on the clients?
I do have a few while -> sleep loops in the script
ok i could be that its a different unit but that doesn't solve the problem
Do you store player unit on server somehow to do that owner check later?
The main script yes, but if that then remoteExecs stuff or whatever then whatever was remoteExec'd will run on other machines
It's hard to pin down an exact cause without seeing the code, there are a lot of different ways to cause complete failures in SQF
nope i send it with publicVariableServer every single time
After player is local to client?
Yeah I get it, though I don't think I should be posting the whole code here, it's like 200+ lines so I think that would be asking for too much 😄
I did inspect the code and I don't have a single remoteexec here. The only commands that actually affect the game world are
setVehicleAmmoDef doSuppressiveFire doArtilleryFire currentCommand
I do have one place where I execute spawn inside of a while loop that runs every few seconds. Could that be dangerous?
Depends on exactly how it's structured
You can use Pastebin to post large bits of code
Keep in mind it's possible that it's something other than this main script
after player is not null
That's the issue then, client might already know of their player unit but it still will be owned by the server
but locality never changes back
How do you check it?
Here it is, I've added some comments to hopefully make it easier to understand https://pastebin.com/6qpfMejN
Pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
fn_suppressionLoopForGroupManual is the method that is supposed to loop indefinitely, but stops doing it after ~5th player joins
waitUntil {local player}
I am trying to detect if a trigger has been activated. It works fine in the editor trigger field but then I had the bright idea since I have a lot of these that it would be nice to have them all in one place to look at.
So I placed the code in initPlayerLocal and now it doesn't work. I assume this is because that SQF is ran at mission start so how could the trigger possibly have been activated yet. (I assumed that stuff in that SQF is constantly being evaluated, which seems not to be the case)
So is there a place I can put all these so I can see them at a glance instead of hunting for the trigger in the editor that contains the specific one I'm looking for in the moment?
if (triggerActivated TestTrigger) then {
NPC sideChat "Blah, blah, blah.";
};
Do you control your unit on second join fine?
If you do then it should be local to you
Pretty sure you have some problem in the sqf that gets you wrong results
pretty sure thats not the case :)
The only 2 places in the game that automatically continually evaluate code are the debug console watch fields, and trigger condition fields. If you want anything else of that sort, you need to make your own while loop, waitUntil, or eachFrame event handler.
This shows how the functions are defined, but it doesn't show where the main function is actually started
did someone test it?
I often hear about performance concerns with these. How do you know when youve made performance worse. Its something like after x about of loops or is it more complicated than that?
You'll know you've made something bad for performance if things start to slow down or stutter
So you need to just look at your fps and see if that drops?
Generally, more commands = slower, commands that affect many objects are slower, commands that search wide areas are slower. There is a code performance analyser function, as well as a button for it in the debug console
That can be part of it. If your code is doing a lot of stuff to the world, moving/creating objects, sending messages etc then that can affect frame rate. Per-frame unscheduled code can also do it, as the game will wait for it. But scheduled code isn't directly tied to frame rate. If you bung up the scheduler with slow/excessive code, then all scheduled code will slow down, but the main simulation won't.
It's started in initServer
call fn_suppressionMain;
call fn_startBigArty;
Make a simple repro mission
The performance concerns about this stuff are mostly if you let it go uncontrolled. A while loop will try to repeat as fast as it possibly can, including multiple times in the same frame, so if you don't rate limit it by including a sleep, it's easy for it to get out of control, particularly if there's no exit condition.
The trigger is "reset" when a player joins because their local copy of the trigger is newly-created according to its Editor attributes. So just the JIP has a copy for this "reset" trigger. Or does now EVERY client have a copy of it.
I had a look and I don't see anything obvious. I'll look again later when I'm not on my phone unless someone helps you first
I believe it's just for the JIP client. But of course, if the trigger does stuff with global effects on activation, then those will be broadcast even if only one copy of the trigger activates.
workin on it
Copy that. My concern is that I have whole bunch of triggers and I'm afraid if a JIP comes then ALL these triggers are gonna start popping off and cause weird behavior. So far it seems that only ones that do this are the condition: BLUFOR/ANYPLAYER Present ones. I can fix this by turning them to Server Only and remoteExec the code. For some reason this wont reset that trigger when a player JIP. Once it's activated it wont ever be again.
For some reason
I mean, we've just been over why :U
Well you said a JIP player will receive a reset trigger on their client. By that logic then even with Server Only checked they still get that trigger reset and thus be able to activate it, right?
The trigger exists separately on every machine. On JIP machines, their local trigger has only just been created as new when they joined, so it can activate if the conditions are then satisfied.
When the trigger is set to Server Only, that changes - the trigger only exists on the server, not on any other machine.
When the trigger is set to Server Only, that changes - the trigger only exists on the server, not on any other machine. If it's only on the server then how come I can walk into it with BLURFOR Present and activate it?
Using a dedicated Server that is.
I get that the player is the Server in local host.
Well, because you're a BLUFOR unit and you're in the trigger area. That's all it's checking for - a BLUFOR unit that is in the trigger area. The server knows about you, you are a globally-existing entity.
Ah OK duh.
The player unit is local to its player's machine, but that's about who has authority. Other machines still know about that player's unit - they have to, in order to render it and interact with it.
Okay so circling back. A JIP player enters the area of the BLUFOR Server Only trigger. You're saying this wont activate because its on the server only, right? But at the same time other players before the JIP were able to activate it. This is where I'm not understanding. This is conflicting info.
I'm saying it won't activate again if it was a non-repeatable trigger
The server's copy has already been activated, and the JIP player doesn't create their own new non-activated copy to then activate
JIP player doesn't create their own new non-activated copy to then activate But this *will * happen if Server Only is *unchecked * right?
Yes, that's what's causing the "reset" behaviour you encountered - a JIP machine is arriving with their fresh trigger and that's then activating
You're not addressing player by vehicle var name, are you?
no i use player
Okay sorry I'm not quite getting it. This will help me. Are these 3 statements true?
-
A player enters the area of a
Server Onlytrigger. The trigger exists only on the server. But because the players are global entities it fires. -
A JIP player arrives and enters the area of a
Server Onlytrigger.JIP player doesn't create their own new non-activated copy to then activate.So this trigger will never fire again. -
A JIP player arrives and enters the area of a
Unchecked - Server Onlytrigger. It fires because he brought his own non-activated copy.
You broke your game. Ask for a refund or get a new one.
under what parameters is this trigger running? what are the other settings you use? cause if it is server only, and you use player in your activation condition, player is undefined on the dedicated server. but if you use any player in the drop downs and this in the activation condition, then it would fire once on that server, period.
netId player should change if its not the same unit?
My brain hurts.
yes
Can you see how examples above 2 and 3 are contradictory? Or is it just me?
Why does a JIP player not bring copies of a server only trigger. But he does non server only triggers. I guess that's what it boils down to.
Because when a trigger is Server Only, it literally only exists on the server
No other machine has a copy of a Server Only trigger, JIP or otherwise
And it's not reset when the JIP arrives. But a JIP will reset the non-server only ones because his mission.sqm(?) has them I guess.
I think I'm finally getting it. A JIP player can't bring a Server Only copy into the game because he is a client and not the server. He doesn't have access to them. But the server can update his client to let it know if it was fired already.
Regarding 2, if you mean the trigger is already activated by another player, yeah it won't fire again
And if that's what you mean, 3 is true too. The JIP player will create a new trigger for himself which gets checked on his machine and will fire when its condition is met
ok netId changes
Can you use the hide module to hide other modules? Since I think delete vehicle wont work for modules.
modules don't work like that unless specifically written for it. think of a module as a user interface to run a script in the background
that background script might have some early exits, like detecting if the module is destroyed, some run forever, etc
Can they disabled or removed through a trigger perhaps? In SOGPF there is a module that plays ambiet village noise. I want to diable it when blufor is detected for immersion.
you'd have to check to see how the module function is written
I found isDisposable = 1. That kinda sounds like it maybe could be turned off.
It plays ambient village noise. I want to disable it when BLUFOR is detected for immersion.
means that it is a once and done kinda deal. if its 0, then you can turn it on and off with a trigger (also needs isTriggerActivated = 1)
any one know how to do planes in the IFA3 AIO mod
what do you mean do planes
like retexture them and put in the editor
2 methods:
via script: setObjectTexture or setObjectTextureGlobal with your custom texture - used in missions - post editor
via mod: changing the class's hiddenTextures[] with your custom texture - used for universal use and in editor
i did the hiddenTexture one but it doesn't show up
Dang so close! It does have isTriggerActivated = 1.
in Eden editior
which means it can be started by a trigger, but will never be able to be turned off due to disposable being false
unless, they have some early exits you can exploit in the code
post your question and your config in #arma3_config
would someone add to this script so it gives a random facewear and backpack? and if posible random things in the back
Facewear is CfgGlasses. Backpack is CfgVehicles
the problem is that im so dumm, i really don't know how to script. it dosn't seem to work everytime i try
hes telling you what to change
on the _allFacewear line, go passed configClasses where it says (configFile >> "CfgWeapons") and change that to (configFile >> "CfgGlasses")
ohhh i will try
that should fix the facewear issue (but you still need to select one of them and apply it)
i tried adding it but it still dosn't work
Debug it.
do you want us to write it for you? or do you want to learn it. either is fine.
There is no addGlasse command.
could you try do write it? couse i don't get the problem in the code
i tried that too but didn't work
Sure, there is NO such command.
But there is such: https://community.bistudio.com/wiki/addGoggles
ohh, now i just remove the goggles but don't add any new goggles
Very unlikely -- there is no removeGlasses command.
Thank you. I did not see you provided a solution.
is think i found the issue
Tell us.
Sure
if (local _x) then {
_x setGroupOwner (owner (allCurators select (count allCurators - 1)));
};
} count allGroups;```
this is running serverside
The fuck is that
haha
👊
in fact i set the group owner of the group to 2 which prevents the unit from being transfered to the client
You should add a false at the end of all your count loops
If BI decides that setGroupOwner returns a value your loop might crash
whitch makes it slower then foreEach 😉
no
nil is faster
i throw this stuff away cause it breaks JIP and costs me almost 7 hours of troubleshooting
"move" AI to zeus players to reduce serverside calculations
As an engineer I apply the 10% rule to this and claim it's the same
what are you actually trying to do
https://community.bistudio.com/wiki/actionNow skips the animation for takeWeapon
addweaponitem spawns the magazine so it doesn't get 'taken' from anywhere
and you can specify muzzlename to load ugl
If magazines already exist in inventory when the weapon is added it will automatically load them
requires 2.18 tho
yeah if you dont want to touch inventory at all you'll probably have to use takeweapon, really the only thing you'd have to do though is:
- Add the weapon
- check what magazine etc gets autoloaded by engine
- delete said magazine and readd it to inventory
- add the magazine it was meant to have via addweaponitem etc
now the problem with 3 is yeah it might not end up in the right spot but usually arma goes uniform->vest->backpack in terms of priority, and addmagazine commands etc use that same priority
I get more loops with
{false} count allVariables missionNamespace
than with
{} forEach allVariables missionNamespace
I consider using count instead of foreaching a crime against everything holy.
They forced me the use count D:
@fallen locust how you prove that you didnt add/remove variables from missionNamespace to manipulate the results :P
by doing the test yourself? 😃
does anyone know why I sometimes get automatically respawned without being able to select respawn position?
We have any scripts that can remove vehicle hubs? The Information In the top left and right hand corner?
Server side yes?
no local
I am trying to find a script that will force It In the server.
Those two options removed. We removed weapon Info on foot but cannot remove vech Info.
Hello everyone, I want to create a mission with dialogs, I use the voices from 11labs. There is one nuance, I create dialog through CfgSentences using ConversationsAtBase but CfgSentences does not see ConversationsAtBase. The truth is that I use ORBAT Group in description.ext together with CfgSentences.
I don't know programming and how to use scripts, I do everything by samples from the internet.
Naturally, run via:
this = [] execVM “talk1.sqf”;
anyone knows why i get auto respawn sometimes? cant pick the respawn position then
depends on the mission, but I assume you mean in the same mission. Perhaps you are pressing space
Enabled autorespawn?
i doubt it works like half the time like supposed to
I had inconsistent results if enabled in the SQM via the editor and then adding the scripting parameter in init in the pass, maybe such is the case?
if you mean the multiplayer settings in editor I have those disabled
perhaps a mod then
just tried disabling them all , no luck
maybe its lag causing it, in light map respawn works but when there's heavy laggy map this problem comes up
yep it was the lag and I have a repro
why do some people do double underscores on private vars? like __foo? it serves no practical purpose, right?
The wiki says BIS_fnc_halo results in incorrect behaviour in ARMA 3 (indeed, it does) and should not be used, but I don't know any alternatives, https://community.bistudio.com/wiki/BIS_fnc_halo
You can just set the height of the unit high in the air. Are you trying to make their parachute open automatically as well?
preferably yes, but won't setting the height high in the air make the unit just fall if it doesn't have a parachute backpack, unline in the function above?
the fact of the matter in SQF is the less code syntax you write the better, because literally everything is a command
This wiki here might be useful for you, the code in the question looks like it might be a good option (it creates the parachute vehicle and puts the player in it)
thank you, worked perfectly
@candid sun in sqf locals no idea, but i do it in global variables in sqf
cause in C++ it often signifies that its some sort of very private, interal, do not touch thing
so like namespaces or classes that are not to be used outside of the internal system
Trying to get the vector from one object to another and im not sure how to go about it, any suggestions?
I had tried to use weaponDirection since its a turret im trying to get vectors for ultimatly, but It seems to only return a dir value and not values for vectorUp aswell
That uses vector's doesnt it? is there something similar that just uses the objects?
Don't know. Find in group of related commands.
guys, I'm confused: is this "missionNamespace" argument from the caller of the remoteExec or is it from the target (server)? Does it makes a difference in this context (is missionNamespace the same in the server and the client)? Is there a better way to set a variable in the server only? I've found BIS_fnc_setServerVariable, but I'm not sure this is what I want because it has it's get counterpart; Is every server variable retrievable from clients with BIS_fnc_getServerVariable, regardless of how it was defined as long as it is global?
[missionNamespace, "varname", "varvalue"] remoteExecCall ["setVariable", 2];
inb4 missionNamespace setVariable ["varname", "varvalue", 2];
^
That's so much simpler, thank you, missed it in the wiki
to answer the rest, mission and object namespaces are local to each pc, what you do with the example artemoz gave is broadcast it as you set it so its synced to the target machine. Each machine has each space of its own except for server namespace, which is only available on host or server machine. The rest each hold a local copy of the space in their own locality allowing to have async variables that can be used for a multitude of stuff, or be synced to a specific machine as artemoz did (or also be globally synced,etc).
yup, just corrected it
got it, thanks, what about the remoteExec params: are they local to the target or local from the source? For example: in the statement [missionNamespace] remoteExec [...], is the missionNamespace variable from the scope of the caller or of the target?
does using {} in between the missionNamespace of this example change it's behavior?
another question: does calling predefined functions from the remoteExec instead of writing the code in it saves bandwith and server performance?
they are local to the execution point, whatever parameters you send as variables are taken from wherever its executed
what about the remoteExec params: are they local to the target or local from the source?
They are local to the the source.
does using {} in between the missionNamespace of this example change it's behavior?
Yes. You can write:
[["varname", "varvalue"], { missionNamespace setVariable _this; }] remoteExec ["call", 2];
another question: does calling predefined functions from the remoteExec instead of writing the code in it saves bandwith and server performance?
Yes.
^ not only yes to the last one, but its also prefered, since each function is local to each machine its also faster to execute besides saving performance and bandwidth
this is probably a dumb question, but most variables used are references instead of actual variable values, right? So in the case of remoteExec, passing a variable that only exists in the server will not pass it as a reference, but as a value, right?
yes, what ever parameter you remote execute its interpreted as a non referenced value that has to be picked up by using _this, params or fetching each param individually. This is also true in any function itself, parameters passed into them become non referenced values until properly fetch.
got it, thanks guys
Hey can someone help me out? I’m making a custom mission for a group of friends and in that mission I want to add custom voice lines I made along with some friends of mine. I’m not super familiar with Arma 3 scripts and such but is it possible to add audio to Intel items, have NPCs talk with certain triggers and such, and have audio play with certain actions/places the player does or goes to? I want this mission to feel like a proper mission. I have audio lines for NPCs in it and everything, I just wanna know if there’s a way to put it into the mission itself
If this is a problem for a different channel let me know
wait, you can have a global var __foo?
There are a
Still need help with this?
I want to have my mission end with this code when all players are dead. What are some good ideas? I was thinking using a trigger condition to check the alive status of players then executing the code when it is met.
["end1", false, true, true, true] remoteExecCall ["VN_fnc_endMission"] //shows mission failed screen
Im trying to avoid this screen which wont let you spawn if there aren't any players left.
Or maybe there is a way to disable this screen entirley if no other units are alive.
use the ticket system. i'm assuming you want them per side? then do a check when the tickets are 0 && all players are dead
// description.ext
respawnTemplates[] = {"RespawnTickets", "MenuPosition"};
// Adding tickets at start of scenario - to blufor
[west, 5] call BIS_fnc_respawnTickets;
// End condition - for blufor
[west] call BIS_fnc_respawnTickets <= 0 && { (units west select {isPlayer _x}) findIf {alive _x} == -1 };
This is PVE so there isn't another side. If I'm understanding what you have here, after 5 tickets there are no more respawns?
yes, 5 tickets for all of blufor. you can also assign them per group and per unit, etc
would 0 be infinite tickets? Thats what I want
when no more tickets, it won't let them spawn. they will stay at the respawn screen
oh i think i missunderstood you
Ohhh no Im actually trying a way to turn the respawn screen off.
when all players die I want it to go straight to the end mission screen. right now it hand out in the respawn screen for a few seconds then goes to the end mission screen. It feels clunky like that
well you have to find the IDD/IDC or saved uinamespace variable for the respawn screen, then when you do your condition, check to see if it is open (not null/nil) on the client and close it (all locally)
How do I do this part please? find the IDD/IDC or saved uinamespace variable for the respawn screen
lucky you, it looks like BI already made something for users:
Local Arg | Local Effect
["close"] call BIS_fnc_showRespawnMenu
luck indeed! How can I search effectivley for these functions? the wiki search bar seems to want EXACT matches (no spelling errors, etc)
i just go to the function list page and ctrl f something relavent
How do you execute code in the editor?
you start using advanced developer tools yet?
This isn't quite what I thought it would be. It lets you spawn on position of death if set to close. In the SOG:PF missions when all players are dead you get this nice splash screen that says all player are KIA or something like then it goes to the end mission screen without going back to the spawn screen. That's the effect I'm trying to reproduce.
["close"] call BIS_fnc_showRespawnMenu```
i wouldn't know. i don't have sog atm.
you are doing the vn end mission function after that?
if it still doesn't reproduce, you might have to make your own custom ending, which can be a pain
I hear that. Time to let this one go I think. On to the next one.
Does anyone have any suggestions on how to optimize this code, I can't come up with any more improvements. (its a global function that's executed unscheduled)
params ["_modelVectorDirAndUp", "_modelVector", "_unit"];
_vy = _unit vectorModelToWorld(_modelVectorDirAndUp #0);
_vz = _unit vectorModelToWorld(_modelVectorDirAndUp #1);
_vx = _vy vectorCrossProduct _vz;
_mat = matrixTranspose [_vx, _vy, _vz];
_output = flatten (_mat matrixMultiply (_modelVector apply {[_x]}));
_output;
Why are you trying to optimize this any more?
Beacuse it's one of the heaviest parts of my code (which runs every frame)
whats your current times?
You can inline the params using (_this select 0) (or 1 or 2)
Hm, doing everything inline would mean having to call things like vectorModelToWorld and crossProduct more times then I currently am
and have you run it through arma script profiler to see its impact?
whats the current execution time
according to advanced dev tools, its current time is 0.002ms, however its impact when the script is running is much more significant it results in ~3ms diff
0.002ms average with 10k iterations?
20ms with 10k
you probably aren't going to get that much more speed out of it at the moment. it would be better to consider not doing it every single frame, but have a simulation rate. not even ACE does every single frame for its vectormodels. use something like 0.05. (advance ballistics uses 0.05 for default sim rate)
Unfortunately this isn't really an option, the visual clarity of this needs to be exact. If everything else fails then I can re-consider this
Not sure inlining this really optimizes this much.
_vy = (_this select 2) vectorModelToWorld (_modelVectorDirAndUp select 0);
_vz = (_this select 2) vectorModelToWorld (_modelVectorDirAndUp select 1);
// return
flatten (
(
matrixTranspose [
_vy vectorCrossProduct _vz,
_vy,
_vz
]
) matrixMultiply (_this select 1 apply {[_x]})
)
have you tried it on MP anyways right now? theres already a network update lag that is going to happen as the object position is updated globally
like you can have something super smooth in SP, but its janky in MP due to network speed
I have tried it in mp on a dedicated. The object is entirely local and is not propogated over the network
smart
What is this for?
Have you consider other solutions?
There are keyframe animations that handle smoothly moving objects around. Would that be something could work for you?
Typically when you run into problems like this, you have to make a sacrifice or reshape the problem to be easier to solve
also, your speed tests are going to be different than my speed tests. i could be running it on a toaster and you just crashed my system or gave me a slideshow
I'm making a large quantity of objects follow the player. I've tried a couple different solutions and the one I have now seems to be the best balance between performance and visuals
Noted
Well thankyou both for the suggestions and feedback, I'll take them into account and try some modifications :)
Sounds awesome man.
Hi guys!
Is there a way to avoid loops? Or is this not such a bad way to implement something? If you run them in a separate thread
As far as I know they can put a heavy load on the server
My case: I want to players can't attach the object and enter into the trigger zone. So, if the player attach the object, when he come into the trigger area, attached object should detach
I think, that one way is to make loop, which tracks attached objects in area. If such exist, then they are detach
Loops aren't automatically bad, you just have to use them carefully. They can cause performance problems if you let them run too frequently.
A simple check over the players in a reasonably-sized zone is perfectly fine to run every second or two.
Since you already have the trigger, why not use it?
Activation by player presence?
You can check all objects detected by the trigger activated by any object for attached objects.
How do I make a UserAction/ AceInteraction to replace item A with item B in the inventory?
I need to replace the pistol (knife) with a flame extinguisher (bayonet)
The problem is player can attach something on the border with the trigger
And? Once he/she enters the trigger, it activates, and you can detach all attached objects.
The only problem is that players will be able to attach objects inside the trigger. In this case, you should either disable this possibility or add a check where attaching occurs.
Well, I did it. Thank you so much
But, I have one more question : scripts in the trigger are executed on the server or client side ?
Depends on the trigger settings.
I completely forgot)
In my case, should on the client, because I have hints in my script
In you case I would recommend setting up the trigger to be server side. In this case scripts will be executed, obviously, on server side.
But I have individual hints for players )
Then use 2 triggers: one for client (with client related stuff [hint's, etc] and one for server (which will detach attached objects).
Client side trigger will detect only local player.
👉 👈
What are some good ideas to implement a destroy cache task? Right now I am using invisible ballons near the cache. The idea being that when a player sets and explosive the balloon will pop and then I can deleteVehicle the cache object (some ammo crates). But the problem with this is it is so unreliable. Sometimes the balloon pops and sometimes not.
Worst case scenario I could use hold action to "plant explosives" but I would rather use the in game explosives because it forces the player to think ahead about inventory management.
Any other ideas?
i've seen people using destroyable props with custom damage handlers that block non-plantable-explosive damage
if that speed difference has an actual impact in your code performance theres something wrong with your code
Is there any way minus delaying the creation of the next display to ensure that the onUnload event triggers on any previous displays before my display opens?
as currently all the onUnload events just get stacked up until I use closeDialog 0; with no opening of new displays
closeDialog 0;
private _display = createDialog ["RCI_FactionEditor_Blocked_UI",true];
i think that's just how arma dialogs work, createDialog doesn't close any existing dialogs and the previous dialogs just wait there and will become visible again after you use closeDialog on the top dialog
yeah unfortunate. I was trying to find a way to detect which of my displays is the current active one. I may just use onLoad and set a common variable in uinamespace for it
you can check if dialog is active like this: ```sqf
_dialog = findDisplay 1234567; // Your dialog ID here
_isOpen = !isnull _dialog;
yeah cause the initial plan was to do this
private _display = uiNamespace getVariable ["RCI_FactionEditor_GroupCreate_UI",uiNamespace getVariable "RCI_FactionEditor_GroupEdit_UI"];
as the code is reusable in either GroupCreate or GroupEdit UIs as an example. So I just wanted an easy way to determine which of the two was currently open
but noticed this creates a bug where if you have tried creating a group, it will never make that GroupCreate nil again until all displays are closed. So it grabbed the wrong display
it's wild
from what I can tell, there are two options. One is a more resilient approach but it requires me to do a bunch of restructuring, or I can try to find a different way to detect what display is currently open.
not sure if i follow but another way to do something like that: ```sqf
onLoad = "uiNamespace setVariable ['MyDialog', _this select 0];";
onUnload = "uiNamespace setVariable ['MyDialog', displayNull];";
the issue is
onUnload will only trigger once all the displays are closed
it's delayed
engine limitation magic
hmm ok well thats a problem
If they are both weapons you do a removeWeapon and add the new weapon with addWeapon
For something that doesn't have destruction, I do my own custom damage handlers. This gets super complicated but I can show you a snippet later. Search for conversations in this channel between me and samatra to see how.
But mine is for a PvP scenario and requires a high amount of precision. For you, a silly work around will probably be fine.
@blissful current ready for your head to hurt again?
Read through those messages
Yep
Thanks! This part of my mission is a filler side task so I dont want to devote 30 hours into figuring out how to do something complicated. But I will definitely keep that in my back pocket for something more substantial. I might just nix it all together and wait for a different mission for this task and dive into your workaround.
Ok not home right now. Probably won't be until like 7 or 8 MDT
You can also do a check to find an explosive in an area, then check to see if it no longer alive (the explosive)
Is that an EH? I got my smoke one working but boy did it throw me for a loop for a while.
Or use a put event handler, that then adds an async check to find if that placed explosive is dead
