#arma3_scripting
1 messages Β· Page 140 of 1
yea.. I see it now actually. I thought first maybe I had to pass both a DEFUSED and ARMED variable. But defused false and defused true kinda does that too.
This whole code is not MP compatible at all with CODE being random for each player
That's... funny. Because on the original script it says "Fixed fully MP compatible thanks to K0rd and his hard work." 
Where do you call this code from?
It's in the init.sqf
Yeah, code will be different for each player
unless that's what you wanted
so each player inputs their own found code
and can't say find it and tell another player to input
No, that's not what I want at all
Is there a way to make it random, but the same for everyone or should I revert back to a fixed code? I don't mind either way to be fair
I didn't see what fixed code is
and what these scripts do to advise
Can you post these action scripts?
The addAction scripts that are both on codeHolder and caseBomb?
yes
defuseAction.sqf:
createDialog "KeypadDefuse";
searchAction.sqf:
_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;
_host removeAction _id;
_caller playMove "AmovPercMstpSrasWrflDnon_AinvPercMstpSrasWrflDnon_Putdown";
cutText [format ["Code: %1\n", CODE, 10], "PLAIN DOWN"];
Also, no search action on wrong laptops?
yea, that's correct. Only the laptop that will display the code has the action
Alright
CODEINPUT = [];
// Server decides the code and correct laptop
if(isServer) then {
CODE = [(round(random 9)), (round(random 9)), (round(random 9)), (round(random 9)), (round(random 9)), (round(random 9))]; //6 digit code can be more or less
publicVariable "CODE";
codeHolder = selectRandom [LAPTOP1, LAPTOP2, LAPTOP3, LAPTOP4];
publicVariable "codeHolder";
};
// Waiting for server to decide which laptop is holder
0 spawn {
waitUntil {!isNil"codeHolder"};
codeHolder addAction [("Search for a code"),"DEFUSE\searchAction.sqf","",1,true,true,"","(_target distance _this) < 3"];
};
caseBombActionID = caseBomb addAction [("Defuse the bomb"),"DEFUSE\defuseAction.sqf","",1,true,true,"","(_target distance _this) < 5"];
0 spawn {
waitUntil {caseBomb getVariable ["DEFUSED", false]};
if(isServer) then {
// This is global so have only server change the task state
["Task_Defuse", "Succeeded"] call BIS_fnc_taskSetState;
};
sleep 2;
casebomb removeAction caseBombActionID;
};
0 spawn {
waitUntil {caseBomb getVariable ["ARMED", false]};
if(isServer) then {
// This is global so have only server change the task state
["Task_Defuse", "Failed"] call BIS_fnc_taskSetState;
};
sleep 10;
casebomb removeAction caseBombActionID;
};
Also BIS_fnc_selectRandom is just a wrapper for selectRandom command now
Fixed waitUntil getting false by default
wow. Thanks. Very much appreciated. Is the if(isServer) then basically making sure that piece of code is server-side and not locally done?
Yes, only execute if executor is server
init.sqf is executed everywhere on each client initialization (and server and JIP)
Keep in mind that init.sqf runs each time player joins so if they go back to lobby and join again init.sqf will run again
And waitUntil {caseBomb getVariable ["ARMED", false]}; .. where is the variable set in this case? Should that not be mentioned somewhere as well?
Set it to true when you want it armed or defused
false means default variable value if not set elsewhere
So until some client sets it to something, this variable will be considered false
right. and that change happens in fn_codeCompare.sqf.
//Parameters
private ["_code", "_inputCode"];
_code = [_this, 0, [], [[]]] call BIS_fnc_param;
_inputCode = [_this, 1, [], [[]]] call BIS_fnc_param;
//compare codes
private "_compare";
_compare = [_code, _inputCode] call BIS_fnc_areEqual;
if (_compare) then {
cutText ["BOMB DEFUSED", "PLAIN DOWN"];
DEFUSED = true;
} else {
cutText ["BOMB ARMED", "PLAIN DOWN"];
ARMED = true;
playSound "button_wrong";
};
CODEINPUT = [];
//Return Value
_code
DEFUSED = true; => caseBomb setVariable ["DEFUSED", true, true]
ARMED = true; => caseBomb setVariable ["ARMED", true, true]
second true is to broadcast the variable
And then I also need to change the fn_bombTimer.sqf to get the proper variable. Change it to this?
while {_time > 0 && !DEFUSED} do {
...
to
while {_time > 0 && {caseBomb getVariable ["DEFUSED", false]}} do {
...
after testing that's a no 
Looks correct
Oh you forgot the !
while {_time > 0 && !(caseBomb getVariable ["DEFUSED", false])} do {
Same with lazy eval but its a drop in the ocean difference here
while {_time > 0 && {!(caseBomb getVariable ["DEFUSED", false])}} do {
Could it do the same if I change false to true?
no, that is default value
this condition will break as soon as you assign any value to that variable
break as in not do what you want it to do
while {
private _defused = caseBomb getVariable ["DEFUSED", false];
_time > 0 && !_defused
} do {
...
```if you want it to look neater
while {
(_time > 0)
&& !(caseBomb getVariable ["DEFUSED", false])
} do {
```my kind of neater π€
I have so much respect for you veterans out there.. Just me doing this kind of stuff for the past months, is making me realize how much work goes into this and how much knowledge you need before comprehending it.
Scripting itself is rather easy, knowing all quirks of the engine is something is mostly undocumented and only acquired with experience
yea.. that's it I guess. The logic behind it seems somewhat simple. But knowing the difference between ( ), { } and [ ] is already mind boggling for me.
That's general programming, wont be an issue after some time doing it
hmm.. the only issue I have now is that it's going from 5 minutes straight to 4 seconds and not ticking down. I tried a couple of things but no success π¦
This is the part that handles the countdown from 5:
if (caseBomb getVariable ["ARMED", false]) then {
_time = 5;
ARMED = false //take it I have to change this? But not sure
};```
I change the line I commented to the getVariable part, but that didn't seem to do anything
caseBomb setVariable ["armed", false, true];
I was about to type that, but slightly different. Just realized it's setting the variable to a condition, so it should be set and not get.
I'd prefer to recode that mess from scratch
handle all bomb initialization code on the server side and only init Actions on clients which calls server-side functions via remoteExec
use one object-specific global var to determine the current state of the bomb using macro like
#define BOMBSTATE_UNARMED 0 // not armed, safe
#define BOMBSTATE_ARMED 1 // ready to explode
#define BOMBSTATE_DEFUSED 2 // defused, safe
init on the server side
if (isServer) then
{
bomb setVariable ["BEAR_bombState", BOMBSTATE_UNARMED, true];
};
use addAction only on clients excluding Headless Client. Check the "BEAR_bombState" variable and depending on its state the matchign action should be shown
Assign each action to the server-side function which processes the request from the client, checks conditions, logs, doing other shit by your choice and disarms the bomb, setting it's new state to BOMBSTATE_DEFUSED.
Keep in mind if your server function is not executed in non-scheduled, you have to deal with concurency and lock the variable before processing it. isNil {} is ok for that or just use remoteExecCall.
If you figure out on your own how this client-server mechanism works, you will change your mind set eventually and the other things will be done way faster, more reliable and more clear to understand
if you're want to debug the vars, use Debug Console or add debug commands into your code. For example:
BEAR_fnc_DisarmTheBomb =
{
diag_log (format ["[BEAR_fnc_DisarmTheBomb] state: %1", bomb getVariable ["BEAR_bombState", -1]]);
bomb setVariable ["BEAR_bombState", BOMBSTATE_DEFUSED, true];
};
diag_log writes the line into .RPT so you can monitor the variable before you change the bomb state and make sure it has proper state to avoid disarming not armed / already defused bomb.
so check diag_log, format, remoteExec, remoteExecCall, setVariable, getVariable, CfgFunctions, initization order and Preprocessor BI Wiki articles
the whole idea
1. addAction on client init depending on current state
2. addAction code requests the server to do the job
3. Server process the request(s), makes callback to client-side if needed (for example it removes Actions completely, draws the hint with the message, etc)
And this one for the Mutliplayer scripting
https://community.bistudio.com/wiki/Multiplayer_Scripting
Thanks @bleak gulch for the resources etc.. I'm going to keep working on this and make it less messy. Unfortunately I need this script done by Thursday so it'll be fine for now (still some bugs but fine.) I want to make this better for future missions. I guess I have some reading up to do and make sure I completely understand this.
There are a couple things I would want to add/change anyway. Like an addAction on the laptops that don't give the code and saying "No code here", as well as making the defusing set to cut a wire AND the code.
{
if(_x == codeHolder) then {
// action with code
} else {
// action without code
};
} forEach allLaptops
allLaptops = [LAPTOP1, LAPTOP2, LAPTOP3, LAPTOP4];
...
codeHolder = selectRandom allLaptops;
and similar stuff
Noted! The next iteration will have that! Thanks.
semicolon
Valid by itself 
Is there a reason to put a script like this in it's seperate sqf? Or is putting it in init.sqf is fine? If I'm doing it "optimally"
Whatever is more convenient to you
Ok. I thought maybe there is a good practice idea behind it. I'd probably do it in their won script, so I don't accidentally delete something from other things.
the goodest practice is whatever you can be bothered to do
seperate script files is better only for organisation
theres no performance improvement for it
I'd just like to interject for a moment. When it comes to organisation and readability, there's an obligatory quote: βAny fool can write code that a computer can understand. Good programmers write code that humans can understand.β βMartin Fowler
I mean, it probably doesn't show now... but in my dayjob I have properly named folders and names of files everywhere :p I'm not a "Untitled folder" kinda guy. So I want to be more organized :p
i am an untitled folder everywhere kinda guy
all my blender models are also just kept in my downloads folder
Hey guys, 2 questions as I'm having trouble getting trigger to work correctly - it works but I'm having some locality issues with it and I want to check if my "notes" are right:
- Activation and condition - am I doing it right? Expected behavior is that trigger activates whenever a vehicle present in dnt_deployedVehicles will enter trigger area and deactivates when it leaves it. I set activation to none as
(count ((vehicles inAreaArray thisTrigger) arrayIntersect dnt_deployedVehicles)) > 0is only condition I want to activate it - If trigger is only evaluated on the server but I use remoteExec["someth",-2] in "On Activation" then after trigger is activated "someth" function should fire on all clients, right? Or should I leave "Server only" unchecked if I want function to execute later for clients?
1:
(vehicles inAreaArray thisTrigger) findIf {_x in dnt_deployedVehicles} != -1
1.5:
You may need to select Anybody from the activation condition
2:
Depends, are you absolutely sure that you want this function run on every client? Is it written for that?
Hello, I am trying to apply a 10m trigger condition when in this case an ACE flash is detected, a door is opened, I tried to do it in different ways, but it does not apply to me.
I don't have much knowledge about this and I'm not sure what the problem is.
Perhaps the ace flashbang when airborn is no longer of the class "ACE_M84"
Yes, but I still tried to put it down to check.
If you just placed it on the ground that is not what it would be called when its airborn
try using ACE_G_M84, No idea if that works but worth a shot.
Also this page sounds like exactly what you're doing
https://www.reddit.com/r/armadev/comments/p2rzee/activate_trigger_when_blue_smokeshell_thrown/
Yes I tried, thanks, and it is the page I use as a guide but I can't get it to work.
Ok, after reading it I realized that everything was wrong.
Does anyone know a way to detect an item inside a trigger?
I want to detect the flash when inside the area, but I don't think it will work in
I have only found information about detecting it within an inventory, but it is not what I am looking for.
I'm currently working on an automated mine placement for buildings, but I get stuck at getting floating mines. Any idea?
Code in link
https://pastebin.com/T9W5QvFu
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.
Warlords with custom factions question: Why are units spawned inside sectors to defend not limited to what is shown here? Is it because I have a faction defined in the module to be used?
class CfgWLFactionAssets{
class WEST{
class InfantryUnits{
class B47_WZ_TP_Rifleman_Light_A{};
class B47_WZ_TP_Rifleman_Light_Mk17_A{};
class B47_WZ_TP_Rifleman_A{};
class B47_WZ_TP_Rifleman_Heavy_A{};
class B47_WZ_TP_Marksman_A{};
class B47_WZ_TP_Automatic_Rifleman_A{};
class B47_WZ_TP_Machine_Gunner_A{};
class B47_WZ_TP_Heavy_Machine_Gunner_A{};
class B47_WZ_TP_Rifleman_AT_A{};
};
};
class EAST{
class InfantryUnits{
class B47_WZ_NP_Rifleman_Light{};
class B47_WZ_NP_Rifleman{};
class B47_WZ_NP_Marksman{};
class B47_WZ_NP_Automatic_Rifleman{};
class B47_WZ_NP_Machine_Gunner{};
class B47_WZ_NP_Heavy_Machine_Gunner{};
class B47_WZ_NP_Rifleman_AT{};
};
};```
When i'm commanding a ship and i click on the map, my character gives order to move to the position i clicked on. How do i prevent that ?
I'm looking for a solution without disabling coms
That's intended functionality. Only solution is to not be in a "commanding" seat.
Does this use the same file path structure as the preprocessor has_if?
https://community.bistudio.com/wiki/fileExists
2: I think I do? Function adds an action to object whenever trigger is activated and removes action when it's deactivated. My intention is that whenever a vic (present in array) enters trigger area action is added to an object for all players (JIP too) to interact with and when object leaves area action should be removed for all players and afaik addAction is added locally for a player?
Having a Multiplayer-related issue on Line 30. When in SP, script works fine - radio speaker spawns, light point spawns, spotting tube spawns, and the shot spawns. However, when testing in 3DEN using a MP-host, everything works except for the laser tube sc_scripts_orbitalcannon_beam. Any suggestions to make spawing this work in both SP and MP?
please use pastebin.com
I'm currently working on an automated mine placement for buildings, but I get stuck at getting floating mines. Any idea?
Code in link
https://pastebin.com/T9W5QvFu
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.
private _explosive = createMine [(selectRandom _explosiveType), ASLtoAGL _surfacePos, [], 0];
lineIntersectsSurfaces returns ASL positions, createMine takes AGL
Thank you! Will try that out when I get home from work
damn chat GPT-4o is way better on sqf now ( far from perfect) but it can make some code that really works, so we gonna see a lot of questions here of gpt generated code lol
How about providing it with all info from BI wiki.
I have been doing that with 4, works pretty good
ive tryed to "teach" how SQF works and the commands i want to use, and it was quite good
but now it can do some complex stuff with out so much guidance
I've scraped all commands and functions from BI, and all info from the other pages to txt files and made my own gpt with those files.
It's good, but it's just a guidning in the right direction. Still gives wrong commands sometimes, like vectorsubtract instead of Vectordiff π
yea, still have errors like: side group _unit
but the code is harder to diferenciate now
yea, maybe you run ot of tokens, so not all commands were processed
i guess it can be identified beacse it explain every line with a comment, but its much better now
||```sqf
->THIS IS CHAT GPT GENERATED CODE DONT USE IT<-
// rewardOnKill.sqf
params ["_unit", "_killer", "_instigator"];
// Configure the reward item and amount
private _rewardItem = "rvg_money";
private _rewardCount = 10;
// Check if the killer is a player
if (isPlayer _killer) then {
// Check if the unit is not on the same side as the killer
if ((side group _unit) != (side group _killer)) then {
// Check if the unit is not a civilian
if ((side _unit) != civilian) then {
// Add the reward to the killer's inventory
for "_i" from 1 to _rewardCount do {
_killer addMagazine _rewardItem;
};
hint format ["You have received %1 %2 for killing an enemy!", _rewardCount, _rewardItem];
};
};
};
we gonna need a chatGPT detector now lol
Invite ChatGPT bot to check if code snippets are from ChatGPT 
Checks side group _unit and then side _unit on the next line 
these can result in different sides
isPlayer only checks if effectiveCommander is player, which is not always a case for vehicles
oh wait side group is right, i didnt know that you can use the group to get the side lol
||```sqf
-> chat GPT GENERATED CODE DONT USE IT <-
{
if (!isPlayer _x && (side _x != civilian)) then {
_x addEventHandler ["Killed", {[_this select 0, _this select 1, _this select 2] execVM "rewardOnKill.sqf";}];
};
} forEach allUnits;
it goes in a killed eventhandler, why it can result of diferent sides?
execVM 
There is a bug/case where unit can have different side than their group
private _unit = createGroup blufor createUnit ["C_Man_1", getPos player, [], 0, ""];
[side group _unit, side _unit]
``` => `[WEST,CIV]`
Either way, much more impressive than before
yes, well in this use case, that bug is solved by using side group, since you want to know if there was a teamkill
chatgpt is going to be the way to generate 2000line functions for something that can be written in a human readable way in 100 lines, but going to include nasty race conditions π
hey that ain't bad
if the code works flawlessly in the first try, its usable, but if not, you will spend more time debugging some code that you dont understand, than doing it from scratch.
Its the big catch behind the "AI will remplace x", yea maybe it can do that job, but always will need a human to supervise what a AI does, so in the end... its like saying a wrench will replace a mechanic
i feed it up with some code i found in this channel, and described quite well what the code does, also i ask it to improve de code, and give a pretty decent alternative
"if the code works flawlessly in the first try, its usable" - big no. If you ever need to touch that portion of code again you are essentially fckd. Even if it "works" at a time.
meh, normally the person that uses chatGPT code is bc gpt has more knowlage than that person on that languaje, so it wont be able to write that code in the first place
I challenged chat GPT to work with vehicle pylons, it's now arguing why humanity should be erradicated
oh so you started Skynet, great
It's doing it when i'm leading even if i'm not in a commanding seat. But i see, thanks for your answer
π€¦ββοΈ
Stupid freaking robot is what I call it
So I remember having a problem working on a particular project in the past ( so I don't have any example code drummed up yet) but: there was always something wrong with how handling a "timer" worked. The player's timer goes up upon killing another player. Which is handled by the method that is called after EntityKilled is evoked. I was using remoteExec to ensure it got put into JIP Qeue and remove any type of locality clashes from server and client. Timer would run on the client and anytime a unit would be killed the function that runs on the player for the timer calls for a reup from the server via remoteExec
any inate problems with this? Doesn't seem like a bulletproof way of doing I guess "callbacks?" in the net from SQF level. Timer would constantly drop into the negative despite any logic problems hashed out. It would never kill the player when the timer runs out like it's supposed to or it would kill the player prematurely
Pretty good imitation of a human then.
Assuming that the player needs to see an accurate timer, I'd put the entitykilled handler on the client instead.
remoteExec timing is... not reliable.
that's fair, ditch the MP Handler for the local EH?
You can install mission event handlers on clients too.
That's right. Are they perhaps stackable in the same way then too?
addMissionEventHandler is stackable. I'm not sure what you mean though.
You can install the same code on every machine and they won't interfere.
I'm assuming that because addMissionEventHandler is stackable because of it's own behavior and not a specific event?
and that it gets it's own index for every duplicate event handler added like addEventHandler would
Yeah, you can install two different EntityKilled handlers on the same client for example.
but I think I'm starting to understand what you mean. addMissionEventHandler is kin to as if you were to add the event handler to every player?
I don't know your mission.
EntityKilled is installed once and fires for every object killed.
I'm confused as to why the suggestion is to change how and where the handler is added versus how remoteExec performs
The Killed EH is only fired when the target object is killed.
On the server?
ues
The suggestion is to add it to each client instead.
And then clients do their own timer handling.
Ahh. I see.
Sounds good, I'll see how that owrks out. Fingers crossed.
one last brain battle here,
is loadFile executed asynchronously under the hood? Not sure how the threaded work load works in SQF besdies unscheduled is faster but encounters blocking and scheduled does not have any blocking
(given that you have proper UTF8 endcoded chars)
I would guess that it's synchronous.
"scheduled does not have any blocking" is arguable. If you call a slow command in scheduled then it can take multiple seconds without suspension.
Shouldn't be a problem, it's just essentially a flat configuration lookup that I'm doing.
slow command
Guess that also depends does it not. A headless a3 client running as a server doesn't have a GUI to render and most of the tasks a CPU can crunch through with ease
besides things like high entity count
Commands that scan the entire map for objects are a common example.
So it what, bruteforces a check from starting to end?
given that there isn't any parameters to check by
I'm not familiar with how that works on a fundamental level.
Scheduled only suspends at checkpoints. Ends of statements, some loop commands.
so waitUntil uiSleep and sleep are scheduler flags?
Nah, those are forced yields.
Ok very good lol
Checkpoints, end of statements, and some loop commands though? Is it nearly trivial without debugging it?
I know there are some event handlers that run in a scheduled environment but I just considered that black magic
I think the ultimate solution here would be just to throw top level SQF out the window and use ded's suirrel wrapper
As far as I know, all event handlers are unscheduled?
All except a few, it's been literally years since I last revisted that but a few are scheduled
name one :P
π
Now addAction does run its code as scheduled.
yeah but on the backend of that isn't it just registering new fields into a dialog
shrugs
It would have been a choice at some stage.
Dialog events are generally unscheduled.
Arma 3 alpha π
At least I think so. It's not documented.
onLoad and onUInload
this is all to say though, spawn does exist.
without exiting the working thread though I do not believe you can do the inverse
isNil {
// anything in here is unscheduled
};
π€¦ββοΈ I forgot about that. How tacky but it works
How is it possible that you can create your own event handlers in CBA, how does it work? I thought that events are hard coded in the Arma 3 engine(game code).
secret intergalactic trade secrets (probably macros) π
shorthand in functions I believe
There's actually a vanilla equivalent:
https://community.bistudio.com/wiki/BIS_fnc_addScriptedEventHandler
I don't think that's how CBA ended up handling it though right.
The method isn't dissimilar.
It's not complicated really. On each machine you maintain a list (hashmap, if you're doing it properly) of event names and the code that should executed when that event name is triggered.
The hardest part though, do you have qualifying information to be invoking events off of?
Do they somehow add function calls into the classes definitions in configs?
Oh, that's different stuff.
CBA also does some fairly expensive each-frame checking for whether specific "events" have occurred.
And in other cases it's just forwarding Arma events.
(sometimes when they were added later)
Graceful
I thought they are able to, for example, throw event when you get prone without any kind of additional check via sqf.
animStateChanged I think is one that throws that
but it also executes for every single change in animation change.
There is a lot of like IK animation handled like that. \
I am just trying to figure out how can you simply detect a condition that is not provided by any EH or command by Arma itself without doing heavy per frame checks. If it is even possible to do different way.
To check to see if player is prone?
@ornate whale
player addEventHandler["AnimStateChanged",{
if((_this # 1) find "amovppnems" != -1) then {
hintSilent "player is prone!";
} else {
hintSilent "player is not prone!"
}
}];
and yeah this works for rolling and moving whilst prone as well.
Yeah, I know this, but if it is possible to do without animChanged for example, and without repeatedly checking some sqf command.
last time I checked you can't read memory addresses in SQF so no. Not really π
also, the event handler isn't constantly firing
I thought if the config classes could be of any use in this regard
Like call a function when a unit fires etc.
I mean yeah, but that's to lookup the animation moveset of whatever unit you're targeting
as far as any soldier goes, I don't think literally any of them change from the Man inheritance
All things considered, what you're purposing and what I posted are pretty close. The next variant you get out of that is then switching to handling keys if you say you want to then call a function on firing but without any EH's
displayAddEventHandler has a event called mouseButtonDown I believe that would fire at any time on the main display if you left clicked. π€·ββοΈ
actionKeys, etc
SQF itself is like an abstraction layer between how the game functions on the engine level and your top level SQF scripts. You can only use hooks that are given in that way
animationState player
returns the same info just all lowercase π
"I want to do this"
"Here is the way to do this"
"Yeah okey, but I want to do this without doing that"
But but. But why
?
also I believe we were just talking with you about this:
https://community.bistudio.com/wiki/BIS_fnc_addScriptedEventHandler
@high marsh @granite sky Thanks for your tips, I think you answered my question. I was just curious if there is anything unusual going on in CBA, and what the other options are.
if you're not building an addon or need CBA for something very specific that you couldn't do yourself for some reason than no need to
hey i dont understand this part of addAction, i have the following code:
this addAction ["Mystery Box!", {execVM "Scripts\MysteryBox.sqf";}, nil, 6, true, true, "", "true", 5, false, "", ""];
```in the init of a supply box and i want to pass _caller to the "MysteryBox.sqf" script but i dont understand how to do that. any help?
you are scripting a mission for example, you can dynamically grab user configuration for keys.
or detect when people are prone, etc etc
CBA is a good suite of everything if you are building an addon and want to get things off the ground quick imo. But totally not worth adding another potential dependency
this addAction["Mystery Box!",{[_caller] execVM "Scripts\MysteryBox.sqf", nil}, 6, true, true, "", "true", 5, false, "", ""];
@junior moat
didnt realise it was that simple lol, thanks o7
Wait it's not a magic variable I don't think
you may need to select it from the past _this variable and so if that doesnt work give this a shot:
yea i just got an error with this and now the action doesnt even show up
this addAction["Mystery Box!",{ [(_this # 1)] execVM "Scripts\MysteryBox.sqf"}, nil, 6, true, true, "", "true", 5, false, "", ""]
I need to sleep
how do i reference the caller in MysteryBox.sqf?
@junior moat
?
// option 1: just use the _this reserved variable to reference passed arguments (like _caller in this context)
_callerDude = _this # 0; //depending on how it's passed. It can be an array of many arguments, an array of one, etc etc. the # operator selects the index of 0 from _this in this example
// option 2 : use param and params for error checking and type checking
params[
["_callerDude","ThisIsADefaultValue",["ThisIsAValueIndicatingAcceptedTypes"],1] //1 indicates we only need one of that type in this variable and you just do this for every variable you need accessed
]
ah, thanks
I prefer params for anything that has more than one paramter just because automatic error checking and type checking is a win win
there is also param which you specify at which index to do the checks on
Hello, can anyone give me information about ACE advanced throwing? I want to detect when the grenade is thrown, like "Fired" in ARMA.
["ace_throwableThrown", {
params ["_unit", "_throwable"];
// do stuff here
}] call CBA_fnc_addEventHandler;
Works locally at least.
Thanks, isn't there more information like this?
Yes, but it tends to be incomplete on events: https://ace3.acemod.org/wiki/
I don't think that one is in there. I usually just read the source.
so im using a script to play a video but when i execute it instead of playing the video it just goes to a blank screen?
confused as to why this is ive followed a guys tutorial on YT and his works fine.
script below:
video = ["\movie\endingcutscene.ogv"] spawn bis_fnc_PlayVideo;
Do you have PiP turned on in your graphics settings?
nvm i figured it out now this script only works if its in your mission folder, my video is in a subfolder i moved it now it works π
Yeah, I can't find anything, don't you have the "Cook" part of the code?
If it's your own code (that you can edit/control), you just add callbacks to the events that you need (e.g. let's say you want something to happen when a light is turned on, so you just call a function [true] call my_fnc_setLight and handle everything there, instead of constantly checking a var waitUntil {my_isLightOn})
If it's someone else's code (including engine code), you're at the mercy of whoever wrote it. If they didn't implement any sort of callback for an event you have no choice but to check in a loop (altho sometimes you can come up with more clever tricks)
Error type Any, Expected Number
Any ideas? I am trying to do so, that when you equip specific uniforms, your scale changes (to 1.15 in this situation)
Any ideas where my mistake is? https://pastebin.com/ArqYcJPt
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.
if (uniform _unit in _powerarmor) then {
...
and you are using local _, so it doesn't remove earlier eachofframe eh, you should save that in variable in player or to global var
I'm basically trying to spawn a tank on a empty marker when a certain trigger is activated, but I'm not really sure how this works. The code bellow doesn't return any errors, but doesn't work either
_tankGroup = createGroup east;
"CUP_O_T55_TK" createUnit [getMarkerPos "tankSpawnMkr", _tankGroup];
Use createVehicle.
Check the link for syntax.
https://community.bistudio.com/wiki/createVehicle
private _veh = createVehicle ["CUP_O_T55_TK", getMarkerPos "tankSpawnMkr", [], 0, "NONE"];
createVehicleCrew _veh;
Thanks, I'll try to fix it
Does anyone know the "cook" or "primed" function of ACE advanced throwing?
I know where it's at;
https://github.com/acemod/ACE3/tree/b26d6543a6320000fe585913dd6237c9caca39e4/addons/advanced_throwing/functions
Perfect, thanks.
so ive got this video im trying to get to work ingame as a cutscene ive tried multiple different things to get it to work but for some reason the video just speeds ahead while the audio plays at a normal rate and then it will cut off abruptly
Saving it at a different frame rate, a different bitrate nothing nadda.
What am i missing? is their limitations to the video files?
I've got a retreat function working.
I wondered if there was a method for AI to deploy smoke while considering the wind for maximum concealment during the retreat.
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.
Is there way to restrict to change the public variable for non-owners?
// Server (trusted)
PRO_myVariable = "Hello, World!";
publicVariable "PRO_myVariable";
// Client (non-trusted)
PRO_myVariable = "Hello, Universe!"; // throw an error
publicVariable "PRO_myVariable"; // or here
at this moment I have to use set/get + remoteExcec functions to set and retrieve this type of vars which prevent of unauthorized access to the vars from the clients. But is there more convenient way in my approach? I don't like the idea when the game allows to overwrite other's machine variable without any restrictions (on purpose or accidently).
You can use CfgDisabledCommands to stop non-server machines using publicVariable (https://community.bistudio.com/wiki/Arma_3:_CfgDisabledCommands)
Bear in mind that might affect BI functions as well, though.
this is not what I am asking for... (
Use remote exec and only trust the server
"Hello, World!" remoteExec ["something", 0];
something = {
if(remoteExecutedOwner != 2) exitWith {};
PRO_myVariable = _this;
};
Already using such technique. The problem with this code - it is not mandatory. You can easily overwrite the variable with publicVariable accidently or on purpose ignoring set/get + remoteExec (I mentioned this right in my first message).
whats the purpose of publicing the variable if you only trust the server? Why not feed the value directly to whatever you require it for?
@kindred zephyr
For example you have an object and want to publish its state:
// Server
object setVariabe ["state", 0, true];
// Client decides what to do depending on object's state
switch {object getVariable ["state", -1]} do
{
case 0: {...};
case 1: {...};
default {...};
};
Client must have read-only access to the "state" variable of the object and must never overwrite it because it may affect other client(s) or the whole mission / addon logic.
At this moment CfgDisabledCommands doesn't provide ACL mechanism to whitelist the specific arguments for the command, It filters the syntaxes but you cannot specify this logic:
"You can use publicVariable for all variables but var1 and var2. setVariable with true flag is also not allowed for var3 but allowed for var4 because var4 is in local object".
You have to disable publicVariable and setVariable entirely and make a set-get wrapper for all instances using these commands, especially BIS and CBA functions.
does anyone know if - https://community.bistudio.com/wiki/BIS_fnc_arrayShuffle works properly?
Not having luck using it currently
found out you cant put an array like _array in the [] for it wont work when calling so proper format is actually - _array call BIS_fnc_arrayShuffle;
That's because [ ] are what denote an array. If you have an array stored in _array, then using _array is the same as writing e.g [1, 2, 3]. If you then do [_array], that's the same as writing [[1, 2, 3]] - an array inside an array.
BIS_fnc_arrayShuffle will actually "work" with an input consisting of an array inside an array, it's just that it's only shuffling an array of one element (that element being the inner array) so it doesn't do anything noticeable.
"Hello, World!" remoteExec ["something", 0];
something = {
if(remoteExecutedOwner != 2) exitWith {};
with localNamespace do {
PRO_myVariable = _this;
};
};
PRO_myVariable can be overwritten without calling something. As I told, the whole command (publicVariable and setVariable) must be disabled or it's pointless to use set-method and allowing other ways to bypass the restrictions.
moreover even using set-get way it's very inconvenient comparing to keywords and/or using dedicated CfgWhatever section to define the access levels.
with second example broadcasting PRO_myVariable won't overwrite it inside localNamespace
If you mean a cheater could overwrite something to alter its behaviour, you already have a cheater with random script access and its FUBAR already
yeah, same as using locally created objects but... don't you find this way is a bit bloated and overcomplicated for the simple thing?
Actually, you can even do something like this;
// Server
"Hello, World!" remoteExec ["something", 0];
// Everywhere
something = {
if(remoteExecutedOwner != 2) exitWith {};
PRO_myVariable = _this;
with localNamespace do {
PRO_myVariable = _this;
};
};
"PRO_myVariable" addPublicVariableEventHandler {
missionNamespace setVariable [_this select 0, localNamespace getVariable (_this select 0)];
};
This way you won't have to query localNamespace each time you use the variable and it will protect it from broadcasting
god...
Yeah, the whole thing was designed with trust for clients in mind (aka lazy)
Apparently, I haven't tried it myself
Broadcasting forbidden variables can be partically solved with BE
The problem with the addPublicVariableEventHandler is if "PRO_myVariable" pubVar'ed, the other stackable EHs will be fired despite you reverted the variable value back from the localNamespace. If you have 3rd party addons / frameworks with addPublicVariableEventHandler the EH may proceed the variable before your code makes the variable "read-only". It provokes undefined behaviour. In this case you must be sure
-
Your code, BIS functions, CBA or any 3rd party addons don't use _this select 1 value from the pubVar EH and only work with the variable itself (_this select 0). _this select 1 contains the new variable value which must never be applied.
-
Your protecting EH is fired before any other stacked EHs.
At this moment you have to make overcomplicated solutions for the very simple task even utilizing AC software.
localNamespace is a good option to store private data but the game doesn't serialize the data in that space so it cannot be used with the savegames. We prefer to use locally created vehicle (Logic).
I do want to remove earlier EH. If they will start stacking up, that will hit performance
I'm trying to detect when a grenade is cooked in ACE, but I can't identify it, can someone help me?
https://github.com/acemod/ACE3/blob/b26d6543a6320000fe585913dd6237c9caca39e4/addons/advanced_throwing/functions/fnc_prime.sqf
You could check before adding new or deleting exiting (if not powerarmor), does unit have EH or not.
so you dont add new if he have already EH.
And remove if the new uniform is not power uniform and player have eh,
private _mfresize = player getVariable ["MRK_EachEH", -1];
private _hasEH = _mfresize != -1;
if (uniform _unit in _powerarmor && !_hasEH) then {
_mfresize = addMissionEventHandler ["EachFrame", {player setObjectScale 1.15}];
player setVariable ["MRK_EachEH",_mfresize];
} else {
if (_hasEH) then {
removeMissionEventHandler ["EachFrame", _mfresize];
};
};
you have to subscribe to Throw event
line 55 calls CBA_fnc_globalEvent with type QGVAR(throwFiredXEH) so you have to use CBA_fnc_addEventHandler in order to add the callback function
http://cbateam.github.io/CBA_A3/docs/files/events/fnc_addEventHandler-sqf.html#CBA_fnc_addEventHandler
Nothing of this should matter as long as they don't modify stuff inside localNamespace
Unless you meant you wanted to protect every single public variable like that, then that's futile
Having some protection for own stuff is much more doable
yo am new to arma idk if theres a help channel here but whenever i open the map i get this map not the one with like ability to scroll and mark stuff why is that
on ytube i see em having smthn on top called "tempmissionsp" with like ability to mark stuff
Ability... to... what? Do you mean you are loading Arma 3 Contact and that's why?
I guess you cannot rely on crew being in the same order on all clients?
Hmm, the order always seems to be driver - turrets - seats so you probably can, assuming seats are properly synced
ty, but I can't get the event to identify me, I try different ways:
player addEventHandler [ "QGVAR(throwFiredXEH)", "Throw", { systemChat str "Actived"; }] call CBA_fnc_addEventHandler;
am guesing it should be something like this with markers and stuff i took this ss from ytube
is it cuz of some mod or dlc?
Literally I've mentioned in the post
you are loading Arma 3 Contact and that's why?
add in to init.sqf file
//QGVAR -> quoted ace_advanced_throwing -> becomes "ace_advanced_throwing_throwFiredXEH"
["ace_advanced_throwing_throwFiredXEH", {systemChat str _this}] call CBA_fnc_addEventHandler;
ohh my bad man
appreciate the help
I want to run a script when player has a specific pistol weapon pulled out and only then. It has to be something reusable, ie. it runs every time the player pulls out that specific weapon. I could have a loop script that checks every second if the player has that specific weapon pulled out, but I was wondering if there is more elegant way to do this, or with better performance.
In 2.18 you'll be able to use the WeaponChanged EH, but unfortunately not yet.
For now, I think a loop is the only way.
If it's constructed sensibly it shouldn't be too bad for performance - just check currentWeapon and immediately continue if it doesn't match.
what's your environment? Multiplayer or Singleplayer? Is CBA available? Mission or an addon?
Multiplier, CBA can be used, it will be an addon.
@thorn saffron
If CBA available, check this
http://cbateam.github.io/CBA_A3/docs/files/events/fnc_addPlayerEventHandler-sqf.html
CBA_fnc_addPlayerEventHandler
CBA_fnc_removePlayerEventHandler
βweaponβ currently selected weapon change
βturretweaponβ currently selected turret weapon change
βmuzzleβ currently selected muzzle change
βweaponModeβ currently selected weapon mode change
// Add EH and store its ID
TARO_Weapon_EHID = ["weapon", {systemChat (str _this);}] call CBA_fnc_addPlayerEventHandler;
// Remove EH and set its ID to -1
["weapon", TARO_Weapon_EHID] call CBA_fnc_removePlayerEventHandler;
TARO_Weapon_EHID = -1;
I see, thanks. I was looking at the custom CBA events and missed this one.
You can also use the AnimStateChanged event handler
Hey and good morning, anyone have access to a vehicle spawn script?
Seems like the respawn module In Arma3 does not like to work.
Good Day. I noticed that some buildings (like Land_i_House_Big_01_V1_F for example) do not trigger "EntityKilled" event handler when getting bombed and being replaced with partially ruined model. Is there a known workaround for this issue?
thats strange, you could try "Killed" EH but maybe it has the same issue..
Anything that generates a ruin triggers "BuildingChanged".
Kinda surprised that those don't generate EntityKilled too though.
You're right, thanks!
handleDamage only triggers where the unit is local, right?
even if they are in the vehicle - or can there be in such case some influence from effectiveCommander/to whom the vehicle is local to? (just taking unit/infantry damage)
the only cases where its not local is for bleeding and that weird HitHead damage
Crash damage is done by vehicle owner with no attribution
if vehicle owner decides there was a crash and crew damaged, its broadcasted to remote crew
HD fire still will only be where unit is local
Error Missing )
player addEventHandler ["Fired",
{
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
if
(
_weapon = AM_Laser_Musket
)
then
{
player setAmmo [currentWeapon player, 11];
}
else
{
};
}];
Am I too tired to figure out whats wrong with this?
Perhaps the weapon classname should be a "string" rather than a global variable name?
Also it's == for comparison - = is to set the variable
Perhaps you are right
hey how would i go about making it so that, at the start of the mission, the screen is completely black? i want to have it start black, some title text appears, music starts playing. and as soon as the lyrics start, theres a quick fade from black. i tried using BIS_fnc_fadeEffect but it didnt seem to work how i wanted it to, any help?
Multiplayer or single player. You'll use a combination of cutText and other such stuff but with multiplayer, you'll want the start of everything synced after all client states are ready. Modules Enhanced MP Sync module does this.
multiplayer, im using a function which is in the init box of every playable unit
Is it a scene that you want everyone to see the same exact thing at the same time? If not, then what I said above won't matter. If so, you'll have to sync the start time with all the clients since each client will have a different load time.
true, didnt think of that. its not the absolute end of the world if every client sees it at the same time or not, but it would be prefered if its easy to do. on that note, how would i go about doing this then?
my current code is as simple as:
if (hasInterface == true) then {
hint "call intro music";
playMusic "FalklandsSongIntro";
[1, "BLACK", 10, 1] spawn BIS_fnc_fadeEffect;
};
this works somewhat time
its just that i want the black screen to last longer before fading away, unsure how i would go about doing that
Use cutText
And a extremely small number on the timing to make it instant black. Like 1e-6
got it, ill try that out now
Then wait, and fade it back in the same way.
fade it back using cutText still?
aha, got it working! much appreciated!
Thanks, its works.
@junior moat
if (hasInterface == true)
// change to
if (hasInterface)
there is no reason to evaluate BOOL to BOOL in comparison when hasInterface is already your result (true or false).
So. Just to make sure I'm not going insane. If I use something along the lines of
while{something} do {get new position; simpleobject setpos (new position);};
It should move the obj to the new position repeatedly, correct?
Better to state what makes this question and/or context too
Is the question not clear?
Hence my question
->It should move the obj to the new position repeatedly, correct?
Does the code work as intended?
Technically no because it is a psuedo code. If you write it correctly, maybe, maybe not. I can't say without how exactly you've done this or why you ask this
I'm asking because I swear I'm the definition of insanity. I tell it to get a get a new position every second, It updates to the new position correctly. I tell it to move the object to the new position, it doesnt move.
while {counter < 40} do
{
_relpos = _InterceptObj worldToModel ASLToAGL _InterceptPos;
_obj setPosASL (_InterceptObj modelToWorldWorld _relpos); //not moving for some reason
counter = counter + 1;
sleep 1;
};```
Seems like it is doing its work propely. It's just because it is moving to the same position
Which make no sense, because I'm watching the new position: (_InterceptObj modelToWorldWorld _relpos) change in real time.
yes. _interceptobj is moving.
Also, if you wonder... always do a debug print like systemChat to check how every variables work, or even the code itself
Yeah. I'm using hintsilent inside the while loop for debug. I just removed it when I posted the code for ease of understanding.
Are you sure EVERY variables are working properly?
I want to say yes because I'm watching the variables change, but at the same time. Its not working for whatever reason, so IDK.
I feel like I need to go back to square one and ask: what can I use to move a simple object after its created?
where is _InterceptPos defined?
Anyone know an easy way to replace an item located inside of vehicles to completely replace it? RACS is using a outdated galil mag and i need a script to replace it via script. Problem is, I dont even have the brains to do so and Im completely unsure of any templates out there. Anyone have a template I can use?
if (isServer) then {
private _magToFind = "myMagClassName";
private _magToReplace = "myNewMagClassName";
vehicles apply {
private _vehicle = _x;
private _magazines = magazineCargo _vehicle;
_magazines apply {
private _mag = _x;
if !(_mag == _magToFind) then {continue};
_vehicle addMagazineCargoGlobal [_mag, -1];
_vehicle addMagazineCargoGlobal [_magToReplace, 1];
};
};
};
if !(_mag == _magToFind)
if (_mag != _magToFind)
π
I don't like using those in my code. same with isEqualTo and isNotEqualTo
But it is two operations instead of one.
Also I recommend you to replace second loop with the engine-implemented search like find:
private _index = _magazines find _magToFind; // WAAAAY faster
if ( _index != -1) then
{
// do replace
};
There is only one downside of this method: mag classname is case sensitive. So you need to point EXACT name of the magazine.
You're probably better off reducing the number of inventory ops, like:
private _count = { _x == _magToFind } count _magazines;
_vehicle addMagazineCargoGlobal [_magToFind, -_count];
_vehicle addMagazineCargoGlobal [_magToReplace, _count];
// Based on Hypoxic's
// Edited by Katushka
if (isServer) then
{
// Settings
private _magToFind = "myMagClassName";
private _magToReplace = "myNewMagClassName";
// Job
vehicles apply
{
private _cargo = getMagazineCargo _x;
private _index = (_cargo select 0) find _magToFind; // speed up!
if (_index != -1) then
{
private _amount = (_cargo select 1) select _index;
_x addMagazineCargoGlobal [_magToFind, -_amount];
_x addMagazineCargoGlobal [_magToReplace, _amount];
};
};
};
count iterates over the magazine array as other iteration methods like forEach, select, apply, for, findIf step-by-step.
Yes, but what makes you think there's only going to be one magazine of that type?
the second snippet replaces all magazines of the same type
Ah right, getMagazineCargo is better than I thought.
getMagazineCargo cursorTarget;
returns this for Box_IND_Ammo_F:
[["30Rnd_556x45_Stanag","20Rnd_762x51_Mag","9Rnd_45ACP_Mag","30Rnd_9x21_Mag","200Rnd_65x39_cased_Box","1Rnd_HE_Grenade_shell","NLAW_F","HandGrenade","MiniGrenade"],[24,6,6,6,3,6,1,6,6]]```
So we have 2 nested arrays. One with the classnames and another one with the amount of magz. We can iterate through the first one using engine search `find` to obtain the index and if it's not -1, then we extract the amount of the magz from the second array.
Keep in mind there is NO mass check. You can face the situation when your cargo space is not sufficient to keep all new magz. If you need reliable mag replacement you have to obtain the new magazine mass from the config (check configFile command) and calculate how many magz you can put into the cargo with remaining space.
My homies. It was just a simple question and answer. He's probably gonna run it one time and be done lol.
setUserMFDText has global or local effect ?

thank you guys for all the help honestly
this is way more than i would expect out of other communities, you guys rock!
GUI is 99.9% local
but you can test it anyway
Dedicated server scripters.. question for you. How do you test the performance impact of scripts? I've been trying but I still end up with performance issues sometimes from my community. Is there something like autotesting ?
(yes, this was because of the waitUntil part of my bomb script
)
I've did a session with 4 people, and it was fine. But last night 20 people connected was.. different π
I doubt this is local. MFD is more like an animation, it's meant to be global. But yeah, i'm gonna test it
That bomb script performance impact should be a drop in an ocean
Unless you messed something up majorly
In general FPS in arma declines with amount of players
hmm.. Then I need to investigate it more. I removed the waitUntil part and embedded 1 part in the part where it checks the code. And ran the fail task within a !alive trigger in the editor. But if it's just a drop in an ocean I have no idea what else can be the cause of our significant drops. Used GRAD Civilians, but turned that off and restarted the server, but FPS was dropping over time anyway. Figured it would be that.
If that's still the same script you posted before, it should not matter at all
Not even if it checks every frame?
0 spawn {
waitUntil {caseBomb getVariable ["DEFUSED", false]};
if(isServer) then {
// This is global so have only server change the task state
["Task_Defuse", "Succeeded"] call BIS_fnc_taskSetState;
};
sleep 2;
casebomb removeAction caseBombActionID;
};```
That's why people do
waitUntil {sleep 0.1; condition};
Ctrl+F'ed enableReload, what the hell is that? Prevents AI from reloading, but players don't care?
Yea, I was either going to change the waitUntil to the above.. or omit it completely. Still, is there a way to test performance or find a culprit script to make sure this doesn't happen on a bigger playsession?
Where do you have performance issues? Clients? Server? How did you figure you have these issues at all?
Last night, when we ran the mission for the community (+- 20 players) the frames kept dropping from 50fps to 5fps in a span of lets say 30 minutes. Every player was reporting the same issue. To a point of unplayability and we had to abort the mission because of it. We didn't encounter these issues the week before, with the same map, loadouts, amount of players but without the 3 scripts we were running and without GRAD civilians loading in civilians for ambience.
We turned off GRAD Civilians off in CBA settings, repacked the mission and ran it once again hoping that would've been the issue, but then the same thing happened.
No way these waitUntils can cause that
You probably can have 100 of them and it won't make a difference
is there any way to test any of the other 2 scripts to see if they are the culprit?
Post the scripts, I could say what could go wrong
This sudden FPS drop sounds like RPT error spam issue
Something errors out and spams RPT non-stop and disk writing tanks the FPS
for "_i" from 1 to 1000 do {
0 spawn {
waitUntil {player getVariable ["DEFUSED", false]};
};
};
```1000 never ending threads spawned with 0 delays, FPS went from 200 to 180 on empty mission
Honestly surprised it even dropped this much π€
I'll post them in a pastebin to save some space in here
Is this a script that spawns the same thing a 1000 times? Just to get my head around it?
You can also do this (increasing FPS drop over time) by doing unscheduled iteration on an array that continually increases in size and is never cleaned up
Ask me how I know
It shouldn't.
The scheduler asks once. And if it suspends it won't try till next frame
But that difference probably doesn't exceed the 3ms script limit right?
It would probably run all these waitUntils in a frame. So a thousand getVariables
Huh, interesting, I'm pretty sure I was testing this before and it did the check many times a frame π€
Maybe it was while instead or something, don't do much scheduled scripts nowadays
Yeah while would
If you do 10000 threads it tanks FPS from 200 to 20, so more than 3ms for sure
While without sleep is deadly.
Because it will run it till the 3ms limit.
Once it enters such a loop, all other scheduled scripts after that one, won't get a chance to run this frame and game happily wastes it's time running that loop that probably does nothing
(no chance to fix that btw?)
Should it even be fixed? Sounds like proper behaviour and makes it distinct from waitUntil
Yeah, like you'll get the same with some other 'more mature' languages like python. Just know what you're doing
Ok, so here are the pastebins for all the scripts that I've ran yesterday, that are related to the scripts (so no CBA settings, onPlayerKilled.sqf etc)
Init.sqf: https://pastebin.com/zZu1iVgb
Tracker script: https://pastebin.com/FpbZ0X3t
SpawnInformant: https://pastebin.com/RyqgHwG0
Bomb scripts all together: https://pastebin.com/bkD9aequ
Use < > around a link to suppress the preview card
Where are search and defuse action scripts?
I apologies in advance for the terrriiiible shit you're about to see :p
As in, where in the file structure?
script contents
the ACRE stuff has been there for ages, always ran those. They set our radios to the correct naming instead of frequencies.
The sorting of scripts is somewhat inefficient.
I might take a look at it but I'd expect it doesn't happen so much
It's in the last pastebin, searchAction.sqf is listed from line 42 and defuse is done in fn_codeCompare.sqf on line 13
If this is improved, bad scripts could start spawning 10000 threads instead of 1000 before anyone noticed FPS tanking π
"DEFUSE\defuseAction.sqf" what's there?

createDialog "KeypadDefuse";
yea.. thats what I'm thinking now as well. wtf
player addAction ["Action", {systemChat "action!"}];
its A3 thing, your script is probably from back in the day
It is, 2014 :p
yeah the while no, that works as inetnded.
But shit would still stink
That's why I intend to make this my project to understand scripting. Seems like a good one to fix
Unless you have something very bad in that dialog I don't see any issues with your scripts
Gonna take a bit longer to notice the smell
I can share the .hpp if you'd like.
1 per frame at max speed
This command will loop and call the code inside {} mostly every frame, depends on complexity of the condition and the overall engine load, until the code returns true
No other scripts but that display config?
Also check RPT after FPS tanks
Sudden drops sound like error spam
Yeah I guess I had many times per frame scheduled checks with while instead of waitUntil
also keep in mind Scheduler has overhead
when it switches between the threads it eats performance even if your scripts have zero payload
BIS' OldMan is a good example of performance degradation
related to spawning thousands of spawned scripts
and HIG too (AI cannot see through the grass mod)
FSMs also affect performance badly because they are executed in unscheduled environment
it means if you have a lot of AI they will blow your server up
teh reason why ppl try to move AI away from the Dedi to the Headless Client(s)
That massive performance degradation is not related to single waitUntil even if it doesn't have a sleep.
As a test you can turn eveything off, even disable CBA and test empty map
So, when looking at the RPTs .. I have 3 messages that come up very frequently.. with this one being the majority.
12:31:05 Server: Object 6:21 not found (message Type_463) <-- this one has multiple variations with numbers
then:
12:11:08 Setting invalid pitch 0.0000 for B Bravo 1-1:23 REMOTE
12:29:46 Server: Network message 1151ff4 is pending T_465
When i search the first one on google, I often see "Don't worry about them.."
These are usual errors, yes
The last one, I understand.. it's because of the server setting and actually the server is overloaded with messages
ah yes I meant waitUntil
while is fine π
Session 1: 1.4mb
Session 2: 2.4mb
Bet the engine iterates through all threads even when not executing any of them, so you get performance impact just from the numbers of threads and all the memory accessing required
Only 5 that pop up.
10:27:05 Error in expression <HitEngine> Or a variation of it.
exactly, this is what I was talking about. Back in the days I was fixing HIG and faced with 20k+ of spawned threads bricking my FPS completely.
I'm a bit suspicious of that beeping sound creator tbh, I know you've got that max in there which should be a safety, but I've seen in the past a case where something doing proximity-based frequency of playSound3D got out of control and annihilated the server. Wasn't my mission so I don't know exactly where it went wrong though unfortunately.
Which one is this exactly?
^
Here we go
I don't remember π
Nothing that could break here
Would this already be happening even if the sound isn't going off? It's set to be picked up mid-mission on an objective.. not earlier.
It prevents reloading when mag is empty I think?
Didn't test with AI but it does nothing for player or player controlled turrets
Was looking for a way to stop player from reloading without magazine deletions
well
the problem can be anywhere, ACE, ACRE...
As I understand the FPS loss scales with the number of the players, so it is something related to their interaction
You could try something like
https://community.bistudio.com/wiki/logEntities
to see if something somewhere spams objects
Maybe a player joins with a mod you don't know about and breaks everything for everyone
We don't allow clientside mods though.
So that has to be a server mod as well then.
Its worth testing it out without the tracker script. To make sure it's not the thing Katushka said
Btw, how do you call your bombTimer script?
Jim
On trigger activate once a player steps into via _null = [caseBomb, 300] spawn COB_fnc_bombTimer;
Post exact trigger setup
make new monitor script, something like this:
if (isServer) then
{
while {true} do
{
{
diag_log _x;
} forEach
[
format ["[BEAR_TEST] diag_frameNo: %1", diag_frameNo],
format ["[BEAR_TEST] diag_fps: %1", diag_fps],
format ["[BEAR_TEST] allMissionObjects: %1", count allMissionObject ""],
format ["[BEAR_TEST] holders: %1", (count (allMissionObjects "GroundWeaponHolder")) + (count (allMissionObjects "WeaponHolderSimulated"))],
format ["[BEAR_TEST] diag_fps: %1", allUnits],
format ["[BEAR_TEST] diag_fps: %1", allGroups]
];
sleep 2;
};
};
etc
you need to monitor these vars:
private _activeScripts = diag_activeScripts;
count allUnits, count allGroups, count vehicles, count allDead, count allDeadMen, count agents, _activeScripts select 0, _activeScripts select 1, _activeScripts select 2, _activeScripts select 3, _diagFPS toFixed 1
allMissionObjects during gameplay is a bad idea, guaranteed micro freeze
yes I know, but in debug session it's acceptable IMO
Perhaps. Running that logEntities after FPS tanks could be useful too
Trigger setup:
I guess for the logEntities to be succesfull I'll have to play through it and make it happen, if it even does.
also if you have debug console you may.... ehm π
Hmm, looks alright except that bomb timer is local and each player will have their own 300 seconds
you can make surgery on the fly on the server side π
I don't use editor triggers much to say if this one could go wrong or run player count ^ 2 times
just to be aware: this trigger was not activated when FPS dropped.
remove all EachFrame EHs via debug console for the server
if (isServer) then
{
removeAllMissionEventHandlers "EachFrame";
onEachFrame {};
};
It will break the mission completely but you have to check FPS
right after executing
I'll run the dedi server and do that. one sec
It gives me some gain, not much though. Maybe 8 to 10 fps.
hm
how much FPS did you have before executing the script?
8-10 FPS if you had 40 is a lot
What I might do, is restart the server and start from scratch. Run 3 instances while I need to go to a meeting.. letting it run for a couple hours. And then do the logEntities. To see what it has. Just so it's running for a while.
I started with 70. Did a couple of the things the players did last night.. dropped to 58 and then after the script 65/68
Okay. Just keep in mind probably the FPS loss scales with the number of the players and it's related to EachFrame EH somehow
maybe yes maybe no
yea.. I currently have no other way of testing it with large numbers I guess
Tell my girlfriend I need her PC for a couple hours :p
Is there absolutely no way to tell if remote unit is being remote controlled by player?
remoteControlled only works where remote controlling player is local
Maybe you could setVariable ["TAG_remoteControlledBy",player,true] when giving remote control over the unit?
Yeah, guess I gotta start tracking that with scripting
@meager granite
(unit in allPlayers) ?
or playableUnits
also cameraOn may help
nvm it's local
focusOn introduced in 2.16 but I never tried it. Probably also local and doesn't meet your requirements.
isPlayer (global)
so if unit is not in playableUnits or allPlayers but isPlayer - it's probably under control of some player?
need to test π
isPlayer returns false for remote controlled units
I see that ace_fire_fnc_burn no longer exists in the repository - how do I go on about adding fire damage to units? Is it now standardized to ace_medical_fnc_addDamageToUnit?
So, I tried this. Logged it all after running it 3 hours. with 6 people on and having a good time with flying etc.. Put the lines in google sheets to see if anything is being spammed.. but no π¦ so that's also not a thing. Maybe it was a freak accident, but no way of telling in this
Do the performance problems always correspond with the network message pending warnings?
We had this issue once before, so I can check. But this was the first time we ever had to cancel a mission. So I can't confirm nor deny that
Network message pending is pretty bad IME. Can be caused by excessive publicVariable spam or similar. Not sure exactly what it means though.
It can also happen (and destroy the server) if a particular client has a really bad connection
high packet loss > lots of guaranteed messages failing to complete ("pending" until they finally get through) > server go crunch
But I think,. based on the conversation from earlier is that there is not really any spam like this happening. Or am I mistaken ?
Not sure I saw any relevant evidence.
Evidence of spam you mean? Or to say clearly that there is no public variable spam.
Could still be something within the editor no? That is not linked to the scripts.
Is there a way to prevent Zeus Virtual entities from triggering the Dynamic Simulation wake up?
I never tried this, but you could try using
_this triggerDynamicSimulation false;
In theory this should stop the unit from triggering the Dynamic Simulation
Quick one, Is it possible for gun pods to have ballisticsComputer as one of their variables and for it to work? Looking to implement some goofy stuff on jets pylons
i have a problem if i run the following in debug consol the code does not work (does not toggle between single and fullauto mode):
0 spawn
{
disableSerialization;
waituntil {!isnull (finddisplay 46)};
(findDisplay 46) displayAddEventHandler ["KeyUp",
{
params ["_display", "_key", "_shift", "_ctrl", "_alt"];
if (_key == 33) then // 'F' key
{
if (currentWeaponMode player == "Single") then
{
player selectWeapon [currentWeapon player, currentWeapon player, "FullAuto"];
hint "switched to fullAuto-Mode";
}
else
{
player selectWeapon [currentWeapon player, currentWeapon player, "Single"];
hint "switched to single-Mode";
};
};
}];
};
however if i run the below without the keyUp eventhandler it works:
if (currentWeaponMode player == "Single") then
{
player selectWeapon [currentWeapon player, currentWeapon player, "FullAuto"];
hint "switched to fullAuto-Mode";
}
else
{
player selectWeapon [currentWeapon player, currentWeapon player, "Single"];
hint "switched to single-Mode";
};
it works for me
okay weird i solved it now like this:
0 spawn
{
disableSerialization;
waituntil {!isnull (finddisplay 46)};
(findDisplay 46) displayAddEventHandler ["KeyUp",
{
params ["_display", "_key", "_shift", "_ctrl", "_alt"];
if (_key == 33) then
{
if (currentWeaponMode player == "Single") then
{
player selectWeapon [currentWeapon player, currentWeapon player, "FullAuto"];
hint "switched to fullAuto-Mode";
}
else
{
if (currentWeaponMode player == "FullAuto") then
{
player selectWeapon [currentWeapon player, currentWeapon player, "Single"];
hint "switched to single-Mode";
};
};
};
}];
};
just a note i have created a top down camera and that's why the keybinds are not working so i must add them manually:(sorry for confusing)
if you need switch it is better to use switch
as for the key binds, F is strafe right for me π I play ESDF as Rapha.
ah okay i guess i will change it to
addUserActionEventHandler ["nextWeapon", "Deactivate",{..
switch (currentWeaponMode player) do
{
case "Single":
{
};
case "FullAuto":
{
};
};```
Will this also work for ai units? Like ```sqf
switch (currentWeaponMode _unit) do {
if (hasInterface) then
{
this addAction [
"Take Sample",
{ [_this, "action"] spawn BIS_fnc_initIntelObject },
[],
10,
true,
true,
"",
"isPlayer _this && { _this distance _target < 10 } &&
{ (side group _this) in (_target getVariable ['RscAttributeOwners', [west, east, resistance, civilian]]) }",
5
];
};
I'm using this as part of an intel item script. I need to modify this to also include a function for deleting a unit. The unit is different from the intel item.
I'm unsure as to where I should insert the deleteVehicleCrew function, or if it would be possible to add it into this same addAction function.
Or rather than deleteVehicleCrew, using setDamage.
Is it possible to have two different scripts as part of the same action added by addAction?
Managed to come up with a solution myself.
if (hasInterface) then
{
this addAction [
"Take Sample",
{ testTarget1 setDamage 1;
[_this, "action"] spawn BIS_fnc_initIntelObject;
},
[],
10,
true,
true,
"",
"isPlayer _this && { _this distance _target < 10 } &&
{ (side group _this) in (_target getVariable ['RscAttributeOwners', [west, east, resistance, civilian]]) }",
5
];
};
testTarget1 just being the placeholder for whatever name given to a unit. Will work if unit in question has 'show model' turned off, and simulation disabled.
yes it will
I still need help!
Is there a way to detect if an ai unit is aiming down sights and force it to fire from the hip?
They don't have such state
@spring stone check the arguments for removeAction
it takes <object> removeAction <id>
so try [objectName, ID1] remoteExec ... -
Ahhh okay, I'll try thatso in front of the remote exec I put every argument in chronological order? (Just so I finally understand remoteExec)
afaik yes
ahhh that makes it easier to work with it! :3 thanks!
i wonder why the player in OnUserSelectedPlayer is sometimes null?
If you read the notes for 2.18 it probably can.
hmm ok thx i read that but didnt know it meant null players
Just a guess tho 
i thought the event fires once it has found non-null player π
somehow missed this from the wiki: "From Arma 3 v2.18 the server will pospone this event until the object is not null"
so they are going to change its behaviour
Set rendering distance. Setting view distance to >= 0 resets the value to the client's options (set in Options β Video β General β Visibility β Overall).``` Seems like a typo in the wiki ``setViewDistance``
yea it seems to contradict what the page says under the syntax: "a negative value resets the view distance to user video setting"
A simple >=0 to be changed to <=0
or < 0
negative value resets, like -1 for example. i dont know about zero
how do i make this to only activate by a specific classname?
player addEventHandler["Dammaged",{
if (typeof _x isEqualTo "O_Soldier_A_F") then { hint "hit";};
}];
looks like you already are checking that but _x may not be valid there
replace _x with _this select 0
player addEventHandler["Dammaged",{
if (typeof (_this select 0) isEqualTo "O_Soldier_A_F") then { hint "hit";};
}];```
didnt work :/
does the "Dammaged" handler exist?
yes, it works on all units attacking player, but i cant make it only specific classname
i have a scenario where there are roaming tiger units, if a player is attacked by a tiger it runs a bleeding script
These are the parameters inside the eventHandler - params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
player addEventHandler["Dammaged",{
params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
if (typeof _unit isEqualTo "O_Soldier_A_F") then { hint "hit";};
}];
i tried _unit, but let me try again maybe i missed something
why dont u run sqf hint typeOf _unit and see what it prints
no results so far
have you checked if the event handler works without checking the class name?
yep like this it works
player addEventHandler ["Dammaged", {
hint "hit";
}];
ok then try to get the classname inside - sqf player addEventHandler["Dammaged",{ params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"]; hint format ["Classname: %1", typeOf _unit]; }];
Hello chaps, why can't I remove the GPS from the player in a SP mission. It keeps reappearing at launch despite removing it from the inventory and running
this UnlinkItem "ItemGPS"; Any idea ?
are you running that in the unit init?
Are you using a custom (modded) unit?
Its a DLC unit (SPE) with some modded items
Screenshot
5 seconds in the items repop back into his inventory at mission start
Likely because a Mod is doing it
i got it, just had to change _unit to _shooter, haha..... thanks for help
Would listing the remove item in the InitLocalPlayer.sqf be the way?
Mhhh doesn't work in my case. Is it still, that I give my addaction an ID like this:
ID = [arguments] remoteExec ..... ?
no just delay removal
Or remove the faulty Mod/script
I added a trigger 5 seconds into the mission with the necessary removal sqf - Nuked the bugger! No Gps in 1944!
again its odd that a mod would purposfully add a gps to players
but I guess mods are weird sometimes
most likely the ID won't correspond with the action id on the client if you target more than 1 machine with the remoteExec
Had anyone encountered this bizzare problem, where on dedicated server initPlayerLocal.sqf would not launch at all? Tested locally and it does work as intended. Also it was working previously and I did no significant changes to the code yet it seems like it does not launch at all. Even added a diag_log at the very beginning of it and there is not trace of it in RPT file. Like the file is skipped
Added waitUntill as well, that's basically 1-st two lines of the code
waitUntil {local player && {getClientStateNumber > 8}};```
is it in the right folder (root)? checked the name?
wait its not supposed to be launched in dedi, only on client
Yes, but it does not launch at all which is weird as it did a version or two back. I'm pretty sure file is where it's supposed to be and I don't see any errors. File should launch as player inits on server yet it seems to be completely ignored. Also tested the scripts that are supposed to fire via this file and they all work fine.
are you checking the logs in right place? diag_log in this case would log to the client machines log file
AAaaaah, okay I totally didn't think of that
So I should use the actual ID? (0,1,2,3....) (This is most likely the last thing that needs to be done to have my script functional T^T)
Thanks gencoder8, learned something new today, I'll investigate RPTs and eventually I'll figure it out I hope
Ace maybe ? Its weird I just updated the mission on steam and play tested it and the damn GPS is back ...
its probably not ace
but if you re using a 3cb units they sometimes load in to the misison with the prebuilt loadouts
But that's the thing - the mission starts fine and then boom it appears ...
If using 3CB, donβt use 3CB units when doing custom loadouts, either for player or for enemy unifs. The randomization will sometimes just nullify what you want.
can you use switch to run cases against distance checks as mentioned in example 4? I'm trying to use switch to run based on the distance between the unit and an object.
You can use switch to run checks against anything that evaluates to a bool:
switch true do {
case ((_obj distance _unit) < 10) : {
aight cool thanks
Any way to forbid an unit from going prone? Or to enforce a specific stance? I did some digging, but only found a way to check the stance
@silent comet https://community.bistudio.com/wiki/setUnitPos
is it possible to detect when music ends? at the start of my mission i have it play some intro music which lasts for about 2 mins. is there any way besides using sleep to play some ambient sounds directly after the intro music ends?
if (hasInterface == true) then {
_intro = 0 spawn {
playMusic "FalklandsSongIntro";
100 cutText ["<t color='#ff0000' size='5'>East Falkland Islands, 1982</t><br/><t size = '2'>3km North of Goose Green</t>", "BLACK OUT", 1e-6, false, true];
sleep 9;
100 cutText ["<t color='#ff0000' size='5'>East Falkland Islands, 1982</t><br/><t size = '2'>3km North of Goose Green</t>", "BLACK IN", 3, false, true];
sleep 1;
playMusic "FirefightAmbience";
};
};
```i was hoping this would work but it doesnt seem to.
MusicStop event handler
How do I supply default values to params?
how would that look?
params [
["_paramName", defaultValue, ["accepted types, like", 0, [], true]]
];
cool thx mate
addMusicEventHandler ["MusicStop",
{
params ["_music", "_id"];
if (_music == "FalklandsSongIntro") then {
playMusic "...";
removeMusicEventHandler ["MusicStop", _id];
}
}]
If your music is 2 minutes long why do you only sleep for 9 seconds?! 
oh no, the 9 seconds of sleep is for an intro on the screen :) it starts the song and shows an intro and after 9 seconds (when the lyrics kick in) the title fades away
anyway ill try that event handler now, much thanks o7
Is there an invisible dummy object that you can apply BIS_fnc_holdActionAdd to?
Sign_Sphere200cm_Geometry_F remove its texture but don't make it invisible
or uncheck 'Show Model'?
Its shadow Would still be visible
You can use invisible helpers, walls, helipads, (or even a tiny cellphone) since the function can be customized to extend the range at which it can be triggered by a player.
right i cant seem to figure out why this wont work
Description.ext:
class CfgMusic
{
tracks[] = {};
class FalklandsSongIntro
{
name = "Falklands War Song";
sound[] = { "\Sounds\Music\falklands_war_song.ogg", db + 0, 1.0 };
};
class FirefightAmbience
{
name = "Firefight Ambience";
sound[] = { "\Sounds\Ambient\distant_firefight.ogg", db + 0, 1.0 };
};
};
fn_introMusic.sqf:
if (hasInterface == true) then {
_intro = 0 spawn {
playMusic "FalklandsSongIntro";
addMusicEventHandler ["MusicStop",
{
params ["_music", "_id"];
if (_music == "FalklandsSongIntro") then {
playMusic "FirefightAmbience";
removeMusicEventHandler ["MusicStop", _id];
}
}];
100 cutText ["<t color='#ff0000' size='5'>East Falkland Islands, 1982</t><br/><t size = '2'>3km North of Goose Green</t>", "BLACK OUT", 1e-6, false, true];
sleep 9.5;
100 cutText ["<t color='#ff0000' size='5'>East Falkland Islands, 1982</t><br/><t size = '2'>3km North of Goose Green</t>", "BLACK IN", 3, false, true];
};
};
but this doesnt work for whatever reason
What doesn't work?
Unchecking "Show Model" disables collisions, and interactions. Because the object I want players to interact with (a satellite dish) is on top of a building, placing an extra object looks out of place. Sign_Sphere200cm_Geometry_F seems to work. PS Appreciate you taking the time.
Thank you
hi, pls help
I got my addon config.cpp
class CfgPatches
{
class CONAN_UAV
{
name = "CONAN UAV";
author = "CONAN";
url = "";
requiredVersion = 1.60;
requiredAddons[] = {"A3_Functions_F"};
units[] = {};
weapons[] = {};
};
};
class CfgFunctions
{
class CONAN_UAV
{
file = "\CONAN_UAV\Functions";
class preInit { postInit = 1; };
class main_Init {};
class grainFX_Init {};
};
};
and my folders like this
this is my fn_preInit.sqf
//----------------------------------------------------------
diag_log "=================== UAV LOADED ===================";
G_UAV_Action_ID = player addAction ["Drone Support", CONAN_UAV_fnc_main_Init, nil, -99, FALSE, TRUE, "", format ["G_UAV_bCanUse and %1", G_UAV_UseCond]];
G_UAV_Killed_EVH = player addEventHandler ["Killed", {
player removeAction G_UAV_Action_ID;
}];
G_UAV_Respawn_EVH = player addEventHandler ["Respawn", {
G_UAV_Action_ID = player addAction ["Drone Support", CONAN_UAV_fnc_main_Init, nil, -99, FALSE, TRUE, "", format ["G_UAV_bCanUse and %1", G_UAV_UseCond]];
}];
//----------------------------------------------------------
my problem is that, when I go check the rpt file after testing, the line
"=================== UAV LOADED ==================="
is not there...
You're missing a layer in your cfgfunctions
It should go like this:
class cfgFunctions
{
class tag
{
class category
{
class function1 {};
};
};
};```
You're missing either the tag or category layer, depending on how you look at it
thanks : D
class CfgFunctions
{
class CONAN_UAV
{
class CONAN_UAV_scripts
{
file = "\CONAN_UAV\Functions";
class preInit { postInit = 1; };
class main_Init {};
class grainFX_Init {};
};
};
};
this look ok?
Yes, although it makes me very sad that your function is called preInit but runs on postInit
the second music doesnt play after the first one
or well, at all.
You could just call the category layer "scripts" btw, it's already within the CONAN_UAV tag so it won't conflict with any other "scripts" category outside of that
awesome, thank you : D
i have two functions, function 1 creates an object and function 2 is supposed to delete the last created object. how do i do this?
@hallow mortar
pls helpπ₯Ί
I'm getting this
19:49:11 Warning Message: Script \CONAN_UAV\Functions\fn_playerInit.sqf not found
19:49:11 Warning Message: Script \CONAN_UAV\Functions\fn_main_Init.sqf not found
19:49:11 Warning Message: Script \CONAN_UAV\Functions\fn_grainFX_Init.sqf not found
Make sure your pboprefix is correct
u mean like this?
No
...mmmm
I forget how you can check in PBO Manager but IIRC somewhere in Edit
Okay that's pretty wrong
yup... how do I change it?
It does mean your file is recognized as addons\Functions\fn_main_init.sqf
How do you pack PBO
pbo builder from a3 tools
Addon Builder you mean?
OPTIONS > Addon prefix
thank you
use deleteAt
_arr = [1,2,3,4];
_arr deleteAt [-1];
hint _arr;
// Output: 2,3```
I'd suggest using setVariable and getVariable, e.g.
// function1
missionNamespace setVariable ["meth_var_lastCreated",_object,true];
// function2
private _lastCreated = missionNamespace getVariable ["meth_var_lastCreated", objNull];```
(There are a number of possible variations in the exact implementation)
You can't use negative indexes until 2.18
What version are we now π
2.16
ah ok
oh lemme try that thanks
Somehow yes, if it's the first publish
aaah
ok, i'll just let it finish then
ty
No it's already finished
You can confirm in your Workshop, if it's done properly, you can close Publisher safely
yup, they're there... duped... π
Someone help me with the logic:
I want to run a code inside a while loop every 5 seconds using diag_tickTime
did you find the root of the problem?
Why would you use diag_tickTime for that?
Is there a better alternative
sleep is usually fine.
If it's not then you have far too much scheduled shit running.
Theres already an existing code that runs based off of diag_tickTime
That doesn't seem like a good argument.
What's it doing in between diag_tickTime checks anyway? eachFrame or what?
private _acefireFX =
{
private _firePos = getPos _this;
private _endTime = diag_tickTime + 20;
while { diag_tickTime < _endTime } do {
uiSleep 0.5;
{
private _distanceFromTanker = (vehicle _x) distance2D _firePos;
private _unit = _x;
private _burndmg = 0;
switch true do {
case (_distanceFromTanker <= 50) : {_burndmg = 10};
case (_distanceFromTanker <= 75) : {_burndmg = 5};
case (_distanceFromTanker <= 100) : {_burndmg = 3};
case (_distanceFromTanker <= 125) : {_burndmg = 1};
case (_distanceFromTanker <= 150) : {_burndmg = 0.3};
default {_burndmg = 0};
};
[_x, _burndmg] remoteExec ["ace_fire_fnc_burn", _x];
[_x, _burndmg, "Head", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
[_x, _burndmg, "RightLeg", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
[_x, _burndmg, "LeftArm", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
[_x, _burndmg, "Body", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
[_x, _burndmg, "LeftLeg", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
[_x, _burndmg, "RightArm", "burn"] remoteExec ["ace_medical_fnc_addDamageToUnit", _x];
} forEach allUnits;
};
};```
well, that's horrifying
private _future = 0;
while {true} do
{
// Payload. Executes every ~1 second.
// ------------------------
// ...
// ------------------------
if (diag_tickTime >= _future) then
{
_future = diag_tickTime + 5;
// Payload. Executes every ~5 seconds.
// ------------------------
// ...
// ------------------------
};
sleep 1;
};
That's even worse.
wtf? remoteExec ......
This clearly isn't critical code that actually needs to run precisely on 5 seconds, so just sleep 5. And then don't fire off seven remoteExecs to the same client.
whoah that performance hit
its still needs work flushed out yes - im trying to get the core idea down before thinking about performance
sorry I forgot about the sleep π
The core principle for this sort of code is performance. Otherwise you end up with abominations like Bloodlust :P
And yes, that remoteExec on allUnits should not exist
If you need to broadcast shit, it's better to create one function instead of calling it 7 times
switch {true} do replace with call-if-exitWith
best part, it does the full remoteExec spam even if the unit is >150m away.
is it possible to make the checks local?
similar loop but players run it locally for them and their subordinates
That would be a good starting point.
also use ternary operator instead of switch {true} do:
private _burndmg = call
{
if (_distanceFromTanker <= 50) exitWith {10};
if (_distanceFromTanker <= 75) exitWith {5};
0; // default
};
kind of
int x = <condition> ? 10 : 5;
in C++
It sends 7 remoteExecs per unit instead of 1 per machine every 0.5 seconds (WHAOW). And it keeps spamming even there is nothing happening (switch hits default value). If you have 100 units it's 7 * 100 / 0.5 = 1400 remoteExecs per second :)))))) DATS GUD.
@finite bone
I'd recommend you:
-
If it's on the server - call remoteExec ONCE per remote machine to notice clients that they should start the local loop. Process the local to the server units as it's a client.
-
Client should process their local units without spamming to the network. And stop the loop if there is nothing to process. Wait for the server's next remoteExec.
y'all know how to make a delay on a waypoint? for example if a patrol makes it to the waypoint I would want them to wait 40 seconds then take off to the next
I assume its in seconds?
yup
yeah it seems so.
Not with any definite proof. Iβve ran the mission with 6/7 people to test it out, let them roam and do stuff , even dropped a bike at the end and no change. Ran it on my own dedi server with 9 clients open and no changeβ¦ nothing in the logs or anything that indicates it.. so no idea.
So I might just run it again this Thursday and have a backup mission ready without the scripts and civilians module
Somebody mentioned about the memory allocator on the server .. or server settings in general. But no idea what to change on that, or how. The guy that used to do that for us is kinda awol
About server settings, have you disabled 'Object not found' spam? I saw you suffered from it up in the conversation. It's not much in terms of performance, but better than not do it at all.
class AdvancedOptions
{
LogObjectNotFound = false;
};
https://community.bistudio.com/wiki/Arma_3:_Server_Config_File
Iβll do, see if it makes any difference. Thanks.
hmm.. looking into the mission once again.. I've overlooked one error that pops up at initialization.. but not sure if this could be the issue. I have these barrels with m112 explosives attached and used the following to attach them : [this, barrel_5] call BIS_fnc_attachToRelative; but on load, I get [BIS_fnx_attachToRelative] Error: type ANY, expected object, on index 1, in [437691: rhsusf_m112x1_e.p3d,any] as an error that stays there for a second or 2. Could that be it? I got 9 barrels, and 4 explosives attached to it, leading to 36 of them. Is it trying to attach it and not able to because of this error? Overtime making it too many requests for the server?
Something else, I omitted the two functions in the init.sqf that have the waitUntil and embedded them into another part of code. Would this be a better way of doing it?
The task succeeded is now within fn_codeCompare.sqf:
//Parameters
private ["_code", "_inputCode"];
_code = [_this, 0, [], [[]]] call BIS_fnc_param;
_inputCode = [_this, 1, [], [[]]] call BIS_fnc_param;
//compare codes
private "_compare";
_compare = [_code, _inputCode] call BIS_fnc_areEqual;
if (_compare) then {
cutText ["BOMB DEFUSED", "PLAIN DOWN"];
caseBomb setVariable ["DEFUSED", true, true];
if (isServer) then {
["Task_Defuse", "Succeeded"] call BIS_fnc_taskSetState; ///The task success code is now here
};
casebomb removeAction caseBombActionID; ///The removal of the action to not be able to defuse again is now partly here
} else {
cutText ["BOMB ARMED", "PLAIN DOWN"];
caseBomb setVariable ["ARMED", true, true];
playSound "button_wrong";
casebomb removeAction caseBombActionID;
};
CODEINPUT = [];
//Return Value
_code```
The task fail is now set on a trigger with a `!alive caseBomb;` condition, same trigger that terminates the tracker script
Is there any way to detect that Zeus has an item selected from the list but has not yet placed it?
"curatorSelected" command works for already-placed
but not sure how to detect that Zeus has an object selected (but not yet spawned)
Hello,
I'd like to know whether the change in the flow of time (see at the top left of the recording : https://youtu.be/u3MgSYcBTq0 ) is due to the execution of a command to change the wind strength (e.g. https://community.bistudio.com/wiki/setWind ).
Or is it due to the following command: https://community.bistudio.com/wiki/setTimeMultiplier
thanks
Could be setTimeMultiplier but also scripted continous skipTime
barrel_5 is undefined. Are you sure the name of the variable is correct in that script? Even with that script error it should not impact so badly. It's definitely something else. Next time try to dump everything related to the perfomance / resources. count all objects, vehicles, scripts running, units. As a test at the very end of the mission when the objectives will be finished, delete all vehicles from the map, remove EachFrame handlers. It will f..k the mission up but you can measure the FPS.
This is all done in the editor, not by script. I really have a feeling it's something super small we're missing and it has a major impact. My plan for this coming thursday is to have at least a backup mission without any of the scripts (unfortunately) and let Zeus handle it :/
barell_5 is a name of the object. Literally your barell's name. Probably it's barell5 or something else. Make sure it's actually barell_5 π
I will check all the barrels again because I have barrel 1 to 9 with 4 explosives on them. Just making sure. Otherwise I'll get rid of them, it's just ambience anyway and I can use just barrels.
I'm not 100% sure if your object defined AFTER the init code referring to it executed the game probably will throw an error. Gonna check right now.
But it's kinda lame...
fortunatelly it works fine:
2 objects were placed in the editor rock_1 and rock_2
// rock_1 init field
diag_log (format ["[rock_1] rock_1: %1 | rock_2: %2 | this: %3", rock_1, rock_2, this]);
// rock_2 init field
diag_log (format ["[rock_2] rock_1: %1 | rock_2: %2 | this: %3", rock_1, rock_2, this]);
.RPT
9:37:32 "[rock_1] rock_1: rock_1 | rock_2: rock_2 | this: rock_1"
9:37:32 "[rock_2] rock_1: rock_1 | rock_2: rock_2 | this: rock_2"
Seems good. rock_1 init field code reffers to rock_2 (and vice versa) which is defined AFTER rock_1. But the things didn't mess, so the game inits object variables before the init scripts are executed.
False alarm.
so, you have to ensure the barrels are named correctly. Anyway it's minor issue. Probably it may be not related to your mission but to some other addon like ACE, ACRE, CBA or even to the game engine.
I know ACE had an update the day before our mission. Not sure if that had any impact on it. I made the mission pre-update. I doubt it.. but at this point Iβm second guessing everything π
while {true} do {uiSleep 5; your_code_here};
anyone know how I could make a rally point system? squad leader drops his backpack (or some sort of item) and players can spawn on it?
how would i combine two keys? im doing the below but it does not work: (pressing W and D key at the same time to play the action)
0 spawn
{
disableSerialization;
waituntil {!isnull (finddisplay 46)};
(findDisplay 46) displayAddEventHandler ["KeyDown",
{
_this spawn
{
params ["_display", "_key", "_shift", "_ctrl", "_alt"];
if (_key == 17 && _key == 32) then
{
player playActionNow "SlowRF";
};
};
}];
};
You could check what that return when you are pressing those buttons.
waitUntil {!isNull(findDisplay 46)};
(findDisplay 46) displaySetEventHandler ["KeyDown",{
systemChat str _this;
}];
_key cant be two keys at the same time
so how would I combine them?
Does anyone know an easy way to open 3DEN-like vehicle customization (color and 'visible parts' selection) ?
hmm cant think of simple way , you probably need to use variables and store the key states to it
and you need keyUp EH too
which keys you need to check?
if W and D keys are pressed
W & D
oh sorry i forgot x)
That's what I thought, but I still wanted to ask, maybe there was an easier way
What I can think of is something like
- EventHandler for KeyDown - add key to your global array, call your script that would check that array contains what you are expecting and run logic if that is the case
- EventHandler for KeyUp - remove key from array
No need for spawn and etc. Just two event handlers
u need something like flag register for the keys and check the register each time the keydown/up fired
Yeah
Paradox was asking how to detect if these two keys are pressed (so he can run animation/ action on player)
- keyDown fired on key1
- add DIK to the array
- check if we have to process the key register
- keyDown fired on key2
- add DIK to the array
- check if we have to process the key register. Yes if combo found
- key1 is up - remove the DIK from the register
oh it was another person
add key to the array and check the combo each time the key pressed
currentlyPressedKeys = [];
// keywDown EH:
// ----------------
if !(_key in currentlyPressedKeys) then
{
currentlyPressedKeys pushBack _key;
};
if ((DIK_W in currentlyPressedKeys) && (DIK_D in currentlyPressedKeys)) then
{
// Your code
};
// ----------------
// keyUp EH
// ----------------
currentlyPressedKeys = currentlyPressedKeys - [_key];
// ----------------
You can go even further using hash maps or array with preallocated elements and save the performance because you don't need to reallocate memory for currentlyPressedKeys each time the key released.
you can use global vars for your keys
keyStatus_W = false;
keyStatus_D = false;
// keyDown EH
// ----------------
switch (_key) do
{
case DIK_W: {keyStatus_W = true;};
case DIK_D: {keyStatus_D = true;};
};
if (keyStatus_W && keyStatus_D ) then
{
// Your code
};
// ----------------
// keyUp EH
// ----------------
switch (_key) do
{
case DIK_W: {keyStatus_W = false;};
case DIK_D: {keyStatus_D = false;};
};
// ----------------
But I prefer to use registry, it's faster and more convenient. In this case DIK code can be a key or index in the registry. For example:
pressedKeys = [false, false, false, false,...];
...
// DIK_K is a key code and the index at the same time
pressedKeys set [DIK_K, true]; // Manage the element in the down and up EHs
...
if ((pressedKeys select DIK_K) && (pressedKeys select DIK_M)) then
{
// Do something if K and M are down
};
With such technique you can make almost unlimited key combos like Q+A+U+T+7+N+F6+SHIFT+PgDn+ESC+ENTER
also this may help
https://community.bistudio.com/wiki/inputAction
Personally I found hard coding the keys is pretty annoying thing.
thank you for your effort
in this case i need to hard code it because it is a top down view created with camCreate and there is no other way to move the player:
Anyone know how to execute code after countdown completion?
How are you made your countdown?
bis function, but I think I figured it out, just gotta test it now. I am using trg1 = true in the command line of a laptop that the players have to hack to assign the task and set the trigger countdown to the same as the bis function
well that didn't work... how do I execute a trigger with a script?
Let's rebuild this idea to get away from that poo poo function and triggers all together.
So you want a countdown that starts when a player uses a laptop action?
no, I did that already, I want a task to be assigned after said countdown ends
Since you know when the countdown ends, use the task function directly in your code. No need to have a trigger checking something all the time.
Use any of the applicable functions here:
ah, gotchu, thx
General thing is if you know exactly when something happens, you shouldn't spend resources waiting for it to happen, just make it happen.
ok
Is there some established way to make a function wait until a spawned function gives a return? I don't want to use call as I need to use sleeps.
I tried using scriptDone, but then it turns the variable that was supposed to be the result of the spawned function into a script handle.
Basically I want to suspend the execution of a function until a spawned function finishes.
Wait, if I use spawn instead of call then I do not get the result back?
Like _thingy = ["derp"] spawn taro_fnc_doTheThing , I thought that _thingy would be the result of the function, but it seems if you use spawn it becomes a script handle.
It sounds like you should spawn your function
You can use sleep in a called script
As long as you call from a scheduled script
0 spawn {
_result = call {
sleep 3;
1;
};
systemChat str _result
}
Well yeah, but how do I get a result of the spawned function as it appears if you spawn then what would be result becomes a script handle.
@little raptor I thought about doing that, but how do I get the result out of that spawned function. I can't do it all inline as I have rather extensive functions that require spawn.
If your script is not scheduled, you can chain the calls:
_stuff spawn {
sleep 3;
[_stuff, 1] call nextScript; // pass the result and other stuff to the next script
}
Where does everything start? (And how)
e.g. from an event handler, init field, etc.
The whole thing I'm making is a base network generation. Just calling a function, it's not something that is run often, but it relies on different function that does a position search and that one hangs the whole game when it tries to find a position. I wanted to introduce a sleep every few attempts at finding the position to offload the scripting. The whole thing does not need finish as fast as possible.
If timing is not important, you can spawn that slow function, and pass its result, plus extra args (e.g. local vars that are needed to continue execution) to another function that continues the job like I showed in an example above
// Slow fnc
params ["_args", "_nextFnc"];
_result = ... // Do some slow thing;
_args pushBack _result;
_args call _nextFnc; // pass the result, and the args to the next function
Which you execute like this:
[[1,2,3], my_fnc_next] spawn slowFnc
that's a more general way of doing it.
if the next function is always my_fnc_next, you don't need to pass it
The way I have it set up now is like this:
//this is a generate site function
//doing stuff
_siteLocation = [_area,_excludedAreas,_inclusionAreas,_condition] call taro_baseNetwork_fnc_findSitePosInArea;
//do stuff with the site location we got from the findSitePosInArea function
findSitePosInArea function is quite heavy and this is the one I want to introduce some sleeps to keep the game going.
Problem is if I switch to spawn instead of a call then _siteLocation seems to become a script handle.
I could edit the findSitePosInArea function so it spawns and inline function, as long as I can get it to return data into the generate site function, into the _siteLocation variable.
What I showed here is perfectly applicable to your code
But I recommend just doing it this way
i.e. spawn this very code
you no longer have to do weird stuff
0 spawn {
//this is a generate site function
//doing stuff
_siteLocation = [_area,_excludedAreas,_inclusionAreas,_condition] call taro_baseNetwork_fnc_findSitePosInArea;
//do stuff with the site location we got from the findSitePosInArea function
}
anyone got a script where it auto refuels / rearms / repairs any type of vehicle that gets inside of a trigger with just putting the script into the on activation area
Even if this function is part of another series of codes, all that matters is that you start this by a spawn, and everything else can be call
capture keys and check inputAction instead of _key
it's just non-sense for the thread to have return value.
thread returns its handle when spawned
you never know when the thread will end so it's pointless to stop the execution of the parent instance and wait until the thread dies
Hell'O
it's better to ask in dedicated BE channel
https://discord.com/channels/105462288051380224/107123316912844800
Is there any way to allow players to toggle Grass on / off without effecting terrain quality viasetTerrainGrid? I know that I can strip the grass from the map in CfgSurfaceCharacters, but that would apply globally to all players. I'd like to provide an option for players to choose if they want grass or not while keeping setTerrainGrid = 3.125 so there are no abuses of deformed terrain...Is there any way to do that?
have you tried the grass cutter objects?
I'm aware of them, but I mean more-so map-wide. Like we are both playing the same map, but you have grass on, and I don't, but we both have our terrain quality set to ultra.
ok
There are low-grass mods that I think adjust the grass models. I don't think there's any way to do it through script.
I have a question
I have something that has a light behind it and I want it that when it dies the light to be deleted will this work
_light attachTo [this, [0, -3, 0]];
_light setLightColor [1, 0.54, 0.1];
_light setLightAmbient [1, 0.54, 0.1];
_light setLightUseFlare true;
_light setLightFlareSize 8;
_light setLightFlareMaxDistance 3000;
_light setLightBrightness 1000;
_light setLightIntensity 90;
_light setLightDayLight true;
this addEventHandler ["Killed", { params ["_unit","_light"]; deletevehicle _light;}];```
No. _light doesn't exist in the event handler context. You'd need to do something like this instead:
private _light = "#lightpoint" createVehicleLocal [0, 0, 0];
this setVariable ["mymodtag_attachedLight", _light];
// other shit goes here
this addEventHandler ["Killed", {
params ["_unit"];
private _light = _unit getVariable ["mymodtag_attachedLight", objNull];
deletevehicle _light;
}];
Is it possible to make an object ignore the wind when being dropped via a cargo parachute?
Doesn't seem to work when I change the weather through Zeus
Tried it on both the parachute and the crate itself
Will test it out tomorrow, thanks o7
Hi I tried to spawn an item at a waypoint and I get this error will post code
private _veh = createvehicle [_pos ,"pook_SCUD_nuke_spawner"];```
"this" is supposed to be the waypoint
that syntax of createvehicle takes the class name first, then position
oh
I'm trying to move some of the bombscript outside the trigger, and into scripts. And making sure everyone has the same timer, as it was mentioned before. But I'm not getting it working on dedicated.
This was what was in the trigger before:
[ west, ["Task_Defuse"], ["Find the code and defuse the bomb before it explodes.", "Defuse the bomb", "DEFUSE"], objNull, FALSE ] call BIS_fnc_taskCreate;
[ west, ["Task_Secure"], ["Secure the SCUD launcher and bring it back to FOB Sentinel Ridge for proper disposal", "Secure CBRN SCUD Vehicle", "SECURE"], objNull, FALSE ] call BIS_fnc_taskCreate;
_null = [caseBomb, 300] spawn COB_fnc_bombTimer;
And I've moved it now to init.sqf. Since I saw that _null = is a relic code.. I thought that was the fact it's not showing up, but no bueno. It's working on MP within Editor.
0 spawn {
waitUntil {sleep 1; triggerActivated bombTimer};
if (isServer) then {
[ west, ["Task_Defuse"], ["Find the code and defuse the bomb before it explodes.", "Defuse the bomb", "DEFUSE"], objNull, FALSE ] call BIS_fnc_taskCreate;
[ west, ["Task_Secure"], ["Secure the SCUD launcher and bring it back to FOB Sentinel Ridge for proper disposal", "Secure CBRN SCUD Vehicle", "SECURE"], objNull, FALSE ] call BIS_fnc_taskCreate;
[caseBomb, 300] spawn COB_fnc_bombTimer;
};
};
fyi: the tasks work, just not the COB_fnc_bombTimer;
I'm guessing I'm forgetting to define caseBomb?
I have a sound effect I want to be heard across the whole-ass map. I know ArmA takes into account things like distance and doppler and changes the sound accordingly. Can I do that with a sound that can be heard over like, 20 kilometers? Or does the sound system break down after a point?
Just make a sound source near the player in the direction of where you "think" it would come from. Or just use a 2d source
You won't hear it otherwise across the map.
Delete and repost here
Roger that. Apologies
Store it somewhere local, like setVariable on a game logic.
But when I load it up on a dedicated server for some reason
_cam2 setPos (asltoagl getPosASL player);
doesn't work
Anyone have any insight on this
I've tested it all on the dedicated server and found that the issue lies in the setDir as it teleports the camera to the player, and then moves it to where it would view the full character but because it never looks at the player
player is not defined on dedi. Well, it's defined as <OBJ-NULL>
you need to be more specify where did you define that code
This gets executed in initplayerlocal in a seperate script.
initplayerlocal
[] call sal_fnc_openDialogCreation;
with sal_fnc_openDialogCreation being the above script
I don't believe it is that I believe it's just the cause of the weird behavior of setDir
It works if I put it in after all the setPosASL but not before which could just be a weird bug with the command, the wiki says defining it after you've done a setPos can lead to wierd behavior
well, you didn't post anything related to setDir behaviour before.
_cam2 setPos (asltoagl getPosASL player);
it's still unclear is setDir working or not. And if it's working, why is it glitching?
The position works but setDir only works if its done like this
_cam2 = "Land_HandyCam_F" createVehicle [0,0,0];
_cam2 enableSimulation false;
_cam2 setPos (asltoagl getPosASL player);
_cam2 setPosASL (getPosASL _cam2 vectorAdd [2, 3 ,1]);
_cam2 setDir (_cam2 getDir player);
switchCamera _cam2;
Which has me confused but I've switched to setVector and I'm about to see if that works better
It worked
createDialog "playerCreation";
_cam2 = "Land_HandyCam_F" createVehicle [0,0,0];
_cam2 enableSimulation false;
_cam2 setPos (asltoagl getPosASL player);
_cam2 setVectorDir [0, -1, 0];
_cam2 setVectorUp [0, 0, 1];
_cam2 setPosASL (getPosASL _cam2 vectorAdd [1.8, 3 ,1]);
switchCamera _cam2;
[] call sal_fnc_determineAP;
Just changed it to this, arma is a funny game.
did you try to use setDir before setting the position?
also setVectorDir and setVectorUp can be combined in setVectorDirAndUp
I did and it gave some weird effect but appreciate the help man
instead, use a camera target and screenToWorld
they don't? what else is going on in your script?
they don't for me. do you have dynamic simulation running or something?
does it happen with a vanilla jet?
al least you made it working. You can use this if you want to use degree instead of vectors
private _angle = 45;
myObject setVectorDir [sin _angle, cos _angle, 0];
// or
#define MYOBJECT_ANGLE 45
myObject setVectorDir [sin MYOBJECT_ANGLE, cos MYOBJECT_ANGLE, 0];
is there any way outside of config to filter specific types/individual of vehicle weapons?
Be specific.
in an if then check if the weapon is fired in a fired eh is an air to ground missile or not that type is simpler than just an if weapon = specified weapon config name then do thing?
it may depend on how it is detected. If you sense the projectile by a handleDamage EH you will have specific information available.
I used something like this in an MPkilled EH a while back:
if ((currentWeapon _killer) in blck_forbidenVehicleGuns) then {do something};
I am not sure if that works if the projectile/missile was fired from a pylon
Hey guys. What would be the most simple way to start one of 3 possible sqfs (that each create 2 tasks in the briefing?) when BLUFOR enters a certain trigger?
you mean like ```sqf
_script = selectRandom ["script1.sqf","script2.sqf","script3.sqf"];
execvm _script;
Is it failing just because the current channel is already 15, and the watches are evaluated constantly?
Nope. Works for every other channel. setCurrentChannel is bugged and doesn't work with custom channel 10
Dude tnx. For dedicated I need this && isServer ?
There's the isDedicated check ( https://community.bistudio.com/wiki/isDedicated )
uhrm .. just some random question comming into my head right now
when could setCurrentChannel fail at all?
only reason i could see when it would fail would be on some disabled channel
When the channel is disabled or the index is out of bound
Or on a custom channel that exists when a unit is not added to it.
setCurrentChannel is also the only way to find out if a channel is enabled.
Loop through all channels and set the original one at the end.
how would i get a specific object that is attached to the player?
attachedObjects player returns every attached object, so how could i check if a specific object is attached to the player by the objects classname?
attachedObjects returns the .p3d file
use typeOf
[c4g2,"SERGEANT"] remoteExec ["setRank",c4g2];
[c4g2,["Keni Thomas","Keni","Thomas"]] remoteExec ["setName",0];
[c4g2, "WhiteHead_06"] remoteExec ["setFace", 0, c4g2];
is this script right?
yes
another way would be to use nearestObjects and then compare it with attachedObject
A very elaborate way but usually typeOf should handle the .p3d files no problem
how do i make my script wait until my squad has left vehicle? i only know ab this one
_incar = true;
while { _incar } do {
if ( ({!(alive _x) || _x in c4 || _x in c5 || _x in c6 } count (units d1)) == count (units d1) ) then {
_incar = false;
};
sleep 2;
};
but idk how to change it for not being in vehicle
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
Array of Objects attached to the given object
it's not .p3d
_filteredObjects = (attachedObjects _object) select {(typeOf _x) == "classname"};
// Wait until count of car crew is 0
waitUntil {sleep 0.5; ((count (crew yourCarName1)) == 0) && (count (crew yourCarName2)) == 0) && (count (crew yourCarName3)) == 0)};
what if i have 3 cars that players are in?
this will work only for passangers right? i got AI driving and AI gunner on it
if you have more cars, it's better to use forEach or apply π
crew works for any unit in the car (including dead)
objectParent is probably more preferable
yea mb, i got 3 jeeps driving then will drop off player and i wanna make when players group leave those 3 vehicles Ai will drive off
{!isNull objectParent _x} count units GROUP == 0
O(2n), counts only alive units, ignores deadmen, AI ignored
waitUntil {sleep 0.5; ({({(alive _x) && {isPlayer _x}} count (crew _x)) > 0} count [car1, car2, car3, ..., carN]) == 0};
yea i need it to count only player group
enjoy
im trying to find nearobjects but make a check to ignore emptydetectors, triggers, and proesses with jip like i have this in my code
private _jipid_attachTo = format [TAG_JIP_attachTo_%1", str(_vehicleinfi)];```
and i am trying to check it with a condition like this
```sqf
if ((typeOf _x != "EmptyDetector") && (str _x not in "TAG_JIP_rocket_attachTo"))``` is this valid or is there a better way?
dont need to do it one liner lol, also sleep .5 is redundant, waituntils has .5 s sleep in it already π
Wiki:
This command will loop and call the code inside {} mostly every frame, depends on complexity of the condition and the overall engine load, until the code returns true
0.5s delay is for the triggers
position nearObjects [typeName, radius] you can specify what you want to grab from near objects, maybe use something generic for your use case?
damn i was sure i read that somewhere, probably was triggers
yea i have the nearobjects array loaded for a loop (hence the _x) and I also know theres a jipfunction created with the name TAG_JIP_attachTo so i want to filter out from the nearObjects array with elements of this
morover even trigger's delay is adjustable with setTriggerInterval 0 - each frame
yea, if you cant use nearentities for this, you will need to filter out, you can use select to make it more readable, or use findif to make it more eficient, but less readable lol
im basically trying to find out all objects like houses, vehicles, units except triggers and TAG_JIP_attachTo attached things from the list
well one limitation of nearobjects that wont find units in vehicles (i just learn that lol )
https://community.bistudio.com/wiki/nearObjects
yes thats fine
you will need an||to make that working, also is a little more readable if you dont nest to much ifs
if (typeOf _x == "EmptyDetector" || str _x in "TAG_JIP_rocket_attachTo") then {continue};
Which doesn't work when there is a channel 10 :/
so the logic works fine?
I don't understand the purpose of using formated strings. Is it really faster than using attachedTo or attachedObjects?
Didn't test the code in the game, but something like this
private _filteredObjects = _nearObjects select
{
(((typeOf _x) != "EmptyDetector") && {isNull (attachedTo _x)})
};
It selects elements with the two conditions:
1. object type is not "EmptyDetector"
AND
2. object is not attached to anything
I learned now that it might be better to put the 0 spawn {}; inside the if (isServer) then {}; but don't think that'll fix the issue of the timer not displaying for the clients? I did learn that it's only firing on the server, and not on the clients.. but unsure how to also trigger it for the clients to be honest.
well I propose to use global var for the objects + function to sync the timers
// 200 seconds before explose, propagate over net? YES
bomb setVariable ["theTimer", day_hour_minute_second, true];
and the function which syncs the time for the client and JIPs
(attachedObjects player) select {(typeOf _x) == "Land_PaperBox_01_small_closed_brown_F"};
this unfortunately does not return a boolean but i need to use it inside an if statement
Does attachedObjects player returns anything?
and sure it returns array, not boolean
- attachedObjects player must return non-empty array
- I recommend you to replace == with isEqualTo to perform non-case sensitive comparison (NVM, MY BAD. DON DO THIS)
- The whole expression returns ARRAY, each element must satisfy the condition.