#arma3_scripting
1 messages ยท Page 338 of 1
but if an array is not passed - i'd like to return false
so can i set the defaultvalue to false and the expected data type to [] ?
if(_inventory isEqualTo false) throw "Error: Invalid inventory specified";```
like this
Ohh nice, thanks found the control type, it's exactly what I was looking for
@Neviothr#0132 How about
// Because lineIntercets needs ASL
_aiPos pushBack (getTerrainHeightASL _aiPos + 0.1);
// Check if the player sees the position
_intersections = lineIntersectsSurfaces [eyePos player, _aiPos, player, objNull];
? Just a simple addition instead of a vectorAdd
@mortal halo Try it
default value type does not matter
ive converted a ghosthawk into a uav, but when a player controls driver/gunner his view camera pos is in the seat (since no human model?), any way to use a GetIn EH to change the crew camera pos?
does getIn even trigger when someone controls a uav?
you guys took too long to respond, so i had to ask the losers in #cfg, now i feel dirty and violated.
does getIn even trigger when someone controls a uav? no
Because you are not getting into anywhere
And his camera pos should be in the camera
@regal geyser Everything is wrong on there
you are getting the position of a marker.. but providing an array instead of a marker. and then you are trying to select a random element from that position (which only has 3 elements) using a completly outdated method
BIS_startingPos setMarkerPos ((BIS_spawn getMarkerPos) select (floor (random (count BIS_spawn))));
That is what you are doing
and yes.. an array is not a marker. so the error is completly correct
BIS_startingPos setMarkerPos (getMarkerPos (selectRandom BIS_spawn));
There is a correct version..
Oh. Yeah, I'm bad at this. I've been analyzing old BIS inits to try to figure this out
Also you were not actually calling getMarkerPos with BIS_spawn as argument.. you were trying to call BIS_spawn which is not a script command with getMarkerPos which is not an argument as argument
@still forum quote: And his camera pos should be in the camera
if you mean the view the the typical uav driver hud, that camera pos is fine
but when you switch views back to the internal cockpit view then your view is where your balls are
the argument goes to the right side. Check the Wiki
Thanks for the correct version.
@still forum that would probably work, and be more efficient.
I have been messing with this for way too long but I've been working off an old init and so my code is all convoluted and outdated because I've been learning from convoluted and outdated inits
so thank you so much
i can't believe it was that easy
Also I'm quite sure the error message didn't just tell you "error in expression".
RPT first lists the error. then location.. and under that it prints "error in expression"
RPT?
oh i didn't even look at a log file.
how do i check if my cursortarget is a TREE? isKindOf "tree"?
A tree cannot be the cursorTarget
how bout an intersect object?
Sure.
cursorObject
Returns the object under cursor. This command is quite different from cursorTarget as it is more precise in determining the boundaries of the pointed at object and can detect a larger variety of objects including map objects and trees.
so how do i find out if its a tree? can be vanilla and/or cup trees
Not sure if it works, if it doesn't just use https://community.bistudio.com/wiki/nearestTerrainObjects
nearestTerrainObjects [player, ["Tree","Bush"], 200];```
_object in nearestTerrainObjects [_object, ["TREE", "SMALL TREE"], 0]
gonna attach a rope to a tree the player is aiming at so gotta be accurate
I like this to check if a thing is a tree.
so all trees in tanoa churnarus altis whatever are all child class of "TREE"?
No, that's why this method is better.
They don't share a base class and this is one is more like a classification.
All trees share.
so "TREE" is like a config property? like isTree = 1?
Trees baked into the map arent "real" objects and dont necessarily have a config entry
so i can check it like this?
_beg = eyePos _myPlayer;
_end = (_beg vectorAdd (_myPlayer weaponDirection currentWeapon _myPlayer vectorMultiply 500));
_array = lineIntersectsSurfaces [_beg , _end, _myPlayer, objNull, true, 1, "GEOM","NONE"];
_targetObject = ((_array select 0) select 2);
if ( _object in nearestTerrainObjects [_object, ["TREE", "SMALL TREE"], 0] ) then
{
// yes its a tree now rope it
};
I think it was something in the model. But I can't remember for sure.
trees has which LODS? GEOM FIRE VIEW? which one to make sure intersect hits a tree?
trees and ropes, huh ๐
monkey business
cant wait to watch war for the planet of the apes!
so will turn arma into apetopia irst
A3 trees have VIEW, they all should have GEO and FIRE GEO at least in the trunk.
whats the best LOD args i should go for?
Chernarus trees don't have a VIEW geo by default iirc, which is why the AI can see through them in A2...
_array = lineIntersectsSurfaces [_beg , _end, _myPlayer, objNull, true, 1, "GEOM","NONE"];
_targetObject = ((_array select 0) select 2); could also return an empty array
how can you make intersect check all the LODS of an object?
You can only have two.
ill then just have to run intersect multiple times covering all LODs until the tree is hit
the higher up the player aims at the tree the less likely intersect will be reliable?
Anyone mind explaining all the LOD types (fire, view, geom, ifire and none)?
Hello, I have a small question about trigger activation. I want to make a convoy stop once a random guy is shot in the convoy, I am doing this by a trigger and setting the fuel 0 for all the cars. and i gave names to all the people in the convoy so i want that if any of these guys is shot the script will activate
so i want to do something like !alive en1 or !alive en2 or etc
shot as in hurt or shot as in dead?
Why don't you just do !alive en1 or !alive en2 ?
this addEventHandler ["killed", {
[car, 0] remoteExec ["setFuel"];
}];
?
the brackets shouldn't be needed I think.. but... oh well
Are you scraping for that 0.00000000000001 MS performance gain? :p @still forum
No.. There is no performance gain in brackets
Cries, we have to go faster! Ludicrous speed!
but !alive is easier to write than !(alive) when you are doing that a dozen times
What do you mean?!?
if (!(alive(enemy1))) then {
Does anyone know why selectplayer _name; doesn't work?
if (player distance cursortarget <50) then {
if (alive cursortarget) then {
_name = name player;
selectplayer cursortarget;
sleep 5;
selectplayer _name;
};
};
Yup, that would be sufficient to explain why it fails.
ok thanks
@little eagle, adding private to those variables as described did not fix my problem.
I am trying to run a script in a composition. It can't be run from a file.
I answered how to set the variables private scope. Didn't read the convo above.
Ah! Okay, thanks.
I need to run a script as part of an Eden composition and have it run when the composition is placed. Anyone know anything?
This is basically the script:
Sleep 1;
_G2 = [(getPos thisTrigger), INDEPENDENT, ["I_officer_F","I_soldier_UAV_F","I_Soldier_TL_F","I_Soldier_GL_F","I_Soldier_LAT_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G3 = [(getPos thisTrigger), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_soldier_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
{
{
_x execVM "Gear\FN_CentralGreen.sqf";
_x setBehaviour "SAFE";
} forEach units _x;
} forEach [_G1,_G2,_G3];
[_G1, getPos leader _G1, 3000] call BIS_fnc_taskPatrol;
Sleep 45;
_G2 copyWaypoints _G1;
Sleep 45;
_G3 copyWaypoints _G1;```
It appears @little eagle has a solution.
what is the problem. Why doesn't it just work?
It won't use a local variable, but if I use global variables, then the scripts will be stepping all over themselves.
Eden complains about local variables, because this game is retarded.
GG Bohemia
It seemed to accept it.
Now I just have to figure out a decent activation method.
@little eagle, can you not use sleep commands inside calls?
You can use sleep inside calls.
Hmm...
But you can only use sleep or any other suspension command inside the scheduled environment.
Since it complains, you're probably operating in the unscheduled environment.
I'm running it from an editor placed trigger, if that helps.
To enter the scheduled environment, you have to use spawn (or execVM).
Interesting. It never complained when I was using this script as an sqf. Are sqf files treated differently in that way?
Thanks so much for how much help you give me all the time, by the way. You're always teaching me stuff on here.
No, it depends entirely of the environment you're operating in.
Unfortunately, I'm pretty sure I'm not retaining enough.
init.sqf runs in scheduled environment.
Every eventhandler in unscheduled.
You can use
canSuspend
to debug the current environment.
Could I wrap my script in spawn {SCRIPT};?
Sure, but keep in mind that spawn has a fixed return value (a SCRIPT type for this command), so you have to use an assignment with a throwaway variable, OR wrap it all into an additional call.
Otherwise the Editor complains again, because this game is retarded.
AH! interesting. So I could do call{spawn{SCRIPT};}; or something of that nature?
I thought it was an OR type scenario between call and spawn.
Yes, except that spawn is a binary command that needs an argument on the left side too.
Even if it's just an empty array or 0 as throwaway value.
is it possible to disable lobby slots based on conditions? no idea when the slots are established or if it's possible at all. deleteVehicle from the init line is happenign to late it seems
0 spawn {};?
Yup, DEL
@polar folio, I know for a fact that you can disable lobby slots, but my way would be hacky.
@polar folio Since the lobby is created before any script of the mission is run, I'd say no.
@little eagle, you can kill the unit.
But how do you kill the unit before the first mission script ran?
Also what if it's a mission with respawn? Delete the unit?
oh dude. i have zero issue with hacks if they do the job ๐
Sounds like he does need it too early for my solution.
ah k
If you need it before players can join the lobby, then I can't help you, haha.
yer ideally it would atleast feel clean on the clients side. kinda want to avoid screen messages a la "you chose the wrong slot pls go back to lobby"
@polar folio, actually, I do have a solution for you, MAYBE.
Script your own lobby :S
i guess i could do it the dayz mod way with a shitload of civ slots and then move them into groups
yer kinda like that. but then how do i avoid people having to fully join to find out that player limit is reached
If you want like a certain ratio of players to be certain things or something, you could use the skiplobby command, then just place down the units in your mission in the exact order you want those slots occupied.
?
Place them all ungrouped and enable dynamic groups for a little more flexibility.
Isn't there also a forced auto balance or am I thinking of enemy territory again?
mostly aiming for it to be clean for someone who joins. i can come up with ways to do it after the lobby but ideally i would like to have someone know they can't participate before they join
@little eagle, will I be able to use 0 spawn in multiple scripts or will I have to start using 1, 2, etc.?
did someone successfully hack the lobby dialog? i guess i could add a message there and disable the join button, if max players are in
It's just a throwaway argument. _this becomes 0 inside your spawn-block.
The game has as many zeroes as you want.
Ah, gotcha.
That's good. Now my problem is this. Wait one.
Error in expression <call {
0 spawn {
_G1 = [(getPos thisTrigger), INDEPENDENT, ["I_Soldier_S>
10:07:22 Error position: <thisTrigger), INDEPENDENT, ["I_Soldier_S>
10:07:22 Error Undefined variable in expression: thistrigger```
Yeah, thisTrigger is a special variable in that it's only defined in the triggers script instance.
Now it's not working at all and complaining about that. Before it was complaining about and skipping sleeps, but it worked otherwise.
Haha, Arma, always something.
When you start a scheduled script with spawn, thisTrigger is no longer defined.
FUDGE. Any way to define that one internally? Holy cow, haha.
It's the ideal candidate to pass as argument instead of the zero.
Yeah?
call {
thisTrigger spawn {
_G1 = [(getPos thisTrigger), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_Soldier_M_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G2 = [(getPos thisTrigger), INDEPENDENT, ["I_officer_F","I_soldier_UAV_F","I_Soldier_TL_F","I_Soldier_GL_F","I_Soldier_LAT_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G3 = [(getPos thisTrigger), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_soldier_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
{
{
_x execVM "Gear\FN_CentralGreen.sqf";
_x setBehaviour "SAFE";
} forEach units _x;
} forEach [_G1,_G2,_G3];
[_G1, getPos leader _G1, 3000] call BIS_fnc_taskPatrol;
Sleep 45;
_G2 copyWaypoints _G1;
Sleep 45;
_G3 copyWaypoints _G1;
};
};```
Yeah, except that thisTrigger is still undefined.
The passed argument is inside the _this variable.
call {
thisTrigger spawn {
_G1 = [(getPos _this), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_Soldier_M_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G2 = [(getPos _this), INDEPENDENT, ["I_officer_F","I_soldier_UAV_F","I_Soldier_TL_F","I_Soldier_GL_F","I_Soldier_LAT_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G3 = [(getPos _this), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_soldier_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
{
{
_x execVM "Gear\FN_CentralGreen.sqf";
_x setBehaviour "SAFE";
} forEach units _x;
} forEach [_G1,_G2,_G3];
[_G1, getPos leader _G1, 3000] call BIS_fnc_taskPatrol;
Sleep 45;
_G2 copyWaypoints _G1;
Sleep 45;
_G3 copyWaypoints _G1;
};
};```
The first line is superfluous.
And is missing a ;
[1,2,3] spawn {
_this // [1,2,3]
};
[4,5,6] call {
_this // [4,5,6]
};
lgtm now
@little eagle, my script as posted above is working perfectly thanks to you!
What is this that you've posted most recently? A more efficient way of doing something?
It explains how passing variables works.
You write something on the left of spawn or call and its value becomes the value of the _this variable inside the CODE-block.
AH! Okay, sounds good!
Now that it's working, I need to work on some randomization and the like.
Imo, you should tweak it a bit.
// init.sqf
MyTag_fnc_spawnGroups = {
...
};
// trigger box
call MyTag_fnc_spawnGroups;
That way you can edit these functions with a text editor and don't have to use the ingame boxes.
I edit it in NotePad++ then past it into trigger boxes at present.
Well that way you don't need to change anything in the trigger and could use multiple of them with the same function.
That's a solid copy. Sounds good.
_x setFormation [(selectRandom ["COLUMN","STAG COLUMN","WEDGE","LINE","FILE","DIAMOND"])];```
Arma is saying this needs to be a string. How do I make it a string?
Why does 3den complain about local variables?
@shadow sapphire remove the outer []
@tough abyss, according to @little eagle and some other skilled scripter people, "It's retarded."
currently is ["STRING"] where you need "STRING"
@indigo snow, that was my first instinct. I should have at least tried it before I came crying to deddy.
@tough abyss There is literally no reason.
X39 will probably tell you otherwise.
And that is when you know that there actually is no reason.
Hmmm. Why isn't there an AI behavior somewhere between SAFE and AWARE. I want them to be relaxed, but not completely dicking off. Like, instead of rifles at high ready, rifles at rest, but like, in formation and shit, ya know?
Anyone know of a solution? Maybe some kind of force formation command with the SAFE behavior?
@little eagle maybe it's a bug?
Maybe it's a feature.
Perhaps.
Bugs < Features
Does this work to delete the trigger from which the script is running?
call {
thisTrigger spawn {
_G1 = [(getPos _this), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_Soldier_M_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G2 = [(getPos _this), INDEPENDENT, ["I_officer_F","I_soldier_UAV_F","I_Soldier_TL_F","I_Soldier_GL_F","I_Soldier_LAT_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G3 = [(getPos _this), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_soldier_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
{
{
_x execVM "Gear\FN_CentralGreen.sqf";
_x setFormation (selectRandom ["COLUMN","STAG COLUMN","WEDGE","LINE","FILE","DIAMOND"]);
} forEach units _x;
} forEach [_G1,_G2,_G3];
[_G1, getPos leader _G1, 3000] call BIS_fnc_taskPatrol;
Sleep 45;
_G2 copyWaypoints _G1;
Sleep 45;
_G3 copyWaypoints _G1;
Sleep 1;
Delete _this
};
};```
as you can see from syntaxHighlighting... no..
Delete doesn't exist
deleteVehicle might do the job
Ah! Okay.
call {
thisTrigger spawn {
_G1 = [(getPos _this), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_Soldier_M_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G2 = [(getPos _this), INDEPENDENT, ["I_officer_F","I_soldier_UAV_F","I_Soldier_TL_F","I_Soldier_GL_F","I_Soldier_LAT_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
_G3 = [(getPos _this), INDEPENDENT, ["I_Soldier_SL_F","I_Soldier_GL_F","I_soldier_F","I_Soldier_AR_F"],[],[],[],[],[],180] call BIS_fnc_spawnGroup;
Sleep 1;
{
{
_x execVM "Gear\FN_CentralGreen.sqf";
_x setBehaviour "SAFE";
_x setFormation (selectRandom ["COLUMN","STAG COLUMN","WEDGE","LINE","FILE","DIAMOND"]);
} forEach units _x;
} forEach [_G1,_G2,_G3];
[_G1, getPos leader _G1, 3000] call BIS_fnc_taskPatrol;
Sleep 45;
_G2 copyWaypoints _G1;
Sleep 45;
_G3 copyWaypoints _G1;
Sleep 1;
deleteVehicle _this
};
};```
what was the solution for line numbers being weird when #includeing files again? ๐
#LINE 1
Unpacked Folder -> use server profile -> restart server to see changes
@little eagle adding #LINE 1 completely breaks the PBO
aww
actually, it could be armake ยฏ_(ใ)_/ยฏ
Is there something I could stick in the init of an autoturret to change the side it is on?
group it to a different side unit with a spawn probability of 0%
autoturret? like the autonomous hmg gmg? then deletecrew replace with uav_crew class of desired side?
@little eagle Preprocessor failed with error - Invalid file name(empty filename) is the error in case you're interested in what it did
So, I know about the grouping trick, I was hoping there was a slightly more sophisticated way to do it.
I'm trying to get a Praetorian 1C anti-air turret to be on independent side.
I believe they work just like the autonomous GMG and HMG turrets, yes.
delete the crew and put an ai from the needed side inside?
@halcyon crypt #LINE macro needs filepath
SO MY SUGGESTION WORKED BUT WE IGNORED CUZ IM STILL A LITTLE SHIT?
@little eagle, this is what I know needs to be done, but until you phrased it that way, I didn't realize it was that simple.
#LINE 1 file\file\file.sqf
maybe path in quotes
I'll place an empty one and then search Eden for AI units.
yes you can enter anything in there
I'll give that a try in a bit, it's not a real solution though ^^
You can make arma tell you "error in file hubbabubba"
I like to (try to) phrase things simplistically, because I am a simple mind.
That won't help you if you put it into the included file though
@little eagle, I can't find an AI type unit to place there. Do I need to place it like game logic or whatever?
as Arma add's another #LINE after it goes back to the file that is including
If they had some kind of presence in Eden then I'd just drag the appropriate AI from an existing autoturret, but they aren't clickable.
Ah! Very nice.
i got a point from an intersectsurf, i want it to continue for 2 more meters from returned point. (say if a wall was hit, i want another point just 2 meters continuing along the same vector)
_beg = eyePos player;
_end = (_beg vectorAdd (player weaponDirection currentWeapon player vectorMultiply 100));
_array = lineIntersectsSurfaces [_beg , _end, player, objNull, true, 1, "GEOM","NONE"];
_targetPoint = ((_array select 0) select 0);
_newPoint = (_targetPoint vectorAdd ( _targetPoint vectorMultiply 2));
_targetPoint vectorAdd ( _targetPoint vectorMultiply 2)
Isn't this just a fancy way of writing:
_targetPoint vectorMultiply 3
?
@little eagle, haha, I figured that's what you meant, but I don't know how I'd have said AI created, let alone occupy the turret.
If you've got better things to do than help me at the moment, I will just group the turret to the appropriate side.
@still forum @little eagle adding a path to the #LINE 1 thingy with or without quotes results in the same error ๐
ok so i can do vectormultiply 1.5 to add just 0.5 meters to my vector?
Anyone know of a script that does a better job imitating off duty behavior than the damn DISMISSED waypoint?
@lusty canyon Yes, that is how multiplication works^^.
1 x 1.5 = 1.5
yes im being stupid but the amount of vecAdd / vecMulti translates to how many game meters?
vecAdd 1 = 1 game meter?
vecadd takes 2 vectors
vectorMagnitude _vector; will tell you how many metres long it is
vectorAdd is just a plus sign for vectors in SQF
It's like asking "how many numbers does "+" add?"
@halcyon crypt DIAG_log a preprocessed script and look at how the line command works yourself
@digital pulsar great thats what i was actually looking for
@still forum there's a ton of whitespace after the "normal" #line 1 cutting out at the diag_log char limit before showing anything else
I guess something is off somewhere
put the function in debug console watch and copy the source out of there
you'll get the whole code
can't copy.. ๐ฆ
working through steam in home streaming
(because BI refuses to update the port ๐ )
You can, click line, press "home", hold "shift" and press "end".
Hey, how would one place a group randomly within a certain radius of its editor placed position?
If I change the spawn radius of the group, it does nothing.
If I change the spawn radius of the group leader, then the rest of the group has to run to him at mission start.
@little eagle I know, the steam streaming thingy doesn't support clipboard stuff
Aww
exactly
I blame Microsoft.
this is what I have to work with
and yes, the text in game actually looks like that, it's not compression ๐
in home streaming to a mac? nvr tried it before is the performance good?
to Linux and it works
my laptop is too underpowered to do anything above 800x600 though
actually playable? 60fps?
input is spot on but without a proper GPU I can't tell you how it plays but it should be fine
how about voice input steam send it back to the game?
@shadow sapphire loop through each of the group leader's group members and put them next to him on mission load maybe
im in a similar situation, using slashtop to a shitty laptop but it doesnt stream back the remote mic input so i can only use teamspeak on the other machine
Can anyone help me with my MP mission i use the liberation mission and i want to add custom ammo boxes into the game that they can buy from the Fob menu.
@lusty canyon give it a try I guess, if your host has a decent GPU it will probably work fine at 60fps
i would need steam on both ends right?
@worthy zealot someone here would need intimate knowledge about that liberation mod considering you want player to buy from its UI? if its only just creating a new ammo box and placing it in the world then that should be easy you just need the classnames of items to put in
yep
Yeh i know how to place in editor and i also know how to add/remove boxes from the buy menu. What i am stuck with is making a custom box and then adding a custom box to the liberation files
so i guess what i am asking is how would i get the box from arma editor that i made from there and into the libeartion mission
@worthy zealot sorry i dont know anything about liberation. if you have access to the cfgs then i guess you can inherit an existing crate class then go from there
they have an array of crates they allow (default arma crates )
// Classnames of ACE3 crates (which have to be in the unit preset as well).
KP_liberation_ace_crates = [
"ACE_Box_82mm_Mo_HE",
"ACE_Box_82mm_Mo_Smoke",
However if i make a custom crate with all various contents i don't know where i would add it
support_vehicles = [
["ACE_medicalSupplyCrate_advanced",50,0,0],
["ACE_Box_82mm_Mo_HE",50,40,0],
["ACE_Box_82mm_Mo_Smoke",50,10,0],
And that's the buy menu array
Only the mission makers would know. Looks to me like you can't do it. At least like that.
You could do this...
Use the ACE_Box_82mm_Mo_HE class
And then add an init event script to this class to fill the crate yourself with script commands.
are the mission scripts not unpackable?
You mean the PBO?
yeah just unpack the pbo
yes they are unpackable
Well, everything is unpackable.
the you can trace how the author makes the buy menu? only BIS can make ebos?
or can we make ebos too?
The sentence sounds funny.
ebos?
"everything is unpackable"
encrypted pbo
You can't make EPBO's yourself.
can you get the contents of a populated crate in the INIT? or the crate is still empty on INIT phase?
No, it will be full. Otherwise clearItemCargo this etc. wouldn't work.
What am doing is am taking away the virtual arsenal and i want players only to be able to use BAF mod content so i want to add one crate with all BAF weapons uniforms ect to the fob buy menu. i can make a custom crate with all that in the editor and place in the world and i can also add crates to the buy menu. but i am new to scripting and i have no idea where to go from there
Yes you can make ebo's yourself
This helps?
//init.sqf
["ACE_Box_82mm_Mo_HE", "init", {
params ["_box"];
if (!local _box) exitWith {};
clearWeaponCargoGlobal _box;
clearMagazineCargoGlobal _box;
clearBackpackCargoGlobal _box;
clearItemCargoGlobal _box;
/* fill box */
}, false, [], true] call CBA_fnc_addClassEventHandler;
Same as you can build a fusion reactor yourself. You can. But you don't know how
Woah, how exactly can you make your own ebos?
Dedmen doesn't know
How exactly can you build your own fusion reactor
I actually do know.
But I also know I'm not allowed to talk about that
Careful that the CIA doesn't land a drone on you.
Alright, stepping out now. That was obviously a bait question
You still haven't disproved dialetheism.
What?
Dedmen
I assumed as much ๐
Anyone else who thinks it would be nice with a command like return and then value instead of just putting value in order to return data?
IMO, having a command like that makes it explicit and more easy to understand codebase quickly
Theoretically Intercept could
Hmm
Why would you use breakOut at end of scope?
It's gonna end execution either way
You can put it anywhere, I'm just not very creative.
Is there an event handler that is linked to AI switching behaviors?
No.
Drats.
Of course you can put it anywhere, but why use breakOut when it's not needed? @little eagle
breakOut is for stopping execution
...
At end of scope it will end anyways
Any way that I could have it where whenever a group switches to COMBAT mode, it switches all allied groups within a certain radius to AWARE and gives them a waypoint at the nearest identified enemy?
while loop
onEachFrame
Hmm... I don't think I'd be able to do that.
I really doubt you want to check this every frame.
I'm working on a system that covers a map in AI bases and patrols, so performance is a huge deal.
You could use a lazy eval, and check what frame it is on
so it won't check that unless it's every like x frames
Hmm... I'll have to think on this more.
if (diag_frameno % 50 isEqualTo 0) then {
if _myCondition then {do what you want here};
};
};```
@shadow sapphire could do something like that
or addMissionEventHandler ["EachFrame", { if (diag_frameno % 50 isEqualTo 0 && {myCondition}) then { do what you want here }; };
Is there a set frame cycle? Or maximum I can check, like fifty or could I do a check once every thousand frames or something?
Or if you want to create a thread for "_i" from 0 to 1 step 0 do {sleep (x amount of time); do what you want};
I'd switch to a time based thingy
Time based would probably be my go to.
You could also switch to time based with eachFrame
But I'm not opposed to anything that gets it done.
at 120 fps this diag_frameno would do 2x the work in the same amount of time as 60 fps
assuming that it's linked to the fps ๐
Yes ^
Well, it'll be on a dedicated server, which is locked to fifty cycles per second.
EachFrame + time thingy is fine but you're probably better of doing a spawned while since it's not really time critical at all
as @little eagle said
private "_lastCheck";
if (time > _lastCheck) then {
do whatever....
_lastCheck = time + (minutestosleep * 60);
};
};```
Could do that as well
that won't work
Which I think is good because then you don't have to create a thread
_lastCheck goes out of scope every frame
You sure?
I'm not sure sure but I'm pretty sure ๐
Underscore would make it unusable in other scopes
Good question - > but i does. I probably should've said for future reference
The private making it even more so
Terrible time even
Well, undefined variable in expression time
Oh no. Time to use sqf lint ๐
You guys are making this way too complicated I feel like.
Yes, indeed.
@little eagle Do you know if local variables will be undefined in next frame in OEF handler?
They have to be, theyre not subscopes of each other
Just like how local variables in a GetIn eventhandler wouldn't carry over.
So you'll likely want to send any params to a fnc?
When you put it like that in makes sense @little eagle
I mean, SQF are known to have weird things so...
That is why I said it this way. Thanks for noticing.
Wouldn't be surprised if they were defined
when you want to do EachFrame stuff that's time based then you'll probably want to wrap it in a per frame handler as CBA already did
What, pass arguments into next frame?
nah just in general
it basically keeps an array with functions and the delays they run at
and there's 1 EachFrame thingy that goes through that list and calls the functions in it when needed
used to have a much more simple example than what's currently in CBA but don't have it anymore
that's the core of it though
Could've read if it weren't for the 100000000 macros
I think DEL is more likely to ruin something than he can save by not just using a while loop with a sleep.
Could've read if it weren't for the 100000000 macros
Sounds like a personal problem to me.
Was on about the whole of CBA
Like 99% of them are GVAR and FUNC though^^
For example, what is the reason behind this? #define IS_ADMIN serverCommandAvailable "#kick"
Someone asked for it.
I used them in my section of the code and defined them there.
For new users it will be very hard to learn
And I was asked to move it to the main file.
serverCommandAvailable "#kick" is horrible to read.
I never can remember which one is for voted and which one is for logged admins.
So I put these in the local header file.
But as I said, they wanted me to move them to the common one.
So... ยฏ_(ใ)_/ยฏ
it's quite useful actually
In cba_common GVAR(xyz) is cba_common_xyz
It's used so you can move files between components (and mods) without having to rewrite their pseudonamespace.
I don't use the macros myself but I see how they can be useful ๐
FUNC is the same just FUNC(xyz) is cba_common_fnc_xyz
I see how something can be useful with macros as well, like defining a number to a more suitable name to that number
I doubt it's 95% ๐
Measured per use it probably is.
Why have a bunch of macros in your hpp that never gets used?
Half of them are legacy.
Aah
E.g. EXPLODE_N is basically the same as params is now.
Aah I see
I just never saw the point in making things to obscure code
New people are just going to learn the macros, not the syntax itself
You get used to GVAR and FUNC quickly and the PREP framework instead of CfgFunctions and then you can't go back.
The syntax doesn't change with any of this though.
Of course not, it's essentially just an alias
But on the other hand, apparently half this channel scripts their mods in the debug console, so help is beyond them anway.
Wot? ๐
always wondered about PREP. In what way is it better than CfgFunctions?
would it make sense to move an existing code base over to it?
I guess it's also mostly about prefixes
You can edit / add / remove PREP all the time, while you would need config file patching enabled with CfgFunctions.
Because it's all script based.
Also with CfgFunctions, you can make use of recompile for all functions.
But in ACE that would mean adding like 40 seconds to every restart just to recompile everything.
With PREP you uncomment one line in the local header file and it takes not even a second for one component.
I'd go insane with CfgFunctions.
would it make sense to move an existing code base over to it?
Probably not. I see it as a part of the build environment. So if you start from scratch you can use the example addon that is somewhere on github I think and start something from there.
okay
im gonna start working on a virtual inventory system (@little eagle ) so I can finally go about remaking the whole inventory system. i need advice on how to network it properly for multiplayer tho
as in, take and remove items from containers (all items are stored as variables on the objects they are in)
any suggestions on how to do it safely?
How would I know? You act like I've done something so ambitious ever before.
you have! an year ago.
yeah you've been telling me progressively to stop trying to achieve an inventory system
because you tried it all an year ago
as in weapons in containers, etc etc.
No, I said I tried to make an AI reliably drop a weapon about one to two years ago.
I never tried to rewrite the inventory system, because I know it's futile to do so.
sounds like a burnout in the making ๐
Call me when it's done. โ
sure, but you must send nudes if i make it happen
raises eyebrow
I thought this had an emoji too, but then I remembered that the Japanese have weird eyes.
there's ๐ค
My favourite emoji. I dunno why.
๐ค
๐
what's the simplest way to create a temporary fire with damage and smoke?
Blow up a vehicle
mmm, wrecks are undesired
what i have now is, a fuel pump spawns and blows up
but you can see it for a few frames
@digital pulsar there are test fire objects under the CfgEmpty biki page
can't see it in cfgvehicles/empty
FireSectorTarget i guess?
Nope
well then there's no "test fire objects"
Afaik it was in there
if (serverCommandAvailable "#kick") then is more readable than if (IS_ADMIN) then. @rotund cypress are you serious?
๐ฟ
๐ฟ ๐ป
And if you wanna read the code and understand what it does. Which is the definition of readability. You can just ignore GVAR and that stuff.
And because the code is much shorter it's easier to read
And if you want to use the variables in your own code. GVAR is just modname_component_varname
On Github you already have the component in the filename which is displayed in big letters right above the file you are looking at.
If you unpacked a pbo you also have the modname in the path.
There also is now this super useful (ironic) command that only works on the server, yay!
https://community.bistudio.com/wiki/admin
@still forum I do not use CBA and probably will never do, so it's irrelevant to me
And IS_ADMIN can be pretty much anything in a project as big as CBA
So putting that in global macros I just think is stupid
Why would just not a comment suffice?
We have different ways of developing, that is why code look different, this is just my opinions
It can be anything? Sounds to me like it can only be one thing but whatever.
Always Same
Not all code written has to be the same, some is written better but in a better method for the author
Don't even have to write it to conclude that
I have no idea what this is about now.
Me neither
๐ฟ roll with it i guess.
Is it possible to set a custom camera as the main perspective?
yeah. You can move the players view into a camera that you can create and move as you want
I've been looking around the wiki but I only found something on KK's blog, is there an easy way to detect when the play is talking? I only need to know it client-side, lighting up an image in the player's GUI when they're speaking in-game.
KK's blog post and code explains how to do exactly that though..?
Yes, I was just asking if there was an easier way to do it, as many posts from KK have been obsoleted by updates to the game later on.
Most of KK's posts come with feature requests, many of which have been added.
yeah it's kinda convoluted, but i don't think anyone's gonna write this for you from scratch when KK's basically already done it
try modifying his code, that's what i'd do
Hi, I have this t12 animate["terc", 0]; codes.
I execute those with execVM. I have asked here a couple of days ago if the code runs globally, and I've got an answer says it is.
But when I host a server on my PC and I have someone else besides me, I bring the targets up and they only pop up on my screen.
When I run it on a dedicated server, it runs only on the server.
What should I do to make the animate command run globally
When I use AttachTo commands, to Attach a vehicle to something, it breaks the weapons cool down. It's really wierd, Like the turret spins super fast, and the weapons, refire and reload times are drastically refuced.
Really wierd.
is there a way to display the displayname prop of an object without traversing cfg >> shit ?
No.
Ty. now suffer classnames cuz im lazy
where is TypeOf partner NameOf?
i want to play some music while in virtual playground (debug console) is it easy to do and which pbos do i have to unpack to find the music path?
been looking for a simple music player mod but cant find any
i need an equal chance random num from 0.0 to 0.5, will this work?
_num = 0.(floor random 5);
wait im stupid ((floor random 4) * .1) works
how do you get the code in the init field of a vehicle/object during runtime? ๐
nvm, don't need it anymore.. bad thought process ๐
hi all, im hoping someone can help me...
im trying to create a tank factory, what im trying to do is to activate a add action that would spawn a tank if certain conditions are met.
For instance if a number of fuel barrels and ammo crates are detected in trigger area i want it to activate a add action that would give the player a option to spawn a tank.
im currently sitting with a trigger that can spawn a tank if playr is detected, my next step is to have the trigger only activate once required fuel and ammo is detected in trigger area
how do i script a trigger to activate once certian number of items are detected
count ((getPos thisTrigger) nearObjects [typeName, radius]) > 10
should be able to use something like that for the trigger condition
replace typeName with the class of the barrels and radius with the radius you want to check
what's the benefit of using private? parser knows that variable starting with _ cant be manipulated outside the scope
scope bleeding for one
how
_myVar = true;
[] call someFunc;
someFunc:
_myVar = false;
results in _myVar being false after the call
and if i use private in front of either of these, they won't collide?
yup
cool
i'm usually used to it being the other way around, keyword global to manipulate variables from outide function
the way I remembered this happened was assuming that call is basically an #include
which is kinda true in a way ๐
myeah like a paremetrized copypaste
- does the cba xeh stuff add new events like onParachuteOpen or leanLeft/r?
- should dumb shits like me just stay away from CBA?
- how do i get exact moment when my AI units have deployed their chutes?
dumb shits should actually use CBA lol ๐
and I don't think CBA adds any new events by itself
Actually there are a few.
Variables carry over to lower scopes. That's why you can manipulate the _myVar in the higher scope
When you access a Variable in Arma it always searches from lowest to highest scope and uses the first variable it finds
by using private you create a new variable in the lowest scope. So the engine will always use that then
@indigo snow ah cool, didn't know about that
those player events can be used on ur AI too or not?
No, they behave like mission event handlers in that they dont have a specific target
Just the player
it looks like when a unit open a chute they become a vehicle?
while (true) { if ( vehicle _myCunt == "Parachute_Classname" ) then { // chute is open? };};
They are inside a vehicle
They don't become one
Besides a Unit is always a vehicle theoretically
vehicle keyword should get the parachute they are inside right?
yes
so does the condition work or not?
or i could just go vehicle _myCunt != _myCunt to cover all parachutes?
or is there a parachute parent that i can isKindOf?
Check config viewer if there is a parent
if you just check if he is in a vehicle it would also return true for any other vehicle
no your condition doesn't work. vehicle returns a object not a string
oh right forgot the typeOf
but yeah i gotta include mod chutes as well. i guess ill just run the loop check while unit is freefalling so if they become a a vehicle chute must of opened. (unless they are doing hollywood A TEAM stunts)
are IRL chutes disposable use once only? is BIS trying to simulate that by force dropping the chute bkpk when you hit the ground
In IRL you pack the chute back into the bag after you landed
then you can go back up and halo again with your same chute?
.-. no
You can't jump with the parachute again after you packed it, it has to be folded in a particular way for it to open correctly.
I also didn't know they pack the parachutes after they landed I thought that they just leave it like that
Yeah.. And by "Packing it" I meant folding it exactly that way
If you do it you can. And Helo jumpers certainly know how to do that
Do they do it in combat too? It doesn't make any sense
In the middle of combat probably not
Yeah, that's what I though lol
yeah doesnt make sense: its like "UNDER FIRE TAKE COVER!"
" SARGE WAIT IM STILL PACKING MY CHUTE!!"
And if they don't plan to helo again they probably also wouldn't fold it correctly
@lusty canyon When I say "combat" I didn't mean under fire
I meant in a combat zone
I'm reading here from a paratrooper:
I was a paratrooper for 2 years. In combat, the chutes would be discarded. But for training jumps, we would deflate the canopy, fold it up and stuff it into a bag that we carry in a compartment on the parachute harness. Then we would carry it to the waiting logistics trucks to bring it back to base. When we are done with the day's jumps (there may be more than one jump in a day), we head back and hang the chutes on 3-storey hooks and shake them out, then pack them back into the bags for the rigger folks to prep them for the next jump.
what about those self packing oen with vacuum suction and stuff? (like in the bond movies, no IRL counterpart?)
Is there a mod for the jump masks?
https://i.ytimg.com/vi/NgGgRvSpiV4/maxresdefault.jpg
VQI has something like that
got tools like the spec watch for halo
do i still have to do the assignAsCargo shit when i use https://community.bistudio.com/wiki/moveInCargo
or is that just legacy and already fixed?
RE: The parachute, it's simulation type might be special, maybe
so check getText(configFile >> 'cfgVehicles' >> typeOf (vehicle player) >> 'simulation') and see if that gives you anything
assignAsCargo does different stuff than moveInCargo
Just read the wiki page
it says everything
I'll assign you as cargo ๐
i guess what im trying to ask is, why do i have to assign anyone as anything they should automatically be assigned to whatever seatType it is. i dont see any ill effects i can move them in dismount then they still FFV shoot and whatnot
well these questions come up alot when dealing with arma. you can just make your own little function that checks free slots in any possible form and return them / put a unit in them.
and assigns too
is there a way to return the current selected squad in high command?
is there a way to use the respawn modules (and menu selection) with the Nimitz? At any height everyone respawns in the water, never on the Nimitz itself
like setting the height of the respawned player when selected in the menu?
it's not a marker
it's a respawn module
and it's a meter above the deck of the Nimitz
yet spawns people below sea level
How would I make a small group patrol to move with my vehicle via a trigger?.
https://pastebin.com/12E03zAi
I'd basically want 2-4 guys to spawn relatively close to the vehicle and to move on its path.
i'd get positions to the left and right side of the vehicle and repeatedly tell group members to moveTo those positions
Anyone here know if those text fields being really off with a small font in dialogs have been reported to BI? I thought they'd be fixed by now
@hasty pond, I never reported it, haha.
Anyone know what kind of AI drives the Praetorian 1C turret and/or how to replace it with AI of a different faction?
I swear to god
What?
It's been annoying me too much
Screenshot? I haven't seen it.
@shadow sapphire the game handels Praetorian C1 liken an uav so there is no real Driver. but if you write this in the init of it [this] joinSilent (createGroup EAST) it will join opfor
@warm spade, thanks! Will try it immediately!
@shadow sapphire also, spawn empty one in eden and drag soldier from desired faction in to turret
@tame stream, thanks! I thought I'd tried that, but I was trying to group it. Didn't work as well, haha.
Your trick works perfectly.
@tough abyss i had the same issue and realized it was me placing the carrier out of bound (check on the map and make sure carrier is not in the black border of the map)
Do I need to hide the unit or disable them to make sure nothing screwy happens, @tame stream?
I don't want a crewmember to pop out of the turret or something if it's destroyed. I want it to appear automated just as normal.
nope not needed, the turret will act as a UAV does. If destroyed the unit dies aswell
@shadow sapphire Make a marker on the map and it's not vertically centered
It's noticably off
This can also be noticed in dialogs where there are text controls
Ah! Okay.
@tame stream placing it there still spawns people on the lowest deck ๐
but it'll do for the purpose
Why is BIS_fnc_findSafePos so atrociously slow?
doesn't it already do that whenever you use setPos
im trying to activate a trigger once condition is met...
Condition must activate once 5 item are present, 3 barrels and 3 ammo crates.
this works fine on cond count ((getPos thisTrigger) nearObjects ["CargoNet_01_barrels_F", 5]) > 2 but i need it to count/check that there are ammo boces aswell
it should be like this count ((getPos thisTrigger) nearObjects ["CargoNet_01_barrels_F" plus "B_CargoNet_01_ammo_F", 5]) > 2
so it should count to see if there are more than 2 barrels and more than 2 ammo boxes before condition is met
count (thisList arrayIntersect [barrel1, barrel2, barrel3, crate1, crate2, crate3]) == 6
count (thisList arrayIntersect entities [["CargoNet_01_barrels_F", "B_CargoNet_01_ammo_F"], []]) >= 6
@little eagle thx for that but i was hoping that the barrels it would not have to be named as the barrels will be spawned in periodicly during the game, but ill give it a go
See 2.
- wouldnt fully satisfy the condition would it? 6 barrels or 6 ammoboxes would work too.
Yeah. Does it have to be 3 each?
count (thisList arrayIntersect entities "CargoNet_01_barrels_F") >= 3 && count (thisList arrayIntersect entities "B_CargoNet_01_ammo_F") >= 3
How so?
placed crates both in the trigger area, should then spawn tank but no joy
You need 3 each, 6 items in total.
on first try i did
on second try i made it >= 1 to speed up testing
@tame stream Apparently ammo boxes etc. don't get picked up by triggers list or thisList.
count ((getPos thisTrigger) nearObjects ["CargoNet_01_barrels_F", 5]) > 1 && count ((getPos thisTrigger) nearObjects ["B_CargoNet_01_ammo_F", 5]) > 1```
got it working thx
@little eagle thx for the help
@little eagle if i could bother you for one last thing....?
how would i make the trigger delete the boxes after it activates?
count (entities "BOX_ind_ammo_F" inAreaArray thisTrigger) >= 1 && count (entities "CargoNet_01_Barrels_F" inAreaArray thisTrigger) >= 1
I came up with this. Changed classnames for my mission.
Triggers are so random in what they pick up and what not.
yup seems like that
script ... test ... swear at monitor ... adjust sript... script ... test ... swear at monitor ... adjust sript... script ... test ... swear at monitor ... adjust sript... script ... test ... swear at monitor ... adjust sript... script ... test ... swear at monitor ... adjust sript... script ... test ... swear at monitor ... adjust sript...
You forgot the part where you sit on Discord for 8 hours trying to figure out why that one line doesn't work.
๐ true
And it ends up being some arbitrary shit in another conflicting mod.
Hey! Anyone know how to create a zone into which and through which AI will not go? A zone to force them to go around, rather than through or into?
any idea how to delete all or specfic items (not named) if trigger area.... i tried
{deleteVehicle _x} forEach nearestObjects [player, ["all"], 200]
replaced player with trigger name but no joy
@tame stream, I do this:
Wait one. Realized I gotta launch Arma.
{ _x hideObjectGlobal true } foreach (nearestTerrainObjects [this,[],50])```
Placed inside of a gamelogic entity.
If that won't work for you, I've got something else that might do it.
@shadow sapphire do tell
Toy with this, see if you can make it work for you:
_house = nearestObjects [player, ["house"], 2000];
{
switch (typeof _x) do {
case "Land_d_House_Big_01_V1_F": {
_dir = getdir _x;
HideObjectGlobal _x;
_h = createvehicle [(selectRandom ["Land_i_House_Big_01_b_blue_F","Land_i_House_Big_01_b_pink_F","Land_i_House_Big_01_b_whiteblue_F","Land_i_House_Big_01_b_white_F","Land_i_House_Big_01_b_yellow_F","Land_i_House_Big_01_b_brown_F"]), position _x, [], 0, "NONE"];
_h attachto [_x,[0,0,0]];
detach _h;
_h setdir _dir;
deletevehicle _x;
};
};
};```
What this does is replace a destroyed house with any of the non destroyed versions within 2km of the player.
sorry i should have specified, players will place items on trigger area which will activate the trigger...i then want those items in that trigger area to be deleted
๐ฆ
Ah! Okay, yeah, my solutions are tailored for different purposes for sure.
You can just deleteVehicle them
You already have a list of them you count, so you can delete say 3 from both lists
im still learning scripting so not to sure how to utilize that command proparly, how would i structure the script within a trigger's on act:
in my senario id have upto 3 CargoNet_01_barrels_F.
how do i combine the command deleteVehicle with the object type CargoNet_01_barrels_F to achieve the desired result
deleteVehicle _CargoNet_01_barrels_F; obviously won t work
sure but entities "BOX_ind_ammo_F" inAreaArray thisTrigger would for example give you an array (list) of all ammoboxes in your trigger
just delete three of those
deleteVehicle expects object
e.g.
{
deleteVehicle _x;
} forEach (entities "B_CargoNet_01_ammo_F" inAreaArray thisTrigger select [0,3]);
wasnt sure about the order of inAA vs select
It might be different for STRING vs ARRAY
ok great lemme give it a go
in STRING it's the length of the result.
wiki says same for array
ยฏ_(ใ)_/ยฏ
I hate that the ARRAY version has "count" mandatory, while omitting the "length" for the STRING version makes it select everything to the last char.
WORKS PERFECT :)
Still infant when it comes to constructing new scripts, i can reconise and ammend most script but compiling new ones is were im seriously lacking ...thx again ๐
gotta build up your sets of building blocks man, its ok
hey guys someone here with experience in extDB scripting? I'm quite new to it so would really appreciate some guiding. I've got some functions in the init and config already and the sqf functions almost ready but I'd love to have some with experience see if I am doing it right ๐
PM if possible
@hasty violet The displayName from config has nothing to do with the name reported by the command. The premise of that question is wrong.
hi all :)
how can i have a delay on a addaction once its been activated, example...
walk to object with addaction
activate script via addaction
addaction disapears/deactivates for 30seconds
30 seconds later addaction reappears/re-activates and ready to execute script again
you'll have to keep track of the time someone used the addAction and then test whether the current time - last time used is more or equal to 30 seconds in the addAction condition
well i was hoping its possible to disable the option for 30 seconds after its been activated, then have it back to just execute the script again
yeah that what the condition thingy is for
if that condition doesn't return true it'll hide the action
ok but i have not idea how to do that
currently i have the addaction working fine but the delay has me stumped
how would i go about adding a condition to check if time has passed?
one sec ๐
๐ค
While {true} do {
_action = _unit addaction ["Action", {go = 1; execVM "script.sqf"}];
waituntil {go == 1};
_unit removeAction _action;
sleep 30;
go = 0;
};``` this should work
checking
does it replace my current addaction command in init
getting generic error in expresion
_factory addAction [
"some title", // title
{ // code / script
(_this select 0) setVariable ["last_time_action_used", diag_tickTime, true];
},
nil, // arguments
1.5, // priority
true, // showWindow
true, // hideOnUse
"", // shortcut
"(diag_tickTime - (_target getVariable ['last_time_action_used', 0])) >= 30", // condition
15, // radius
false, // unconscious
"" // selection
];
as an example
if you use a script instead of a code block then put the setVariable thingy in that script
im currently calling it as follows...
_act = this addAction ["Produce Fuel", "scripts\Fuel1.sqf"];```
script simply spawn feul barrels on marker
_act = this addAction [
"Produce Fuel", // title
"scripts\Fuel1.sqf",
nil, // arguments
1.5, // priority
true, // showWindow
true, // hideOnUse
"", // shortcut
"(diag_tickTime - (_target getVariable ['last_time_action_used', 0])) >= 30", // condition
15, // radius
false, // unconscious
"" // selection
];
obviously its just added to random item
nevermind, mine doesn't work as promised, since you need for every addaction a new script. I recommend using marcel's version.
and add (_this select 0) setVariable ["last_time_action_used", diag_tickTime, true]; to the Fuel1.sqf
all the other values are just the defaults for addAction ๐
_act = this addAction [
"Produce Fuel",
"scripts\Fuel1.sqf",
nil,
1.5,
true,
true,
"",
"(diag_tickTime - (_target getVariable ['last_time_action_used', 0])) >= 30",
15,
false,
""
];```
more like this i suppose
```css
_act = this addAction [ "Produce Fuel", "scripts\Fuel1.sqf", nil, 1.5, true, true, "", "(diag_tickTime - (_target getVariable ['last_time_action_used', 0])) >= 30", 15, false, ""];
and in my fuel1.sqf
(_this select 0) setVariable ["last_time_action_used", diag_tickTime, true];
_veh = "CargoNet_01_barrels_F" createVehicle getMarkerPos "barrela1";
sleep 5;
_veh = "CargoNet_01_barrels_F" createVehicle getMarkerPos "barrela2";
sleep 5;
_veh = "CargoNet_01_barrels_F" createVehicle getMarkerPos "barrela3";
;
if i understand correctly
yeah probably
ill give it a test
not sure what you changed in the above but if it works it works ๐
simply removed to comments
ah
Why is the syntax highlighting so weird
You cant inline comment like that
this ```
instead of
```this```
?
If its in a line you need /* comment */
what languague are you using for the highlighting?
ah cool @indigo snow didn't know that. They were just there for clarity though. ๐
Yea just thought id clarify why since copy paste is so common in here
fucking SQF ๐ฅ
Good solution with the ticktime btw
๐
_act = this addAction [ "Produce Fuel", "scripts\Fuel1.sqf", nil, 1.5, true, true, "", "(diag_tickTime - (_target getVariable ['last_time_action_used', 0])) >= 30", 15, false, ""];```
works like a BOSS
@halcyon crypt thx my man ๐๐ผ ๐
nice ๐
@tame stream
```sqf
<code>
```
wonder what language does this weird stuff with the brackets ๐
css
heh weird well not weird but yeah ^^
Can you use macros in discord like IRC? Explaining how to make SQF code boxes would deserve one...
!help
/help
๐ฆ
You can make the same macros that you can with a Console window as IRC client
Which is.. Your keyboard software if you have macro keys
I mean shorthands. Like how in the BWA3 Slack I can type !pr and it opens the gitlab pull request page for that mod.
Yeah, that might be it.
I'll bind it to some keycombo I guess.
hi guys. I'm using this "1 man tank" script which allows me to control the turret of a tank while driving it. I'm getting this bug that accumulates the "Get out" user action every time I enter and exit the vehicle. If I enter and exit a few times this happens.
"Get out"
"Get out"
"Get out"
This is the script I'm using:
private ["_v", "_laser"];
_v = _this select 0;
_v call {
if (isServer) then {
_this lockCargo true;
_this addMPEventHandler ["MPKilled", {
if (isServer) then {
_d = driver (_this select 0);
_g = gunner (_this select 0);
if (!isNull _d) then {deleteVehicle _d};
if (!isNull _g) then {_g setDamage 1};
};
}];
};
if (!isDedicated) then {
_this addEventHandler ["GetIn", {
_tank = _this select 0;
_unit = _this select 2;
if (vehicle player != _tank) exitwith {};
_unit allowDamage false;
_unit action ["EngineOn", _tank];
_unit action ["MoveToGunner", _tank];
_tank addAction [localize "str_action_getout", {
(_this select 0) removeAction (_this select 2);
(_this select 1) action ["GetOut", (_this select 0)];
}, "", 3, false, true, "GetOver"];
_tank spawn {
waitUntil {!isNull gunner _this};
_ai = createAgent [typeOf gunner _this, [0,0,0], [], 0, "NONE"];
_ai allowDamage false;
_ai moveInDriver _this;
waitUntil {!isPlayer driver _this; !isNull gunner _this; };
_this lock true;
enableSentences false;
};
}];
_this addEventHandler ["GetOut", {
_tank = _this select 0;
_unit = _this select 2;
_unit allowDamage true;
deleteVehicle driver _tank;
_unit action ["EngineOff", _tank];
_tank lock false;
}];
};
};
can anybody immediately see were the problem is?
Yes. You are never removing the getOut action.
Oh yeah... Please use
```sqf
<code>
```
Makes it far easier to read
and use params. also makes it easier to read
You only have that one getOut action? What happened to the default getOut action?
dunno.. I found this script. Didnt write it myself. I don't know too much about sqf scripting. basic stuff really
My thought is that you already have a "Get Out" action by default. If you use that instead of the one you added then yours won't be removed
so you're saying I should just remove this?
(_this select 0) removeAction (_this select 2);
no sry. this I mean
(_this select 1) action ["GetOut", (_this select 0)];
if (!_tank getVariable ["hasGetOut",false]) then {
_tank addAction [localize "str_action_getout", {
(_this select 0) removeAction (_this select 2);
(_this select 1) action ["GetOut", (_this select 0)];
}, "", 3, false, true, "GetOver"];
_tank setVariable ["hasGetOut",true];
};
this will prevent your action from getting added multiple times
thanks alot @still forum I'll try it
you can only "GetOut" once with that though
oh?
ยฏ_(ใ)_/ยฏ
@still forum didnt work :\
what about this?
_this addEventHandler ["GetOut", {
_tank = _this select 0;
_unit = _this select 2;
_unit allowDamage true;
deleteVehicle driver _tank;
_unit action ["EngineOff", _tank];
_tank lock false;
}];
this is just what happens to the tank when getting out isnt it?
yes
Ah, does that trigger when you get moved out by script tho
That doesn't make sense though. How does the action get added if my variable is set to true.
that doesn't matter though. as it does nothing to the action
Try adding some letters to it so its different from the engine one, what if its the engine one thats multiplying?
@still forum I was actually packing it in the wrong place lol. but when I tried your code
if (!_tank getVariable ["hasGetOut",false]) then {
_tank addAction [localize "str_action_getout", {
(_this select 0) removeAction (_this select 2);
(_this select 1) action ["GetOut", (_this select 0)];
}, "", 3, false, true, "GetOver"];
_tank setVariable ["hasGetOut",true];
};
I get this error
if (!_tank getVariable ["hasGetOut",false]) then { -> if (!(_tank getVariable ["hasGetOut",false])) then {
I find it weird to have the ! outside of the if condition
But I'm also doing that alot myself
now it worked, but I can only exit the vehicle once
Once I enter it again, I can never get out
it is 2 when Im in
and 1 when out
never 0
should this be (_this select 0) removeAction (_this select 1);
instead of
(_this select 0) removeAction (_this select 2);
?
I'm a little closer now. now I always have a "Get out" action when standing by the vehicle. both when inside and out
but it dont accumulate
do you guys think publicVariable of a number every second is too much?
guess not.
I think the question should be do you guys think publicVariable of a number every second could be done a better way?
just wondering because i have a time limit that i sync and last test certain players had and caused desync but others were totally fine.
yes BoGuu you are right. it's a bit of a lazy solution atm
a single number every second definetly won't cause desync
already changing it but i was wondering how touchy force syncing like that is. i mean ideally i wanna make code that potentially works well no matter the number of players
If the time is just ticking down as normal, you can avoid pvar'ing it every second
yer that would be my next question
isn't there still stuff happening that might desync mission time?
or is it totally tied to system time?
ah k. i just have a mission time limit bleeding down. so doing sync every 10 seconds should be enough to keep all synced
Im having trouble understanding bounding boxes. How would I use them to get an offset position from another position utilising the objects bounding box to avoid getting a colliding position?
boundingBoxReal ?
if distance to bounding box on second object on x and y axis is bigger than respective bounding box side on first object/2 then they don't collide
|-----x-----| |------x------|
| being the bounding box
x being model center
use math
Yeah im horrible when it comes to maths haha. But I understand what you mean, wasnt sure how to go about it. Cheers
collision detection is one of the most asked and written about subject in game development ๐
I'm sure you can find something
You'll need math for game development
Somebody knows how to play a custom .ogg video-file on an ingame billboard or on a usertexture eg?
you should try looking at the functions added with the APEX expansion
@indigo snow Is this answer to me? ๐ If yes, thak you for your fast reply
yes
also, http://killzonekid.com/arma-scripting-tutorials-ogv-to-texture/ might be interesting to you
@abstract shuttle ogv not ogg. ogg is audio
True ๐ Thanks for the last link! That is what I was searching for. +1
You could still handle that with a CBA PFH.
But 4-5 loops likely wont be too many either way
@hasty violet CBA PFH sorts the handlers. No it won't have a big effect having lots of handlers that execute on bigger intervals
PFH also has a scheduler though. @tough abyss
case "define":
break;
case "include":
break;
case "ifdef":
break;
case "ifndef":
break;
case "else":
break;
case "undef":
break;
case "endif":
break;```
anything i forgot in regards of preprocessing commandS?
check, the latter are macros though?
or are you actually able to write #__EVAL etc.?
They are preprocessor commands, but without #.
"Config parser macros"
"keywords"
so just the predefined and not undef'able as specialized macros
I never tried to undef them, but I doubt that would work.
@queen cargo #line
__EVAL, __EXEC, __FILE__ and __LINE__. Are more Macros not Preprocessor commands
I think that was some bug that came up recently
Would a for loop nested in a forEach do anything to the forEach's _x ?
No, unless you use _x for your for loop instead of the common _i
Alright, thanks!
But somehow, _x here is nothing.
_num = "";
{
for [{_i = 0}, {_i < 5}, {_i = _i + 1}] do {
_x = _x + (str floor(random(10)));
};
} forEach [_num];
From what I've read, _x should be a reference to _num here.
hint _num returns absolutely nothing. Not even "".
Might it be that _x lost its reference when moving to the for loop?
It's got nothing to do with the latter. Is _x still a reference to its original like in Arma 2?
Should work from what I can see.
Can you show how you really wanna use that? Your code is useless
Yeah, this code does nothing.
_x doesn't exist in the scripts main scope, only in the forEach-block scope. And it can't leave to the main scope anyway, because as a magical variable, it's set to private to the forEach-block.
And _num is never changed.
I'm having trouble understanding what you mean. Are you saying _x is undefined in the for loop? Shouldn't _x be a reference to _num when used in the for loop?
One wiki entry on forEach talks about _x being a reference of its original (_num in my case), assigning a new value to _x should assign it to _num from what I understand.
The entry is from 2010 though, which means it was from Arma 2. But I might be using forEach wrong anyway.
_x is undefined in the main scope. The most outer part of the script.
there are no string references. You can only have references to arrays
_x is not a reference to _num. It just has the same value. Only ARRAY's are passed as reference.
_num = [""];
{
for [{_i = 0}, {_i < 5}, {_i = _i + 1}] do {
_x set [0, (_x select 0) + (str floor(random(10)))];
};
} forEach [_num];
_num = _num select 0;
Assigning a new value would stop making it a reference, even if it was an ARRAY.
And nothing changed in that regard since A2.
private _num = "";
for "_i" from 1 to 5 do {
_num = _num + str floor random 10;
};
Now for the commy version:
private _num = random 1 toFixed 5 select [2];
I'm new here what's the commy version?
It's when I turn your script into a one liner.
I posted it already
here is my commy version:
private _num = "";for "_i" from 1 to 5 do {_num = _num + str floor random 10;};
tadaa
Better Idea!
private _num = "12345";
That is no longer random.
It was random once though
I'm struggling to understand your one liner. I mean it works, but I wish I could understand it.
Oh
shit
I just got that
Only thing I can't understand is the select [2]
generate a random number between 0 and 1..
0.1242357345358345 then convert it to string with 5 precision "0.12423" then cut off first 2 letters "12423"
oh
STRING select [offset,length]
Can someone explain __EXEC and __EVAL in layman's terms?
In layman's terms: "Doesn't exist"
Anyone knows as to why endMission only works once. I got a mission where people get booted back to the lobby if there not enough players on for that slot. And it seems to only happen once (on mission start). But after that they don't get "kicked" by endMission. (if they rejoin in that slot or any other slot that should end their mission.) And if I try to execVM my script via debug console it "kicks" me.
I diag_log'd the whole path and it all runs correct, but endMission is just not doing its thing...
same behaviour with BIS_fnc_endMission.
Adding a sleep of 2 seems to have fixed it. looks like the endMission was done too soon.
im trying to spawn a dead unit
im spawning it as vehicle to reduce performance impact (im willing to spawn alot of those)
but i dont want the animation to be visible (the unit needs to seem dead)
is there any way to do it? the most i could achieve was to set damage and hide, then unhide
but the ragdol dont always finish at the specific time interval between the hiding and unhiding.
has anyone an idea how to approach this, perhaps on a different way?
found a solution for the approach i've taken, which is to wait until velocity is [0,0,0]
@distant egret if it's MP better use https://community.bistudio.com/wiki/BIS_fnc_endMissionServer
@digital pulsar it's only to kick a single client.
That ends the mission for everyone
force respawn then?
That will just respawn them?
well depends on respawn settings
It's for a locked player slot. I don't want everyone to get into it.
But a 2 sec delay seems to have fixed it so ๐
So if someone gets in the slot that shouldn't he gets brought back to the lobby because his mission is ended.
cool
It worked fine back in the day so I think they might have changed some stuff. but all works again.
Dedmen you asked me earlier how I was using the snippet I posted, I'll answer with another question if you don't mind. It's supposed to generate a phone number for the player and then save it in the database. Now my question is, I have to check every time a number is generated for its existence in the database. Every player has 3 numbers (1 for every faction). Should I make a DB call every time I generate a number like this:
_nums = [];
for [{_i = 0}, {_i < 3}, {_i = _i +1}] do {
_num = random 1 toFixed 5 select [2];
_query = "SELECT COUNT(*) FROM cellphones WHERE civ_nid = _num OR cop_nid = _num OR med_nid = _num"
if (_query isEqualTo 0) then { _num pushBack _nums }
else { _i = _i - 1};
};
INSERT CODE
Most of the code here doesn't make any sense and wouldn't work, it's mainly to show you what I mean.
{
if (!(EQUAL(name _x, name player)) && !(EQUAL(vehicle _x, _x))) then {
findDisplay 12 displayCtrl 51 ctrlAddEventHandler
[
"Draw",
format ["_this select 0 drawIcon
[
getText (configFile >> 'CfgVehicles' >> %1 >> 'Icon'),
[0,1,0,1],
%2,
24,
24,
%3,
%4,
1,
0.03,
'TahomaB',
'right'
]", str(typeOf vehicle _x), getPos vehicle _x, getDir vehicle _x, ,str(name _x)]
];
};
}forEach playableUnits;
any way to make this work? this is just an example of what i want, i need to remake it so position and dir updates. This only draws static icon because position is same from time it was called because of format. I want to cycle it through every playable unit.
@tardy yacht Just make a custom stored procedure that takes care of all that on the DB side and only returns the phone number to you.
youre right, gonna try, thanks
@tough abyss __EXEC and __EVAL can only be used in config. They allow for SQF expressions that are evaluated when the unbinned config is parsed at game start. They are not very useful generally imo.
If you need a good trick with it, you can randomize mission loading pictures for example. https://github.com/TMF3/TMF/blob/master/tmf_template.Altis/description.ext#L5
ugly
__EVAL(format ['\x\tmf\addons\common\ui\loadscreens\%1.jpg', floor random 10 + 1]);
ceil random 11 could result in 11 technically, so ...
And ceil random 10 can result in 0.
Whenever I learn something new about configs I immediately start thinking "can I use this for dynamic #includes?".
Hey, guys. How can you convert uid in guid?
Does drawTriangle work with inArea?
there is no real guid @nova belfry