#arma3_scripting
1 messages Β· Page 137 of 1
np
What condition needed in a trigger Condition field if i want to trigger a vehicle's hull damage percent above 10%?
you want the hull damage and not the overall damage?
I have a tanker truck filled with poison π
The fuel tank is a part of the hull.
But if you have an idea for overall damage triggering, my ears is open too!
well you can just get the overall damage: ```sqf
damage _vehicle >= 0.1
or specific part damage ```sqf
_vehicle getHitPointDamage "hithull" >= 0.1
Many thanks @proven charm!
is there a way to spawn a flare that the flash is very big
Like make a flare where the flash is huge. I want it for particle effects to attach to a missile
Yeah, it's an Arma issue where non-physX objects acquire velocity when you attach them and move the parent around, and then don't zero it when placed.
If you run into the other common issue where carried physX objects are extremely dangerous, the workaround is to setMass the object to near zero. But you have to remoteExecCall the setMass because setMass is super-slow propagation.
Thx for the Background Informations, Arma has to beloved
Is there a ballpark number for how much execution time is acceptable for eachframe unscheduled code? I'm looking at converting a scheduled loop to eachframe unscheduled; at the moment each iteration is about 0.06ms
Not really. Just consider that a 60Hz frame is about 16ms and consider how much of that you want to use.
Note that an eachframe likely has additional overhead on top of the SQF, so spamming tiny eachframes that check a counter is probably not a good idea.
And 20ms of these 16ms will be used by Arma itself on a populated server
Considering ace has to iterate every frame for every projectile, I don't think you need to worry
Can you link me the script?
Don't worry, that's not what I'm doing. Just nearObjects every frame :U
Curious what it does
onEachFrame allMissionObjects gang π
Yeah let me find it. I also had performance questions when I first started moving things to 100% unscheduled. The team told me to stop worrying about it cause whatever I'm doing is probably not gonna kill it.
advanced_ballistics\functions\fnc_handlefirePFH.sqf
I've played missions of similar size both with ACE and without, and to be perfectly honest I'm not going to take performance advice from ACE
That is a single eachframe for all the bullets though.
This is for wind deflection which runs every frame on every projectile.
Oh, extension ballistics. interesting
It's just doing some maths and returning :D
Wind deflection doesn't apply to AI bullets. Not sure about advanced ballistics.
its possible to cause lag spikes with unscheduled. that's the main problem with it
or plain crawl π
Then the maker is doing something very wrong imo.
yea CPU can handle only so much code
not for every projectile
and not on every frame
only for projectiles of player and as frequently as you've set in your CBA settings for simulation interval.
I'm tackling a script to save a loadout, then that loadout will be loaded on respawn. It works, almost :p I keep getting a script error upon respawn and I cannot seem to figure it out. It loads me with the saved loadout but still want to get rid of that error.
This is the script
// in onPlayerRespawn.sqf
if(_this select 1 != objNull) then {
if(!isNil "VirtualInventory") then {
hintSilent "Your loadout has been loaded from your save!";
_this select 0 setUnitLoadout [VirtualInventory, true];
};
};```
```sqf
// in ammobox INIT
saveAmmobox addAction ["Save Loadout", {VirtualInventory = getUnitLoadout player}, 10];
See attached the error
You can use isNull to check if something is null rather than comparing it directly to objNull
The only possibility I can see is if something else is setting VirtualInventory to a string, outside of these two bits of code
btw, why are you passing 10 as an argument to the addAction code and then not doing anything with it?
I'd recommend using a more unique name for VirtualInventory, it's pretty generic and something could be overwriting it
I'm not sure π I looked around here for some script examples and found it, was meaning to clean it up a little bit or at least understand if I need it or not. I guess I can take it out if it's not being used anyway. If I understand correctly if I want to keep it, I should reference it somewhere else?
Gotcha! Thanks for the advise.
Funny enough, the error does not replicate on dedicated server..
https://community.bistudio.com/wiki/addAction see: Parameters & example 5
You can keep it without referencing it anywhere else, but the whole point of passing an argument to the action code is to reference it in the code. If you pass it and then don't use it, it's pointless.
Ill yeet it out. Itβs not needed in this case
I personally like using the unit's namespace for this kind of thing
I found this post on reddit, seemed like a good working script.. but it never seemed to work for me :/ And I'm unsure why https://www.reddit.com/r/armadev/comments/60lw5w/comment/dfc8d5n/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
//onPlayerRespawn.sqf
[player, [missionNamespace, "inventory_var"]] call BIS_fnc_loadInventory;```
```sqf
//initPlayerLocal.sqf
sleep 1; //Time to wait for player to initialize in the mission
//Save loadout when ever we exit an arsenal
[ missionNamespace, "arsenalClosed", {
systemChat "Arsenal closed"; //Not actually needed, can say anything you want
waitUntil {time > 0.2}; //Time to wait to make sure Arsenal items are applied
[player, [missionNamespace, "inventory_var"]] call BIS_fnc_saveInventory;
}] call BIS_fnc_addScriptedEventHandler;```
That one always mentioned that variable inventory_var was not found
Is it possible to replace the skybox using cfgWorlds in the mission file, or does this require an addon?
addon
That said, how difficult is it, do you know?
Assuming you had another skybox ready to go - say, overwriting Takistan's sky with Livonia's or something like that
That script is designed to save the loadout whenever the player exits the Arsenal.
If they respawn before they've exited the Arsenal at least once (for example, if Respawn On Start is on, or if they just never open the Arsenal at all) then the loadout won't be defined and that's likely to cause an error.
I assumed that this only applies to the BI Virtual Arsenal? And not ACE arsenal?
that is vanilla
That's the only reason why I could not figure it out.
are you wanting something that saves ace arsenal?
Yea, we use ACE for our missions on dedicated server.
I also don't necessarily need this function, and addAction would do fine for me. But it's a "nice-to-have" thing.
I can write something. Kinda on a writers block on my own stuff atm so I got time.
Would be appreciated! I'd like to learn it more indepth as well, but seeing working scripts helps me understand the functions often.
// init.sqf
if (hasInterface) then {
["ace_arsenal_displayClosed", {
player setVariable ["BEAR_ACESavedLoadout", getUnitLoadout player];
hint "Respawn Loadout\nSaved";
}] call CBA_fnc_addEventHandler;
};
// onPlayerRespawn.sqf
params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];
private _loadout = _oldUnit getVariable "BEAR_ACESavedLoadout";
if !(isNil "_loadout") then {
_newUnit setUnitLoadout _loadout;
};
now you just add the arsenal to anything and when the arsenal display closes, it saves the player's loadout. No actions needed.
Great! Thanks a lot. I just got into bed, will rest it out in the morning. This should work for dedicated servers too Iβm guessing?
yes
Yeah, the if (hasInterface) command means that the script only runs on player machines, so it should work on local or dedi servers
Hi, im looking for some help with holdactionadd. How do i make my action persist after being completed once?
For more detail: I'm trying to implement self-revive. I've added the following holdaction into onPlayerRespawn.sqf to attach it to players when they respawn. the problem is that it only works on the first time they're incapacitated
// Inject self-res action?
[
player,
"Self-Revive",
"",
"",
"player getVariable['incapacitated', false]",
"true",
{},
{},
{ player setDamage 0;
player setVariable['incapacitated', false, true]; },
{},
[],
4,
nil,
false,
true
] remoteExec ["BIS_fnc_holdActionAdd", 0, player];
Are you sure you don't have something else removing actions from the player on revive?
maybe, there are a bunch of events in base Arma and the mods i run that trigger on players incap status. its possible that some other garbage is wiping out my data, which is big sadge
the best way i can think of is to reinject the action when a player is revived, but i can't seem to find an event tied to it. theres only "KILLED" and "RESPAWN"
SOLVED: I put the script into the core function that handles unconsciousness
fn_unconscious.sqf
Is this Antistasi :P
yeep
antistasi legacy, hence why im maintaining it myself
the new A3A mod cant be hacked as easily as the old one π¦
This works great!! I've added a hint to the Respawn code to notify people that their loadout is restored. Thanks!
I do got 2 questions though.. just to make me understand.
- in the onPlayerRespawn.sqf you have put the params in, the first 2,
_newUnitand_oldUnitI understand why they are there. But what are the last 2 good for? I don't see them referenced anywhere else but they are vanilla params? - How do you get the
ace_arsenal_displayClosedfunction?
Hey,
I'm having 2 functions. One is only available to the server and handles reading data from inidb2. Other one is global and calls this function in order to retrieve data read by the server function. Is this a proper way of:
- Defining function in init.sqf
call compile preprocessFileLineNumbers "Donut\Supplies\DNT_fncServer.sqf"; //In my understanding compiled functions are only available to the server
};
call compile preprocessFileLineNumbers "Donut\Supplies\DNT_fncCommon.sqf"; //Functions should be available globally```
2. Calling it between server and global function? I want for server function to retrieve data from db and then I want a global function to use those data
```DNT_updateSupplyTrackerTasks = { //Global function
private _suppliesStatus = remoteExec ["DNT_readFromDb", 2, false]; //Calls server function and retrieves array returned by it
rest of function...
is there a way for setting the image of a control by using an image from the mission folder? What would be the path structure? Example:
_control ctrlSetStructuredText parseText "<img image=\images\img1.paa />"
all the examples are from gamefiles
<img image='\a3\Data_f\Flags\flag_Altis_co.paa'/>
<img image='\a3\Data_f\Flags\flag_Altis_co.paa' />
<img image='\a3\Data_f\Flags\flag_Altis_co.paa'></img>```
i just got "image mydir not found"
that is, replacing mydir with my image folder ofcourse
could be something with parsetext
i moved to using rscpicture
hintSilent composeText [image "mydir\mypicture.paa" setAttributres ["size", "5"], " "];
to hint test a path
private _suppliesStatus = remoteExec remoteExec doesnt actually return anything else than JIP stuff
I'm a little confused then. If only server has inidb2 installed and only server can read data from db how do I make it accessible to different functions then? I tried calling DNT_readFromDb this way
hint _str(_state );
on client but instead of db contents it returns an array like ["any", "any", "any"] (it should be numerical values for different supplies). So it looks like data retrieved by server are not available to other global functions
if you want server to read inidb2 you can send the data to client if thats what you want sqf // Server serverReadDB = { // Read inidb2 // Send data to client _inidbData remoteExec ["inidbRead", clientIDHere]; }; // client inidbRead = { params ["_inidbData"]; }; something like that
Okay but if I want it distributed to all clients I could just do _inidbData remoteExec ["inidbRead", -2]; right? Also I'd like for it to be accessible to folks joining in progress as it's used to update list of supplies and they should see current status on join so also I should add true for JIPs right?
yeah and for JIP you must set the jip arg: _inidbData remoteExec ["inidbRead", -2, true];
Okay, I'm going to try this way, thanks
hey, need to reveal enemy units and mark theyr poses on the map.
using the nearestobject
or anymore syntax
Sorry, I'm still having problem understanding that. Let's say I have a globalFunction that want's to get data from db for a client. How would I go about calling it? Workflow I want to achieve is:
_dbData = call inidbRead;
...
};
But the thing is inidbRead only receives data when serverReadDB is fired. But then if I run serverReadDB why would I pass it to inidbRead instead passing it directly to the variable?
Like someGlobalFnc should both initiate server function and then get data from client function so how to achieve that as I'm a bit lost on that π
not sure what you mean. your not following my example where inidbRead is client function and gets called via remoteExec
I'm having trouble understanding how to retrieve data from inidbRead as it's executed by serverReadDB
someGlobalFnc would have to execute serverReadDB and then serverReadDB also instantly distributes data to clients via inidbRead function but I'm not sure how to access data from inidbRead if that makes sense?
my bad actually inidbRead was not good name, I meant it as inidbReceive , where the server sends the data
Okay so let there be 3 functions
- updateValuesFunction - global, requests data from db using serverReadDB and then updates some globally available values by reading inidbReceive
- serverReadDB - serverside, when called reads data from db and then passes it to client scope by calling inidbReceive
- inidbReceive - global - stores data passed by serverReadDB
Now what I want to achieve is:
updateValuesFunction = {
remoteExec ["serverReadDB ", 2, false]; //Requests data
_data = call inidbReceive ; //Stores data in variable
};
It seems wrong to me though as inidbReceive by itself does nothing so it shouldn't be called separately from serverReadDB but then serverReadDB does not return anythign by itself so I can't assign it to the variable?
.
so client calls updateValuesFunction which starts the whole thing?
Exactly
ok so maybe you mean this: ```sqf
// Server only functions here
if(isServer) then
{
serverReadDB =
{
// Read ini db here to _data variable
_data remoteExec ["clientReceiveDB", -2, true]; // send db to clients
};
};
// Client only functions here
if(hasInterface) then
{
updateValuesFunction = {
remoteExec ["serverReadDB ", 2, false]; //Request data
};
clientReceiveDB =
{
params ["_data"];
// Do something with the DB data
};
};
Okay so this way I have a client fnc that only requests data from server but clientReceiveDB is actually the function that uses the data, right?
yes
Okay, looks legit, will give it a shot, thanks for the help ;)
though i dont understand why one client calls updateValuesFunction and all clients receive the data. sounds like you could just directly call serverReadDB on the server
What I'm trying to actually to do is to have a fnc that just returns data from db for different purposes but I struggle with getting data by other functions that require it
Like server fnc actually is
private _inidbi = ["new","Quartermasters_logbook"] call OO_INIDBI;
private _suppliesStatus = [];
private _ammoCount = ["read", ["Supply count", "Ammo",9999]] call _inidbi;
private _medicalCount = ["read", ["Supply count", "Meds",9999]] call _inidbi;
private _scrapCount = ["read", ["Supply count", "Scrap",9999]] call _inidbi;
private _vehicleGarage = ["read", ["Supply count", "Vehicles",[]]] call _inidbi;
private _vehicleSummary = _vehicleGarage call BIS_fnc_consolidateArray;
private _vehicleMissionTxt = "";
{
_vehicleMissionTxt = _vehicleMissionTxt + "- " + (_x select 0) + ": " + str(_x select 1) + endl;
}forEach _vehicleSummary;
_suppliesStatus = [_ammoCount, _medicalCount, _scrapCount, _vehicleGarage, _vehicleMissionTxt];
_suppliesStatus;
};```
And it worked locally
private _suppliesStatus = call DNT_readFromDb;
private _ammoCount = _suppliesStatus select 0;
private _medicalCount = _suppliesStatus select 1;
private _scrapCount = _suppliesStatus select 2;
private _vehicleMissionTxt = _suppliesStatus select 4;
if((["Supplies"] call ENGTASKS_GetTaskState)== "") then {
["Supplies", ["Claimed supplies", (format["Current list of supplies brought to Haunter - ammunition: %1, medical: %2, scrap %3",
_ammoCount,_medicalCount, _scrapCount])], "CREATED"] call ENGTASKS_CreateTask;
} else {
["Supplies", ["Claimed supplies", (format["Current list of supplies brought to Haunter - ammunition: %1, medical: %2, scrap %3",
_ammoCount,_medicalCount, _scrapCount])], false] call ENGTASKS_SetTaskDescription;
};
if((["VehiclesList"] call ENGTASKS_GetTaskState)== "") then {
["VehiclesList", ["Available vehicles", (format["Current list of available vehicle types: %1 %2",
endl,_vehicleMissionTxt])], "CREATED"] call ENGTASKS_CreateTask;
} else {
["VehiclesList", ["Available vehicles", (format["Current list of available vehicle types: %1 %2",
endl,_vehicleMissionTxt])], false] call ENGTASKS_SetTaskDescription;
};
};```
But I just couldn't seem to pass data from db to DNT_updateSupplyTrackerTasks
You mean RPT or something else?
diag_log is probably the best if you end up testing it in dedi
Ah okay so I should just call it within let's say all relevant fncs and we'll get an idea which were called, right?
i mean use loggin to see which line gets processed
Okay expected order is:
Init.sqf >> DNT_initSupplies >> DNT_updateSupplyTrackerTasks >> DNT_readFromDb
DNT_initSupplies runs at mission start and should call subsequent fncs
Part of RPT
So it looks like the data from DNT_readFromDb is not passed correctly to DNT_updateSupplyTrackerTasks
it could be DNT_readFromDb fails to read the DB. so id log that data to see if DB is properly read
Okay, I'll log the values then
Welp to me seems like DNT_readFromDB reads values properly from db. DNT_updateSupplyTrackerTasks seems to be unable to reach them though
@proven charm
Oh wait, If I added diag_log at the end of function it wont return variable or is it alright?
DNT_readFromDb = {
diag_log "start of DNT_readFromDb";
private _inidbi = ["new","Quartermasters_logbook"] call OO_INIDBI;
private _suppliesStatus = [];
private _ammoCount = ["read", ["Supply count", "Ammo",9999]] call _inidbi;
private _medicalCount = ["read", ["Supply count", "Meds",9999]] call _inidbi;
private _scrapCount = ["read", ["Supply count", "Scrap",9999]] call _inidbi;
private _vehicleGarage = ["read", ["Supply count", "Vehicles",[]]] call _inidbi;
private _vehicleSummary = _vehicleGarage call BIS_fnc_consolidateArray;
private _vehicleMissionTxt = "";
{
_vehicleMissionTxt = _vehicleMissionTxt + "- " + (_x select 0) + ": " + str(_x select 1) + endl;
}forEach _vehicleSummary;
_suppliesStatus = [_ammoCount, _medicalCount, _scrapCount, _vehicleGarage, _vehicleMissionTxt];
diag_log "DNT_readFromDb output:";
diag_log format ["_ammoCount = %1", _ammoCount];
diag_log format ["_medicalCount = %1", _medicalCount];
diag_log format ["_scrapCount = %1", _scrapCount];
diag_log format ["_vehicleMissionTxt = %1", _vehicleMissionTxt];
_suppliesStatus; //Value to return
diag_log "EOF DNT_readFromDb"; //Is it okay to leave it there and fnc will still return _suppliesStatus?
};
Hey guys is it possible to script roads in a modded map ? Because the roads are here but some of them aren't considered as roads.
welp my bad
you must not put the diag_log as last line in function because it will mess up the return. I mean put diag_log format ["READ: %1",_suppliesStatus];
to see if DB read ok
Yep fixed that and also logged values passed to DNT_updateSupplyTrackerTasks and it seems values are correctly put inside of it
So is it working now?
Nope, that's what confuses me π
I'm not an expert when it comes to iniDBI stuff, but I noticed that you're trying to create new instance of the same DB repeatedly (I think). Maybe it causes it to fail? ```sqf
private _inidbi = ["new","Quartermasters_logbook"] call OO_INIDBI;
Yeah but if it would fail the values wouldn't be read properly from db and yet they are. What is happening here is:
- DNT_initSupplies is called from Init.sqf and it calls some other functions, one of them being DNT_updateSupplyTrackerTasks
- DNT_updateSupplyTrackerTasks calls DNT_readFromDb to receive data for update
- DNT_readFromDb reads data properly as I was able to log the values
- DNT_updateSupplyTrackerTasks receives the data as I was able to log them in it's scope as well
So SOMETHING happens at this piece I think
diag_log " start of DNT_updateSupplyTrackerTasks";
private _suppliesStatus = call DNT_readFromDb;
diag_log " DNT_readFromDb is called by DNT_updateSupplyTrackerTasks";
private _ammoCount = _suppliesStatus select 0;
private _medicalCount = _suppliesStatus select 1;
private _scrapCount = _suppliesStatus select 2;
private _vehicleMissionTxt = _suppliesStatus select 4;
diag_log "DNT_updateSupplyTrackerTasks _suppliesStatus output:";
diag_log format ["_ammoCount = %1", _suppliesStatus];
diag_log format ["_ammoCount = %1", _ammoCount];
diag_log format ["_medicalCount = %1", _medicalCount];
diag_log format ["_scrapCount = %1", _scrapCount];
diag_log format ["_vehicleMissionTxt = %1", _vehicleMissionTxt]; //Works until this part```
["Supplies", ["Claimed supplies", (format["Current list of supplies brought to Haunter - ammunition: %1, medical: %2, scrap %3",
_ammoCount,_medicalCount, _scrapCount])], "CREATED"] call ENGTASKS_CreateTask;
diag_log " task == empty, create new task";
} else {
["Supplies", ["Claimed supplies", (format["Current list of supplies brought to Haunter - ammunition: %1, medical: %2, scrap %3",
_ammoCount,_medicalCount, _scrapCount])], false] call ENGTASKS_SetTaskDescription;
diag_log " task == exists, update task";
};
if((["VehiclesList"] call ENGTASKS_GetTaskState)== "") then {
["VehiclesList", ["Available vehicles", (format["Current list of available vehicle types: %1 %2",
endl,_vehicleMissionTxt])], "CREATED"] call ENGTASKS_CreateTask;
} else {
["VehiclesList", ["Available vehicles", (format["Current list of available vehicle types: %1 %2",
endl,_vehicleMissionTxt])], false] call ENGTASKS_SetTaskDescription;
};
};```
more debug π
Arma is an unforgiving mistress π
How do you know it's not reaching the code? According to the diag_logs in RPT that code gets run
Yeah something I didn't consider apparently it does reach this piece. I left the server, rejoined and values updated
But then I ran from debug console
remoteExec ["DNT_updateSupplyTrackerTasks",0,true]; and values are of "any" type again.
if you ran that from debug console that means you ran it on client? there should be run at server option
I run it globally
Yeah
wait I got something
Running it like this results in properly updated supplies
Like this
Returns any
how about call DNT_updateSupplyTrackerTasks on "Server"
Same as global, so it seems the server does not have DB data?
it worked?
When run on server it didn't
hmm not sure then
0 means its ran everywhere
Yes but below you have scopes at which it is run, in this case I ran command on server
It doesn't matter, as the 0 makes it run everywhere
yep and global runs everywhere also
so you can make it run everywhere twice (with global)
Yeah but in some order I guess? I noticed that in tasks the values are for like a 0,0001 second updated with correct values and THEN they are getting "any"
Like client overwrites correctly but then server overwrites with no data
Try to run exactly this on "Server" (no remote exec): ```sqf
call DNT_updateSupplyTrackerTasks;
Definitely, only server should have access to DB and game logic anyways
Okay, big thanks lads, I've been struggling to wrap my head around locality for months now and I still fail spectaculary xD
Welcome to the club π
I'll try to restrict execution to server, hopefully that's it
} else {
grrr.
What do you mean when you call the function a "global"?
A global variable in the namespace or defined on the all machines in the network?
it can mean two things. "Global" exec button. or 0 as remoteExec target π
_suppliesStatus; //Value to return
don't use semicolon for the returning value
and defining function(s) in the init.sqf is probably not good idea in general
because everything must be ready and compiled before your clients start to interact with the server
unless you're trying to load functions dynamically from the server on purpose
Also, do not expose functions you don't want to call over the network
Ideally only interface and unified functions must be exposed
everything else should not be whitelisted
Client and server can have same function identifier (a var name) but completely different functionality or even types.
So when you call something "global", it's basically not global, but the variable with the same name on the different machines. In general "global" is applied to the variable defined on the same maching outside the local scope
what's wrong about semicolon?
something like this:
x = 1; // global variable
fnc_foo = {}; // global function
publicVariable "fnc_foo"; // propagate function over the network
fnc_foo =
{
private _result = 2 + 3;
_result
};
private _x = call fnc_foo;
// is complete equivalent of
private _x = 5;
// whe you use semicolon, the equivalent changes to this
private _x = 5;;
it adds empty expression
in most cases it won't break things but in some it will (e.g. macro)
I see
Why isn't the sub sinking, but flying up into the air???
private _d = 0;
while { _d != -20 } do {
sub1 setposASL [(getpos sub1 select 0),(getpos sub1 select 1),(getpos sub1 select 2)+_d];
_d = _d - 0.05;
sleep 0.1};
You're mixing two different position formats, positionAGLS from getPos and positionASL from setPosASL. AGLS is relative to the terrain; ASL is relative to a fixed sea level.
Use getPosASL instead to keep the formats consistent (it's also faster)
You can also use vectorAdd to simplify the maths.
for "_i" from 1 to (20 / 0.05) do {
sub1 setPosASL (getPosASL sub1 vectorAdd [0,0,-0.05]);
sleep 0.1;
};```
Beautiful. Thanks
hey there, trying to spawn a custom composition through a trigger.
// Define the position where you want to spawn the plane
_planePosition = getMarkerPos "planeSpawnMarker";
//Spawn The plane
_composition = createVehicle ["JUMP PLANE", getMarkerPos "planeSpawnMarker", [], 0, "NONE"];
its not working, and im not getting any errors. any ideas?
technically that code doesn't try to spawn a composition but a vehicle. you should replace the "JUMP PLANE" with the vehicle class name
so the vehicle is a c17 with crap in the back for testing, I made it a composition. Would i still want to use the C17 classname?
not sure what ya doing but you need to get the plane class name for createVehicle command
right now im just trying to spawn this c17 thats grouped with a few items as a composition on the ground in front of me.
i guess im having trouble understanding whats confusing?
maybe someone can help you with that (eden?) composition because i havent used those but I know you dont use createVehicle for compositions
what i dont understand is if the stuff is already on the map why do you need to recreate them?
thers no c17 with crates in the cargo bay on the map
eventually i want to spawn it in the air, not have it on the ground
just trying to figure this piece out first
Go in the editor and place a house, now put a table in it, now make that a composition.
Now what if you want to spawn that using a trigger?
im trying to do that with a plane and some crates.....
ok gotcha you need some comp spawn function for that, i forgot which one
but im not sure how up to date that is
maybe this helps too but I think its for eden: https://community.bistudio.com/wiki/Eden_Editor:_Custom_Composition
ok thank you
Is there a way to send a post request in eden (on the server side)?
through an Extension eventually
No way to do it natively?
no, if we are talking about Arma 3
Is there a way to make really any http request?
https://community.bistudio.com/wiki/htmlLoad eventually, but that's not ideal
yeah i saw that
im gonna try make it work, see if its possible
i only need it to effectively ping something
that's about it
k, thanks.
question, is there a way to use said htmlLoad without making a visible gui?
sorry to bug you again π
you could make some overlay with transparent or out-of-screen controls
moveInDriver
Hi, this is perhaps a noob question but I've been struggling with it for quite sometime. I have a vehicle that uses rtm based animations. The animations work fine in object builder and appear to be successfully binarized but I can't get them to play using switchMove, playMove or any others in a script. I've setup a CfgMoves class that defines the states for all these animations. Is there something I'm missing please? Also, the vehicle never shows up as one of the animated objects within Eden's animation viewer.
Hey π
I'm trying to setup a 'mission room' with plenty of screens playing videos from within the vanilla source files (better than having players download a load of video files)
It seems to be working ok, but I have two issues I was hoping somebody could help me with
- The videos are playing sound (not in 3d) and ideally id like them have no sound at all
- The videos play once and then end, id like them to loop infinitely
Any help is much appreciated!
_video = "\a3\missions_f_exp\video\exp_m04_v02.ogv";
this setObjectTexture [0, _video];
[_video, [10, 10]] call BIS_fnc_playVideo;
this might be a #arma3_config question
Is it? I really donβt know. Iβm presently using a script being called from the config file to run the animation (doesnβt work).
Reference KillzoneKid's blog on the topic
killzonekid.com/arma-scripting-tutorials-ogv-to-texture/
1.) Out of luck for 3D sound. Need to remake video without sound for no sound.
2.) There is an internal scripted event handler that is made within the function:
[missionNamespace, "BIS_fnc_playVideo_stopped", [_videoContent]] call BIS_fnc_callScriptedEventHandler);
you can use this event handler to find out when to run the script again
is there a way to get the model path for the current scope of a players main weapon?
I have something like this I normally use for other items:
_weaponConfig = configfile >> "CfgWeapons" >> (headgear player);
(getText (_weaponConfig >> "model"));
Just not sure what to use to check primary weapon scope
You're on the right path, you just need to use the scope's classname itself:
https://community.bistudio.com/wiki/primaryWeaponItems
That just returns the attachments, its there something specific to put in to just refer to current scope
you want the attachment of the optic right?
I want to get the model path from the players current scope
primaryWeaponItems player params ["_silencer", "_laser", "_optics", "_bipod"];
private _model = getText (configFile >> "CfgWeapons" >> _optics >> "model");
// return
_model
That isn't returning anything for some reason
because its stored in the _model variable
just put _model at the end
Ahh thanks works now
Perfect, thanks for the help π
so im trying to take a large composition, and turn it into 2 functional parts built around a turret.
the "base" of the turret will rotate to face the direction of the aforementioned turret. and the "barrel" of the turret will change its elevation based on the "turret" barrel elevation while also following the rotation of the base to create a rather large weapon. ive currently got both the "barrel" and "turret" rotating but not the elevation using attachtorelative fuckery. whats the best way to approach the elevation issue?
BIS_fnc_attachToRelative doesn't have the features you need to do this (https://feedback.bistudio.com/T156957).
You need to use attachTo directly, and work out the relative positions yourself.
@fair drum (or anybody who may also know!) Apologies, I tried following your advice and have found a way to ensure the video plays correctly for a dedicated server too, I just cant figure out where to amend this to have it loop infinitely. Are you able to assist?
Thank you again!
if(isServer) then {
private _video_1 = "\a3\missions_f_exp\video\EXP_m06_vIntel.ogv";
_screen_1 = toc_screen_1 setObjectTextureGlobal [0,_video_1];
_screen_1 setObjectTextureGlobal [0, _video_1];
[_video_1, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated), false];
};
that would be god tier
Sorry Nikko, tagged you by mistake there!
so before i get to work. as an outline:
using the turrets rotation im gonna have to get every object i wish to "follow" its rotation, get their offsets. maintain them while rotating them by the elevation of the turret and maintain their world offset from the turret
No
my apologies, i must have misunderstood
You're going to get all the objects you want to follow the rotation, and attach them directly to the bone that rotates by using attachTo, and turn on the "follow bone rotation" parameter in attachTo.
If you want to Editor-place them then you'll need to get their positions relative to the turret in order to copy their Editor positions (this is what BIS_fnc_attachToRelative does internally). Otherwise, you can just trial-and-error the attachTo offset until you have them positioned correctly.
im using 7erras attach to finder to test out some bits, but i cant even get a single object attached to the "turret" or "gun" memory point of a praetorian. i assume thats where the "selection names" comes from
so i can grab the memory point of the actual barrel
perfect. thats actually fixed my small scale testing
_barrel = createVehicle ["Land_MetalBarrel_F",[0,0,0],[],0,"NONE"];
_barrel attachTo [yourTestTurret, [0.5,1,0], "gun", true];
_barrel setVectorDirAndUp [[1,0,0],[0,1,0]];```
do i even bother with the offset feature in attach to considering there is the "automatic offset" in example 3
assuming that does what it says
Server Version
if (isServer) then {
// Video function
MON_PlayVideo = {
private _video_1 = "\a3\missions_f_exp\video\EXP_m06_vIntel.ogv";
toc_screen_1 setObjectTextureGlobal [0,_video_1];
[_video_1, [10, 10]] remoteExec ["BIS_fnc_playVideo", ([0, -2] select isDedicated)];
};
// Repeat setup with event handler
[missionNamespace, "BIS_fnc_playVideo_Stopped", {
call MON_PlayVideo;
}] call BIS_fnc_addScriptedEventHandler;
// Initial video call
call MON_PlayVideo;
};
and really, for something like this, its better to make it all local and not use remoteExec since those event handlers could fire at a different time on the server than the client:
Local Version
if (hasInterface) then {
// Video function
MON_PlayVideo = {
private _video_1 = "\a3\missions_f_exp\video\EXP_m06_vIntel.ogv";
toc_screen_1 setObjectTexture [0,_video_1];
[_video_1, [10, 10]] call BIS_fnc_playVideo;
};
// Repeat setup with event handler
[missionNamespace, "BIS_fnc_playVideo_Stopped", {
call MON_PlayVideo;
}] call BIS_fnc_addScriptedEventHandler;
// Initial video call
call MON_PlayVideo;
};
okay, figured out how to "automate" the attachto instead of using attachtorelative.
next question: why does this
_barrel = (8 allObjects 0) inAreaArray barrel;
just fetch seemingly everything
i asked this a day or two earlier and someone said a precedence issue? not entirely sure how to fix it however in this case
Thank you very much! Will give this a go. I really appreciate it! π
The precedence issue was with this structure:
{ ... } forEach (8 allObjects 0) inAreaArray barrel;```
In that structure, the game goes "`forEach`? ok, let's see what you want to iterate over", sees `(8 allObjects 0)`, and immediately executes that to use as the array for `forEach`. _Then_ it reads `... inAreaArray barrel;` but it's too late.
The solution to that is to use these `( )` to force the correct parts of the expression to be executed first, same as in a maths expression.
No, it still reads left-to-right *when the commands involved have equal precedence
In fact, it might then read 8 first and try to use that (then fail with an error because 8 is not an array)
(8 allObjects 0 inAreaArray testingtrigger); then?
This specific piece of code β¬οΈ shouldn't have this issue because it involves a variable assignment (=) rather than forEach, and = has very low precedence.
ill just crutch on that then
Hey guys, idk where should i write this so im doing it here, anyone can help me out with UPnP error when i want to host a server to play with my friends?
Try #arma3_troubleshooting, #server_admins, #server_linux, or #server_windows. This channel is for in-game scripting - server configuration happens outside the game.
alright thanks!
I'd suggest using an Editor layer or something rather than positional detection, to avoid accidentally catching anything you don't want.
You can also create everything through scripting once you find out the right offset and vectors to use, which will make it much easier to place the turret wherever you want without disturbing its accessories.
i dont see that really being an option as its a custom composition that is rather large
it would take a while
_relPos = john_1 worldToModel (getPosATL _x)
_x attachTo [john_1, _relPos, "gun", true];
instead im gonna use something like this (gonna plug in a vectorDir and vectorUp finding solution to plug into the setVectorDirAndUp
and there will only be one of him
yes the turret is called john
so:
_base = 8 allObjects 0 inAreaArray testingtrigger;
_barrel = 8 allObjects 0 inAreaArray barreltest;
{
_vDir = vectorDir _x;
_vUp = vectorUp _x;
_relPos = john_1 worldToModel (getPosATL _x);
_x attachTo [john_1, _relPos, "gun", true];
_x setVectorDirAndUp [_vDir,_vUp];
} forEach _barrel;
I was working on writing something to do it mostly automatically for you but it seems like we're missing some ways to get information that would be needed for that, like which selection an object is attached to :U
why would that be necessary? wouldnt it be possible to just save the prior attached selection
I wanted to let you design it in the Editor so you could see what you're doing, then scrape all the position information from the completed package to feed into a script to automatically recreate it
ill dm you it
But associating the appropriate selection with each object would require you to do that yourself, which sort of defeats the purpose
couldnt i just use the two triggers ive got setup to attach those objects that way?
base gets attach to relatived. the barrel attached to the turrets barrel
Yes, probably, though I think you need to do some more maths than you're currently doing, because the offset is relative to the selection, not the object origin
I'm just looking at ways to make the whole thing into a script, for my own satisfaction rather than because it's necessary
im just doing this for a cool op aswell as my own learning
couldnt i just find it via this?
That's one of the ingredients, yes
Seems likely
for the correct setVectorDirAndUp
as currently my method has a strange slight vector issue
its a bit off
do any type of commands exist that forbid a certain heli being able to detect/land on a particular heli/invis heli pad?
for example i want to assign a landing pad to a specific unit and another one to another unit in close proximity but ensure unit A lands at pad A and unit B lands at pad B
UNITS will be flying back and forth over a long mission to their respective pads,so removing/hiding pads etc isnt an option
having a bit of a headache converting the selection position relative to the model origin to a world position to set the objects relative attachment
although at the same time im not entirely sure its necessary but its 3am and im losing my marbles
nope
i'm assuming you've already tested it and they land wherever the hell they want?
I'm not certain about this, and especially the vectorDiff might need to be the other way around, but try it:
private _selectionPos = _parentObject selectionPosition _selection;
private _selectionPosASL = _parentObject modelToWorldWorld _selectionPos;
private _offset = _selectionPosASL vectorDiff (getPosASL _childObject);```
so the current code ive got then is:
_base = 8 allObjects 0 inAreaArray testingtrigger;
_barrel = 8 allObjects 0 inAreaArray barreltest;
_selectionL = steve selectionPosition "gun";
_selectionV = steve selectionVectorDirAndUp ["gun","Memory"];
private _selectionPos = steve selectionPosition "gun";
private _selectionPosASL = steve modelToWorldWorld _selectionPos;
{
_vDir = vectorDir _x;
_vUp = vectorUp _x;
private _offset = _selectionPosASL vectorDiff (getPosASL _x);
_x attachTo [steve, _offset, "gun", true];
_x setVectorDirAndUp [_vDir,_vUp];
} forEach _barrel;
steve switchCamera "internal";
player remoteControl steve;
steve is my new test turret
got a bit of old code still stuck in there
okay the attached stuff is inverted
well, not inverted. off by 90 degrees
and upside down
You're not converting the vectors. You're just getting their old (worldspace) vector and applying the same vector after attaching them. Now they're operating relative to the selection, the old vector is no longer correct.
You need to get the selection's vector in world space, get the child object's vector in world space, and compare them. The difference should be the relative vector you need.
I see
_base = 8 allObjects 0 inAreaArray testingtrigger;
_barrel = 8 allObjects 0 inAreaArray barrel;
_selectionL = steve selectionPosition "gun";
_selectionV = steve selectionVectorDirAndUp ["gun","Memory"]; //parent vectors
{
_vDir = (_selectionV select 0) vectordiff (vectorDir _x); //child vector dir
_vUp = (_selectionV select 1) vectordiff (vectorUp _x); //child vector up
_relPos = steve worldToModel (getPosATL _x);
_x attachTo [steve, _relPos, "gun", true];
_x setVectorDirAndUp [[_vDir],[_vUp]];
} forEach _barrel;
steve switchCamera "internal";
player remoteControl steve;
something like this?
im a little bit lost at this point
Actually its working relatively well, in this example, one pad is the departing pad and one is RTB pad(RTB PAD has a rearm trigger area)
randomPoint= selectRandom ["AO", "AO"];
{ deleteWaypoint _x } forEachReversed waypoints EBIRD;
_wp = EBIRD addWaypoint [position LIFTPADEBIRD, 0];
_wp setwaypointtype "GETIN NEAREST";
_wp setWaypointSpeed "NORMAL";
_wp setWaypointBehaviour "AWARE";
_wp = EBIRD addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1];
_wp setwaypointtype "MOVE";
_wp setWaypointBehaviour "COMBAT";
_wp = EBIRD addWaypoint [AGLToASL (randomPoint call BIS_fnc_randomPosTrigger), -1];
_wp setwaypointtype "MOVE";
EBIRD setBehaviour "CARELESS";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointTimeout [1, 2, 3];
_wp = EBIRD addWaypoint [position LANDPADEBIRD, 0];
EBIRD setBehaviour "CARELESS";
_wp setwaypointtype "GETOUT";
_wp setWaypointBehaviour "CARELESS";
_wp setWaypointTimeout [1600, 1700, 1800];
_wp = EBIRD addWaypoint [position LANDPADEBIRD, 0];
_wp setwaypointtype "CYCLE";
you can see "liftpad" and "landpad"
the pads need to be close together, at 50 mtrs distance, and the wp in syntax above,all runs ok
but theres another aircraft and script and 2 more pads "landpadbird2" for example also close by. all seems ok actually and iv had no issues, however i just want to make 110% sure they follow directions to their sepcific pads and wondered if such a command existed
hmmm actually i could manipulate the pads with show/hide command when one particular aircraft flies to within a set range of landing area. that should garauntee it
Once 2.18 arrives, you can use the new alt syntax for landAt to target a specific pad
first time realising page like this exists
thats awesome and lovely timing thanks for mentioning
https://community.bistudio.com/wiki/BIS_fnc_unflipThing pretty awesome. il find a way to have this as an automated script for AI
i suppose you could usehttps://community.bistudio.com/wiki/getEntityInfo with this https://community.bistudio.com/wiki/BIS_fnc_unflipThing for good effect
pretty much anything that's in a function is something you can also do yourself without the function btw. Functions are made from commands; they're just a way of condensing several commands into one quick reference. Unflipping things has always been possible (setDir resets orientation), the function just makes it more convenient.
true enough,i some time ago made a small funtion to get ai squad mates to disable pathing and teleport to my exact pos in order to get them into a building that had no positions. just nice to have snippets so to speeak,we spend enough time in the editor and doing random things. Arma is such a rabbit hole
Is there a reliable way to preload music?
playMusic
Been an issue forever, you randomly end up with music not playing
I tried running playMusic on all tracks during loading, but it doesn't really preload it
You randomly end up with music not playing when you do playMusic
Same music?
Or do you randomly pick a music and that random music doesn't play?
I only use 3 track, I do playMusic on each during loading
When time comes to play, playMusic randomly does nothing
(How the hell did I end up typing "on all vehicles"?
)
It sounds like a bug. it makes more sense to make a ticket instead of looking for a workaround imo
Preload:
{
playMusic _x;
} forEach ["LeadTrack04_F_EPC", "LeadTrack01_F", "LeadTrack03a_F_EPA"];
0 spawn {playMusic "";};
Usage:
if(publicVar_game_winnerTeam == client_mySide) then {
playMusic ["LeadTrack01_F", 130.6];
} else {
playMusic "LeadTrack03a_F_EPA";
};
I think it fails with both?
Just had it fail with playMusic ["LeadTrack01_F", 130.6];
Next time I tried running same command, it worked
no repro = no fix
thus the search for crutches
Asset preloading is a long going issue to be honest
I don't think the problem is the preloading
Also I don't know if playMusic actually loads anything immediately when you call it
Help me figure out the addAction please.
I'm trying to make a mission script that allows locking/unlocking doors if player have a "key" in inventory. But I cannot add action to door and I don't understand why.
My current code is:
// init.sqf
DD_fnc_initDoors = {
params ["_building", "_door", "_key"];
_building addAction [
"Try unlock", // Title
{
params ["_target", "_caller", "_actionId", "_arguments"];
_target setVariable [format ["bis_disabled_Door%1", _arguments], 0, true];
}, // Script
{_building, _door, _key}, // Args (_this select 3)
1.5, // Piority
false, // ShowWindow
true, // HideOnUse
"", // Shortcut
true, // Condiditon
15, // Radius
false, // Unconscious
"", // Selection
"" //MemoryPoint
];
};
And in the init field of the building I call this
[this, 1, 1] call DD_fnc_initDoors;
// Door_1 is disabled via attributes
But action isn't added.
The way you pass the args is wrong
Also where have you defined the function?
Are you sure it's defined when you call it?
The way you pass the args is wrong
So what's wrong, I'm too used to C-like languages and I'm a bit los in sqf
Also where have you defined the function?
Umm, in init.sqf.
Are you sure it's defined when you call it?
I tried calling it while in mission via execute field, same result
It seems to me that you're only trying to pass the door number as arg, so the addAction args should just be _door, not {_building, ...} (which is a "code", due to being wrapped in {})
also, init.sqf gets executed after object init fields
So your object init never sees the function
Will use of sleep fix this or should I define function as file?
Also regarding your bis_disabled_doorX variable, wasn't it supposed to be assigned a boolean? You're assigning it a number
You can't use sleep in init fields (at least not without spawning the code)
I recommend using the functions library
I found this script where lock state controlled by integer as I understand https://forums.bohemia.net/forums/topic/215428-addaction-in-building-doors/
Hello, Its possible to put an addaction command to a certain building door ? I did locked all this building doors via gamelogic (9 doors in total). Now I want to put an addaction to some of this doors. Is there any easy way to do it? I know there are some scripts to breach doors and all, but I wa...
@meager granite thanks. Next question:
Is it possible to invoke push to talk ingame with SQF? (e.g. like player action ["pushToTalk"])
I thought they were booleans. nvm then
So it isn't working because init.sqf is executed after object init? If so, I need to make sure function is loaded first by either using library (looks kinda complicated), or call it mid mission, right?
BTW, I used sleep in object init field to change texture of shoulder rank for CWR3 uniform and it worked as expected.
If you are talking about other arguments passed to addAction as 3rd argument {_building, _door, _key}, this is because I want to use it later for lock logic. It doesn't matter if I don't use them, isn't it?
I noticed that issue after I sent message and fixed with _arguments select 1
As I said {} means code. You need [] which means array
Just use the functions library
Using a delay is weird
And there's still no guarantee that init.sqf has completed running the bit you wanted (tho you can use waitUntil and isNil but that'd be overkill)
Functions library is complicated at first but once you figure it out it becomes far easier, cleaner, and more convenient than many other solutions
Especially if you intend to make a lot of functions
Ok, I'll try this way, thank you
Tell me please, how can I remove the standard action?
I need to delete the repair action
I recommend doing it this way:
- Make a folder in your missions folder called
DD - In DD make a folder called
functions - Make a file called
functions.hppin the mission folder, next to mission.sqm and description.ext, like this
class CfgFunctions
{
class DD
{
class DoorStuff
{
file = "DD\functions\door"; // directory where the following functions are located:
class initDoors {};
};
};
};
- In description.ext write
#include "functions.hpp" - Now create a folder called "door" in the functions folder, and put the
fn_initDoor.sqffile in it (function files should be calledfn_functionName.sqf, otherwise you have to specify their full paths for the game to find them)
That will create a function called DD_fnc_initDoors (DD comes from the "class DD" part)
When you add new functions, you have to stop the mission and go back to eden and start the mission again
VOIP is in a whole other layer of the engine'
Got it
anyone has any idea what changed between 1.52 and ACE3.3.1 and now that makes this snippet not work anymore: http://pastebin.com/pQesSU5X
it goes into spectator but going out of spectator no longer works
Unreliable
What will happen if that delay is not enough on 2010 machine?
Or you're loading the game and copying the files at the same time?
Are you talking about changing textures?
yep
you know there are those dubbing_radio_f sound files that have sounds for numbers directions etc. is there function that can play sentence using those? Like "enemy 50m east"
if you need to do something after init, use postInit event
FYI
It is not possible to delete standard actions.
So I just removed the engineer's trait from the player
Well, I have enough time to set delay up to 10 minutes. And as I understand this delay starts just after map screen, so, I don't see big issue in terms of old PCs.
Anyway this was only for testing purposes, in final variant I will do this via proper script.
this addAction ["exit respawn island", {player setPos (getPos ex1)}]
Using this script to teleport my players back onto the carrier from where the respawn point is but it spawns them under the boat in the water. I know theres something to change to fix that but I dont remember what it was
Try using getPosASL and setPosASL instead of getPos/setPos. (And of course make sure ex1 is actually on the deck of the carrier)
Using getPos/setPos is strongly discouraged because a) they're slow and b) they do NOT use the same position format. There is a note on each command's wiki page explaining further.
How do i stop or delay players force respawning? using the ESC menu that is
There's is an attribute in your description.ext.
respawnButton = 0;
init.sqf starts before the user presses START button.
init.sqf
// post init in the SP and post postInit in MP
sleep 0.0001; // wait until user presses the START
// continut to execute the code
moreover in MP you can experience the situation where player variable is not initialized at init.sqf script
It is better to strictly follow the guidlines, because A LOT A LOT of community creators commit the same mistake
Alternatively if you don't use postInit, it is good practice is to wait BIS_fnc_init
something like this
waitUntil {sleep 0.1; (!isNil "BIS_fnc_init") && {BIS_fnc_init}};
// set textures
Keep in mind, player variable can be <NULL-OBJ> if player's slot changed the group mid-game
Or even his AI avatar was killed
In this case you have to detect and resolve this.
It's common mistake to use these constructs
waitUntil {player == player};
waitUntil {!isNull player};
waitUntil {local player};
// etc
because in some cases player will never be initialized and this will waitUntil to stuck infinitely checking the variable.
For example if your mission doesn't even have player slots
If player variable was not init before postInit or even in "PreloadFinished" EH there is definetly something went wrong
If you're using CBA's Settings, in general CBA_fnc_addSetting called in XEH_preInit.sqf. Code in the argument #7 is executed AFTER preInit phase. It means of you set global variable in that code you cannot use these vars in XEH_preInit.sqf:
XEH_preInit.sqf:
// Add CBA settings
[
"MyOption_enable",
"CHECKBOX",
["Enable", "Enable description."],
["MyModName", "General settings"],
true,
1,
{
// code executed after preInit
MyGlobalVariable = _this;
},
false
] call CBA_fnc_addSetting;
// error! MyGlobalVariable is nil
if (MyGlobalVariable) then
{
hintSilent (format ["Checkbox is set to %1", MyGlobalVariable]);
};
The good example is WBK's Death and Hit Reaction mod (by Webknight).
I hope he will fix that someday
TL;DR It is very crucial to develop the habit of writing code properly from the very beginning. IMO. Sure you can code whatever you want without limitations, but the users probably will curse everyone and arma developers for "bad unstable and glitchy" game.
Hi guys.
I'm trying to damage a technique module using
_vehicle setHitPointDamage ['hitfuel', 1]
But after some time (3-4 seconds), the value is set to the previous value itself.
The only problem is the multiplayer. If you run it locally, everything is fine
where are you running that code? wiki says it needs local argument
I run locally from the player
make sure _vehicle is local to wherever you call that code from
_vehicle is essentially a cursorObject
That doesn't really have anything to do with locality
Use remoteExec to send the command to the machine where the vehicle is local
i think this is what Nikko means , (hope i got the code right π : ```sqf
[_vehicle , ['hitfuel', 1] ] remoteExec ["setHitPointDamage", owner _vehicle];
owner isn't needed
Oh shit. I tried to do
[cursorObject, "hitfuel", 0] remoteExec ["setHitPointDamage"]
Thank you very much
you only need remoteExec if you dont know where the vehicle is local though
I am so confused about ExtDB2 not working for me...
Hello, please tell me,how can positions array?
nearestObjects [pos1,pos2,pos3, ["LandVehicle"], 100, true];
private _nearest = [];
{
_nearest append nearestObjects [_x, ["LandVehicle"], 100, true];
} forEach [pos1,pos2,pos3];
private _nearest = [];
{
{
_nearest pushBackUnique _x;
} forEach (nearestObjects [_x, ["LandVehicle"], 100, true]);
} forEach [pos1,pos2,pos3];
to make sure there are no duplicates
(You can also use arrayIntersect to remove duplicates from code bit 1)
Can you tell me where the error is?
_pos = [22810,18166,0.00143886];
_pos2 = [22997.9,18433.9,0.00143886];
_posmove = [22768.4,18364.4];
private _nearest = [];
{
_nearest append nearestObjects [_x, ["LandVehicle"], 100, true];
} forEach [_pos,_pos2];
_arr = nearestObjects [_nearest, ["LandVehicle"], 300, true];
{
if (_x isKindOf "LandVehicle") then {
_x setVehiclePosition [_posmove, [], 250, "NONE"];
};
} forEach _arr;
My task is to take cars from several positions and move them
I think I understand
to
_arr = nearestObjects [_x, ["LandVehicle"], 300, true];
in the end something like that
_pos2 = [23995.1,18074.7,0.00143886];
_posmove = [22768.4,18364.4];
private _nearest = [];
{
_nearest append nearestObjects [_x, ["LandVehicle"], 100, true];
_arr = nearestObjects [_x, ["LandVehicle"], 300, true];
{
if (_x isKindOf "LandVehicle") then {
_x setVehiclePosition [_posmove, [], 250, "NONE"];
};
} forEach _arr;
} forEach [_pos,_pos2];```
as a continuation from previous entry of mine in this chat
_base = 8 allObjects 0 inAreaArray testingtrigger;
_barrel = 8 allObjects 0 inAreaArray barrel;
_selectionL = steve selectionPosition "gun";
_selectionV = steve selectionVectorDirAndUp ["gun","Memory"]; //parent vectors
{
_vDir = (_selectionV select 0) vectordiff (vectorDir _x); //child vector dir
_vUp = (_selectionV select 1) vectordiff (vectorUp _x); //child vector up
_relPos = steve worldToModel (getPosATL _x);
_x attachTo [steve, _relPos, "gun", true];
_x setVectorDirAndUp [[_vDir],[_vUp]];
} forEach _barrel;
steve switchCamera "internal";
player remoteControl steve;
trying to attach a load of objects within a trigger to a turrets barrel, attempting to get the correct vectors so they stay as they are when the attachment happens
this currently works to attach them to the turrets barrel, but they are all rotated wrong (presumably due to my bad vector math)
I have a request, do you know how to use a script to increase the volume of the environment played in the trigger??? 3d sound
You're comparing the selection vector (modelspace) to the object vectors (world space). You need vectorModelToWorld to convert the selection vector to a world vector before comparing it.
hello
how would one make a helo troop immune to damage untill they get out of the helo then be killable again?
use a getIn / getOut event handler:
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetIn
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#GetOut
Is there a script command to avoid the AI to get in inside all vehicles in his group ? Because when i put 8 soldiers on the ground and i add to that group, 2 vehicles like transport trucks or even Apcs like the Marid for example, the AI order to all units on foot to get in.
https://community.bistudio.com/wiki/allowGetIn
for the units of the group you don't want to get in
... hmm i whish i had the skill to understand that π¦
just say: "hey, would you mind writing it for me?"
hey, would you mind writing it for me? as im bad at arma scripts? thank you
oh ok thank you π
if (isServer) then {
this addEventHandler ["GetIn", {
params ["_vehicle", "_role", "_unit", "_turret"];
[_unit, false] remoteExec ["allowDamage", _unit];
}];
this addEventHandler ["GetOut", {
params ["_vehicle", "_role", "_unit", "_turret"];
[_unit, true] remoteExec ["allowDamage", _unit];
}];
};
put this in the heli's init box
that simple?
yeah, anybody that gets in is immune, anyone that gets out is not
no longer valid. Problem solved
like so?
_base = 8 allObjects 0 inAreaArray testingtrigger;
_barrel = 8 allObjects 0 inAreaArray barrel;
_selectionL = steve selectionPosition "gun";
_selectionV = steve selectionVectorDirAndUp ["gun","Memory"]; //parent vectors
{
_vDirRel = steve vectorModelToWorld (_selectionV select 0);
_vUpRel = steve vectorModelToWorld (_selectionV select 1);
_vDir = _vDirRel vectordiff (vectorDir _x); //child vector dir
_vUp = _vUpRel vectordiff (vectorUp _x); //child vector up
_relPos = steve worldToModel (getPosATL _x);
_x attachTo [steve, _relPos, "gun", true];
_x setVectorDirAndUp [[_vDir],[_vUp]];
} forEach _barrel;
steve switchCamera "internal";
player remoteControl steve;
Move the vectorModelToWorld conversion outside the forEach, you only need to do it once
_base = 8 allObjects 0 inAreaArray testingtrigger;
_barrel = 8 allObjects 0 inAreaArray barrel;
_selectionL = steve selectionPosition "gun";
_selectionV = steve selectionVectorDirAndUp ["gun","Memory"]; //parent vectors
_vDirRel = steve vectorModelToWorld (_selectionV select 0);
_vUpRel = steve vectorModelToWorld (_selectionV select 1);
{
_vDir = _vDirRel vectordiff (vectorDir _x); //child vector dir
_vUp = _vUpRel vectordiff (vectorUp _x); //child vector up
_relPos = steve worldToModel (getPosATL _x);
_x attachTo [steve, _relPos, "gun", true];
_x setVectorDirAndUp [[_vDir],[_vUp]];
} forEach _barrel;
steve switchCamera "internal";
player remoteControl steve;
That should be right
Please bear in mind that I hate maths, and 3D maths is obviously 3x as bad, so it's possible I'm wrong about some of this
_vDir and _vUp are already arrays, you don't need to give them more []. That just turns them into arrays of arrays.
_x setVectorDirAndUp [_vDir,_vUp]; ?
Yes
_vDir is literally the same as [x, y, z]. If you do [_vDir] that's the same as [[x, y, z]], which is not the array format the command expects.
That don't look quite right
Well, I tried my best and now I'm out of ideas. Good luck someone else π
no, it doesnt
maybe you should have named him greg
:despair:
ps. go accept the rules or whatever it is and you'll be able to post pics
this is my learning experience
agony
so my friend who doesnt know a whole lot about a3 scripting but has read the documentation suggested this:
vDir has [x,y,0], and vUp has [0,0,z]
so you need
newVectors [x1, y1, z1] = vectorModelToWorld [x, y, z];
vDir = [x1, y1, 0]
vUp = [0, 0, z1]
not correct syntax but the best way he could articulate the idea
any weighins while i write the code?
I didn't read the whole discussion but what you wrote here is wrong
im at a roadblock with this
trying to attach objects within a trigger to a memorypoint via attachto, but automating finding the vector so it just attaches everything without the need to do them individually
as otherwise it just rotates everything incorrectly
_base = 8 allObjects 0 inAreaArray testingtrigger;
_barrel = 8 allObjects 0 inAreaArray barrel;
_selectionL = steve selectionPosition "gun";
_selectionV = steve selectionVectorDirAndUp ["gun","Memory"]; //parent vectors
_vDirRel = steve vectorModelToWorld (_selectionV select 0);
_vUpRel = steve vectorModelToWorld (_selectionV select 1);
{
_vDir = _vDirRel vectordiff (vectorDir _x); //child vector dir
_vUp = _vUpRel vectordiff (vectorUp _x); //child vector up
_relPos = steve worldToModel (getPosATL _x);
_x attachTo [steve, _relPos, "gun", true];
_x setVectorDirAndUp [_vDir,_vUp];
} forEach _barrel;
steve switchCamera "internal";
player remoteControl steve;
``` curent code
_x setVectorDirAndUp _selectionV doesn't work I assume?
im attempting to make a dynamic set of tasks simply involving a set of vehicles being destroyed. the thing is i only want the task to complete if the player is the one who destroyed them,and the task cancel if it was anyone else
i cant find any info on condition if player does x
that works on vehicles and units or just units though?
yes all in editor
It works on all objects
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
private _task = _unit getVariable ["mytask", taskNull];
if(isPlayer _instigator || crew _killer findIf {isPlayer _x} >= 0) then {
_task setTaskState "Succeeded";
} else {
_task setTaskState "Failed";
};
}];
_killer could be a tank so that crew _killer findIf {isPlayer _x} >= 0 checks if any of the crew is player, in case player was driving and AI unit shooting or something
I guess you have your tasks setup through task framework or something so change that setTaskState to that instead
(This is a code bit for init field)
You'll need to set your ask to a vehicle as "mytask" variable btw
depending on how you setup your tasks
yep using it through task framework, thats awesome thank you il get to testing as soon asπ
hey, good morning!
i have a problem i'm not able to resolve.
we have special logic in our gamemode that a player character will not instantly die, but will enter an "incapacitated" state instead. a bleedout timer will start, and if the player is revived within it, he'll be back in business.
the problem is, that it works only once. during testing:
i throw a grenade at myself, it goes off, i go unconscious (perfect)
get healed by AI
i throw again, get again unconscious (also fine!)
a second later the game engine kills me
is there anything i'm not considering?
will throw some code here shortly
_unit addEventHandler
[ "HandleDamage",
{
private [
"_unit",
"_selections",
"_getHit",
"_selection",
"_killer",
"_projectile",
"_oldDmg",
"_curDmg",
"_newDmg",
"_EnemyDam"];
diag_log format["HandleDamage eventhandler invoked - unit %1 - killer %2", name _unit, name _killer];
_unit = _this select 0;
_selections = _unit getVariable ["selections", []];
_getHit = _unit getVariable ["gethit", []];
_selection = _this select 1;
_killer = _this select 3;
_projectile = _this select 4;
// Check if damaged part is already damaged
if !(_selection in _selections) then {
_selections set [count _selections, _selection];
// Add placeholder damage value
_getHit set [count _getHit, 0];
};
// this is used later to apply damage to AI soldiers (if non-lethal damage)
_i = _selections find _selection;
_oldDmg = _getHit select _i;
_curDmg = _this select 2;
if (isPlayer _unit) then {
diag_log format["Damage (%2) for player %1 would have been fatal - intercepting", name _unit, _curDmg];
_newDmg = 0;
if (local _unit) then {
private _incapSide = side _unit;
// here we handle that the unit goes into "incapacitated" state
[_unit, _EnemyDam] spawn fnc_enterIncapacitatedState;
[_unit, _incapSide, _killer] spawn fnc_onKill;
};
_newDmg;
} else { ... }
];
sorry for the formatting, let me try fixing this
i do have experience in software development, but quite new to Arma3 scripting - please forgive me any beginner mistakes in that code π
i checked the logs a couple of times and improved the logic, but it keeps happening, though the logs do now look as i expect them. i really have no idea what's going on. i would have expected the eventhandler ot intercept my death, pushing me to incapacitated state and removing damage from my unit.
thankful for any help!
Should be OK, he assigns stuff from EH into these privates later
Ah okay, that code is very hard to read
Another potential issue, game retains both EHs and variables on respawned units
So your "selections" and "gethit" from previous life would persist on respawned unit
not sure about it, but as the unit is not actually "killed", does it matter (as a respawn should only be applied to actually killed units, shouldn't it)?
let me see what to post from the incapacitated state code
Oh you didn't actually die, AI healed you
exactly!
Also I don't see _EnemyDam defined in your script
I'd suggest to just post the whole thing, would be easier to figure
pastebin for big chunks of code
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
for small
nice! thanks for that, i was already wondering how to achieve the highlighting! π
give me some minutes to prepare pastebin - and thanks for the assistance in advance!
one more thing - in order to give you more context, my brother and me are playing "The forgotten few 2" gamemode here - we love it, but didn't like the medical system, thus we decided to do some minor updates to it. so it's not all my code here, but i do understand it quite well so far. and one more disclaimer - we are only using the modified version for our private games ONLY (2 players + AI).
this is the code for the event handler:
and this is the incapacitated script:
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.
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.
Anyone got a pointer as to how to make these pretty white background squad overview tables you see in singleplayer missions?
Thanks, the name was completely gone from my memory for some reason π
Uff, really hard to figure it out. So your incapacitated state ends with setDamage 1 once it expires?
If you say death happens after some time, perhaps previous script causes it somehow?
I see that's it scheduled and there are some sleeps
Since you use unit variables, maybe you don't reset some after being healed?
Make a diag routing to show all your variables somewhere?
onEachFrame {
hintSilent parseText ([
"TFFG_fnc_ReviveSuccess"
,"someothervar1"
,"someothervar2"
] apply {
format ["<t size='0.7' align='left'>%1</t><t size='0.7' align='right'>%2</t>", _x, player getVariable _x]
} joinString "<br/>");
};
Further question about ORBAT
I want to load my own config, defined in description.ext for all player slots. I cant seem to get the correct syntax for the ORBAT Module. Can someone help me with that?
from line 276 a bleedout timer starts counting down. it's within a while loop here. and if that expires, the script continues, checking if the unit is still incapacitated and alive (meaning no first aid was applied -> bleeded out) - in this case it kills the unit by setting damage to 1
i'm currently not near my private laptop, in 2-3 hours i will be back and then paste the code of the revive action as well (from the top of my head, we deal with it - we re-set damage and "incapacitated" variables for the player after revival)
can it be that very severe trauma lead to instant death, regardless of that interception? somehow controlled by the game engine?
Cheers. I've used GPT and some less than basic scripting knowledge in my head to try & make a zombie script for public zeus as i cant find any online. Please don't hate me for using GPT. I did enough revisions to get the code to work with one exception. In the beginning there is a check for the zombies damage that, in case it did take any damage, changes the variables that declare the distances for the zombie to react to. However, when shooting the unit, it keeps behaving like before and for the love of god, i cant seem to figure out why...
Hello. Is there a way to disable 3rd person view only in vehicles? And when on feet 3rd person allowed
had a question,im testing a task system and i have a pretty simple one here,the task is to level a building and in trigger there is con: !alive h1
however this is satisfied before the house is FULLY destroyed
seems to trigger after the first level of desctruction is applied
is there an alternative to " !alive" for objects that satisfies once the house is caput? its an editor placed building
iv also tried "h1 getHit "dam1"==1" doesnt do anything in this case except removes the 3D task trigger when house is partially destroyed
Buildings get replaced with damaged version after certain threshold
I've used GPT
well...
it's possible only via the loop checking the current state of the player
something like
Marky_fnc_perFrameHandler =
{
if (player == (vehicle player)) then
{
// player is on foot, force FPV
player switchCamera "INTERNAL";
};
};
(personally I hate non-schedulled code)
alternatively you can use waitUntil:
waitUntil {call Marky_fnc_perFrameHandler; false};
so !Alive is basically returning that building is "not there" when a damaged model replaces the original hence the task completes
i thought this would be easy, theres then no way around doing this right?
But probably locking the the keyboard action is better in terms of resource consuming.
what does wait until do?
and how do i implement this codes ?
sorry im not so good at this
it waits until condition in the brackeds is true
addMissionEventHandler ["BuildingChanged", {
params ["_from", "_to", "_isRuin"];
}];
how would i call this effectively from a trigger con? my triggers are going to be synced to buildings for task marker positions
waitUntil {1 == 0}; // wait until 1 is equal 0 (never)
the idea of using waitUntil instead of PFH is how fast waitUntil evaluates the condition. It evaluates it in scheduled environment and each frame at maximum speed.
you need to add this to init.sqf or something similar
i see
then check if _from is one of your scripted\target buildings
like your example earlier
and maybe swap it in variables?
thanks man il experiment
Both methods are working, waitUntil is more resource friendly, PFH is reliable
addMissionEventHandler ["BuildingChanged", {
params ["_from", "_to", "_isRuin"];
if(_from == myBuilding && !_isRuin) then {
myBuilding = _to;
};
}];
well....
for example in the init.sqf after player init, add PFH handler with that code
init.sqf:
// by Prodavec
// Edited by Lou Montana
// Do not execute on HC or Dedi server
if (!hasInterface) exitWith {};
// Define the event handler
Marky_EachFrame_EH =
{
// if player is Null -> skip the frame
if (isNull player) exitWith {};
// if player is not inside the vehicle and the camera mode is 3rd person view -> force FPV
if (((isNull (objectParent player)) && {cameraView in ["GROUP", "EXTERNAL"]}) then
{
// player is on foot, force FPV
player switchCamera "INTERNAL";
};
};
// Assign event handler with its corresponding name
Marky_EachFrame_EHID = addMissionEventHandler ["EacHFrame", {call Marky_EachFrame_EH;}];
// execute this if you want to remove the EH and disable the feature
//removeMissionEventHandler ["EachFrame", Marky_EachFrame_EHID];
//Marky_EachFrame_EHID = -1;
are you making an addon or mission?
you can allow optics, right π
addMissionEventHandler ["EachFrame", {
if (isNull player) exitWith {};
if (isNull objectParent player && { cameraView in ["GROUP", "EXTERNAL"] }) then { player switchCamera "INTERNAL"; };
}];
it's just an example, because this code must be executed on human controled clients.
initPlayerLocal.sqf?
yep
(I think it also runs on Headless, beware)
addon
im so stupid lol
i dont understand how i implement this
edited the original code according to @winter rose proposition to allow optics view, credit added.
big thanks, no need ^^
where do i place this?
is initPlayerLocal.sqf working from the addon PBO? If yes, just put this code into that file
oh... and just in case it's headless client.....
wait so i create a text doc, copy paste the code above and name the text doc initPlayerLocal.sqf and then pack it into a pbo?
yes
pack and test
you don't need config
To use an Event Script, create a file of the given name in the mission directory.
well it seems it doesn't
testing now
I suppose initPlayerLocal.sqf doesn't work from the addon. You just need to test. If it doesn't fire, we will create config.cpp with CfgFunctions
Did not work
as expected...
sounds so confusing lmao
okay, create config.cpp defining your addon and add CfgFunctions section:
class CfgFunctions
{
class Marky
{
class MyInitFunctions
{
file = "functions";
class myPostInitFunction
{
postInit = 1; // postInit attribute
};
};
};
};
create file
<ADDON_ROOT_DIR>\functions\fn_myPostInitFunction.sqf
and put that code into the file.
@meager granite
on recent conversation, here's the script that handles revive action
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.
how do i define my addon and add cfgfunctions sections?
Try watching all your revive related variables and see what doesn't reset after a revive
I posted a snippet that hints variables each frame
for easy debugging
do i just put this code in the config?
oh i see
wait
nvm im stupid
config.cpp
class CfgPatches
{
class MarkyAddon
{
units[] = {};
weapons[] = {};
requiredVersion = 1.00;
requiredAddons[] = {};
};
};
class CfgAddons
{
class PreloadAddons
{
class MarkyAddon
{
list[] = {};
};
};
};
class CfgFunctions
{
// ...
};
my eyes π
what
(dark mode)
no I mean u need to insert the CfgFunctions posted above
thanks! i will do that and come back later
Functions
wait
alright let me post the full version.... wait a bit
yes but remove that CfgFunctions with // ...
looks good
nice i ill try now!
Don't forget to create a file
<ADDON_ROOT_DIR>\functions\fn_myPostInitFunction.sqf
with the code
u need to create the directory called "functions"
initPlayerLocal.sqf can be deleted
it doesn't work anyway
folder names "functions"?
yes
what do i type in fn_myPostInitFunction.sqf?
the code listed above )))
this one right?
yes
oh crap, I found a mistake π
if (hasInterface || isDedicated) exitWith {};
must be
if (!hasInterface) exitWith {};
! is missing.
!hasInterface only is required π
(a dedi doesn't have an interface either ^^)
see https://community.bistudio.com/wiki/Multiplayer_Scripting#Different_machines_and_how_to_target_them, I like this page :p
omg
bro
thank you
but i found ace has this function
i really appreciate your help! thanks bro
The snippet was indeed very helpful. But it looks like all the state variables around the incapacitation are maintained properly.
Can it somehow come from the game itself? Or another event is raised that i do not explicitly handle?
i'm really lacking more ideas to be honest, i've spent hours on that already and it seems like i haven't moved anywhere
so im making an arsenal with whitelists, and blacklisted bunch of shit. If i go to attributes in ace arsenal and do the same on all box, mission file will be huge. Any way to make the arsenal not have big file?
like by script in init or sum, i tried using ace framework but i got nowhere
indeed
this is the result:
i need the objects to maintain their current vectors from before the attach is run
@meager granite
allow me some minor final question please:
- when i blow myself up with grenades (or get hit with a tank shell, or whatever), is there any chance that any other mechanic kills me instantly if i am too close to the grenade? (that's how i did most of the testing)
i came to the conclusion that while my unconscious script is running, somewhere inbetween the unit is killed by the game - for whatever reason. logs do confirm that.
You could test with falling damage instead.
I don't recall units ever being insta-killed with grenades though.
Usual issue is that there can be multiple fatal HandleDamage calls for one hit, and they're not necessarily all in one frame.
But I haven't seen your script.
i have this code in the init of a unit but nothing seems to happen and i get no errors, anyone know why?
[this, "AmovPsitMstpSlowWrflDnon"] remoteExec ["switchMove"];
- init field may be executing too soon during mission initialisation, before the unit is actually capable of animating
- the unit may be immediately switching back out of the animation
- you don't need to remoteExec from an Editor init field. Init fields are already executed on all machines.
remoteExec in the init field is O(n^2) work.
Hey guys, how to make "else if" script ?
does this work :
if (blabla) then {blabla}
else if (blabla) then {blabla}
else if (blabla ......
else {blabla} ?
There is no direct elseIf in SQF.
You can nest another if within the else of a previous if, or you can use a switch structure.
e.g.
if (true) then {
// blah
} else {
if (_condition) then {
// blah 2
};
};```
<https://community.bistudio.com/wiki/switch>
Or you can combine the two, or find another approach that doesn't need elseIf.
or exitWith
private _value = call {
if(condition1) exitWith {result1};
if(condition2) exitWith {result2};
if(condition3) exitWith {result3};
if(condition4) exitWith {result4};
defaultValue;
};
alr thx guys
There's also the hashmap switch method if you really need something fast with a lot of cases.
so if i did something like
sleep 5;
this switchMove AmovPsitMstpSlowWrflDnon;
do you think that would work?
You can't sleep in an init field because it's unscheduled; you'd freeze the whole game so it doesn't let you. You'd need to use spawn to make a scheduled scope.
The animation name still needs to be a "string".
If this unit is meant to change animation at some point in the future, then don't use an init field at all. It's executed for all machines including JIP, so if someone JIPs later after the unit has changed to another animation, that will reset it back to the one in the init field.
its just like a general dead animation, but ill throw it in a spawn thing and see if that works
when something is not working for you which should work
write it yourself @hasty pond
been doing that, but this language I'm facing isn't familiar
@lunar mountain might happen if the server is running AI mods (or scripts), using HC etc..
Not running AI mods, but using HC. However I tried without HC too. Looks like the first waypoint always gets completed instantly, but not the others. Is it a problem if I'm using the same variable ( _wp) for all waypoints?
not if you're creating a new one, no
Obviously the variable changes after I set all of the waypoint parameters.
It is my first time working with AI and waypoints, but I hate it already :D
what mods?
As I said, not running any AI mods, completely vanilla
"been doing that, but this language I'm facing isn't familiar"
ehhh ... c/c++?
As Sa-Matra proposed, but for defaultValue; do not close it with semicolon. Alternatively you can use switch {true} do:
private _value = switch {true} do
{
case (condition1): {result1}
case (condition2): {result2}
case (condition3): {result3}
case (condition4): {result4}
default {defaultValue};
};
but call-if-exitWith is faster in terms of performance.
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
I suppose if units are in danger, they won't follow the order to move unless you explicitly tell them to ignore the danger.
Not sure.
Yes, it is sure. Please no questions
Also this line
{_x doMove (getmarkerpos "wp")} foreach units _grp1;
inside another loop
foreach units _grp1;
looks weird
{
// ...
{_x doMove (getmarkerpos "wp")} foreach units _grp1;
} foreach units _grp1;
For each unit of your group you goes through each unit of your group to order them to retreat.
I just don't understand why do you need to loop through the group to get count of the remaining units.
Maybe there must be kind of while {...} do loop, not forEach?
also take a look on this
https://community.bistudio.com/wiki/disableAI
and units MUST be local to the script
I mean, you cannot control AI from the server side if they are local to some player (and vice versa).
yup thx youu !
I corrected it but it still doesn't work: _grp1 = [getMarkerPos "spawnunits", west, (configfile >> "CfgGroups" >> "West" >> "CUP_B_US_Army" >> "Infantry" >> "CUP_B_US_Army_WeaponsSquad_OCP")] call BIS_fnc_spawnGroup; { _x setSkill ["general", 0.3]; [_x, "111thID"] call BIS_fnc_setUnitInsignia; _x setFormation "DIAMOND"; } foreach units _grp1; _grp1 setGroupId ["US Army, Infantry 893th"]; if (({alive _x} count units _grp1) <8) then {_x doMove (getmarkerpos "wp")};
does anyone have a solution?
I repeat without brainstorming, please only clean solution
also _grp move _pos works fine
Inb4 I spend a few hours on this tomorrow. Anyone have any advice for this? Vector math in A3 is definitely not my strong suit
nvm i got it
@hallow mortar as you hit a roadblock also:
_base = 8 allObjects 0 inAreaArray testingtrigger;
_barrel = 8 allObjects 0 inAreaArray barrel;
_selectionL = steve selectionPosition "gun";
_selectionV = steve selectionVectorDirAndUp ["gun","Memory"]; //parent vectors
_vDirRel = steve vectorModelToWorld (_selectionV select 0);
_vUpRel = steve vectorModelToWorld (_selectionV select 1);
_vDirandUP = [_vDirRel, _vUpRel];
{
private _vectorDirAndUp = [_x, steve] call BIS_fnc_vectorDirAndUpRelative;
//_vDir = _vDirRel vectordiff (vectorDir _x); //child vector dir
//_vUp = _vUpRel vectordiff (vectorUp _x); //child vector up
_relPos = steve worldToModel (getPosATL _x);
_x attachTo [steve, _relPos, "gun", true];
_x setVectorDirAndUp _vectorDirAndUp;
} forEach _barrel;
steve switchCamera "internal";
player remoteControl steve;
the key factor being https://community.bistudio.com/wiki/BIS_fnc_vectorDirAndUpRelative
simple as
there is some "fine tweaking" required but this was the major factor in getting about 90% of it working
yeah...
thanks for the reply, i completely missed it yesterday - sorry!
meanwhile, i finally fixed it by introducing a different method how damage is handled. it's a workaround, but works quite well. but I appreciate your help and will keep in mind for future issues!
BIS_fnc_unitCapture/BIS_fnc_unitPlay are linked to specific vehicles, right? as in, I can't just stick it on an AI driver in a dynamically created car?
oh
sweet
is there any benefit to keeping fps for it at 20? 5mb of data just for movement is a bit much π
i.e it interpolates between points right
Hey, does anybody have a script that can be put into hold action complete, which will remove the object?
Tried this:
deleteVehicle _this;
but that didn't work. It only works if I give the object I want deleted a variable name (hedgehog1) and put this into the hold action complete:
deleteVehicle hedgehog1;
It works on a small scale, but on a large scale it's gonna get too tedious setting the variable name for each singular hedgehog and changing the target every single time
_this#0 refers to the target object
Dunno, I honestly would write my own method tho...
i will find out
https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd
The holdAction completion code is provided with pre-named arguments, including a reference to the object the action is added to (_target)
yeah framerate of 2 gets really noticeable on corners
not only that but it makes the wheel screeching much longer for some reason too lmfao
anyone got an up to date syntax highlighter for VSC/notepad++?
sqf-vm, hemtt etc
that would be #server_admins I would wager
im having trouble disabling collision with the player object. my code: ```sqf
_pobj = createSimpleObject ["Land_Plank_01_4m_F", getposASL player, true];
_pobj disableCollisionWith player;
player disableCollisionWith _pobj;```
You don't need to do it both ways. The command already does that.
To my knowledge your issue is that you are trying to disable collision with a simple object and the player
Question how do i detect if a player has intel, like a laptop in his inventory, or files?
try createVehicle
Use in with items or magazines (yes, some inventory items of that sort are magazines)
hi need help with cfgsounds
ty
Can you be less specific, please?
class CfgSounds
{
sounds[] = {};
class burst_missile_global_sfx
{
name = "burst1";
sound[] = {"burst_missile_global_sfx.ogg", 1000, 1, 10000};
titles[] = {0,""};
};
};
I want to make my sound play over 10km and be heard from within planes
I run this command from a composition
playSound "burst_missile_global_sfx";
should I do it within the
forEach playableUnits;
playSound isn't a positional command. It will indeed be audible at over 10km; it will be audible everywhere as if it was transmitted into the player's brain.
Also, the volume setting is capped at 5.
ok i tried it one way first but that didnt work so i tried both ways
i tried createvehicleLocal first but same problem
since I run it in a custom composition so it's local compared to a trigger should I keep in the foreach loop?
If the custom composition is being placed by Zeus, then it is local and you'll need to remoteExec it to the relevant units. I would suggest doing it outside of any forEach and instead just use playableUnits as the remoteExec locality target.
If the custom composition is being placed in the Editor, then it is not local-only - init fields will be executed on all machines same as any other Editor-placed objects.
I'll post a pastebin
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
Doesn't change anything I said.
https://community.bistudio.com/wiki/remoteExec
Again, playSound is not a positional sound. When you do this, all players will hear the sound without any sort of 3D simulation - it will be as if it's projected directly into both ears at point-blank range. If that's what you want then OK, but some players may find this jarring.
I had someone tell me that the sound while I was testing in zeus the sound was getting fainter and fainter
so I should do something like
["burst_missile_global_sfx"] remoteExec ["playSound", 0];```
Yes, if you want everyone to hear the sound.
Well, it will be equally deafening literally everywhere on the map, and it will always sound like it's coming from inside your head. There is no positional simulation, no speed of sound simulation, and no maximum range.
It doesn't make any difference at all when using playSound because it is a non-positional command (you might have noticed you don't provide any position as part of the command syntax)
yes
The description.ext CfgSounds distance values are only used when using say3D without specifying any overrides
say3D doesn't use positions. It's used to make objects project a sound. You would need to create a dummy object at the position.
The alternative would be to use playSound3D, which does use positions, but doesn't use CfgSounds.
["burst_missile_global_sfx.ogg", 0 , false ,_newpos1, 5, 1 , 10000 ] remoteExec ["playSound3d", 0];
the 0 is where the object is
I don't have an object but I have a position which is _newpos1
is there an elegant way of defining if a vehicle uses Dynamic Loadouts?
because i'm using getAllPylonsInfo, if it returns !isNil, then it is a dynamic loadout vehicle 
you mean count == 0
that also works
command never returns nil
i'll take a look at the cfgs to see if I can use any hint from there
The proper way would be a config check
isClass(configOf _vehicle >> "Components" >> "TransportPylonsComponent")
this works very well and reads best
ty
https://community.bistudio.com/wiki/playSound3D
playSound3Dis Global Effect. You don't need to remoteExec it.- you cannot use
0as the object parameter because it requires an Object. 0 is not an Object. If you don't want to specify an object, useobjNull.
Also, the file path is wrong. playSound3D looks at the entire game folder structure, not just the mission folder. See Example 3 for how to use a file path in the mission folder.
I return in search of more answers.
Im trying to use attachto to put an object on a door. How do I get the doors memory point?
selectionPosition
That will return the modelspace position of the memory point once you have it (not actually useful for attaching things to the memory point). It will not help you get the memory point to begin with.
the names are like Door_1 , Door_1_trigger, etc
hmm ok sorry I had used that in my code but forget what it was doing π
i have ```sqf
private _pos = _bldg selectionPosition format [_x, _doorIndex];
private _doorpos = _bldg modelToWorld _pos;
maybe my code is buggy then lol
This is valid code for getting the world space position of the memory point from a known name.
It is not useful for attaching things to the memory point. When you attach things to a memory point, you don't need to know its position [except for copying relative offset from before the attach, if you want to do that], you need to know its name.
ah ic, im mixing mempoints and selections then
Same thing for this purpose
The real answer to this question is to either use selectionNames and code in the selection you want to attach the object to (easiest, harder to do dynamically for different objects), or use something like lineIntersectsSurfaces to get the selection the player is currently looking at (pain in the ass but doesn't need hardcoded selection names)
wouldnt attachTo to work with the offset instead than memory point? using selectionPosition as the offset
That would attach the object to the position of the door but not to the door.
right
It would still be attached to the main part of the parent object and wouldn't move with the door when it's opened or closed.
yeah would have to run loop or something to update the pos. unless there is no way getting open/closed pos
there is Door_1 , Door_1_trigger, Door_1_axis but i forgot what each one doesπ
i had to create the (plank) object at [0,0,0] and add small sleep after disableCollisionWith before moving the object or the player started riding the plank
can someone shine a light into this issue i'm having once again?
I have a function that adds a magazine to the turret of a vehicle once its current magazine runs out of ammo.
it works well until, for example, I spend all the magazines in a tank (HE, AP, HEAT)
after that, every single shot adds another magazine to the turret
if (_thisvehicle magazineTurretAmmo [_magazine, _thisvehicle unitTurret _gunner] == 0) then {
systemChat "No ammo on this mag!";
_currentTurretPath = _thisvehicle unitTurret _gunner;
_thisvehicle addMagazineTurret [_magazine, _currentTurretPath];
};
for some reason, this condition is always satisfied even after reloading with a new magazine created by addMagazineTurret
it is as if the Fired event handler's _magazine refers to the old, empty magazine
it mostly likely is this
finally, that did it. thank you removeMagazineTurret
fixed statement:
if (_thisvehicle magazineTurretAmmo [_magazine, _thisvehicle unitTurret _gunner] == 0) then {
systemChat (format ["No ammo on this magazine: %1", _magazine]);
_currentTurretPath = _thisvehicle unitTurret _gunner;
_thisvehicle removeMagazineTurret [_magazine, _currentTurretPath];
_thisvehicle addMagazineTurret [_magazine, _currentTurretPath];
};
if someone finds or knows a better way to do this let me know
"why not just set ammo to 100%/max value/etc" - that's because I want to force a reload, if anyone asks
I saw none. I think the loop is my best bet. Im trying to do dynamic.
Hello, please tell me how to specify the radius?
instead of 100 (_pos1 select 0)
_tomove = [14734.5,16693.3];
_pos1 = [100,[15166.4,16726.5,0]];
_pos2 = [250,[14665.7,16213.3,0]];
private _near = [];
{
_near append nearestObjects [_x, ["LandVehicle"], 100, true];
private _arr = nearestObjects [_x, ["LandVehicle"], 100, true];
{
if (_x isKindOf "LandVehicle") then {
_x setVehiclePosition [_tomove, [], 50, "NONE"];
};
} forEach _arr;
} forEach [(_pos1 select 1),(_pos2 select 1)];
As I wrote somewhere yesterday that I want the soldiers to move towards a certain point when the number of the group is less than 8 soldiers. I have the code in the trigger and it works perfectly, but how can I transfer this code to the script if there is no condition? I do not understand. Condition: ({alive _x} count units nato_units1) <8 and On Activation {_x doMove (getmarkerpos "mk1")} foreach units nato_units1; nato_units1 setSpeedMode "FULL"; nato_units1 setBehaviour "AWARE"; nato_units1 setCombatMode "YELLOW";
I see you, can answer when I get home later tonight.
how regulate a trigger sound? I need a radio with music for a mission and, when i spawned to test a few things, the trigger "radio" is fucking loud.. how fix it?
I made it! After many hours of coding and research, I solved the problem
this code looks like a mess π¦
you want to replace 100 to _pos1# 0?
why not just pass the whole var to the forEach?
{
_x params [_radius, _coords];
} forEach [_pos1, _pos2];
hey does anyone know if it is possible to create config files on the fly?
im digging through a mod that has thousands of configs that are needlessly bogging down loading times, so i wanted to look into creating them only as needed, thus allowing the mod to work right but not have a bunch of data that another dynamic server mod is pulling from and literally barfing out these ghost items that the player cant see the useable items through
the config.cpp is literally 99383 lines
If I understand your goal, here is what you'll get:
- will reduce no config load time, but only increase
- yes it's possible to hide or even delete some of things using a Mod
- there is no way to load dynamically created config
- loading data (as in, models or textures or such) does not increase config load time, are different things
you can update config in the dev branch
whats the best way to make something happen on key press knowing that the key is not mapped to some action?
"every frame on every projectile."
Every tracked projectile.
Which is local units (which in usual MP game is only one) or tracer rounds within 2km around player
Without semicolon:
"endExpression
push 2
push 3
callOperator +;
assignToLocal _result;
endExpression
getVariable _result;
"
With semicolon:
"endExpression
push 2
push 3
callOperator +;
assignToLocal _result;
endExpression
getVariable _result;
"
That would do a get request, and it requires you to have a UI.
He wanted a post request, and on server which doesn't have UI. So not really usable.
I don't know of a way without extension
Thanks for the tip, I'm just learning and trying to do something myself
hm
It was believed at one point that the returning statement should not have a semicolon ; after it; this is false and having a semicolon does not change anything and is recommended.
as I understand it's human-readable representation of the byte-code (or intermediate assembly code) and there is no difference between these samples.
curprev 18:36, 19 May 2014β Killzone Kid talk contribsβ 8,641 bytes +478β ββReturn Values: semicolon is not required
Good to know.
ACE/CBA still do it by code convention, to indicate that something is supposed to be a return value.
Its also good practice to prevent accident, because if you put code after the return value, it would be an error
diag_dumpScriptAssembly command is available to look at the assembly.
But the expression end marker is just empty string in that one
cant figure why I cant (fully) disable collision between player and object : ```sqf
private _pobj = createSimpleObject [placingObjType, [0,0,0], true];
player disableCollisionWith _pobj;
https://community.bistudio.com/wiki/Arma_3:_Simple_Objects
positioned - using setPosWorld (absolute world position); there are no land contacts that would allow using setPos or setPosASL like commands
Is _pobj local to the player?
It seems you're using 'local' parameter, but if that code executed on the dedicated server, it will fail.
all is local right now (from the editor)
i tried also private _pobj = createVehicleLocal [placingObjType, [0,0,0], [], 0, "CAN_COLLIDE"]; but same effect
"CAN_COLLIDE" disables checking with the other objects at the creation time
yeah i know
is player not null?
yeah its fine
probably this one: this command does not disable collision between PhysX objects
not sure
hmm i was thinking the same but it seems to work on editor placed object
well, I placed Sun Chair in the Editor and disableCollisionWith removes collision partially
it still is in effect somehow
yep im getting the same result. I can walk thru the plank object but I can also walk over it.....
also it behaves differently for the truck (C_Van_01_fuel_F) - it works perfectly, I can go through the truck model but for some reason Land_Sun_chair_F allows me to walk over it and even ramp up π
same results)
need some clarifications
looks like a bug, partially disabled collision
or in other words player's feet-ground contact code doesnt take disabled collision into consideration
Also I tried to climb on the truck with
player setPosATL ((getPosATL player) vectorAdd [0, 0, 3]);
but the collison doesn't work
yea it seems its the objects top surface that prevents player from falling through even collision is disabled
video of the bug
yep
is it possible to get a vehicle like the Slammer's Eden editor class?, it would, for example, be "Tanks"
I'm trying to make a script that classifies vehicles, however, they're a total mess to classify using isKindOf as some APCs are tanks, some aren't. blufor MLRS is artillery but of the MLRS type, Zamak is also rocket artillery but MLR type
oh yes editorSubcategory
that should work
The config viewer shows you the entire hierarchy
yeah but it's somewhat inconsistent
editor subcat is much more reliable, much better for mod compatibility too
that if they use the same category

Hi, I want to allow users to configure my mod. is there a native way to do it?
I'm trying to avoid cba_settings here
I am painfully aware and thinking of a workaround
maybe you can try using chat commands
but cba is by far the best and pretty much everything depends on it
and very simple to use too
@undone flower
so to clarify, arma has built in support for function comilation but no native mod configuration
i'm afraid you'll need to come up with a solution yourself because I recall trying to not depend on cba a few years back
but it's too much effort and bloat
so I just used cba
Depends on the type of mod i guess, if you have a missionfile you can just use description.ext.
It's an addon
Hi. Tell me please. How do I remove certain vehicle from the radar?
using same routines as CBA uses for /userconfig
could you clarify a bit more?
back in the days Arma community used
<ARMA_ROOT>/userconfig/your_mod/your_config.hpp
files to configure the mods
it is just SQF file (a header) with global variables which was parsed by your modification and the used as settings
This way has its own downsides
Users prefer fancy GUI over dealing with text files which are very sensitive to misstakes and spelling
And it is potential security breach. Because client has to turn of -EnableFilePatching option (and it must be allowed on the server).
without that option client cannot load code outside the packed (and signed) .PBO files
In short, its better to stick with cba for now
If you don't want to use CBA, you still have an option to use userconfig or implement your own mechanism
100% better unless you need something very specific
got it, thanks a lot
alternatively, make your own GUI which stores options into user profile
This is probably the "does not disable roadway LOD" note from disableCollisionWith's page
Anyone aware of an A3 script for a notebook similar to the one ACE 2 had?
What exactly do you want to achieve (haven't played ACE2 for years)
I'm working on a mission where a squad has to do battle damage assement on a crashed jet and I want to give them a proper form that needs to be filled out. Something to make them hang around while under fire
Theres a mod out there that lets you fill in a notebook, 9 liners, 6 liners etc
Mhhh, sorry I don't remember having seen something like that
@indigo snow Do you iknow the name of that off the top of your head?
9Liner ^^
Thanks
seems like the notes get saved to profileNamespace so you can parse what they wrote down as well
cool
general question: are add actions applied to units,such as an add action to recruit a unit with a distance of 5 meters, heavy on performance if applied to many units?
and does dynamic simulation have any effect on an add action in this case if so?
No. It's just a distance check, when you look at the unit (the condition is also checked once you're close enough)
But instead of that you can also add the action to the player himself and use cursorObject in the action condition to check if a unit is recruitable (it won't make much difference in terms of performance, but it's easier to handle than having potentially hundreds of actions)
cheers. i didnt know about CursorObject
in this case my units recruitable need a name in the addaction though
"co pilot" for example
this addAction
[
"Recruit co pilot",
{
{
[_x] joinSilent group (_this select 1);
_x removeAction (_this select 2);
} forEach units group (_this select 0);
},
[],
5,
true,
true,
"",
"_this distance _target < 3"
];
but if no hit on performance il use this way, only about 25 potential units to go through
what would the script be in order to fold the wings on aircraft
iirc you can use something like %UNIT_NAME (don't remember the exact words) to make it show the type of the unit (the one that shows under the crosshairs, in green)
nvm that was for comms stuff π
Depends on the aircraft
Normally they have an animation source for that
Right click on the vehicle in eden
Select find in config viewer
In config viewer, on the left hand side tree, go to AnimationSources and see if there's an anim for that
You can also check its UserActions
Got it, preciate
yeah i added ghost hawk doors
h1 addAction ["Open side door", { h1 animateDoor ['door_R',1];
h1 animateDoor ['door_L',1]}];
h1 addAction ["close side door", { h1 animateDoor ['door_R',0];
h1 animateDoor ['door_L',0]}];
not sure why actions like this arent default Arma3
as far as i recal even the Ifrit had anims for its boot(trunk)
You might want to add some additional conditions to that, such as a radius limit or a requirement that the player be in the vehicle - at the moment they could be opened from up to 50 metres away.
yep thanks man i know, iv tweaked it,just had that syntax close by
....or maybe its full of storm troopers and Darth vader is opening the doors for them π
beauty of Arma aye
no limits
SOO - I have a mission, Sound files and a small script to stop the death when you spawn - when i put them both into the ext they dont work - Whats wrong with this? π π
The sound files in my sounds folder and all thats set
(both bits work fine on their own but having them both in here breaks them both)
In what way does it break?
Those two items can coexist perfectly fine in description.ext and I don't see any issues with how they're written there
The respawn on start still makes me respawn and then the sound rubble comes up as not found - Theyre wrote the same on the mission, like i say they work fine individually they just dont like being there together
if:
- your sound is located in the Sounds folder inside your mission folder and is called
rubble.ogg - this is the only text in your
description.extfile - your
description.extfile is actually called exactlydescription.ext, notdescription.ext.txtor something like that - your code is correctly looking for the
"rubble"cfgSounds class (that is, using a command that looks at cfgSounds rather than sayplaySound3D)
then there shouldn't be any problem.
But surely if any of these was the issue the sound file wouldnt play if its isolated right? i took respawn on start out to test if maybe i wrote something wrong and it works just fine - Upon second test the sound file works W/ Respawn script - but the respawn script seems to not be recognized, confused as to why lmao - Heres the mission file, afaik everything works just fine
The description.ext is correct in all aspects.
The mission.sqm file is binarized so I have no idea what's happening there (that contains everything you've done in the Editor)
Thats why im confused lmao - As far as i see, it should work, but, well, it doesnt lmao, Im no code guy lmao
Is there an modelToWorld command with a position instead relative to an object?
hey guys. in a bit of haze here. the "playerViewChanged" event handler, ON DEDI. i was oh so sure i could use it for an auto view distance script. but it does not seem to recognize vehicles i go in until i drive them (take ownership)... which completely ruins the concept for me.
i've tried adding the event only to the server, nothing works (the "mission" event handler part made me thing it was.... well, to only be added to whoever is running the mission).
then i've tried adding globably. now i get the afore mentined ownership issue.
help???
also noticing objectParent suffers from something similar. returns the player if exec localy, and the vehicle if exec on server (all playable units are var named [s1, s2, etc])