#arma3_scripting
1 messages · Page 556 of 1
"generic errors" no
it also tells you the real error
show us the error
I assume it says "got array, expected object" right?
I'll have a look again later
Will be there a way to use vanila spectrum device's screen as a custom ui screen?
Its interesting that the screen seems to need PIP system but it works without PIP setting. What do we call such technologies? Is it something related to IGUI?
Is there a function in ace medical to get the wound status of a unit? as in, something like an array with each body part and its wounds?
@errant patio _damageArray = _unit getVariable ["ace_medical_bodyPartStatus", [0,0,0,0,0,0]];
👍 i found that a little while after and it's not great but it is something at least
I've started running into the issue mentioned on this page https://community.bistudio.com/wiki/getPlayerUID for both that command and name :/ does anyone know what the best, most reliable way to get a player's identity is?
ask him an id scan?
:p
you could "ask him" his playerUID, make him send it to the server
or on connection, setVariable it so the server can read it
🤔 i'll give it a shot. annoyingly hard to test bug sadly
I guess so yes - unreliable "safety" command…
according to what i've found and read it can cause issues when called on the same frame as a unit is created so. using waitUntil and asking the client to send it themselves is probably a pretty good idea
waitUntil isPlayer unit and getPlayerUID unit ! = "" ?
maybe. i just noticed that PlayerConnected lets you read their name and uid so i'm going to try using that information instead.
in my rigorous testing of one attempt, it at least works as well as before so that's good lol. Hopefully it holds up, it's fairly important :/
I've seen a lot of people use compileFinal with large strings but why doesn't people use compileFinal preprocessFileLineNumbers file.sqf?
Is there a specific reason or just personal preference?
@mint kraken we use this on every mission)
?
With preprocessFileLine i mean
I have not commonly seen that either. There's no specific reason to that I can think of (except laziness or wanting more in one file).
Functions Library is the other common choice (and mine):
https://community.bistudio.com/wiki/Arma_3_Functions_Library
hmm, ok thanks!
personal un-preference I guess
people who just don't know are everywhere
and the people who know, will probably just use CfgFunctions
Still working on upgrading OCAP replays. Want to detect placed mines. The problem is, that in ocap every entity gets unique id via setVariable. but mines, as part of CfgAmmo cannot get that. Did anyone tried to overcome this? Thought about detecting a mine, while it's not armed, so it's a part of CfgMagazines
Hey @still forum , talking about my issue yesterday, I took a look at it and you're right. It did indeed say 16:58:05 Error additemcargoglobal: Type Array, expected Object
You happen to know how to fix that?
If it's an array of objects, a loop.
You were passing an array
not your target
you need to pass _target instead of [_target]
Hmm, so you mean just params "_target"; rather then params[ "_target"];?
addItemCargoGlobal ["rhs_weap_rshg2",1];
this works fine
[3, [_target], {
Should be:
[3, _target, {
For example.
Alright, I think I understand, i'm just rather new to coding
this works fine
no it doesn't missing left parameter, thats a syntax error
ok, its working, thanks for the help!
_NewVehicle addEventHandler ["ControlsShifted", {
params ["_vehicle", "_activeCoPilot", "_oldController"];
If (_vehicle isKindOf "air" and (roleDescription _activeCoPilot != "Pilot")) then {
["Apenas pilotos podem co-pilotar aeronaves"] remoteExec ["Systemchat",_activeCoPilot];
[_activeCoPilot, ["SuspendVehicleControl", _vehicle]] remoteexec ["action",_activeCoPilot];
};
}];
this script does not work in dedicated servers, the player can still get the control of the helicopter, whats wrong?
Where are you running that? On the server?
This event handler will always fire on the PC where action is triggered as well as where the vehicle is local at the time. When control of the vehicle is shifted, the locality of the vehicle changes to the locality of the new controller. For example, if helicopter is local to the server and co-pilot takes controls, the helicopter changes locality to co-pilot PC.
is on the server, the _NewVehicle was created by the server
Then that's your issue.
So, the event handle is useless simply because its depends on locality to fire?
You'd have to add it to them when then get in that specific heli afaik
Hm is there a command to make the mine dispensers fire?
setDamage 1 should activate it
hello.i am trying to fix something that worked in 1.94 and now it doesnt ;)
i am getting an array of certain buildings on the server to later spawn a script forEach of them ```sqf
global_object_array_var = [];
_houses = nearestTerrainObjects [
[worldSize/2, worldSize/2],
["house"],
worldSize,
false
];
{
if ((str _x) find "shed" >= 0) then {
global_object_array_var pushback _x;
};
}foreach _houses;
publicvariable "global_object_array_var";```well i figured that i cant spawn stuff on them client side (but want to) because my array returns a list of "NULL-Object" entries on clients.what can i do to solve this?or is it because its terrainobjects?
createVehicleLocal involved?
terrain objects are local yes
Question: How do I execute a script depending on a units next waypoint name?
Intention: If unit spawn_heli_vehicle's current waypoint is spawnDespawnWP I want to execute a script, else I want to execute a different script.
Current code: sqf if (spawnDespawnWP == currentWaypoint spawn_heli_vehicle) then { [] execVM "onPlayerKilled.sqf"; } else { player moveInCargo spawn_heli_vehicle; player assignAsCargo spawn_heli_vehicle; };
Could you give an example, @winter rose? I'm simply too inept to figure it out on my own though I am trying.
I suppose this would work:sqf private _currentWP = currentWaypoint spawn_heli_vehicle; if (waypointName _currentWP == "spawnDespawnWP") then { // bla } else { // bla };
Thank you kind sir.
drag_evh = (uiNamespace getVariable ["lega_vehicle_shop_paint_display", displayNull]) displayAddEventHandler ["MouseMoving", {
params ["", "_dx", "_dy"];
if (dragging) then {
private _distance = (missionNamespace getVariable ["lega_vehicle_preview_cam_dis", 10]);
private _object = (missionNamespace getVariable ["lega_vehicle_preview_object", objNull]);
private _direction = ((missionNamespace getVariable ["lega_vehicle_preview_cam_dir", objNull]) + _dx);
private _camera = (missionNamespace getVariable ["lega_vehicle_preview_cam", objNull]);
private _cur_pos = (_object modelToWorld [0, _distance + _new_y, _distance * 0.3]);
private _coords = [_object, _distance, _direction] call BIS_fnc_relPos;
_coords set [2, (_cur_pos # 2)];
_camera camSetPos _coords;
_camera camCommit 0;
missionNamespace setVariable ["lega_vehicle_preview_cam_dir", _direction];
};
}];
``` have a clean x rotation around an object, was wondering how I would impement the y dragging around the object, tried a few things, not been able to get it working.
Unfortunately it didn't work, trying a few other things as of right now.
More specifically it spits out the following error message:
currentWaypoint: Type Object, expected Group
therefore since you are trying to get the waypoint of a object rather than using the id of a waypoint you could get the pilot group
_pilotGroup = (group (driver spawn_heli_vehicle));
_currentWaypoint = currentWaypoint _pilotGroup;
_pilotGroup = (group (driver spawn_heli_vehicle));
private _currentWaypoint = currentWaypoint _pilotGroup;
if (waypointName _currentWaypoint == "spawnDespawnWP") then
{
[] execVM "onPlayerKilled.sqf";
}
else
{
player moveInCargo spawn_heli_vehicle;
player assignAsCargo spawn_heli_vehicle;
};``` Like this?
If yes, doesn't work.
But hey, at least it now complains about line 3 instead of line 1 😄
Progress!
waypointName check is wrong
_wpName = waypointName [_pilotGroup ,_currentWaypoint];
if (_wpName == "spawnDespawnWP") then
No errors, testing again to make sure.
Hm, doesn't work 100% but that could due to tiredness. Gonna get some sleep and pick up where i left off tomorrow, see if it makes more sense to me then.
Thank you for your help though, @frozen knoll @winter rose
regarding my camera question, this is the best i got with it so far https://gyazo.com/1572fc0cc94657ab14692ca9fbd1585b
nice
is there an easy way to sort an array and store the index shifting of the elements?
easier than keeping a copy of the original array sorting then finding index on copy of the original with find?
Hello folks,
I'm having an issue trying to get random weapons and their corresponding ammo into a loadout script for players. I've randomised backpacks, headgear and uniforms without any difficulty but the weapons have me stumped.
I've tried a dozen different iterations of selectRandom and weapon arrays but still can't wrap my mind around it. Any help would be appreciated...included is the latest iteration I've tried:
_wep_01 = [
"player addWeapon 'rhs_weap_ak74n';",
"player addPrimaryWeaponItem 'rhs_acc_dtk1983';",
"player addPrimaryWeaponItem 'rhs_30Rnd_545x39_7N6M_AK';",
"for '_i' from 1 to 10 do {player addItemToVest 'rhs_30Rnd_545x39_7N6M_AK';};"
];
_wep_02 = [
"player addWeapon 'rhs_weap_ak74n';",
"player addPrimaryWeaponItem 'rhs_acc_dtk1983';",
"player addPrimaryWeaponItem 'rhs_30Rnd_545x39_7N6M_AK';",
"for '_i' from 1 to 10 do {player addItemToVest 'rhs_30Rnd_545x39_7N6M_AK';};"
];
//SELECT RANDOM WEAPONS
_weapon = selectRandom ["_wep_01", "_wep_02"];
Maybe try randomizing it with a number?
if (_random > 49) then {
loadout1
};
if (_random <51) then {
loadout2
};
etc
Atleast thats how I would do it @opal turret , though i'm hardly a scipting progidy
private _weapon = selectRandom [
["rhs_weap_ak74n", ["rhs_acc_dtk1983"], ["rhs_30Rnd_545x39_7N6M_AK", 10]],
["rhs_weap_ak74n", ["rhs_acc_dtk1983"], ["rhs_30Rnd_545x39_7N6M_AK", 10]]
];
_weapon params ["_weapon", "_items", "_mags"];
player addWeapon _weapon;
_items apply {player addPrimaryWeaponItem _x};
for "_i" from 0 to (_mags # 1) do
{
player addItem (_mags # 0);
}
``` would have to do some error checking in that though.
See what Leigham just wrote is just confusing to me with my limited knowledge 😛
private _weapon = selectRandom [
["rhs_weap_ak74n", ["rhs_acc_dtk1983"], [["rhs_30Rnd_545x39_7N6M_AK", 10]]],
["rhs_weap_ak74n", ["rhs_acc_dtk1983"], [["rhs_30Rnd_545x39_7N6M_AK", 10]]]
];
_weapon params [
["_weapon", "", [""]],
["_items", [], [[]]],
["_mags", [], [[]]]
];
if !(_weapon isEqualTo "") then
{
player addWeapon _weapon;
_items apply
{
player addPrimaryWeaponItem _x;
};
_mags apply
{
player addMagazine _x;
};
};
``` would probably be a little better.
@dire hearth your script would necessitate whole separate loadouts and would be perfect if you only wanted a couple, however the script I'm working with has a selection of 20 uniforms, 15 vests etc. Thank you for your help though!
@wary vine that looks pretty damn good mate. You're using the one format I haven't tried. I've been basing it on the code exported from the virtual arsenal...which might be my issue.
Fair enough, gl with it 🙂
@wary vine you nailed it. There was a little alteration needed, it didn't like the mag number being included in the array but with a little adjusting it works perfectly. Cheers.
Here it is with the modification:
["rhs_weap_ak74n", ["rhs_acc_dtk1983"], "rhs_30Rnd_545x39_7N6M_AK"],
["rhs_weap_ak74n", ["rhs_acc_dtk1983"], "rhs_30Rnd_545x39_7N6M_AK"]
];
_weapon params ["_weapon", "_items", "_magazines"];
player addWeapon _weapon;
_items apply {player addPrimaryWeaponItem _x};
for "_i" from 1 to 10 do {player addItemToVest _magazines;};```
@opal turret player addMagazine [_magazines, 10]
Anyone happens to know how I add ace actions to a AI in a car? I'm able to add the actions to themselves when they are outside of the car. But I also want a action to be available when they are inside the car, same way the actions like "get out" are available
@velvet merlin
turn your [a,b,c] array into [[a,0], [b,1], [c,2]] then sort, it will sort the inner arrays based on first element, and youll have the original index in second element of the subarray
good thinking. ty
// Server Only Execute
if(!isServer) exitWith {};
//Parameter init
params ["_animation"];
//Checks animation played
if (_animation in ["ace_gestures_hold","ace_gestures_holdStandLowered","gestureFreeze"]) then
//Stops car
{
_car = nearestObjects [player, ["car","truck"], 12];
{if (side _x == civilian) then {_x disableAI "PATH";}} forEach _car;
};
//=====================================================
//Checks animation played
if (_animation in ["gestureGo","gestureGoB","ace_gestures_forward","ace_gestures_forwardStandLowered"]) then
//Gets car to go again
{
_car1 = cursorTarget;
if (side _car1 == civilian) then {_car1 enableAI "ALL";}
};
I got this script working with this event handler:
["ace_common_playActionNow", {(_this select 1) call fw_fnc_gesture;}] call CBA_fnc_addEventHandler;
Works in SP, doesnt work on the server, anyone happens to know how to fix that?
do you add this EH on the server itself? isn't the EH local to the unit?
you are running a script only on server
but you use player inside the script which is invalid on a server 🤔
cursorTarget is also not valid on server
and playActionNow looks to me like it would run clientside
guys, has anyone worked with inpolygon? can I provide the positions to the command in any order? Would it be better to provide them in a clockwise direction?
clockwise or counter-clockwise I would say, just not random order 😄
ok thanks. i need a 6 point shape.. a rectangle with a gentle bend in it halfway down
so 2 rectangles touching end to end, but not quite in the same dir
oo yes
it gets weird if you dont provide them in a sensible order
ugh, it's too complex, im making the polygon in code and getting its points in the right order is faff
easier to have 2 rectanlges and have
inarea rect1 OR inarea rect2
@still forum sorry didnt come round to check for replies here.actually i thought so but wanted to make sure,thanks for the replies.
i tried a workaroud through remoteExecing this on clients uding something like thsi sqf { [] spawn { for "_i" from 1 to 5 do { playSound3D ["tzr\tzr_audio\nuclear_boom.ogg",_x,false,getpos _x,15,0.8,10000]; sleep 9.5; }; }; } forEach tzr_siren_sources;but this will throw undef var in exp "_x".can playsound3d not be executed foreach?
you are not passing _x to the new script instance that youre spawning
so "[_x] spawn..."?
ah there we go,thanks.its always the "little" things^^
I haven't studied the arma config sciences properly, but why does "ACE_quikclot" call bis_fnc_itemType return ["Item","AccessoryBipod"] 😦 or how do I universally get item type in this game?
(reliably at least for base game stuff + ace)
NVM I will ask that at ACE slack probably, unless you really want to reply to me
because its a bipod
previously it was a mine detector.. but that caused medical items to accidentally act as... mine detectors..
so it was changed over to bipod
But wasn't there a way to configure it to... something else?
item type is an integer or what is it? 🤔
YES
Do you guys know how to go about targeting the pilot camera in a script
it doesn't appear to be a seat of its own
Hello,
Hoping you folks will be able to help me again. I'm trying to get a variable passed in an eventHandler but can't get it to work properly. If I put the variable in the init.sqf and make it global it will work for the event handler but not rest of the script...heres the example:
UCShotsFired = 0;
//EVENT HANDLER FOR SHOTS
{
_nearEnemy = nearestObjects [_x,["Man"],250];
_x addEventHandler
[
"FIRED",
{
if ((east countSide _nearEnemy) > 0) then
{UCShotsFired = UCShotsFired + 1}
}
]
} forEach allPlayers;
waitUntil {UCShotsFired > 1};
{_x setCaptive false} foreach allPlayers;```
Do you want it to exit the waitUntil if any player fires?
Because a global variable is still local to a client, you might want to remoteExec it to server and public variable it from there @opal turret
@finite jackal Hey mate, I don't mind how it get's exited, one player, all players, doesn't matter at this stage as I'll be modifying the rest after I get my head around this issue.
All I want is for the variable UCShotsFired to be recognised in both the EH and the waitUntil. I can get either, but not both. The script is executed only on server.
if that script is going to your servers init,
UCShotsFired = 0;``` is local to the server
and all code excecuted in that eventHandler is local to the client
`object-based Event Handler is always executed on the computer where it was added.`
so UCShotsFired is undefined on clientside
You will need to define it in something like initPlayerLocal (or define it in your forEach allPlayers), and RE the value to the server for it to update that waitUntil on the server
@opal turret
Also did not notice this, but the server init will excecute before any player joins(roughly as soon as you boot the server up), you must add that EVH client side or have some kind of waitUntil/sleep because no players will be connected when that excecutes @opal turret
UCShotsFired = 0;
publicVariable "UCShotsFired";
@finite jackal Firstly, thank you for your help.
Secondly, If i were to put the above script segment into the initPlayerLocal, made UCShotsFired private, and included a loop to check the status of UCShotsFired, would that be sufficient?
@frozen knoll sorry mate, I'm having a hard time figuring out how to implement that into the script??
//COUNTER FOR SHOTS
UCShotsFired = 0;
publicVariable "UCShotsFired";
//EVENT HANDLER FOR SHOTS
{
_nearEnemy = nearestObjects [_x,["Man"],250];
_x addEventHandler
[
"FIRED",
{
if ((east countSide _nearEnemy) > 0) then
{UCShotsFired = UCShotsFired + 1;
publicVariable "UCShotsFired";
};
}
] ;
} forEach allPlayers;
waitUntil {UCShotsFired > 1};
{_x setCaptive false} forEach allPlayers;
@frozen knoll Thank you for that. Just wasn't sure where to rebroadcast the publicVariable. It's no longer throwing undef var errors at me.
Still not working though. I think there may be an issue with _nearEnemy.
slight edit
if ((east countSide _nearEnemy) > 0) then
{UCShotsFired = UCShotsFired + 1;
publicVariable "UCShotsFired";
};
yeh have a look at nearEnemy
ill read over the rest shortly to see if i can notice anything for u
@frozen knoll thanks again. Player starts as captive, EH is supposed to kick them out of captive if they fire in proximity to opfor, it's just not kicking the player out of setCaptive though.
just the player fired near or all players ?
or is there just 1 player in this mission?
In its current iteration, all players
looking at it _nearEnemy is defined outside of the eventhandler
Can you define a variable inside an EH?
it can be a local global var
since its just ran local
nearEnemy instead of _nearEnemy
it will just update as forEach loops
@frozen knoll still no good I'm afraid. I'll have to come back at it when I can concentrate. Cheers again for the help bud.
On the server
is the whole thing on server?
another thing to note
with
_nearEnemy = nearestObjects [_x,["Man"],250];
outside of the event handler it will only register that first postion
bring it inside the event handler so it checks every time fired is triggered
Yup. I brought it inside the EH but not sure how to call the players position. Can't use _x, or player.
i really would add the eventhandler to the player client side
so each player has it added on connection
//server side
UCShotsFired = 0;
publicVariable "UCShotsFired";
waitUntil {UCShotsFired > 1};
{_x setCaptive false} forEach allPlayers;
//initPlayerLocal
waituntil {!isnull (finddisplay 46)};
player addEventHandler
[
"FIRED",
{
_nearEnemy = nearestObjects [player,["Man"],250];
if ((east countSide _nearEnemy) > 0) then
{
UCShotsFired = UCShotsFired + 1;
publicVariable "UCShotsFired";
};
}
];
you could even go with
//server side
UCShotsFired = 0;
publicVariable "UCShotsFired";
...it works! Awesome work mate. You're a legend
//initPlayerLocal
waituntil {!isnull (finddisplay 46)};
player setCaptive true;
player addEventHandler
[
"FIRED",
{
_nearEnemy = nearestObjects [player,["Man"],250];
if ((east countSide _nearEnemy) > 0) then
{
UCShotsFired = UCShotsFired + 1;
publicVariable "UCShotsFired";
};
}
];
waitUntil {UCShotsFired > 1};
player setCaptive false;
ha sweet was typing up that alternate options aswell but all good
- maybe remove the eventhandler once its fired
Yeah, I'll be adding that next.
awesome man all the best
Can somebody confirm a suspicious bug?:
Do this disableCollisionWith veh; this disableCollisionWith player; in Init for 2+ units, where veh is a vehicle, and the commands aren't executed properly for units expect placed last guy.
In my case, I placed player, 3 units and a Marshall named veh and do the same commands and in the preview the player is “ghost” for these units but veh isn't “ghost” for 2 units who placed firstly
productVersion = ["Arma 3","Arma3",197,146060,"Development",true,"Windows","x64"]
Can you have multiple of the same event handler assigned to the same object?
E.g. if I want to catch Killed multiple times with different results
Yes @plucky wave
is there a way to get a players armor rating? or total allowed damage based on their gear? i cant find a function using basic searches.
You can read the armour value from the config
probably would need a more complex calculation based on hitpoint health values and gear armor damage reductions. Question is, is it worth it?
do you need to know if you die from the next pistol body shot or not?
Hey, perhaps someone could explain this to me. I'm creating a ACE action to call upon a script. Using the call function. I want to attach two paramaters to that.
_action1 = ["sr_checkDocuments", "Check documents", "",{[_target, _unit] call fw_fnc_checkDocuments;}, {_checkDocuments = _target getVariable "documentsCheck_done";isNil "_checkDocuments";}] call ace_interact_menu_fnc_createAction;
[_veh, 0, ["ACE_MainActions","ACE_Passengers", str _unit], _action1] spawn ace_interact_menu_fnc_addActionToObject;
Now the issue is, the _unit variable here is a object, but when I go into the actual script and try to hint it.
// Server Only Execute
if(!isServer) exitWith {};
// Parameter init
params ["_target", "_unit"];
It complains _unit is a number rather then a object, anyone has any idea why this happens and how to fix it?
// Server Only Execute
if(!isServer) exitWith {};
can't work.
ACE actions are only executed on clients
so unless you are in singleplayer, or playing a self-hosted MP game by yourself that cannot work
[_target, _unit] call fw_fnc_checkDocuments;
_unit is undefined
Surely the script it calls upon can be server only? Won't it otherwise create stuff for server+every player?
don't understand why its telling you that its a number
Surely the script it calls upon can be server only? it only runs on the client executing the action.
Won't it otherwise create stuff for server+every player? no.. I don't see why it would?
only valid variables in fnc_createAction are _target and _player.. aand _actionParams
Imagine there is more stuff above that script, _unitis defined as a object
The formatting of that code is top notch
Imagine there is more stuff above that script, _unitis defined as a object
doesn't matter.
The code of the action is a new script
not in the context
local variables carry over into lower scopes, but not into entirely new scripts
Aah, I see
https://ace3mod.com/wiki/framework/interactionMenu-framework.html just read this whole page
_action1 = ["sr_checkDocuments", "Check documents", "",
{
// this will be in a new context and the local variables defined outside won't work
[_target, _unit] call fw_fnc_checkDocuments;
},
{
// same here
_checkDocuments = _target getVariable "documentsCheck_done";
isNil "_checkDocuments";
}] call ace_interact_menu_fnc_createAction;
[_veh, 0, ["ACE_MainActions","ACE_Passengers", str _unit], _action1] spawn ace_interact_menu_fnc_addActionToObject;
Ok, makes sense
Same thing as with eventhandlers
actions are actually eventhandlers
So the ACE action can only pass over the _target _player and _actionParams?
// this wont work either
private _friend = call some_fnc_getMyFriend;
player addEventHandler["DoStuff", {
hint name _friend;
}];
So the ACE action can only pass over the _target _player and _actionParams?
no
As I said and linked above. Read that page
you'll find out how to pass parameters by yourself
I most likely won't since I don't understand, hence the question
Nope, I can honestly say I have no clue how to pass on any other variable but _target and _player
Sry but wiki is down
is disableSerialization only meant to work in spawned scripts? Or does it also enables saving non-serializable stuff into missionNamespace in event handlers?
non-serializable stuff cannot be saved
Yes I meant setting missionNamespace variables
disableSerialization just makes sure your whole script instance is not saved, instead of variables
unscheduled code is never saved
as you cannot save a game while they run
as they freeze the game while they run, so the game cannot freeze in that time
thus disableSerialization not a thing in unscheduled
yeah I get that, thanks!
I thought it meant like 'from now on don't warn me any more when I save dumb stuff into missionNamespace' but appears it's not like this then, thx
Does anyone know how to make something like this? Is it hard to make something like this? I just wanna see if I can make it for free. If not I’ll pay for it. https://imgur.com/a/cXI8NNS
Do you mean UI? Yeah you can for sure, CBA has features to let you override standard displays
If you have never worked with UIs, then the proper word is not "hard", probably there is not even such word 🤔
You can have a look at #arma3_gui , I think we have discussed this topic some time ago in it
@patent moat its rather easy but you still need to understand what you are doing... i recommend doing a mockup in photoshop to plan how you want it to look... create the basics of it via the gui editor and then style it via dialog file and code to function as intended
example of something ive made similar following that process
https://imgur.com/a/X6XvlRl
How can one increase (via mod or otherwise) the default right click view zoom level?
without altering the normal fov
mod yes ; 👉 #arma3_config I think @mortal wigeon
hey there! do someone knows how to turn off the fireplace effect (any fire) to give damage when unit is close? Im gettting damage by fire from absolutely stupid distance.....
no can do from script, beside making yourself temporarily invulnerable with allowDamage or turning the fire off with inflame @lucid junco
Is there a disconnected event handler? So if i'am pressing abort a script can be executed?
Run code on client or on server? On server this should do the job: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#PlayerDisconnected
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#PlayerDisconnected
However this only works on MP and will only trigger when someone leaves the server (?)
I need it on both, SP and MP and on player side. I'm trying to use a recursive function with CBA_MissionTime atm, but it is not the preferred way
I can explain it a bit. I have a radio that I can turn on inside a mission. But my problem is that you can't turn it off as soon you are out of the mission. You need to close the game to end the radio stream
But the disconnect event is kinda random for every client
I just a "trigger" that says me, hey I'm out of a mission
Yeah I understand, I will need to solve a similar problem soon.
So is "ended" event handler not doing the job for you?
I don't think so. I mean if you disconnect before the mission is ended, there is still a problem
Is exist any article about level streaming realization in RV engine? GDC presentation, etc
you mean like how the engine does it?
Yea
its not really scripting/modding related tho
and its not probably public information
Since you know RV isnt open engine and the big terrains is one of its trump cards
I suggested that this thread is most closer to my question :D
Sometimes devs publish some information about their research in computer science, on GDC for example
Hello fellow people im back from the dead
does anyone have a script or a good way of telling for the AI if they are under fire? (especially sniper fire)
i hate if players outrange the AI and they do nothing. so i want a script to detect them being fired upon
suggestions?
also i need that part for a more complex "entrenched ambush" and "hit n run" enhanced ai script
The only thing I've found is to use a handledamage event handler to alert the group if a unit takes damage. The FiredNear event handler (@ wiki) has a hard-coded limit of 69m
That said, the AI seem to be pretty good at determining if they are under attack, the problem you may be seeing is that the shooters are far away enough that the AI can't effectively engage the target
I'm looking forward to the further development of this FSM - https://forums.bohemia.net/forums/topic/225402-lambs-improved-dangerfsm/
I've got a question regarding getUnitLoadout;
at the moment I use it to create ACE Arsenal default loadouts in combination with CfgRespawnInventory (get loadouts and add them to the list).
This works like a charm, however the function seems to have issues with custom weapons and backpacks (due to attachments and inventory).
Is this normal behaviour, or is it simply because I set the scope to 1 (so it doesn't show up in Arsenal, but is available for my custom faction)
that AI mod looks promising. will keep an eye on it
sadly not what im looking for
im trying to determine if they are being attacked BEFORE they take damage. a player who notices bullet impacts at his feet wont stay still, unlike the ai
getSuppression? Also AI will react to flying bullets / impacts on the ground
@spark turret
iirc getSuppression just spikes on bulletimpact and returns to zero a second after which makes checking it rather performance heavy
hmmm wait i got Brightcandle to include a custom suppresion value in his mod for me
there it is:
"Took a little longer than I hope as I hit a bunch of dumb issues and problems. Releasing now, [_unit] call CF_BAI_fnc_getSuppression; //gives you a value between 0 for no suppression and 1.0 for maximum suppression." - BrightCandle
mod is cf_bai
Guys. I added to my dialog
url = "https://www.google.com/"
How to make the site open in Steam overlay.
dialog? Steam overlay?
#arma3_gui, but…
@winter rose I for button added url. My site opens in the browser Google Chrome. I need it to open in steam overlay.
you sure its even possible?
opening random websites from the game seems like a big welcome to abusing it
@young current I don't know. That's why I ask)))
That's not a thing afaik.
spamming teamkillers with popup ads lol
^ That is a thing.
We can't attachTo to a house from the map, but can to a house placed in the editor. Is it a known bug or am I not reading the wiki properly again?
You can, you just need to find the object, ie:
_house = nearestBuilding player
player attachTo [_house, [0,0,0]]
Huh, I say that, but in testing it doesn't seem to work.
terrain objects != objects
I suppose you could get around it by getting the class name of the house, its coordinates and direction, delete the house and create your own
why would you even "attachTo" to something static?
it won't ever move anyway, just setPos it
If it's an object that's affected by gravity, you'd need to use attachTo if it's ... precariously positioned
why would you even "attachTo" to something static?
unless when it's destroyed, it gets moved under the ground together with all my attachments 🙂
but yeah I have worked around that by using a bunch of modelToWorldWorld, vectorModelToWorld, etc
Might be worth placing a note on the wiki about it...
New to all of this, but is there any scripts I can use in the editor to raise or lowered the sea level? AKA, flood terrian or just flat out lower the sea level?
I have heard that you can do it through mods, but I am trying to avoid using extra mods at all costs.
Hi there! Do you guys have an idea how to pass the string from this mission.sqm line into the script environment?
onActivation="call{call line1;" \n "call line2;}";
i am accidently passing that with
_statements = triggerStatements _x;
_statements params ['_cond','_activ','_deactiv'];
...
text format["onActivation= %1;",str _activ] call KK_fnc_makeFile;
but i cant do that on demand, i.e.
(missionNamespace getVariable ["__temp", ""]) + "\n" + str _this
hi all, when does a compileFinal stop being final?
1 - Mission End
2 - Mission Restart
3 - Server Restart
4 - A.N.Other
compileFinal where? On the server or a client?
server - dedicated
Server or client doesn't make a difference.
If it's saved in mission namespace, that gets cleared at the end of the mission. UI namespace remains until you shut down Arma.
The short story is: They stay as long valid as the namespace it is attached to lives
Server or client doesn't make a difference.
Sure does. If the client leaves the server, the mission on the server didn't end, but the namespace should have, no?
If anyone is interested, there's a way using .net core to create cross platform extensions(C#).
The same code can be compiled without any 'adjustments' both on linux and on windows. It can be then called as an extension from arma engine.
Here's the repo for an extension template: https://github.com/DardoTheMaster/ArmaDotNetCore
Obviously you will need to have .net core sdk in order to compile it to a shared library.
Shortly, this is a good way of doing extensions if you do want to stick with C# , but this really has no sense if you already code in c/c++
That's cool but unfortunately will be lost in this chat after a few days, consider posting it on the forum @jovial nebula
Yeah sure just wanted to check it was actually something useful 😂
I have created a feature request for all the spawn enthusiasts: https://feedback.bistudio.com/T146326
@jovial nebula https://community.bistudio.com/wiki/Extensions
@astral dawn kinda feel like this only ever is useful case by case
What do you mean?
Changing it for All will just lower the fps
A single spawn May needs a higher count
Aka
An array variant of spawn would be more useful
There is only a single VM though, and the whole VM controls the time available
Isn't my suggestion is more like changing the int const vmTimeFrame_ms = 3; to a variable which can be edited through the SQF command?
Ok, but max value is a const I assume? It must have some threshold after all beyond which it doesn't run more per frame>
no
How does it work then if it's not the no more than 3ms per frame as advertised literally everywhere? 🤷
its a global int
which gets changed by the loading screen up to 50
and down to 3 at end of loading screen
Well ok, IIRC there might be more 'contexts' in which this is changed, like the init sequence of a mission, etc
Doesn't seem likely right now, but maybe others might need it on client 🤷
Also I'll need that for HC to be fore precise
It's the binary made by you, no?
originally yeah
But now do BI make it for all versions too?
no
So...
Anyway in my tests generally FPS is below 50 although still OK, I don't think this is a viable option really
lowering your fps further while youre already low isn't a good idea
I knew you'd say that but still!
well i wish you luck getting that command
So to sum it up, do you think that it can be done, is it hard to do, and how likely anyone at BI will bother to do it?
sure it can be done. its easy to do.
likelyhood: 0%, its a stupid idea and gives so many people to ability to break even more crap
if you want I can give you a server binary with 50ms limit ¯_(ツ)_/¯
But I won't have the time to update it so whatever
spawn without arguments would be nice (the same as call)
I would not call this stupid due to it giving ability to break crap. There are so many ways to bring FPS down already by scripting.
like.. ever seen a while true loop without a sleep?
most newbs write scheduled scripts, meaning most bad scripts, are scheduled.
But thats not a problem because thanks to the 3ms limit they can't break that much
now you want to give the idiots the ability to disable the 3ms limit and let everything go ham
I'd assume it to have some reasonable limits actually
Seems to make sense 🤷
is it a bug that if ... exitWith within an apply block seems to be too aggressive, IMO. in other words, exits the entire calling scope, not just the apply. In this case, however, I think we can apply the conditional transform something like this, if ... then ... else as the closing statement.
As I have observed, scheduler won't run my stupid crap for some time if FPS has been brought down by scheduled scripts low enough, but I don't have a solid evidence of that
correct
So it must be a bit more advanced internally
I wrote a blogpost about the depths of the scheduler
Never saw it, could you share?
Carefully and biologically produced Arma 3 sqf training site
@dreamy kestrel I guess so. But also exiting a "apply" is what I would consider undefined behaviour. apply applies a function to an array, and returns an array of the same size. It cannot return same size if you abort in the middle.
Also I don't see what the reason for an exitWith is
if you want to check whether array contains some element, use findIf
I've read your article, interesting. I thought that scripts suspended with waitUntil take the priority in the queue (at least on wiki it says that arma will try to evaluate my condition mostly every frame)?
I didn't get the point of your mention(?) @queen cargo
you may want to edit the biki page if you got something new
he prolly cant
is it possible to sync locally executed variables with global?
how
publicVariable?
Should I use getArray or BIS_fnc_getCfgDataArray for configs?
I would say to stick to getArray, unless you expect it to maybe be a string or something else.
Alright, thanks!
Anyone have experience with the select random script? I created a script thats meant to move an object to your or somewhere around your general area depending on a random event. I just want to know if it will work. Anyone able to take a look at it?
sure such thing is possible
Can I send you the script then?
no, put it into pastebin and link here.
I wrote most of it myself based off of BI's website
The setPos however I did not write
Just edited
so what seems to be the problem then?
I was wondering if it would work, I havn't had too much success with the randomSelect. I understand it calls for a random variable from an array but I havn't had it actually do something.
soo you have not tested it?
Not yet. I don't want to get people together to test something just so it wouldn't work.
xP
well I suppose it could work then
someone else might actually run that in their mind and figure out if it works
you should be able to run that by yourself though
put in some debug hints in different phases to see if they go through etc
you could use switch instead of the ifs though
hrmmmmm I didn't know about that command. That would make it nicer looking wouldn't it.
Hello. I'm trying to run a script on a dedicated server, from a client. The script runs, but doesn;t seem to be passed any parameters. Form is:
{ [_veh, _calledby] execVM "hH_moveRespawn.sqf" } remoteExec ["call", 2];
Hi! Any idea why this doesent work?
vehicle player addMagazineturret ['Redd_Mg3_Mag_120',[0],10];
vehicle player loadMagazine [[0],'Redd_MG3','Redd_Mg3_Mag_120']```
@worn flame I'm not sure but I don't think _veh and _calledby are not defined in the called statement. You need to pass the parameter with the remoteexec too, first try to replace [_veh, _calledby] with _this. If this doesnt work try [[_veh, _calledby], "hH_moveRespawn.sqf"] remoteExec ["execVM", 2];
@calm bloom I'm not sure which MG3 you wanna use but i used the AI version to test and got a magazine classname of Redd_Mg3_Belt_100_ai and a weapon classname of Redd_MG3_Static_ai.
And tested
vehicle player addMagazineturret ["Redd_Mg3_Belt_100_ai", [0], 10];
vehicle player loadMagazine [[0], "Redd_MG3_Static_ai", "Redd_Mg3_Belt_100_ai"]
and this worked
Hm, interesting
Have your turret weapon got other magazines?
I was trying to make fake reload animation on turret with empty magazine
For all turret magazines use magazinesAllTurrets vehicle player;
For all turret weapon names use weapons vehicle player;
For reload use reload player;
@spice axle That did it, thank you.
For some reason my selectRandom script is not able to determine "Able"
Thats the script
"Able" != Able
So take the " " away?
If you want to select from an array of presumably undefined global variables, sure
I want them to be more local variables so that way the same variables can be used on other clients at the same time
A few things: ```1. You're missing a semicolon in the first line of your code.
2. You should read up on the difference between Local, Global, and Public Variables.
3. A switch statment would probably be a cleaner way of doing this.
@still forum to be clear, I am not just exitWith {...} with no result.
which in an apply {} I would take to mean, one of the transformed results.
even if that is nil
that being said, was able to work around it with the verbose if .. then .. else ternary statement.
you could do
appply {call {if () exitWith...; other stuff}}
I'm sure I'm making little mistakes here, like a missing semicolon or something, but I'm just not sure where- https://pastebin.com/fPVeNpEg
what is the returned error @vernal venture ?
It said "missing ;" at the "if side" line. which is why I thought it was literally missing a semicolon.
Yes
Inside the If statement is a code block and a code block does not return a Boolean then it is not called
you are literally missing a semicolon
line 15, missing semicolon
and yeahalso that wrong code block in line 4, that you will get warned about when your script first executes
Also you have a typo in "Initialized"
Problem solved. Thanks for the proofread.
Is it possible to remove one of an item inside a players inventory? E.g. player has 3 smokes and I want to decrease this to two?
at the start of the mission or as a trigger further down the line? @plucky wave
Further down the line @red meadow
https://community.bistudio.com/wiki/removeMagazineGlobal smokes might be magazines I think 🤔
Was hoping so, just couldn't find any docco on it.
I'll give it a test, cheers fellas
Why 3 times if he only wants to remove one?
Is it possible to check if a building has a ladder on it?
check selectionNames for "ladder" maybe
no dice :(
apparently selectionNames doesn't look at all LODs according to the wiki comment? that sucks :(
tru
but it should look at the mods that matter?
maybe you can try finding the buildings config class? is that a thing?
first building i tried it on that has a ladder only returned doors and doorhandles
maybe selectionPosition with some commonly used names for ladders
i'll try checking the config yeah
yup, looks good. Buildings have a Ladders[] property so i can just check if it's empty or not
@still forum , on the forum you mentioned binary params should be bool and not just 1/0 or some arbitrary name. Is that correct? And if so do we,
If (_binaryPARAM==true) then {//stuff};
like that or is there a different syntax?
if (_booleanVariable) then
if needs a bool, if you already have a bool, then ==true makes no sense
okay so just the boolean Variable, thanks I'll play around with that
potentially stupid question - but why does:
if (true == true) then {systemChat "success!"}```
throw an error?
Error position: <== true) then {systemChat "success!"}>
Error ==: Type Bool, expected Number,String,Not a Number,Object,Side,Group,Text,Config entry,Display (dialog),Control,Network Object,Team member,Task,Location
Error in expression <if (true == true) then {systemChat "success!"}>```
this only just occured to me, but it looks like it's not possible to compare booleans with one another, which seems... odd?
disregard - apparently it's just the == and != operators that don't work; isEqualTo works fine
What Dedmen is trying to say is that you can't == true, you just use this method to detect true/false
if ( myTrueVariable ) then {systemChat "success!"}
Or if you're looking for false,
if ( !myTrueVariable ) then {systemChat "success!"}
my line of code was just an example, the actual use case was to check if two boolean variables had the same value (similar to how a XOR gate works):
if (_oldState != _curState) then {
systemChat "Status changed";
_oldState = _curState;
};```
something that wouldn't be a problem in other languages
but it's a moot point - I'm now using isEqualTo instead
How to open tailhook_door_l ?
@gleaming cedar you need to explain that question to me. which door is that, a vehicle one? then you should start with animateDoor
@spice axle I want to open de door on the aircraft carrier
The thingy that opens when an airplane takes off
It comes off from the ground
hello, i was hoping someone could answer a few questions about the implementation of scripts by explaining to me the process of applying a particular script. it would highlight the parts of the process that i find difficult to get started
http://www.armaholic.com/page.php?id=23967
i understand it requires three units, named something particular, but how do i link them in the code?
i know exec vm calls the script but... wheres the REST OF THE OWL
i have all the scripts in the mission directory already
like... it mentions "FO"= but where do i put that?
people forget what its like to not know something they became an expert in lol
FO seems to be a guy with a laser designator: FO"=
Forward Observer: The "FO" will report all targets to the "FDC".
For best efficiency use units with Rangefinders or Laser Designators as they tend to spot more reliable.
"FO"s won't call for a fire mission if the spotted unit is closer than 250m.
If all "FO" units get killed the "FDC" won't receive anymore targets.
Since I'm on my phone I can't open the script rn but I'll have a look later
... @fervent kettle please tell me that was sarcasm
@heavy pendant What?
Copy pastingstuff from the armaholic page isn't useful at all?
not really... i have already read that so iti snt TOO useful
Welp then i got the question wrong
im just trying to figure out how to go from point A to point J without skipping the letters inbetween
SO
I have THREE units
and some kinds of scripting that LINKS them
i have the knowlede of how to CALL the script but not how to IMPLEMENT it
you put FO or whatever name you used in the script into the units variable name, do you mean that?
no offense @fervent kettle but i have little faith you are going to be able to understand what im asking after that
you`ve asked before where you should put FO
ok.... lets try this another way! HOW would YOU put this in a mission?!? STEP BY STEP
DONT
SKIP
ANYTHING
- I copy the files from armaholic into my Arma 3-Missions folder
- I check how the variables are defined in the SQF files
- I place the units IG and give them the names I`ve defined in the SQF file (for example FO. the observer is defined as FO so i put that in the variable name in a recon)
- Testing and fixing
in the Init.sqf the first line says "null = [[Monitor1],["FO1","FO2"]] execVM "LFC\feedInit.sqf";null = [[Monitor2],["Artycam","Artycam2"]] execVM "LFC\feedInit.sqf";"
FO1 and FO2 are the observers so you put FO1 in one recon and if you want FO2 into another one
and I make the init.sqf myself?
no it is in the ZIP file you downloaded from armaholic
you can find it in the Altis demo mission folder
naw dude thats what is causing the confusion i think
it doesnt come with that, i have to make my own
welp for me it came with it so i wonder why you dont have it
i just downloaded it again... no init.sqf
you go into the GOM_FSS_DemoV103.Altis folder
lots of "GOM_FSS_xxxx" stuff
oh....
hold on let me sdee how stupid i am give me a second
if you unzip you get 2 folder and 1 .pbo
as mentioned above: copy the Init.sqf from the demo mission into your own one and the contents from GOM_FSS also
you can then delete the lines 2-9 from the init .sqf since its just text from the author you probaply dont want in your mission
and all i have to do to use it is name units the right thing, have files in the imssion directory, and have that line in the init.sqf?
very simplified, but yes
yeah i was losing my mind because i couldnt see tht file lol
i made an empty init.sqf and forgot and thought the one in the archive was empty
thank you
np
i am going to find this dude and have them add at least that because this script is somerthing new people are going to see quickly lol
id like the ability to stop the arty by shooting ONE GUY
You can find him on BI Forums, hes active every day
does player hasWeapon work in multiplayer?
yes
thanks
https://community.bistudio.com/wiki/hasWeapon @smoky verge 😉
yeah I'm on that page but honestly does it say it anywhere?
wanted to check there before asking but in the Multiplayer part it just says " - "
I constantly forget that there is a "Multiplayer" part under additional info
I have never seen anything written there
I guess its just used for stuff that work differently in mp
which is usually written in the notes or description
indeed
well, thanks for the rapid answer anyway
@smoky verge Argument Global, so yes
I have never seen anything written there
I have; I was there, Gandalf! 3000 years ago
private ["_whatever"] is how you get objects from a higher scope into your script as a local variable right? so its like the command line argument variable?
params*
so when you call null = [[varA],["var1"]] execVM "xxxxxx.sqf"; it feeds varA and var1 to xxxxx.sqf as private ["_asdf", "_qwer"] ?
^ Private array is bad, and anyone who uses it should feel bad
context and circumstance defines tyhe usage of all code
Nah, private array is just bad
@heavy pendant params , not private
But you want Params
["one","two"] call fn_someFunc
//fn_someFunc
params ["_one","_two"];
sigh the higher complexity is nice but I miss modding homeworld 2 with lua lol
I mean, you could always go full Arma 2 and just use = _this select # for however many lines. 😅
No don't do this please, use params
BUT... private accomplishes that same thing as params? because I need to know that before I go changing this and forgetting I changed it and confuse myself again lol
No
Private just says "this is a private local variable", it assigns no value
Params makes a variable private and assigns it a value from _this (or whatever you want if you use a left argument)
this working script does not have "params" and is receiving params... how is this?
oh _tjhis is array?
_this
It's a magic variable, which is an array of all things passed to the function, yes
Well, not necessarily an array
so when calling with execvm it magically passes the params as an array named _this ?
yes
all parameters are passed to the function with the magic variable _this
If you pass multiple parameters, _this is an array. If you pass a single parameter, _this is just whatever that was
so when is params needed? to reassign as local? why not use private only then?
[1,2] call {_this}; //[1,2]
1 call {_this}; //1
because you can define default values then the parameter is not passed, define allowed data types or filter the array or single value problem
ohhh for better context
Also because it's significantly faster from a performance standpoint
Like
1 call abc_fnc_abc;
// inside abc_fnc_abc
_this // 1
[1] call abc_fnc_abc;
// inside abc_fnc_abc
_this // [1]
but
1 call abc_fnc_abc;
// inside abc_fnc_abc
params ["_number"];
_number // 1
[1] call abc_fnc_abc;
// inside abc_fnc_abc
params ["_number"];
_number // 1
you see the difference?
[1,2,3,4,5] call someFunc;
//This is good
params ["_one","_two","_three","_four","_five"];
//This is bad for the same result
private _one = _this select 0;
private _two = _this select 1;
private _three = _this select 2;
private _four = _this select 3;
private _five = _this select 4;
so im seeing this script can be really streamlined right from that alone
As for private array being bad, use private as a keyword instead, it's faster even if it doesn't look like it
But params makes variables private by default, which is another reason it's good
You see the difference here?
[1,2,3] call abc_fnc_abc;
// inside abc_fnc_abc
params ["_one","_two","_three"];
_one; // 1
_two; // 2
_three; // 3
call abc_fnc_abc;
// inside abc_fnc_abc
params [
["_one", 1],
["_two", 2],
["_three", 3]
];
_one; // 1
_two; // 2
_three; // 3
i hate how even though i can read it all its stil gonna take a month to learn it
And chances are that if your script is old enough that it's not using params, it's going to be running much slower than it probably should be because of other reasons
I wouldn't know; I'm an accountant not a programmer. I only know sqf 😅
to achieve the same result as params you have to do
private "_one";
if (_this isEqualType []) then {
if (isNil {_this select 0}) then {
_one = myDefaultValue;
} else {
_one = _this select 0;
};
} else {
if (isNil "_this") then {
_one = myDefaultValue;
} else {
_one = _this;
};
};
usually, competant programmers can read other languages pretty well when they get familiar with several languages
oh no, he mentioned it...
hahaha yeah lolcat is old now
well i guess this is the first .sqf batch going to my github rofl
to be never finished
how do i do code tags?
on github?
you can type sqf after them for syntax highlighting, but encase your code in three tilde's top and bottom ```sqf
```sqf
your code
```
private ["_getrndreloadtime","_FDC","_grouptype","_radiochatter","_debug", "AND_SO_ON"];
_getrndreloadtime = 6;
_FDC = _this select 0;
_grouptype = _this select 1;
_radiochatter = _this select 2;
_artyready = _this select 3;
_debug = _this select 4;
_rnds = 4;
yes right format but false code
Looks about like most things that exist for Arma
why no best practices ;_;
at least line up the text for readability
"=" at the same column position
Combination of poorly informed "coders", and an ever changing codebase.
The fact that findIf wasn't a thing years ago still baffles me
well to be fair you need newbies for innovation
and bad language is "challenging"
that last one was sarcasm lol
If you don't have it bookmarked yet, absolutely bookmark the Biki - https://community.bistudio.com/wiki/findIf
Any errors or ambiguously worded explanations are solely Lou's fault and responsibility. :p
when calling a script with execvm, does the compiler allow you to specify which variable you are assigning? EG.
null = [ _asdf = [Monitor1], _qwer = ["FO1"]] execVM "GOM_FSS_FO.sqf";
I don't think this will work:
private "_one";
I think it would need to be
private ["_one"];
either use
private _one;
or
private ["_one"];
wait... the wiki ways that private "_varname"; also works...
Personally I don't understand the hate on the private [] command, as it's useful to declare at the beginning so you can keep track of what you'll use. Also if I'm going to assign a value to a local variable later on with an if statement or the like, I'm not going to waste time assigning it some nonsense variable
It's the fact that between params and private keyword, there's much better ways of doing that same thing
You don't strictly need private to assign a value, you can just do
_value = "1";
which is the same as
private _value = "1";
Second is faster
Well I do have to type in six whole characters, which isn't faster for me 😛
Seven, if you count the space
defining privates beforehand is slower than setting each variable private on its own, but when a lot of variables need to be set private it will be slightly faster
That code optimization for private looks like if you're assigning many variables ... yeah that
yall are like, super awesome helpful. I like this place.
But for just a single variable I doubt there's a significant difference
It's like old school IRC
ICQ 😛
@worn forge use private, unless you want to take the risk of overriding a previously defined variable of the same name
I do use private, mostly for personal sanity
I don't think this will work:
private "_one";
I think it would need to be
private ["_one"];
it is not a matter of belief, it is a matter of wiki 😛
The fact that it has a code optimization benefit was previously unknown to me, so win x2 😛
lol it depends onwhat you are doing, you should always go for performance and readability unless the context calls for deviation
Well, when I say "think" it's because I haven't personally tested it, but I seem to recall getting an error when I did that by accident once.
I'd be curious what the private command is actually doing, because it's clearly populating a value of some kind into the variable, enough so it's not nil
readability > performance
@winter rose I tend to agree
better to overbuild than over engineer, you dont have to be afraid of lots of text if its formatted well
https://community.bistudio.com/wiki/Code_Optimisation
Make it work
Make it readable
Optimise then
I would know, I wrote the page
Like I said, any Biki issues are your fault lol
well i meant dont use things obviously unperformant because its easier to implement
@exotic flax private _one; thats bullsh. you are calling private command, on a undefined variable.
@worn forge
But for just a single variable I doubt there's a significant difference
for a single variable the difference in % is the same as for a hundred variables.
Just fully expect that when you post questions here asking how to make it work, you'll get advice on all 3 steps at once
The only thing I would say is that understanding good patterns in advance will save you a lot of time reworking for optimization later
@still forum I know, it only works when setting the variable. Although reading wiki can help
What you mean is private keyword
@still forum I think the point I was trying to make is that yes, there is a quantifiable performance benefit, but if you are shaving 0.0004ms off the execution time because you defined a single variable with the private function, you won't be throwing a party for yourself
its a "modifier" for = operator.
without = that makes no sense
but shaving of 1000000 x 0.0004ms because it's in a loop does help, especially when you have a lot of variables
.... yeeeeeeeesss, that's what I previously agreed to, I am talking about a single variable
in a loop it might be more efficient to just move the variable into the scope outside the loop
Problem is private array, private array ALWAYS makes stuff slower, instead of faster
even with a single variable
That kind of performance gain may also be more useful in something that's executing rapidly (onEachFrame, for example)
thats why its bad practice and everyone doing that deserves to be called stupid or unwilling to improve on their coding ability
Well, we're lively in here today.
A couple of obvious observations.
- If you're defining 100,000 variables, you have bigger problems than use of the private function.
- If you're defining private variables in a scope that's repeated often (onEachFrame) there's probably a better way to do it like a global variable.
I for one will be happy to say that I learned something today.
well , im going to make this my personal project because its really neat to have a fire support system that uses observers and relays insterad of spawning shells
theres ALiVE for the player side but nothing for the OPFOR
there's probably a better way to do it like a global variable.
global variables are WAY slower than local variables
A simple
private _myVar = MyVar
and then using _myVar will make your code faster
Sorry that some of us work on mods (ACE,CBA,TFAR,ZEN,ACRE) where such performance does really matter.
Quick question, how do I run a script only if a variable name does not exist?
isNil "_myVariable" // returns either true or false
lol vcomAI mod does what i want and more
Hi guys, so I'm trying to create a fire extinguisher with some particles. However the particles won't change their angle.
Here is my code:
extinguisher = "Land_FireExtinguisher_F" createVehicle [0, 0, 0];
extinguisher attachTo [player, [0, 0, -0.2], "RightHand"];
extinguisher setDir 90;
extinguisherSource = '#particlesource' createVehicle (getPos extinguisher);
extinguisherSource setParticleParams [["\A3\data_f\Cl_water", 1, 0, 1], "", "Billboard", 0.1, 1, [0, 0, 0], [0, 5, 2], 0, 10, 1, 0.075, [0.3, 2, 4], [[1, 1, 1, 1], [1, 1, 1, 0.5], [0.5, 0.5, 0.5, 0]], [0.08], 1, 0, "", "", extinguisher];
extinguisherSource setDropInterval 0.05;
Any ideas on that problem? I can't seem to fix it.
I've checked the directions and both, the player and the particlesource directions, are the same
but you need to set the direction of the particle not the source
oh okay now I get it
@heavy pendant vcom AI is great, but it's resource intensive. On our 60-player server running I&A it took the client's FPS down to a crawl. On a smaller op with about 20-30 clients and far fewer enemy units it wasn't as strong a performance hit. So it really depends on your use
How to open tailhook_door_l
Can someone explain why the angle parameter on setParticleParams does not work? At least in my code above. I don't understand how I should set the dir of the particle in any other way.
anyone know a way to make ai not target a player other than setcaptive true. when i use setcaptive true then players side changes to civilian.
disableAI
i wrote a custom incapacitated script and the last piece is to get ai to stop shooting the player when incapacitated but i dont want to set the player to captive.
Why don't you want to set the player to captive? Ie., why do you need them to retain their side
Does setCuratorCameraAreaCeiling use a height ASL/AGL, or relative to the position of the camera area?
I would say AGL, but I don't know for sure (the wiki is blank about it)
time for science I guess
tell me the result of your experiment so I can enrich the wiki 😉
so ATL above ground and ASL above water?
wut?
interestingly it still seems to be AGL over water
@worn forge i plan to make missions for small 1-6 person teams with a zeus
the zeus can play alongside lol
Then Vcom's gonna be great for you 🙂
haha yeah, I hate PvP. PvE is more relaxing considering my mental issues rofl
i like to think i can add a TON if resource hogging stuff if I keep the player base small also
What's the best way to make a simple variable final? Obviously you can use compileFinal but then you have to use call every time you want the value - is that the only way?
@errant patio yes thats the only way currently
ah well, it could be worse. ¯_(ツ)_/¯
Is there a script to turn off auto contrast on thermal imagers? Real IR sensors can perform a Non Uniform Correction to adjust for changes in ambient temperature. It’s frustrating to see individuals as bright spots and having a completely washed out terrain/buildings.
@errant patio see Code Optimisation for "constants" through Description.ext
Not ideal, but another way too
@void delta nope
Try maybe setApertureNew
I'll give that a shot. Thank you.
@winter rose Where do I need to put that script to get it to change anything?
Anyone got an example of a working addAction using BIS_fnc_MP?
@void delta you would have to detect when your camera is in thermal mode, then use this
I'm pretty new to scripting. Do you know how to detect when in thermal mode?
I appreciate all the help
check camera mode, on wiki (I am on mobile rn)
Don't k ow if this is what you're looking for: https://community.bistudio.com/wiki/currentVisionMode
Yep, there is no "camUseTI", only camUseNVG
But you can use a number to set the state of the nvg
I appreciate the help
Quick one, may be the wrong place to ask but does anyone know the locality of ace actions? If you add an ace action to an object does this need to be run once server side or per client on client side?
Can't tell you but if in doubt, it's useful to check their source code
Trap been a while since I used ace but I think ace actions are client side
Is there a trick to using removeAction that I'm missing?
this removeAction 0;},0,0,true,false,"","_this == IDAPMedic"];```
every action added increases action id
change:
this removeAction 0;
To:
(_this select 0) removeAction (_this select 2);
Aha
Trap:Anyone got an example of a working addAction using BIS_fnc_MP?
That's an old implementation for multiplayer, use remoteExec or remoteExecCall instead. For what you're asking:
[player, ["<t color='#FF0000'>This Useless Action Is RED</t>", {hint "RED"}]] remoteExecCall ["addAction", 2]
adds the action to all players and not the server.
@plucky wave ace actions are local
@worn forge & @spice axle Thanks for confirming. Did some further testing and can confirm, they're local. Which is unfortunate
Just use remoteExecCall to push them to clients as you need
It’s really simple to add them locally forEach one, but remove it for everyone expect one
Or if it's on a mission-placed object, you put the code in the init segment
No don’t do that pls
😛
Use the initPlayerLocal.sqf
Obviously depends on your level of scripting and intended use, using init is an acceptable solution
Implemented with CBA event handlers
But a really bad for, especially for actions like ace actions or bi actions.
What? I didn’t expect that, what have you done?
You will run into problems very soon when you use the init of objects, creating a txt file and rename it is quiet simple
But a really bad for, especially for actions like ace actions or bi actions.
Why?
What? I didn’t expect that, what have you done?
Was this aimed at me?
Because you need to filter the join in progress. All inits are global and will get executed for everyone, everytime.
Yes
Got an extended init EH for vehicles that spawns a function, function checks if vehicle is west, applies ACE interaction to it
You can add ace interaction to vehicle classes, so you don’t need to manually add them every time
Fair enough, and I do recall dealing with that in the past. Personally I set everything up using onPlayerRespawn.sqf (following a removeAllActions call so the player's a blank slate)
Yes of course there are several ways to do this kinda simple thing, but there are bad, good and better ways, you need to choose
I suppose you could do:
if ( local this ) then { this addAction ... };
in the init field
Yes of course, but you need to check the skill of the asking one if he is able to add this and understand or not
@spice axle Eh, don't have specific classes though
Ah ok
How to make ai plane go full throtle and stay full throtle
I think way points do a good job
Q: when you setup a MP mission, how do you set the group names and have them stick? Setting the call signs in editor does not seem to stick.
CBA can do that
it has a feature where you set the description to something specific, and itll stick into slot selection
@still forum thanks, brilliant that works. although I'm not sure why the Callsign is not honored in the first place without a kludge like this being necessary. thanks, though.
follow on question, how to ensure the order of the groups? is that mission file order? so we need to delete, copy/paste, etc?
its order of how they were placed in 3DEN
cba has a UI editor coming up to change that order. But its still WIP
it's the same as
_lootholder = _this select 1;
thanks
it doesn't support all of selects abilities. It only does select element at index from array
hint ((50000000 - 10) toFixed 0)
prints 49999992 , wtf
Welcome to floating point precision
so there is no way to have an exact result ?
Use a smaller number. 
how to callExtension callback in c#?
same way as you call any unmanaged c++ function by pointer
I don't know how, but I know google knows
@plain current https://github.com/3F/DllExport
@tough abyss i already use the dllexport package and decorator to do my extensions, but i wasn't sure the function pointers work
i think they do, i dont have the source of my discord bot on hand but i didn't have implmentation issues with it while making it
i was thinking of using the unsafe keyword and just yoinking the shit out of the wiki? i might just as well write it in cpp
i think i used unsafe
it'd be nice to have a cs reference just in case, tho even if i got a cs version working i couldn't post it on the wiki 
although yes, C++ is a better solution to this
Is it possible to disable the sirene on ambulances?
@plain current Marshal the (function) ptr into a delegate
does the arma 3 interpreter/compiler support multi-line statments? e.g. an array with many many variables having each variable on its own newline for improved readability?
yes
so i just add a newline and nothing special? no delimiter?
thank you for answering btw
with the exception of macro's, but that's another story 😉
so i just add a newline and nothing special? no delimiter?
Correct.
private _myArray = [
"one",
"twelve"
];
diag_log ("blahblah" serverCommand '#exec users');
3:10:59 true
3:10:59 Failed attempt to execute serverCommand '#exec users' by server.
Huh? Password wrong but serverCommand goes true?
Return Value: Boolean - always true for some reason (since A3 v1.39 also false if a non valid command is used ("#blah"))
Maybe that extends to the password now too 
i should have asked tyhis yesterday lol, does that multi line statment also work for if statments? i dont wanna refactor all my script, reload the game, and find out i have to undo it lol
cause I have an if conditional with like, 20 required booleans
and the rest are getting up there with thwe more small ideas i add
SQF doesn't care about line breaks
you can write all your code in one line, same as you can write it in 2000 lines
You can use SQF-VM for simple compilation-level checks like that for your code
If it doesn't complain, then arma won't complain either
ohhhh thank you for the heads up @astral dawn and @still forum
@mild pumice what you need that precision for?
hey can someone point me in the right direction for creating reusable global functions in sqf?
MyFunction = {< code here>}
done?
you can write all your code in one line, same as you can write it in 2000 lines
if i see anyone doing a one line script, ill whoop their ass
I got a small issue with CfgRespawnInventory, I'm getting the following error: 17:29:26 [weapon hgun_P07_F]: item[optic_Hamr] does not match to this weapon!. This is what I have in weapons and linkeditems:
"Throw","Put",
"arifle_MX_GL_Black_F",
"Binocular",
"hgun_P07_F"
};
linkeditems[] = { "H_HelmetB_light",
"V_PlateCarrier1_rgr",
"optic_Hamr",
"ItemMap",
"ItemCompass",
"ItemWatch",
"TFAR_anprc152",
"ItemGPS",
"NVGoggles" };
Anyone know how to fix it?
well dedmen i thought more about a website with documentation or sth
not sure what you mean
ALright, read up on fucntions.
Now, if i do
_value= [_x,_y] execVM "folderetc\myScript.sqf"
//myscript.sqf:
_x = _this select 0;
_y = _this select 1;
_returnVal = _x + _y;
_returnVal
will _value == _returnVal?
i saw it like that on the wiki, is the last line value always passed in return after exectuing the script?
@wispy cave well is that item compatible with the weapon? or is it supposed to go on main weap?
@spark turret yes
the last value that was left over, will be returned
it's the RCO, it's supposed to go on the main weapon, not the handgun
you could also do _x + _y;
then the result of the call to the + script command, will be the last value left over, and be returned
@wispy cave random idea, try to swap the order of the weapons in the weapons array
such that main weapon comes below handgun
I'll give it a shot
@spark turret you May want to download sqf-vm for Quick testing or head over to the discord for testing it https://discord.gg/eP4QgTr
oh nice
Alt, run arma and test it there in the debug console
is that an alternative to ingame testing?
bc ingame testing is awful and takes ages.
Yup
Though, no full Support of every command
got a list of supported or unsupported comands?
also, is it able to mimic multiplayer dedicated server?
bc thats the biggest cancer. having to upload testmissions to a ded. server and get multiple people to test out
It is only Supporting a basic Set of commands currently
More on the sqfvm discord (as that does not belong here)
yea, that fixed it @still forum , no idea why
@spark turret Launch two arma clients with different profiles (can easily organize it through launcher), one can host a server, another can join the server. And you have good test environment.
With access to variables through the console, plus fast restarts
good idea, stealing taht
Hello everyone, got a interesting dilemma that falls under multiple channels so ima put it here. Im trying to create a spawner that is able to be placed by both editor and zeus as a object. This being said, I want to have it be a set of objects that are placed together and tied together. Essentially, i need a podium + the spawner location(a grass cutter) to be placed whenever the zeus spawns the podium(new one added via config) and then for the two to connect to each other(probably via a setvariable on the podium used by the action added via config). Anyways, in short is there any way to make it so that spawning a object via zeus of editor will spawn two objects and also if its possible to have both objects show as a preview while spawning?
If you have CBA you can add a "init" XEH, on your podium, such that when a podium is spawned, that script runs, and then you spawn the other part via script
is there a marker creation limit?
hey is there a way to truely attach a marker to an object?
with something similar as attachTo, without having a setpos getpos loop
kju, i have created up to 10000 markers on a map in the past, no problems
@velvet merlin
copy
Isn't attach to also essentially just omeachframe setpos? That's why if you chain then a few object they'll delay
likely, i just dont wanna write the loop myself
Isn't attach to also essentially just omeachframe setpos?
not really.
Same as moving a pencil is essentially the same as disassembling it into molecules, and then rebuilding it elsewhere
@spark turret no way to attach it AFAIK
shame.
Just make a loop for all markers you have created
And it would iterate them all once in <what interval you need>
Could have an array like [object, markerName]
yeah did that. any way to check if a marker still exists, so the loop stops when the marker is deleted without error?
i have
//mom script
[_tpMarker,_object] execVM "IRON\teleporter\markerPos.sqf";
//child script
params ["_marker","_object"];
while {true} do {
sleep 1;
_marker setMarkerPos getpos _object;
}
does "isNull" work for markers?
apparently not, throws an error bc it doesnt want a string
@spark turret markerPos , check if [0,0,0]
don't spawn a new script for every marker
have a single spawned script, that takes care of all markers
that makes sense.
alright, working fine so far. a bit worried that i might clog up the server but since its a teleportation script i dont expect to have mroe than 10 markers
Markers are for players. Therefore you could run your script on each client instead.
You can create local markers @spark turret
yeah i know but i dont see a point why i should run it on each client. very prone to mistakes made by me
interesting fact: if you do "_marker setmarkerpos getpos _object" on an object that is deleted, the marker goes away. not sure if to 000 or deleted too
it does not throw an error.
because getPos of objNull most likely returns [0, 0, 0]
So marker most likely goes there
Did you look at the map edge?
no, i made an extra condition, deleting the marker if object isnull or posmarker isequalto 000
is there a way to add code to the "onrespawn init" of a player via script?
i have educator players with a marker and i delete the marker if they respawn (or die) and if they respawn i want them to get a new marker.
There is a respawn Event Handler @spark turret
ah completly forgot about that. that works too thanks
will use that too for assigning custom gear on respawn as well. since arma likes to sometimes ignore my onplayerrespawn.sqf.
i had players respawn in vanilla gear in a soviet-afghan 1980 mission. really annyoing.
how do i select the player that controles the unit? for the EH i also need to get the players new unit after respawn
@still forum wanted to see if there was an alternative. Will this work in eden though?
XEH should work in 3den too
k, wasnt sure if it did. really havent used xeh on objects yet.
Not sure if this is more related to server setup or scripting but.... Is there a way to disable explosions?
like, all explosions?
Yeah
not without tampering with the game files and making a config patch addon.
would also make you unable to join most of the servers
Well its serverside I want to put it @young current
thats not possible
the effects are local
read from your local files
like Blastcore for example
at least thats my impression on the matter
i guess if you disable vehicles cookoff and ammo explosion as well as not giving otu grenades or anything explosve, its hard to trigger one
@wraith cloud notManhattan?
@wraith cloud No lol, whos that? Was just something that came up in a conversation with a friend
that guy? notmanhattan
#5691
lol it would be hilarious if its the manhattan i posted here. bc hes known for cheesing and cheating in a completly different game i also tend to play
Oh lol, didnt even realise. I dont really deal much with the players anymore, I more just code because I enjoy it. So people joining and leaving I dont really see haha
whats the purpose of removing the effects?
It is quite a lot of work so I wonder is it worth it
also quite wierd trying to disable explosions on a mil sim game
Your probably right, it wont be worth it. It was more to help with FPS But didnt realise it was clientsided. So it wont affect performance anyways
It migth but it will make the game look a lot worse
you can force graphic settings with ACE to affect performance. also theres better ways to do that
Well thanks for the input 🙂
i remeber there was a way to force players to respawn first after joining, but i cant find it in the editor settings?
found it:
in description.ext put a line saying:
respawnOnStart = 1;
source:
https://community.bistudio.com/wiki/Description.ext#respawnOnStart
just so i get that right: variables stored in missionnamespace are updated on the client they are changed on but not broadcasting their changes automatically?
yes
Question about addAction and remoteExec. On init, I'm adding an action to an object without remoteExec. When the action is selected, I remote exec (-2) to removeAction from all clients. However, when I try to add the action back using remoteExec I get issues.
When I try an addAction with remoteExec of -2 I get duplicates of the action (one per player in the game). When I try using 2, I don't get an action at all.
how do i do that map reload type thing where pretty much the whole scene changes to advance the story. like, AI placment and modules and props all change. Is it simply a completley new map or is there a script creating and destroying these things on the fly?
createVehicle/createUnit/deleteVehicle ?
That's how you create vehicles and AIs and destroy them 🤷
Or you probably want to change them from some preset?
do variable names that go with X_1 X_2 X_3
get the same results when called?
@astral dawn im looking for advice on how they built the missions i guess. I was wondering if they had a seperate map creation for each major stage of a mission or were whole missions built in one mololithic scripted patchwork
or does it even matter?
Hmm... when depends on how huge your scenario is!
For more open world scenario, it would be wise to divide the map into areas and for instance disable simulations of objects when player is not in this area, or do similar things
yes that would be the limiting factor i supopose. im all for pve with small groups so it could get HUGE if we want to command armies against each other
Well then you would even need to spawn/despawn units I suppose, this is a very hard task (I'm on it now and it IS very hard for armies). ALIVE mod should be solving this problem.
i was typing out what im trying to do and solved it in my head, create and destroy keywords should do just what i need thank you for mentioning them
im doing a SF map on livonia so ALiVE doesnt work too well there
oh ok, interesting, don't they have tools for automated indexing (also what does their indexing do?)
platyers are special forces in a small heli avoiding AA and doing nasty stuff in the dark
indexing i assume generates a "map" of sorts in a data form that can be used as a generic programmatic map of an in game area
something for AI to use, optherwise they think stuff isnt there
i tried to use the indexing tool on livonia and my game hung up
Hey, would anyone be able to help me figure out how to add an addAction to all objects of the same type?
I want to make all bunk beds call ACE Advanced medical self heal
https://community.bistudio.com/wiki/entities
^+ foreach @autumn nexus
Thanks @wispy cave
@autumn nexus i advise using the ace add action instead of vanilla one. prettier to use and also comes with a "addactionto classe" function so no foreach loop needed
first you create the action and then add that action to the class of objects.
Ok thank you
ugh multiplayer scripting is the bane of my sanity
@smoky verge don't understand question
if I place 3 units
and write in their variables
"man_1"
"man_2"
"man_3"
and on a trigger I start an animation for "man"
will the animation play for all 3?
normally I'd say no
but a similar thing happened to me last night and I got curious
no it should not
you can use a script to select all units containing the word "man" but it doenst do that automatically.
iirc something along the lines of ```sqf
{
if ("man" in (str _x) then {_x execVM "specialscriptforManunits.sqf";}
}foreach allunits;
very performance heavy tho bc it checks all units.
gets even worse with allmissionobjects
yeah
weird,
last night one of the units in my mission was supposed to have an animation, but all of its copies had the animation aswell
but now that I tried it again it doesnt replicate
thanks for the answers anyway
hey, how do i attach a variable to an object and have it local to a specific client?
You wanna have a local saved variable or a variable on a object local to the player?
i want to have a variable that is different for each object and each player. its used for actions added to the objects and since actions are local, the variable containing a list of these actions needs to be local too
the object is serverside, but sometimes also a player.
i use _object setVariable ["name",[array],clientowner]
run locally from all clients.
if you run it locally
you don't need to set clientowner
that is only for sending the variable tot he server and other players
okay. any chance that:
_object setVariable ["name",[array]]
``` is public by default?
bc that would explain my problem
no
alright, ill try again with _object setVariable ["name",[array],false] and see if that fixes it. not quite sure whats wrong in my script
,false
that does absolutely nothing
[_object, ["name", [array]] remoteExecCall ["setVariable", client] ?
the script is running locally on the client anyway. so you don't have to do anything special
maybe explain what you are really doing and what your problem is.