#arma3_scripting
1 messages · Page 525 of 1
gotcha
looking
found it
["NonStrategic","Building","Static","All"]
Ok now I know how to do that as well. thx guys !
Ok so I just found out I didn't have to go through all that. I couldn't find it because i'd set the object as simpleObject and it wasn't taken into account by nearestObjects
I have a radio trigger set up to pause all AI in the mission. Is there a way to limit it to just a few players in the mission file, preferably by class name?
How difficult is it to iterate through all of the wheels on an IFV via scripts? I want to add an AddAction for a special type of re-sealable/inflatable set of tires that the commander can use once.
It's not hard, here's my code that iterates through wheels and tracks
AI_misc_fnc_isAnyWheelDamaged = {
params [["_veh", objNull, [objNull]]];
(getAllHitPointsDamage _veh) params ["_names", "_selections", "_damages"];
pr _repairNames = ["wheel", "track"];
pr _return = false;
scopeName "s0";
for "_i" from 0 to ((count _names) - 1) do
{
pr _name = _names select _i;
// Repair wheels
pr _isWheelOrTrack = (_repairNames findIf {_name find _x > 0}) != -1;
if (_isWheelOrTrack) then {
if (_damages select _i > 0.89) then {
_return = true;
breakTo "s0";
};
};
};
_return
};
Dope.
¿ pr ?
priv
I'm creating a camera scene and I'd like to set the camera target to the front of a moving vehicle. How could I do that ?
This isn't working
_camera = "camera" camCreate [0,0,0];
_camera cameraEffect ["internal","back"];
_camera camSetTarget [1215.573,3865.788,2];
_camera camSetPos [getPosATL player select 0,getPosATL player select 1,(getPosATL player select 2)+200];
//_camera camSetFOV 0.5;
_camera camCommit 0;
waitUntil {camCommitted _camera};
[format["<t color='#FFFFFF' font='PuristaMedium' shadow='2' size='%1' align='left'>Created and Scripted by<br/>Flash-Ranger</t>",_size],-1,0,8,3,0,4002] spawn BIS_fnc_dynamicText;
sleep 10;
["someId", "onEachFrame", {_camera camSetTarget [getPosATL vehicle player select 0,(getPosATL vehicle player select 1)+10,getPosATL player select 2];}] call BIS_fnc_addStackedEventHandler;
_camera attachTo [(vehicle player),[0,0,2]];
_camera camCommit 0;
waitUntil {camCommitted _camera};
["someId", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
sleep 20;
player cameraEffect ["terminate","back"];
camDestroy _camera;```
I understand why tho, but would you guys have another solution
you can make the camera follow the vehicle
but I don't think you can let it follow the front
mmmh...
Ah wait
Didn't fully see what you're doing there
_camera variable in first line is undefined
this is only part of the script. let me compete it
whatever part is infront of that. _camera is undefined
the eachFrame handler is a seperate script. Local variables don't carry over to other scripts
ah
that's different
yes indeed
I know that. That's why I was saying it wasn't working ^^ you taught me that 😄
Well if you know that's what's wrong. Why don't you fix it then?
you can make the camera a global variable. Or pass it into the eventhandler via the arguments
https://community.bistudio.com/wiki/BIS_fnc_addStackedEventHandler there. It has a arguments parameter
I made it a global variable but it didn't work either
Still not working
["someId", "onEachFrame", {_camera = _this#0; _camera camSetTarget [getPosATL vehicle player select 0,(getPosATL vehicle player select 1)+10,getPosATL player select 2];}, [_camera]] call BIS_fnc_addStackedEventHandler;
_camera attachTo [(vehicle player),[0,0,2]];
_camera camCommit 0;
waitUntil {camCommitted _camera};
["someId", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;```
what exactly is happening?
If you remove the eachFrame EH it will ofc stop updating position
the waitUntil will only wait very briefly
what is happening is that it is still targeting my previous target and not taking this new one.
I know, I need to delete the waitUntil. anyways I have a sleep 20; just after.
what is your previous target?
and removing the waitUntil is not the solution
that way your eachFrame EH is removed even sooner
_camera = "camera" camCreate [0,0,0];
_camera cameraEffect ["internal","back"];
_camera camSetTarget [1215.573,3865.788,2];
_camera camSetPos [getPosATL player select 0,getPosATL player select 1,(getPosATL player select 2)+200];
//_camera camSetFOV 0.5;
_camera camCommit 0;
waitUntil {camCommitted _camera};
[format["<t color='#FFFFFF' font='PuristaMedium' shadow='2' size='%1' align='left'>Created and Scripted by<br/>Flash-Ranger</t>",_size],-1,0,8,3,0,4002] spawn BIS_fnc_dynamicText;
sleep 10;
["someId", "onEachFrame", {_camera = _this#0; _camera camSetTarget [getPosATL vehicle player select 0,(getPosATL vehicle player select 1)+10,getPosATL player select 2];}, [_camera]] call BIS_fnc_addStackedEventHandler;
_camera attachTo [(vehicle player),[0,0,2]];
_camera camCommit 0;
waitUntil {camCommitted _camera};
["someId", "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
sleep 20;
player cameraEffect ["terminate","back"];
camDestroy _camera;```
No true.
I'll put a systechat in there to see what happens
okay nope it isn't executing at all
then maybe your waitUntil doesn't sleep at all and you remove the EH before it can execute
crap indeed... my remove was before the 20 seconds pause instead of after .....
okay so now it is executing because I see my systemChat flooding my screen but it's not taking my target ....
missing camCommit
Which command removes the standard action on the mouse wheel? like "Open door"?
@umbral oyster none
Sadly
no, i need only for one object
Then you need addon
Hi all.
I'm creating then deleting a waypoint. But i'm getting an error on deletion Error: type Array, expected Number Can someone find my mistake ?
_wp1 = DDAY_grp1 addWaypoint [getMarkerPos "attack01", 0];
_wp1 setWaypointType "Move";
_wp1 setWaypointCombatMode "Red";
_wp1 setWaypointBehaviour "Aware";
_wp1 setWaypointSpeed "Full";
_wp1 setWaypointFormation "Line";
[...]
deleteWaypoint [DDAY_grp1, _wp1];```
Check again what addWaypoint command returns, and what deleteWaypoint command wants as arguments
Guys, please help. I need to put an object relative to the mouse position and I ran into a problem. I use lineIntersectsSurfaces and screenToWorld, but screenToWorld returns the position relative to terrain. I need to put the object above the horizon line and I think I need to use positionCameraToWorld, but how to make the mouse position be taken into account. Sorry for my English if I misspelled something.
@rigid bloom Mouse position: https://community.bistudio.com/wiki/getMousePosition
use that for screenToWorld
returns the position relative to terrain what's the problem with that?
I tried to use this command, but it doesn't take terrain into account. Accordingly, I will not be able to put the object at a position that is above the horizon
screenToWorld returns the position on the terrain that you're aiming on
It does take terrain into account
https://ibb.co/nLxyN3r
in the screenshot, my mouse is at the top of the screen, but the arrow won't move there
Not sure which LOD it uses to intersect. Might be GEO lod
I used VIEW and GEOM, but it also didn't solve the problem.
Here is a good example of how it works. https://ibb.co/nM0wJLn
Arrow is in position below the red line, and I, for example, you need to put the object at the point where the mouse is over the red line (the blue circle)
which distance does that need to work on?
not more than 100 meters
_eyepos = positionCameraToWorld [0,0,0]
_targetpos = positionCameraToWorld [200, 0, 0] //200m infront of you
Then do lineIntersect between that
https://community.bistudio.com/wiki/positionCameraToWorld
//200m infront of you that would be [0,0,200]
Oh. Now I understand, but this is if I would need to put an object in the center of the screen. But it is necessary to put the object on the position of the mouse
I think it should look something like this, but with some wild math
getMousePosition params ["_xpos","_ypos"];
_pos1 = agltoasl ( positionCameraToWorld [ 0,0,0 ] ) ;
_pos2 = agltoasl ( positionCameraToWorld [ _xpos,-_ypos,200 ] ) ;
_re = lineIntersectsSurfaces [ _pos1 , _pos2 , player , objNull , true , 1 , "VIEW" , "NONE" ] ;
positionCameraToWorld doesn't take mouse position :/
I understand this, but it seems to me that through this method you can somehow get the same result as with screenToWorld, but with the correct position for the object. However, I do not yet understand how to do it.
Are you trying to get the line from camera to mouse?
Yes
If I move the mouse for example in the ceiling of the house in which I am, the object is not put in this point. It will be placed in a position that is not above the terrain line. Therefore, this method did not win
The problem with screenToWorld will be clearly visible on the VR map. If you create a house on the ground and try to point the mouse at the roof of the house, your position with lineIntersect will be somewhere at a height of not more than 2 meters, but not on the roof of the house, where the mouse points
screenToWorld finds the terrain position. If you aim into the sky.. there is no terrain there
That's why I say that screenToWorld does not give the desired result
Maybe use the camera vector, find the fov, get the partial angle using mouse position
hey, how can i make an addon that adds a new function to the game?
like, a new script function
you dont need addon for that
for combining existing SQF operators into a scripted function you don't need it, you just wrap them into {} brackets and then call it
if you mean to add a new SQF command/operator like player doMagic 123; then you can use Intercept addon
nah, i'd like it in an addon, because it has custom assets, and so i can use it in multiple missions without having to readd the script and assets
and without bloating the mission filesizes
Then you need to read this if you haven’t already https://community.bistudio.com/wiki/Arma_3_Functions_Library
Is there any way I can find a list of available speech options that can be used in the conversation system?
CfgWords in config explorer yes
see https://community.bistudio.com/wiki/Conversations#.bikb_advanced_example @harsh sphinx
Thanks, legend. I somehow totally missed that.
please use and abuse this page (and bring feedback if it were eventually incomplete or unclear)
Hi, I’m trying to attach an object to the player and make it look like it is attached to the backpack. My question is, what’s the memory point the backpack uses to move? I have tried with spine, spine 2 and spine 3. None seems to give the desired effect.
@tough abyss thank you, much appreciated
I've forgotten how to pass information (params) into a forEach.
_x ? @drowsy axle
https://github.com/TermiGR/Aram3Life/blob/1306f33623f7978b86fd16478a9d7bb534ada28d/ArmA3Life.LakesideValley/core/cop/fn_copLoadout.sqf#L10
Can someone explain why they use 'spawn' instead of a normal call here? I mean in the next line they still wait for the function to be done.
Is it just bad code or is there a reason for this?
createDialog "RscSecretIntelDialog";
waitUntil {!isNull (findDisplay 3842);};
Another example, is there reasoning behind all these waitUntil calls?
Can someone explain why they use 'spawn' instead of a normal call here?
no. there is no good reason.
that specific display waituntil is pretty pointless too
Ah okay, thank you for confirming
This script seem to be running in scheduled already no need to spawn another script from it and wait for it, if it is called the original script would wait for it to finish
Good morning all. I'm not as gifted as most of you are in terms of scripting and appreciate the scripts that you all have here on discord. I attempted multiple times browsing Armaholic and other sites for an enemy aviation script. I see it all the time in Invade Annex servers but wanted to place it in my EOS mission. Ideally looking for enemy aircraft to spawn at a certain frequency, fly over the mission at random and respawn after being shotdown. Any help? Thank you for your time. Please do an @ to let me know.
Try this:
SQF_fnc_flyThrough =
{
private _startPos = player getRelpos [1000, 180];
private _plane = createVehicle ["B_Plane_CAS_01_dynamicLoadout_F", _startPos, [], 0, "FLY"];
private _velocity = velocityModelSpace _plane;
_plane setDir (_startPos getDir player);
_plane setVelocityModelSpace _velocity;
createVehicleCrew _plane;
_plane doMove (player getRelpos [1000, 0]);
_plane addEventHandler ["Fuel",
{
_this select 0 removeEventHandler ["Fuel", _thisEventHandler];
[] spawn
{
sleep 10; // respawn next plane in 10 seconds
call SQF_fnc_flyThrough;
};
}];
_plane setFuel 0.005;
};
call SQF_fnc_flyThrough;
why setVelocityModelSpace is not highlighted, what is this blasphemy?
@next scaffold I don't mean _x
@drowsy axle sqf { _x params ["_unit", "_damageValue"]; _unit setDamage _damageValue; } forEach [ [unit, damage], [unit, damage], [unit, damage] ];?
Hey can anyone help me with this little snippit? I had it working at one point but I cant figure out what i did to do so, and its not working anymore
elevator = (nearestObjects [(getpos SpaceElevator), [], 600]); {this setFeatureType 2} foreach [elevator]
put a ; at the end of it?
doubtful, it doesn't return an error it just doesn't have an effect.
just don't delete the ; to be safe
can I just have a look at the space elevator? 😄
oh wait I see the error!
foreach [elevator]
should be forEach elevator
also if you don't need the variable to reside with global variables, declare it as private _objects = nearestTerrainObjects ***
They arn't terrainobjects though
they need to be, but they arn't
thats what I'm attempting here
let me see if thats indeed the error
elevator is an array and you put an array inside array foreach [elevator]
Ahh
also
inside forEach
{this setFeatureType 2} foreach [elevator]
must be
{_x setFeatureType 2;} foreach elevator ??
uhh I can try that
I thought running _this was giving me an error in the past
alright lets try that now
Nope
still not functioning
well then you must debug it properly
see what this thing returns
elevator = (nearestObjects [(getpos SpaceElevator), [], 600]);
like, type elevator in the console and see what's there, since it's global already
now how exactly do I read what that returns, thats one thing i Never figured out.
like, you type 1+2 and type enter, it gives 3 at the bottom of the console
it should tell you contents of elevator variable at the same place
yeah it should give you like [] at least
or [object_1, object_2, ...] a list of objects, which is what you need
if it gives you nothing then it's nil probably, try isNil "elevator";
also how do you run your script?
o_O then what it is it if it's not nil but returns nothing O_o 🤔
idk... if i do elevator = (nearestObjects [(getpos SpaceElevator), [], 600]); the field is blank, but Isnil returns false
but it doesnt even return [] ??
Nope
you don't understand, if you execute variable = 123; it returns nothing, because = operator returns nothing, so the console returns nothing
you should either do (nearestObjects [(getpos SpaceElevator), [], 600]); or elevator = (nearestObjects [(getpos SpaceElevator), [], 600]); elevator to make it return the result of nearestObjects
Ohhh
oops
OK yes it does return what i need it to return now
it is infact seeing it
then {_x setFeatureType 2;} foreach elevator should do setFeatureType properly
IDK if setFeatureType itself works or not, never used it 🤷
yea the popin for the place is a little jarring given how large it is, so I was hoping to use it since its a landmark on the mission
I want to see the space elevator 😄 is it going to space??
Supposedly
Ugh... not thats not working either
is it specifically _x or?
oh yea _x is for arrays isnt it
@winter rose before the first {
Cancels his SQF lessons with Sparker
@tough abyss thank you for the plane script but there was no altitude in there.. planes kept smacking into mountains on Lythium.
Is there a way to set the aircraft to go to a marker on the map and just loiter?
@drowsy axle then it's not "arguments for forEach" ? it's script variables used in forEach?
Yeah, sorry.
private _myVar = 5;```
@tough abyss why setVelocityModelSpace is not highlighted, what is this blasphemy? The highlighting library that discord uses is not maintained anymore. I made a PR adding new commands over a year back. They don't accept PR's anymore.
fellas, got a question again. actionKeysNames 'revealtarget'; gives me """T""" ... is there any way to grab just the T? even if i use splitString """"; after, i still get "T"
i'm using it in a custom text, in which it is then shown as "T", which is not what i want
hint call compile actionKeysNames "revealtarget"
exactly what i want. thanks.
now i just need to find the correct text color. based on my profile namespace variables it should be "gui_bcg_rgb_.." but it's too dark
ah, nevermind. it'll do it
welp, obviously it is darker.. the background color is darker as well
however if someone will have 2 or more keys bound to this action it will give an error
only works for single key
There is a reason the keys are in quotes because the result could be "A" or "Left" for example
or "Space" or "Enter" or "Middle Mouse Btn."
it's showing like that in the hint text, though
which is what i want to mimic
this sucks
is there a way to replace the "" with [] ?
then i dont mind about it. it's really only the "" that is bugging me
or i'll just call it "reveal target" .. then i skip that whole stuff
Hi, I am new in the community of ArmA 3, and then, after playing some campaigns (I left them half-heartedly, since the mods were not very compatible ...) and I would like to do missions, I know the basics, but I need a Necessary piece, how do I make an activator that creates missions or activate them? Thanks in advance
an activator that creates missions or activate them
what?
I mean, for example, you talk to a person, like a mission, and this one activates another besides completing the previous one
oh allright, I guess you mean the tasks, like when you press J button
I guess you need these
thanks very much , sorry for my english , i'm a noob spanish XD
yeah it's allright, they just call it task in functions, not mission
ok thanks
To add scroll menu actions to objects you must use this
https://community.bistudio.com/wiki/addAction
thanks , i know that
I have amount1 + amount2 which gives me result1 that i compare to neededNumber (bigger as or equal). After that, i want to make sure i get only the needed amount to reach the neededNumber. Quick example:
_s1 = 17
_s2 = 5
needed = 20
restult s1+s2 = 22
My thought was i would do result minus needed, then i would do _s2 minus newresult to have a final result which the amount is.
Would there be a simpler way? Or a command in arma 3 where i can test how much a number exceeds the needed endresult?
are you talking about min max commands?
(17 + 5) min 20 will return 20 even if the sum is 22
if not I have no idea what you need then
_unlimited = 20;
_playerHas = 7;
_isAlreadyBox = 15;
_playerMustPay = ?;
The _playerMustPay should be 5, because thats the amount that you need to reach _unlimited. So the player does not have to play the other 2 (_playerHas is 7). Currently i just do it with a not so big mathematic line. But maybe there is a command already that i can use to figure out how much something exceeds. Like 7 + 15 = 22, so the excess amount from the 7 is 2.
I hope i am not too confusing XD
haha, i mean my script works like a charm and if i have to write 2 lines or 1 line, isnt that big of a deal. :3
Would anyone know how to allow clients to interact with doors via an object spawned with createVehicle? The host can open doors of buildings, clients can see the action, but the doors only open for the host? Am I missing something here?
is this syntax example ok? {WaitUntil{!isNil "PO3_core_init"};}; I think that second to last semi-colon might be the issue but there are a lot in this script im trying to debug and dont want to waste time deleting all of them if its correct.
@hushed lagoon Cant you have blue? ^^ Well, if i am correct you probably didnt make the action opening the door global. I guess that you open the door on a local_client. If you havent, already, maybe look into https://community.bistudio.com/wiki/remoteExec
Maybe thats the solution to your problem.
@keen bough, I did not add the action, it's the default one that comes with the building. I'm not sure how I would do that if I don't have access to the action code.
I try to understand it - so you want to be able to control a door withing or via a vehicle that was spawned with said commands. The created vehicles is used but only the door-open basic action is seen by host as well as the door opens only for the host?
Do you have any form of code eventually? I am not a pro-scripter but i may see eventually something.
This code is spawning compositions I have saved, the _type would be 'Land_Cargo_HQ_V1_F' for example { private _type = _x select 0; private _offset = _x select 1; private _newDir = _x select 2; private _obj = nil; _obj = createVehicle [_type, [0,0,0], [], 0, "CAN_COLLIDE" ]; [_source, _obj, _offset, _newDir] call BIS_fnc_relPosObject; _obj setPosASL [getPos _obj select 0, getPos _obj select 1, getTerrainHeightASL getPos _obj]; _obj setVectorUp (surfaceNormal (getPosATL _obj)); _compositions append [_obj]; } forEach _composition; It also breaks vehicles, not sure why. As I use the same createVehicle line of code elsewhere and it works fine.
@slate gull the part you sent looks okey. But no way to tell if your full script is okey without seeing the full script
Thanks. Yeah i was just wondering about those semi-colons inside the end brackets. They looked out of place and since there are so many of them in this particular script i just wanted to confirm.
Don't need semicolon at end of code piece
{waitUntil{!isNil "PO3_core_init";};}; is just as valid as
{waitUntil{!isNil "PO3_core_init"}}; and also as valid as
{WaitUntil{!isNil "PO3_core_init";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;};;;;;;;;;;;;;;;;;;;;;;;;;;;;};;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
lol, ok. Thank you that is actually more helpful, now i dont have to wonder about it if i come across something like that
ACE/CBA also uses missing semicolon at end, to indicate that this line of code is a return value
Ok. Thanks for help. You guys are awesome
@hushed lagoon sadly i am not too fond to break that up. But i am very sure, the keen eyes uf @still forum for example may spot something.
For me it just looks very fine (but i tend to oversee things)
Ewww... wtf is that code man
psch, be nice! Else i take away your hot chocolate.
{
_x params ["_type", "_offset", "_newDir"];
private _obj = createVehicle [_type, [0,0,0], [], 0, "CAN_COLLIDE" ];
[_source, _obj, _offset, _newDir] call BIS_fnc_relPosObject;
private _newPos = getPosASL _obj;
_newPos set [2, 0];
_obj setPosATL _newPos;
_obj setVectorUp (surfaceNormal _newPos);
_compositions pushBack _obj;
} forEach _composition;
Okey now we can get started. What was the problem again?
Ah the actions don't work.. No idea. Don't see any problem in the code that would cause that
1762 lines of code (-20% empty lines for separation) ... this shop-script is a hell lot a work. YET! Not a single error.
Split into multiple files :U
already did, this is just the script where you pay. It checks for so many things and a lot of things are just redo-writings. Basicly the script is extremely simple ^^ But there are so many items, price-checks, is it unlimited, will it be unlimited, and so on.
having it near realistic has a price. And its more or less a lot of preparation work
there is no price involved in that ... just basic data
if the script has 1762 lines of code, you got a hell lot of stuff you should rewrite entirely
yep, but sadly for some cases i didnt find well made tutorials. So i am left hanging and i am going with more line of codes until i figured out stuff myself 😃 i can easily rewrite that stuff then ^^
oh, and a lot of the lines are documentation 😃 i am not like most guys that have snippets but extreme well documented scripts :3
if you indeed need tutorials then you should not rewrite stuff
That's how I most often learn things. I build stuff, then improve my skills while doing that. And then later see what garbage I produced and rewrite everything 😄 and while doing that improve my skills again by seeing what I did wrong
don't we all, scared by the output of our previous self we are forced to improve…
How to I make a forEach iterate early?
Like continue in Java etc.
exitWith will kill the whole loop right?
{
if (condition) then {
stuff
};
} foreach [];```
there is no continue command, however you can skip elements that dont meet ur condition like this
yes exitWith exits the loop
https://community.bistudio.com/wiki/breakOut @ornate sky
this one should work
Or use findIf
once you return true, it stops iterating
{
if (condition) then {
stuff
};
} foreach [];
Same as
[] findIf {stuff; condition}
ugh syntax highlighter doesn't know findIf ^^
nah
he wants to skip over certain elements:
foreach (auto iterator in new int[] { 1, 2, 3, 4, 5 })
{
if ( iterator % 3 == 1)
continue;
// stuff
};```
breakOut needs labels and I think the simplest thing is gonna be an if
I meant the scopeName
oh.. mixed up continue and break ^^
I got mixed up in Java, suffice to say, the if is gonna do the trick this time.
You can call another scope inside the loop and exitWith that if you want to skip but the fastest of them all will be if (cond) then {... without else
Huh! Curious if it is as fast
technically should be faster than if. Less values allocated, less script commands. Just doesn't know if it errors if code doesn't return a bool
would expect it to error @still forum
soont™ stuff like this can be checked in SQF-VM sqf test cases
That is, if the test cases are actually correct 😄
well ... all added until now are confirmed with arma itself: https://github.com/SQFvm/vm/tree/master/tests/sqf
Okey yeah. Throws a type error on non-bool.
But dunno if that kills the loop or if it just continues running
uff ... crap
forgot to double check that stuff in arma for count already 🤦
because if it continues to run, it just is a warning
Never understood how arma error handling really works. Sometimes errors kill your whole script. Sometimes it just continues running..
Nah there is no info about that in the command
implements not in the struct
Maybe scheduled vs unscheduled. Or it depends on what callstack level or whatever
presumably some check deep down the ground
but you do not want to follow that rabbit hole
or you discover eternal doom
Don't follow the white rabbit
Could somebody please check what the output of this is?
{
private "_i";
if (!isNil "_i" && {_i isEqualTo 1}) then
{ diag_log true; }
else
{ _i = 1; diag_log false; }
} foreach [1,2,3,4,5]```
well, () && {} is faster if you need to return boolean, but if you don't but forced to do it to avoid error, if () then {} is obviously faster as you don't have to return anything
you mean return boolean inside the code of the && {}? not return boolean to the forEach
yeah it expects boolean from {}
have you tested if it exits the loop after the first error?
Maybe one can just keep using it despite puking out errors 😄
except if you have -noLogs 😄
doesnt even run once
ah no had spelling typo
yea runs the loop with errors
you can return nil
bool or nil
that's fine no error
{(_x != 10) && {a = _x}} foreach [1,2,3,4,5,6,7,8,9,0] error
nil works? good to know.
so yeah I think usable but need to keep in mind assignment
Well last example returns nothing. That is.. Eval error? Or Generic error
3% faster
Hey my besties.
I have a dialog gui showing up and would love to blur the background to receive more focus on the GUI.
https://community.bistudio.com/wiki/ppEffectCreate
Found that but it looks like it will apply effects to the whole. Is there a way to blacklist Dialogs/Controls from that? Or another way at all to add that feature?
Always thought it only applies effect to actual game rendering, not dialogs and such 🤔
Yeah, same here, have you actually tried it or you assume?
Found that but it looks like it will apply effects to the whole - I assume by reading the biki that it affects the whole (game rendering)
or is game rendering != dialogs ?
Ah wait 🤔 when hitting ESC and pausing I am looking at Dialogs while the background is blurred
💡
Yeah, same here, have you actually tried it or you assume? @tough abyss nah at work atm so can't test stuff. Was just reading about the command in biki
allowedQM isEqualTo allowedAdmin; that line does nothing
Other way around?
no
currentQuarterPlayerLoadout = currentQuarterPlayer setUnitLoadout currentQuarterMasterLoadout;
makes no sense. setUnitLoadout doesn't return anything
if ( allowedQM find (getPlayerUID (_thisList select 0)) )
if takes a bool, find returns a number
if you just want to check if the playerUID is in the array. Then just use in
Also trigger condition requires a bool. You return a IfType
Changed.
_triggerQuarterMaster = createTrigger ["EmptyDetector", _posQuarterMaster, true]; Missing ; Getting this error.
Why do you think that is?
Okay, so it works, code wise. ```sqf
allowedAdmin = [
"76561198079984427" // Capwell
];
allowedQM = allowedAdmin;
EC_QuarterMasterSystem = {
currentQuarterMaster = nil;
currentQuarterMasterLoadout = nil;
currentQuarterPlayer = nil;
_posQuarterMaster = getPos QuarterMasterPos;
_triggerQuarterMaster = createTrigger ["EmptyDetector", _posQuarterMaster, true];
_triggerQuarterMaster setTriggerArea [1, 1, 2, true];
systemChat 'Setting up QuarterMaster Trigger';
sleep 1;
_triggerQuarterMaster setTriggerActivation ["ANYBODY", "PRESENT", true];
_triggerQuarterMaster setTriggerStatements [
"this",
"
currentQuarterMaster = (_thisList select 0);
currentQuarterMasterLoadout = getUnitLoadout [currentQuarterMaster,true];
systemChat format['Current QuarterMaster Loadout: Transmitted. %1 %2', name currentQuarterPlayer,currentQuarterMasterLoadout];
",
""
];
_posQuarterPlayer = getPos QuarterPlayerPos;
_triggerQuarterPlayer = createTrigger ["EmptyDetector", _posQuarterPlayer, true];
_triggerQuarterPlayer setTriggerArea [1, 1, 2, true];
systemChat 'Setting up QuarterPlayer Trigger';
sleep 1;
_triggerQuarterPlayer setTriggerActivation ["ANYBODY", "PRESENT", true];
_triggerQuarterPlayer setTriggerStatements [
"this",
"
currentQuarterPlayer = (_thisList select 0);
currentQuarterPlayer setUnitLoadout currentQuarterMasterLoadout;
systemChat format['Current QuarterMaster Loadout: Received. %1 %2', name currentQuarterPlayer,currentQuarterMasterLoadout];
",
""
];
sleep 4; systemChat 'DEBUG: Triggers are now being deleted.';
deleteVehicle _triggerQuarterPlayer;
deleteVehicle _triggerQuarterMaster;
};``` However, currentQuarterPlayer / currentQuarterMasterLoadout etc. return as any, for both triggers.
_thisList is nil inside the trigger
So how do I fix that?
thislist
Hey have any of yall used something like initInspectable to make a cell phone inspectable and show a text message when inspected? Or something of the sort?
That's not a thing but addAction would be a good bet.
Oh neat. Had no idea that was a function. I'd probably still use addAction anyway.
Word.
I figured it out.
The documentation is less then stellar but meh.
Its pretty easy though.
Is there a place at all that has the pixel sizes for screen images?? Like to use something for a laptop screen for it to effectively not be over sized it needs to be 1024x1024 pixels or something like that?
depends how the screen is unwrapped
textures always need to be power of 2
but the area used might not cover all of it
I dont think it works like that
i dont get it from the current example that i found. Could someone explain me, how i take a variable from one script, to the next one?
As Example:
_mapleSirup = "Delicious";
_notMapleSirup = "Bleh";
["script2.sqf"] remoteExec ["execVM", 2];
I just want the _mapleSirup variable to be taken into the next script.
@jade oracle throught script? Execute it on the server and create the unit every 30 seconds. You should probably look into https://community.bistudio.com/wiki/call or https://community.bistudio.com/wiki/spawn as well as in https://community.bistudio.com/wiki/remoteExec
Got the solution to my own problem.
[[var1, var2, ...], "script.sqf"] remoteExec ["execVM", 2];
forgot the []
class TG
{
tag = "TG";
class server
{
file = "filepath\folder"
class theScript {};
?question?
};
};
Okay. The first "class"-Tag is used so i have to write, as example "TG"_fnc_myScript or if it said class boob i would write "boob"_fnc_myScript. Right?
tag is furthermore the definition of the class before. If i name the class "abc" but the tag "def" i would have to write "def"_fnc_myScript, am i right?
Next up says class server. Which means, that this is the folder-name and with file = we define where the folde is. Am i still right so far?
now comes class "myscript" where i use the function. I name my script fn_myScript since arma would not know that this would be a function withouth the fn_ part, right?
The "?question?" is also this:
Where do i put the second function? Right under the old? Like just another "class myScript2"?
... guys, why do i even ask here? I mean, really? I put in a question, i figure things out shortly after. But if i dont ask, it takes me days. Is this some form of programmers curse?! ...
Yes
That's how you learn new things. Figure it out how not to do. Give up. Ask the question (you actual want someelse to understand so you think in other ways). Solution is in your mind. That is how it is done.
Hm, the list-script (containts all the lists for magazines, weapons, vehicles) is just big because the lists kinda big. Should i split up for vehicles, items, weapons and so forth or should i put everything in one function script?
Return value is basically whatever. Magazines is the magazine bullet count, vehicles is if its east/west etc.
@keen bough I put in a question, i figure things out shortly after. It's called "Rubber duck debugging"
There is a saying to this? hah, nice ^^ thanks
Hm, the list-script (containts all the lists for magazines, weapons, vehicles) is just big because the lists kinda big. optimally you generate the list on-the-fly from config
Not just a saying https://en.wikipedia.org/wiki/Rubber_duck_debugging
Ah, i have more detailed lists as i need them for very specific tasks. Since i have to have high-tech and lo-tech as well as basic-tech split up and such.
End of switch do. Do i write
default: _myStuff =
or
default _myStuff =
?
Example only shows me code with hint.
Example only shows me code Yes because default is a command that takes code
you need to give it code
https://community.bistudio.com/wiki/default same as here
a basically for me
default { _theResult = "Error"}; thanksies.
Or just "Error", I believe you can store the result for the switch statement if you store it in a variable
Interesting. If i dont forget it, i will test it as i test the functions.
Need a quick help. Can someone send me the Arma 3 dta/bin.pbo via discord DM?
Don't wanna remote boot my home PC to grab it
@still forum Would, if the file limit wasn't 5mb via discord. Want it through gdrive?
Narsiph is already sending it to me. Thanks o7
👌
Now I can do Arma stuffs at work 😄
That’s what BI devs say
Is there a difference in defining a variable? example: i want to define _X to use in an array. it is going to take the properties of tz_blacklist. so can it be written tz_blacklist = _X or does it have to be _X = tz_blacklist ?
one assigns _x the other assigns tz_blacklist
so yeah.. there is a difference
and no. the computer cannot read your mind and figure out what you want. Thats why we have syntax
Hmm. Already glorious 16 functions defined and finished roughly a third of them already. Sooooo much easier.
What are the scripting functions we have to interact with player's ragdolling state? Ideally I'd like to get this state and disable in some situations.
Afaik there are none
setUnconscious triggers ragdoll for a few seconds, but that's the only command about it
no getter, no real setter
if I setPos will it stop player's ragdoll?
ragdolling after what? being killed?
or maybe switch animation to previous 🤔
I was thinking how to disable this BS when you touch a car with your finger and start ragdolling
ragdoll cannot be stoppd. There is a hardcoded X seconds timer
That also runs locally on overy players machine
I mean. Stopping after it started
Damn that's sad but thanks
Are you totally sure it's not scripted somewhere? Then we could intercept it?
Too deep for intercept. You can start ragdoll. But not stop it after it was started
Captain Kirk:
- Too deep to intercept. We can start ragdoll maneuver, but we cannot stop it once it is started...dramatic music
Thanks @still forum. i just found the error in the script ive been staring at for days. thanks to you
idk if any of you know this, but there was this once scene in the 2013 godzilla movie where they do a halo jump and the guys have this red smoke on their foot. I wanted to try n do that so im using attachto and createvehicle to create and attach a smoke on to the left part of a players foot. But I noticed something that I couldnt spawn modded grenades. I can use this to spawn vanilla smoke grenades but I can say spawn the optre yellow smoke grenade
works
_the_thing = "SmokeShellRed" createVehicle (position player);
doesnt work
_the_thing = "OPTRE_M2_Smoke_Yellow" createVehicle (position player);
also doesnt work
_the_thing = "ACE_M84" createVehicle (position player);
any idea's why? Im in the virtual arsenal map so im not sure if that would cause issues
SmokeShellRed inherits from SmokeShell and
ACE_M84 inherits from HandGrenade
try it with ACE_M14
okay ill try that
Is it better to include a separate script in your config by using "execVM" or "#include"??
_className = _this select 0;
test3 = _className;
switch true do {
case (_className in _25rndMagazines): {_theResult = 25};
case (_className in _30rndMagazines): {_theResult = 30};
case (_className in _40rndMagazines): {_theResult = 40};
case (_className in _44rndMagazines): {_theResult = 44};
case (_className in _45rndMagazines): {_theResult = 45};
case (_className in _50rndMagazines): {_theResult = 50};
case (_className in _75rndMagazines): {_theResult = 75};
case (_className in _100rndMagazines): {_theResult = 100};
default {_theResult = "Error"};
};
_theResult
But i dont get _theResult. If i do test4 = [_name] narS_fnc_listMagazines; nothing happenes. But test3 gives me the magazine name which was clearly brought into the function correctly. Am i overseeing something with the case or switch do?
use private "_theResult"; before the switch; else the variable is only declared in the case scope
So before the case i define the private variables? I did before the block now
private ["_theResult"];
That correct, please?
for example yes
okay, running new tests.
uff, works. Thank you Lou! So in every function i should private all variables, would that be correct too?
yes, that would avoid any other script interference
so, as a save-run, i would private all local variables in any function/script to be safe and i still can give them to another script if needed with arguments? Just want to make it sure so i dont learn it wrong :3
(Of course, not global variables ^^)
What is the ingame command to find the texture of the object your looking at? I remember its something like getobjecttexture but not sure
@keen bough yes, no probs 😃 names are just references to values, you can name them and pass them as you will
there is like a cusor target or something on the start and im not sure what that is
Ah, okay - last question because i am unsure about the topic (harder to understand english than german). If i have a private variable and that variable has multiple use (like getting variable updates) within the same script. Does the private variable setting not forbid an update?
context?
like private _a;
_b = 1;
_a = 1;
_a = _b + _a;
_a = _a + _a;
private does not make the variable readonly; it just says "the variable exists in this scope (script) only, and will be deleted once exited"
ah, so i can do all kinky things to the variable and have no problems if i call functions with the script that use the same variable in the new called function (bot both private, so they dont interfere)? If thats correct i have understand it XD
private _a = 1;
_a spawn {
_this = _this + 1;
hint str _this; // 2
};
hint str _a; // 1```
same as sqf private _a = 1; _a spawn { params ["_a"]; _a = _a + 1; hint str _a; // 2 }; hint str _a; // 1
yes, since spawn is a new instance :3 i understood it ^^ wohooo! Can we now get drunk? 😄
@winter rose do you actually know the full command for getting the texture? its not working for me
yeh but what do I do with that?
place down kickass ship. Name the ship "assKick" and do it like
myGlobalVariable = getObjectTextures assKick;
or
_myLocalVariable = getObjectTextures assKick;
@torn kite
hm, getCursorObject or something, i dont know all the commands, would've to look it up.
Could someone help me out with this error:
_selectFirstFirstStr = [_select>
0:18:01 Error position: <;
_selectFirstFirstStr = [_select>
0:18:01 Error Missing ;
0:18:01 File C:\Users\Jack\Documents\Arma 3 - Other Profiles\Lt%2e%20Capwell\mpmissions\EC_Training.hebontes\initPlayerLocal.sqf, line 33
0:18:01 Error in expression <ectFirstThird, '"'] call CBA_fnc_replace;
_selectFirstFirstStr = [_select>
0:18:01 Error position: <;
_selectFirstFirstStr = [_select>
0:18:01 Error Missing ;
0:18:01 File C:\Users\Jack\Documents\Arma 3 - Other Profiles\Lt%2e%20Capwell\mpmissions\EC_Training.hebontes\initPlayerLocal.sqf, line 33```
EC_uuid = [
["76561198079984427", 2400, "LT"], // Capwell
["76561198057050881", 1700, "SGT"], // Skid
["76561198054232175", 1800, "SSGT"], // Jagged
["76561194014843973", 1700, "2LT"], // ViBro
["76561198007468329", 1600, "SSGT"], // Kage
["76561198799159646", 1100, "PVT"], // Darky
["76561198101994293", 1600, "CPL"], // Passos
["76561193907264988", 1600, "SSGT"], // Irish
["76561198323567243", 1100, "PVT"], // Andronov
["76561198067428987", 1300, "PVT"], // AtomicVenom
["76561193764413242", 1100, "PVT"], // Classicsss
["76561193859459179", 1200, "PFC"], // Dannn
["76561193721197702", 1100, "PVT"], // Kampfkruemmel
["76561198450220482", 1400, "CPL"], // Farmer
["76561198063303666", 1400, "CPL"], // Oliver
["76561198132446948", 1000, "REC"], // Shuzurrow
["76561198354092237", 1000, "REC"], // Temperz
["76561198137961331", 1300, "PVT"], // Anton
["76561193766117918", 1100, "PVT"], // Viktor
["76561198133724195", 1400, "CPL"] // Will
];
_selectFirst = (EC_uuid select 0);
_selectFirstFirst = (_selectFirst select 0);
_selectFirstSecond = (_selectFirst select 1);
_selectFirstThird = (_selectFirst select 2);
_uid = getPlayerUID player;
_index = EC_uuid findIf {(_x select 0) isEqualTo _uid};
if (_index > -1) then {
[player, _selectFirstSecond] call grad_moneymenu_fnc_addFunds;
hint format['Your UID: \n %1 \n Operation Paycheck: \n %2 CR \n',_selectFirstThird, _selectFirstSecond];
[player, _selectFirstThird] call CAP_fnc_rankSelect;
hint format['Your UID: \n %1 \n Rank: \n %2 \n',_selectFirstFirst, _selectFirstThird];
} else {
hint "Your UID has not been entered into the Payment System, yet... A log of your UID has been made.";
diag_log format["----------------- [[[UID:]]] %1",_uid];
};```
Rather than whatever you're doing there... ```sqf
_uid = getPlayerUID player;
_index = EC_uuid findIf {(_x select 0) isEqualTo _uid};
if (_index > -1) then {/do things/} else {/don't do things/};
Okay, thanks. 😃 Doesn't fix my issue though.
Looks like your semicolon isn't actually a semicolon (or whatever is making  show in there)
i forgot the command to check the base weapon. You know, you get weapons witch attachements like "rifle+optic+anotherthing" and you can do
_baseWeaponClassName = checkForBaseName "thisweapon-with-stuff-on-it-classname";
Know what i mean? 😄
found it! BIS_fnc_baseWeapon
I have a problem with some objects duplicating and staying behind after attaching and detaching it. I want to have the Nimitz list at an angle, at times it works, at times it doesn't work properly. The current script is at https://pastebin.ubuntu.com/p/pTzKv6yhCf/ and an example of the problem is at https://www.dropbox.com/s/1zvv6la81eprej2/listProblem-small.jpg?dl=0
any ideas what might cause this duplication? It seems to go away when editing the mission objects again and again, but I cannot detect a pattern
Can RscObject be used in .sqf based interface without a .hpp or description.ext defining the object? Tried ctrlSetModel and had no success.
Have been able to write an interface using 2D stuff like background, buttons, text, and listbox without a .hpp or description.ext
No luck with RscObject though. Trying to do it within a display
@slate gull
Is it better to include a separate script in your config by using "execVM" or "#include"??
You can't include scripts in configs using #include. Configs and scripts are entirely different things
execVM is also bad. Use CfgFunctions if you call a script more than once.
@keen bough when you are assinging a variable anyway use private _var = x
instead of
private "_var"
_var = x
The first variant is called private keyword and is ♾️'ly faster
Well i dont know if that applies to any config that isnt config.cpp. To be more specific, i am trying to get a blacklist to work on my server where it reads what pbos the player has loaded and compares them to what is on a already defined array of banned mods. So in the "blacklist_config.sqf" script has all the banned mods defined and in "blacklist.sqf" is where the script is that does has the actual function of comparing the names. So in my blacklist_config i have it as calling up "execVM "blacklist.sqf"; and i was wondering if there is a better way. I know it calls it up because of the hints i put in it to tell me how far along it gets show up on the screen when i load in. But when i load in with a banned mod it doesnt kick me the way its supposed to.
add diag_logs to your blacklist.sqf and see why it doesn't kick you
How would i implement that?
@slate gull https://community.bistudio.com/wiki/diag_log
i kinda check my stuff with "hint" or systemChat so i know where i have to look
and i can put that at the top of the script?
no
everywhere
diag_log logs one line into the RPT
throw it everywhere in your script where something interesting happens. So that you can see exactly what your script is doing
ok. and then where do i look to find the logs to observe what happened?
https://www.google.com/search?q=Arma+RPT
https://community.bistudio.com/wiki/Crash_Files
%userprofile%\AppData\Local\Arma 3
ok. thanks. will def look into it
How to get array classnames of all available vehicle (Planes tanks ifv helis )?
with my current mods?
like this one
private ["_air","_land","_veh"]; _air = []; _land = []; _veh = ""; { _veh = configName _x; switch (true) do { case (_veh isKindOf "air") : {_air pushBack _veh}; case (_veh isKindOf "car") : {_land pushBack _veh}; case (_veh isKindOf "tank") : {_land pushBack _veh}; }; } forEach ("true" configClasses (configFile >> "CfgVehicles")); copyToClipboard format ["Наземная техника - %1",_land];
Solution
private _air = [];
private _land = [];
{
private _veh = configName _x;
private _isLand = (_veh isKindOf "land");
private _isAir = if (_isLand) then {false} else {(_veh isKindOf "air")};
if (_isAir || _isLand) then {
([_land, _air] select _isAir) pushBack _vec;
}
} forEach ("getNumber (_x >> 'scope') == 2" configClasses (configFile >> "CfgVehicles"));
copyToClipboard format ["Наземная техника - %1",_land];
Better solution
Your solution will also list classes that are not spawnable. Like... "car" and "tank" and "air" and all the other base classes.
Also my version is "slightly" faster
HI everyone.
Im trying to make a mission where your players spawn in, in a random place on the map, spawn different objects/barricades that can then be moved with ALiVE or some sort of move/drop script. and then just have unlimited waves of enemies spawning. The spawning part I have to tackle at some other point. Right now i've just set it up with /show/hide modules)
I'm pretty new to arma scripting and dont even know how to begin with how to let the game find a random place to spawn(or let the command player pick one if that is easier) or how to do the random spawning of movable objects. (so you can go around and scavenge to fortify a makeshift base or whatever)
Im sorry if this is way to much to ask. and Im not expecting someone to just dump me the solution, but any pointers would be helpful 👋
Look for an existing Deploy and Defend mission and see what they are doing for a starting point.
So for the random spawning I could Make an object spawn at some random markers I place on the map ( or script the markers to be placed at random at a safepos?)
and then tie the players to that object and spawn them in after. ill give that a try first!
Thanks
So i've found multiple ways to do the spawning in. The object I want my players to start at are randomly spawning on one of my invisible markers (yay). I want my players linked to the camp though. I thought I could just take the group leader and sync that to the object but that doesn't work. I then found some people talking about giving my leader a varaible name and running a script (I reckon it would be written in the int.sqf and one of them write this:
"_x setPos getMarkerPos ""marker_1" "" forEach units bravo"
What is "_x" referring to ? I guess I just dont understand the underscore X part of it. liek I dont have anything called "_x"
sus
in this instance, it's the currently tested variable when running through the array you gave forEach
Yea
so, say the array units bravo contained: ["BLAH!","BLah!","BLOO!","AAA"]
It would iterate through "BLAH!", "BLah!","BLOO", then "AAA"
_x contains whichever element it's testing
Yes
Yes
I don't know if a count loop is still the fastest or not though. ForEach is slower than count. But when using count, your condition has to return true (in order to return evaluated element)
I want to make the players in my server see what I say with systemChat, but my friends say they don’t see the message?
Only i can see it
Like its not global
Idk
doesn't have global effects yeah
Will try later, ty
ah ha. ill have to try working with that and doing some stuff 😃 cheers
alright. got it working. Justr wondering. who does the _x need curly brackets when the this = setpos (for example) can just run without?
im asking because im not always sure when it need to be curlied or not
Ok, so I wanna use the "findsafepos"
and I've tried this:
_pos = [_MiddleMarker, 1, 15000, 3, 0, 10, 0] call BIS_fnc_findSafePos;
campfire setPos [getPos _pos];
so my thinking was that the _pos would be defined from ´the middle of my marker and 15 kilometers out adn then I would use that location to setPos my campfires location. But it just tell me "undefined variable in expression"
Im guessing I dont get a hold of my middlemarker properly but what do I look up to go on from here?
BIS_fnc_findSafePos returns an array in format [x,y], setPos accepts this, not sure what your [getPos _pos] is for
I thought I had to move that result I get from BIS_fnc_findSafePos to my setpos by telling it that I could get it from the _pos but I can just straight up do setPos _pos?
Yup. Should work
Alright. And am I calling my marker correctly or is there a better way to do that? Right now it doesn't work unless I use an object
If _MiddleMarker is a marker, the first parameter of BIS_fnc_findSafePos has to be an Object, Position, or an empty array https://community.bistudio.com/wiki/BIS_fnc_findSafePos. You'd have to use getMarkerPos to get the position of the marker and then use that as the first argument instead.
Cheers mate. Ill get it working
Sorry, maybe im just stupid, but it is true that I cant run a sleep in an objects init before it runs?
@leaden parrot https://community.bistudio.com/wiki/Initialization_Order
Object Init Event Handlers are called All Unscheduled
Unscheduled < so... no you definitaly can not sleep in unscheduled
What do you want to achieve? Probably you need to spawn some code in which you can sleep and then run something, but then your objects will not initialize in a synchronous manner, but probably you don't care about it anyway if you want to sleep there
👉 👉 that would be my problem then.
So i have crate and some other object that I want to spawn next to my campfire. right now I just have this in each of the objects inits
this setPos [(getPos campfire select 0) + 0, (getPos campfire select 1) + 5, 0];
to tell it where to be placed realtive to the campfire, but I want it to be executed after the script have chosen a random place 😃
so you have another script that generates the position and this position must be passed to the script in init field of multiple objects to place them?
If so, placing your code in the init field is a wrong approach
Instead you should run your code in init.sqf
Just give names to your objects and manipulate them from one place (init.sqf)
well... maybe you can also manipulate them all from init field of one of the objects... I would prefer init.sqf though
my code is running in my init, and those objects are placed inside the ditor with that line in their init field.
so I would then just call them one by one and apply their respective line of code?
dont know enopuhg about arrays to do a foreach for each of the objects and let it choose a lione of code.
ugh... it's hard for me to tell without seeing the architecture of all your code
You know you double click on an object in the editor, and type something like obj_0 in 'Variable Name' field?
then the game will make obj_0 a global variable with object handle of this object, which you can access later
just put the code here, no?
sure thing
_markerpos = getMarkerPos "MiddleMarker";
_pos = [_markerpos, 1, 15000, 1, 0, 5, 0] call BIS_fnc_findSafePos;
sleep 0.5;
campfire setPos _pos;
sleep 2;
{_x setpos (getpos campfire)} foreach units Bravo1;```
I just simplified it so it's just 4 tents
so... why does it need sleep then?
The first sleep was becuase I got a weird bug with the findsafepos where the player and AI would always get launched into the air. The sleep fixed that. the second sleep is just for me to be able to see whats going on
Then I have my 4 tents in the scene called; Tent_N, Tent_W, Tent_E, Tent_S
and I want them to be placed accordingly with their init line:
this setPos [(getPos campfire select 0) + -5, (getPos campfire select 1) + 0, 0];
this setPos [(getPos campfire select 0) + 5, (getPos campfire select 1) + 0, 0];
this setPos [(getPos campfire select 0) + 0, (getPos campfire select 1) + -5, 0]; ```
So i would just do a Tent_N = setPos [(getPos campfire select 0) + 0, (getPos campfire select 1) + -5, 0];
for each?
hmm no, you would do
Tent_N setPos [(getPos campfire select 0) + 0, (getPos campfire select 1) + 5, 0];
just four lines for four tents
Tent_N setPos ...
Tent_S setPos ...
Tent_E setPos ...
...
roger roger.
would it make sense to do it with a foreach if I had like 20 items and then letting it sort the lines out accordingly?
sure, IDK if you really have four or four hundred 😄
so why is it sometimes "tent_N setpos" and other times with the equalssign? what determines that? Sorry for all the noob coding questions
Do you have to put them at some distance around campfire in a uniform pattern? If yes, you can do like...
{
private _angle = _foreachIndex * 45; // 45 degrees per object
private _pos = _posCenter getPos [15, _angle]; // 15 meters from center, at given angle relative to North
_x setPos _pos;
} forEach _objects;
WHere did you see it like object = setPos ... ?? It's a totally wrong syntax and makes no sense, setPos returns nothing, and takes one argument on the left and one on the right
https://community.bistudio.com/wiki/setPos
yeps that exactly what im doing. just so it not all cramped up. I just want a cargo box, a a whiteboard or whatever for some addactions and hescowall around the campfire
okay sorry, so setpos was just an example. its just looking and some of the init coding in the editor I sometimes write "this = setpos" but writing scripts outside of it does not need an equalssign
It neither needs an equal sign inside an init box or outside of it or anywhere at all 😄
I mean setPos syntax is the same everywhere
Probably setPos was launching your team members into the sky because you were setting their position to exactly the same place, then simulation would start up and produce weird effects because it had many objects at exactly the same coordinates
oh yeah. forget about setpos. cant come up with an example where I used it right now haha, just saw that sometimes it needs the equalssign and sometimes not.
the script you just pasted in. why did you use the private and not just make up a new name for the variable?
ah, so if I give my unit move line a random distance from the position instead it shouldnt be an issue I guess. I've read anout that somewhere today!
ill find it haha thanks.
why did you use the privateand not just make up a new name for the variable?
there are global and private variables in SQF
you don't want to make global variables without a really important reason
if you do like myVar = 123; then it's global variable
so... you typically want to have all variables private
so the variables I made in te start of my script should be set to private as well ?
also do I jsut comment out stuff with double forward slashes? //
well... in your script you already start var names with _ so it's fine, but typically it's better to have all marked as private
alright 😃 Didnt know that. Thanks
if you just declare them like _pos = [1, 3, 2]; and you call a function my_fnc_findSomePos which has a variable declared as _pos = ... inside it, then it will overwrite the first initial _pos variable in upper scope, it's terrible and thus you should declare variables as private _pos = ...
if you declare both as private, the function you call won't overwrite the variable in the upper scope
also do I jsut comment out stuff with double forward slashes? //
yes,// single line commentor
multi
line
comment
*/```
👌 Thank you so much. I really need to try these things out now and get to know them a bit better. It makes sense im just not the best logical thinker 🙂
ah, so if I give my unit move line a random distance from the position instead it shouldnt be an issue I guess.
probably you can just add some random value to each component of the position and it will do
Question: How do you get the dark box around your messages?
three apostrophes on either side of the message?
ah ok
Lies, I’ve got ` on the same key as ‘
If I create a unit with createUnit and call removeBackpack right after (or any other remove command) the unit still has a backpack. It seems like the units loadout is added sometime after the call to createUnit returns. Does this make sense?
If I wait 2-3 seconds the remove succeeds.
Does anyone know if there is a proper check to know the unit is fully initialized?
afaik it depends on the unit / mod too. some mods have scripts randomizing after init.
dont know of any eh.
if i am correct - when i let a player start a script (press a button whatever) and use "clientOwner" i get his personal ID so i can refer to that within all scripts if i hand it over with params, right?
there were some questions about the recent #perf_prof_branch 1.90.145620 build fix of waitUntil
it fixes the situation when waitUntil statement returns nil, it got stuck on that and cluttered the script scheduler
now waitUntil is aborted and the error message is displayed to the user like some examples below:
Error Type Bool expected Bool
Error Type Any expected Bool
Error Type Nothing, expected Bool
Error Type Obj expected Bool
etc.
@queen cargo ^
Already see it breaking scripts that expected that nil==false in a waitUntil...
Most people probably think "this will exit when I return true"
Now returning nothing is also wrong, while it was valid before. And people also used it before.
waitUntil {variable == 5}
will wait till it's 5, but also till it's actually defined. No need to wait for isNil too.
sqf script errors explode in the distance
😂 😂 😂 👌 👌 @still forum
waitUntil {variable == 5} will wait till it's 5, but also till it's actually defined. No need to wait for isNil too.
No one is using it like this. an undefined variable error is written in the logs every frame
There is no good example when someone want to rely on returned nil but in badly written scripts it will be a hog spamming rpt and holding the script in schedule. At least now it will just abort it with error
mumbles you wanted performance, you got fix and performance, in single package 
uhm ...
private _arr2 = [0,1,2];
{
_arr2 deleteAt _x;
} forEach _arr2;
diag_log _arr2; // [1, 2]
private _arr2 = [2,1,0];
{
_arr2 deleteAt _x;
} forEach _arr2;
diag_log _arr2; // [2]
private _arr2 = [0,1,2,3,4,5];
{
_arr2 deleteAt _x;
} forEach _arr2;
diag_log _arr2; // [1,2,4,5]
private _arr2 = [5,4,3,2,1,0];
{
_arr2 deleteAt _x;
} forEach _arr2;
diag_log _arr2; // [5,4,3]
what's the problem?
thought arma is copying the bloody arrays around
nope
writing some testcases for sqf-vm now ... and got surprised with this
deleteAt is by ref
count has the same "issues"
private _arr2 = [0];
{
_arr2 pushBack _x;
true
} count _arr2;```
it iterates by index.
After 2nd element comes the 3rd.
If you delete a element such that what was 4th is now 3rd. It will go to that
it is an issue 😄
Well... People can always break things if they want to I guess 😄
need to fix SQF-VM now .-.
i just copy stuff around ... because simpler and cheaper -.-
now everything needs the actual arraydata
and additional boundary checks
"because simpler and cheaper"
copying a full array is cheaper than just forwarding a pointer to it?
then adding the whole arraydata to literally all files
- less checks
- everything ...
need to modify ton of commands now
well ... all fixed now
It's an issue because it wasn't the same as sqf-vm 🙃 ?
it is an issue because it just blew my expectations away
SQF-VM already has adapted, an annoyance at best to me 😛
Is there a way to exempt all but vehicle tires from receiving damage?
So the vehicle itself doesn't simply explode?
Yeah you will need to do some voodoo with HandleDamage event handler, but no one really knows how it works
mhh?
HandleDamage is fairly basic ...
though ... you rly are better off to just do:
_veh addEventHandler ["HandleDamage", { [] spawn { /* whatever you want fixed */ }; }]```
as that is simpler
though ... that will break them for a brief moment
@rocky drum Actually it is easier than I thought at first:
_quadbike addeventhandler ["handledamage", {if (_this select 7 == "hitlf2wheel" || _this select 1 == "") then {_this select 2} else {0}}];
you can explode a nuclear bomb on it but only left back wheel can be damaged
Anyone know how to createVehicle but when you do it, the player is inside it, “teleports” inside, cant think of the right word
Ty
does anyone know of a way to get how far into the ground a unit has sunken when they're at a distance?
I hoped getPosVisual (or any of the Visuals) would do the trick, but they give the same result as the non-Visual versions
maybe the ground moves up, instead of the units down
This is what I get drawing some lines around eyePos
https://imgur.com/a/LdOh7yT
oof
Yeah, quite the difference!
quite some high rise eyes they have
Got some problems with a fairly long Script. My if conditions in the While Loop are not Working, also the Countdown-thing doesn't work like it should. Its hard to explain in text, when you look at the Script you know what it is for and what Part i mean. Should i just paste it right in the Channel or do you Guys want it on Pastebin?
Depending on how big it is
Try here, you can delete the message anyway
just do it in the code block
I just realized its to long for Discord, about 140 Lines. Will post it on Pastebin. Wait a Sec
Its a Type of Law Enforcement Mission thing iam currently working on, the Scipt is like a Mission generator.
private "_marker";
_marker = [
No.
private _marker = [
yes.
And for the Record, weirdly enough the first if Condition seems to work. Thx Dedmen btw
what is up with your sometimes private, sometimes not private, and using the bad syntax?
which line breaks?
need to optimize it a bit, not so experienced in scripting. Its like pre-pre-pre-alpha xD
if (debug) don't use global variables with such generic names. If you have a global, then put a tag infront of it.
tag_debug
or use a debug macro 😄
https://community.bistudio.com/wiki/createMarker
page shows using the value returned by createMarker for all the setMarkerX commands. You don't do that here
Line 72
while {true} do
You can never exit that while loop.
never ever.
So line 81 can never be called ever
Oh
why is debug even a global variable, when you define it directly in the script at the top? Why not make it local then.
tryed to fiddle around in the Script trying to get it to work, maybe was Private one before idk
123 if (speed (veh) == 0) then useless parenthesis around veh.
Also I'd say don't check for == 0. Maybe do something like < 2
Ok
" also the Countdown-thing doesn't work like it should" countdown variable is only set once? outside of the loop
meaning it's value will never be updated
so it will also never get 0 if you only grab it once, and do that right at the start of the countdown
call Bis_fnc_selectRandom;
don't do that.
Also choose one style. Don't mix.
Bis_fnc_selectRandom vs BIS_fnc_selectRandom vs bis_fnc_initVehicle
First letter captical. Tag correctly capital, or all lowercase.
Choose one.
I'd say go for the correct variant like it's shown on the wiki and in all BIS scripts which is
BIS_fnc_...
countdown = missionNamespace getVariable "bis_fnc_countdown_time"; That's nonsense. You are already in missionNamespace
that's the same as
countdown = bis_fnc_countdown_time
Also what is that countdown func even?
https://community.bistudio.com/wiki/BIS_fnc_countDown Doesn't seem to exist on wiki
just store the time, and then compare if current time > storedTime+300
for 300 seconds.
so I assume countdown launches a script which runs in parallel. Total waste, don't need that at all. You can just check the time yourself
Ok, will try that, do you thing that solves the Problem with the If-Conditions ?
Don't know which if condition
but global variables that never change, and expecting them to still change won't work
Wait, if i use pre placed triggers on the Map it wont work ?
Don't know where the variables come from and what you do with them
you can also add diag_logs to your script to check what's happening and to debug your problems
How can i do that? Looked on the Wiki page, do i need to Add one at the Start of the Script to use it or...?
at every line where you wanna log something
didn't I tell you that already days ago?
ehm no, on the armaworld forum maybe? I never used the Arma Discord to report my Problems.
Someone asked the exact same thing about putting diag log into first line recently. Dunno where
Whatever, will try your Ideas, will report if anything doesn't work.
Meanwhile.. Dev branch changelog
Added: addWeaponWithAttachmentsCargo and addWeaponWithAttachmentsCargoGlobal script commands
orgasms
O_O omg really?!
<screams in delight>
Gotta find the code now and write docs
god, if that command is somewhere decent it would help me so much ^^
It is. God I hope I didn't overlook anything
//container addWeaponWithAttachmentsCargoGlobal [weaponClassname, muzzle, side, top, bipod, [(primaryMagazine), (ammoCount), (secondaryMagazine), ammoCount], (count)]
//count is optional. you can supply empty array for magazine if you don't want any
Here
that means i dont have to check for grenade launcher anymore?! 😄
Basically the same as for unit only for container?
it seems so
which flaw?
If you want secondaryMagazine. You have to provice ammoCount for the primary. If you provide 0 you'll get empty magazine I assume
Maybe -1 works. I need to double check. but that's certainly something I didn't think about
🤞
Nope -1 doesn't work.
Not fatal, but not good either. Easy to fix tho
yes, not too spectacular of a problem 😃
perfection!
Can anyone throw me a command that has a array argument, with optional values? can't find any on biki 😄
kbTell iirc
YES! thanks
argumentArray1toN (Optional):
I'm supposed to write optional before the colon. already expected that I'm missing that
https://s.sqf.ovh/notepad%2B%2B_2019-04-18_22-42-08.png heh...... yeah man.
Dedmen at job interview at bohemia: "Why do you think that you are the best for this position" well if you'd look into your game binary you'd find my name in there already.
edited my post about the waituntil fix, to make it clear there could be more different error messages
@lavish ocean permission to edit the Dev branch changelog of waitUntil to add instead it now throws a script error to make it more clear?
I'm sure oukej wouldn't mind
well i didn't edit it either with the link to my preliminary documentation of server timeout and votekick settings
new server administration features are also available in the #perf_prof_branch builds, preliminary documentation is in those two posts i made:
https://forums.bohemia.net/forums/topic/160288-arma-3-stable-server-190-performance-binary-feedback/?do=findComment&comment=3350010
https://forums.bohemia.net/forums/topic/160288-arma-3-stable-server-190-performance-binary-feedback/?do=findComment&comment=3351042
perf02 works for vanilla King of the Hill servers! - had session lost before. Im hoping the fix will be distributed to everyone soon. Thanks for the fast and good work! 😘
perf02 works for vanilla King of the Hill servers! - had session lost before. Im hoping the fix will be distributed to everyone soon. Thanks for the fast and good work! 😘
Aaand I found the first flaw. in your intercept one or in dev one?
Both are the same
So it turns out that the blacklist.sqf i was trying to de-bug and get working was just entirely too complicated. And it was trying to call an array from another script which just wasnt working. I just kept chipping away at any things that didnt make sense or just didnt work and eventually succeeded.
It went from looking like this ```waitUntil{!isNil "tz_isExempt"};
waitUntil{!isNil "tz_util_isAdmin"};
// hint "tz_isExempt loaded";
sleep 2;
_name = name player;
_i = 0;
_o = 0;
if (player call tz_isExempt) exitWith{hint format ["Welcome %1 I hope you had a good day Middle Finger", _name]};
if (tz_warning == 0) then
{
{
tz_blacklist = _X;
for "_n" do {
if(isClass(configFile>>"CfgPatches">>_X))then {
_i = _i + 1;
};
};
}forEach tz_blacklist;
if (_i > 0)then{
hintC format ["%1 You will now be kicked back to the lobby", tz_kick_message];
sleep .01;
_o = _o + 1;
if (_o > 0)then{
endMission "END3";};
{
tz_isExempt = _X;
for "_n" do {
hint str format ["%1 was kicked for have %2 mods on", _name, _i];
};
}forEach tz_isExempt;
};
};
if (tz_warning == 1) then
{
{
tz_blacklist = _X;
for "_n" do {
if(isClass(configFile>>"CfgPatches">>_X))then
{
_i = _i + 1;
};
};
}forEach tz_blacklist;
if (_i > 0)then
{
hintC format ["%1 You will now be kicked back to the lobby", tz_warning_message];
sleep .01;
_o = _o + 1;
if (_o > 0)then
{
{
tz_isExempt = _X;
for "_n" do
{
hint str format ["%1 has %2 mods on", _name, _i];
};
}forEach tz_isExempt;
};
};
};```
Eww
to looking like this ```_name = name player;
_X = _blacklist;
hint "Blacklist read";
sleep 2;
if(isClass(configFile>>"CfgPatches">>"bannedMod1")) then
{
hint format ["%1 is being checked",_X];
sleep 2;
hintC format ["%1", _kick_message];
sleep 5;
hintC format ["You will now be returned to the lobby. Have a nice day %1", _name];
sleep 2;
endMission "END2";
};
if(isClass(configFile>>"CfgPatches">>"bannedMod2")) then
{
hint format ["%1 is being checked",_X];
sleep 2;
hintC format ["%1", _kick_message];
sleep 5;
hintC format ["You will now be returned to the lobby. Have a nice day %1", _name];
sleep 2;
endMission "END2";
};
sleep 2;
hint "Congratulations on not being a cheater ;)";```
I know but it works exactly how it should
private _name = name player;
hint "Blacklist read";
sleep 2;
{
if (isClass(configFile>>"CfgPatches">>_x)) then {
hint format ["%1 is being checked",_x];
sleep 2;
hintC format ["%1", _kick_message];
sleep 5;
hintC format ["You will now be returned to the lobby. Have a nice day %1", _name];
sleep 2;
endMission "END2";
};
} forEach _blacklist;
sleep 2;
hint "Congratulations on not being a cheater ;)";
Not sure what your _x at the top is. That won't work my way. But this way it's easier to maintain
_X is the array of names of banned mods.
So if you already have it.
Can just iterate
My code with forEach _blacklist
Where would i put that?
So i can just write that whole thing once? instead of repeating for every mod?
yeah
whats the purpose of putting private before _name?
Can't overwrite local variables from scripts that called yours.
probably not a problem in your case. But a good thing to make a habit out of
ah ok.
@still forum I just tested the way you did my script but it didnt work. The script cant resolve an array here if (isClass(configFile>>"CfgPatches">>_blacklist)) then where _blacklist is. I have tried many different ways of getting an array in that spot but it just wont take. So thank you for the help. The way i have it now works, yes its longer and a bit messier but its easy to read and understand and most importantly, works
I edited my script
like 10 seconds after I wrote "I edited my post" and fixed that
"I have tried many different ways of getting an array in that spot" the array being there is the error. there is not supposed to be an array here
so trying to put different arrays there won't do anything
Yeah. So unless there is a way to, looks like the way i have it is ok.
huh?
I already told you how to fix
I already fixed it in the code snippet I posted above
Yeah thats what i just tested, it didnt work.
the one with _x?
yes.
That means blacklist doesn't actually contain the names of the mods like you told me it does
Tested with _X, tested with _blacklist
Run this through init.sqf with
[] execVM "admin_tools\blacklist_config.sqf";
*/
waitUntil {!isNull player};
waitUntil {(vehicle player) == player};
waitUntil {(getPlayerUID player) != ""};
_blacklist =
[
"KA_Suitcase_Nuke",
"SSPCM",
"NSS_Admin_Console",
"balca_debug_tool",
"LAGO_SCannon",
"LAGO_KU3K",
"LAGO_CP",
"LAGO_Weapons_Pack",
"LAGO_ku3k",
"LAGO_ku5k",
"LAGO_ku98k",
"LAGO_kuoook",
"CCS_Armour_BlackSun",
"Jaffa_Hand_Mounted_Cannon",
"backpack",//Super high capacity backpack mod
"sn_carryall_backpack_plus",
"sn_carryall_backpack_lite",
"TIOW_AutoWeapons",//Warhammer mod
"a40K_wepbase",//Warhammer Mod
"Cadian_Weapons"//warhammer Mod
];```
Yeah. That's correct and mine should work
how does blacklist.sqf get the _blacklist variable?
It's a local variable. so blacklist.sqf can't access it
It doesnt. that was another problem. So i just ended up pasting it into same file as the _blacklist
Don't understand the problem then. My code should work just fine with that
where _X is. thats where the problem lies. There isnt supposed to be an array there. So if _blacklist is an array and _X=_blacklist then its not going to work.
and _X=_blacklist then its not going to work. it's not
_x is a magic variable set by forEach
it contains the current element inside _blacklist that is being iterated
so _x will be "KA_Suitcase_Nuke"
And you DON'T SET _x yourself. It's done automatically
Just like in the snippet I posted
I copied and pasted your post.
_blacklist =
[
"KA_Suitcase_Nuke",
"SSPCM",
"NSS_Admin_Console",
"balca_debug_tool",
"LAGO_SCannon"
];
{
if (isClass(configFile>>"CfgPatches">>_x)) then {
systemChat format ["%1 is being checked",_x];
} else {
systemChat format ["%1 is not being checked",_x];
};
} forEach _blacklist;
Just plugged that into debug console to test it.
Exactly this.
Result: https://s.sqf.ovh/arma3_x64_2019-04-19_02-15-51.png
no error whatsoever. Runs through perfectly fine
And that is the code I posted above. Which works fine
hmmm.
No idea what you're maybe copy-pasting wrong
lol
maybe show me the full script instead of just parts of it
i do
[_v1, _v2] call awesomefunction;
And within the next script "_this" is filled with all informations. But when i do
_nV1 = _this select 0;
_nV2 = _this select 1;
_nv2 would be (always) empty. Am i overseeing something or do i do something wrong?
_nv2 should be within my test an everyContainer array.
My workaround would be storying my values within an array with all the params i want. like _tekeThis = [_v1, v2];
Yet i wonder what i do wrong.
So, what is the cfg for general items? Items like whatever's not a weapon, weapon attachment and so on? Like vests, uniforms, bandages and so on?
CfgVehicles, CfgBackpacks (iirc), and some others
Anyone familiar with this script http://www.armaholic.com/page.php?id=32520?
Getting a error expression _character f on line 10. With that the script does not init. Followed the video exact as per the guide.
Hi, need help with a script. Is there anyway to make a health regen script for ace medical? looked online and there's no solutions. im also wanting a trigger to last for a certain amount of time e.g, once the trigger is activated, some walls spawn in and these walls should last for 500 seconds. i got the walls spawning in script
@tough abyss
1.92 RC adds third party DLC support to the launcher. Now guess how far 1.92 is away 🙂
How to use "diag_captureSlowFrame ['total',0.3]"? Every time I want to use it I get error
Error missing ;```
only works in profiling build
I have profiling build. still get the error
you don't
How did you get profiling build
Maybe you just got the performance once?
Through steam, when I launch Arma I have green badge in top left corner of the launcher saying "profiling"
Steam only has one branch. perf/prof
and afaik that's only prof
check ingame with script command productVersion
I always install them manually through dropbox. much easier
["Arma 3","Arma3",190,145620,"Stable",false,"Windows","x64"]
"Stable"
that's not "profiling"
I'd recommend just installing manually from dropbox
So I have to download profiling using dropbox?
So, I installed profiling and performance builds and problems with freezes disappeared so I don't have any possibility to check what's wrong with my game.
well if that fixes the freezes. then it will be fixed in next game update
Hopefully, I'm on literal binge for arma
im wanting this set of code this setHitPointDamage ["hitHead", 0]; this setHitPointDamage ["hitBody", 0]; this setHitPointDamage ["hitArms", 0]; this setHitPointDamage ["hitLegs", 0]; to execute every 15 seconds
or even better, execute 5 seconds after they take a hit
Use an event handler https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Dammaged
right, so how would i make my code trigger when a unit gets hit by anything. Essentially im trying to make a health regen script for ace3
so im using this script: ```this addEventHandler ["Dammaged", {
params ["this", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
}];
this setHitPointDamage ["hitHead", 0];
this setHitPointDamage ["hitBody", 0];
this setHitPointDamage ["hitArms", 0];
this setHitPointDamage ["hitLegs", 0];``` and im getting "local variable in global space"
this can only be used in very specific ways. https://community.bistudio.com/wiki/Magic_Variables#this_2
Leave the params line unchanged and just work with _unit inside the braces.
Try a systemChat str [_unit, _selection, _damage, _hitIndex, _hitPoint, _shooter, _projectile]; to get familiar with what values get put into those variables.
where do those results go
would i do params systemChat str [_unit, _selection, _damage, _hitIndex, _hitPoint, _shooter, _projectile];?
this addEventHandler ["Dammaged", {
params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
// you can now use those ^ variables inside the braces {}
//see what they hold
systemChat str [_unit, _selection, _damage, _hitIndex, _hitPoint, _shooter, _projectile];
//do the stuff you want
}];
ok so that script is working but my heal script isnt working
did you put it inside the braces?
as in?
put your heal script where it says //do the stuff you want, and make sure they are working with _unit instead of this.
Or better yet:
systemChat str _this;
I don't think he's ready for that yet xD one magic variable at a time
params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
[objNull, player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal;
}];```this is now working, essentially i get hit, and it instantly heals me. now i want it to register i get hit, wait 5 seconds, then heal me
could i just do sleep 5 in between the eventhandler and the script
params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
sleep 5;
[objNull, _unit] call ace_medical_fnc_treatmentAdvanced_fullHealLocal;
}];``` here's my script. its registering im hit and then immediately healing me, and isnt waiting 5 seconds
Unscheduled
?
Read the page for sleep, look at the Description and Example.
ah, so would i replace that sleep 5 with [] spawn {sleep 5;};
then you will launch a new script. that sleeps for 5 seconds and then does nothing and exits
so thats what im wanting right?
Spawn needs the parameters from the EH still
You want to do nothing?
_this spawn { }
I thought you wanted to heal after 5 seconds. So you gotta put the heal part in there too
i wanth the first event handler to execute, wait five seconds, then heal me
currently you are doing
heal instantly, then wait 5 seconds and do nothing
you have to put the heal after the 5 second sleep
[] spawn {sleep 5; [objNull, _unit] call ace_medical_fnc_treatmentAdvanced_fullHealLocal; };
is that it?
Yes
now _unit is undefined though
you have to get it into the spawned code
If you look at
you'll see that you can pass arguments into it
params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
[] spawn {sleep 5; [objNull, _unit] call ace_medical_fnc_treatmentAdvanced_fullHealLocal; };
}];``` this is my code so far
yup.
coul i replace _unit in the sleep script with player
We don't know what your unit is
_this spawn {
params["_unit"];
sleep 5;
[objNull,_unit] call ace_medical_fnc_treatmentAdvanced_fullHealLocal;
};
which units init are you putting that into?
fullHealLocal only works for local units
this is all in the init of a player
singleplayer?
i have 6 players which will be on a dedi server, each having this code in the init
That means player1 will have the dammaged eventhandler on player2
and player1 will try to heal player2
which doesn't work. fullHealLocal only works local
meaning the player can only heal himself
thats what im wanting
So you have to only add the eventhandler to yourself. Not to all other players
when a person gets hit, it should wait 5 seconds, then heal them. I want this on each person
so could i not put the script in each person's init
Have you ever used a scriptfile? init.sqf or initPlayerLocal.sqf?
a bit but not too experienced
you'd want the eventhandler to be added in initPlayerLocal.sqf
then just add it to player
and then you also don't need _unit and can just use player in the heal script
but i would still need _unit in the eventhandler?
you said i dont need _unit in the heal script, i didnt know that included the eventhandler
i have hardly done scripting so no need to be condescending
params ["_unit", "_selection", "_damage", "_hitIndex","_hitPoint", "_shooter", "_projectile"]; ```
right there
right, so is that what i need in the initPlayerLocal.sqf, and that will check every player?
It will check yourself
as each player is himself. Yes.
Each player runs that script. And the script checks the local player
initPlayerLocal.sqf
Told you that 6 minutes ago
Move the whole thing that you have in init boxes now. Into that script file
params ["_unit", "_selection", "_damage", "_hitIndex","_hitPoint", "_shooter", "_projectile"];
_this spawn {
params["_unit"];
sleep 5;
[objNull,player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal;
};``` this is what I have in the initPlayerLocal
you don't need to pass _this to spawn anymore
you don't need the params for _unit as you don't use it anymore
and as you've been told before. this can only be used in specific ways.
And as you've also been told before then just add it to player
add the eventhandler to player. not this
params ["_unit", "_selection", "_damage", "_hitIndex","_hitPoint", "_shooter", "_projectile"];
spawn {
sleep 5;
[objNull,player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal;
};``` better?
You are missing one };
i know nothing about this so sorry about not grasping everything
You are opening the brace on addEventHandler. And opening another one at spawn. But you are only closing it once
You have to have a equal number of opening/closing
You are also not closing the [ of addEventhandler
i know that just didnt see it xD
params ["_unit", "_selection", "_damage", "_hitIndex","_hitPoint", "_shooter", "_projectile"}]];
spawn {
sleep 5;
[objNull,player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal;
};```?
wut
params ["_unit", "_selection", "_damage", "_hitIndex","_hitPoint", "_shooter", "_projectile"]}]; ``` surely this has closed em all off
No
Okey yeah this variant is more correct
but now you don't have any code in the eventhandler. besides the params which I've told you to remove
You want to execute your healing script when the eventhandler fires
so you have to put it INISIDE the eventhandler. Not just next to it
The eventhandler executes the code you give it, when the event fires
params ["_unit", spawn {
sleep 5;
[objNull,player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal;
};
]
}
]; ``` any better?
worse
i had no idea what to do with the brackets at the bottom 😛
I told you to remove params 3 times now
you still have it
and now you've stuck the spawn into it which makes no sense at all ^^
Also I told you you had it right before when it was still in init box.
Just scroll up in the chat and look what you did there
thats the thing, i dont get what your saying, if you perhaps showed me instead of just telling me im wrong i might understand
i dont grasp code well at all
[] spawn {sleep 5; [objNull, player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal; };
}];```
👏 👍
But now you've reverted what you previously did right and are now doing it wrong again ^^
but then do i remove the this at the start
player addEventHandler ["Dammaged", {
[] spawn {sleep 5; [objNull, player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal; };
}];```
ignore sqf at start
```sqf
<code>
```
instead of
```
sqf
<code>
```
player addEventHandler ["Dammaged", {
[] spawn {sleep 5; [objNull, player] call ace_medical_fnc_treatmentAdvanced_fullHealLocal; };
}];
ah i see
right thats working thanks for the help
quick question: I want to place some units offset to an object I have on both X and Y axis. I can move them in one direction by using getpos [6, 0]; and then do a _foreachIndex * 5; to move each 5 meters when placing them in my array.
but what if I want to place them offset on the Y axis?
yeah so i would to [5, 180]to move them south of my object. but now I want to spawn them on the right side of the first dude. so I get a line going west to east.
use 90 degrees then
but then they get offset 5 meters to the right but they are still placed northwards.
private _posCenter = campfire getpos [5, 180];
{
private _grouppos = _foreachIndex * 5;
private _unitpos = _posCenter getPos [_grouppos, 0];
_x setPos _unitpos
}
forEach (units Alpha1);
this question is rather in geometry domain, it's better resolved by taking a paper (with grid) and drawing what you want to achieve 🤔
Am I right in thinking I cant get the getpos to take in multiple axis at once? The wiki had the "getposATL " which takes 3 axis input, but changing it to that and feeding it 3 numbers didnt work.
getPos has special syntax which can return position relative to another position by taking heading and distance, other commands dont have such functionality
but they are still placed northwards. Yes. Because you are placing them northwards
private _unitpos = _posCenter getPos [_grouppos, 0];
Direction 0° which is north.
Am I right in thinking I cant get the getpos to take in multiple axis at once? it takes a direction. Compass direction.
If you make it northeast it will move on X AND Y axis. So it can do multiple axis
..
so
Dunno what happened before.I already tried changing my second degree input and they just got placed in a circle. I probably did it so the foreachindex was adding the rotation up per placement
but of course it works now. I can place them in a line offset from the object now. Thanks for keep helping me
maybe this is to advanced for me. is there any way to make "BIS_fnc_findSafePos" choose a place that includes at least one building or structure?
You can find out what the function does by reading the documentation https://community.bistudio.com/wiki/BIS_fnc_findSafePos
you apparently need to add the PathCalculated eventhandler to the agent
and then it will eventually fire
unless you add it too late and miss it
I see. Thought I could use that command to draw the path a unit would take before actually giving the order.
Guess I'll wait until the documentation is finalized
can spawn agent on same position and let it calc path. Should be same result
I'll wait and see. Could be an intersting little command.
I'll wait and bleed... inside my shell
Hahaha really?? Why did they add a calculatePath command?
I have made a forum thread a year ago or more like' could you expose game's path finder to SQF because It's stupid to see people make their own super slow A* planner all the time'
I even have found this thread, lol, it's 11 months old https://forums.bohemia.net/forums/topic/216934-request-expose-engines-path-finding-algorithm-to-sqf/
guess that was the easiest way ¯_(ツ)_/¯
Yes the way it's done is pretty... interesting...
private _thisArray = _this select 0;
private _countThisArray = count _thisArray;
for [{_loop = 0}, {_loop < _countThisArray}, {_loop = _loop + 1}] do
{
_select = _thisArray select _loop;
removeAllActions _select;
[_select, [
"Scrap Wreck",
{
params ["_target", "_caller", "_actionId", "_arguments"];
// put function for wreck here
[] call narC_fnc_vehiclePlayerWreck;
},
[],
1.5,
true,
true,
"",
"true", // _target, _this, _originalTarget
6,
false,
"",
""
]] remoteExec ["addAction", 0, true];
in my called function i cant access _this. What am i doing wrong, please?
If i am correct it says, it sends those informations in params automatically over. But it wont. I am now a bit clueless.
it looks like you are missing a bracket [ at start or am I wrong?
thats the selected vehicle, thats fine. action works but i dont get any params.
Cant tell. addAction told me, when i use the action, basically activating the action, i get the params in the new script i call. like _caller _target n' such.
the wiki i mean.
its working all fine, but in my fn_vehiclePlayerWreck the "_this" mVariable is empty. But the wiki stated that i get all the named params like _target, _caller and such. Or did i misunderstood that?
correct
you are passing [] as arguments to call
and _this is your arguments
thus _this=[] when you pass []
are the params, that addAction gives me already filled with the informations? If so, i could put them all into an aray, or if its something else, what can i write into [] before call?
you can either fill the empty array with the things you want.
or do a _this call to pass it through directly.
OR. Just do a call without arguments.
Which will leave _this undefined in your fnc_vehiclePlayerWreck. Which means it will use the _this of the next higher scope. Which will be the arguments of your action then.
ah! i will try it. Didnt know that. I could pass _this within the [] before call too?
sure.. But why pass array inside array just to pull array out of array again.. If you could just pass _this directly
hehe, sure, just wanted to be fully sure :3
<squeaks> all the functions run so perfect. So smooth, so awesome. I can write scripts now double the speed and bugfix even faster!
Currently still on the lookout. But i ask anyway: Is there a way i can check if something already has an addAction / action active? So i dont have to remove everything all the time and re-add it? (current workaround)
i check in the player vicinity if there are wrecks so they can salvage or repair those wrecks. Script runs on live server every 30 seconds, for testing every 15 seconds. Everything works perfect but... i get annoyed when the action pops up all the time when i am near the vehicle wreck.
(if iam near to it)
hmm. That would work. How precise does it need to be? straight look at the very specific point where the vehicle exists or 'general direction'?
or how precise is it.
Hmmm. Not particular to my liking.
Still the vehicle easily can be intersecting and the thing popping up. Its not like crazy - we have it in different other situations too even with ace-stuff or rhs-stuff. So i guess there is no pure clean solution to it i guess
Only thing i can imagine is, instead of an automatic check i could make it an interaction check. I mean... A wreck is not that hard to see XD