#arma3_scripting
1 messages · Page 529 of 1
ill try not mate haha
so am i correct in saying i can litreally copy and paste a script off the internet and put in and it will work?
ahh sweet any thing with a video is of great intrest my fried
so am i correct in saying i can litreally copy and paste a script off the internet and put in and it will work? Depends where you copy it from 😄
haha nooby question where do i put it 😅
oh as well r3vo when i save a mission it saves as a pbo so i can't open it to insert script how do i change that?
When you save a mission it will save in Documents/Arma 3/missions or Documents/Arma 3/mpmissions (assuming you're on your main profile)
pbo means it's a packed file, ready to be played. You cannot changed pbos without unpacking them first.
That's why it says "Export" instead of "Save".
btw you just helped me fix that issue with exporting to sqf not working with 3den Enhanced. Thanks!
i don't have a clue how i helped with that but your more than welcome haha and thanks horner the only ones i can seem to find are the pbo ones, so do i save the scenario then export as single player i plan on doing a singple player one then look in the area for it ?
ever so sorry for the nooby questions guys its my first pc only bin on one 8 month so its like learning how to walk to for me tbh
You can open your scenario folder from within the editor directly
when i save it the mission don't go to that folder for some reason it shows on the video the same location as you said horner but not there for some reason
just loads said scenario
i want the location but to add script if you with me
found it
guys i seem to have a bigger problem when i right click and try to press new it crashes and dosn't work....
so i go to documents arma 3 mp missions right click go to click new to make new text and it crashes and dosn't create one
yeah more common than you think if you google it,conflicting program some where
Random thought, would it be possible to add an internet radio to a vehicle?
(Currently working on vehicle reskins for my group and want to expand my horizons a little bit on various functions)
I doubt you can make arma play an audio stream even through Intercept
....but you could write a .dll that just plays sounds on its own I guess?
of course all players must have this addon
anyone know of a way to see what object is currently under a vehicle
isTouchingGround returns true while atop of an object
@astral dawn it is possible https://github.com/maca134/arma-nradio . But this version isn't functional at the moment
does arma play audio for you or does your addon play it itself?
@cosmic lichen I've at to make a new user and lose many things 😩 😫 😭 😭 😭 😭
Hello guys.
wanted to check if anyone could help me out.
Basicly I would like to use a object as a autoheal function. When a player stands closer than 5m from the variable/object (In this case KLT_healLocation) he gets automaticly fully healed.
What I´m having problems with is the definition of my local variable _nearby_units. This one needs to define the specific player that is close towards the KLT_healLocation.
This is what I got so far....
while {true} do
{
if (player distance KLT_healLocation < 5) then {
_unit = player;
_nearby_units = {if (_unit distance KLT_healLocation < 5)};
hint "works";
//Ace
{
if (local _x) then {[_x, _x] call ace_medical_fnc_treatmentAdvanced_fullHealLocal}
else {[_x, _x] remoteExec ["ace_medical_fnc_treatmentAdvanced_fullHealLocal", _x]
};
} forEach _nearby_units;
//Vanilla
{
_x setDamage 0;
} forEach _nearby_units;
}
else {
hint "Too far away";
};
};
@obsidian violet Is this piece of code executed locally, on the server, both, or within a trigger/gamelogic entity? And when you say specific player, do you mean whoever is closest to the KLT_healLocation?
The code is being run on both server and locally so it would work on a dedicated server.
Afirm, to anyplayer/ players standing closer than 5m from the object KLT_healLocation
@obsidian violet this is my take on a solution, hopefully it does what you're looking for
while {true} do //Run indefinitely with a delay of 100ms between iterations. Excluding the sleep function can cause performance issues
{
_nearby_units = (getPos KLT_healLocation) nearEntities 5; //_nearby_units will be an unsorted array of objects that exist within 5 meters of KLT_healLocation
{
if (_x isKindOf "Man") then //Filter the object entity array for infantry units, ignore everything else
{
hint "works";
//Ace
if (local _x) then
{
[_x, _x] call ace_medical_fnc_treatmentAdvanced_fullHealLocal
}
else
{
[_x, _x] remoteExec ["ace_medical_fnc_treatmentAdvanced_fullHealLocal", _x]
};
//Vanilla
_x setDamage 0;
};
} forEach _nearby_units;
if (player distance KLT_healLocation > 5) //If the player is more than 5 meters, give them a hint that they are too far away
then
{
hint "Too far away";
};
sleep 0.1;
};
Damn, this works great!
Thank you sooo much! 😄
Hey need a bit of help if someone can spare the time. I'm rather inexperienced with sqf so be gentle :|
Basically I have a turret attached to a vehicle, and I'm trying to figure out how I delete said turret should the vehicle it's attached to be destroyed or deleted. When I run my script the turret is spawned and attached, I don't get any script errors, but when I delete or destroy the vehicle, the turret remains.
if (isServer) then {
params["_Jackle"];
_Main_Gun = "HE_Turret_TypeX" createVehicle (getPosASL _Jackle);
_Main_Gun attachTo [_Jackle,[-1,0,-0.5]];
createVehicleCrew _Main_Gun;
[_Main_Gun, true] remoteExec ["hideObjectglobal", 0];
_Jackle addEventHandler ["killed", {deleteVehicle _Main_Gun;}];
_Jackle addEventHandler ["deleted", {deleteVehicle _Main_Gun;}];
};
@versed elbow SQF scripts are executed in a scheduled enviroment. Event handlers execute in a different enviroment (unscheduled) where they cannot access private variables in your SQF. You pass _Main_Gun into the event handler, but when the event handler executes, _Main_Gun is undefined, and due to the nature of event handlers that won't return an error. To resolve this, create and attach a variable of datatype object for _Main_Gun to the object of _Jackle itself, which can then be accessed by the event handler via the parameters that the event handler "killed" provides, which is "params ["_unit", "_killer", "_instigator", "_useEffects"];. For the event handler "deleted, it will be params ["_entity"]; What you'll want to use here is "_unit" for the killed EH, and "_entity" for the deleted EH, which in both instances is the object the event handler is assigned to; which in your case with be the same as _Jackle.
This is my take on a solution to the problem, hopefully it does what you're looking for
if (isServer) then
{
params["_Jackle"];
_Main_Gun = "HE_Turret_TypeX" createVehicle (getPosASL _Jackle);
_Main_Gun attachTo [_Jackle,[-1,0,-0.5]];
createVehicleCrew _Main_Gun;
[_Main_Gun, true] remoteExec ["hideObjectglobal", 0];
_Jackle setVariable ["mainGun",_Main_Gun]; //Attach a variable of datatype object referencing _Main_Gun to the object _Jackle itself.
_Jackle addEventHandler ["killed",{params ["_unit", "_killer", "_instigator", "_useEffects"]; deleteVehicle (_unit getVariable "mainGun");}]; //Use the _unit parameter provided by the EH to access _Jackle, then access _Main_Gun, deleting it
_Jackle addEventHandler ["deleted",{params ["_entity"]; deleteVehicle (_entity getVariable "mainGun");}]; //Use the _entity parameter provided by the EH to access _Jackle, then access _Main_Gun, deleting it
};
Thank you so much for the explanation and solution, as I said I'm fairly new to SQF so detailed stuff like this really helps.
Just tested it, works like a charm 😉 Thank you again!
does anyone know why
(-1) mod 7;
``` is -1 in arma,when it should be 6?
That is some strange behaviour, it may be a bug. I would use this instead for now, it's an equation with the same/correct behaviour as the modulo function (A mod B)
(A - floor(A/B)*B)
@astral dawn the extension plays the audio. You are correct that you can't get arma to play it.. Atleast not without alot of work
@edgy dune @tough abyss
Because C++ does it that way.
https://en.cppreference.com/w/cpp/numeric/math/fmod
The returned value has the same sign as x and is less than y in magnitude.
oh ic, daz weird ive never seen that
_MyArument = (_this select 0);
_string = (_this select 1);
hint str _MylocalVariable;
getting error code on this why guys?
i know its basic but im learning
Because it's not defined. You never assigned anything to that.
Also use params instead of _this select X.
Also no need to put that in parenthesis
_this select 0 and similar is old code and is not recommended to be used if params can be used instead
in your code above you set the variables _MyArument and _string
And then try to read the variable _MylocalVariable
But you never set the variable _MylocalVariable so it doesn't exist, thus it's an error
myVairable = 0;
hint str myVariable;
i can't even figure this one out to just get a 0 to come up at the top right
Again undefined variable.
you set myVairable But try to read myVariable but you have never set myVariable thus it will be undefined and error
so what should it look like dedmen
myVariable = 0;
hint str myVariable;
gives me error code on line 2
You wrote there
hint str _MylocalVariable
Look again what i wrote
so if i wanted to swap the 0 for text how would i go about that
myVariable = "text";
it works!!!!! thanks so much man!!!
it shows the " " as well though is that some thing you cant change?
and it stays there how do i make it stay for 5 second thengo
the additional quotes are added by your str call
turning a string into a string makes a string inside a string. So you'll see the quotes.
hint automatically disappears after some time
okay i see thanks im going to practice
so if i wanted a helicopter to fire a certian rocket at a target would i use
_handle = this fireAtTarget [groundtarget1,"HellfireLauncher"];
needs setVariable.
Error Reserved variable in expression@hollow thistle
Obviously, it is just when people say I have seen nil, and nul, and null used... I'm like 🤦
What did I just find?
doStuff = {
diag_log str _a;
};
_a = 666;
remoteExecCall ["doStuff"];
And it outputs 666 into RPT? Seriously?!
And dedmen's ade_dumpcallstack can't see _a but SQF can see it?! @ebon ridge
(╯°□°)╯︵ ┻━┻
if I do remoteExec then stack variables are not being passed
If anyone has experience with powershell, I'm just trying to make a script that will move coords for map objects: https://stackoverflow.com/questions/56078952/how-to-change-values-in-text-files
In case you know: When a player is on a heli and the heli crash on the ground, and the player dies, what is the _source and _instigator returned by the player HandleDamage event handler calls? I can't test now, sorry!
guys ive downlaoded ad script from armaholic where it will randomly generate ai drop offs and reinforcements how do i put that into my game now ?
documents arm 3 missions the mission folder?
Is there a way to set the tooltip a slider has via script?
done it mate getting error codes now when i reach the trigger
trying to figure that bit ot now
"And it outputs 666 into RPT? Seriously?!"
So... what? What's special on that? remoteExec just calls in current scope
ade not seeing it is probably a bug then
Maybe it's a seperate callstack but the root node has the script where remoteExec was called as parent
ADE doesn't check namespace parents
I expected it to call in a clear scope, maybe even in another frame
So code executed on local machine and a remote machine gets different environments and variables, wtf :/
I have code that relies on isNil of some local variables
and i noticed that it was working wrong on my local computer
anyway don't you agree that it should not work like this?
🐧
well it's some logging macros and it relied on special private variables added, let's say, per each function call
I would execute things that execute locally right there and then.. Just like a normal call
Though I think it's definitely possible to make things thing
I add stuff to JIP queue and use side as JIP flag
@cosmic lichen already tried https://community.bistudio.com/wiki/ctrlSetTooltip?
anyway don't you agree that it should not work like this?
did someone delete tonnes of messages?
? I'm refering to my message above with a piece of code
doStuff = {
diag_log str _a;
};
_a = 666;
remoteExecCall ["doStuff"];
yes
are you testing in SP or MP?
sp
might be different in MP then
let me see in mp actually
you are right, in mp it works as expected
in SP it's just replaced with plain call I think
keep getting a error undefined variablein expression: _helitype
if(typeName _heliType == "ARRAY")then{_heliType = selectRandom _heliType;};
thats the script
well. did you define _heliType?
no i thought it randomly generated one
🤦
hese why it says select random heli type
im new bear im trying to learn please please bear with me hahaha
Your computer does nothing you don't tell it to do.
selectRandom selects a random element from a list
It does not generate a list.
makes sense
How would it even know what kind of list you want?
_helitype
so how would i just tell it to pick a PO-30 Orca
By assigning the class name of the Orca to the variable.
i downladed the script of armaholic i thought it was just a simple case of putting the sqf in mission file placing a trigger and calling the script
did you read the text on the scripts armaholic page?
which text you refering to ded?
"on the armaholic page"
where you downloaded the script from
there is usually text above the download button
yeah it says to see included documentation ive opened that and it simply says to copy and paste this
nul = [this] execVM "LV\heliParadrop.sqf";
so i place that in my trigger activation and i have the script for the helidrop in my mission file
it gives me error line for 122 as above
"in my trigger activation" no
how come?
this is undefined in trigger activation
I assume it's meant for a init script on something
sorry i don't follow
Hey, I'm having problems with vehicle customizations being visible online. Apparently just customizing the vehicle with things being visible isn't visible to people joining and I somehow can't get BIS_fnc_initVehicle to work to do it, so this:
[
car,
["Guerilla_11",1],
["HideDoor1",1,"HideDoor2",1,"HideDoor3",1,"HideBackpacks",1,"HideBumper1",1,"HideBumper2",1,"HideConstruction",1,"hidePolice",1,"HideServices",0,"BeaconsStart",0,"BeaconsServicesStart",0]
] call BIS_fnc_initVehicle;```
doesn't work even when called on all clients.
Anyone can help me with my question some messages above?
sorted it guys
@turbid thunder how do you do it, works fine for me
@tough abyss Init.sqf. Does it work for those that join your game too?
JIP works yes
what if you delay it
because maybe it is too soon
try
[] spawn {
sleep 1;
[
car,
["Guerilla_11",1],
["HideDoor1",1,"HideDoor2",1,"HideDoor3",1,"HideBackpacks",1,"HideBumper1",1,"HideBumper2",1,"HideConstruction",1,"hidePolice",1,"HideServices",0,"BeaconsStart",0,"BeaconsServicesStart",0]
] call BIS_fnc_initVehicle;}
in init.sqf
Will try. I'm having some big trouble getting this to work because apparently just setting it to be like that in the editor doesn't work. And my next problem is that if I want to spawn in vehicles with that customization, I have to use the vehicle spawn code coming from the export. At least I couldn't figure out how else I would apply the customization without needing a giant list pre-made functions ready to use for every customized vehicle variant I use
My bet is on this executed too soon
Okay so
No, it doesn't work
But somehow the customization works for the T-140 without any issues
does it change texture at all?
for you
Well, yes, it works for me because it works for me without any scripts
That any customization done is visible to me as the host
But when my friend joins he can't see it
tested on a self hosted server
ok let me try that
yeah hosted is fine as well
you must be doing something else
make a simple mission 2 players 1 car
Hi! I'd like to make an object that would be a copy of my drone (x,y,z) but with (x,y,-1) how do I do it?
Also apparently when we respawn our guns make no sounds. Nice
what sound the guns should make?
oh then you definitely have something broken
probably overloading network with messages or have lost packets
@tough abyss So apparently, enableSimulation causes that issue
If I disable it, it doesn't work
Yeah, all that stuff in the game is simulated, not real 😅
you disabled simulation on the vehicle?
Yes. They're not supposed to be used
did you put it in vehicle init?
No
I mean, define "init field". I put a script execution in the init field
Btw a simple two player mission with nothing also creates the sound issue
you said you added it in init.sqf?
Not the enableSimulation
this enablesimulaion false?
yeah
Hu?
You tell the engine "I don't want this object simulated"
Engine: Ok
You: Now update the texture
Engine: U wot m8?
So basically, I can't ever make a vehicle static if I want customization in multiplayer?
btw I figured out that switching weapons or reapplying the loadout fixes the sound issue. GG bohemia
customize it, then disable simulation.
You can create it as simple object and customise it no need to disable simulation
Adding in a one second sleep fixed that issue
I never figured out why but to get my custom HUD working I had to have a 1 second sleep before initialization
I should revisit that
@random crescent
deleteVehicle _veh;
_export = compile ([_car,typeOf _car] call BIS_fnc_exportVehicle);
call _export;```
Believe it or not, but for some reason, THIS works and I can use _veh to reference the vehicle spawned in from the BIS_fnc_exportVehicle
why are you creating a vehicle and then immediately delete it?
If I don't delete it, I have two vehicles. If I remove the first spawn code, then _veh can't be used as a reference for the vehicle which just spawned in. It throws an error. But for some odd reason, THIS, works.
it will be null though
_veh = createVehicle [typeOf _car, [0,0,100000], [], 0, "NONE"];
deleteVehicle _veh;
_export = compile ([_car,typeOf _car] call BIS_fnc_exportVehicle);
call _export;
_veh attachTo [_car, _offset];
Vehicle actually gets attached to the object I wanted it to be attached to
yeah that's because the code that export function refers to its vehicle
its entirely unrelated to spawning a car first
then _veh can't be used as a reference for the vehicle which just spawned in.
🤦
_veh = objNull
is the same as creating and deleting
this is what that export function creates
_veh = createVehicle [""gm_ge_army_Leopard1a1a2"",position player,[],0,""NONE""];
[
_veh,
[""gm_ge_wdl"",1],
[""CamoNet_01_unhide"",0,""CamoNet_02_unhide"",0,""CamoNet_03_unhide"",0,""AmmoBox_01_unhide"",0,""AmmoBox_02_unhide"",1,""FuelCanister_01_unhide"",0,""FuelCanister_02_unhide"",0,""FuelCanister_03_unhide"",0,""beacon_1_1_org_unhide"",0,""sideskirt_unhide"",1]
] call BIS_fnc_initVehicle;
so what you want is
private "_veh";
call compile ([_car,typeOf _car] call BIS_fnc_exportVehicle);
_veh attachTo [_car, _offset];
no need to spawn stuff.
also dont spawn 10k mid air. just spawn at 0 0 0, it has some optimizations.
private _veh = objNull
:U
//_veh = createVehicle [typeOf _car, [0,0,100000], [], 0, "NONE"];
//deleteVehicle _veh;
_export = compile ([_car,typeOf _car] call BIS_fnc_exportVehicle);
call _export;
_veh attachTo [_car, _offset];```
Throws an error and the vehicle doesn't get attached
¯_(ツ)_/¯
But how would I do that when I'm using the export function?
mason just copy my three lines and replace your three lines with what i wrote
it works.
Well no because it needs to work with any vehicle I attach that script to and not just that one that I have prepared to look that certain way
and?
🤔
any way i can make notepad++ dark theme?
C++ Best
yes
@random crescent so "private" in a nutshell does what? I never understood it
my variant would work without private too
thanks @queen cargo
private _x = 1;
call {
_x = 2
};
hint str _x; // 2
call {
_x = 2
};
hint str _x; // error
private _x = 1;
call {
private _x = 2
};
hint str _x; // 1
makes sense?
if the variable exists in an outer scope, and you dont use private, the variable in the outer scope will be changed.
if the variable does not exist in an outer scope, and you dont use private, the variable is undefined, even if it is used in an inner scope.
if the variable exists in an outer scope, and you use private, you prevent accidentally overwriting stuff from an outer scope.
if you just use private "_x", the variable won't be undefined, but it will be nil. nil basically means "it exists but has no value".
params and param automatically will do privatization, too. it's best practice to always use privatization because of the accidental overwriting.
you're welcome
Now I just have the weapon sound issue to deal with
I dunno for some odd reason, even on a simple 2 player mission with nothing on it, weapon sounds cant be heard after respawn unless we switch to our pistol and then back to our primary
@random crescent Do you know a way to exclude the game automatically spawning in the vehicle while still being able to apply the customization
use unscheduled
so no spawn or execVM
then everything happens within a single frame
param doesn't make variable private D:
use unscheduled so no spawn or execVM then everything happens within a single frame
or wrap the code that must not be interrupted into isNil {}
"param doesn't make variable private D:" it does
params does
^^
param is like select or #
Indeed ^^
JIP is not working anymore. when you want to join you are in the lobby and when you choose the slot and click ready its also loading but then it stays on the loading screen. is there a standard JIP script what i can try?
20:26:18 "JIP: Саша (00000) ready."
20:26:18 Performance warning: SimpleSerialization::Write 'JIP0000_aiSetting' is using type of ',NaN' which is not optimized by simple serialization, falling back to generic serialization, use generic type or ask for optimizations for these types
20:26:18 Performance warning: SimpleSerialization::Read 'JIP00000_aiSetting' is using type of ,'NaN' which is not optimized by simple serialization, falling back to generic serialization, use generic type or ask for optimizations for these types
20:26:18 .: Value type not matching: Number != Not a Number
20:26:20 Error in expression <ime;
looks like you tried to transmit a NaN and arma didn't like it?
I was messing with remoteExec(Call) today and it works as expected for JIP 🤷
Yes I was able to reproduce it with a bad number, it looks like it doesn't execute the function remotely if it can't serialize arguments:
doStuff = {
params ["_value"];
diag_log format ["Value: %1", _value];
};
_a = sqrt(-1);
[_a] remoteExecCall ["doStuff", 2];
23:23:51 Performance warning: SimpleSerialization::Write 'params' is using type of ',NaN' which is not optimized by simple serialization, falling back to generic serialization, use generic type or ask for optimizations for these types
23:23:51 Performance warning: SimpleSerialization::Read 'params' is using type of ,'NaN' which is not optimized by simple serialization, falling back to generic serialization, use generic type or ask for optimizations for these types
23:23:51 .: Value type not matching: Number != Not a Number
so, check what parameters you are transmitting
NVM, missed something obvious
it does
not
When I have this: random [240,600,1200] can I make it so it only gives me numbers in steps of 60? (so basically minutes)
Use smaller numbers and then multiply the result with 60
Just do smaller random, then round and multiply my 60
// from 1 to 10 minutes
private _duration = (ceil random 10) * 60;```
Ah, duh I totally forgot that I could just multiply. Thanks :3
_firstshot = [cam1, cam2, target1, 9, 0.3, 0.1, false, 0, 0, 0,false] execVM"AL_intro\camera_work.sqf";
any one see any thing wrong with that ive follwed the video down to t and cant figure it
now no error lines just script_AL_intro/camera_work.sqf not found
\ not / maybe used the wrong slash?
on the code?
On the code that runs the script, yeah
Okay. So far i have a script with which i can shoot grenade from a "thought shoulder weapon" something like a shoulder mounted grenade launcher.
I can dumb fire, dumb mass fire, target on map within range and so on. Near limitless options to make 'cool shoulder mounted weapon'
But immersion is a thing, you know... a script can only do so much. Is there a mod-less solution i can kind of get an object attached to the shoulder with which i can fire then those grenades? Or is a mod unavoidable? Future Setting is awesome but kinda everyone still sticks to ww2, cold war n' stuff... So nobody thinks of the future kind of.
What would a solution look like? Full blown script with all yadda yadda or a straight up mod?
what does |#| in a error line
# highlights where a problem has been found
i guess generic error if i remember correct.
[150, 90, 400, 1000, restriction] spawn Dan_fnc_CruiseMissile / or ExecVM "fn_cruiseMissile.sqf";
got a # at the spawn part
and correct @keen bough saying error generic error in exspression
oof, dont know - the spawn looks correct if its configured exactly like that. The error could be then in the function. Dont know the code before spawn or the function itself
no worries thanks any way
hey. Somebody needs to make SPIE (Special Patrol Insert/Extraction ) in arma 3. https://youtu.be/oPBQ5vnPBmU
Yeah go ahead, let us know when you're done
_rng0 = random [-2, 0, 2];
_rng1 = random [-2, 0, 2];
_pllX = _plLok select 0 + _rng0;
_pllY = _plLok select 1 + _rng1;
throws me a zero divisor every now and then, yet i could not tell why that happens. Any clues?
It seems it did not worked well with select 0 select 1, so i used () around them and now there is no zero divisor.
If a player take one hit and die, the **HandleDamage ** EH is processed to all parts before the **Killed ** EH runs even if the player died on part 2 or 3 of 9?
@peak plover thanks!
Player doesn’t die during HandleDamage
This is why you can override the damage
Because it is not applied until after
@keen bough look up sqf operator precedence
addEventHandler is local command?
what does it mean when i got to launch a script in debug and it says cannot find script ?
script AL_intro\time_sev.sqf not found im getting
but that sqf is in the mission folder
the script is in the folder "AL_intro" within your mission directory?
I'm trying to use setName to change the name of a dog unit
but it is not displaying on the DUI Squad Radar mod
is this a problem with the mod or should I use another way of doing this
_grp = createGroup civilian;
_dog = _grp createUnit ["Fin_blackwhite_F", _pos, [], 0, "CAN_COLLIDE"];
_names = ["Bella","Lucy","Daisy","Luna","Lola","Sadie","Molly","Bailey","Max","Charlie","Cooper","Buddy","Jack","Rocky","Oliver","Bear","Duke","Tucker","Sophie","Lexi","Pepper","Poppy","Maya","Izzy","Annie","Harley","Belle","Willow","Cali","Marley","Angel","Sugar","Shelby","Nova"];
_selectedName = selectRandom _names;
_dog setName _selectedName;
[_grp] joinSilent _dog;
player groupChat (format ["name: %1",(name _dog)]);
the name of the dog is being outputted, however DUI is not showing it
🤷 then we must know how the addon is getting the name
I think @digital jacinth made it?
Until he's here I would start looking at https://github.com/diwako/diwako_dui to search for your answer
Thanks, gonna do some crawling then 😄
Just to be sure, does name _dog return the name you have set with setName?
yh
@surreal peak you sure the dog is even in your player characters group?
it takes orders and the empty group symbol only appears after I get ihim to join
Here is the full script for reference:
["Dog Modules", "Spawn Friendly Dog",
{
params ["_pos","_unit"];
_grp = createGroup civilian;
_dog = _grp createUnit ["Fin_blackwhite_F", _pos, [], 0, "CAN_COLLIDE"];
_names = ["Bella","Lucy","Daisy","Luna","Lola","Sadie","Molly","Bailey","Max","Charlie","Cooper","Buddy","Jack","Rocky","Oliver","Bear","Duke","Tucker","Sophie","Lexi","Pepper","Poppy","Maya","Izzy","Annie","Harley","Belle","Willow","Cali","Marley","Angel","Sugar","Shelby","Nova"];
_selectedName = selectRandom _names;
_dog setName _selectedName;
[_grp] joinSilent _dog;
player groupChat (format ["name: %1",(name _dog)]);
{_x addCuratorEditableObjects [[_dog],true];} forEach allCurators;
[_dog, 0, ["ACE_MainActions"], petAction] call ace_interact_menu_fnc_addActionToObject;
_dog setVariable ["BIS_fnc_animalBehaviour_disable", true];
}] call Ares_fnc_RegisterCustomModule;
petAction = [
"Pet Dog",
"Pet Dog",
"",
{
[_target] joinSilent _player;
_player setDamage 0;
_handle = [{
params ["_args", "_handle"];
_args params ["_target"];
scopeName "handle";
if (!alive _target) then {
[_handle] call CBA_fnc_removePerFrameHandler;
player groupChat (format ["Dog Dead"]);
breakOut "handle"
};
_gLeader = leader group _target;
if (speed _gLeader > 6) then {_target playMove "Dog_Sprint"};
if ((speed _gLeader > 3) && (speed _gLeader < 6)) then {_target switchMove "Dog_Run"};
if ((speed _gLeader > 1) && (speed _gLeader < 3)) then {_target switchMove "Dog_Walk"};
if (stance _gLeader == "PRONE") then {_target switchMove "Dog_Sit"};
if ((stance _gLeader == "CROUCH") && (speed _gLeader == 0)) then {_target switchMove "Dog_Sit"};
}, 2, [_target]] call CBA_fnc_addPerFrameHandler
},
{true}
] call ace_interact_menu_fnc_createAction;
hmm i see. i take it no icon and name is shown @surreal peak ?
Just tried it out on the current dev version of DUI, this is how it looks like
https://i.imgur.com/n5BPSDl.png
seems to work on my end? Is it a multiplayer issue?
my current recommendation for the name to show up is to do this and the setName command
_dog setName _selectedName;
_dog setVariable ["ACE_NAME", _selectedName, true];
Will try that out when I get home. Thanks!
how to detect editor testing vs SP mission play?
I’m a complete idiot when it comes to scripting.
I’m trying to figure out / see if there are any prewritten scripts for a flag.
Idea is to walk up to a flag, scroll wheel with the AddAction and to raise the flag of your own side.
Does anyone know anything similar / relatable to this?
@cold pebble ty. but not useful:
true when inside editor environment, false during preview
will be true for editor testing but false for mission play? 🤔
so the BIKI info is wrong?
uiNamespace getVariable "gui_classes"
this seems to have been a way pre Eden editor
@velvet merlin You need that for a mod or just a script?
uiNamespace getVariable "gui_classes" is no longer set it seems
currently trying to find some other variables
how do i set camera target on vic
@velvet merlin If the player used the context menu and pressed "Play as this characer" the variable "bis_fnc_3DENMissionPreview_code" is set in uiNamespace
Becomes temp mission
But whats a mission in SP called which has no author set
@cosmic lichen still working with the 2d editor here
i think i need to find a var that is set in SP and not via editor preview
@burnt torrent https://community.bistudio.com/wiki/camSetTarget
don't forget to camCommit
whats that im a noob to all this
oh... what are you trying to make right now?
are you using the built-in camera or doing it with scripting?
oh okok
so if you want to make a camera in script
one second
https://community.bistudio.com/wiki/Category:Command_Group:_Camera_Control check this list of functions you can use to affect the camera
do i just exc them in debug?
you can do that
or you can make a .sqf in your mission and run it from there; but for learning, the debug console works great
ive bin trying to do that one but it says cant find al folder with script even though its in my mission directory
you have the camera_work.sqf?
yes sir
is it in the same folder as mission.sqm
random [0,0.5,1]; gravitates towards 0.5. What to use/how to get random to gravitate towards 0? And maybe even actually get 0 now and then. Heh, would this work random [0.2,0,1]; ?
@blissful phoenix how ever it is saying script_camera not found
@forest ore https://gyazo.com/b53da10a582d097c3f23ab6cb59f930d?token=b8c2bca679c1b3c19290e3add91107fa this will help you with the random distributions
have you restarted the mission since adding the file to the mission folder
yeah several times
hmmm
im not sure
i'd have to see what you're doing
what are you putting into your debug console
@forest ore yeah that should work
_camera_shot= [cam1, cam2, target1, 13, 0.4, 0.5, false, 0, 0, 0 ,false] execVM "camera_work.sqf";
Technically, it is a rescaled Bates distribution with n = 4. The distribution is split in two at its midpoint and scaled linearly such that its maximum lies at the specified midpoint. @forest ore
so if you want a maximum probability at 0, put 0 as the midpoint and then whatever ranges you want
Thanks M242, gotta test extensively and see if there's some comprehensible results to be drawn.
Sneakyevil, I've seen the table for sure but haven't quite yet figured it out. In those examples there's no results for 0 but that's probably because there's no example for floor random [5, 0, 10]
yeah absolutely
you can just make an array in a while loop for like 10,000 runs and make your own probability distributions for testing
Anyone knows a way to add a fine adjustment to slider controls? For example, holding the ALT key modifies the step to 0.01 when the slider is dragged?
onKeyDown = "params ['_slider', '_key', '_shift', '_ctrl', '_alt']; if (_alt) then {_slider sliderSetSpeed [0.01,0.01]}";
onKeyUp = "params ['_slider', '_key', '_shift', '_ctrl', '_alt']; if (_alt) then {_slider sliderSetSpeed [1,1]}";
I tried that, but this does only influence the step size when clicking on the arrows.
sliderSetRange?
Maybe as a workaround. If I get the current position and limit the overall range to +-20 then the user has more space to and the increments become smaller. But that's quite some hack.
Another thing I noticed. Pressing the ALT key when a slider is focused seems to trigger the onSliderPosChanged event ?!?
I am lost...
_slider sliderSetPosition ((sliderPosition _slider) + 0.01 * _scroll);//Scroll very smoothly. Direction is given by _scroll (can be positiv or negativ)
_slider sliderSetSpeed [1,1];
``` I also tried to execute this code onMouseZChanged, but that does not trigger the onSliderPosChanged event.
Anyone got a basic towing script they wouldn't mind sharing? Would really help a guy out, looking for something simple using attachto and setdir
Im making a custom main menu and I want to spawn a function onload but it doesn't seem to work. has anyone tried this?
why do you need to even run a function in the main menu?
is there even anything to run it on there?
@cosmic lichen You have to use a on mouse move event and key down event
https://community.bistudio.com/wiki/User_Interface_Event_Handlers#onMouseMoving
And just modify the thing
I would just completely get rid of the normal slider
and script the entire thing out of EHs
Instead of changing the slider speed or stuff like that, just change the value by using the onmousemove event and keydown
_handle = this fireAtTarget [groundtarget1,"HellfireLauncher"];
will this make my apache force fire?
Well,
- fireAtTarget returns a boolean
- if
thisis the Apache, then maybe
another thing when i try my mission then go back to editor i cant move the camera around it just moves the x,z,y axis at bottom left....
if (!loopdone) then <<<< im getting undefined vairable on that line any one help?
most unhelpfull discord ever 😆
its not 24/7 helpdesk 😛
3 days ive been trying to get this camera script to work 😩
you may need to explain that again.
what are you trying to do, what does not work etc.
because if youre questions are spread over 3 days of chat, no one will scroll through them to understand what your issue is.
this is the script im trying to use
i follow him step by step
but when i try to exc in debug as he does it get a error line which refers to
if (!loopdone)
undefined vairable
well you dont seem to have the loopdone defined anywhere
also short description of what the script is supposed to do is better than a long video
and by looking at your script you dont have the loopdone variable defined anywhere
@peak plover Thanks, gonna try that!
params 😃
can any one help with the script ive just posted im getting erorr on line 17 for undefined variable
_firstshot = [cam1, cam2, target1, 9, 0.3, 0.1, false, 0, 0, 0,FALSE] execVM "AL_intro\camera_work.sqf";
that is what ive got in my debug exc
well, the error is self explaining
not when this is your first time scripting lol
this is my 3rd day trying to do this 😩
!loopDone is not defined anywhere
i though it was in that one
line 39
thats the intro.sqf. the other one is camera_work.sqf
there both in my mission folder
Open the debug console and put loopdone in one of the watch fields
That way you can see the value.
just type in loopdone?
jupp
nothing happens just same error code
set loopdone = true; in the debug console and try again.
ahhh ive get some where now im getting script camera_work.sqf not found
i removed al_intro out the line in the debug because id removed the scrips from the folder
_firstshot = [cam1, cam2, target1, 9, 0.3, 0.1, false, 0, 0, 0,FALSE] execVM ">>>>AL_intro<<<<camera_work.sqf"; i removed that and now no error line just script camera_work.sqf not found
well where is the camera_work.sqf?
in the mission directory
seems like its not if it cant find it
is it directly in the mission directory?
did you restart the mission?
yeah several times
why dont you have the AL_intro folder and all the scripts in it?
removed them from there to see if it would make a difference as it didnt work with them in the folder
you sure thats the right mission folder?
yes sir i saved it then checked the date modified to be sure
idk. if its supposed to work with the files provided then you have probably missed a step in the tutorial
Is there a function that displays an image full screen?
for the undefined variable
how would i install the script of steam workshop as that script got updated recently ?
could be script on armaholic is outdated maybe?
possibly
where did you have this?
@burnt torrent
because if this does not run
then the loopdone never gets defined
this part is what you are trying to run from the console right?
because to me it looks like your are not using the scirpts as they should be used
yes that is the part im trying to run mate
the bit youve pointed at with the arrow is the bit im putting in the debug
horrible goat i could kiss you mate!!!!!!!!!!!!!!
_ammo = getArtilleryAmmo [gun1] select 0;
_tgt = getMarkerPos "target1";
gun1 doArtilleryFire[_tgt,_ammo,10];
sleep 2;
_ammo = getArtilleryAmmo [gun1] select 0;
_tgt = getMarkerPos "target1";
gun1 doArtilleryFire[_tgt,_ammo,10];
nearly there guys now im trying to get 2 scorchers to fire but 2 seconds apart so it don't look fake but that sleep code is chuckig up a error im putting this into the trigger information the artillery works if i remove the sleep 2;
So here's an interesting one - I'm looking to run an Ace Combat inspired mission, based around Stonehenge Defensive from AC7
What I really need is a script to have a visible "beam" fire when the countdown is complete
Any thoughts?
(for those that have played the game, I'm going to have the players be one of the "menhir" defensive positions defending against the incoming Eruseans)
[_priceCheck] remoteExecCall ["narMoney_fnc_moneySavePMC", 2];
Yet it throws me a "generic error in expression" but i wrote it, no matter if remoteExec or remoteExecCall, exactly as it is stated in here: https://community.bistudio.com/wiki/remoteExec
_priceCheck contains a number.
Do DayZ scripting commands have 10 position formats used among all functions too, or is it finally unified?
i mean ASL/AGL/ALGS/ALSW/ALTWTF and so on xD
They all serve different purposes
sure, still makes no sense to have drawLine3D use AGL, and lineIntersects to use ASL :/
I would expect commands not involved with creating objects just use some unified world coordinates TBH
That could make things easier for sure.
maybe while we are on it, if I am writing functions like 'find safe position on road', 'check if position is safe', and so on - which format do I use?
I hate to think about converting this sh*t before calling any of my algorithms, I would like to have a unified coordinate system
for my scripts I mean
My Problem is solved. I was looking into the wrong script. Could solve the issue.
is there any way to lock the game to first person, apart from when in vehicles?
@broken forge I dont know vanilla settings beside the difficulty settings which i would suggest to look into. But when you use ace you have such a setting within the ace-addon settings for missions/server and client.
okay, thankyou
@broken forge did you want to allow using 3rd person view in vehicle, but not on foot? Without additional mods)
yes @lost copper
@broken forge try this:
- Enable 3-rd person view in server config.
- Code in init.sqf:
if hasInterface then {
execVM "disable3rd.sqf"
};
- Create file disable3rd.sqf:
waituntil {!(IsNull (findDisplay 46))};
player addEventHandler ["GetOutMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
if (cameraOn == _unit && cameraView == "EXTERNAL") then {
_unit switchCamera "INTERNAL";
[] spawn {
hint "3rd view enabled in vehicles only!";
sleep 3;
hint "";
};
};
}];
(findDisplay 46) displayAddEventHandler ["KeyDown", {
params ["_displayorcontrol", "_key", "_shift", "_ctrl", "_alt"];
if (isNull objectParent player) then {
if (_key in actionKeys "curatorPersonView") then {
[] spawn {
hint "3rd view enabled in vehicles only!";
sleep 3;
hint "";
};
true
};
};
}];
- The work in done, check it on server.
nope. just that. the server is running on warlords in multiplayer with zeus and the following mods:
CBA_A3
Achilles
Radio Anim for TFR
TFR
RHSAFRF
@lost copper
maybe some of those would mess with it
Test this script on vanilla, that works on them.
@broken forge any errors?
So it works?
nope, the script doesn't do anything to my game as far as i can tell
that is strange, cause it works in my test mission.
may be me not understanding something and o know it seems simple sqf "nuke" remoteExec ["playsound",-2,true];will play a sound foe every unit on the server,i just need it to play local per player (but the script is server side).wheres my fault?
as in "every player can hear the sound as much times as there are players on the server" iand i dont like that^^
@sturdy cape-2 means "everywhere but the server (and actually, a server can be a player)
Also, maybe not set the JIP param to true
According to what you say, it seems that this script may run on every client too
And if that is the case, just use "playSound" here
well its executed on the server for sure.i just ended up placing the playsound in a client side file and will check.it was just there to have the absolute timing of the event the script is
thanks
dunnow if i already asked this. If i use the init-field of a unit to give that unit a specific eventhandler, and the player, choosing this unit, respawns, will the event handler be active on that unit again?
My understanding says "Nope, because the object after respawn is a new object" am i right?
@echo yew did you mean that:
https://community.bistudio.com/wiki/Arma_3_CfgMarkerColors
Guys'. How can I find out the color of the pixel under the mouse cursor?
you can't
Pretty sure -2 stops it executed on the server, if it does then you have some other execution in addition somewhere @sturdy cape
eh, i disabled "disable negative rating" but i dont get a negative rating. I am independend, switch via zeus to blufor and started to kill blufor enemies - rating stays at 0. Did i forget to turn something off script-wise?
So far i figured out that, if you switch side, you cant get a negative rating since you're considered still "original side" which, in my case, is greenFor...
Somebody can show me how to increase size of a map marker gradually?
@winter rose thanks can u tell me how to increase a-axis, b-axis value gradually?
depends, what do you want to do?
You may want to look at while-do for example, or for
i want to increase gradually size of the marker just for like 3/4 secondes
an area marker?
yes
"analogically" or by steps, etc
private _marker = "myMarkerName";
private _size = markerSize _marker;
private _wantedSize = [_size # 0 * 2, _size # 1 * 2];
private _duration = 4; // seconds
private _step = 0.1;
for "_i" from 0 to _duration step _step do
{
// something
};```
wow thanks
and in the something, well something like this:
private _w = _size#0 + (_i/_duration) * (_wantedSize # 0 - _size # 0);
private _h = _size#1 + (_i/_duration) * (_wantedSize # 1 - _size # 1);
_marker setMarkerSize [_w, _h];
sleep _step;```
Sorry, coding from my phone ^^
Not my best code, but I am going to sleep so others may optimise this :-] @tough abyss
thanks, i did not know how to write it, but now i think it's fine.
stupid question I'm sure, but is it necessary to declare that as private @winter rose ? Isn't the variable already private when prefixed with the underscore?
no
it's local, not private. completely different things.
local variables only exist for the current script and any scopes within (so functions you call or anything with curly braces).
that is unlike global variables, which exist for all scripts.
private variables don't influence outer scopes. going to copy what i wrote a couple days ago
private _x = 1;
call {
_x = 2
};
hint str _x; // 2
call {
_x = 2
};
hint str _x; // error
private _x = 1;
call {
private _x = 2
};
hint str _x; // 1
Hey bois trying to find that animation trace script, probably going to be an AnimDone EH, anyone know what I am talking about? Cheers
hey guys im having a problem when trying to get my current weapon magazine ammo, im using this code ((currentMagazineDetail player) splitString "(/)") select 1 when i put it in the debug console i do get the amount, but when i use it in a function it doesn't work, i get this error : Error Zero divisor. which i know happens when you try to select element that is not available in the array. but in my case the element is available.
also i get this Error in expression <litString "(/)";
select 1 if splitString doesn't return array with 2 elements or more, that will error
"but in my case the element is available" made double sure?
Maybe it's something before/after your code
this is the return for that ((currentMagazineDetail player) splitString "(/)") - ["5.7 mm 50Rnd ADR-97 Mag","50","50","[id","cr:10000032","0]"]
so if i select 1 i get "50"
nvm i figured it up
thank you anyways..
Are there commands to retrieve the acceleration of vehicle? I guess not
Or more importantly, commands to set acceleration of vehicle
velocity yes, acceleration no
_v1 = velocity _veh
sleep 1;
_acc = _velocity _veh vectorDiff _v1
^ Doesn't actually work. Its stupid code that will return wrong results.
But something like that
Unfortunately retrieving acceleration from velocity is not enough for me, I would have needed the real acceleration
As I'd have used the acceleration in giving speed boost to tanks, which doesn't work on velocity based acceleration (it ends up tanks flying in air lol)
If you dress it up in the scheduled environment and run it on each vehicle in a loop and cache the result as a local parameter you could retrieve it and it wouldn't be that bad.
Faster sample times will give you closer to the real acceleration and by the time you are running every frame it is going to be as accurate as the game is calculating it too
"As I'd have used the acceleration in giving speed boost to tanks, which doesn't work on velocity based acceleration (it ends up tanks flying in air lol)" I do that too.
I have a multiply by 2 button.
Works fine, if you don't press too often thinking it has no effect..... oops
Faster sample times will give you closer to the real acceleration and by the time you are running every frame it is going to be as accurate as the game is calculating it too
``` I ran it every frame and got flying tanks 😄 I guess the problem is when you want to change direction, the "last known velocity" doesn't take it into account
well yeah constantly accelerating every frame is probably bad idea 😄
^ combine that with ace g forces
@still forum The script had speed limit though, the problem was that eg. when you climbed over an hill, the tank kept rolling "uphill" if you kept your forward key pressed down lol
A community in Arma 2 gave tanks a speed boost at low speeds, it's really useful feature in Benny's Warfare - the fights are much more dynamic and interesting
But you can't use the same script in Arma 3 since the FOV is dependent on vehicle speed, so the camera jerks all the time when the speed limit of the script kicks in
just interpolate the changes over a couple of frames and don't add velocity immediately
@peak plover Could try that out, thanks for tip
Guys. How to remove 1 clip from the container?
"the container" ?
"clip" ?
yes, container
Which BI function is called by the Zeus module named Skip time? I want to use the "x hours later" display players get.
BIS_fnc_setDate
hmm, i was looking at any function starting with "moduleX"
well it's in fn_moduleSkiptime.sqf
it is?
Yeah it is in there, must have missed it
not helping dude :u
does not have the functionality i was after
i am well aware of both commands, but I wanted the transition effect
Yes setDate has the UI stuff
neat, makes things easier
@fleet hazel Take a peek at the biki for clearItemCargoGlobal, addItemCargoGlobal, and getItemCargo. Unless Dedmen has sprinkled some magic around there's no way to remove a single magazine from cargo; you have to cache the inventory, delete it all, and re-add everything less whatever you want to remove.
Might be magazineCargo; been a while since I played with those and don't remember if magazineCargo returns removable mags or the turret's mags
@ruby breach I have a container
it does
unless you don't actually have a container
But it seems like you don't actually want to give any details
so can't help you any further I guess
Using attachTo on a vehicle seems to artificially change the boundary box and cause erratic behaviour for vehicles above it. I'm attaching the vehicle to a HeliHEmpty, so I wouldn't expect this to happen. Anyone got any experience of how I might go about fixing this, without using disableCollisionWith 👀
whats helihempty?
It's an invisible landing pad object, but I think I may have solved it by disabling simulation on the parent, or moving it away from the attached object. Not even sure, but not tested in an MP environment so who knows 🤷
why are you attaching a vehicle to the landing pad? 🤔
It's because the wreck is acting like michael j fox otherwise.
Attaching it seems to be the only way for it to behave.
Hey. Problem. When the player gets into the car, his animation in the car breaks down.
Is it somehow possible to change the selected briefing tab when the mission is loaded?
Like with processDiaryLink but that doesn't really seem to work in the briefing screen.
Can anyone help me script for a server? I am willing to pay
@everyone If you can script please help I am in need of support willing to pay
🤔
Willing to pay with what exactly?
Hey all - Is there a way to get the curator cost a unit, given its class?
I'm trying to make an AI wrapper around the zeus interface
Doesn't seem possible to make calls to the zeus interface directly, so I'm trying to at least emulate it
Failing that, can someone help me with function scopes?
private _homeSector = _this select 0;
private _testFunction = {
hint str _homeSector; //undefined variable
};
Why does that not work
because... That's just how it is
variables are passed when code is executed, not when it's defined
So I can't access variables outside of that function?
Only if they exist where the function is called
Like
private _homeSector = _this select 0;
private _testFunction = {
hint str _homeSector;
};
call _testFunction; //Works
You must pass variables to functions when you call them, if you are familiar with that concept 🤔
That doesn't work
That does work
Then you are doing something else wrong
_homeSector = _this select 1;
_taskCaptureInitial = {
_sector = [_homeSector] call _nearestUnclaimedSector;
_vehicle = ["B_MRAP_01_F", position _homeSector] call _spawnUnit;
_vehicle addWaypoint position _sector;
};
[] spawn _taskCaptureInitial;
Is my exact code
spawn is not executing the code right there
It's doing it in a scheduler
It creates a new script that runs later
Can I omit the [] when doing a call?
How about with execVM and spawn?
they both launch the code sometime later
not right now and right here like call does
they create a new script instance.
Variables carry over from higher to lower scopes.
but spawn creates a new script, with no parent scopes that could have any variables
If you want parameters in spawn/execVM then you need to pass them manually
Got it
Same for anything else which doesn't execute "right now, right here"
like addAction or eventhandlers of any kind
yes
there is a limit to recursion depth though.. like after a couple hundred levels deep you'll get problems
I'm only going 1 layer deep
are you sure that you are passing your parameters through params?
when you make a call
should be stuff call code, not _stuff call {_sfuff = _stuff - 1; call code};
_driver = [_driverUnit, _pos] call _spawnUnit;
Type object expected code
So what now
one of your variables that should be code is an object
There is nothing anyone can read out of that generic line of code
I haven't set any expected types on that function
I assume the "expected code" spans from the call command right?
Might be, might be inside the function, might be in the lines above or below the line you sent
The error was that line
maybe _spawnUnit is a object then
Yea, that's what I thought. But I know it's a function, which made me think the fact its called recursively might not be working as intended
if you show your actual code people might be able to tell you what you are doing wrong
Sure
_spawnUnit = {
_unit = _this select 0;
_pos = _this select 1;
_points = curatorPoints _curator;
if([_unit] call _getUnitCost > _points) exitWith {
false
};
_group = createGroup (_curatorSide);
_spawnUnit = _group createUnit [_unit, _pos findEmptyPosition [0, 20, _unit], [], 0, "NONE"];
_curator addCuratorEditableObjects [[_spawnUnit], false];
if(_spawnUnit emptyPositions "driver" == 0) then {
_driver = [_driverUnit, _pos] call _spawnUnit;
_driver moveInDriver _spawnUnit;
};
if(_spawnUnit emptyPositions "gunner" == 0) then {
_gunner = [_driverUnit, _pos] call _spawnUnit;
_gunner moveInGunner _spawnUnit;
};
_spawnUnit;
};
_spawnUnit = _group createUnit
🤔
You used private before, why do you stop now
Rubber duck
That is a prime example of using private
and btw replace your _this select's with params
although private won't help much either here
is equivalent to what you have PLUS private
actually _pos not _points
If cost is too high, you exit with false.
but your other code in _driver and _gunner expects to always get back a unit, that will error
Yea good spot, I'll just add a check
How do I declare a variable to use it later?
Something like
_unitGroup;
if(isNil "_group") then {
_unitGroup = createGroup (_curatorSide);
} else {
_unitGroup = _group;
};
_unitGroup throws an error saying its not defined
_unitGroup = X;
👍
Okay, I think one final question, The script I'm calling creates the unit I want it to, but it dissapears instantly
i want a trigger to execute once a player picks up an item (uniform in specific). how do i go about this?
I'm having an issue where my script works as intended locally, but when I test on a dedicated server, portions of it will execute on mission start. ```if (!isServer) exitWith {};
//definitions
mapmarker = [
"m_2",
"m_5"
];
publicVariable "p2";
justplayers = allplayers - entities "HeadlessClient_F";
playerCount = count justplayers;
accounted = {_x inArea "MS"} count justplayers;
//run check to see if players are in area "MS"
while {playerCount != accounted} do {
justplayers = allplayers - entities "HeadlessClient_F";
sleep 5;
accounted = {_x inArea "MS"} count justplayers;
};
//incoming message from HQ
[[west, "HQ"],"Glad you all made it. Rest up, we'll get you some additional support."] remoteExec ["sideChat",2];
sleep 1;
//blackscreen fadeout transition
[0, "BLACK", 2, 1]call BIS_fnc_fadeEffect;
sleep 2;
6 fadesound 0;
titleText ["10 Hours Later", "BLACK FADED", 1, false];
sleep 2;
//skip time 10 hours
skipTime 10;
//trigger condition = true
p2=true;
//blackscreen fadein transition
[1, "BLACK", 3, 1]call BIS_fnc_fadeEffect;
sleep 1;
6 fadesound 1;
//Mapmarkers revealed
{_x setmarkersize [1,1];} foreach mapmarker;
"m_2" setmarkertext "Laboratory";
"m_5" setmarkertext "Eagle's Aerie";
sidechat, and transitions were not executing (as intended), everything else was executing at mission start, with players outside the specified area. Any insight would be appreciated! Thanks.
What should I waitUntil in a script to be certain the entire mission is initialized
and ready to play
time > 0 ?
Can a switch return a value?
it can, it is not exactly recommended but yes
Ah ok
I guess a better solution would be use the config
How can I filter config for all units belonging to a certain side
I have an idea that I want to click on a map marker and receive an event about it getting the map marker I clicked on
How viable is it to achieve this by making controls and moving them when mouse moves in the map view? Will it lag by one frame?
damn that's cool, why did I discuver this thing so late and have to write all the mouse events myself 🤦 🤦 🤦
help me with what? I thought I can attach the more advanced event handlers to these 'control-markers'
I want mouse over events too and such things
uuuh
the in game map is just a map control
you can add event handlers to it just fine
Is there a way I can still simulate objects that are hidden?
so how do I implement and event that my mouse has entered an area of a marker?
I guess I need to poll the command you gave above
yeah
on the mouse move event of the map control
that's what i would do, too.
Is there an arma equivalent of Javascript || ?
To set default values
eg
_t = (call _test) || "default";
"defualt" will be set if its nil or null
for arma i believe || is "or" in a condition.
private _var = [_maybe] param [0, "default"];
regarding your earlier question:
What should I waitUntil in a script to be certain the entire mission is initialized
nothing at all. initPlayerLocal & initServer will run in postInit, all objects exist at that point, functions are compile etc. if you need for some other scripts to finish, you've got to be more specific.
hey does anyone know if there is a way to start terrain builder or object builder with a command line?
thanks!
Is there a way to animate a mesh (specifically stretch it) through SQF?
Specifically trying to achieve an effect like this (afterburner) https://gyazo.com/3f95685336392f696659e33796d0eea1
What is the best way to play a random death sound effect upon a unit's death?
<<THE UNIT YOU WANT TO SCREAM>> say3D [<<SOUND FILE>>, <<RANGE IN METERS>>];
//Example
_miller say3D ["superMillerLand", 10];
@zinc rapids It also says on the page you linked that your suggestion will not work as units has to be alive
New plan
Spawn an empty object near them (helipad invisible) and have that play the sound
@short vine yes. Scripted animation sources
ZephyrSouza is model maker tho, so I assume that's not gonna be a problem
That would be best achieved with just model.cfg animation and a tube which one end is animated to move.
Could be tied to speed animation source for example. @short vine
How to return players default colour choice for menus etc.?
cannot quite remember which one it was
but you can find the corresponding variable using allVariables profileNamespace
Ah cheers 😄
Can map markers receive color not in string form but in the array form, somehow?
[r,g,b,a]
You can just convert the array to string?
uhm ... setMarkerColor is not supporting non-defined (CfgMarkerColors) colors
I'm almost sure they don't, but do objects keep variable names while in player inventory?
Thats what I thought
That would make my life too easy 😃
i'll just need to grab the client that picks up said object, check if classname is in their inventory when they use an action, reset when they drop it.
CfgVehicles are objects, everything in your inventory is CfgWeapons
Weapons have no variables
backpacks are vehicles though
yes
but they are not in your inventory
They are a container that you put your inventory inside
wait, are vests and uniforms vehicles as well?
yes
I'm trying to make sense of how scoping and variable binding works in SQF just so I can relate the concepts to my existing programming experience, but:
- setVariable and getVariable operate against named namespaces - is the 'default' global namespace as applied to functions executed the "missionNamespace"? (ie: in mission scripts, could I access a global assigned directly
foo = 20;viamissionNamespace getVariable "foo")? If it's not the missionNamespace, is it an accessible namespace?
defaultNamespace (there is a command for it) is usually missionNamespace
ah, awesome.
yes you can access directly
the second question is to do with private scope and blocks and closures/bindings - namely - are private variables in blocks closures, or are they rebound in the caller's context?
I guess that's a bit more complicated to explain directly...
private "_foo"; _foo = 20;
[] spawn { player globalChat _foo };
Is _foo valid inside that block, and if so, does it resolve to the _foo outside, or would it be reevaluated to a new _foo in the context where it's spawed? (That's not the precise context I'm working in, but close enough)
private variables are bound to the callstack
I can see how to not get bitten by spawn for that since spawn permits argument passing, but in the context I'm trying to work out if a compile is necessary or not
right - so the context in which it's called.
You can access them from lower in the callstack, but not higher, and also not from different scripts
spawn launches a completely new script with new callstack, thus variables don't carry over
yup - I presume event handlers are similar
_foo in your above example is undefined
btw private "_foo"; _foo = 20; -> private _foo = 20;
scripts that get compiled hold absolutely 0 information about where they were compiled
yup - it's more that the immediate values are being resolved at the time of compile (they're compile + format combos), and the fact that variables are bound and resolved at call tells me why that's necessary. 😃 thanks!
[well, actually, block scoped even! it's all making sense anyway - just hard to get that direct answer from the wiki]
actually vest is not a vehicle. its an item that is drawn on the character vehicle via proxy
as in vest doesnt have cfgvehicles class
the container is a vehicle though
that it is
https://pastebin.com/WwC5iGK3 Any suggestions for performance improvments?
nearestLocations over the whole map? is there no command to just get all locations?
Not that I know of.
The script runs only once when eden loads a new map/scenario so that's not gonna be a big of a deal.
is it possible to make the pawnee 7.62 minigun use the same bullet on the cheetah anti aircraft tank?
you can remove the original weapon with scripts and add new weapon and new ammo
Will AI actually use those new weapons?
should yes
depends how some animations and fire effects are set up you might lose some of those
okay. Sounds nice. I always wanted to have an AI pawnee shoot HMG bullets at me
One small question about JIP and respawning.
If I disable AI in the slots that the players use, will JIPs use the respawn system so their unit is created?
If I disable respawning, would that cause the JIP player to not spawn at all and only play as a spectator?
@delicate lotus the Pawnee might shoot rockets from its hull then; if so, you can fix this with a fired EH to place the rockets properly
Scripting noob here, I was wondering if you guys could help me write a script that prints the weaponDirection of the Katyusha (lib_us6_bm13) from ifa3 to the bottom of the screen of the player, both azimuth and elevation
how would i script my helictoper to have its engines running but not take off?
@zealous jungle animationPhase Example 3, usually "MainTurret" is traverse, "MainGun" is elevation.
@burnt torrent engineOn
look them up here
https://community.bistudio.com/wiki/All_Arma_Commands_Pages
thank you ampersand most appreciated
And how would it be displayed on the hud every frame?
onEachFrame and hintSilent for prototyping. If you want it to look fancy, that's way more involved.
how to i get units to fast rope ive got a helicopter put the units in it set it a way point and made the waypoint fast rope (achiles mod one) it reaches the waypoint but they don't fast rope
I'm a bit confused now because I'm not so sure on how to use them, keep in mind that I haven't written a single code before so you'll have to go easy mode with me
Try to get onEachFrame Example 1 to work first.
@zealous jungle https://community.bistudio.com/wiki/weaponDirection
and the note in it too
ah, yeah. that's much easier for the primary turret.
Something like this? onEachFrame { hintSilent weaponDirection currentWeapon};
No
look at weaponDirection Example 1
I've looked at it but I don't understand it
It may be more clear to do _yourVehicle weaponDirection (currentWeapon _yourVehicle). currentWeapon _yourVehicle gets the weapon name as a string, and then weaponDirection gets the direction
In the debug console there are 5 Watch boxes. put your weaponDirection code in there to make it quicker to check
Where do I check it?
Returned 2
Did you say I should put _yourVehicle weaponDirection (currentWeapon _yourVehicle) into one of the watch boxes?
Or is there anything in that I need to alter?
I was mostly showing the execution order with the parentheses. _yourVehicle probably doesn't exist in your test mission, so change that to your mlrs vehicle
lib_us6_bm13 weaponDirection (currentWeapon lib_us6_bm13)?
try it. does it work?
Nope
is your mrls vehicle named lib_us6_bm13
Is it possible that https://community.bistudio.com/wiki/ctrlTextHeight does not properly work with <br> tags?
It seems like the height is uncorrectly returned when a linebreak is added.
Yeah that's the classname @young current
You need to give that particular vehicle a variable name and use the variable name.
You mean I should do something like _katyusha = obj lib_us6_bm13; in debug and _katyusha weaponDirection (currentWeapon _katyusha); in watch?
Set the variable name in the attributes of the vehicle in editor
Oh
I set it to "katyusha", still not working for me
Nvm changed a minor mistake in there
Shouldn't it return degrees?
Look at the return value of weaponDirection
a normalised vector iirc
Says [0.672274,0.713409,0.197725]
Should I use animationSourcePhase or animationPhase for degrees?
If you want degrees traverse and elevation you'll have to do vector math against the whole vehicle's vector direction (or a horizontal/vertical vector)
Alternatively you can go back to animationPhase and then convert the phase decimal number which is probably in radians to degrees.
You picked a real doozie for your first project =p
question
why isnt https://community.bistudio.com/wiki/weaponDirection used?
oh there it is
xD
it also has the math in the example
for degrees
hey guys, i've made a function to check how many available magazines the current player has in him inventory that he can use with his current weapon, it work for all of the weapons but not i tried it on MX SW with 100Round magazines and it returns me 0 : sqf if ((weaponState player select 0) isEqualto "") exitWith {""}; _weaponClass = weaponState player select 0; _availableMagsWeapon = getArray (configFile >> "CfgMagazineWells" >> (getArray (configFile >> "CfgWeapons" >> _weaponClass >> "MagazineWell") select 0) >> "BI_Magazines"); if (isNil "_availableMagsWeapon") exitWith {""}; _availableMags = 0; for "_i" from 0 to ((count _availableMagsWeapon) - 1) step 1 do { _toAdd = {_x == _availableMagsWeapon select _i } count (magazines player); _availableMags = _availableMags + _toAdd; if (_i == ((count _availableMagsWeapon) - 1)) exitWith {_availableMags}; };
when i run this code : sqf _weaponClass = weaponState player select 0; _availableMagsWeapon = getArray (configFile >> "CfgMagazineWells" >> (getArray (configFile >> "CfgWeapons" >> _weaponClass >> "MagazineWell") select 0) >> "BI_Magazines");
i only get this array["30Rnd_65x39_caseless_mag","30Rnd_65x39_caseless_khaki_mag","30Rnd_65x39_caseless_black_mag","30Rnd_65x39_caseless_mag_Tracer","30Rnd_65x39_caseless_khaki_mag_Tracer","30Rnd_65x39_caseless_black_mag_Tracer"] without the 100rnd magazines class names..
why is that?
What does bob mean?
Does vectorMultiply 100 make it degrees?
It's weird because straight north is 0, east is 90 and south is also 0
The other side is just the same but negative
Right, but weaponDirection is relative to world. To get traverse and elevation you'd have to do find the vector projection of _wepDir onto the vehicle normal plane, then do ϕ=arccos(a⋅b/ (|a||b|) ) for both a=_vicDir; b=_wepDirProj and then a=_wepDir; b=_wepDirProj
... I think
I want it to be relative to world
Oh ok, then much easier xD
For sure
Look at the note by HWM mainframe
(_array select 0) atan2 (_array select 1) substitute_array with the output from the weaponDirection code
_var1 = 0;
_var1++
now _var1 = 1;? Would that be correct?
How do I check _dir_degrees?
I so far have
onEachFrame { _array = katyusha weaponDirection (currentWeapon katyusha) vectorMultiply 100; _dir_degrees = (_array select 0) atan2 (_array select 1); }
you shouldn't need to vectorMultiply, and you should private _var = both those things, but otherwise looking good. Now add hintSilent str _dir_degrees;
Yeah I forgot to remove that part
onEachFrame { private _var _array = katyusha weaponDirection (currentWeapon katyusha); private _var _dir_degrees = (_array select 0) atan2 (_array select 1); }?
Wait I forgot the =
onEachFrame { private _var = _array = katyusha weaponDirection (currentWeapon katyusha); private _var = _dir_degrees = (_array select 0) atan2 (_array select 1); }
Idk what I'm doing anymore
just private _array = ...
Like this?
onEachFrame { private _array = katyusha weaponDirection (currentWeapon katyusha); private _var = (_array select 0) atan2 (_array select 1); }
Sure, the _variableName can be whatever
_var is a local variable
watch field cannot read random local variable that might be anywhere or nowhere
Right now your code is calculating it on each frame. It's not showing it yet, so add hintSilent str _var;
yeah, it sometimes happens 😄
That's only the azimuth though. Elevation is gonna be a little more complicated.
trying to make an addaction only useable within 2 meters, //Land Nav Course toLandNav addAction ["Move to Course", "scripts\teleports\returntostart.sqf", [],1,false,true,"","_this distance _target < 2"];
am I doing it vastly wrong? Its not working in editor
private _elevation = (_array select 2) atan2 ((_array select 0)^2+(_array select 1)^2);
Why all three coordinates for the elevation?
private _elevation = (_array select 2) atan2 ((_array select 0) ^ 2 + (_array select 1) ^ 2);
Please make it pretty and readable .. urgh
would make that even more readable
private _elevation = _array#2 atan2 (_array#0 ^ 2 + _array#1 ^ 2);
perfect
private _elevation = _array # 2 atan2 (_array # 0 ^ 2 + _array # 1 ^ 2);```*
looks like an accumulation of random characters
How do I hintSilent two variables like A, B?
thats why you use select
the # looks like you just puked all over the place and randomly hit the # button
i agree, !! would have been a much better choice.
i mean haskell uses it, so it's already perfect
urgh ... all ugly
[ and ]
where [ is an unary operator and ] is a nular one, just for the lulz
though ... no wait
i once actually had a working concept idea of that 🤔
Be grateful that it doesn't start array indices with 1
nah ... forget it ... mixing up stuff here right now
i would not have a problem starting with 1 ^^ yet it would confuse me since i am working with 0 as start already for some time
XD
Heresy is fun!!
Where do I save scripts to run later?
C:\
Yeah but what folder
…Windows
So I cant save it on the game files and then execute it?