#arma3_scripting
1 messages ยท Page 680 of 1
maybe script a PPEffect that brightens everything on command when they are in the dark?
if nightvision doesn't apply to your scenario
Yeah it is 1922 in the scenario so no... hope that arma 4 allows you to use the flashlights during the day because it was pretty stupid not to in Arma 3
I mean you can have very dark places during the day too...
I don't think there are any naturally dark places on any arma 3 map come to think of it. They always have some skylights or small residual terrain lighting. even in the temples on apex
can you change the time of day to a daylight time that works with the light? then set your time scale down a ton so it stays in that same range for the mission?
setAperture works as well
Good day. A probably stupid question but, if I call
player remoteExec ["XXX_fnc_SomeFunction", 2];
from the client and on the server side I do have
XXX_fnc_SomeFunction =
{
params ["_playerUnit"];
....some useful stuff to do with unit
}
this _playerUnit object that I will obtain on the server, will be the local unit corresponding to player that called it?
yes
I need to refactor... a lot... Thanks @cosmic lichen
what would be the best way to merge magazines array?
Merge how?
like this: [["mag1",8],["mag1",4],["mag1",3],["mag2",8],["mag2",4]]
What does it return?
Dunnno the most efficient way but you probably get the unique magazine classes and then loop over it.
yeah was hoping some one had done this already
ACE has such a system
I know but I need custom merge script
This one as well. You can download it and unpack the pbo and look at the code if you want
ok thx not sure if this is what I'm looking for though
I've found this quite useful when dealing with same task
https://www.armaholic.com/page.php?id=35582
Has anyone faced this error with SQFLint?
SQFLint: Process crashed Error: spawn java ENOENT
I'm not sure what have changed since yesterday when it was working. I've built few android apks but don't remember anything to update during the process...
It crashed a few times for me today as well.
thx already wrote my script lol
Strangely enough VSCode itself updated today to 1.56 and nothing else did =_=
Guess the update broke something
Is there any way to apply civilian behaviour from Civilian Presence module on unit/agent (for example, they're panicking and trying to find cover when firefight is near them)?
why not use the module?
There is an EH I believe for if a shot goes off by the unit. You can then change the units animation and assign a waypoint away from their location.
FiredNear?
I think
Well, it is a persistent CTI mission, Civilian Presence modules required to be manually placed on each village/city
and since it requires trigger to be turned off or on
i ended up with 100 triggers listening for their variables
and of course, it ate something about 20 fps on just idling
you can create the module for each city by script.
should be possible..
_m1 = civModGroup createUnit ["ModuleCivilianPresenceSafeSpot_F", _pos, [], 0, "NONE"];
_m1 setVariable ["#capacity",3];
_m1 setVariable ["#usebuilding",true];
_m1 setVariable ["#terminal",false];
an example
hmmmm
_m = civModGroup createUnit ["ModuleCivilianPresence_F", _pos, [], 0, "NONE"];
_m setVariable ["#area",[_pos,CIV_AREA_SIZE,CIV_AREA_SIZE,0,false,-1]];
_m setVariable ["#debug",DEBUG_CIVILIANS];
_m setVariable ["#useagents",true];
_m setVariable ["#usepanicmode",true];
_m setVariable ["#unitcount", ("MaxTownCivilians" call BIS_fnc_getParamValue) ];
_m setVariable ["#oncreated",onCivCreated];
_m setVariable ["#ondeleted",onCivDeleted];
that's the wrong way of setting up a module
looks like it is possible
hope that helps!
really? i got it working like that...
What's the right way?
I don't know about that one, but for most modules, this is how:
https://community.bistudio.com/wiki/Modules#Spawning_a_Module_by_script
if yours works, it probably spawns the function instead of calling it
dunno, it just works for me
naturally it shouldn't. first it calls the function, then it sees your variables. so even if it does work for you, its parameters probably don't work
i'm trying to implement it atm, so i will let you know if the way from BIKI works at all
it does
the question is does GC8's one works
i found another example and it spawns the same way
looks like it is somewhat worked at least before
hard to say because it's long time I wrote that code but I'm sure it worked to a point at least ๐
quick test
this code works
private _position = position player;
private _group = createGroup sideLogic;
private _safeSpotModule = _group createUnit ["ModuleCivilianPresenceSafeSpot_F", _position, [], 0, "NONE"];
systemChat str _safeSpotModule;
and this doesn't (systemChat doesn't show up)
private _group = createGroup sideLogic;
private _safeSpotModule = "ModuleCivilianPresenceSafeSpot_F" createUnit [
_position,
_group,
"this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];"
];
systemChat str _safeSpotModule;
i guess civilian presence modules are somewhat special
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
@smoky rune the syntax of createUnit which you are using doesnt return a variable
whoops
Nothing - This syntax does NOT return a unit reference! In order to reference this unit, you can use newUnit = this in the init statement.
If the target group is not local, the init script will only execute after a slight delay; see Killzone_Kid's note below for more information and issues about this syntax.
yeah, this one works, thank you guys for help
"ModuleCivilianPresenceSafeSpot_F" createUnit [
_position,
_moduleGroup,
"this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true]; safeSpot = this;"
];
did you test GC8's method to see if the parameters work?
to be honest, no - i decided to do it BIKI way first
I'm talking about module parameters. both methods can create a module just fine
setVariable?
yes
doing it right now, soon will post results
looks like parameters doing it's job just fine, debug is there, 30 actors is there
private _marker = "marker_1";
private _moduleGroup = createGroup sideLogic;
private _position = getMarkerPos _marker;
"ModuleCivilianPresenceSafeSpot_F" createUnit [
_position,
_moduleGroup,
"this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true]; presenceSafeSpot = this;"
];
presenceSafeSpot setVariable ["#capacity",5];
presenceSafeSpot setVariable ["#usebuilding",true];
presenceSafeSpot setVariable ["#terminal",false];
"ModuleCivilianPresenceUnit_F" createUnit [
_position,
_moduleGroup,
"this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];"
];
"ModuleCivilianPresence_F" createUnit [
_position,
_moduleGroup,
"this setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true]; presenceMain = this;"
];
presenceMain setVariable ["#area",[_position,1000,1000,0,true,-1]];
presenceMain setVariable ["#debug",true];
presenceMain setVariable ["#useagents",true];
presenceMain setVariable ["#usepanicmode",true];
presenceMain setVariable ["#unitcount",30];
then use GC8's method
how can i setup Code On Unit Created in script from main Civilian Presence Module?
nevermind, found it -#onCreated variable
Q: when working with triggers... how do you delete them? deleteVehicle?
yes
dunno if this is the right place to ask this but uh - any idea where CF BAI went?
it's not. ask @tough abyss
can anyone give we some quick help to get this to work
_targPos = aimPos cursorObject
i want to make it _targPos = aimPos cursorObject modelToWorldWorld [0,0,-0.3];
but its giving me an error
https://community.bistudio.com/wiki/modelToWorldWorld takes object not array as left argument
ah thanks
Q: about IED models, do they damage automatically on "deletion" ?
then there's a question, how to 'disarm'? without "deleting" and setting it off?
they should just delete without any explosion
recreate
so to sim an IED explosion, I need to spawn in an appropriate "explosion" effect?
no, setDamage
setDamage to the IED itself?
yes
Hey guys, so I'm trying to add a 'mind control' power to the playable character in my new SP mission, and this is what I've come up with.
this addAction["Mind Control", { selectplayer Unit; [Playa, "STAND1", "ASIS"] call BIS_fnc_ambientAnim; Unit removeAction 0; sleep 30; selectplayer Playa; }, nil, 1, false, false, "", "true", 5, false, "", ""];
I place this in the "init" box of all the units i want the player to be able to control. It's a hassle to add this and name every single unit "Unit1, Unit2, Unit3 ... etc"
I had simply forgotten how to do this, i didn't write anything in arma for a while, and doing selectplayer this doesn't work
okay perfect. is there a way to set the damage the IED itself will do?
The ambient anim is just so the "playa" (Player) unit doesnt fire on the controled unit
who are you trying to control again?
A second unit, in this instance "Unit"
Is there a way to call a unit from its own Init box without naming each unit and yknow
Doesnt work bc it is inside the addAction
I know. I mean is this the same as unit?
well looks like you don't even understand what I'm saying.
just look at the wiki
https://community.bistudio.com/wiki/addAction
params ["_target", "_caller", "_actionId", "_arguments"];
no, no. That works, you dont get me, the part is that i cannot call the unit itself, the one that is carrying the code in its init, with this
I already told you what to do
params ["_target", "_caller", "_actionId", "_arguments"];
this addAction["Mind Control", { selectplayer _target; _target removeAction 0; sleep 30; selectplayer Playa; }, nil, 1, false, false, "", "true", 5, false, "", ""];
returns "undefined variable '_target'"
this addAction["Mind Control", {
params ["_target", "_caller", "_actionId", "_arguments"];
selectplayer _target;
_target removeAction _actionId;
sleep 30;
selectplayer _caller;
}, nil, 1, false, false, "", "true", 5, false, "", ""];
you also have to switch camera
How can you get all the OPFOR groups in a trigger area?
units east inAreaArray thisTrigger;
``` returns all the OPFOR units, but I don't know how to get all the groups.
_groups = units east inAreaArray thisTrigger apply {group _x};
_groups = _groups arrayIntersect _groups;
@little raptor cheers!
@little raptor what does that last line do? is it removing duplicates?
yes
oh that's very nice, I'll have to tuck that one away
hmm I am spawning in IED objects, but they are not firing events 'init', 'hit', etc.
I must be missing something, I spawn in IED objects, i.e. "IEDUrbanBig_F", using createVehicle, but "init", "hit", events are not being raised. also, setting their _x setDamage 1 does not trigger any explosions.
they don't support event handlers
stands to reason; so how might I approach wiring them up?
besides the actual trigger event... but regardless, setting their damage to 1 does not cause any explosions.
other goals include "hitting" them, with HE, grenades, shells, sometimes also small arms. should all trigger a detonation.
then also being able to disarm via menu.
IEDs count as mine. use the action "touchoff" https://community.bistudio.com/wiki/Arma_3:_Actions#TouchOff
huh good to know thank you. interesting also when createMines is used they cease to appear under nearestObjects but rather allMines
and then they go boom nice
huh so they start off created by classes like "IEDUrbanBig_F", but after being created, they end up like "IEDUrbanBig_Remote_Ammo".
yes. i think @little raptor explained this to another person a few days ago. let me see if i can find it
cool thanks... just so my ducks are all lined up for the event handlers
create one of the damage event handlers and check the source or projectile. should give you the correct ones.
more or less, I was sifting through allMines apply { typeOf _x; } and comparing notes with my presets. wondering why I was not seeing my event handlers.
I guess_ "remote ammo"_ MO for use with cell phone triggers?
hey was asking about how to add a add a BIS_fnc_holdActionAdd to all players and was told to put it in an init.sqf but was having trouble figuring out if it should be in a init.sqf, initPlayerLocal.sqf, initPlayerServer.sqf, or initServer.sqf and what the differences are (i have read this https://community.bistudio.com/wiki/Event_Scripts#init.sqf)
also i was told to use addaction but thats not an option for what im trying to do
you can do it multiple ways. did you ever figure out if the clients could see your variable?
see thats the weird thing i can find what changes the variable and what checks for when the variable is changed but i dont see where the variable is created
to answer your direct question between the inits...
init.sqf is going to fire on all machines. So say you have a createUnit or other global effect command in there and say you have 60 players on a hosted non dedicated server. You will get a total of 60 units created as each computer fires that createUnit when they join.
initServer.sqf is only run on the server machine whether it be a dedicated server, or a hosted server machine.
initPlayerLocal.sqf is run on each client individually when they join the mission. if you put a global effect command such as the above, you will end up with the same duplication issue as people join. Keep things local commands here.
initPlayerServer.sqf is something that runs on the server, when someone joins the game. Use this for things like... collecting data on players server side. (but you shouldn't be using this one anyways)
well i want the mission to work on both dedicated and locally hosted server so i shouldn't use init.sqf right?
all of them will fire if they are all provided
so it doesn't really matter. just know your initialization order
well just for this specific task
me personally? I would just keep it in initServer and remoteExec it with JIP
jip is join in progress right?
yes. use the variable of the object instead of this though
ya already fixed that
still need to figure out your condition though which was your issue
so i would use the initPlayerLocal.sqf and put something along the lines of this ["_player", "_didJIP"];
nope, look at remote exec JIP section
Wait is this condition thing a if (!isServer) then {}; that i need to add around my script
Ok im confused is my problem in my remote execute or is there something more basic
repost it
[
crate,
"Load Crate In Blackfish",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"triggerActivated trg1",
"triggerActivated trg1",
{},
{},
{missionNamespace setvariable ["var_crate",true,true]},
{},
[],
7,
10,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, crate];
ah yes so this one was determined that it was your condition that was the problem right?
instead of using triggerActivated, set a variable to true in the trigger, make it public and then use that
So i need to make another variable?
so your trigger onActivation box would be something like... startAction = true and then your condition in this action would be:
"!(isNil 'startAction')"
or if the trigger is set to evaluate on server only...
startAction = true;
publicVariable "startAction";
and
"!(isNil 'startAction')" for the action
also instead of using 0 for the remoteExec, use [0, -2] select isDedicated
@severe ravine
Bringing a friend lol
Ya i figured that the entirety of my remoteExec is wrong
its not that its wrong, its that if you are on a dedicated server, there is no need to add the action to the object since the server has no interface
i do want it to work on both locally hosted servers and dedicated server just to clarify
which that will do. the syntax is
[false, true] select (condition)
so if isDedicated returns false, then 0 is selected. if true, then -2 is selected
ahhhh
cool
remoteExec ["BIS_fnc_holdActionAdd", [0, -2] select isDedicated]; so that overall
looks weird
got a peculiar issue... function can be invoked after I log in, and the effect, an action menu item, is installed.
prior to that during pre/post-init phases, the function is being called, but is failing to install the action menu item.
verified the condition callback is running as expected, and should be returning true, but it is not showing the action
maybe the player doesn't exist
I thought that too, tested isnull player is false.
but it is an action condition, eventually it should see the condition true, verified that in the debugger watch
if I "reinstall" the player action then it "works". really bizarre.
Then add it with delay
question, trying to get it so that if i spawn in a Box_NATO_Ammo_F it gives me an ammo crate
kp_objectsinits.sqf i added this:
[
["Box_NATO_Ammo_F"],
{[_this] execVM "scripts\ammoboxes\Crate1.sqf";}
]
Then in the crate1.sqf I added this
if (! isServer) exitWith {};
_crate = _this select 0;
clearMagazineCargo _crate;
clearWeaponCargo _crate;
clearItemCargoGlobal _crate;
_crate addWeaponCargoGlobal ["arifle_MX_F", 50];
then i added "Box_NATO_Ammo_F" to the build menu
but when i build it, it spawns the crate and its empty, ideas?
clearMagazineCargoGlobal*
clearWeaponCargoGlobal*
params ["_crate"];
are you sure this script is run?
e.g [_this] execVM "scripts\ammoboxes\Crate1.sqf";
vs [this] execVM "scripts\ammoboxes\Crate1.sqf";?
is there a script to make ai mount NVGs only when they have to use them ? :3
most likely, but it could be scriptable quite easily yes ๐
can you give me the script ?
you can script it with while, waitUntil, and linkItem/unlinkItem ๐
while { true } do
{
waitUntil { sleep 60; sunOrMoon > 0.25 };
{ _x unlinkItem "NVGoggles" } forEach (units west);
waitUntil { sleep 60; sunOrMoon < 0.25 };
{ _x linkItem "NVGoggles" } forEach (units west);
};
```this would add/remove all NVGs for west units
@versed widget โ
allUnits select west does that exist? ๐ค i think you meant units west 
Fixed only once
the first one should also be units west right ?
YOU SAW NOTHING
yeah, but AirShark did ๐
That's true.
im getting generic error after the second sunormoon
unscheduled?
if you run this from the console, use [] spawn { /* place code here */ };
if you checked your rpt, you'd see that the error is thrown for the other waitUntil too, in-game the messages overlap each other^^
after adding []spawn i had the code excuted but not functional 
it takes 60s before doing anything
it checks every 60s if the sun is off or not (it could even check a longer time)
yeah i didnt wait enough i guess, i thought speeding the game to x4 would help what the hell i was thinking :p
well, it should
Change the waiting time for the testing time, then set it to whatever is best for you
so the time acceleration does effect the sleep command ๐ฎ
yes
how can i change west to all units i tried west && east and it doesnt seems to work
allUnits ...?
allUnits but this will also include civilians @versed widget
you could dosqf (units west + units east)
yeah thank you guys ๐
how do i implement that script to a config , shall i add cfg weapons and add NVG category im terrible at config level ๐ฃ
why do you want it in a config? Otherwise, #arma3_config
Sorry. Went to bed. That looks fine, you'd add the jip tag after as well
just to excute it on every mission without copying and pasting the code for every sqf mission besides i couldnt find any good tutorials for config and eventHandler
so you want to make a mod, just for this to happen
well the script might be slightly poor for that then
why poor ?
because no matter what, NVGs would appear
even on units which don't have one (e.g resistance)
and also, locality (Multiplayer) issues
i see than maybe the solution is to move it to the vest but than i wonder what would happen if the vest is already full, btw i just want it on singleplayer
Q: can you not add action menus to mine objects?
Like disable demine actions? Suppose no
i.e. disarm, yes
Or, you probably can do a workaround like hide the mine itself and make dummy object
like a proxy object, huh that might be interesting. trying this, does not seem to add any menu:
[
_target
, "STR_KPLIB_RESOURCES_ACTION_DISARM_IED"
, [
{ _this call KPLIB_fnc_ieds_onDisarm; }
, []
, -603
, true
, true
, ""
, "
alive _target
&& alive _this
&& _this isEqualTo vehicle _this
"
, KPLIB_param_ieds_disarmRange
]
] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _target];
yeah I was trying to retrace my steps. created initially using createVehicle but it's not a mine. but I did have the menu then. when I used createMine, no such luck...
the alternative is that I try to flip the table on the mine+player action menu; action goes on player, conditioned on being nearby the mine, etc.
that's ^ a smart move yes ๐ you can even check if cursorObject is the mine.
will try that thanks
just remember to add that action every time the player respawns
one more question, is it possitlbe to use the same crate for different contents?
so in liberation you have a build menu, i want to be able to build crates with different missiles all using the Box_NATO_WpsLaunch_F crate
selectPlayer as I said 
but one will have stinger rounds, the other iwll have maaws rounds, etc
yo its karmakut lol
so if you create a function that is receiving an argument and you add a parameter to the function that pulls in that arguement, you can do a switch do and check that parameter. You can then create multiple different cases that automatically are selected depending on the parameter
its how you can basically use the same script a lot of different ways
old_player = player;
selectPlayer _unit;
["Open", true] call BIS_fnc_arsenal;
_time = time + 30;
_arsenal = displayNull;
waitUntil {
_arsenal = uiNamespace getVariable ["RscDisplayArsenal", displayNull];
time > _time || !isNull _arsenal
};
_arsenal displayAddEventHandler ["unload", {
selectPlayer old_player;
old_player = nil;
}];
isNil {
if (isNull _arsenal && !isNil "old_player") then {
selectPlayer old_player;
old_player = nil;
};
};
https://sqfbin.com/uvunavarinacuqehijot
an example
well lets go over it then. what are you not understanding? and we can go through each
so in the init
i would put, [crateObject1, "stinger"] call TAG_Function
correct?
with crateobject being the class name
and stinger being what kind of crate i want to call?
ok so lets start here. how far do you want to go understanding this stuff? or do you want a quick fix.
i want to understand it enough so that i can make more custom crates in the future
@fair drum better use addMagazineCargo for mags. (not addItemCargo)
okay so. lets move away from using init boxes in the editor for starters. do you know how to define a function or what a function is or their setup?
lol i just started like yesterday picking at and reverse engineering the liberation code
only reason why i'm using the object init
so no i don't hahah
this is funny, you cannot set variables on mine objects either... LOL
you can (afaik)
This command does not work with CfgAmmo or CfgNonAIVehicles objects, like bullets, mines or butterflies.
don't mines count as "ammo"?
I could be wrong, I'll verify. really I am trying to avoid passing mine objects up and down the wire if at all possible.
but maybe that is a non issue
so lets make a function. lets call it going shopping. we go shopping a lot during our lifetime right? so it should be something we commit to memory so we don't have to think about how to go shopping every time. that would be a function. something that is stored that you run many times and you want to recall it quickly. but what do we want to go shopping for? well, how about apples and pears? those would be the arguments to a function that tell what you want to do. so now you are in the store (or inside the function), you know you want to buy apples and pears. but we don't want to buy any apple or pear, lets buy ones that are healthy looking. we can now write in our shopping function a few if statements like, if pear then, if healthy then, put in basket. that would be a parameter.
you cannot (set variables on mines)... at least not directly.
that would explain that yes. also that it is a 'remote ammo' object.
so if we look at the code provided, you see on line 6, there is the params command. this pulls in the arguments to the function and puts them under the variables, _crate and _type. in the order given to the function
confirmed
cursorObject setVariable ["test", true];
allVariables cursorObject; // returns []
the difference between using a function vs a script is that every time you call a script, then computer has to "relearn" the entire script once called. a function gets stored so you can quickly reference it over and over
so you know how you can store things in variables? such as _foodType = apple, well you can also store functions in variables but we use a {} for it.
TAG_Shopping = { /*function here*/ };
it will only be run when you call that function later
or you can define the function in the CfgFunctions in description.ext
I thought it did
what did I do in my code then? ๐ค
magic
oh, right. I used an array and passed the parameters there:
projectiles = [];
...
projectiles pushBack [_projectile,...];
something like that
so this would be an example of that in simple terms.
#arma3_scripting message
hyp_addThings = {
params ["_a", "_b"];
private _return = _a + _b;
_return;
};
private _endingResult = [2, 2] call hyp_addThings;
_endingResult //returns 4
so your final thing would look like
but we have to make sure that function exists first
brain slightly overloading at this point
LOLO
i think i understand
yea i think i understand that code
so we need to define that function, cause all we have is an .sqf file atm and the game doesn't know about it
do you have a description.ext file in your mission folder?
yes i do
so make a functions folder in the root of the mission. and inside of it, place the .sqf code that I made you and name it fn_crateCustomization
%Root%
mission.sqm
description.ext
functions
fn_crateCustomization.sqf
done
now we go to the description.ext which is the file that basically tells the game how to run your mission and what to include background wise.
class CfgFunctions
{
class Karma
{
class functions
{
file = "functions";
class crateCustomization {};
};
};
};
This searches the functions folder and looks for every file named fn_something.sqf in this case, we define crateCustomization so its going to look for fn_crateCustomization
anything you want. that would be the TAG
when this is defined and compiled, it will display as Karma_fnc_crateCustomization and thats what you would call
people use the scenario tag, sometimes short parts of their name, like I sometimes use HYP so all my functions start with HYP_fnc_blahblahblah
bohemia uses BIS
kp uses kp
and thats it for defining. the game now knows that file exists and will load it into memory as a function at the mission start
ok
class CfgFunctions
{
class kc
{
class functions
{
file = "functions";
class crateCustomization {};
};
};
};
it should be 3 to 5 chars per standards ๐
and you can stack functions there too.
class CfgFunctions
{
class Karma
{
class functions
{
file = "functions";
class crateCustomization {};
class function1 {};
class function2 {};
class ect {};
};
};
};
and they will all be defined as long as they are in the functions folder with the name fn_nameHere
did you customize the function file how you wanted it yet?
no
i'm assuming i need to replace stinger class with the class name of the missile right
and then the ammount right
yes class name and then how many you want added
delete the others in the array if you don't need them
do you understand what the switch do is doing in this case. its looking at the variable _type and going if (_type == "stinger") then {} or if (_type == "mawws") then {}
and selecting the appropriate route
right
and _type is whatever string we gave it in the arguments. if that string doesn't match anything, it heads down the default path which basically does nothing
ok almost done
/*
Called by example:
[crateObject1, "stinger"] call TAG_Function
*/
params [
["_crate", objNull, [objNull]],
["_type", "", [""]]
];
if !(isServer) exitWith {};
if (isNull _crate) exitWith {
diag_log "No valid object given to the function";
};
clearWeaponCargoGlobal _crate;
clearMagazineCargoGlobal _crate;
clearBackpackCargoGlobal _crate;
clearItemCargoGlobal _crate;
switch _type do {
case "stinger" : { //Cases are CASE SENSITIVE!!
private _itemCount = [ // [Class, Number to add]
["rhs_fim92_mag", 5]
];
_itemCount apply {
_x params ["_item", "_count"];
_crate addItemCargoGlobal [_item, _count];
};
};
case "mawws" : {
private _itemCount = [
["MRAWS_HEAT_F", 5]
];
_itemCount apply {
_x params ["_item", "_count"];
_crate addItemCargoGlobal [_item, _count];
};
};
case "javelin" : {
private _itemCount = [
["rhs_fgm_148_magazine_at", 5]
];
_itemCount apply {
_x params ["_item", "_count"];
_crate addItemCargoGlobal [_item, _count];
};
};
default {
diag_log "No case match found";
};
};```
!code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
yup looks good. now just remember how you call it. the cases are case sensitive. create your box in the editor, start the mission, and test it out by calling it in debug
so heres the thing right
the case doesn't start in mission
i spawn it in mid game
thats why i use the objinit
right
using kp's stuff already?
you won't have access to this midgame like in the editor
so are you modifying kp liberation for your own, or are you doing something completely different and just going off of kp's stuff to learn
modifying kp lib
ok so you haven't modified any kp files yet? or have you found the file that they use for their build menu and have begun adding things to it
@fair drum
i added the box nato ammo to the build menu
then every time i build it
it spawns mags
i want to do the same thing with the missiles
but use the same crate model
for the 3x types of missiles
okay, let me check their github to see what else they reference in their code real quick
which github are you referencing. I don't see anything named kp_objectsinits.sqf in https://github.com/KillahPotatoes/KP-Liberation
oh its missing the s on objects. give me a sec to read
and which build menu function are you referencing?
so heres the catch so far. if you do it down the objInit route, its very similar to CBA's object init function. you aren't going to have a way to define WHICH _type you want since its going to be the same every time. randomized, yes you can do that. what I need to find now is the function that is executed when the build menu item is selected.
is there a very similar crate to the crate you want to use?
you know how ace has
oh you mean specific class name?
yeah so thats the crude way right
i use a different crate for each missile crate right
i guess i can do that
yes in order to implement into their system. remember, working with someone elses code, isn't always the best way as you have to learn TO code, as well as THEIR code.
params ["_crate"];
clearMagazineCargoGlobal _crate;
clearItemCargoGlobal _crate;
clearBackpackCargoGlobal _crate;
clearWeaponCargoGlobal _crate;
_crate addItemCargoGlobal ["rhs_mag_30Rnd_556x45_M855A1_EPM_Tracer_Red", 30];
_crate addItemCargoGlobal ["rhsusf_200rnd_556x45_mixed_box", 30];
_crate addItemCargoGlobal ["rhsusf_100Rnd_764x51_m62_tracer", 30];
_crate allowDamage false;
can i change _crate to anything?
is that just a name?
_crate is the param, its being pulled in from the arguement. where did you find that?
this is my custom ammo crate
// Custom Ammoboxes
[
["Box_NATO_Ammo_F"],
{[_this] execVM "scripts\ammoboxes\Crate1.sqf";}
]
oh. no, modifying your code won't fix your problem
thats in the kp object init
and then i have Box_Nato_ammo_f in the build menu
so i just do the same thing
but add different crates
right?
and 3 more sqf files
1 for each missile crate
right?
yes. whats stopping you from making a crate with all 3 sets of items in it? like a missile crate?
balance
like gameplay balance
i mean i guess i could
there might be waste though
if the players only want jav missiles
they'd have to buy the crate that gives them all 3
jav stinger maaws
right?
so doing it with three classes would be...
[
["class1"],
{[_this, "stinger"] call karma_fnc_crateCustomization}
],
[
["class2"],
{[_this, "mawws"] call karma_fnc_crateCustomization}
],
[
["class3"],
{[_this, "javalin"] call karma_fnc_crateCustomization}
]
Anyone know if there is a way to allow players to use flashlights in midday? I'm doing a foggy mission and want to use lights to improve visability for players so they can see each other better.
flashlights don't work midday because the flaring system doesn't. the light will work, but won't really "emit" light. engine limitation
Aww, that's a shame.
you defined that class in the build menu i thought?
ooooooh so now I see how kp does it then. they are using config defined crate inventories and just creating the crate itself. try just adding the 3 crate classes and their costs. Then add the above objinit to start
add the 3 crate classes to the build menu, then do the above objinit that i posted a few lines up
if their system works by just creating the class, the function we wrote should overwrite it and clear everything out of it anyways
this in object init, replace class1,2,3 with DIFFERENT crate class names?
Is there a way to get an object's armor value
Like
if ( getArmor (headgear player) > 0 ) then { hint "you have a helmet" };
read it from the config
but now that i know that you are modifying a kp mission, your description.ext probably has a duplicate cfgFunctions in it doesn't it
yeah thats not allowed. we have to add your function under the already added cfg functions
i'm so confused now lol
starting from 0
i have
// Custom Missile/Ammo createSimpleObject
[
["Box_IND_WpsLaunch_F"],
{[_this, "stinger"] call karma_fnc_crateCustomization}
],
[
["Box_NATO_wpsLaunch_F"],
{[_this, "mawws"] call karma_fnc_crateCustomization}
],
[
["Box_EAF_WpsLaunch_F"],
{[_this, "javalin"] call karma_fnc_crateCustomization}
],
wait
sorry
right
then put karma_fnc_cratecustomization in the functions folder right
this
@placid trellis for example:
getNumber(configFile >> "CfgWeapons" >> headgear _unit >> "ItemInfo" >> "HitpointsProtectionInfo" >> "Head" >> "armor")
just fn_crateCustomization is what it should be called. put that in the functions folder
Saved me a bit of googling, thank you!
put this in missionframework/cfgFunctions.hpp
i just copied it, and added your function to the top
ok
so just add lines 1-8
to top
which file is this?
cfgfunctions add 1-8
rgr
yes, but change your karma_fnc_crateCustomization to KC_fnc_crateCustomization in the file with your crate class names
yes and the costs
ok
is it possible to change the name of those items
because they'll just show up as = weapons crate NATO
instead of Javelin crate
you mean what it says on the crate?
i think he means the UI. which i haven't even gotten into kp's UI yet
xD
yeah no it reads it from the config
so like here
i couldn' just at the top add Javeline_Missile_Crate="box class name"
no
my brain
if you want to change the name you'll have to create a new crate (in config)
is going to explode
lol. you decided to jump head first into a pretty complex mission written by like 6 people. its expected
ok
basically
you know the ace_box_82mm crates
i want to create more of those
with custom contents
using the launcher model
now you are looking into modding. you can't just edit configs willy nilly with .sqf. and modding is complex in a whole different way. what i think you should do is leave it as is with the names as is, and just let your players know that they are custom and what they are. i'm sure you understand the cost of learning something complex for a small detail
that they might not even "really" appriciate if you did it right
test it. see if it works. pm me if you want to learn anything new (and you should start with stuff you create yourself next time so you don't have to learn someone elses stuff lol, start small)
or you'll get burned out and not really accomplish anything
Q: about road width... is that between beginPos and endPos? or "side to side"?
i believe side to side
np, so what ive got now is
[
crate,
"Load Crate In Blackfish",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"triggerActivated trg1",
"triggerActivated trg1",
{},
{},
{missionNamespace setvariable ["var_crate",true,true]},
{},
[],
7,
10,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", [0, -2] select isDedicated, true];
still isnt showing up ive got it in the init.sqf rn but ive realized that that is no different than having it in the objects init field
hmm I will need to verify that... I look at width and use it to inform around a point randomly between begin+end... maybe those segments are longer than I thought, or I should just take begin or end point if I want IED on the road itself.
why remoteexec in init.sqf?
you didn't attempt my last possible solution about changing variables instead of using triggerActivated?
he was supposed to put it in initServer
still doesn't make sense, that script doesn't need to be remote executed
its a perfect fit for local execution in some init file for every client, especially that it's jipped
Just to clarify the action will only be used once in the mission and is non repeatable
i agree. he started with a remoteexec so instead of explaining more, I had the simple solution of just putting it in initserver.
I mean i am just looking for the easiest solution but i probably should learn how to use the remoteexec function
you tell every client to add the action for every client if that makes sense, it's a mess(what you have right now)
how would I force AI to turn on their NVGs turning day time?
so to do that i should put it in the initPlayerLocal.sqf and remove the remoteexec
yea
ideally yes
that'd be the most optimal solution
doesnt work
might just be an AI thing then. why do you want them on during the day?
try to find a time that is on the border of the sunmoon phase?
hopefully it doesn't make it too hard in post
oooooor i have an idea
ok but i should still change the triggerActivated trg1 to a (missionNamespace getVariable ["var",false]) in the hold action and add a missionNamespace setvariable ["var_",true,true] to the inside of the trigger
i'm trying to do this with script
take all the units, make them switchable, disable all of their AI, switch to each unit and turn their nvg on, then disable their simulation when you leave
ghetto but might work
elaborate on what you mean by switchable and disabling their ai?
also i'm fairly certain that there's a way of doing this with a script just really hard to find it
don't know didn't follow anything
Good Evening Gents,
I'm having trouble executing a script globally. I downloaded a ready-to-use script from the workshop and implemented it as stated, and the script itself is working flawlessly, except that its not running on all the clients on a dedicated server. The script states that it must run globally to work for everyone.
Currently, the code that has to be executed is this
[EMP, EMP_Range, true, true, 0] execvm "AL_emp\emp_starter.sqf";
I put that line of code into a hold action, and of course it is not working. If I run that line of code via ZEN's code executor for example, its working, because it propagates globally.
I thought about putting that line into an sqf and remoteExec'ing that sqf, but is this a viable option? Is there an easier solution?
TL;DR: Looking for a way to run that line of code mentioned on every client (including JIP) via HoldAction. ExecVM is not working for some reason. Any idea why and how to fix that?
Cheers!
put your hold action script into initPlayerLocal.sqf to have it add to every player that joins the server
hello how do i get a plane (AI) to get shot down, then have the pilot eject and then get captured?
I'm sorry, I've implemented the HoldAction via 3den enhanced, so I dont have an HoldAction script.
oh. yeah don't do that lol look at https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd
have it fly into an area trigger, trigger sets off an eject/getout action, set the damage of the vehicle to 1 to destroy it, then do a waituntil condition that has the unit's height return true when the unit's height is < 5, after that setcaptive to true
https://community.bistudio.com/wiki/action
https://community.bistudio.com/wiki/setDamage
https://community.bistudio.com/wiki/waitUntil
https://community.bistudio.com/wiki/getPos
https://community.bistudio.com/wiki/setCaptive
might want to make the unit invulnerable too so he doesn't die on the way down or by the explosion
ok thank you
...just because its important, does anyone know if unit playback works in multiplayer? EG pre-pathing a jet to fly low across an area, or does it desync and crash shit
o shit sry that was supposed to be for hypoxic
it works fine. just know that shooty shooty is buggy with unitplay and stuff
if you ever wanted a unit or vehicle to play a recorded fire command
OH that, yea I'm not using that
if its just movement, you're good
yes that is fine
do you have an example? sorry still a noob
kk and should i preface it with a if (!isServer) then {};
if its in initplayerlocal, no remote exec, no if !isserver
wait one
put this in its own .sqf file, name it something:
params ["_unit"];
private _vehicle = vehicle _unit;
_unit action ["getOut", _vehicle];
_unit allowDamage false;
_vehicle setDamage 1;
private _parachute = createVehicle ["Steerable_Parachute_F", [0,0,0], [], 0, "NONE"];
private _unitPos = getPosATL _unit;
_parachute setPosATL _unitPos;
_unit moveInDriver _parachute;
waitUntil {
(getPos _unit # 2) < 3
};
_unit action ["getOut", _parachute];
_unit allowDamage true;
_unit setCaptive true;
_unit action ["Surrender", _unit];
sleep 3;
deleteVehicle _parachute;
in the onActivation box of the trigger put:
[pilotVariableHere] execVM "scriptFileLocationHere.sqf"
set the trigger activation to whatever you want. say.. opfor present, and fly the plane through it.
oops. forgot to make it parachute, one sec
on activation fires on every machine right? ๐ค
so i assume unit will be local to the server, means you should tick server only or whatever its called in trigger settings, dont want every machine running that code
!code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
K have this in my initplayerlocal
[
crate,
"Load Crate In Blackfish",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"missionNamespace getVariable 'var_trg1'",
"missionNamespace getVariable 'var_trg1'",
{},
{},
{missionNamespace setvariable ["var_crate",true,true]},
{},
[],
7,
10,
true,
false
]remoteExec ["BIS_fnc_holdActionAdd", [0, -2] select isDedicated, true];
tried to get rid of the
remoteExec ["BIS_fnc_holdActionAdd", [0, -2] select isDedicated, true];
at the end but then the whole thing just stopped working even in single player
as it stands it works fine in single player but doesn't show up for players on a dedicated server not sure where to go from here
and i know the initplayerlocal is working properly because other stuff in the initplayerlocal are working fine (BIS_fnc_dynamicGroups)
you're not supposed to put that in initplayerlocal
missionNamespace getVariable 'var_trg1'
is that variable public?
@copper raven and @fair drum told me to put it in initplayerlocal
and it should be public
var_trg1 = nil;
publicVariable "var_trg1";
Without remoteexec
put that in the init field of my missions so i think it should work to make the variable public
so like this?
[
crate,
"Load Crate In Blackfish",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"missionNamespace getVariable 'var_trg1'",
"missionNamespace getVariable 'var_trg1'",
{},
{},
{missionNamespace setvariable ["var_crate",true,true]},
{},
[],
7,
10,
true,
false
]
call it
[all that] call bis_fnc_holdactionadd
it doesn't. it just means it's defined.
there's no guarantee that the changes are synced. you have to do it yourself
is it in the wrong spot or is my syntax wrong
so literally just add call bis_fnc_holdactionadd to the end of the script outside the brackets
[
crate,
"Load Crate In Blackfish",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"missionNamespace getVariable 'var_trg1'",
"missionNamespace getVariable 'var_trg1'",
{},
{},
{missionNamespace setvariable ["var_crate",true,true]},
{},
[],
7,
10,
true,
false
] call BIS_fnc_holdActionAdd;
check the pinned messages, has useful info on that regard
why are you broadcasting nil?
not sure was fine before hand where it was just defining itself when its state changed but figured it couldn't hurt to double up
where do you modify the value of it? (besides that nil stuff)
in a trigger
how exactly?
was told to create a variable instead of using triggeractivated
missionNamespace setvariable ["var_trg1",true]
^in the onactivation zone of a trigger
and this part is in initplayerlocal?
change nil to false, and remove the pvar
no its in the init field of the mission
the one under attributes, general in the editor which i assume is functionally identical to the init.sqf
put this in initPlayerLocal
amb_showAction = false;
amb_actionCompleted = false;
[
crate,
"Load Crate In Blackfish",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loadDevice_ca.paa",
"amb_showAction",
"amb_showAction",
{},
{},
{missionNamespace setvariable ["amb_actionCompleted",true,true]},
{},
[],
7,
10,
true,
false
] call BIS_fnc_holdActionAdd;
then rely on amb_actionCompleted for the status, get used to using proper tags, var_ is whatever i guess, still better to use something more unique
in your trigger, amb_showAction = true, now not sure if you need to broadcast it or not, not sure if on activation fields run on every machine
well the trigger is only evaluated on the server
did you tick the server only box?
YA
well then broadcast it
PublicVariable "stringOfVariable"
setvariable is probably faster
right but in the initplayerlocal?
kk
set the variable to true, and call publicvariable
in that order
not the other way around
yay
language before the bot gets you
so there is a difference in defining variables in different places?
(hes idle, delete it quickly)
lame
yes there is. for example mp game security, you'd ideally have two of the same variable, one in the server's localnamespace, and then another in missionnamespace. for variables you want players not to be able to mess with, you use server's localnamespace. then when you want to broadcast it, you copy it into missionnamespace then make that global, but still use localnamespace in the end
ohhh ok can see the reason for that but dont think i would ever need to use it
its mainly for big missions on public servers. i use it on my pvp gamemode to help prevent tampering since its on public servers. other games like KOTH just use an off site storage that can't be tampered with and just call stuff in from there
@fair drum @austere nimbus @little raptor thanks for the help guys
theres very little need for that sort of security anymore
maybe only 20-30 servers running 4-5 different modes with decent population need to bother
Hello! I I'm in need of help, I've created a MP mission and placed objects in the editor and then grabbed them with BIS_fnc_objectsGrabber and then placed the code in my .sqf and running it wirh BIS_fnc_objectsMapper. But when the 2nd person joins everything blows up. keep in mind that I am a beginner to scripting and trying to learn. Is there a way to run the script from only one player? I guess that when the 2nd person joins every item adds in again and thats why it blows up?
Don't use init fields indeed
So where do I place this "start = call (compileFinal preprocessFileLineNumbers "composition\startPosition.sqf");"?
initServer.sqf?
Ok, thank you. Can I just call the script as it is or do I need something else?
I just copied everything as it is from the init.sqf to initServer.sqf, but it still blows up when the 2nd player joins
@hallow depot Also see https://community.bistudio.com/wiki/compileScript
Thank you, I dont think I really understand it, how and where can I use this?
instead of "compileFinal"?
read the description
I've done that, sorry but I don't understand
Result:
0.0747 ms
Cycles:
10000/10000
Code:
compileScript ["initPlayerLocal.sqf"];
Result:
0.0503 ms
Cycles:
10000/10000
Code:
compile preprocessFileLineNumbers "initPlayerLocal.sqf"
if you aren't loading bytecode, compile preprocessFileLineNumbers is the way to go imo, the .sqfc lookup does add a decent overhead
Thank you! I think I've solved it, I added "if (!isMultiplayer) exitWith {};" in my initServer.sqf.
It's not blowing up now at least when the 2nd player is joining
guys how to add parachute in arsenal can someone help me pls
- not related to #arma3_scripting
- don't ping everyone
- parachutes can be found in the backpacks section of arsenal
!code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
I'm having a minor issue that is blocking everything's flow here:
I'm broadcasting voice messages through sideRadio, but when I reach the sixth message (mes6) it finishes playing the message, but never stop broadcasting (you can still hear arma 3 sideRadio static in the background, and for that reason when I try to play the seventh message or any incoming messages, it doesn't play, because broadcasting message 6 continues, is there a reason why that happens?
Digger sideRadio "mes4";
sleep 4;
Digger sideRadio "mes5";
sleep 4;
Digger sideRadio "mes6";
sleep 4;
Digger is the entity the message is broadcasted from, simulation disabled and entity is hidden, and damage is disabled in case that affects anything.
mes.ogg is the file extension
in case anyone is wondering
aaaaaah close that parenthese
๐
try to replace mes6 file by another, it might be corrupted - it is not a scripting issue here
Overhead time should be greatly reduced on profiling branch. I improved the speed of the lookup and I know how to make it even better.
Also you only compile once, 0.02 milliseconds happening ONCE is basically irrelevant.
compileScript command is the new recommended way to compile script files.
Hello, earlier today i was messing around with the grad persistence script when i noticed that my game started to get slower, pausing was slower, switching from one tab to another in the editor was slower and when i checked my profile namespace it said it was 988kb. How do i fix this?
- Edit your profile var file manuall
- Used Terras Editing Extension or 3den Enhanced to edit the vars with the Variable Viewer
- use profileNamespace and allVariables commands to edit it via script
but 988kb isn't that big I think. I got 500 and have no issues
I would make a backup of the file and delete the original one to test if your issue is solved, first.
so copy the var file, delete it and then paste it back in?
But wouldn't that delete all of my variables?
that's why you do a back up first of the original file
use the old file again, then
Use Terra's Editing Extension or 3den Enhanced to edit the vars with the Variable Viewer
- Edit your profile var file manually
- Used Terras Editing Extension or 3den Enhanced to edit the vars with the Variable Viewer
- use profileNamespace and allVariables commands to edit it via script
Ok thank you
How would i edit it via script? Also i have hundreds of variables in my profile namespace.
how would one go about adding an action that is available when controlling a UAV ?
@cosmic lichen ?
getVariable, setVariable and allVariables
if you have hundreds of them, I would recommend using a tool
What tool should i use?
Use Terra's Editing Extension or 3den Enhanced to edit the vars with the Variable Viewer
How many variables would i delete and how would i delete them?
I was doing similar feature, maybe that would help?
https://www.sqfbin.com/ocoyororicamaracoyex
Good day. Does anyone have experience in parsing DB (MySQL) response with SQF? It must be something with how it returns CHAR values - parseSimpleArray just breaks with "Generic error in expression"
I've gone through the variables and deleted 1/3 of them but its still slow, would it be ok to just delete the profile namespace and get a new one?
what you should've done is temporarily delete the profilenamespace and run the game to see if that's the issue at all.
not delete variables one by one
I have done that
so does it fix the issue?
yes
then just delete it. you'll lose some settings tho
What settings?
not your game keybinds (but CBA keybinds will be lost)
mod settings, color settings, etc.
maybe.
Q: about triggers, are there BIS functions supporting this, I wonder?
Supporting what?
Anything you can do with a trigger you can do with scripting. It isn't very easy sometimes though.
A: yes.
hey i wanna add zeus(curator) to a player in a MP mission through command line. what do i have to do? can only find the assign curator command, but i dont know the reference to the zeus module
Create the module on the fly. Just don't forget to clean up when it's no longer needed.
hmm perhaps a different question, when you configure trigger activation by to west or blufor, let's say, i.e. "WEST", does that include anything west? i.e. units, players or otherwise, vehicles, etc?
Units and players for sure, vehicles you'll have to test a bit, I don't know for sure.
vehicles too. but not sure about empty vehicles (I think they only count as civilian?)
all good to know, thanks for the feedback
can i exec a sqf via radio call, like "0" custom?
yes using a trigger
do you have additional syntax for google?
in your onActivation do:
[] execVM "scriptnameandlocationhere.sqf"
oke thx. never seen yet radio triggers. thats quite fun
[[0,0,0], 0, "RHS_M2A3", groupname] call BIS_fnc_spawnVehicle;
is there a way to assign this vehicle a variable name? (so that I can setDamage for example)
the return of that function, index 0 is the object of the vehicle
ah alright
[createdVehicle, crew, group]
you mean this right?
private _vehicleReturn = [[0,0,0], 0, "RHS_M2A3", groupName] call BIS_fnc_spawnVehicle;
private _vehicle = _vehicleReturn select 0;
yeah got it from the wiki lol
thanks
but
I will make it global
its possible right?
private _vehicleReturn = [[0,0,0], 0, "RHS_M2A3", groupName] call BIS_fnc_spawnVehicle;
thename = _vehicleReturn select 0;
like this
yup
@drifting portal what isn't exploding? pretty sure that's an animation/effect. simply setting damage does not do that.
post the whole thing you have...
!code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
private _vehicleReturn = [[0,0,0], 0, "RHS_M2A3", groupName] call BIS_fnc_spawnVehicle;
thename = _vehicleReturn select 0;
sleep 4;
thename setDamage 1;
are you in a scheduled environment?
are you calling this script or spawning it...
Debug console
so calling it. you can't do that in default arma debug without spawning the code first
where is zero? water? https://community.bistudio.com/wiki/BIS_fnc_spawnVehicle
and define "doing nothing". like I said, I think "explosions" are animations, you have to script those separately. could be wrong though.
so basically I need sqf file?
no, just spawn it. also, you know you are creating that vehicle at map origin which is usually water right?
okay. well you need to spawn it
I did
[] spawn {
//all the code
};
and you're sure you have the model class name correct? test isNull (_vehicleReturn#0) for instance
you mean "RHS_M2A3"?
for instance, yes
Q: re: triggers, setTriggerStatements versus setTriggerActivation, are these both alternate ways of "triggering" the thing?
why are you even going there? he already successfully spawns the vehicle. the problem is that hes using sleep in a unscheduled environment
Since it gets created, I assume so
ah okay was not clear about that
log would be interesting to review; might have been tripped up over sleep in the debugger, perhaps. versus spawning.
am I correct understanding trigger setTriggerStatements [condition, ...], condition relays what we learn from triggerActivation having happened via this?
what did you put as the condition? your question reads... incomplete
oh i see what you are asking
if your trigger activation is set to bluefor, and your triggerstatement is this, then when a blufor unit enters, it becomes true. just like using a trigger from the editor
@fair drum well, from other contexts, when I think trigger condition, literally is just that, returns a flag or some status, the condition, whereby the trigger is raised. in this context, I am uncertain about that.
in this case I suppose these are the 'callbacks', literally "wax on" or "wax off", as the examples suggest.
you're overthinking it
maybe... so ... setTriggerActivation (i.e. trigger happens, or ceases to happen), setTriggerStatements (i.e. in response to Activation)
setTriggerActivation what is being detected to make this become true
setTriggerStatements condition what its going to take for the whole trigger to be true
the triggerstatements don't have to follow the activation at all. you can literally throw something in there that has nothing to do with the trigger area if you want.
ah I see, so you can return "this", but does not have to be that.
correct. you can do whatever you want
I guess my confusion is reading, this (Boolean) - detection event if that actually read, or mentioned anything to do with activation or setTriggerActivation, that might make better sense, but the association is ambiguous, or undefined.
https://community.bistudio.com/wiki/setTriggerStatements#Syntax
have you ever used a trigger in the editor before? it works exactly like that
how would i go about setting off a trigger when a vehicle is repaired? For like a repair task. I don't see any eventhandlers for vehicle repair
there is none. use a loop
ok
why not just set the trigger condition to check the current health of the vehicle with damage (0-1) and when it reaches a threshhold, it fires?
how would i write that exactly, the example they have on the GetDammage command is:
private _damage = getDammage player;
but how do i use that as a condition brain fizzles
ahh so just like ```sqf
(damage engineer_sq_jeep1) > 0.3
you would just do
damage vehicleName <= 0.1; //or whatever you want
in the condition box of the trigger
remember, higher the number the more damage. you want it on repairs, so do the opposite
OH
that makes sense
hmm i have ```sqf
damage engineer_sq_jeep1 <= 0.5
vehicle is set to 15% health, its not firing the trigger i don't think
try setting trigger activation to "anything"
try forcing the vehicle hp with setdamage. if it works, it probably means that you need to use hitpoint damage or something that the in game repair does
also, 15% health wouldn't fire that trigger, because its 'opposite'
you want anything > than 50% health
ok yea thats the issue, setdamage worked
15% hp would be a value of 0.85
15% is what it starts with, when it gets repaired it should go past 50% right?
i tried setting it to 0.7 as well and no difference
i think the repair works on individual hitpoints then where the individual parts get repaired to 0.25 if non engineer
so now you need to try https://community.bistudio.com/wiki/getHitPointDamage
so i'd need to use a loop with that i'm thinking
the trigger itself acts like a loop
let me test something
okay yes, damage isn't effected by a repair. it just repairs the individual pieces.
[0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6]
this is the array of all the parts of a APC after its been repaired from 16% hp (damage of 0.837154). Damage was unchanged. Individual parts changed to 0.6
{
dostop this;
} forEach units east;
would this work? (apply for each eastern unit)
(allUnits select {side _x == east})
and it would be
doStop _x
(allUnits select {doStop _x == east})
?
{ doStop _x } forEach (allUnits select {side _x == east})
//or
(allUnits select {side _x == east}) apply { doStop _x };
why doesn't this work?
actually its just because of your good ol this. forEach uses the magic variable _x
oh
lol
forgot that
but yes, your units east would work
i just like using select cause usually i have more conditions than just the side
it's also way faster
ah hell i still can't get this repair task to work. I have two triggers, one that fires on Anybody with this code: ```sqf
engineer_sp_jeep1_dmg = engineer_sq_jeep1 getHitPointDamage "hitEngine";
engineer_sp_jeep1_dmgvar = if (engineer_sp_jeep1_dmg <= 0.5) then { true }
and then another trigger that waits for engineer_sp_jeep1_dmgvar to be true and is synced to a task state module
I have two triggers
wat?
just use a loop like I said
i'm not familiar with using loops lol
and someone said the trigger acts like a loop (but im not sure how exactly)
they ARE loops
ok
if you don't want to use loops use one trigger then
and then another trigger that waits for engineer_sp_jeep1_dmgvar to be true and is synced to a task state module
use it in there
engineer_sq_jeep1 getHitPointDamage "hitEngine" <= 0.5
that should be your activation condition (trigger has to be set to "Activation None")
OH that's what i was having trouble with, i thought i had to use getHitPointDamage to fill a variable and then check for that
still not working, maybe i should try to get damage from something other than the engine?
did you set the activation to none?
yeh
what was wrong with getDammage again?
the vanilla toolkit repair only repairs hitpoints, not total health apparently
so it only sets all the vehicle parts to 60%
#arma3_scripting message
the repair didn't change the result of damage at all, just modified the hitParts themselves
why not check if your trigger works at all?
true
put that in activation condition
wait wait wait i think i might've caught it, it's 0.6 but it's reversed like you said so it's only 40%
so it's NOT going to cross 0.5
then change it to <= 0.6
which is what I mentioned here...#arma3_scripting message
Hey there. Im making a Sector Control mission. How can I set up 3D icons like A,B,C,D and so on?
@fair drum Has this changed over the years? I see in the old videos and documentation for this that there is 3D markers for each site. Now it seems its been replaced with this
oh I cant paste pictures
the orange marker showing the active assignment
And only one assignment can be visible on the screen at a time?
can a trigger OBJECT be attached to a MINE?
I would sayโฆ yes? But try, to be sure
yeah, figured I should ask. since cannot set variables, is not an 'object' per se, it is a question mark
it is an object, but a very simple one
I've said that one before ๐
then I have the question, how does the trigger, area, etc, apply? to each attached object as its origin?
sorry, what?
hey guys, I need a small bit of help.
Im trying to define the caller of an addaction script, what's the command for me to define it?
the addaction command automatically defines it with the params provided on the addaction wiki
params ["_target", "_caller", etc etc]
ah, don't i have to change what "_caller" means?
or does it automatically recognize it
you can if you want, it just has to be at index 1
copy.
you just include that params line from the wiki page
and use _caller from there and you'll be fine
hmm well trying to avoid multiple triggers piling up; if I can apply the trigger dimensions using the attached object(s) as the source...
params ["_target", "this select 1", etc etc]
Like this or...?
maybe I have that confused with something like a logic?
params ["_target", "_caller", "_actionId", "_arguments"];
okay, and i put that before the script itself right?
["apples", "oranges"] call {
params ["_item1", "_item2"];
_item1 //returns "apples"
_item2 // returns "oranges"
};
you put that in the code block at the start
as in:
o1 addAction [ "<t color='#00FF00'>What's their goal?", { params ["_target", "_caller", "_actionId", "_arguments"]; [] execVM "chat\chat_astra_goal.sqf"; }, nil, 0.5, false, true, "", "true", 3, false, "", "" ]; ?
well i want _caller to be a player that called the addAction
it will be.
ah, so i don't have to change anything?
_target is your o1
nope you don't you just have to include that params line which you did
okay, cheers mate
I'm not sure. I don't really use the sector module and kinda create my own. the orange markers should be the task system which is different
Hello, I am trying to replace the sound of the kalxon in game, but I can not recover the sound for the delete is this possible?
kalxon... interesting word for horn. gonna add that to the bank. your second statement doesn't make sense to me though
Yes sorry horn
i'm trying to understand what you want. "but I can not recover the sound for the delete is this possible?" this gets me confused on what you want
I am looking for how to recover the sound to delete it, after research on the wiki I did not find anything is what it is possible and do you have the solution?
are you using playSound? say3d? playSound3d?
how are you creating the sound
or are you just trying to mute the horn
This is the basic sound of the horn, so I think it's a say3d
Yes mute the horn for play other sound
but how are YOU creating the sound. it shouldn't be think, you should know, you wrote it lol
oh i see. you just want to mute the game's normal horn
Yes i just want mute the sound of horn for after playsound other sound
i'm not sure if you can easily. a couple ideas come to mind with fadeSound and some player left click event handlers, but its gonna be muted even for a new sound to take its place... would have to think about it
the problem with fadesound is for add the other sound after, i must wait. I have look handlers : SoundPlayed but is not detect
Hi guys ๐
I'm making a rescue mission where, before the rescue, the operators have to get informations from some audio tracks (audio already recorded by me and already insert inside the mission as sound). Do you know how to let the audio start using an hold action? (the audio should be a 3d audio as only the operators close to the console can hear it and it should be repeatable everytime they use the hold action)... Could you help me? What should I use?
do you want it to cut off when they "un"hold the action?
no,I'd like that they use the hold action to play an audio (possibly repeatable)
other way is to create a mod that modifies the vehicle to remove the horn, that probably what I would do but just for a horn? not worth the time
take a look at https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd
on my way, tahnks ๐
For vรฉhicle A3 is not possible ?
I don't think it is possible using just sqf. Its possible with configs but you'd be doing a mod.
Okay thanks
Hello all! Im having a bit of an issue understanding a specific set up in scripting and init. Im fairly new to all this and im not even sure what the problem is or where to begin troubleshooting. Im attempting to integrate the Gruppe-Addler money and buy menu scripts into my server, but i cant seem to get the buymenu addaction init to work. Im not even sure if this is the right place to get help with that
well we can help you with general scripting and teach you, but I don't want to have to learn someone else's code. I'm guessing this is for life?
Its for a PMC server im running. I want to pay my guys for operations and let them buy gear and weapons for future ops
I was able to get the money menu to run, but i dont understand how to get the other to run
point me to some githubs you are using
Ive also been in contact with the original creator but replies are few and far between
this is the github for the buy menu
his tutorial looks pretty dang good. whats tripping you up?
well forget that script for now and lets get you understanding what it is you are looking at. are you prepared to read?
I am
kk making some linkys
thank you
https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting
https://community.bistudio.com/wiki/Operators
https://community.bistudio.com/wiki/Array
https://community.bistudio.com/wiki/Variables
https://community.bistudio.com/wiki/Magic_Variables
https://community.bistudio.com/wiki/Function
https://community.bistudio.com/wiki/Scheduler
https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands
https://community.bistudio.com/wiki/Category:Arma_3:_Functions
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers
https://community.bistudio.com/wiki/Description.ext
https://community.bistudio.com/wiki/Multiplayer_Scripting
if there is a particular thing you are reading and don't quite grasp, feel free to ask and any of us can explain in a different way
Thanks very much ill read through this tonight
Hey so was having trouble with this the other day and yall helped me get it working
This is in the initplayerlocal and works great except it doesnt work for JIP
var_trg1 = false;
var_assault = false;
[
computer,
"Begin Assault",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"var_trg1",
"var_trg1",
{},
{},
{missionNamespace setvariable ["var_assault",true,true]},
{},
[],
5,
10,
true,
false
]call BIS_fnc_holdActionAdd;
do i need to change call to remoteExecCall so i get access to the JIP parameters?
i had been using remoteExec earlier and that was what had been causing my problem if i understand properly
initPlayerLocal is fired when a player starts the mission anyways giving you that "JIP" you are looking for. Its most likely because they don't see var_trg1.
which was the issue last time, and its still probably an issue this time. show me where you are setting var_trg1
when it is innitaly defined or when it is changed?
well if you see up at the top of your script
every time a player joins, its gonna set var_trg1 to false
right
so if the trigger already occurred, the init is going to overwrite it
you still doing something like:
var_trg1 = true;
publicVariable "var_trg1";
?
no thats not the problem even if they join after the mission is started but before the var is changed it wont show up
before the var is set to true?
yes
and just to clarify this is whats in the trigger's onactivation field
var_trg1 = true;
PublicVariable "var_trg1";
you got your server up and anyone can join? no mods that I can easily pop in and track some stuff? i think thats the easiest way instead of dealing with this over chat. its most likely a variable problem as it always has been.
does case matter here
should PublicVariable be publicVariable
doesn't matter
only set the two variables if they aren't set(isNil), i was thinking whether you need jip compatibility or not when i was writing that yeaterday https://community.bistudio.com/wiki/isNil
I dont have them set previously should I?
you do though. line 1 of your initPlayerLocal defines the variable
if isNil "var_trg1" then { var_trg1 = false }
this way you won't overwrite jip value(if it was broadcasted)
getVariable
no real overhead
condition is evaluated every 0.5s
i prefer saving every bit of runtime where possible, so it's preference i guess
low level language vs high level language prime example right here
ya sorry could have sworn that when we tested it both ways last night it didnt work either way cuz i thought this could be a problem but just retested it and it works as long as the variable hasn't been changed yet
so i guess i just need to go with the nil thing
wtf are you talking about?
what is a typical unit running speed in Arma?
I think around 5
No probably like 3.3
Takes about 5 min to run 1k
If you are using Leo's dev tools just set the units speed under the watch list and pin it. It will track it on the side of the screen.
Q: what is player action ["TouchOff", player]; actually doing? i.e. we _ied setDamage 1, correct? we need to animate players with TouchOff?
to clarify, using triggers, identifying when there are X number of players doing something, i.e. running, near IED, sufficient speed/count "activates" i.e. detonates i.e. setDamage 1 on the IED
you can do those actions with a unit that is invisible in the middle of nowhere if you want
Which script command is used to find the offsets of an object in relation to another? (Not the position on the map, but the offset like [ 1.4, 12, 0 ])
vectorDIff
ah I see THAT'S what it does LOL
@little raptor Can you give me an example how to use vectorDiff to get the offset position of an object in relation to another? I made a composition of objects in a house that I want to extract the offsets for each so I can spawn the objects and set their positon, such as:
_chair setPos (_house modelToWorld [3.456 , 1.4 , 0.008]);
for that it's better to use one object as a reference.
let's say the house is the reference
I'm trying to use the house as a reference
Is there a system to play a sound away from the player?
@wanton forge say3D , playSound3D, say, say2D, playSound
good.
then do this:
_relativePositions = _furniture apply {
[typeOf _x, _house worldToModel ASLtoAGL getPosASL _x, _house vectorWorldToModel vectorDir _x, _house vectorWorldToModel vectorUp _x]
};
to translate:
{
_x params ["_type", "_pos", "_dir", "_up"];
_furniture = createVehicle [_type, [0,0,0]];
_furniture setPosASL (_house modelToWorldWorld _pos);
_furniture setVectorDirAndUp [_house vectorModelToWorld _dir, _house vectorModelToWorld _up];
} forEach _relativePositions;
3D sounds are played at a distance and audible within a range, so if you want to have a radio playing use playSound3D or say3D. To end the sound abruptly, delete the object.
Perfect, just what I needed. I love you and your developer mod, you animal.
meow
With low level languages programming style is usually centered around optimization because that code is likely going to be called upon fairly often or you aren't going to have a good processor to run it. With high level languages the code doesn't usually run that much so how quickly and easily you can do it is the main concern. So your argument was essentially what a low level vs high level programmer would argue about.
I am confused... I have a trigger condition that I am 99.997% certain should be returning true right. why am I not seeing the activated callback log anything?
Because it's not 100%๐
@cosmic lichen well yes, I always leave a little room for self correction ๐
Logs:
23:26:32 [KP LIBERATION] [19868.1] [IEDS] [fn_ieds_onTriggerBigCondition] Fini: [_actual, _chance, _runningThreshold, _runningCount, _rollingCount, _trackedCount]: [0.844325,1,0,1,0,0]
Code:
((_rollingCount + _trackedCount) > 0 || _runningCount >= _runningThreshold) && _actual <= _chance;
condition should be met, true if I am doing the math correctly; yet I see no activation callback.
is that all your whole condition?
Should work. But it's 5.30 here so no guarantee ๐คฃ
much appreciated on all counts
yes
well, not "all" the code, but the code that matters, and is logged, contributing to the condition
What happens if you just set the condition to true?
Does it work as expected then?
I could try that
You should
no effect I see no activation callback
oh I see, obvious answer, typo in the func
๐คฃ
I fine tuned the conditions to debug it, it works fantastically. walking, slow walking, no boom, running fast running boom. also,
[] spawn {
while {true} do {
sleep 0.5;
systemChat format ['running: %1', abs speed player];
};
}
why do you use a loop?
player addEventHandler ["AnimStateChanged", {
params ["", "_anim"];
_speeds = ["stp", "wlk", "tac", "spr", "run", "eva"];
_speedsStr = ["Stopped", "Walking", "Tactical", "Running", "Running", "Sprinting"];
systemChat (_speedsStr select (_speeds find (_anim select [9,3])));
}]
