#arma3_scripting
1 messages · Page 652 of 1
yes
Have a one more question, is possible to make AI's static? (not allow them to move from their spawn positions)
@cosmic lichen thank you!
@cosmic lichen tryed this, but my ai's still changing their positions, idk - maybe i doing something wrong
_unit = _model createUnit [_upos,_ai_grup,""];
_unit disableAI "MOVE";
{ _unit enableAI _x; } forEach ["TARGET","AUTOTARGET","ANIM","FSM"];
_unit allowDamage true;
_unit setunitpos "middle";
_unit forcespeed -1;
_unit setCombatMode "GREEN";
_unit setBehaviour "STEALTH";
{ _unit setSkill [_x,_skills]; } forEach ["aimingAccuracy","aimingShake","aimingSpeed","courage","reloadSpeed","spotDistance","spotTime","general"];
_unit addWeapon _weapon;
_magType = selectRandom (getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines"));
for "_i" from 1 to _magCount step 1 do {
_unit addMagazine _magType;
};
_unit disableConversation true;
_unit setDamage 0.01;
_unit setDir(random 360);
I'd like to limit the AR-2 darter so that people cannot control it or view the feed when they are X meters away from it (can't fly drone infinite range basically).
I've figured out how to do the X distance, etc - could anyone provide some ideas on how to forcibly disconnect the user from the UAV control/video?
this syntax does not return a unit
use the first syntax
you could run a loop:
while {alive _uav} do {//loop only if UAV is still alive
if (isUAVConnected _uav) then { //is UAV connected?
_controllers = UAVControl _uav; //get UAV controllers
for "_i" from 0 to count _controllers - 1 step 2 do { //controllers are in this format: [unit1, vehicleRole, unit2, vehicleRole]; unit is every other element (even indices)
_unit = _controllers select _i;
if (_unit distance _uav > _maxDist) then {
_unit connectTerminalToUAV objNull; //disconnect the unit
};
};
};
sleep 1;
};
@little raptor all works fine now, thank you a lot!
np
I'll give that a go! I'll need to do a ton of tweaking, because I'm trying to setup a whole pairing process so that each person has their own individual drone. But that's a real good baseline to start off of
thanks
Pairing process is using this
that loop runs for a single drone
you can better utilize it using an array of drones and forEach
my_uavs = [uav1, uav2];
//
while {count my_uavs != 0} do {
my_uavs = my_uavs select {alive _x};
{
_uav = _x;
//do the rest
} forEach my_uavs;
sleep 1;
}
Is there a way to adjust a unit's blood level within ace 3? I can't seem to find anything about it
what do you mean by blood "level"? you mean volume?
if so:
_unit getVariable ["ACE_MEDICAL_bloodVolume", 6]
other blood related properties and their default values:
["ACE_MEDICAL_bloodPressure", [80, 120]]
["ACE_MEDICAL_woundBleeding", 0]
["ACE_MEDICAL_heartRate", 80]
Is it possible to obtain the Cfg elements from a dialog when it loads, given the ctrl in its load event handler, let's say. I want to review Cartesian elements, for instance. thanks...
how can I get the name of a weapon (not the calssname) through debug console?
nvm got it
getText (configFile >> "CfgWeapons" >> (currentWeapon player) >> "displayName");
huh is it similar for dialogs? controls? if I have _ctrl, then getText (configFile >> (typeName _ctrl) >> "x"), something like that?
not typeName
depends on what you want
the onLoad EH already passes the config to the code
you can save it using setVariable
Is there a way to do this within the zeus menu, whilst in server?
@winter rose I want to query some of its attributes, ^^, x, y, etc
so far I havegetNumber (configFile >> ctrlClassName _ctrl >> "x") but it is yielding 0. or could I just say getNumber (_ctrl >> "x")?
ah ok thanks @little raptor, sorted it out I think, getNumber (_config >> "x")
if you don't have the config as param at hand you can also do
getNumber (missionConfigFile >> "YourDisplayName" >> "controls" >> "ControlName" >> "x")
``` substitute `missionConfigFile` with `configFile` if you are working with a mod/the main game and `controls` with `controlsBackground` (or even `objects`) when wanting to access controls in those subclasses and if the control is part of a controlsgroup you also have to access that config first: `... "controls" >> "ControlsGroupName" >> "controls" >> "YourControl"`
Yes! You will need Zeus Enhanced.
I can’t remember if vanilla Zeus has the functionality but I’d expect not.
depends where and how the display was defined.
it can be in missionConfig, configFile and it can even be under RscTitles
and for scripted displays you can completly scrap the idea of getting a config :)
Many Thanks
I remember trying to look around for a script involving disguising as enemy soldiers, but apparently bohemia does not allow you to pick up enemy uniforms. Is a "disguise script" not possible?
forceAddUniform?
This won't prevent you from get shot from enemies, so use other scripts such as setCaptive will do?
forceAddUniform sounds it should work combined with setCaptive. thank you!
Has someone found the possibility to integrate the phone from the old man in the multiplayer?
https://community.bistudio.com/wiki/Category:Function_Group:_Phone
Hi again and thanks for pointing me in the right direction.
I still don't understand where I go wrong with this script.
What is it that needs til be fixed for the script to spawn in a "I_LT_01_AA_F" with desert camo net?
_veh="I_LT_01_AA_F"createVehicle(player modelToWorld [-8,0,0]);
_animSources = (configProperties [configOf _veh >> "configfile >> "CfgVehicles" >> "I_LT_01_AA_F" >> "AnimationSources" >> "showCamonetHull", "isclass _x && {getText(_x >> "showCamonetHull") != ''}", true]) apply {configName _x};
_veh= animateSource ["showCamonetHull", 1, true];
_textures = (configProperties [configOf _veh >> configfile >> "CfgVehicles" >> "I_LT_01_AA_F" >> "TextureSources" >> "Indep_03", "isclass _x && {getText(_x >> "Indep_03") != ''}", true]) apply {configName _x};
_veh= _textures ["Indep_03", 1, true];
Path to _animSources:
configfile >> "CfgVehicles" >> "I_LT_01_AA_F" >> "AnimationSources" >> "showCamonetHull"
Path to _textures
configfile >> "CfgVehicles" >> "I_LT_01_AA_F" >> "TextureSources" >> "Indep_03"
Quite confusing
- What the last line supposed to do?
- Why you use
configPropertiesto get the name when you already knew the name, and you didn't even used the returned value?
I am a bit new to this. It's like learning a new language.
is it okay to make switch do files for mission flow? its got to read through everything until it finds a suitable case right?
it will iterate through each comparison from top to bottom until a match is found; that is when you can break
I really want to make the script work.
I've now tried these script (and variations of them) but I am not getting the script to spawn in a "I_LT_01_AA_F" with desert camo net. What is it that needs til be fixed for the script to work?
_veh = "I_LT_01_AA_F" createVehicle(player modelToWorld [-8,0,0]);
_animSources = (configfile >> "CfgVehicles" >> "I_LT_01_AA_F" >> "AnimationSources" >> "showCamonetHull") != ''}", true]) apply {configName _x};
_vehicle animateSource ["showcamonethull", 1, true];
_textures = (configfile >> "CfgVehicles" >> "I_LT_01_AA_F" >> "TextureSources" >> "Indep_03") != ''}", true]) apply {configName _x};
_vehicle textures ["showcamonethull", 1, true];
_veh="I_LT_01_AA_F"createVehicle(player modelToWorld [-8,0,0]);
_veh=[vehicle player, false, ["showcamonethull", 1]] call BIS_fnc_initVehicle;
_veh=[vehicle player, false, ["Indep_03", 1]] call BIS_fnc_initVehicle;
depends how many cases you have, and how many times it gets called.
@fresh wyvern ```sqf
not cpp/c/etc.
Thanx a lot! I really made it easier to get an overview 🙂
then you should already see that you're doing something wrong
since the highlighting is messed up
_animSources = (configfile >> "CfgVehicles" >> "I_LT_01_AA_F" >> "AnimationSources" >> "showCamonetHull") != ''}", true]) apply {configName _x};
what on earth is this?
what I said in here
#arma3_scripting message
was to show you how to get the anim sources.
When you know what it is, all you have to do is use:
_vehicle animateSource [_anim, 1, true];
Tied to fill in this :(configProperties [configOf _vehicle >> "animationSources", "isclass _x && {getText(_x >> 'displayName')
I must have been mistaken.
in your case:
_vehicle animateSource ["showCamonetHull", 1, true];
Wow I got it! Thanx for the patience. Seems like textureSource was needed before animateSource 🙂
_veh="I_LT_01_AA_F"createVehicle(player modelToWorld [-8,0,0]);
[
_veh,
["Indep_03",1],
["showCamonetHull",1]
] call BIS_fnc_initVehicle;
is hash faster then select?
any way to trigger a .sqf file on all units with a certain prefix in their name?
Are you going to be spawning new units during the mission?
And are you going to be using the classes for the prefix or the unit role?
im probably going to be spawning new units, and ill be using the internal unit name's prefix, in my case DSA_ since im using spooks & anomalies
however it is acceptable if i cant spawn new units
So if you want to spawn new units and are using cba, look at the
With the handler being "init"
Also taking note of the inheritance line
@royal spruce
ill take a looksie at it soon, thanks
hi guys, i opened BIS' animals module and the first 2 lines are these:
_logic = _this param [0,objnull,[objnull]];
_activated = _this param [2,true,[true]];
how do i find out what is contained in the _this variable?
It contains a logic (since a module is attached to one), and a boolean to know if it should be active.
All additional info is attached to the logic
yes how do i find out what they are?
from config viewer?
that _this variable is an array that contains at least 3 items right?
the _this variable contains all the data that is passed to the function when it's called.
So technically _this could be anything, which is why it uses the param command to make sure the correct items are being passed to the function.
how to know what data was passed to the function by the animals module?
that script IS the module
In that function specifically or from an outside context?
for example i put down animals module, what happens is that module runs the following
[value,value,value] call BIS_fnc_moduleAnimals;
right?
i want to know those values
_logic is a Game Logic (a simple object)
_activated is a boolean
That's it
If your writing in the function that it calls then you can use the _this variable.
If your writing in the function that calls the BIS_fnc_moduleAnimals function then you can access them directly.
If your not doing either then you can only access them if they are defined globally within the function.
what about the 2nd value?
like those are the 1st and 3rd value right
it's obviously not used, so doesn't matter
For modules usually the 2nd item is an array of units.
well i gues... but what i mean is i want to find the code that explains what the module passes to the function
Applies to Zeus Modules only:
// Argument 0 is module logic.
_logic = param [0,objNull,[objNull]];
// Argument 1 is list of affected units (affected by value selected in the 'class Units' argument))
_units = param [1,[],[[]]];
// True when the module was activated, false when it is deactivated (i.e., synced triggers are no longer active)
_activated = param [2,true,[true]];
yes this is what im looking for, thank you!
already gave that answer 3 times 🤷♂️
all modules work the same (except for 3den modules, those are complicated), and it's nothing more than an object, an array and a boolean
what is done with it is inside the module script, no other magic happens there
No. But it can be faster than find/findIf
Thanks
Hey, I have a script that replaces wrecks with working vehicles of the same type but works mostly on the cursorObject command, in conditions and in addAction too. Will the action work only on the wreckage of the person using the action, or also on the wrecks that other people are looking at?
if the action is assigned in a script ranby all players like init.sqf yes it will do stuff for each client
however you need to be careful that its not running the same script across all clients every single time somebody uses the action, otherwise you will duplicate the vehicle once for every player on the server regardless of where they are
you only want it to do stuff for whoever actually used it
if the action is placed directly on an object all players will be able to trigger it until the action is removed or the object deleted
no its the same thing. If you mean _stuff#1.
I'll not assume you mean HashMaps because thats a COMPLETELY different thing than select.
You can read the wiki page of the script function
if it was filled 😉
https://community.bistudio.com/wiki/BIS_fnc_moduleAnimals
Filling module pages is kinda pointless, they are all more or less the same.
When using createDisplay the display underneath hides until the newly created display is destroyed.
Anyone know why this would happen?
because you can only have 1 display at a time, so it will close the previous one
createDialog will allow you to stack UI's
Fairly sure createDialog closes the display underneath?
but will open the previous one again when closed, where displays will just close
cutRsc is also possible, but will only show stuff and won't allow you to use your mouse on it
hides it maybe, dont think it closes it as dialog could be created as child of display underneath and that would cause crash
Well I am attempting to create a dialog/display on top of a dialog without hiding/closing the one underneath.
Normally createDisplay works, but for some reason it seems to hide the dialog underneath.
create those as controls on top of controls for the same dialog
Personally I use createDialog to open a base and switch the Control Groups based on the content I want to present.
But it really depends on what you're trying to build
Hey guys, I need some help modding.
Just ask the question
Well, do I recompile like this? PBO manager won't work rn...
damn I can't post an image
PBO Manager is a super notorious software. At least you should use Addon Builder, preferably PBOProject

No. Use imgur
here
...Where?
(I don't see any imgur or other image hoster link)
(Im just aving a giggle tbh)
And yes, what's the issue?
Well, it's solved.
...??
It was an issue of which address to use/what to check Ig but
that was just my anxiety
I get anxiety flushes, not necessarily attacks, from this type of stuff.
Idk what to call them
anxiety rush is a good description I guess
yea
like my name?
I think I just needed tp.bikey for my bunghole.pbo
yep
IT HAPPENED NEVERMIND
Looks like a broken or corrupt mod
And it looks like a #arma3_config issue instead of scripting
Hmmm would sniper {_x reveal} forEach unit thisList; work
if placed in a trigger that has opfor present as the trigger condition
That line of code most certainly not, but the idea would
how would it be written then
Something like
{
sniper reveal _x;
// or
sniper reveal [_x, 4];
} forEach this list;
whats the 4 for?
See wiki page of reveal
oh facepalm right knowledge level
@exotic flax thanks wasnt too far off the mark with my code jsut in the wrong order
hmmm would while {'triggerName' Activated} do { sniper reveal [_x, 4];} forEach List 'triggerName';} cause the snipers knowledge of the target to remain at 4?
if i placed in a second trigger that was server only and non repeating
thislist, btw?
better (updated)
How would I go about getting all soldier/vehicle classnames?
Excluding uniforms, backpacks, and such.
huzzah i now have a script for sniper support
Please ping me if anyone replies
arma2, is there any way to make field hospital tents invulnerable to being crushed by vehicles?
allowDamage
already used allowDamage. It appears to protect against everything except being ran over by vehicles.
ouch. well then I don't know, sorry
at least this is the case for the field hosptial. don't know about other kinds of objects
in the editor?
enableSimulation?
field hospital is placed in the editor, and it's init line is this allowdamage false
i'll try enableSimulation
just tried enablesimulation. Didn't work. However, I did discover that allowdomage does prevent ME from running over the tent in SP. However, I've definitely seen the ai run over and destroy the tent in MP. Weird.
maybe this?
https://community.bistudio.com/wiki/allowDamage
This command has to be executed where object is local and as long as object does not change locality the effect of this command will be global. If object changes locality, the command needs to be executed again on the new owner's machine to maintain the effect
everything is local to my machine, in fact I'm playing by myself at the moment.
and I'm the server
well you can try the handleDamage event handler too
Hello, Q: concerning LISTNBOX, what does control lnbSetValue [[row, column], value] do?
Is it setting a value "behind" the row/column in question? or is it actually affecting the shown content?
the docs suggest "additional value", but I don't know what that means exactly...
https://community.bistudio.com/wiki/lnbSetValue
values and data are additional elements that you can add to your listBox and listnBoxes. They won't affect the text
or as you put it they're "behind" the text
the tooltip on the init fields has me scared. Just to be clear it is called ON every machine for every player that joins while the script is running, not it is called on every machine every time a player joins in progress.
right?
indeed
ok I can stop sweating now, thanks
so if you put player setDamage 1; in the init field of an object, it will kill ALL player every time someone joins 🤣
lmao that is nasty
and also, am I able to edit properties of entire groups by referencing the group's variable name?
like using this in a trigger pmcs enableAI "Move";
pmcs being the name of the group
it appears not
would also help if I set the trigger activation -_-
read the command description
the wiki says nothing about whether it does or doesn't work for entire groups
Syntax
Syntax:
unit enableAI skilltype
Parameters:
unit: Object
skilltype: String - See disableAI for possible values.
Return Value:
Nothing
the wiki lists the supported data type for each parameter
Object being any specific instance of a class?
you can click on it and read its description too
object means stuff like: units, vehicles, buildings, etc.
in this case it only applies to units of course
enableAI only works on single units
if you want to apply it to the entire squad you could do a foreach
its easy to get an array of units in a group using units command
not the group name
the group itself
as a variable
yes
no such thing
I see the edit
thegroup itself is a datatype
and inside forEach you use _x
well theres one part of it
_x gets swapped for whatever element in the array that is being ran
theres a group command to get the group data from an object
and do I need to use group to specify
you will replace pmcs with the group variable
pmcs was a group
yes ok, so just use _x inside the foreach
and you don't need a group for the units command
it also works with objects
e.g. units player
wasn't even aware of that
although these days its a bit hard for me to stay up to speed with every little command in the game
lol yeah I'm not even gonna try
making missions is fun
but I dont have that level of dedication
stuff like Java sure I will learn all that but Arma... language? meh
sweet, it works
thanks for the help guys
Hi! I was hoping I could get some help understanding the addMagazineTurret command. Basically, I'm trying to set ammo on the CUP Tunguskas so that they only have 1 AA missile. The problem is, their default magazine comes with 8. So from what I understand, I should be able to run:
_this addMagazineTurret ["CUP_8RND_9M311_Tunguska_M",[0,1]];
and it would only set them to one missile. However this seems to not do anything at all and I'm not sure if I'm fully understanding the syntax.
that command simply adds the magazine. It doesn't necessarily load it.
Are you sure the syntax is the only thing you don't understand? For example what is _this?
Are you sure the turret path you provided ([0,1]) is correct?
And you didn't provide any ammo count. It's the third element in the array (i.e [magClass, TurretPath, AmmoCnt])
To actually load the magazine, first you have to remove the current magazine, then load the new one.
There's also this command but it's semi-broken:
https://community.bistudio.com/wiki/setMagazineTurretAmmo
any one help me really quick, i just want some practice,
i want to make a mission where the players will have to kill a target then move to the mission end zone, how to i set it so that the mission end is not availble untill the target is dead and how to see the mission end to require all players in the zone to finish the mission
what script do i use to keep the mission finished disable untill the target is killed?
I suppose you use a trigger? Otherwise "make end mission unavailable" is quite simple, just do not call it
what code do i use to keep it disable untill the target is killed
conditions : this && not alive theTargetToKill
thenks
G´day gentlemen! I have a little waitUntil issue i cant get around... Its pretty simple: An unit has to move to a position specified like this: ```sqf
nearestArray = nearestLocations [position vip, ["nameCity","nameVillage", "Hill"], 10000];
nearestPos = nearestArray select 2;
nextpos = getpos nearestPos;
vip doMove nextpos;(yes, i know that the last step isnt necessary... 🙂 ) Then i´d like to put a simple waitUntil thingy:sqf
waitUntil {vip distance nextpos < 100}; Aaaaand its ***generic error in expression***. I dont understand why... All the data right up until the waituntil line are fine ( *[x,y,z] coords and sutff....*), even if i trysqf
vip distance nextpos``` in console, a simple number appears... But that waitUntil just aint doing its job. Any suggestion? Thanks!!
did you read the whole error
yup....
it probably says "cannot suspend" because you are in a unscheduled script which, cannot suspend
how is your script executed?
i tried both, excVM-ing, remoteExec-ing and right in the debug console in Eden.... Its not running from init or initServer or anything...
error: ´waitUntil {vip distance nextpos l#l < 100}; ´ Error Generic error in expression. Both from Exec and debug console...
Ah
l#l
shows where the problem is
its probably trying to compare array (nextpos) to number. which it can't
It should tell you that in the error message though
waitUntil {(vip distance nextpos) < 100};
Trouble being... the nextpos var is a neat [x,y,z] ...
So there is no reason why the distance shouldn't fire...
oh thanks! It runs now! But... still a little issue... The vip unit stays still.... He simply wont move. Why? I mean.... the code is so simple... ```sqf
nearestArray = nearestLocations [position vip, ["nameCity","nameVillage"], 10000];
nearestPos = nearestArray select 2;
nextpos = getpos nearestPos;
vip doMove nextpos;``` I get no errors. the destinations are set correctly (checked through console....) But why does the guy stay still??
Even after some time has elapsed.... not one single step
how far is the position away?
if its too close it might already think it arrived at target
if (airdrop distance [3184.07,12914.4,0] <= 3) then {deleteVehicle parachute};
if (airdrop distance [3197.91,12899,0] <= 3) then {deleteVehicle parachute};```
2.9km @still forum
@warm hedge I thought I figured it out, but I didnt
I set all location to one global variable, but it isn't looking for an array?
Is there a simple way of compiling the three locations?
What is airdrop?
"C_supplyCrate_F"
You meaning it is a string or an object?
object
Okay, so... your question, is kinda confusing for me. Can you elaborate?
I have three if statements doing the same thing can I compile them to check all three in one statement?
I assume the airdrop drops from the sky, and if airdrop nearly lands, you wanted to remove the parachute right?
yes
Then you can simplify the script with justsqf if (getPosATL airdrop#2 <= 3) then {deleteVehicle parachute};
i forgot again how to test if a variable is a certain type.
it was something along the lines of
_bool = (_myVar isKindOf []) //true if myvar is an array```
typeName
isEqualType
any easy way to shuffle an array?
cool. wonder why i didnt find that one lol
BIS_fnc_midweekBeer, perhaps? 🙂
quick question: I'd like to remove a BIS_fnc_holdActionAdd with a BIS_fnc_holdActionRemove. Where do I find the action ID assigned by the BIS_fnc_holdActionAdd?
A2OA: What do the "endurance" and "general" ai skills actually do?
I get that, but as the wiki for the holdActionRemove says I need to enter a number(the ID) which means I need to see it somehow. Do I just run the script and use a hint to show it?
[
_myLaptop, // Object the action is attached to
"Hack Laptop", // Title of the action
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen
"_this distance _target < 3", // Condition for the action to be shown
"_caller distance _target < 3", // Condition for the action to progress
{}, // Code executed when action starts
{}, // Code executed on every progress tick
{ _this call MY_fnc_hackingCompleted }, // Code executed on completion
{}, // Code executed on interrupted
[], // Arguments passed to the scripts as _this select 3
12, // Action duration [s]
0, // Priority
true, // Remove on completion
false // Show in unconscious state
] remoteExec ["BIS_fnc_holdActionAdd", 0, _myLaptop]; // MP compatible implementation
Using this as an example. I dont know where the 10 comes from in the holdActionRemove. I might be stupid but as the command wants me to enter a value I dont have I feel pretty retarded.
[ player,10 ] call BIS_fnc_holdActionRemove;
you can't get the return value of that remoteExec
where do you remvoe the action?
in hackingCOmpleted function?
yea, but I run it in a separate .sqf - as from my experience - it only works for the _caller if I do it via the holdAction
seperate .sqf means what?
I add the holdAction via a execVM in a .sqf I than execute a seperate execVM for the code complete.
but why execVM?
if you're already calling _this call MY_fnc_hackingCompleted?
It does look weird. But if I put the removeAction in the code domplete it only works for the _caller
ah every player gets the action?
yea, and once it completes it should be removed for everyone
Move your hold action adding into a function via CfgFunctions.
inside that function, store the actionId from holdActionAdd in a variable
the remoteExec your function, not the holdActionAdd
then to remove, you make a second function that uses your variable
and then again you remoteExec your second function to everyone
Tying my hand at scripting for the first time. Following a tutorial, but I can not even make a simple hit message work. I have made a init.sqf file in my mission file but nothing is happening. Any help?
An example of what Dedmen said:
[_myLaptop] remoteExec ["MY_fnc_addAction", [0, -2] select isDedicated, true];
fn_addAction.sqf:
params ["_myLaptop"];
_actionID = [
_myLaptop, // Object the action is attached to
"Hack Laptop", // Title of the action
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen
"_this distance _target < 3", // Condition for the action to be shown
"_caller distance _target < 3", // Condition for the action to progress
{}, // Code executed when action starts
{}, // Code executed on every progress tick
{ [_this#0] remoteExec ["MY_fnc_removeAction", [0, -2] select isDedicated, true]; _this call MY_fnc_hackingCompleted }, // Code executed on completion
{}, // Code executed on interrupted
[], // Arguments passed to the scripts as _this select 3
12, // Action duration [s]
0, // Priority
true, // Remove on completion
false // Show in unconscious state
] call BIS_fnc_holdActionAdd;
_myLaptop setVariable ["MY_action_ID", _actionID]; //store the ID locally
fn_removeAction.sqf:
params ["_myLaptop"];
[_myLaptop, _myLaptop getVariable ["MY_action_ID", -1]] call BIS_fnc_holdActionRemove;
code?
Dummy of the day award goes to.... Fatboy! I never actually saved the file on notepad++, so it never worked.
Got a little ahead of my self than got lost. Thanks for the time, I am sure ill be back with more questions later lol.
Hi again and thanks for helping out last time.
Is there an equivalent to disableAI to human characters?
like:
this disablePlayer "NVG"
how about you just remove the nvg?!
Thanks a lot!
Enables or disables transport NV (Night Vision)
probably won't work on infantry
@fresh wyvern ☝️

So you can't have this look Item_NVGogglesB_gry_F, but without the night vision function? (standard and therminal, but no NV)
not unless you make a new one and remove the NVG using config
In v2.02 you can attach a fake nvg model to your head
and have it follow the head bone
but that won't even have the TI
Nice one x)
disclamer.. user has no experience in pp efects
feel like you could also figure out some way to construct an event handler that detects the "NVG on" action and uses action to immediately turn them off again
construct an event handler
users can't make them
at least not reliably
you could use the keybinding (KeyDown)
but again not reliable
but tbh, if it came to ruining something like that, I'd be looking to rework the story, not the equipment
unit action ["NVGogglesOff"], not that other command
https://community.bistudio.com/wiki/currentVisionMode returns what unit is using
..........I don't mean a new type of event handler
I mean figure out which of the existing types you can use to make an EH that does it
you could use the keybinding (KeyDown)
but again not reliable
Is it possible to scrip an item to look like an other?
AnimStateChanged might be able to do it if there's a universal NVG animation name
nvgs don't use animations
and even if they did, they'd use gestures (actions), which again do not have EHs
remind me again why the KeyDown option is not reliable
users might change te key
you can get the key they've bound it to
One reason is key combos
E.g. you can't return something like ctrl+Middle mouse button
which is what I use for NVG
default is N, but thatsnot a toggle it's a multi daytime> nvg> TI
there is action keys for that:
https://community.bistudio.com/wiki/actionKeys
but my point still stands
you can't return something like ctrl+Middle mouse button
All numbers in SQF are floats and those are only precise up to 6...7 digits.
486539264 + 19 == 486539264 + 20
-> true
The DIK codes for 'LCtrl + R' and 'LCtrl + T' are indistinguishable.
one of the notes on that page
Could str them and compare that
this sounds horrific. Why....why is it like this?
So this if probably why get so many error setting up my HOTS x)
"F#" keys keeps getting added in unless I disable things underways.
Because a single number type is easier to handle then multiple
I didn't mean the part about using floats, I meant why make a key registration system that ends up having two different key combinations register as the same thing
On the original topic, I reckon you could use a keyUp EH, ignore which key it returns and just use currentVisionMode to check whether the vision mode was set to NV. But crippling the NVGs through PP effects is probably the better route.
not a bad idea
wouldnt the end effect be dependent on users selecyed graphics options?
I don't think the ColorCorrections PP type is affected by graphics options, so you could just wipe out the contrast and brightness and basically make a black screen
Is there a way to set a value to indefinite?
Setting the number 10 underneath to value -1 does not work.
this addItemCargo ["Integrated_NVG_F", 10];
Ok, thank you.
(Item isn't available in arsenal..)
you could use an event handler on the object, and refill it after someone took an item out
Cool how?
Do you know how I combine it into a working script?
this addItemCargo ["Integrated_NVG_F", 10];
this addEventHandler ["ContainerClosed", {
params ["_container", "_unit"];
}];
Does anyone know how to use (https://community.bistudio.com/wiki/createTask) the createTask code?
or maybe have an example?
you can check the contents of _container and if it has less than 10 NVG's, add one
How do you do that?
read up on https://community.bistudio.com/wiki/Arma_3:_Task_Framework_Tutorial (which is for Arma 3)
Anyone who know how to combine these two scripts so that they work with the warlords add on?
class CfgWLRequisitionPresets
{
class A3DefaultAll
{
class EAST
{
class Vehicles
{
class I_LT_01_AA_F
{
cost = 3000;
requirements[] = {};
};
};
};
};
};
[
_veh,
["Indep_03",1],
["showTools",0,"showCamonetHull",1,"showBags",0,"showSLATHull",0]
] call BIS_fnc_initVehicle;
so which parachute class do i use on big vehicles (apc's and such)?
@fair drum Check it directly yourself for each vehicle? :)
https://community.bistudio.com/wiki/Arma_3:_Vehicle_in_Vehicle_Transport
Defined in VehicleTransport >> Cargo
lol i guess i need to use many more parachutes, 1 doesn't cut it and it just slams into the ground lol
Doubt that is possible but u could maybe temporarily reduce mass of your vehicle... I dont really know what a paradrop considers during.... paradropping
hmm... what if i attached the vehicle to the parachute instead of the parachute to the vehicle? let me try that
ah, if it uses attachto, then yeah u probably got confused with that I believe
yup thats what it was. you have to attach the vehicle to the parachute instead of vis versa
Anyone good with scripting triggers or alive checks?
@heady quiver What's the question?
I concur
So im creating a task right, and with that tasks comes a radio tower and i wanna check the 'alive' status on that object and update the task if needed.
couldn't you just check it's destruction state?
Do you spawn this tower yourself or do you use an existing one on the map?
I want if the tower is destroyed update the task.
I spawn it randomly
objective = "Land_TTowerBig_2_F" createVehicle _player_circle;
that works?
sure why not
Doesn't the code run once and stops?
yes
Then it wont work right
Did you check the wiki?
Its runs creates tower also checks state right after the creation and thats it
Dont i need a while loop?
what if you used BuildingChanged
Got an example?
addMissionEventHandler ["BuildingChanged", {
params ["_previousObject", "_newObject", "_isRuin"];
}];
wiki
Well..
lol
I was wondering if needed to create a trigger with that tower to check state.
Mmmm
You can use the handler, waitUntil, while or a trigger
your decision (handler is most efficient)
i concur
If like most of new starters, u re not afraid of eventhandlers and the risk of them biting you...
How would:
addMissionEventHandler ["BuildingChanged", {
params ["_previousObject", "_newObject", "_isRuin"];
}];
This look like if i used:
objective = "Land_TTowerBig_2_F" createVehicle _player_circle;
wait are you just using this as an objective to destroy a tower? I'm sure there are plenty of premade scripts via googl
Well not really that
ohk
More dynamic but thats another convo
lolk
But not sure what to do with
addMissionEventHandler ["BuildingChanged", {
params ["_previousObject", "_newObject", "_isRuin"];
}];
`
// Create object (like tower etc)
objective = "Land_TTowerBig_2_F" createVehicle _player_circle;
// TODO: CHECK IF OBJECTIVE (TOWER IS ALIVE)
// Update task
["task1", "SUCCEEDED"] call BIS_fnc_taskSetState;
`
This is what i got lol
Hey guys a friend of mine started to mod an exile server, but now were stucked on one specific thing.. maybe one of you guys got an answer for that. some time players got stuck in combat mode and all the other features like repairing/lock a vehicle, food/drink/hp bar freezes or stop working for him until he reconnects to the server. We didnt find any answer for that..
I would check the debug console and see if you come across any errors while playing...
@heady quiver sorry im not too sure how to help you im fairly new with scripting myslef so
sup
MyTower = "Land_TTowerBig_2_F" createVehicle _player_circle;
addMissionEventHandler ["BuildingChanged", {
params ["_previousObject", "_newObject", "_isRuin"];
if (_previousObject isEqualTo MyTower && _isRuin) then
{
["task1", "SUCCEEDED"] call BIS_fnc_taskSetState;
};
removeMissionEventHandler ["BuildingChanged", _thisEventHandler];
}];```
oh damn
is it a single player mission or MP?
MP
In my multiplayer mission, I want generators to randomly spawn across the map, but in predefined locations. Like a place markers down and get generators to spawn on the model right, but I only want like 3 or 4 to spawn every mission, just in different spots, which keeps the mission new and poppin.
A) Is this possible within SQF?
B) How would I go abouts it. I was contemplating using SelectRandom with the array of generators, but would that keep them from spawning in the mission?
Thanks
also @cosmic lichen that looks right bro nice
I updated the code to remove the EH
Also, I am not 100% sure about locality since EH is local, and create vehicle global.
@heady quiver epic bro
@cosmic lichen My hero
@warm swallow I think you can make a map area for example get like 4 random radius positions in that area marker and spawn vehicle (generator) right?
for "_i" from 0 to (floor random 4) /*[1,3] call BIS_fnc_randomInt; works too*/ do
{
createVehicle selectRandom [generators]
};```
@warm swallow Something like this. This is not valid code though
i would be afriad that they spawn somewhere i dont want lol, like in a wall or outside a playable area
@cosmic lichen could you explain the first line?
I thought you have predefined positions
for is to execute same code for multiple times
@warm swallow Have you checked the biki?
yea, maybe like 20 or so positions where they could spawn, but then they only spawn at like 3
(floor random 4) put that into the debug console. It should be clear what it does then
@cosmic lichen You know how to generate a random string?
Define random.
like length of 10 al random
ay im a noob does this go in the init file?
letters
What init field`?
where do i put the code, sory
initServer.sqf preferably
alright
Happy
yes
myletters = ["a", "b", ....];
You can also add execVM"filename.sqf"; to that init file and make your code in that filename.sqf too keep it clean.
if im not wrong.
@cosmic lichen yea but thats array i mean more like
_rNumber = random 1;
but then for letters.
selectRandom is your friend
im a serious poo at scripting, do you guys have any suggestions or guides? I've looked through the biki a lot, and im not like getting it
This is inefficient for 2 lines of code.
@cosmic lichen assuming he was expanding ^^
Q: I would like to execute code on a client from a server-side mod, is that possible?
Do I have use publicVariable to make the code available on the clients, or can I just remoteExec the code on each client?
PS. I want to add event handlers on all clients, while the code is on the server only.
Just remoteExec?
If the mod is server side, then the client does not know the code
Just use remoteExec from the server to the client
also @cosmic lichen would I spawn the generators in the editor, and control which ones spawn in the mission, or put down markers where they could spawn and do it that way?
Whatever is easier for you.
ok
I usually try to separate Editor / Scripts whenever possible
i really appreciate all the help
If you have 3den Enhanced installed you can pre-place the generators, select them all and select "Copy Positions to Clipboard" then paste those into an sqf file
Quickest way I believe
i do
Need help to clarify something:
createVehicle is to spawn an object and createUnit is for a AI Unit right?
yes
private _rNumber = random 1000; this generates a random number between 1 and 1000 right?
1 (inclusive) but never 1000
Thanks @cosmic lichen
its just so i can randomize the task
Guys, is there an EH that fires when trying to open/close doors? I want to check if player has the inventory item "keys" and if so the door unlocks
No
ooooof
@cosmic lichen last question of the night, my creating task BIS_fnc_taskCreate expects a string but i want that random generated number in that string area bit how would i do it?
cuz it wont accept a int
private _rNumber = random 1000; into private _myTask = [groupOfPlayers, "HERERANDOM", [_description, _title, _waypoint], objDocuments, true] call BIS_fnc_taskCreate;
Check the wiki format
Not that I know. Perhaps you can detect the closest door somehow?
Or, detect all doors in the AO and lock/unlock them depending on whether the player has the key
private _myTask = [groupOfPlayers, format(formatString,_rNumber), [_description, _title, _waypoint], objDocuments, true] call BIS_fnc_taskCreate; like this? @cosmic lichen
No, read the format page carefully
Mmmm
private _myTask = [groupOfPlayers, toString _rNumber, [_description, _title, _waypoint], objDocuments, true] call BIS_fnc_taskCreate;
Maybe i just need to sleep xD
toString is not doing what you think, at all..
Cant think anymore.
Just read the examples on formatpage. Your first code was close
but the syntax is simply wrong
- staring hard at screen *
hold up
private _myTask = [groupOfPlayers, format("%1",_rNumber), [_description, _title, _waypoint], objDocuments, true] call BIS_fnc_taskCreate;
almost..
I am starting to think that the examples are wrong on the biki
What did i do wrong?
he he he
example 1 is what i have
even example 2
i dont get it
ohhh
private _myTask = [groupOfPlayers, format["%1",_rNumber], [_description, _title, _waypoint], objDocuments, true] call BIS_fnc_taskCreate;
thank god
THANK GOODNESS
private _myTask = [groupOfPlayers, format["task_%1",_rNumber], [_description, _title, _waypoint], objDocuments, true] call BIS_fnc_taskCreate;
jeez this took way too long
But then again its 02:06 in Amsterdam
i need sleep.
Same here 🙂
I appreciate the time and help @cosmic lichen
yw
Goodnight all!
I started clearning up the biki page just because of you T_T
gn8
I guess this is wrong? I'm trying to add an element into an array inside a dynamically formed global variable
_skillWest = format ["WFBE_CL_VAR_SKILL_WEST_REQUESTID_%1", _skillWestRequestID];
missionNamespace setVariable [format ["WFBE_CL_VAR_SKILL_WEST_REQUESTID_%1", _skillWestRequestID], _skillWest set [count _skillWest, _skillWestRequestIDplayerSkill]];
WFBE_CL_VAR_SKILL_WEST_REQUESTID_%1?! 
You should consider choosing shorter names for variables.
Also, _skillWest is a STRING
I don't know what you mean by array. There's no array there
I don't mind long variable names as long as they're readable. Quoting one of the most famous programmers in the world, "any fool can write code that computer can understand, but it takes a true programmer to write code that humans understand" 😛
Fixing those issues you mentioned now
_skillWest = missionNamespace getVariable format ["WFBE_CL_VAR_SKILL_WEST_REQUESTID_%1", _skillWestRequestID];
Better now? @little raptor 🙂
no
Haha
I'm too used to strongly typed languages, I want a nagging mommy IDE to take care of wrong types of variables
😆
so im using markers as spawn locations right. Is there a way to change what orientation the spawned object is?
change the orientation of the marker
although not sure if the respawn framework follows that 🤔
yeaaaaaa
that does seem like the obvious answer, ill try it thanks
also @cosmic lichen solution to my prob.. not perfect but solution nonetheless. Place markers where you want spawn locations to be. right click object > Select Spawn Location. then click the corresponding object
Not sure if this is the right place to ask, but I'm having a bit of trouble using cameras to render to texture. Whenever I use
_camera cameraEffect ["Internal", "BACK", "myrendersurface"];
or
_camera cameraEffect ["Terminate", "BACK", "myrendersurface"];
it also closes the Zeus/Spectator camera as well, any way to get around this?
A2OA: I'm making a custom cover system. How do I force an ai unit to stop shooting and to move to a position?
combat mode "BLUE"?
I'm trying to calculate a difference between a projectile's hit location on an object and a specific memory point (on a building's door handle), but the value changes depending on which door I'm shooting at.
last_pos = [0,0,0];
[_projectile] spawn {
_projectile = _this select 0;
while {alive _projectile} do
{
last_pos = getPosATL _projectile;
sleep 0.01;
};
};
_bulletLandPos = _projectile worldToModel (getpos _building);
_memPoint = (_doorArr select 1) select 4;
_memPointPos = _building selectionPosition [_memPoint, "Memory"];
hint format ["%1\n%2\n%3", _bulletLandPos, _memPointPos, _bulletLandPos distance _memPointPos];
on one door, the impact hints between 4 and 5, and on another its between 11 and 12
don't use getPos
getposvisual?
I was already on the page, deciding which to use
Syntax:
getPos object
Parameters:
object: Object
Return Value:
**Array - format PositionAGLS **
now compare that to worldToModel and you'll understand
last_pos = ASLToAGL getPosASL _projectile;
_bulletLandPos = _projectile worldToModel (ASLToAGL getPosASL _building);```
``worldtomodel: position: Array - world position, format PositionAGL or Position2D``
assuming I'm right in converting the position to AGL this way, its not fixing the problem
what is _doorArr?
it just passes the memorypoint for the handle
well you're using _projectile worldToModel
you should use building
@agile pumice ```sqf
_bulletLandPos = _building worldToModel (ASLToAGL getPosASL _projectile);
what about last_pos then?
I don't know what that even is
you don't use it
I think I accidentally removed it from one of the calculations by mistake
_bulletLandPos = _building worldToModel last_pos; maybe
okay, so now the values are similar but they're like 4000+
the x for _bulletLandPos is 4000 for some reason
I tried forcing unit to move by setting combatmode to blue. tried a bunch of other things as well. Can't seem to get them to do it at all. Can they not navigate amongst bushes?
but it should be worldToModel so that doesn't make sense
Their path generation is a bit flaky.
It depends how dense it is.
See this:
https://en.wikipedia.org/wiki/A*_search_algorithm#/media/File:Astar_progress_animation.gif
They're not going to any position I've selected. In fact they don't seem to even be trying.
perhaps last_pos never updates
check its value
I bet it's still [0,0,0]
what command do you use to move them?
yeah it is 0,0,0
that's obvious
because:
- you're using a scheduled code
- you set the initial value to [0,0,0] (while it should at least be the projectile's initial position)
i did dostop and then domove
doStop, sleep 0.01, moveTo
try that
@agile pumice also, store the variable in the projectile's namespace
you don't have to make a global variable
it didn't hint 0,0,0 that tme
what time??
when the hint was in the while block
I didnt think a local variable could be updated when used inside a spawn block
@agile pumice ```sqf
_projectile = _this select 0;
_lastPos = ASLToAGL getPosASL _projectile
while {alive _projectile} do
{
_lastPos = ASLToAGL getPosASL _projectile;
sleep 0.001;
};
_bulletLandPos = _building worldToModel _lastPos;
_memPoint = (_doorArr select 1) select 4;
_memPointPos = _building selectionPosition [_memPoint, "Memory"];
hint format ["%1\n%2\n%3", _bulletLandPos, _memPointPos, _bulletLandPos distance _memPointPos];
because you're doing it all wrong
I didn't notice it
all inside that spawn block?
yes
well, dostop sleep and then domove, kind of sort of looks like they're moving toward the position. But it's hard to tell. They never get very close to the position. I also notice that movetocompleted and movetofailed never appear to trigger.
moveToFailed typically triggers after 13 seconds
what about movetocompleted
if you had A3 you'd have better ways to check
dunno, never tried that
okay, it seems to work
thanks for the help
_building = _doorArr select 0;
[_projectile,_doorArr] spawn {
_projectile = _this select 0;
_doorArr = _this select 1;
_building = _doorArr select 0;
_lastPos = ASLToAGL getPosASL _projectile;
while {alive _projectile} do
{
_lastPos = ASLToAGL getPosASL _projectile;
sleep 0.001;
};
_bulletLandPos = _building worldToModel _lastPos;
_memPoint = (_doorArr select 1) select 4;
_memPointPos = _building selectionPosition [_memPoint, "Memory"];
_distance = _bulletLandPos distance _memPointPos;
//hint format ["%1\n%2\n%3", _bulletLandPos, _memPointPos, _distance];
if (_distance < 0.5) then {
_doorArr call saf_fnc_breachOpenDoor;
};
};
np
is it possible to get the ai to move in a direction instead of toward a point?
wdym?
well, trying to get them to move to an exact point seems to be pretty much not working at all.
@agile pumice btw I still recommend unscheduled code. like eachFrame EH
So i wondered if you could just get them to move in a direction instead
you can disable their AI "MOVE" fsm
and play the move animation on them
and adjust their direction in a loop
using setVectorDir
not setDir
the animation is probably going to be choppy as heck though on the loop. might need a loop accurate to the 0.001 mark and timings don't work that exact. i tried messing with the walk animation before and if you call it a single time, it last i think 4.88x seconds
is there a built in way to get the average recent velocity of a unit?
nearestobjects over 10 meters, vs. lineIntersects 10 meters. Which do you think is less expensive?
velocity or speed over time?
nearestobjects over 10 meters, vs. lineIntersects 10 meters. Which do you think is less expensive?
what do either have to do with the "average recent velocity of a unit"?
and... we're back.... electricity is back on in the Tank house
Does anyone know how i can access a private var from within a addMissionEventHandler ?
if its private somewhere else... there is no way
[_taskName, "SUCCEEDED"] call BIS_fnc_taskSetState;
private _rndNmb = floor (random [600,800,1000]); private _taskName = format["task_%1", _rndNmb];
mmm
So i got this right:
addMissionEventHandler ["BuildingChanged", { params ["_previousObject", "_newObject", "_isRuin"]; if (_previousObject isEqualTo objective && _isRuin) then { [_taskName, "SUCCEEDED"] call BIS_fnc_taskSetState; }; }];
But he can't access the _taskName
_taskname needs to be in the same scope, or privated in a lower scope
Mmmm
is there a reason _taskname has to be local?
Not really
make it a global then... taskname woud seem to be the sort of thing that should be global, or maybe even public
How would i do that exactly?
take away the underscore
yep
Ah make sense now
🙂
Lets check if it works
yes, if you privated the variable somewhere, remove that
nah, coffee is for heathens and americans... im neither lol
😢
or, indeed, civilized lol
hehe
Hello I am working on WarMachine game mode. I would like to ask you for help.
How to make object semitransparent and in one color (green, red…). Thank you
I would like to have the object (fortification) visible before placing, to know where it will be placed.
Here is the code where i want to use it
f1=[ player, //target "+ Sandbags barricade high", //title "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", //idleIcon "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", //progressIcon "player==leader player && coolDown==false", //conditionShow "true", //conditionProgress {hint"Sandbags barricade will be build 2m in front of you";}, //codeStart { //VISIBLE OBJECT - SEMITRANSPARENT, ONE COLOR - how to do it? //USE COMMANDS createVehicle, attachTo... }, //codeProgress { _posZ = getPosAtl player; _bag = createVehicle ["Land_SandbagBarricade_01_hole_F", (player getRelPos [1.8, 0]), [], 0, "CAN_COLLIDE"]; //1.6 _bag setDir (getDir player); _bag setPos [(getPos _bag select 0),(getPos _bag select 1),(_posZ select 2)]; fort1 = 1; hint""; [1] spawn wrm_fnc_V2coolDown; systemChat "fortification built"; }, //codeCompleted { //delete semitransparent object //USE COMMANDS detach, deleteVehicle }, //codeInterrupted [], //arguments 6, //duration 0.3, //priority false, //removeCompleted false //showUnconscious ] call BIS_fnc_holdActionAdd;
I don't know off hand but I would look at the old becti game mode cause that has something that you want in it.
Guys simple question i wanna wrap my code into a function and call it manually how would i do this?
functionName = { // Code here };
Just wrap it in here?
Mmmm
I did wrap it in that and added into the init.sqf so i can add multiple functions in there but not sure how i would call
yes, need to restart so the init is reread
Btw
Do other people have access to these files when i make a mp game for my friends?
you can recompile the function without restarting from inside the debug menu > functions
Ah good to know
For example i got this code where i have a trigger on a laptop that executes a piece of code.
you might want to make yourself familiar with locality
if you're doing MP stuff
your function, for example, if its made in init.sqf, then all players and server will have it
is useful
for me, if it aint a missing semicolon or just bad logic, it's locality thats breaking stuff in MP
hehe welcome to my world
addAction ["Start a new mission", { call createDestroyMission; }];
i want something like this but this doesn't seem to be the right syntax
virtual arsenal and addAction are local. You have to run it on all clients. use remote exec
to work in MP I use mostly remoteExec and publicvariable
https://community.bistudio.com/wiki/remoteExec
https://community.bistudio.com/wiki/publicVariable
You need to add an object to add the action to.
e.g
player addAction ["Hello", {systemchat "Hi"}]
The player object has an action added to them which prints "Hi" in chat when the action is pressed
Yea i fixed it
Although it is recommended to add the action to an object other then the players object, or else the condition will be checked every frame.
I created a white board in the map and added this to its init:
this addAction ["Search & Destroy", {call createDestroyMission}];
Seems right?
Yes, although because you've not included any of the optional items in the array the action will be usable for up to 50 meters away.
So you can have a read of this https://community.bistudio.com/wiki/addAction
And it lists all the optional parameters for the addAction command
this addAction ["Search & Destroy", { call createDestroyMission; systemchat "Target has been found." },nil,1.5,true,true,"","true",3,false,"",""];
Got it 🙂
3 meters interaction
might want to add a cursorobject clause, so the action only appears when player is looking at the object
The action is added to the object, so that's already done by the engine.
ah right.. most of my addactions are on the player
Btw i got this random number gen but its not exactly what i want
rndNmb = floor (random [1,9999,9999]); what is this doing xD?
i just want a number between 1 - 9999
thats what i was looking for
your script is choosing 1 of those 3 numbers at random
When should floor return 0 when the lowest input is 1?
its going to return 9999 2 times out of 3 and 1 the rest
oh yes... well spotted
random != selectRandom
*nods
- stares *
Btw
Does one know how to get the actual name from an object?
objective = format["%1",object] createVehicle _player_circle;
i didnt name it but for example Land_TTowerBig_2_F this is the code name but i want like the title of that item
hint format ["Name is: %1", objective]; <-- this returns the name of the p3d file...
why do you need it?
you would have to set vehicleVarName
Well i want the task name to be something like: Destroy the namehere
so i need the actual name of the tower i created not the file name
getText (configFile >> "cfgVehicles" >> _type >> "displayName"
wowow
where _type is the classname
format ["Destroy the %1.", getText (configFile >> "cfgVehicles" >> typeOf objective >> "displayName")];
Mmm this works but something is off with my code
it always says 'radio tower' even tho sometimes a generator spawns
forget that
it works ty ty
Btw what editor you guys use for sqf files?
^^^ _this ^^^
hot damn
Is there a way to obtain all tasks?
Edit: currenttask player isequalto tasknull check if player has task if so he can't ask for another one (this works) but i want to check if bluefor has tasks at all
Check if any player on side west has any task. If yes, then _haveTasks=true;
_haveTasks = false; _blueBoys=[]; {if(side _x==west) then (_blueBoys pushBackUnique _x;)} forEach allPlayers; {if (count (_x call BIS_fnc_tasksUnit) != 0) then {_haveTasks=true;};} forEach _blueBoys;
Nice
Im gonna check it now
Think we missing a )
Actually what im really looking for is if BlueFor has any uncompleted tasks
then (_blueB there is a brace missing
But why loop through them twice?
Just put this into one loop
Mmmm
Can't i just do something like count(player call BIS_fnc_tasksUnit) ?
but with a filter or something
i just wanna know if bluefor has has an active task (only 1 allowed at the time)
Well
Why check this afterward
Just prevent them from taking more than 1 task at a time
it will be at the beginning of the function
yea
thats the idea
at the beginning of my function createDestroyMission i wanna check if they already have one active
any mission
When you assign the first task, you know the task ID right?
yes *
So when they try to assign another task, just check the status of the previously added task
Why not?
Because its locally created who ever interacts with the board
private _myTask = [west, taskName, [_description, _title, _waypoint], objNull, true, 0, true, "destroy"] call BIS_fnc_taskCreate;
missionNamespace setVariable ["CurrentTask", "taskID", true];
no
You need 3 lines of code to find that out
//Create task id
//Create task with task ID
//Store task ID globally
//Get task ID
//Check if task with task ID is done
// If yes, create new task, else do nothing
`
// Create task ID globally
lastCreatedMission setVariable ["CurrentTask", taskName, true];
// Set random task location
[taskName, _player_circle] call BIS_fnc_taskSetDestination;
// Check if task last task is done
if(format['%1', taskName] call BIS_fnc_taskCompleted){
// Return task is done
};
`
Would this work?
oh no
wait how would i get the taskID globally?
`
// Create task ID globally
lastCreatedMission setVariable ["CurrentTask", taskName, true];
// Set random task location
[taskName, _player_circle] call BIS_fnc_taskSetDestination;
// Check if task last task is done
if(format['%1', getVariable "lastCreatedMission"] call BIS_fnc_taskCompleted){
// Task is done
};
`
If i named it CurrentTask i can get it back like this right?
if(format['%1', getVariable "CurrentTask"] call BIS_fnc_taskCompleted){ // Task is done };
@cosmic lichen
Please help xD
Read setVariable documentation first
you did read it, but you did not understand it.
Well you didnt say that
check the examples and the syntax
xD
missionNamespace setVariable ["CurrentTask", format['%1', taskName]];
hint CurrentTask;
Now its stored yea?
why format?
it can take var right away?
missionNamespace setVariable ["CurrentTask", taskName];
What data type is taskName?
taskName = format["task_%1", rndNmb];
yeah, and what data type is that?
str
me stupid?
I just want you to reflect. Don't write things you don't understand
xD
I see.
So this is step one then?
// Set task globally missionNamespace setVariable ["CurrentTask", taskName]; hint CurrentTask;
If it works
Reserved var
_myCurrentTask setVariable ["CurrentTask", taskName, true]; <-- error undefinded var, do i need to declare it first somewhere above?
what does setVariable expect on the left side?
wait i got it
missionNamespace setVariable ["currentTaskOn", taskName]; hint currentTaskOn;
This works
now
I dont know.
// Set task globally missionNamespace setVariable ["currentTaskOn", taskName];
Im assuming this is set now but can't seem to retrieve the value
getVariable
missionNamespace
hint missionNamespace getVariable "currentTaskOn"; ?
()
o
m
g
finally xD
Any reason why it needs () ?
So i can remember for next time
yes, operators precedence
it does (hint missionNamespace) getVariable "currentTaskOn"
🤔
hint (missionNamespace getVariable "currentTaskOn"); _completed = "CURRENTTASKIDHERE" call BIS_fnc_taskCompleted;
Final moment
How would i merge these two
hint (missionNames_completed = "CURRENTTASKIDHERE" call BIS_fnc_taskCompleted;pace getVariable "currentTaskOn"); Merged 😛
😢
private _currentTask = missionNamespace getVariable "currentTaskOn";
private _isTaskDone = _currentTask call BIS_fnc_tasKCompleted;```
private _isTaskDone = (missionNamespace getVariable "currentTaskOn") call BIS_fnc_tasKCompleted; Which is less ledigable
There is one more thing though, the alternative syntax of getVariable which involves a default value
private _currentTask = missionNamespace getVariable ["currentTaskOn",""];
if (_currentTask isEqualTo "") exitWith {hint "Task ID does not exist!"};
private _isTaskDone = _currentTask call BIS_fnc_tasKCompleted;
aah oke but one problem
oh no wait
`
private _currentTask = missionNamespace getVariable ["currentTaskOn",""];
if (_currentTask isEqualTo "") exitWith {
// Create mission
};
// Task exists (Check for complete)
private _isTaskDone = _currentTask call BIS_fnc_taskCompleted;
`
Im gonna take a short 15m break need some food and fresh air xD
brb.
@cosmic lichen
if (_currentTask isEqualTo "") exitWith { // Cant find any mission };
Is there also something isNotEqualTo ?
in the next patch
otherwise, if !(_currentTask isEqualTo "") exitWith {
or != ""
Ty bud
Im getting slowly to what i want xD
What is the in-game message again instead of hint?
chatmessage or something?
systemChat
Ah yea
if !(_currentTask isEqualTo "") then { private _isTaskDone = _currentTask call BIS_fnc_tasKCompleted; if(_isTaskDone == false) then{ systemChat "Please complete your current task before starting a new one."; // It needs to stop here completely }; };
How do i completely stop the code at a certain point?
three ` followed by one sqf then line return
i dont know why but im so confused sometimes im thinking of PHP a lot
mmm
Not sure what you mean by that 🤔
// Check for mission and if mission is completed if !(_currentTask isEqualTo "") then { private _isTaskDone = _currentTask call BIS_fnc_taskCompleted; if(_isTaskDone == false) then { systemChat "Please complete your current task before starting a new one."; // Exit here completely dont run next code }; };
Can you show?
```sqf
// Check for mission and if mission is completed
if !(_currentTask isEqualTo "") then {
```
=
// Check for mission and if mission is completed
if !(_currentTask isEqualTo "") then {
Doesnt seem to work
Hi
One question about objects
If we put a variable name on an object in Eden Editor
We surely can get it through missionNamespace getVariable["variable_name", objNull] ?
yes
I'm doing that and in server-side: the script doesnt success to get the object
Is that because of special states of the object (as simulation, simple object) ?
nope
where did you name it?
in variable name attribute, eden editor
and trying to access it in game, not in editor?
oh nevermind, was using wrong local variable when fetching object with getVariable
😦
🔨 agrrrrrr è.é
xD Lou im still not sure what you meant
no worries 😉
about?
`
// Check for mission and if mission is completed
if !(_currentTask isEqualTo "") then {
private _isTaskDone = _currentTask call BIS_fnc_taskCompleted;
if(_isTaskDone == false) then {
systemChat "Please complete your current task before starting a new one.";
// Exit here completely dont run next code
};
};
`
// Check for mission and if mission is completed
if !(_currentTask isEqualTo "") then {
private _isTaskDone = _currentTask call BIS_fnc_taskCompleted;
if (!_isTaskDone) then {
systemChat "Please complete your current task before starting a new one.";
// Exit here completely dont run next code
};
};
Uh what changed xD?
It's human readable now
ha ha 😢
Still need to know how to force exit it
The thing is the code above is checking for some task status and everything below that is a createMissionFunction so i dont want it to go further if the task is not completed
exitWith is commonly used; for loops, an assortment of break commands is coming; and there's also terminate.
would be true if i wasnt already in another if statement
i can't exitWith inside that
if (!_isTaskDone) then { hint "buhbye" } ELSE { hint "oooh, task completed" };
Alright problem is _currentTask can be empty then it should keep going, if _currentTask is not empty check if that task is complete if so then just keep going if not then stop right away and give message
