#arma3_scripting
1 messages · Page 520 of 1
Good luck bud, let us know how it turns out.
haha thanks
@sinful flame init.sqf is executed once on mission start, allows waiting and executed after all objects initialised. Object init field executed for every client present and future in multiplayer, doesn’t allow suspension and is executed quite early so some commands might not work when placed in it
@sudden yacht where do you put the code when the game freezes?
init box. Have any suggestions?
init box is unscheduled so this loop wouldnt be sleeping.
while {alive player} do {nul = [getPos player,240,"Banshee",2] execVM "MIL_CAS.sqf"; sleep 60;};```
How do i make it scheduled?
put it inside a spawn
though i dont know if ur player exists when init boxes are executed so that may end up being a new problem.
@hasty violet The benefit to the FUNC macro are that it allows you to very easily move stuff between modules or rename modules or split things apart, the FUNC macro automatically changes the function name that you are calling, no need to do it manually.
XEH_PREP is basically like CfgFunctions, but it has correct line numbers for errors (CfgFunctions does not if you have #include's) and has better caching.
And the specific files for pre/postInit and preStart are just very handy, because you immediately see the entry point. If it were CfgFunctions you'd first need to look into the config to see which file has which kind of init.
@knotty arrow use the private keyword, not the command.
@robust hollow
init box is unscheduled so this loop wouldnt be sleeping. And it also wouldn't be looping as the script get's killed on the sleep.
Your thingy seems really weird. Scripts shouldn't be able to crash the game no matter if unscheduled/scheduled.
Some UI Eventhandlers can crash the game because BI is missing some checks. But if you don't do any UI stuff you should be in the clear (unless you spawn a broken vehicle model or whatever else)
hey was wondering how could i see the server threads that are running
Profiling build would show them. But that is not out yet for 1.90
Currently not
what about checking Client threads?
same
does diag_activeScripts return value of scripts?
Who knows what it returns, it is a mystery...oh wait https://community.bistudio.com/wiki/diag_activeScripts
That function will return how many scripts are running depending on how you have ran them.
ye just read it
PROBLEM: Programmatically created trigged does not execute activation statements.
DESCRIPTION: I'm creating a side mission of destroying enemy's cache. If I destroy the crate nothing happens, where it should show the chat message. Could anyone assist?
CODE:
_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
_trigger_name = format ["trgCache_%1", _cache_number];
_cache_trigger = createTrigger [_trigger_name, _ammo_pos];
_cache_trigger setTriggerStatements [
"!alive _nva_crate",
"systemChat 'Cache destroyed'",
"systemChat 'Cache NOT destroyed'"
];
!alive _nva_crate Local variables don't carry over to other scripts
_nva_crate is undefined
VAR_changing is a global variable that changes many times by various scripts on the mission. On the code bellow there is a chance of the different diag_log str VAR_changing; (1, 2, 3 and 4) return differente values? waitUntil { diag_log str VAR_changing; //1 (some code with no sleep)... diag_log str VAR_changing; //2 (some more code with no sleep)... diag_log str VAR_changing; //3 (some more code with no sleep)... diag_log str VAR_changing; //4 false };
How to properly pass it, then? Should I use i.e. missionNamespace setVariable ["crate", _nva_crate]; and call missionNamespace getVariable "crate"; in the condition?
_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
missionNamespace setVariable ["crate", _nva_crate];
_trigger_name = format ["trgCache_%1", _cache_number];
_cache_trigger = createTrigger [_trigger_name, _ammo_pos];
_cache_trigger setTriggerStatements [
"!alive (missionNamespace getVariable 'crate')",
"systemChat 'Cache destroyed'",
"systemChat 'Cache NOT destroyed'"
];
@tough abyss yes script might be suspended at any point in scheduled
@formal vigil That's unnecessarily complex.
You set/get a global variable by just writing the name. So
crate = _nva_crate and !alive crate would do it.
If you use a global variable then there can only be one crate. Also global variables should always have a prefix like DAR_crate to not conflict with anything else.
You can instead setVariable onto the trigger.
And then getVariable from thisTrigger in the condition. That way you can have multiple crates.
So it would be as simple as:
_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
OS_crate = _nva_crate;
_trigger_name = format ["trgCache_%1", _cache_number];
_cache_trigger = createTrigger [_trigger_name, _ammo_pos];
_cache_trigger setTriggerStatements [
"!alive OS_crate",
"systemChat 'Cache destroyed'",
"systemChat 'Cache NOT destroyed'"
];
?
@still forum if the code runs in a EachFrame event handler (unischeduled) the answer is no?
i'm looking through a3wasteland code to learn about multiplayer scripting. can somebody explain to me reason for some functions defined in CfgFunctions and other using globalCompile.sqf in that file i see that functions are compiled final if debug mode is turned off. is the debug mode only reason for this kind of compiling scripts?
Probably yes. With CfgFunctions you cannot control whether compileFinal or not that easily.
Oh, I think I understand what you've meant by setting a trigger variable...
_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
_trigger_name = format ["trgCache_%1", _cache_number];
_cache_trigger = createTrigger [_trigger_name, _ammo_pos];
_cache_trigger setVariable ["OS_crate", _nva_crate];
_cache_trigger setTriggerStatements [
"!alive (thisTrigger getVariable ""OS_crate"")",
"systemChat 'Cache destroyed'",
"systemChat 'Cache NOT destroyed'"
];
Right?
yep
👌 I'll test it out right now
So then probably systemChat also should be escaped with double quotemarks instead of apostrophe?
Tested the code. Seems the condition still doesn't work, even if I use double quotes instead of apostrophes.
Perhaps it has something to do with trigger activation, pretty sure you need to set that to anybody(https://community.bistudio.com/wiki/setTriggerActivation), but why use triggers at all? 😄
Is there an external way of compiling and testing sqf?
@copper raven what other way would you recommend? Attaching to some kind of like ObjectIsDestroyed event?
sqfvm
yeah, like an event handler, either assigned to the crate itself, or like an EntityKilled on server
There is Deleted or Killed eventhandlers. Or HandleDamage
Worked like a charm! Thanks guys, I owe you 😃
@formal vigil there is only one name you could use to create trigger, where did you get an idea you could just make one up?
https://community.bistudio.com/wiki/createTrigger name is a classname, not just any name
@sinful flame Depends on what you want to test. SQF is pretty much an API to the game engine, without the actual engine you could only emulate script functionality to a certain degree.
@tough abyss Ahh okay I wasnt sure if it was it;s own language that Bohemia decided to use or if it was created for the game.
Yes it is, but 90% of sqf operators are getters and setters for engine methods
@formal vigil
My solution(script runs on the server), line 51+
https://pastebin.com/v6Rwq91v
this is the code that's I'm having right now:
_cache_number = floor random 100;
_ammo_pos = [getPos _module, 5, 10, 10, 0] call BIS_fnc_findSafePos;
_ammo_marker_name = format ["mrk_cache_%1", _cache_number];
_ammo_marker = createMarker [_ammo_marker_name, _ammo_pos];
_ammo_marker setMarkerType "b_uav";
_ammo_marker setMarkerText "Ammo Cache";
_nva_crate = "uns_AmmoBoxNVA" createVehicle getMarkerPos _ammo_marker;
_task_name = format ["DestroyCache_%1", str _cache_number];
OS_task_id = _task_name;
[west, _task_name, ["Enemy Ammo Cache is present in this area. Find it and destroy using explosives","Destroy Enemy Ammo Caches"], objNull, "ASSIGNED", 1, true] call BIS_fnc_taskCreate;
_nva_crate addEventHandler ["Killed",{
[OS_task_id, "SUCCEEDED"] call BIS_fnc_taskSetState;
}];
I will still need to change those BIS_fnc_task* calls to remoteExecCall for the tasks sync
Oh, nice.
@still forum i don't understood u
ok
And I don't remember about what I was last talking to you. That makes two people that don't understand what's going on
this
Ah
Use private _item = param... instead of
private "_item";
_item = param...
private keyword infront of variable is free. The other private is a command call that costs you performance
additionally you can more easily see where a variable is defined for the first time (because that's where the private is) making your code a bit more readable
yep, but my problem is when i exec this from a function, arma crash
thanks for the tip
Ah yeah. I thought about that but I can't see any reason in the script why Arma might be crashing.
you could add tons of diag_log's into your script. One in every line.
And then when your game crashes look into your RPT to see at which line of the script, the game crashes
i try to debug all code with diag_log
and not showing anything on rpt
i try it already
nothing at all? are you 100% sure it's that script that crashes then?
Try emptying the script file and running it. Maybe it's something before the script you posted
How do you call is as a function @knotty arrow ?
["classnameofmagazine"] call x_fnc_repack
exactly:["50Rnd_570x28_SMG_03"] call rb_fnc_repack
i empty the file and game not crash @still forum
makes no sense that the diag logs don't show up
nap
if i test it block for block, game not crash
and if i exec all the function crash
i will do another one
@still forum thanks for ur help ❤
I have a script that gives players certain items. Is there a way that this script detects the players weapon and gives the player X amount of a defined magazine ? For Example: 2 players (one with ak one with m4)... both access the script via "addaction" ..... both get the items the script contains plus 5 mags for their weapon... the mag count should be adjustable aswell as the mag type (classname)
anyone that knows how if can make this work ?
if (currentweapon player isequalto "m4") then {player addmagazine "m4magazine"} else {player addmagazine "akmagazine"}
@thin pond
Or you can just check https://community.bistudio.com/wiki/primaryWeaponMagazine
Have one OnEachFrame with all code instead of having the code broken in 5 OnEachFrame is better in terms of performance?
Yes
slightly
most important is to not have the actual code directly in the eachframe
but to instead call a function
Yes i do that
addMissionEH ["EachFrame", {call myFunction}]
instead of
addMissionEH ["EachFrame", {function code here}]
Thanks Dedmen!
I'm transforming some code i have in this format _var1 = 0; _var2 = []; _var3 = objNull; waitUntil { (CODE...) false }; to OnEachFrame. Sadly i will need to transform _var1, _var2 and _var 3 in global variables.
You can go for stacked oneachframe EH. It allows you to pass arguments @tough abyss
@copper raven not sure... _var1 for example is a incremental variable, inside (CODE...), in the waitUntil, i have that: if (...) then {_var1 = _var1 + 1;}; The variable needs to maintain itself each cycle.
Yeah, then you need to go for global var.
Would there be a way to script a MP missions to allow certain players (possibly with their steam ID) be allowed a specific slot in the lobby of the server? say i have 20 playable units, but three were only restricted for 3 individuals
https://community.bistudio.com/wiki/getPlayerUID
Under notes at the bottom
So that script would be placed on the specific unit in question?
No one will script it for you, learn sqf and ask questions if you stuck somewhere, the link is only a hint for the steam check
I was not asking for it to be scripted, just a starting point
But thank you for the help
Okay I think im getting the basic understanding of this now. so _var is for private varibles where as var is for global? Objects are just like 90% JSON objects? All lists/arrays are tuples? Is that a fair jugement?
Objects are just like 90% JSON objects no
All lists/arrays are tuples no. Arrays are arrays.
_var is for local variables.
There is a private keyword which makes the variable local to the current scope, instead of the variable potentially overwriting ones in parent scopes.
_var is local not private, becomes private when you make it private
ahhh okay I see. so you have to staticaly declare its private
so 'private _innerVar;'
private "_innerVar";
_var = 5;
if (true) then {
_var = 10;
}
//_var is 10 here
_var = 5;
if (true) then {
private _var = 10;
}
//_var is 5 here
ahh okay i see. This is unlike a language i have used before. You guys must have had to really power through learning it.
Have you ever come across any other languages like this?
Nope. Syntax wise there are many similarities ofc. But backend wise not really
You can compare private keyword with javascript's let
if and then i have used before in Bash scripting and Perl, i think. but that was years ago
I know Java and C++ so I'm familiar with access modifiers
Now i know what let does 😃
IMO SQF is easier to understand if you know the low level stuff.
Everything is a command. There are 3 types of commands. nular, unary, binary
Interesting...
You guys must have had to really power through learning it comes down to remembering the commands
if (true) then {true_code} else {false_code}
if, then and else are commands.
https://community.bistudio.com/wiki/if
https://community.bistudio.com/wiki/then
https://community.bistudio.com/wiki/else
else has highest priority and just returns an array like [{code1}, {code2}]
then takes a IfType on the left side, and either array or code on the right side.
So after the else is evaluated you have
if (true) then [{true_code},{false_code}]
Next up the if
IfType then [{true_code},{false_code}]
Last the then command is executed. It get's the IfType and the array of code values as argument.
The IfType internally stores the result of the condition (true command returned a boolean true. So the condition is true.)
then command then chooses the corresponding code value in the array, and executes what's inside it
Once you understood that. It's all about knowing the commands.
And here is a list of ALL commands.
https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3
Thanks 😃 I've been looking over the Wiki for a couple of days now and it seems like there is tones of calls you can do
Look at the Workshop, then you will see what ppl do with arma
Scope for variables is fairly common though in other languages
A lot of game functionality could be duplicated with scripts and a lot could not be
Im trying to focus on learning a little bit a day. yesterday I got the say3Dsound method working and i could make some sound come out the radio which was cool but today I think im gonna focus on making an intro and cut scenes
say3Dsound say3D or playSound3D?
There is also a C++ scripting mod btw.
But it's only really useful for playing around and making specialized tools as it doesn't work with battleye
It was say3dsound
say3dsound doesn't exist
no such method
playSound3D that was it. https://community.bistudio.com/wiki/playSound3D
if you know c++ you may want to jump to callExtension
callExtension doesn't help you learn scripting tho
helps you to learn about strings and arrays
Yeah I best just try learn some SQF so if i want to make something multiplayer I know battleye wont play up.
what this has to do with battleye?
callExtension and Intercept both don't play with battleye
callExtension?
you need to get the extension whitelisted
And why is it a problem?
Battleye doesn't care about your SQF skills, unless you tell it to care @sinful flame
Ah im sure about that since its only designed to interact with Bohemias API and AFAIK Battleye is made by Bohemia. i think.
Ohh okay.
Yeha I seen it being used in battlefield.
not sure which one.
3 i think
And if your extension is not whitelisted you cannot run on a server running BattlEye. Even if it is whitelisted there are problems occassionally where BE on your client barfs on the DLL
If you scroll this page https://www.battleye.com/ you could see who is using it
Happens for me with ACE3 every now and again...
Insurgency, thats what i was thinking of. I had a friend by Arma and he instantly got perma banned by battle eye for cheating. He kept trying to email support to say he only just purchased the game and didnt even get to play it before he got banned. That was years ago and he said he would never buy it agian.
BE might have deeper integration with Bohemia games for historic reasons
arent a2 banns carried over to a3?m quite few ppl complained in the steam forums purchased a3 and beeing banned on their first altis life visit xD
Isn't a BE ban applicable to all BE supported games... that is what I assumed. Asking because I may be wrong?
Doubt it
#arma_battleye
https://www.pcgamesn.com/arma-3/battleye-bans-now-extend-across-arma-3-dayz-and-arma-2-operation-arrowhead
The BattlEye anti-cheat engine now handles bans across Arma 3, DayZ and also new SteamID-based bans issued in Arma 2: Operation Arrowhead.” said Bohemia. “So, for example, a ban in Arma 3 will also apply to Arma 2: Operation Arrowhead and conversely.”
And for DayZ Standalone too... just checked that
Thats nice
Solution is: Don't get banned!
infiSTAR global bans cross ARMA2 and ARMA3 too thankfully
If a method has a return type do you always have to give it a varible to return to? even if you are not going to use that return value?
no, but sometimes you might want to
like if you put the code in init field in editor it will complain if you have something returned
but because assignment operation doesn't return anything you can just use assignment to dummy variable
Like in this example https://youtu.be/_MGfY5gn-kc?t=263 he uses _camera for all the returns but only uses _camera when he calls camdestroy _camera
ahhh I see. thx
no he assigns to it then uses it as argument for binary commands
arg1 command arg2 <- binary command
= <- assignment
camdestroy is unary
command arg1 <- unary
and binary is when a method take arguments but also returns an array/object/value?
and if a command takes no input and has no output then it is a nulary method?
nular* method
select returns anything, because it returns whatever you have in array which can be anything
if (currentweapon player isequalto "m4") then {player addmagazine "m4magazine"} else {player addmagazine "akmagazine"} any way to make this detect the handgun aswell ?
nular can have output
for example forceEnd is nular that returns nothing, but allPlayers is nular that returns array of objects
okay so its like a return type that can be void but it can also be a varible or an object?
its not fixed to HAVE to return something?
yeah something like that only instead of void it returns nil which can be tested with isNil
its not fixed to HAVE to return something? dont understand the question
I know what you need
type this in debug console:
also is there any way to make for "_i" from 1 to X do {this addItemToVest "X";}; any shorter like with player addMagazine ["X", 10] for example
{diag_log _x} forEach supportInfo "";
okay thanks. I will give it a go
Then go to your .rpt and get the long list of all commands it printed
each command will have TYPE of argument used, but for return type you will need to look up wiki
Ah awesome. Thanks man!
I want to improve the sound of the rain. would a 2D sound be better than a 3D sound call? How does 2d sound call relate when you go indoors/car? do you know if it filters the sound like a 3d sound?
you can just make a mod and change sounds
people have done this
there are things that are easy to do with scripts and there are things that are better done with mods
I have seen JSRS and Dynasound mods
@thin pond no, additemtovest could also add a weapon or magazine as well as items, but addmagazine adds magazines only
But I only want to change the rain, and wind sounds. Sound engineering is one of myhobbys and im sure I could make it sound better.
so make a mod and replace the sounds with yours
How can i check if a vehicle was killed vs just got despawned or deleted?
!isNull _vehicle && !alive _vehicle <- dead
thanks!
player removePrimaryWeaponItem "acc_flashlight"; should also be able to remove magazines but can you also remove any magazine in the weapon ?
I want to remove any magazine that is currently equiped in the weapon, also i cant seem to get items removed that are inside a vest/uniform/backpack
Good point, I will stick with mission making for now. Don't want to over fry my brain
https://community.bistudio.com/wiki/Control_Structures#for-from-to-Loop is step 2 on this wrong? AFAICT it should read "greater than" rather than neq
that is how you use step.... what do you mean it should read "greater than" rather than neq?
The loop processes as follows:
A variable with the name VARNAME is initialized with STARTVALUE
If VARNAME is not equal to ENDVALUE, the code block is executed
If ENDVALUE is greater than STARTVALUE, the variable VARNAME is incremented by 1
If ENDVALUE is less than STARTVALUE, the variable VARNAME is decremented by 1
Go back to step 2
To me, that suggests that once the VARNAME is equal to the ENDVALUE, the code does not execute
what happens in game is that it executes until (excluding) the increment pushes VARNAME over ENDVALUE
it depends which way your interval goes. if you use a negative step it needs to be less than the end value.
regardless, that does read wrong.
fixed 😃
any chance to get this to work with vests and uniforms ?clearMagazineCargo (unitBackpack player)
Where is the output for the debugger?
Ahh conflicts. I was just going to reword to say #The code block will be executed until <tt>VARNAME</tt> increments beyond <tt>ENDVALUE</tt>, but your works
@thin pond
clearMagazineCargo (vestContainer player)
clearMagazineCargo (uniformContainer player)
If ENDVALUE is less than STARTVALUE, the variable VARNAME is decremented by 1
this isnt right either is it?
_a = [];
for "_i" from 5 to 1 do {_a pushback _i};
_a // []
its only if you specify a negative step
@sinful flame what debugger?
correct. I'll update
the Eden debugger. I ran the code you gave me and i get no visible text output
then there was no return value?
But I have just founf about about arma.rpt so I think i know where the results are going.
.rpt file
I made a template script for the other mission makers of our unit. Is anybody willing to take a lock at it and tell me if its compatible with dedicated servers ?
they are going to be replaced by classnames of items
;D
i tested all of it in the edior/singeplayer and everything worked there
should be fine, you could reduce it to a single setUnitLoadout command but either way gets the job done.
you're using this in your for loops though. instead of player
already fixed that... little copy and pasting mistake
the players decide which weapons/vests/uniform etc they want to wear after that they execute these template scripts to get their "role loadouts"........ i just need a gui that can excecute .sqf files (like with addaction and the actionmenu)
so no player has to make sure he has everything he needs.... reduces mission prep from 30-40 minutes down to 10 (without briefing and joining)
i just need a gui that can excecute .sqf files (like with addaction and the actionmenu) is there anything out there that does this ? otherwise i'm going to make my own (atleast try :D)
not sure how to answer that, any gui can execute files if you tell it to
hm than i have try to make my own.... just a list where you select which sqf is excecuted and than closes should be easy
if you'll excuses the plug, is this kind of what you're after?
https://forums.bohemia.net/forums/topic/222184-user-input-menus/
there is a listbox function where you provide the options and then itl execute the code you give it with the player's selection as the argument.
I'll take a look at it but it looks promissing
okay thats a bit complicated for me... I can do some sqf stuff but that looks a bit much for me... dont have the time to dig into it right now
how much work would it be to make a gui with a list to select from, where the selected option excecutes a sqf ?
Can I store code in a variable? Like var01 = {hint "test"}; call var01;
@radiant needle yes, variable can be of type code
in fact if you do allVariables missionNamespace, you will find lots of code-type variables there, which are in fact functions from function library and other places
You can store code in a local variable too
Thanks, thats what i figured but wanted to double check
How do i get out of that weird camera mode in the eden editor? I can see the X, Y and Z axis and I can't move. Is this a big? Its happend to me a few times now.
I'm currently using "cutText" to display a text when a player excecutes my script, but i cant seem to let it only show for the player you executes it
what do you mean? cutText is a local effect.
okay i didnt know it was local, consider my question stupid and answered then 😄
I forgot the name of a function: it rescales a value from one range to another range. Could someone please remind me?
Rescales?
yeah value is in range a -> b, and it can return that value relative to range x -> y
so if v=0.5, a=0, b=1, and x=2,y=4, it will return 3
useful for animating something based on time, which is what i am trying to do now
you can apply an array of values under a certain value
?
I know this function exists I have used it, can't remember the name or which mission though :/
linearConversion
WOO
that is it
thank you
pr _actualX = linearConversion [animStartTime, animCompleteTime, time, _prevx, _currx, true];
@high marsh it does that
anybody know a way to remove the magazine in any weapon equiped via sqf script ?
player removePrimaryWeaponItem (primaryWeaponMagazine player # 0);
player removeSecondaryWeaponItem (secondaryWeaponMagazine player # 0);
player removeHandgunItem (handgunMagazine player # 0);
not sure how reliable that is at removing the mag in the gun before any in inventory, but it worked in a quick test.
weaponState can return all this
yea that would probably work better.
@robust hollow how should i use this to achive what I'm trying to do ?
use what? weaponState?
the first thing you wrote worked but i dont know how i should use "weaponstate" to remove a magazine in a weapon
weaponState player # 3 but it only shows the currentWeapon. not sure how to get it showing the holstered weapon info.
Seems like that linear conversion would be useful for converting colors
one last thing than my template is done: I cant remove the "launcher" i.e. secondary weapon, tried multiple things but none seem to work
@radiant needle it is, made a colour picker grid using it
You tried player removeWeapon (secondaryWeapon player)?
yep... says ) missing, which is weard
Can you post the actual code you have?
wow.... found the error..... the side where i copied the line "player removeWeapon (secondaryWeapon player)" had a } instead of )... couldnt see it because fkn 4k 😄
should turn up my "font size"
thanks for the help guys script is working perfectly with all intended functions and customizations !
Hey guys
So I want the AI in the player's squad to be in BLUE (forced hold fire) state at the beginning of the mission but I don't want to hear my guy say "Hold Fire" at the opening. Is there a way to make that silent? I've tried it from the init.sqf and my guy still says "Hold Fire"
could do _unit setSpeaker "NoVoice" on the unit temporarily.
Oooh that's interesting, how would I turn the voice back on?
What's the opposite of "NoVoice" I mean
https://community.bistudio.com/wiki/setSpeaker
one of those options. the unit probably has an option specific for them in their config
How do I put quotes into a format[]
Like if I want to display "Hi", I can't imagine format[""HI""]; would work
Do I need doubles like format["""Hi"""];
if its just a plain string "hi" you can do str "hi", otherwise yes double quotes inside a quote
The quotes aren't part of the var iteself though
Like say _var = 6; format["""%1""",_var]; would display "6"
?
yes it would.
Btw thanks Connor that worked like a charm
hey guys are they a script for apply durty in arma 3 ?
"apply durty"?
use a new texture when you roll
setObjectTexture on keydown event 🤷
"roll" ??
i assume the Q and E roll
What about animation change event?
drive
the vehicle gets dirtier automagically doesnt it?
yes
is it possible to not be the commander of a vehicle with a gun?
I can't seem to just be a passenger
vehicle only moves if I command it with wasd keys
Why am I getting "Type number not array" for_Array = _Array pushBack ... in this code
[] spawn {
_Crates = nearestObjects [SearchObj, ["plp_ct_LockerBig"], 100];
_Array = [];
{
_WeaponCargo = getWeaponCargo (_this select 0);
_MagazineCargo = getMagazineCargo (_this select 0);
_ItemCargo = getItemCargo (_this select 0);
_Weapons = "";
_Magazines = "";
_Items = "";
{
_CurrentIndexWeapon = format["_x addWeaponCargoGlobal [""%1"", %2];",_x,(_WeaponCargo select 1 select _forEachIndex)];
_Weapons = [_Weapons,_CurrentIndexWeapon] joinString " ";
} forEach (_WeaponCargo select 0);
{
_CurrentIndexMagazine = format["_x addMagazineCargoGlobal [""%1"", %2];",_x,(_MagazineCargo select 1 select _forEachIndex)];
_Magazines = [_Magazines,_CurrentIndexMagazine] joinString " ";
} forEach (_MagazineCargo select 0);
{
_CurrentIndexItem = format["_x addItemCargoGlobal [""%1"", %2];",_x,(_ItemCargo select 1 select _forEachIndex)];
_Items = [_Items,_CurrentIndexItem] joinString " ";
} forEach (_ItemCargo select 0);
_Array = _Array pushBack format["%1 %2 %3",_Weapons,_Magazines,_Items];
} forEach _Crates;
copyToClipboard _Array;
};
send error log
Where can that be found?
rpt file
dont worry actually
pushback returns the index the element was inserted to. remove _Array =
oh yeah, for some reason I was thinking of it like joinString
@sinful flame
If a method has a return type do you always have to give it a varible to return to? No. But there is a bug where in script fields in the Editor you cannot have a value left on the stack at the end. So you have to do something like 0 = ... or _dummy = ... or whatever just to make it go away.
and binary is when a method take arguments but also returns an array/object/value? no, binary is when a command takes two arguments. One on the left and one on the right. Whether it returns something or not depends on the command.
and if a command takes no input and has no output then it is a nulary method? no. If it takes no arguments it's a nular command. Says absolutely nothing about return values, refer to the wiki page of that command for return values.
@sinful flame the Eden debugger. I ran the code you gave me and i get no visible text output The debug console you mean?
There is the big text box on the top for script to put into. Then there is a small textbox below that where the output of the code goes.
If there is no output aka "nil" is returned then that box stays empty.
@radiant needle Why am I getting "Type number not array" for_Array = _Array pushBack ... in this code
Because you didn't read the wiki page for pushBack.
I don't think reading a wiki page influences code execution
Connor found the issue
It influences whether you write correct code or whether you have wrong assumptions and your code fails because of that
You would've found the issue yourself if you had read the wiki page and had seen that it modifies the array, and that it returns a number.
Cool this actually works
https://pastebin.com/raw/HG561KVF
Woah _AddItems = compile (_Array select _forEachIndex); Don't do that. Why are you doing that? Don't do that
Performance of compile is terrible. And there was a memory leak in there just recently
Just make 3 arrays of weapons, magazines and items. And then iterate through them
I mean it runs once, is performance really an issue?
well for each crate, but only once per mission
As I said there was recently a memory leak in that. The string stays in memory forever.
And it's just not good practice.
Is there another way to turn the string, into not a string?
No
Just don't use a string
as I said. Just collect arrays of the things you wanna add
You are just using format and compile to work around the fact that you don't know how to properly script
Is there a reason for the hostility?
Which hostility?
Telling people they don't know how to script.
Why is that hostile?
Because it's rude and uncalled for. My script works fine as is. If you have suggestions make them, if not shut up. Telling someone they don't know how to script is completely unconstructive and useless information
I'll consider and appreciate valuable or constructive input, but that's not it.
https://gist.github.com/dedmen/ab17fe25dec0b9f005ebc9f3b2d8503c here is a cleaned up version of your script
without hacky format/compile workarounds
You should also get used to using private. You already did at your _dialog but nowhere else.
It makes sure that you are not accidentally overwriting other peoples variables And it makes the code more readable because you can see where a varible is first defined
Also see how I used apply, instead of a forEach with tons of pushBacks.
It does the same thing, but it's shorter and faster.
Basically I wanted to turn it into code the user could copy the code, save it in their files, and execute it later. SearchObj is fixed, and locations of the containers are fixed, figured a sorted search would maintain consistency among the containers
Basically I wanted to turn it into code the user could copy the code, save it in their files, and execute it later. I did the same. Without any call compile
So what does private actually do? I thought it being underscore local already made it private?
Nope. Just _var looks if the var already exists in any parent scope
_var = 10;
call {
_var = 5;
};
//_var is now 5.
_var = 10;
call {
private _var = 5;
};
//_var is still 10.
imagine the call being someone else calling some function that you wrote.
The user will then be completely confused as to why their variables magically change around without them actually changing it
But what if I want the innerscope to set the var for the outerscope, do I not make it private or is there another way
You just leave away the private when you assign the variable
Btw your script is collecting the cargo of many crates.
And then combines all that cargo and puts it in all crates.
So if you start out with 2 crates that has each one bandage.
If you run that script on 2 crates later. You will have 2 crates with each 2 bandages. Instead of one bandage each.
But there is no real way to fix that besides making sure that you only have one crate in the input
Nothing a little clear cargo can't fix
Also whats the difference between local and global arguments?
Local argument means the command only works when the object is local to you.
Generally only objects that you spawned yourself (not spawned by the mission) and vehicles that you are the driver of are local to your computer.
The rest runs on either other players computers, or on the server.
Btw that script for the crates. Do you intent to put that into a init script in the editor? or init.sqf? or where do you intent to put that?
Achilles execute code module
So live then? not set somewhere in the editor?
Because init boxes in editor, or init scripts run for each player.
Meaning if you have your script in there, and you have 10 players, the crates would be filled 10 times.
It allows me to execute as local
It's pretty much just like the debug console
Looks like with the string one, it's a zero divisor error
on this line
_weaponsArray append ((_WeaponCargo select 0) apply {[_x,(_WeaponCargo select 1 select _forEachIndex)]});
I guess _WeaponCargo might be empty
Dialog output looks like this
[[["rhs_weap_pb_6p9",1],["FirstAidKit",1],["rhs_weap_fim92",1],["rhs_weap_fim92",<null>]], [["rhs_mag_an_m14_th3",3],["ACE_M14",<null>]], [["rhs_6b26_ess_green",3],["TFAR_anprc148jem",3],["rhs_acc_1p78",4],["rhs_acc_1pn93_2",4],["ACE_RangeTable_82mm",4],["rhs_6b23",<null>],["rhs_6b23_medic",<null>]]] spawn {
params ['_weaponsArray', '_magazineArray', '_itemArray'];
private _Crates = nearestObjects [SearchObj, ['plp_ct_LockerBig'], 100];
{
private _crate = _x;
{_crate addWeaponCargoGlobal _x} forEach _weaponsArray;
{_crate addMagazineCargoGlobal _x} forEach _magazineArray;
{_crate addItemCargoGlobal _x} forEach _itemArray;
} forEach _Crates
};
That happens when the two arrays of getWeaponCargo are not the same size. But why would that happen 🤔
Looks like quantity is shifted somehow
Does there happen to be an _applyIndex?
no
Wiki being really slow for anyone else?
not really
So the only way i know to retrieve index from an array, is with the find command. But I imagine it's quite performance intensive
Or would it be better just to swap the apply for forEach?
forEach would definitely be the easy way. Trying to think of a better way
I wanted to do it in a better and shorter way anyway. One minute
[] spawn {
private _Crates = nearestObjects [SearchObj, ["plp_ct_LockerBig"], 100];
private _weaponsArray = [];
private _magazineArray = [];
private _itemArray = [];
{
(_weaponsArray) pushBack getWeaponCargo _x;
(_magazineArray) pushBack getMagazineCargo _x;
(_itemArray) pushBack getItemCargo _x;
} forEach _Crates;
private _Output = format ["
[%1, %2, %3] spawn {
params ['_weaponsArray', '_magazineArray', '_itemArray'];
private _Crates = nearestObjects [SearchObj, ['plp_ct_LockerBig'], 100];
{
private _crate = _x;
(_weaponsArray select _forEachIndex) params ['_weaponClasses', '_weaponCounts'];
{_crate addWeaponCargoGlobal [_x, _weaponCounts select _forEachIndex]} forEach _weaponClasses;
(_magazineArray select _forEachIndex) params ['_magazineClasses', '_magazineCounts'];
{_crate addMagazineCargoGlobal [_x, _magazineCounts select _forEachIndex]} forEach _magazineClasses;
(_itemArray select _forEachIndex) params ['_itemClasses', '_itemCounts'];
{_crate addItemCargoGlobal [_x, _itemCounts select _forEachIndex]} forEach itemClasses;
} forEach _Crates
};
", _weaponsArray, _magazineArray, _itemArray];
uiNamespace setVariable ['Ares_CopyPaste_Dialog_Text', _Output];
private _dialog = createDialog "Ares_CopyPaste_Dialog";
};
Only slightly shorter I think
zerodivisor @ (_weaponsArray select 1) append (_WeaponCargo select 1);
Ah ffs. I should test my code.
private _weaponsArray = [];
private _magazineArray = [];
private _itemArray = [];
->
private _weaponsArray = [[],[]];
private _magazineArray = [[],[]];
private _itemArray = [[],[]];
Can't select the second element out of an empty array ofc
_itemArray params ['itemClasses', '_itemCounts']; local variable in global space
is there a reliable way to get an AI driver to move somewhere when you are in as gunner/commander (effectiveCommander)
_ missing on itemClasses.
Error is actually "global variable in local space" arma is not very accurate
I need to step up my code review game
@velvet merlin it doesn't seem like it can be changed
any vehicle with a weapon mount of some kind automatically sets the player as effectiveCommander for some reason
only problem is, now it adds the items from all containers combined, into each container
i have limited success with move the AI and back in just before the command, yet its not fully reliable
I ran into this issue earlier when testing ai visibility with vehicles and nothing I have tried has worked
not a priority for my purposes, but for actual mission makers it is a serious oversight
I don't remember it always being this way
only problem is, now it adds the items from all containers combined, into each container
Yeah that's what I said before.
Oh FFS I need to learn to read better
Even shorter now
[] spawn {
private _Output = format ["
%1 spawn {
private _Crates = nearestObjects [SearchObj, ['plp_ct_LockerBig'], 100];
{
private _crate = _x;
(_this select _forEachIndex) params ['_weaponsArray', '_magazineArray', '_itemArray'];
_weaponsArray params ['_weaponClasses', '_weaponCounts'];
{_crate addWeaponCargoGlobal [_x, _weaponCounts select _forEachIndex]} forEach _weaponClasses;
_magazineArray params ['_magazineClasses', '_magazineCounts'];
{_crate addMagazineCargoGlobal [_x, _magazineCounts select _forEachIndex]} forEach _magazineClasses;
_itemArray select params ['_itemClasses', '_itemCounts'];
{_crate addItemCargoGlobal [_x, _itemCounts select _forEachIndex]} forEach itemClasses;
} forEach _Crates
};"
,
(nearestObjects [SearchObj, ["plp_ct_LockerBig"], 100]) apply {[getWeaponCargo _x, getMagazineCargo _x, getItemCargo _x]}
];
uiNamespace setVariable ['Ares_CopyPaste_Dialog_Text', _Output];
private _dialog = createDialog "Ares_CopyPaste_Dialog";
};
So here is the output
[[[[[],[]],[[],[]],[["gorkaemrs"],[2]]],[[["rhs_weap_6p53"],[2]],[[],[]],[[],[]]],[[["FirstAidKit"],[2]],[[],[]],[[],[]]]]] spawn {
params ['_Array'];
private _Crates = nearestObjects [SearchObj, ['plp_ct_LockerBig'], 100];
{
private _crate = _x;
clearWeaponCargoGlobal _x;
clearMagazineCargoGlobal _x;
clearItemCargoGlobal _x;
(_Array select _forEachIndex) params ['_weaponsArray', '_magazineArray', '_itemArray'];
_weaponsArray params ['_weaponClasses', '_weaponCounts'];
{_crate addWeaponCargoGlobal [_x, _weaponCounts select _forEachIndex]} forEach _weaponClasses;
_magazineArray params ['_magazineClasses', '_magazineCounts'];
{_crate addMagazineCargoGlobal [_x, _magazineCounts select _forEachIndex]} forEach _magazineClasses;
_itemArray select params ['_itemClasses', '_itemCounts'];
{_crate addItemCargoGlobal [_x, _itemCounts select _forEachIndex]} forEach _itemClasses;
} forEach _Crates
};
_itemCounts undefined variable error on this line
{_crate addItemCargoGlobal [_x, _itemCounts select _forEachIndex]} forEach _itemClasses;
fixed
What was it?
for some reason you had select params
But now it works great
And way more compact now. Also the string to copy-paste should be alot smaller
I'm sure there are still a couple characters that can be chopped off 😄
Actually I see 22 characters that I can remove. Probably not worth posting the script again now....... But I can edit my above one!
yeah somethings up with the wiki for me, can't even access now
Just removed the [] from the spawn. As we are already passing an array to it. Don't need array in array ^^
Works fine here
Does BI forum work? https://forums.bohemia.net/
yeah working now, just insanely slow, like 10 seconds for a load
whoops I forgot about backpacks
easy enough fix though
@velvet merlin https://feedback.bistudio.com/T78152 is this the same issue?
yep
I'm starting to worry that it's intended behaviour
So final code with some QoL
https://pastebin.com/raw/srUndaRX
Just have to remember that the save crates all have to be same classname, and remember to click on the same crate when saving and loading
I need command to get class of the vehicle (Truck , MotorCycle, Tank e.t.c.)
is there any command for this?
not exactly what I'm looking for.
I'm loking for how to get this https://community.bistudio.com/wiki/Models_%26_Classnames:_CfgVehicles_-_Vehicles#class_Land_:_AllVehicles
clases
@radiant egret
You can't
You can use isKindOf to check through each of them. And then take the first one you found
but you can't just "get" the "type" of the object. Because what you are thinking of is not actually the class/type of the object. It's one of it's many parents
yeah, isKindOf should work for me, thx
is there any way to customize (paint/parts) vehicles that are already spawned or is there a vehicle spawner that allows a player to customize a vehicle before spawing ?
I have a related question, but I want to be able to change appearance of ANY object in game. Any ideas? setObjectTexture/setObjectMaterial won't work on lots of objects (H-barriers for instance). I want to make the semi-transparent preferable, or at least be able to change their color. My next approach to look at is using particles. Can this be done? i.e. pull the p3d from the object config and make a fake particle using it and apply alpha/whatever?
Would it not be setObjectTextureGlobal
For MP anyway
And setObjectTexture whether global or local only works on objects with hiddenSelections iirc
@ebon ridge those would be way to complicated as we have 20-30 different vehicles that are spawnable through a menu.... setting this up for every single part wouldn be practical
Yeah you remember correctly @restive leaf, that is the problem I am trying to find a solution to now
Okay you didn't give any constraints just asked if there was a way, that is a way. Maybe someone made a mod that gives you a UI for doing it? In fact I think I maybe remember something like that.
Not that tough to script on start since you can extract the hiddenselections easily. I retexture the UGV in a roaming AI script with these two lines but it wouldn't be difficult to automate it for many vehicles: _vehicle setObjectTextureGlobal [0, "x\addons\EpochZMod\data\UGV.paa"]; _vehicle setObjectTextureGlobal [2, "x\addons\EpochZMod\data\UGV.paa"];I'm sending you a PM btw with a couple of references
PMing you too @ebon ridge
Guys. Prompt. I have a script that creates furniture in the house.
dom setVariable ["Furniture",[
["Land_Sofa_01_F", [-3.63843,-0.175781,0.852625 + 0.2],181.334,true],
["Land_TableDesk_F", [-1.47363,-0.185059,0.852638 + 0.2],0.00568346,false]
],true];
life_downloadFurniture = {
{
if !(_x select 3) then {
_getPos = dom modelToWorld (_x select 1);
_oilModel = (_x select 0) createVehicleLocal [0,0,0];
_oilModel setDir (_x select 2);
_oilModel setPosATL _getPos;
};
}forEach (dom getVariable "Furniture");
};
When I request a location again
dom worldToModel getPosATL _obj;
The result on the x-axis is slightly different from the original data. What am I doing wrong?
Data to Spawn:
[-1.47363,-0.185059,0.852638 + 0.2]
After
[-1.47339,-0.185059,0.872818]
might be adjusting to a slope
getPosWorld
yeah sounds more like it
setVectorDirAndUp
Thanks, guys.
So if nobody has ideas for my one I will ask more specific question: can I get a p3d model from any object config and apply it to a particle and have it render that model in particle form?
@still forum What should I do with setVectorDirAndUp
you can set the direction and up vector with that
can I get a p3d model from any object config and apply it to a particle and have it render that model in particle form?
AFAIK yes
Awesome, and I would guess all particles can be alphed?
But not sure if it let's you apply alpha if the object itself doesn't support it. Need to test
How can I check if player is near a rear of vehicle? I want to make the Open Ramp user action available to be used by someone outside of the vehicle.
ok so the UserAction for opening the ramp has this as a condition
this doorPhase 'Door_1_source' < 0.5 AND Alive(this) && {(player in [driver this, this turretUnit [0], this turretUnit [1], this turretUnit [2]])} && {((this getVariable ['bis_disabled_Ramp',0]) != 1)}
The issue is that it lets only the gunner, pilot or FFV guys to open the ramp. I would like it so they can open the ramp as well as allow somebody near it to open. If I remove the turret check, then you can open the turret when standing near the rear, but it removes the action from the crew.
The user action has the radius and everything set up, so I would prefer use those setting instead of construction a completely custom check for radius
So im trying to use achilles dynamic dialog boxes (https://github.com/ArmaAchilles/Achilles/wiki/Custom-Modules), however im getting a generic error. The code im using:
[
"Test Dialog",
[
// The last number is optional! If you want the first selection you can remove the number.
["Combo Box Control", ["Choice 1","Choice 2"], 1]
]
] call Ares_fnc_showChooseDialog;
// If the dialog was closed.
if (_dialogResult isEqualTo []) exitWith{};
// Get the selected data
_dialogResult params ["_comboBoxResult"];
// Output the data to the chat.
systemChat format ["Combo Box Result: %1", _comboBoxResult];
rpt log: ```16:51:46 Error position: <isNil "Ares_var_showChooseDialog" };
if>
16:51:46 Error Generic error in expression
16:51:46 File \achilles\ui_f\functions\dynamic\fn_ShowChooseDialog.sqf [Ares_fnc_ShowChooseDialog], line 292
Ok, I think I found the simplest solution: I will just have a separate action for opening the ramp from outside
What's the best way to get the base mod name that a piece of a equipment comes from?
I am working on the UO Framework and I'm creating a conditional that hides gear presets if a user does not have the mod that a piece of gear comes from.
https://community.bistudio.com/wiki/configSourceAddonList
this returns the addon(s) the item class is defined in
I've been trying to use SQF Linter with Atom recently
But I keep getting this error
linter-registry.js:145 [Linter] Error running SQFlint Error: Traceback (most recent call last):
File "c:\users\alex\appdata\local\programs\python\python37\lib\runpy.py", line 193, in _run_module_as_main
"__main__", mod_spec)
File "c:\users\alex\appdata\local\programs\python\python37\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "C:\Users\Alex\AppData\Local\Programs\Python\Python37\Scripts\sqflint.exe\__main__.py", line 5, in <module>
ModuleNotFoundError: No module named 'sqflint'
at ChildProcess.<anonymous> (C:\Users\Alex\.atom\packages\linter-sqf\node_modules\sb-exec\lib\index.js:56)
at emitTwo (events.js:126)
at ChildProcess.emit (events.js:214)
at maybeClose (internal/child_process.js:925)
at Process.ChildProcess._handle.onexit (internal/child_process.js:209)
did you consider doing a quick search?
https://github.com/LordGolias/sqf/issues/22
I did not manage to make setWaypointScript and setWaypointStatements to work, none of the exemples works, is there any other way to check if a group finished a waypoint that does not require a loop to run?
@robust hollow I've already attempted that fix. Tis the reason I asked here.
right, I assume this needs to go in here. I want to have a drone act on its own, just following a unit around like it's a normal private, only without actually having a guy controlling it. Just have it have its own AI. Is that possible? Are there examples of this?
@earnest roost
https://forums.bohemia.net/forums/topic/210444-drone-de-mining-script/
Should get you on track. I don't recall actual autonomous behaviour, but am no expert on the matter.
@devout stag
As suggested by Connor, https://github.com/LordGolias/sqf/issues/22#issuecomment-326786174
The problem is most likely environment variables not being set. If you did not succeed, you probably did something wrong.
Make sure you:
- Installed all dependecies.
- Configured its' settings the way they should be. (Both the Executable path and the Python path)
- Apply forementioned fix.
If all those are done and you are still failing, try again.
Suggestion: What about splitting scripting into scripting-help & script-review.
I don't want to disturb posts of people who are looking for help while I just want a quick review of my script-logic
#discord_server <--
People just need to learn to talk over eachother 😄
You mean apply the pitch and yaw of one object to another?
More like say I have a car on a road facing north, and a helicopter hovering 50m in the air, 100m to the east, I want the car to point at the helicopter so that if I did car setVelocityModelSpace [0,1000,0]; it'd hit it
_dirToHelo = car_1 getDir helo_1;
car_1 setDir _dirToHelo;
he wants his car to point in the direction of the heli, and up at it.
i know what u mean, just cant think of how to do it 😕
Is it possible to just use gonio functions? Does this support math?
Also is there a reason why this is so far off depending where I spawn it on map?
[(_this select 0),615] spawn {
params ["_Location","_Adj"];
_LocAdj = _Location getPos [6000, 0];
_projectile = createVehicle ["Sh_120mm_HE",[0,0,0],[],0,"NONE"];
_LocAdj set [2,4000];
_projectile setPosASL (_LocAdj);
_light = "#lightpoint" createVehicle getPos _Projectile;
_light attachTo [_projectile, [0, 0, 0]];
[_light] remoteExec ["fn_meteorLight", 0, true];
_vector = vectorNormalized ((getPosATL _projectile) vectorFromTo (_Location vectorAdd [0,0,((getTerrainHeightASL _Location) + _Adj)]));
_projectile setVelocity (_vector vectorMultiply 1800);
waitUntil {!alive _Projectile};
deleteVehicle _light;
};
_Location vectorAdd A location is not a vector
yeah but it doesn't know that what?
You can't vectorAdd a location. That doesn't make sense
vectorAdd will accept any 3 element array
yeah it adds the 0
It'll print [1234,5678,0]
Why are you using ATL position on the left of vectorFromTo.
But whatever _Location is and ASL on the right?
Don't mix position types
ATL might be 100 while ASL might be 5000
Basically LocAdj is Location shifted 6000m away, and 4000m above. I basically just need to make sure that the projectile always spawns 4000m above the terrain height of location, regardless of ATL of LocAdj
And that _Adj is always 615m above Location
So basically 2D distance from _LocAdj should always be 6000. 3D distance from _LocAdj to _Location should always be the same.
so you want to have the projectile come in sideways, not straight from top down?
Basically LocAdj is Location shifted 6000m away, and 4000m above.
Not 4000m above. You set the height to 4000m. If location is at 5000m it might even be below location.
Basically I only care about the height of the aimpoint and spawn point relative to the target point
If terrain under spawn point is 3995m, it doesn't matter that the shell is only spawning 5m over the terrain
[(_this select 0),615] spawn {
params ["_Location","_Adj"];
_projectileSpawnPoint = _Location vectorAdd [6000, 0, 4000]; //6000m northwards, 4000m above location
_projectile = createVehicle ["Sh_120mm_HE",[0,0,1000],[],0,"NONE"];
_projectile setPosASL _projectileSpawnPoint;
_light = "#lightpoint" createVehicle getPos _Projectile;
_light attachTo [_projectile, [0, 0, 0]];
[_light] remoteExec ["fn_meteorLight", 0, true];
//Let it fly towards _Adj above location
_vector = vectorNormalized ((getPosASL _projectile) vectorFromTo (_Location vectorAdd [0,0,_Adj]));
_projectile setVelocity (_vector vectorMultiply 1800); //1800 m/s
waitUntil {!alive _Projectile};
deleteVehicle _light;
};
How about this maybe? I also changed the spawn point of createVehicle to be in the air, because if you are unlucky it might crash into the ground immediately before you setPos.
mhm looks like the distance between spawn point and aimpoint is still different
Surely the maps in Arma don't have projection?
They're a flat plane right?
wtf
So this is what I'm running:
[(_this select 0),430] spawn {
params ["_Location","_Adj"];
_projectileSpawnPoint = _Location getPos [6000, 180];
_projectileSpawnPoint set [2,4000 + (getTerrainHeightASL _Location)];
_projectile = createVehicle ["Sh_120mm_HE",[0,0,1000],[],0,"NONE"];
_projectile setPosASL _projectileSpawnPoint;
_light = "#lightpoint" createVehicle getPos _Projectile;
_light attachTo [_projectile, [0, 0, 0]];
[_light] remoteExec ["fn_meteorLight", 0, true];
_vector = vectorNormalized ((getPosASL _projectile) vectorFromTo (_Location vectorAdd [0,0,_Adj]));
_projectile setVelocity (_vector vectorMultiply 1800);
systemChat format["%1",_projectileSpawnPoint distance (_Location vectorAdd [0,0,_Adj])];
waitUntil {!alive _Projectile};
deleteVehicle _light;
};
I'm clicking at the Thronos castle on Altis
When I change between _projectileSpawnPoint = _Location getPos [6000, 180]; and _projectileSpawnPoint = _Location getPos [6000, 0]; my projectile spawn altitude, and aimpoint altitude are the same (between the two different directions)
But yet the distance is different
by about 90 meters
Surely the maps in Arma don't have projection what do you mean?
They're a flat plane right No.. Mountains and underwater terrain are not flat
altitude above terrain might be the same.
But altitude above waterlevel might not be.
The following logic is checking through an array of CBA hashes. These hashes have a property that contains a timestamp value. In the forEach I am checking these times and control if the timestamp is too old. If it is too old it gets added to an array that contains all "too old" timestamps. This array should be substracted from the original array. The resulting array should only contain those elements where the timestamp is "valid" in context of the logic.
Here is the script. I'd like to know if I am doing it the right way with substracting an array as mentioned here: https://community.bistudio.com/wiki/Array
private _tasksToBeRemoved = [];
{
private _currentTime = call coopr_fnc_currentGameTime;
private _taskCreatedTime = [_x, COOPR_KEY_TASK_CREATED] call CBA_fnc_hashGet;
private _freshness = _currentTime - _taskCreatedTime;
if (_freshness >= COOPR_TASK_MIN_FRESHNESS) then {
DEBUG2("freshness of task %1 is too old", _x);
DEBUG2("was: %1", _freshness);
_tasksToBeRemoved pushBackUnique _x;
};
} forEach COOPR_TASKS_QUEUE;
DEBUG2("there are %1 tasks to be removed", count _tasksToBeRemoved);
COOPR_TASKS_QUEUE = COOPR_TASKS_QUEUE - _tasksToBeRemoved;
DEBUG("task queue has been cleaned from old tasks");
Looks right to me.
It's a "little" inefficient as the - operator copies the array. Depends on how big your array is.
You could also collect the indicies of all elements to remove. Then reverse that (because if you remove at start you change all other indicies)
and then use deleteAt to delete from back to front
Surely the maps in Arma don't have projection what do you mean?
If you had unlimited view distance, would departing ships eventually disappear below horizon?
no. sea is flat
Still can't figure out why distance is changing based on direction
https://community.bistudio.com/wiki/random <- can anyone tell me what it means for a normal distribution to have a minimum and a maximum? Are there any more details on the algorithm used?
You mean alt syntax 3?
no, number 1
That is gaussian distribution. See the image on top right
But you can just put the Gaussian curve between your min and max
https://i.imgur.com/7Fk0F7i.png this equation is never equal to 0
Hi everyone! I work with ACE 3 medical system now, and have a one question. Info about all units fractures saved in QGVAR(fractures) variable (full name: "ace_medical_fractures"). But i can't find code, which add effects of broken legs and arms to unit (shaking hands, slow speed of moving). Does anyone know where i can find that?
That's done by Arma. Hitpoint damage
that's why you need to floor if you want to have chance of 0
so my question is - what cut-off is chosen? it seems like a reasonably important detail
@still forum so if i set this variable to [] like:
player setVariable [QGVAR(fractures), [], true];
It fix my leg and arms automatically?
@errant widget Hm sadly I don't know the cut off points either, what's your use case if I might ask?
I just want to know what to call a variable lol
@errant widget
random [min, mid, max] ->
randomValue = random 1;
result = if (randomValue < 0.5) then {min + (mid - min) * (randomValue2)} else {mid + (max - mid) * (randomValue2-1)}
I'm calling it "sigma" at the moment but I think it might actually be sigma / 2
wait, that gives you a normal distribution? eugh, computers should be banned
@still forum did that depends on current player damage?
I'm about broken legs and arms.
yes
if your legs have too much damage, you can only walk.
If your arms/hands have damage, your aim is shaking
So fixing that is equal to setting damage of palyer to 0?
I think so yes
That's a problem for me. But thanks, @still forum
@still forum , what was that code supposed to be?
that is how the normal distribution random works
yes
that just remaps a uniform distribution to within a certain range
Well not quite.
It actually does random 1 4 times. And then divides by 4.
I shortened that
https://i.imgur.com/bK1IbTm.png I just ran it 100,000 times
@still forum yeah i was considering the removal by index at first, too. Good you mentioned the reverse "trick". Would not have considered that
(your code, not ArmA's)
Okey I just tried that and got out a 17 on a max of 15.
Must be a typo in there I'll recheck
I mean, it's pretty obviously not doing any exponential stuff there
it's just doubling a number
randomValue = ((random 1)+(random 1)+(random 1)+(random 1)) / 4
result = 0;
if (randomValue < 0.5) then {
result = min + (mid - min) * (randomValue * 2)
} else {
result = mid + (max - mid) * (randomValue * 2 - 1)
};
result = 0? does it iterate at all?
also, the mean of 4 identical uniform distributions will just the the original uniform distribution
That should be the same as I wrote above right?
also, the mean of 4 identical uniform distributions will just the the original uniform distribution I know. That's why I shortened that when I first posted it
OH!
Yes it's not
it's based on a seed that changes every time it's called
oh, that's a very weird choice
ok
well yes, your code would rescale a distribution
the question is what on earth is random x, then?
aha, now we're getting somewhere, thanks
hmm, LCGs should be uniform
huh, dedmen, taking the mean of the four uniform distributions is the thing that matters
I guess I need to brush up on my stochastic algebra a bit more
@still forum can I change the link in the wiki to https://www.wikipedia.org/wiki/Irwin–Hall_distribution because it's actually correct? Or, at least, that's what the LCG is being used to approximate
I can't quite believe I said that the mean of four uniform distributions was a uniform distribution. that's clearly just not right
what even is the central limit theorem
Maybe not change the link.
But make a note that that is what is actually used.
Few people will care about that. And gaussian is more easy to understand
does anyone know of a tool or vim plugin that can handle the BI FSMs without all the string crap?
don't really want to use the BI FSM editor
well all code is wrapped in strings
e.g.
/*%FSM<STATE "End_delete_group">*/
class End_delete_group
{
name = "End_delete_group";
init = /*%FSM<STATEINIT""">*/"if (typename _grp == ""OBJECT"") then {_grp = group _grp};" \n
"[_logic, ""delGroup"", _grp] call ALiVE_fnc_CQB;" \n
"" \n
"if(_debug) then {" \n
" format[""%1 aborting Simple House Patrol FSM"", _leader] call ALiVE_fnc_logger;" \n
"};" \n
"" \n
"deleteMarkerLocal _mkr;" \n
""/*%FSM</STATEINIT""">*/;
precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
class Links
{
};
};
/*%FSM</STATE>*/
anyone know how isNil would behave with
isNil {(_someObj getVariable "an_object_that_might_be_nil") getVariable "possibly_nil"};
?
would it start throwing errors or catch the first nil?
seems like it catches it, yay 😃
👍
It would have been pretty useless command if isNil threw error on nil
True!
want to talk about try-catch that only catch created exceptions?
well I figured it might've with an operation on nil ^^
@halcyon crypt y u no like bis fsm editor?
guys, a way to whitelist any warlords mission? i mean like:
missionWhitelist[]={
"warlords"
};
No you need to give full mission name
can someone give me a script for firing cluster shells?
this one can fire cars
player addEventHandler ["Fired", { _bullet = _this select 6; _unit = _this select 0; _newPos = _unit modelToWorld [0,8,1]; _veh = createVehicle ["I_MRAP_03_F",_newPos,[],0,"CAN_COLLIDE"]; _veh setDir getDir _unit; _veh setVelocity velocity _bullet; deleteVehicle _bullet; }];
I did it
nvm
private _creationSuccess = [_unit, _taskId , _taskType, _destination, 1, 2, true] call BIS_fnc_taskCreate;
DEBUG2("task creation: %1", _creationSuccess); // [Server] COOPR.TASKS.debug - task creation: coopr_task_type_assault_[]
Where Biki says: Return Value: Boolean
The logging tells me the return value is: coopr_task_type_assault_[] (where coopr_task_type_assault is the _taskId given to the function as parameter)
Am I getting something wrong here? My controls are awaiting boolean values for my guard clauses but I cant get booleans outta the function call
If I need to add onEachFrame missionEventHandler, should I use the BIS_fnc_addStackedEventHandler or addMissionEventHandler?
I found Dedmen's message from a year ago if you have many handlers the BIS_fnc_addStackedEventHandler has better performance. Because addMissionEH recompiles the script before every execution., is it still the case because of the disabled compilation cache?
new question, how do I make a pawnee that fires cluster bombs
attach eventhandler to your helicopter
I dont know shit in coding could u type what I need to add in
is it still the case because of the disabled compilation cache? it was the case with and without the cache
the stacked eh scripted stuff also has overhead
why is this not working - https://pastebin.com/8F8Ws1Dw
its a shotgun script I found online
@slow isle First thing you need to understand is that people here are helping for free. You really have to make their helping as comfortable as possible. Just asking why isn't this working and providing a huge ass of script logic won't work. People in here are lazy yet willing to help - but only if they do not have to work their ass off to figure out what you actually want.
If you want someone to write your code for you, you're likely looking in the wrong place. We'll help you to the extent you attempt to help yourself
I mean I dont understand shit and I found this online and im wondering why its not working, not with a bad intent, im just confused what to ask
I cant find the error myself
if one doesnt want to help he can pass it, im not making anyone help me
Well, for one if you're only executing it once it's not going to do anything
wdym?
@slow isle in this case you really have to get basic knowledge in scripting SQF. It might sound annoying but if you don't even understand what we would tell you what went wrong with that script what is the point of asking then?
The first line says "If X exists, do this with X". The second line says "X exists, this is what it is"
@frigid raven im not wanting to learn it long term, i just found myself playing around with it and got confused why some things dont work and posted it here
if someone wants to help he can and if one does not he can pass it
@slow isle alright - just telling you what might be a reason why nobody is replying to you
Hoping to get some help with some scripting I'm trying to do.
Is this the right spot for this?
yes
Is there a way to apply torque force to an object?
https://community.bistudio.com/wiki/Category:Scripting_Commands_Arma_3 here is a list of all commands. Just search for torque
I'm actually hoping someone would be willing to join me on VoIP
scripts are usually text. So writing text messages is usually better than trying to dictate code over voip ^^
And doing both is better :3
But I mean, okay.
I just the feel Im going to put this code down and get directed to some other place where I can find better code.
Id like to go through it with someone and learn, ratther than the former.
But alas:
[this] call teleportNetwork;
params [
"_target",
"_caller"
];
// Varify Target is Sensible
//[ Author: Whigital
if (isNull _target) exitWith {
diag_log "RGTA_fnc_teleportNetwork::Target object is null!";
};
if (!hasInterface) exitWith {
diag_log "RGTA_fnc_teleportNetwork::Instance has no interface, skipping actions";
};
//]
_styleOpen = "<t size='1' font='PuristaSemiBold' color='#58D3F7'>";
_styleClose = "</t>";
_target addAction
[
format ["%1Base%2", _styleOpen, _styleClose],
{call RGTA_fnc_teleportPlayer}, [_target,"tpNodeBase"]
];
_target addAction
[
format ["%1Range%2", _styleOpen, _styleClose],
{call RGTA_fnc_teleportPlayer}, [_target,"tpNodeRange"]
];
_target addAction
[
format ["%1Explosives%2", _styleOpen, _styleClose],
{call RGTA_fnc_teleportPlayer}, [_target,"tpNodeExplosives"]
];
What am I doing wrong here? The object doesn't get any of the actions.
[this] call teleportNetwork; That means target is set. but _caller will be nil. You don't pass the second parameter. And you also seem to not be using it
My bad
is teleportNetwork variable defined at the point where it's called?
_target is meant to be _caller
where are you defining that?
Also why does the teleportNetwork function say RGTA_fnc_vehicleSpawnSetup
? Seems like it should be called RGTA_fnc_vehicleSpawnSetup and not teleportNetwork
removeAllActions _target; there is your problem
you are adding actions. And immediately removing all actions again
Ah, I hadn't renamed the function yet.
That bit comes from a fellow unit member.
Does everything else apart from the end snippit appear correct @still forum ?
didn't notice anything else
Oh my gosh
I cannot believe I spent hours ripping my hair out over that
Thanks @still forum
If I receive the _caller in my params
params [
"_target",
"_caller"
];
Could I just directly push it to the next function like I have?
{call RGTA_fnc_teleportPlayer}, [_caller,"tpNodeBase"]
yes
well
you are passing the _this from the action through
that does contain your arguments array. But not only that
What would be the cleanest way to make sure the next function can get the _caller?
Also , would it be beneficial to rather have a looped addAction which works from an array?
array would be easier to maintain. but not necessarily better
you want the caller who executed the action right?
You can get the _caller inside the action code. YOu don't need to pass it beforehand as argument
{(_this select 3) call RGTA_fnc_teleportPlayer}, [_caller,"tpNodeBase"]
that would be equivalent to
[_caller,"tpNodeBase"] call RGTA_fnc_teleportPlayer
But as I said you can get the caller in the script
https://community.bistudio.com/wiki/addAction
{[_this select 1, _this select 3] call RGTA_fnc_teleportPlayer}, "tpNodeBase"
Thanks!
For switch do, can I have or statements in the cases
like case ("classname1" || "classname2"):
no, but you can do
case "class1";
case "class2":{
};```
so if class 1 matches, it executes class 2 code?
yes
you can do as many of these case "class1"; as you like, itl jump down to the next case with code to execute.
https://community.bistudio.com/wiki/switch_do
See example 4
unrelated but what is the effective difference between a visual and non visual command
what does it mean for something to be done in "render time scope"
i dont know exactly, but the idea is visual commands return results for how something actually appears. a practical example being if you use getPosASL to draw 3d icons on a unit, when theyre moving quickly the icon will jitter around, but if you use getPosASLVisual the icon stays fixed on the units visual position.
render positions are interpolated
like when you see a car driving somewhere. You see it driving smoothly
even though there is only a position update every half a second or so
In render/visual scope, the position is predicted as to what it will be in the future. And it's updated every frame to look smooth
is it still the case because of the disabled compilation cache?it was the case with and without the cache
the stacked eh scripted stuff also has overhead
I think it's even worse now, right, since the cache is gone?
it's as bad as it was before the cache was added
That's another way to look at it 🤔
Anyway
SHould I use the BIS_fnc_addStackedEventHandler or addMissionEvent handler?
The second has compilation, the first one has overhead?
oh wait
if I pass code to addMissionEventHandler, it doesn't get recompiled
if I pass it a string, the string gets compiled every time
right?
nvm found your issue at tracker website
if I pass code to addMissionEventHandler, it doesn't get recompiled it does
that's the bug
Yes got that, I recalled I've read it in the feedback tracker
I wonder why it wasn't fixed yet :/
it's not trivial
I assumed code variable is some sort of assembly or bytecode?
it is
and compiling the string is deterministic and should return the same sequence of assembly commands?
it does yes
Then I'm confused 🤔
whats the thing I have to do for disc point picking?
Also is there a way to make it so civilians can enter blufor vehicles?
And access inventory
I have multiple boxe scattered around the map were players can but items and then delete them, what should i but in place of "this" in order to not make a script for every single box. script is triggert with "addaction"
how would one open the cargo ramps on a vehicle that would be used in Splendid Camera?
So, further to the ongoing discussion about code compilation and EHs, am I better off making my EH code fragment just a call to an already compiled function (i.e. AddMissionEventHandler ["Event", {_this Call MY_Fnc_EventHandler}]; ) - to minimize this compilation overhead (at the cost of one additional Call) ???
depends on the size of the eh code, but in general yea, calling a compiled function from the event is the way to go.
Thanks
What's the best way to execute a script through a hotkey? Let's say when the player presses HOME, then script should be executed.
a display event handler I guess
yeah ive been trying it with that, unsuccesfully, might be that my code is wrong
keydown = (findDisplay 46) displayAddEventHandler ["KeyDown", "if (_this select 1 == 199) then {player execVM 'dialog\fn_adminMenu.sqf'}"];
where do you exec it?
fn_keyHanlder.sqf ```sqf
params["_ctrl","_button"];
if (keys_mainKeyHandlerOn) then {//Provides ability to temporarily disable this key handler
_disableButton = false;
if (_button == someDIKcode) then{[] spawn mld_core_fnc_ep_main; _disableButton = true;};// Earplugs. DEFAULT: F1
_disableButton;
};
some other local script: ```sqf
(findDisplay 46) addEventHandler ["KeyDown",{call tag_fnc_keyHandler}];
This is what i use for that Niko
I did use
(findDisplay 46) displayAddEventHandler ["KeyDown", "systemChat str _this; if (_this select 1 == 199) then {hint 'working!';}"];```
and it worked
(in Eden console)
It just allows you to have multiple keybindings in a single function and a single down pres handler.
maybe waitUntil findDisplay 46 != displayNull
That too ^
@tough abyss execute script on hotkey do you have CBA? Could use CBA hotkeys system
thank you for the suggestion but I've got it down with displayAddEventHandler
@winter rose @slow elbow thanks guys
What's the general preferred way of attaching two remoteExec's to the same Object? Making a wrapper function for both remoteExecutions?
Make a function which will have both scripts needed for RE and RE only 1 function
Yeah got that! Thx!
Somehow I wish there was a version that would not override existing remoteExecs attached to object, but rather queued both of them 🤔
Me too
Or maybe CBA has such a thing actually?
The problem comes when you have other modders wanting to use the same object
yes yes, CBA could add a general queue to which we would add CBA-wrapped remoteExecs, for instance
Then the CBA's queue could be overwritten by any non-CBA remoteExec 🤦
what do i need to replace "this" with to make "clearitemcargo" applie to the containerthe script called from with "add action" ?
Why are you using local command instead of global?
I'm using global... local was faster to write 😄
clearItemCargoGlobal this;
clearBackpackCargoGlobal this;
clearMagazineCargoGlobal this;
clearWeaponCargoGlobal this;
this is the "template" that im working of.... i know i can type the variable name of the box... but i dont want to have a script for every single box in my mission
the aim is to have multiple boxes in the mission where players can put stuff in and delete it manually.. .script is executed with "addaction"
you want to add an action that spawns a box?
In some mp scenarios I saw a delay for respawn button: when you are pressing ESC - respawn button has grey colour and unawaible, but 5 second later - button becomes awaible again. This good to prevent pushing the button by accident, If you are going to settings.
How can I make this kind of delay for respawn button?
Is there vector to dir and dir to vector functions? Searching yields nothing for me
I want to interpolate dir
Ah I find CBA functions for this now
Would be nice if there was vanilla though
Vector dir is 3D while dir is 2D how are you using it?
@swift crane https://community.bistudio.com/wiki/Description.ext#onPauseScript and use something like:
params["_display"];
private _button=_display displayCtrl 1010;
_button ctrlEnable false;
sleep 5;
_button ctrlEnable true;
@tough abyss I just want to interpolate between directions over time to animate a transition. However it won't work with a single dir value due to discontinuity at 0 etc, so I convert to vector, slerp it then convert back
The problem with onpausescript is that it is scheduled and when you press escape, respawn button can still be available due to busy scheduler
Use setvelocitytransformation @ebon ridge
that is for a different problem but thanks
i don't want to modify an object just have the values and animate the values
Oh you can wait for new commands to hit dev branch think you can interpolate vector with them
How can I reference an object in a function?
params [
"_target",
"_caller",
"_tpNode"
];
_caller allowDamage false;
_caller setPos (getPos _tpNode);
sleep 5;
_caller allowDamage true;
_tpNode is the variable name of an object in-game
I've got this in the initialization field of a box with the appropriate gear inside.
This addaction ["Equip Rifle Kit",
{params ["_target", "_caller", "_actionId", "_arguments"];
private _cargo = getitemcargo _target;
_cargo params ["_items","_amount"];
private _index = _items findif {_x = "30Rnd_556x45_Stanag_Tracer_Red"};
if (_index >= 0 && {_amount#_index > 0}) then {
_caller additem "30Rnd_556x45_Stanag_Tracer_Red";
_target removemagazineglobal "30Rnd_556x45_Stanag_Tracer_Red";
_amount set [_index,_amount#_index -1];
};
}];```
The add action appears. When I use it, nothing happens. No errors are displayed in game or in the report file. But the desired effect is not achieved.
@spark turret I have multiple boxes on the map were players can but items and then delet all items in the box... a "trashbox".... they can excecute the "delete" with a "addaction".... i know how to do it with a script for every single box but i want to have one script that identifies the box from which its called from and then delete its contents
the box should stay where it is
so a certain class of boxes should all act as the trashcan?
just the boxes which have the addaction
clearItemCargoGlobal this;
clearBackpackCargoGlobal this;
clearMagazineCargoGlobal this;
clearWeaponCargoGlobal this;
i just need something to replace this with something that can identify the box from which the add action is called from
not sure what exactly you want, so you got boxes all around the map and want a script to find them without having to touch the boxes themselves?
or do you manually add the addaction to each trashcan box? bc the addaction passes on the object from which it is called
its one of the parameters passed in the _this value of the addaction. so if i walk up to the trashcan and use the action, the script run can read that I, the player interacted with that specific trashcan.
quote BI webiste: Parameters array passed to the script upon activation in _this variable is:
params ["_target", "_caller", "_actionId", "_arguments"];
Sorry to butt in here! Just a simple question ^^
When using set with arrays, how do I select the index of an array within an array.
array select 0 select 0 = "hi" in [[hallo,miau],[xyz]] if thats the question
@real moat
@thin pond
ah no it wasnt lol
Not quite, but II iwill wait for @thin pond to be done before I elaborate.
ah i understand now. not sure, try 0 select 0 as the index for multi dimensional arrays
then put "_this execVm "scriptyouhave.sqf"; " in your code of the addaction
and in the script "_this select 0" is your trashcan and _this select 1" is the player using it
Hey guys, dont you know why civilianAi when i go around them and fire, they go into the combat behaviour and then back to safe like they should. But when this "behaviour cycle" goes like four or five times then civs dont react on fire so much. So do someone know why is that?
@spark turret not quite shure how to use the select0/1
here are the "delete" commands clearItemCargoGlobal _this;
clearBackpackCargoGlobal _this;
clearMagazineCargoGlobal _this;
clearWeaponCargoGlobal _this;
well the _this thing is an array created by the addaction. if you put hint str _this (display it in the game) you get something like "[Player1 IRONSIGHT,trashcanobject102485]
_this select 0 selects the first position in the _this array which is the calling entity, here its the player
but you need to put _this select 1 since it selects the second position in the _this array which is the object the action was used from, aka the trashcan
so put clearBackpackCargoGlobal (_this select 1);
is SHOULD work lol can guarantee it tho
put this into the trashcans Init line in editor, it will show you what the _this array looks like:
_actionID = _this addAction ["Show me the _this value", {hint str _this;}]
keep in mind that the _this value is different for every command or entity. it changes/can be changed by commands and other factors. it basically stores important information you need to know about the object or command
@spark turret my brain is deep fried after 8 hours of scripting any chance you could tell me what exactly i should put in my .sqf ? 😄 heres my add action i use: this addAction ["<t color='#960600'>TEXT</t>", "scripts\GEN\Trash.sqf", [], 1, false, true, "", "_this distance _target < 2"];
_actionID = this addAction ["empty the trashcan", {_this execVM "scripts\GEN\Trash.sqf";}]; is the command you need in the init line of the trashcan.
in the script you put:
clearBackpackCargoGlobal _this select 1;
clearMagazineCargoGlobal _this select 1;
clearWeaponCargoGlobal _this select 1;
Hey guys
Yea my brain is beyond friend at this point
Its taken be like 2 days to write 120 lines
But Im trying to learn rather than copy-ppaste
Is there anything wrong with this line of code: somewreckthing setTaskState "Succeeded";
somewreckthing is the variable name of a task module
then it should be fine
It says there's a general error
im not sure how the modules work but with chance the variable name of the module is NOT the actualy task name
@real moat I'm beyond the point to learn something right now ;D
@toxic temple did you put something in the Task-id field of the module? that should be the name
if its empty, it should be the variable name
I put a 1 in it
Then just ran it again with that in before you asked
And it still says Error General Expression Error or something like that
Generic Error in Expression
hm interesting. i have never used tasks tbh
I really want this too work...
where is the command executed?
In the trigger's activation thing
@spark turret "array excepted object" didnt work.. digging into it right now
==
its not a condition its a assignment 😄
👀
Just scroll up a bit
can probably yes, want is another thing lol
code looks fine. If somewreckthing is really what you expect it to be
if (_target == _tpList select _i) then {} needs to have _i defined, either by you or be in a for "_i" from 0 to 100 do {} loop. are you aware of that?
i assume you want to check if the _target is in the _tplist. try if (_target in _tpList) then {} for that
its case sensitive so watch out
@real moat
Huh
kinda, but not qute like that
I seemed to have found a different way
["task1","CANCELED"] call BIS_fnc_taskSetState;
Well that works via Debug menu
Let's test it with the trigger
One sec
This is what I'm tryin to do:
params [
"_target",
"_caller",
"_pos"
];
// Establish Array
_tpList = [
["_tpNodeBase", "Base" ,2],
["_tpNodeRange", "Range" ,2],
["_tpNodeExplosives", "Explosives" ,2],
["_tpNodeIsland", "Island Runway" ,2],
["_tpNodeUSS", "USS Freedom" ,2],
["_tpNodeRGS", "RGS Posidon" ,2],
["_tpRandom", "Random" ,2]
/* Value 2 = coordinates */
];
for "_i" from 0 to (count _tpList) do {
if (_target == (_tpList select _i) then {
_tpList set [[0,2], _pos];
//hint "True!";
//sleep 2;
}
//else { hint "False!"}
};
(_tplist select _i) set [2, _pos]
?
Btw. Don't do for loop. Use foreach if you need to loop
@real moat you just wrote a really complicated if (value in array) then {}
btw2 use findIf to find the index
or a foreach yeah
Thanks. I mean, guys, im learnin.
private _index = _tpList findIf {_x select 1 == _target};
(_tpList select _index) set [2, _pos]
also just fyi count _array returns all positions added, so count [a,b,c] = 3
for "_i" from 0 to 3 executes the code 4 (!) times
means for "_i" from 0 to count [a,b,c] do {array select _i}; gives an error bc it tries to do array select 3 which does not exist
gives an error bc it tries to do array select 3 which does not exist
No. I think one past the end still returns nil
if you go two past the end you'll error with zero divisor
Arma is great
you re probably right, anyways just dont do that lol
if you really MUST use it, use:
for "_i" from 0 to (count [a,b,c] - 1 ) do {array select _i};
I don't see any reason why that would ever be needed
At most, you might need the index for something.
but forEach gives you the index
i dont fully understand foreach commands and dont trust them so if i need a foreach for 2 arrays within each other i use that method
not a good reason I KNOW lol
{
private _firstElement = _x;
{
_firstElement setPos _x
} forEach _array2;
} forEach _array1;
you enlighten me again and again
My bulb is turned on
I dont even know what anymore
while we are at it, whats the difference between private _variable = ""; and _variable = "";
innermost scope only right?
yes
@real moat { player addMagazine "M16"; } forEach [1, 2, 3, 4];
https://community.bistudio.com/wiki/forEach
Eww 😄
lol
player addMagazines ["M16", 4]
Btw M16 is not a magazine
its from the BI webiste, im not to blame
blames #community_wiki
@real moat what is THAT trying to achieve? _tpList set [[0,2], _pos];
it will change the same positon in the array over and over
I really cant explain this in simple over text. Could you join me in the voice chat perhaps?
the positon of the string "Base" will be changed to _pos every time its called
sure why not
I already showed you how to do it ^^
select the array you want to set something in first.
Then call set on that
@spark turret https://community.bistudio.com/wiki/addMagazines where exactly does it say M16?
Oh that, tsk tsk tsk
tzück tzück
How to I make it so that a create task module only happens after a trigger?
condition for existence: change true to whatever global variable boolean you have
oh wait i take it back
doesnt work
I don’t know if this is the case, but some modules if linked to a trigger will only execute once the trigger is activated
@toxic temple
I did it dw
"M16" was both weapon and magazine in OFP
class M16: Riffle
{
scopeWeapon=2;
scopeMagazine=2;
valueWeapon=0;
valueMagazine=1;
model="m16_proxy";
modelOptics="optika_m16";
optics=1;
opticsZoomMin=0.34999999;
opticsZoomMax=0.34999999;
displayName="$STR_DN_M16";
displayNameMagazine="$STR_MN_M16";
shortNameMagazine="$STR_SN_M16";
drySound[]=
{
"weapons\M16dry",
0.0099999998,
1
};
magazines[]=
{
"M16",
"Mortar"
};```
"good old days" ;-p
How would I go about sending a getPos result through to a called function?
(getpos player) call myfunction
yes
Thanks
Actually
I would imagine select 2 would be the getPos result
but it just spits out "5"
select 2 is syntax error. what are you actually executing
Object Init:
[
this,
player,
getPos this
] call function;
Function
params [
"_target",
"_caller",
"_pos"
];
Test
hint str(_pos);
Gives me "5"
Not possible
Not possible wat?
I've got a question, i'm guessing it's an obvious one, but I can't figure it out. I'm trying to learn how to run scripts on my dedicated server as an admin, and i'm struggling with applying the command to a specific player. An example:
player enableFatigue false;
I can run that locally, and it'll apply to myself, so that's fine. But what I don't understand, is how do I apply this to a specific connected user that isn't me? what do I put instead of "player"? do I need to do something else to make "player" count as that user?
Getpos returning "5" is not possible
what do I put instead of "player" it's not that simple
allPlayers is a list of all players
you can iterate through that till you find the unit that you want
what condition you want to base that on is your decision. You could check the name
So i'm guessing I need to loop through all players, find the user, and put that object into a variable that I can then put instead of "player" in the above example?
yes