#arma3_scripting
1 messages · Page 633 of 1
possible solution: always lock the car (globally) and only unlock when owner calls the unlock script.
that works too
Or dont unlock at all. Just use moveInXXX commands.
adding a fake "get in" action is a possibility yes
I've been trying to find in on BIki but I guess my question is so simple there is no answer there - how to increase one value in an array by given value?
I don't want to increase the size of an array, I just want to increase one of the values by 0.1
_array set [0,_array#0 + 0.1];```
thanks, I think also vectorAdd might work
yes it would, if the array is a 2d or 3d vector.
quick question about params:
I star with my call being:
private _object = [_stationID,_stationLetter] execVM "returnObject.sqf";
My receiving end isn't receiving the strings
params["_stationID","_stationLetter"];
are the two variables defined when you are using them? also execVM wont return the result of the script (presumably an object). you need to use call.
yes they are defined (used hint to check) do the params look good?
yes it looks fine. put hint str _this; in the receiving script and see what it says
I'm looking to implement a system to allow players to customize already spawned vehicles, like a Virtual Garage-lite. Is there any way to make BIS_fnc_garage work based on an already existing vehicle and not spawn a new one when it's opened? I've already figured out limiting the available options to just the target vehicle, but I need help with making it not spawn a duplicate of it in the same place. I've considered making an entire new system for this, but considering I know jack about GUI manipulation, I figured this'd be faster.
You could use BIS_fnc_addScriptedEventHandler with garageOpened to delete the pre-placed vehicle in order to substitute it with the virtual one, it might take some fiddling to get it smooth but it could work as a hacky work-around
https://community.bistudio.com/wiki/animate
Can be used to customize vehicles as you can See in the examples
No need to create a New vehicle
Hi there my addaction works fine. But when I have 1 player there is only 1 addaction. but when I have 2 players in multiplayer there is instead 2 addactions of the same one how can I only make it one
I have a script that is supposed to return an object from within an If statement, how do I make this happen?
so as long as I place the object in the exitWith{} it should return?
yup
Idk if this is possible but are we able to use zeus enhanced on public servers as a script?
I'm going to assume no
I just set up an I&A server, still building stuff and trying to get more options for zeus to spawn things and edit stuff, but I don't necessarily know how to atm
Morning, ladies.
Can't I optimize this
if (isServer && _Simu) then {
HZ_ServerControllingSettings = true;
publicVariable "HZ_ServerControllingSettings";
} else {
HZ_ServerControllingSettings = false;
publicVariable "HZ_ServerControllingSettings";
};
to this
HZ_ServerControllingSettings = false;
if (isServer && _Simu) then {HZ_ServerControllingSettings = true};
publicVariable "HZ_ServerControllingSettings";
And is this public declaration even necessary?
And is this public declaration even necessary?
if you want everyone to know what the value of the variable is then yes. if only the server should know then no.
["Open",[true,_entity]] call bis_fnc_garage3DEN;
``` you can pass the vehicle as an argument to the function like this
HZ_ServerControllingSettings = isServer && _Simu;
publicVariable "HZ_ServerControllingSettings";
``` your other approaches are valid as well
Oh, cool, thank you. Thought a variable without underscore would be public anyway.
global, not public
rgr
is the double underscore a typo? Does it do any harm?
__cleanup_loop = [] spawn HZ_fnc_Cleanup;
most likely a typo, yet no harm done
(as long as it's named the same everywhere - underscores included)
Roger, thanks
@languid oyster https://community.bistudio.com/wiki/Identifier This might be interesting
Did anyone have anything about my question earlier?
@tough abyss About ZEN https://zen-mod.github.io/ZEN/#/
Is this able to be put into the mission file via SQF?
Or without adding CBA or anything, as base zeus stuff is pretty bland
Read the documentation, I don't know
_logo = if (configSourceMod _x == '') then {[""]} else {modParams [configSourceMod _x,["logoSmall"]]};
_logo = _logo # 0;
is there a nice way to do this?
select?
private _logo = if (configSourceMod _x == '') then
{
""
} else {
modParams [configSourceMod _x,["logoSmall"]] select 0;
};
// or
private _logo = "";
if (configSourceMod _x != '') then
{
_logo = modParams [configSourceMod _x,["logoSmall"]] select 0;
};
```@cosmic lichen
what's nice?
One line? remove array in if case, select 0 in else
Optimized? isEqualTo? 'cache' configSourceMod?
nice is nice! la la, la lala 🎵
Forget about it. Looks even worse than mine 😄
modParams command is so annoying since it spams rpt if mod name is ""
Muh! :<
hi!
I dont remember how can I define a variable in one line with conditions
it should be something like
a = condition : if true ? if false
a = if condition then {true} else {false}
thanks!
Working on arma and giving Support on discord. Dont get burned out dedmen 
a = [falseValue, trueValue] select _condition;
``` will work as well
didn't know this format
If I set a variable using setVariable on a display, once the display is closed, the variable is instantly set to nil too ?
basically, yes
its namespace gets deleted, and all its variables with it @compact maple
okay ! 🙂
So I know this must sound extremely simple, but I want to put a link through a billboard I have that can get people to automatically join our discord, anyone able to help quick?
sounds simple when you say it like that
Yeah but things like that are never simple are they XD
hm
it doesnt do quite what you want though
I've been looking for a way to open a URL through arma aswell but dont think I found anything good last time I looked
you want the billboard to make the link, presumably the billboard has an image that says 'click here to join our discord
addaction takes structured text so as a title
"<a href='http://arma3.com'>Arma 3</a>" could work
I doubt it, but I am curious now 
emphasis on "could" 😄
biki is dead send help
yep just wanted to fix something on the addAction page
i downloaded an offline copy just yesterday
Nope dont think it works, I might be doing it wrong tho 
yes. that, Lou 🙂
You have great taste.
it was online for a second, dead agaimn now
I have it on my PC of course ^^
here it is
tries to publish profiling
internet problems 
😏
illegal reupload Intellectual Property DMCA uuuuugh!!1!
hehe
Quite sure IT is on it
is there any chance we can get an offline FNCref, Lou?
i use functions as much as commands
its not really down, rather at internet speed of 1997
d❤️dmen
by using it too much
You could also put a QR code on there.
Holy shit you right
yes, QR codes is s funky solution
Im making YT vids linked from QR codes that I will show in mission
as a video briefing
TMKY: if you try to create a marker with the same name again, it will silently fail without logging.
Glad I could help
In Soviet Russia, The More Know You
The marker name has to be unique, if a marker with the given name exists, the command will be ignored.
yep
does ace simulate complicated stuff for sound traveltime like temperature etc ?
Quick note re allMapMarkers, and I'm wondering if other coders are seeing the same thing;
_userMarkers = allMapMarkers select {_x find "_USER_DEFINED" > -1};
This script will return an array of user-placed markers. However, when the server runs the command, it gets far fewer markers than when the player runs the command. Is this intended behaviour?
i do use that, let me check
I only use it on the server and it always gets what I expect
ive never noticed any problems
some markers are local maybe? (e.g createMarkerLocal)
hmm - how much load is your server under? Ie., how many players are dropping markers
all my markers are global, might be relevent
These are all standard vanilla markers placed by players on the map (you know, double click on the map)
its rarely under big load, Ryko
I'm looking at 40-60 players
lol, i wish i could see that many
the channel selected when marker placed is going to be the thing here?
So my intended behaviour is to have markers placed in sideChannel to fade away gradually over time; in the end I've pushed the functionality to the client rather than the server, side effect is one less thing the server has to do
But I do have to do a complicated dance to ensure the player gets their direct play id so they can find markers they have placed, as I don't think there's a command which picks that up
there are new marker related commands coming iirc
Yeah, there's a command which segregates markers by channel, but I can already do that by parsing out the text of the marker name
If there's a further command that associates ownership of a marker with a UID that'd be golden, but it's all for naught if the server isn't detecting the same number of markers as the client
is the discrepancy in server / client marker counts only happen with user markers? or does it happen with mission created ones?
done a few quick tests.....i can't recreate the problem, count of user markers is the same on both server and client
but makers all placed in global channel
I've only been checking user created markers
do i have to kill coroutines after i spawned them?
i noticed my script seems to hurt performance in the long run
depends on what they do really
most do some simple thing but delayed
the script is ended when it reaches code's end, no need to "free the memory"
alright thats what i wanted to know, thanks (y)
How can I format a debug message to show the params and name of the called function?
you_fnc_debug=
{ params [["_arr", [], []], ["_fnc", "you_fnc_debug", []]];
systemChat format ["%1 call %2", _arr, _fnc]
};
if each function has a line like,
if (missionNameSpace getVariable "you_debug") then { [params, function name] call you_fnc_debug}
How do I reference the params array?
Or is there just a better method to get this information?
_this for params
if you defined the code as a function, you could also use:
_fnc_scriptName to get the function name
the latter requires being defined in cfgFunctions
So Im trying to make it so the Artillery bombards the Enemy posistion then the Infantry will charge, The problem is, How do I get the Artillery to cease fire after a certain amount of time?
@little raptor ,
that's great, thanks so much!
the functions are defined in config and that will work perfectly!
Is there any way to make the Artillery cease fire and consider the waypoint complete?
@formal brook for firing, doArtilleryFire
to stop, maybe doArtilleryFire at a position too far (like [-1e20,-1e20,-1e20])?
Im using the Fire mission waypoint
does clearing the waypoint help?
I've never used the waypoint variant so I'm not sure
This waypoint, or the squad's ammo, may have to be modified/deleted via script in order for the squad to cease fire.
maybe it does work, if that's to be taken as true
Yeees but we still need to get sleep or waitUntil incorporated, that'll be easier if the whole act is done via script
So there is no way to do it via waypoint?
I just need help understanding the waypoint timer tool.
You see @formal brook, usually what I would do is write a script like this and execute it (we can tell you how):
while {time < STOP_ARTILLERY_FIRE_TIME} do {
MyArtilleryUnit doArtilleryFire [ENEMY_POS, currentMagazine MyArtilleryUnit, 10];
sleep 10;
};
```That is because editor modules and waypoints are often hard to bend to one's will - they can barely offer more than basic functionality.
is there a better way to call a debug message like above? Instead of calling it through each function could I intercept this information as it is sent for execution?
I vote not possible...
no
But you can probably just run a real debugger and just set a breakpoint
maybe I need to make a tutorial on how to get the debugger going...
systemChat and educated guesswork all the way
hint "plop" 😄
@still forum ,
so I'll call it a "call monitor"? I don't mean to misappropriate terms but you can see what I want it to do
I think that might be right term yea
how do you compile your functions?
you can also just add a custom header to all your functions that just dumps on call
Notepad++ search and replace in multiple files!
the functions are defined as configs
CfgFunctions lets you choose between
none of these do logging....
I guess _headerLogScriptMap logs the call/callstack.
But I think textLogFormat is internal-only command
sadly doesn't let you set a custom header
Is there documentation on that? First time I see that stuff
probably not
thanks, it's a kinda gimmicky idea anyway-- but that's what I do!
write faster plox 
👀 BIS gotta stop letting Dedmen get into the cocaine stash
Anyone know how to make a module repeat over time without using a trigger? Maybe in the init?
Either way, if you're trying to avoid putting your code
if (missionNameSpace getVariable "you_debug") then { [params, function name] call you_fnc_debug};
```into every function, you could try writing a wrapper function for `call` / `spawn`:
```sqf
params ["_args", "_function", "_debugFlag"];
if (_debugFlag) then {
systemChat format ["%1 call %2", _args, _function];
};
_args call _function;
```Something like this, probably won't work exactly like this because `call` expects code, but you get the idea. Then you can change the way you invoke functions that you want to log:
```sqf
[[ARG1, ARG2, ...], ME_fnc_someFunction, true] spawn MyWrapperFnc;
which module
also repeat what?
@willow hound params missing quotes
TF Snow Storm. Basically it will have snow for a set period and thats it. I'd like it to repeat itself over time.
every module uses a script in the backend
its probably easier to run that script manually, rather than going through the module
Good call @still forum . Thanks for the pointer. I'll give that a shot.
hello i have an issue were im trying to get radar missiles to be able to lock and fire on dead targets because evan though its dead it shoudl still be lockable
unfortunately the only way of doing it i know of is https://community.bistudio.com/wiki/setMissileTargetPos which requires manual control is there another way of doing this im not seeing
Could try creating a dummy target on the dead target's position and use that for setMissileTarget.
Hello again all
Addaction question
How do i limit the distance for people to access it.
"_this distance _target < 2"
Is that right so if over 2m then it won't appear
If yes can someone show me how or where to put this code in an example addaction in a remote exec that target is 2
this addAction ["Enter", {player setPosASL (getPosASL S1)},nil,1.5,true,true,"","_this distance _target < 2"]; think i got it now not to worry:)
Whats a radius argument
Read the documentation aaaaaaaaah
hey any reason a script would work in singleplayer and local hosted but not on a dedicated server? I'd post it here but its like 36k lines
36k line file 
Sorry :(
I have a script with 570,000 lol!
smells like refactoring
_newObject = createSimpleObject ['Land_DistrictWall_Straight', [1482.52,1956.62,12.1676]];
_newObject setPosWorld [1482.52,1955.36,46.0151];
[_newObject, [[-1,1.19249e-008,0], [0,0,1]]] remoteExecCall ["setVectorDirAndUp", 0, _newObject];
basically a line like this but for 36k times and this at the end
{
_x enableSimulation true;
} forEach (getMissionLayerEntities "Enemies" select 0);
and how is it called?
and when you are on dedi, this console execution doesn't work?
this addAction ["Enter", {player setPosASL (getPosASL S1)},this select 3 _this distance _target < 2];
Is that it?
correct
can you test in solo, but not from the editor?
as a single player scenario?
How much of the documentation did you read? Example 5 shows the radius argument being used correctly.
yup (don't forget to enable the console)
I'm trying. I do not understand it thats all
I mean i don't even know what argument stands for in arma put it that way
this select 3 _this distance _target < 2
what's this?!
what argument stands for
it refers to any parameter you provide to the commands
I think you may have skipped a lot of stuff and now you're confused
I'm really really trying
for example,
https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting
did you read the stuff about data types?
and sqf syntax?
I kinda just dived into it and learnt what I know from examples
Thats probably the issue lol
yeah
I apologise if I'm causing people headaches
anyway, if you're referring to the "arguments" part of addAction, look at its code
params ["_target", "_caller", "_actionId", "_arguments"];
tried to turn it on from the attributes but it doesn't pop up
from where should I enable it?
whatever you put there will be later available in the code (in the 4th param, aka _this#3)
from the attributes, otherwise description.ext @smoky verge
He's actually trying to use the radius parameter
Yeah the radius bit then someone said i could do radius in an argument that's where I got confused
Otherwise I will stick with the nil,true,true,1.5,"",2 (radius bit)
mhm enabled it for everyone but it still doesnt show up
is there a script to make preplaced AI spawn via a trigger when players enter it
?
Chances are its disabled in description.ext then, that overrides the editor settings.
you can put any script in a trigger, or call any script, even to spawn AI or objects.
@idle jungle ty
@idle jungle The code you're looking for is something like this:
this addAction ["Enter", {player setPosASL (getPosASL S1)}, nil, 1.5, true, true, "", "true", 2];
```That `2` at the end is the radius.
Ah I missed a true out in my version woooops lol
Thank you ansin
You're welcome. Don't forget to practice with the documentation, it answers many questions!
I will mate I will start at the beginning instead of skipping like I did
I think there maybe some videos I can watch also
@winter rose ok managed to play it in a singleplayer scenario outside of eden and it worked
so I'm not sure whats up with the dedicated server one
Maybe a stupid question but is there a counterpart toappend ? Like _arrayNew = array1 - array2; without returning a new array?
@smoky verge
Did you use allSimpleObjects on the dedicated server to make sure the objects actually weren't created?
May or may not be the issue, but you should change
[_newObject, [[-1,1.19249e-008,0], [0,0,1]]] remoteExecCall ["setVectorDirAndUp", 0, _newObject];
to
[_newObject, [[-1,1.19249e-008,0], [0,0,1]]] remoteExecCall ["setVectorDirAndUp", _newObject];
as it executes that on all machines otherwise.
nope
deleteAt, eventually
Guess a - b is faster then
@crude needle the general idea is that it plays it on every player locally but not on the server
also don't think I've used allsimpleObjects
That's just gonna multiply the objects every time you run that script on a player. createSimpleObject already creates one for everyone to see.
oh alright
could this fix the dedicated server problem?
Honestly can't say for sure. Definitely helps the network and player performance.
The objects in theory should've still shown up on the dedicated server and that's why my money is on the setVectorDirAndUp being the issue since when you run object manipulations like that in quick succession from multiple machines, things have a tendency to teleport to [0,0,0].
oh actually running the script on a trigger worked
but still gonna fix that code
thanks
@crude needle sorry to bother, a friend suggested I used this at the beginning of the script
if(!local) exitWith {};
to do it only locally for every player
but it gives me an "unexpected )" error that way
Yeah, needs something to test against.
https://community.bistudio.com/wiki/local (Ignore the variable syntax)
don't shoot the messanger I didn't come up with that
Just to be clear, your goal is to create these objects for everyone and do nothing else with them, correct?
I'm trying to play this script, which creates a lot of simple objects, but not on the server, I want it locally on the players machines so it doesn't destroy the server CPU causing desync and other problems.
from whats in that biki page I guess I need to put something after !local, but what?
No.
createSimpleObject will always sync across the network since it has a global effect. You can't get around that.
oh I see, @still forum suggested this
do local only simple object and run script on every client
now I'm not sure what he meant by that
As far as I know, there isn't a local only simple object command, just regular objects.
Wait,
There is a local flag.
createSimpleObject [className, positionASL, local]
So just add true where local is.
so referencing from that initial script I posted
_newObject = createSimpleObject ['Land_DistrictWall_Straight', [1482.52,1956.62,12.1676], true];
_newObject setPosWorld [1482.52,1955.36,46.0151];
[_newObject, [[-1,1.19249e-008,0], [0,0,1]]] remoteExecCall ["setVectorDirAndUp", _newObject];
it should be something like this?
Exactly.
do I just scratch the if (!local) part?
Yeah, no need for it.
it kinda scares me to run something so big locally but I guess if there is no JIP there should be no downside to this?
could it cause desync on the players computers?
The only thing I would be curious about is setPosWorld since it definitely has a global effect. Not sure how other players will handle that or if they would get a message, though I'd imagine there are things in place for objects being marked as local only as to not send that message across the network.
Shouldn't be an issue otherwise.
a message?
Just a message that tells everyone to set that object to that position.
not sure honestly
tried to reverse engineer a script meant to mass spawn objects with createVehicle
so the setPosWorld may be redundant?
but the values seem different so no clue
Could be redundant. Don't know what the one in createSimpleObject is based off of (ASL, AGL, ATL, etc.) but they are likely the same since the positionWorld only has it's z axis changed.
yet you can see a difference in the y and z axis
also is there something I can do on the server management to help run this script better?
On the map for this mission, type this into the debug console:
AGLToASL [1482.52,1955.36,46.0151]
and see if it comes out as the other one in createSimpleObject
gives me this
[1482.52,1955.36,45.9612]
different from
[1482.52,1956.62,12.1676]
If it's not running on the server, it's settings likely won't make a real difference, though you could ask around #server_admins
Dedmen did post a good run down of how to get the most out of the settings in there a while back.
I'd just leave it then, could test it with a couple of people just to make sure it doesn't cause massive lag.
yeah the number of people is my main concern
hard to test a mission meant for 30+ people
I'd imagine that since you are creating objects in the thousands here, if it were going to cause issues with 30+ it would be noticeable if even just one other person were present.
mhm, could be true
so, not sure what caused it, if the local or the setVectorDurandUp fix you told me
but now all the simple objects have 0 dir
On dedicated?
yeah
Is the trigger local?
don't think so
used radio alpha
oh actually I had not yet saved the local true so it has to be because of this
If it's editor placed, put that in the onActivation field to be sure it doesn't run on the server.
if (!isDedicated) then {
/*code*/
};
you think could that cause the 0 dir?
Probably not, but it keeps the server from running that script just in case.
I'll try to revert this
the activation should look like this right?
if (!isDedicated) then {
nul = [] execVM "script.sqf"
};
Yep.
huh apparently it was the true that brokes the direction
why would locality do that?
Could be the use of remoteExecCall on a local only object.
or not nevermind
its very confusing
its like only when both the _newobject fix and the local = true are not used it works
@smoky verge Tested it with createVehicleLocal, doesn't look like you can remoteExec (at least setVectorDirAndUp) onto a local only object, gonna test it with createSimpleObject.
sorry if I haven't replied but been making tests mixing combinations
it seems to work at random, so confusing
if I either add the true or the _newobject fix, or both, it breaks the direction, I'll try that clientOwner thing
No need.
Doesn't work with createSimpleObject on local mode either.
So it would appear that you need to remove the remote execution from setVectorDirAndUp.
and what should I put in its place?
[_newObject, [[-1,1.19249e-008,0], [0,0,1]]] remoteExecCall ["setVectorDirAndUp", _newObject];
to
_newObject setVectorDirAndUp [[-1,1.19249e-008,0], [0,0,1]];
mhm ok let me try
bit hard to doo when there are so many lines, even with the replace function
Yeah. Gonna take some voodoo to do it.
ok made it
it didn't break but I'm not sure if it optimized anything
I still haven't added the true for the locality
_allSpawnPos = [[4783.464,6112.624,3.453],[4728.515,6154.601,4.023]];
_randomPos = selectRandom _allSpawnPos;
CP1 setPos _randomPos;
any idea why this would be giving me the error
On Activiation: local variable in global space
It's just in the "On activation" part of a trigger.
Is hintC entirely broken?
ok @crude needle the true worked too
I forgot why I was making all this in the first place
Is CP1 defined?
To keep the server from dealing with it?

yeah I'll test it on the server, thanks for the time
Yeah there is another trigger called CP1
i used this code just a day or two ago for something else and it worked fine so i'm not quite sure what's gone wrong lol
What's your issue with it?
Can't see why it wouldn't work. Does the trigger activate anything else or is CP1 made in a script?
Nope, CP1 is just a normal trigger already placed, it's linked to a sector control thing.
I've got this working in another mission but i'll have to go enable all these mods to get to it.
i'll do that in a sec
@crude needle It doesn't show.
Its called via init.sqf execVM within isDedicated condition
followed by a (player getVariable ["isSurvivor", false]) then condition.
command is structured like in wiki example.
In Ticket T123800 in 2017 reported broken. Reported fixed in 2019.
if (player getVariable ["isSurvivor", false]) then {
hintC format [
"TEXT1<br/>
TEXT2<br/>",
"TEXT3<br/>
TEXT4"
];
hintC_arr_EH = findDisplay 72 displayAddEventHandler ["unload", {
0 = _this spawn {
_this select 0 displayRemoveEventHandler ["unload", hintC_arr_EH];
hintSilent "";
};
}];
};
Thanks.
above code is called from init.sqf via execVM, as said above
What does the isDedicated bit look like?
"isSurvivor" is assigned to the playable unit init field
if (!isDedicated) then {
waitUntil {!(isNull player)}; //JIP proofing
execVM "startHintSurvivors.sqf";
};
Try sleeping 0.5 just before the hintC.
within the if condition or before?
Within.
If that doesn't work, use a systemChat or something to make sure you're getting past the condition.
condition doesn't fire
this is within the player init _this setVariable ["isSurvivor", true];
So the right place would be playerInitLocal using _player?
or would this suffice instead of _this
In the initPLayerLocal, yes.
Just make sure to include the params ["_player"]; at the top.
Interesting. 🤷♂️
One day SQF will put me in a coffin, I swear
@crude needle also you were right about sleep
sleep 0.1 suffices for hintC to load
weird as fuck
Cool.
From the mission that works (with mods)
_allSpawnPos = [ [3708.646,4151.678,1.712],[3714.204,4192.589,2.384],[3710.093,4243.225,0.232]];
_randomPos = selectRandom _allSpawnPos;
CP1 setPos _randomPos;
With no mods at all, doesn't work
_allSpawnPos = [[4783.464,6112.624,3.453],[4728.515,6154.601,4.023]];
_randomPos = selectRandom _allSpawnPos;
CP1 setPos _randomPos; ```
weird
You're probably trying to name your trigger: _CP1 (ie an underline at the start of the name)
Most likely because you haven't defined CP1
I don't see anything else wrong
And what you wrote has nothing to do with mods
Is there an easy way to align text in a formatted text correctly? Like so
from this
bla1: blablabla
blablabla: blablabla
bla: blabla bla
to this
bla1: blablabla
blablabla: blablabla
bla: blabla bla
Is that a gonna be used in a control
If so, why not use two separate controls?
anyway, I don't think there's an "easy" way.
you can use something like:
_spaces = ": ";
_leftSides = ["bla1" + _spaces , "blablabla" + _spaces , "bla" + _spaces];
_widths = _leftSides apply {_x getTextWidth ["font", 0.1]};
_widths sort false;
_longest = _widths#0;
_spaceW = " " getTextWidth ["font", 0.1];
{
_dw = round ((_longest - (_x getTextWidth ["font", 0.1]))/_spaceW);
_txt = [];
_txt resize _dw;
_leftSides set [_forEachIndex, (_txt apply {""}) joinString " "];
} forEach _leftSides;
maybe there's a better way. that's just what I thought of right now
what this does (or is supposed to do, bcuz not tested) is that it adds spaces to texts that are shorter than the text with maximum length
It can be made a lot easier if you use a font with uniform character spacing (e.g. EtelkaMonospacePro, or maybe PuristaMedium but not sure about that one)
@little raptor omg, I asked for an EASY way 😅. But many thanks for your solution.
@languid oyster that's the thing. there's no easy way
as I mentioned it can be made easier if you use a font with uniform character spacing
That code is using a more general approach
hiho all - I am stuck with an issue and I believe the issue is connected with publicVariable: The client places an _object via script. the information about the _object is sent to the server (information is stored into a DB, this works well). Same time the server should now setVehicleVarName the _object vehicleVarName and send that information to all clients. This works on Hosted MP but not on a dedicated Server. This is the code i execute server sided to update the _object vehicleVarName:_ojectVN = MyObjectVarName123; _object setVehicleVarName str _objectVN; _objectVN = _object; publicVariable str _objectVN;. The objects vehicleVarName is stored correctly on the DB, but for the clients, the object would still return "" when checking the vehicleVarName (vehicleVarName cursorobject). What am I missing XD? Any help or direction is appreciated.
@languid oyster one more thing you can try (but it may not work) is define two texts, one with left alignment and one with right alignment.
@little raptor Will try it. Let's see, if I can do some Word worksheet with SQF ^^
no quotes yeah, i am using it in connection with inidbi2 and in some instances i need the information without str
so my base variable is without quotes
and i add str where needed in the scripts
I don't think it does what you think it does
i was afraid that would be the case 🙂
str hello will not return "hello"
if it has one
_ojectVN = MyObjectVarName123;
_object setVehicleVarName str _objectVN;
_objectVN = _object;
publicVariable str _objectVN;
here, _object doesn't have a vehicle var name
because _o(b?)jectVN doesn't have one
so str _objectVN will not return "MyObjectVarName123"
Since it is possible to setVehicleVarName individually on each PC, the value of vehicleVarName returned will be local to the PC on which command is executed.
sh*t, i thought i had tested that and figured it did
also, why do you want to broadcast a vehiclevarname? only the varname would be enough no?
MyObjectVarName123 = _object;
publicVariable "MyObjectVarName123";
```no bs, all clean
riight maybe i was overcomplicating stuff and therefore breaking it 🙂 thank you guys - let me rewrite the larger scripts behind this with the above. will report back in with results
much appreciated!
good luck!
deleteRange?
higher FPS on server.
-limitFPS parameter
Dunno, I would need to know the indices of the items first . Would need to test if that's faster
"getTextWidth" ahhh, missing unicode support and missing optimization stuff
I'd appreciate a fix! I use that command a lot.
missing unicode support
even with forceUnicode?
quick! release a v2.00 hotfix with everything in devbranch this afternoon! 😄
yes, thats what i mean.
Hi again! I cant wrap my head around how i can replace setVehicleVarName with the above suggestion and while I appreciate that I might have gotten some basics wrong here, I might not have explained well enough what I am trying to do.
Hence i will provide a detailed explanation of my code / feature below:
Sorry for the wall of code but hopefully this helps to explain why i believe that i would need to use setVehicleVarName/vehicleVarName to name and identify my object.
Generally this whole feature works well except that I want this vehicleVarName of the recently placed object to be instantly broadcasted to all clients.
So all clients should get the same information whan checking for vehicleVarName _object
right now, on hosted MP, if player "A" places an object he will be able to interact with the object and remove/update it in the database because player == server here and the player knows what the server knows. In that case the vehicleVarName of that object.
on Dedi the whole feature fails as the player != server and does not know what vehicleVarName the server created for the object. This could be fixed for player "A", who placed the object by setVehicleVarName to update the objects vehicleVarName localy within the placement script.
However, other clients (player "B", player "C") do not know about the objects vehicleVarName.
///////////
//client side
_objectCN = "Land_VR_CoverObject_01_kneel_F";
_object = _objectCN createvehicle getposatl player; //player places object
_pos = getposatl _object;
_dir = getdir _object;
_vectorDir = vectorDir _object;
_vectorUp = vectorUp _object; //gather placement info of object
_objectVN = formatText ["OB%1%2%3%4%5%6", _crateCN,floor (random 9),floor (random 9),floor time,selectrandom ["a","b","c","d","e","f"],selectrandom ["a","b","c","d","e","f"]]; //create unique identifier for DB storage and later loading from DB
saveDataObjects = [_objectVN,_objectCN,_pos,_dir,_vectorDir,_vectorUp,_object];
publicVariableServer "saveDataObjects";
///////////
//server side
"saveDataObjects" addPublicVariableEventHandler
{
private ["_data"];
_data = (_this select 1);
_objectVN = (_data select 0);
_objectCN = (_data select 1);
_pos = (_data select 2);
_dir = (_data select 3);
_vectorDir = (_data select 4);
_vectorUp = (_data select 5);
_object = (_data select 6);
_object setVehicleVarName str _objectVN; //this will apply my custom/unique var name to the placed object
_inidbi = ["new","Objects"] call OO_INIDBI;
["write",[str str _objectVN,"Array",[str _objectVN,_objectCN,_pos,_dir,_vectorDir,_vectorUp]]] call _inidbi; //writing info into DB
/////
//this here should inform all clients about the objects new variable name.
_objectVN = _object; //following BI instruction on how to use publicVariable (it thought)
publicVariable str _objectVN; //following BI instruction on how to use publicVariable (it thought)
};
the above correctly names the new object as intended and it will also store it in the Database with the right Information and identification (vehicleVarName).
On dedicated server, the clients currently do not get the information about the objects vehicleVarName.
This is a porblem as later functions rely on clients knowing the vehicleVarName to update object information or delete it in the database.
this is why i have been using setVehicleVarName and vehicleVarName so far. it allowed me to identify an object and work with it as per below example (except on dedi where clients miss the vehicleVarName).
//client side deletion /Database removal script
params ["_object"];
_objectVN = vehicleVarName _object;
player playactionnow "putdown";
sleep 0.8;
removeObjectDB = [_objectVN];
publicVariableServer "removeObjectDB";
removeDataObjectsArray = [_objectVN];
publicVariableServer "removeDataObjectsArray";
deletevehicle _object;
//server sided script to remove object from database
"removeObjectDB" addPublicVariableEventHandler
{
private ["_data"];
_data = (_this select 1);
_objectVN = (_data select 0);
_inidbi = ["new","Objects"] call OO_INIDBI;
["deleteSection", str _objectVN] call _inidbi;
};
remoteExec the setVehicleVarName, that command is effect local
not sure if you need JIP handling tho
[_object, _objectVN] remoteExec ["setVehicleVarName", 0, true];
thank you
i used the above in a previous version but it would not update the vehvarname for clients
yeah as said not sure if JIP is needed. Server might transmit what it has locally, to joining clients
ok i will retry with this option (with and without JIP enabled) - thanks!
Yeah, I use this too, albeit in a function
with the same issue or does your function work?
mine works 🙂
{
params ["_veh", "_name"];
missionNamespace setVariable [_name, _veh, true];
[_veh, _name] remoteExec ["setVehicleVarName", 0, true];
};```
oooh, thanks!
i identify as church so i am tax freed but your £15 have been donated for a good cause, i have no sister and i am too greedy to share beer so lets make a compromise: i send you pics of my beer!
I think you misuderstood the terms of this deal 🙂
what language is dayz written in
DayZ itself? maybe C++
the scripting language is kind of similar to C#
And why are you asking that here? @tough abyss
uhhh scripting channel
Arma Scripting
no it's not
But for arma 2 dayz you should be asking in #end_of_life_arma
it's based on a completely different engine
Dayz mod is written in SQF @tough abyss
If you are talking about that
is there any way to change the colour and the size of conversation / chat / dialog in the left corner when using kbtell function?
thanks lou
ok i understand now how i was wrong about using str, thanks for the hint! it definitely was messing with my code!
anytime, this chan is open!
So I am playing with basic tasks and triggers.
I figured out most of things I am just stuck on how to get a task by interacting with a civi.
this addaction ["Ask about Soviet","????? civ1"];
What do i write in the ??? Or how do i got about doing this
I used this this addaction ["Ask about Soviet","DeleteVehicle civ1"]; based on how I did it with items, but I just want to talk to the civi not kill him
this addAction ["Ask about Soviet", {
params ["_target", "_caller", "_actionId"];
_target removeAction _actionId;
_target setDamage 1; // 😬
}];
I meant I want to interact with him and have the trigger activate and just walk away.
without killing the civ
then… don't kill him?
what do you want to do exactly
Is _Unit already definite by itself or I have to definite it with _this?
definite by itself
it's a variable, so it's never defined by itself
i think he means, is it a magic variable that is set by another function or command
the only exception is magic variables https://community.bistudio.com/wiki/Magic_Variables
I'm trying to make ai throw chemlights randomly, so I'm just creating a init script that gives them colors depending on their side. I tried _this select 0 and _this and I still always get undefinite. First time scripting
it all depends on how and where you execute the script
in the init I tried compiling it then executing it with execvm
so like this?
[this] execVM "pathToScript"
with out the [this]
that's where you're wrong
execVM creates a new handle
none of the variables defined before are gonna be accessible to it
oh
so first add that: [this]
and in your script put this at the start:
params ["_unit"];
what it does is that it defines a new variable called _unit and gives it the value of the first element of the array you're passing to it ([this])
it was also possible to use:
this execVM ...
_unit = _this;
but not recommended
for educational purposes
without warning nor historical context!
still showing up as undefine for me. when I put params at the first of the init or in the script
in your script put this at the start
adding params to init makes no sense. you must add it to your script
yea I did that at first. But I guess it just the way I have the script set up. below it I have _Unit addmagzines
post your whole script.
and the init too
how do I get the boxes you guys use?
see the pinned messages
or I just copy and paste?
put three accent graves (on most keyboards it uses the same key as ~)
then put sqf next to it
and last also end it with three accent graves
Dedmen having fun with his new toys
he's even using one as his new profile picture! 🙃
chem = compile preprocessFileLineNumbers "chem.sqf";
[this] execVM "lightinit.sqf";```
_Unit addMagazines ["chemlight_yellow", 2];
if((side _Unit) isEqualTo WEST) then
{
_Unit addMagazines ["chemlight_blue", 2];
};
if((side _Unit) isEqualTo EAST) then
{
_Unit addMagazines ["chemlight_red", 2];
};
if((side _Unit) isEqualTo RESISTANCE) then
{
_Unit addMagazines ["chemlight_green", 2];
};
[this] execVM "chem.SQF"; ```
why do you compile a code without even using the compiled code?
took me a long time to realize the "`" wasn't "''"
```sqf
code after line return
[this] execVM "lightinit.sqf";
params ["_Unit"];
_Unit addMagazines ["chemlight_yellow", 2];
if((side _Unit) isEqualTo WEST) then
{
_Unit addMagazines ["chemlight_blue", 2];
};
if((side _Unit) isEqualTo EAST) then
{
_Unit addMagazines ["chemlight_red", 2];
};
if((side _Unit) isEqualTo RESISTANCE) then
{
_Unit addMagazines ["chemlight_green", 2];
};
_this execVM "chem.SQF";
that's it
your main issue was: [this] execVM "chem.SQF"; at the end of lightinit.sqf
this is no longer defined in lightinit.sqf
I was looking at some vcom scripts for reference and it looked like that in the init.
Yeah, sadly most people use bad coding practices and some new comers learn from them
it spreads like a disease
lol
I added the execvm chem because I also had a system chat that would tell me if it was running the script. Never got that in till I added the execvm
anyway, you could've written that bit in a "cleaner" (plus faster, performance wise) way:
params ["_Unit"];
_sideID = [west, east, independent, civilian] find side _unit;
_Unit addMagazines [format ["chemlight_%1", ["blue", "red", "green", "blue"] select _sideID], 2];
_this execVM "chem.SQF";
and note that this is only used in eden init fields. don't use it anywhere else
the equivalent in other places is _this (if applicable)
like I said, pay attention to your scripts and the variables. when you use execVM, the local variables defined in the "previous" script will no longer be available in the "next" script
It's just the init.
If you used the above code, it should work fine.
your problem is probably in "chem.SQF"
It's just the init.
are you talking about a unit's init?
because this is always defined there
not the chem it's something else I think I removed it then I hidden my light code.
could be a local or singleplayer thing
no
how does your init look like right now?
Just one line of code like the one you posted above
well post it
[this] execVM "lightinit.sqf";```
it doesn't have any problem
did you update "lightinit.sqf"?
yep
post the full error from the rpt
this will take you to the rpt folder if you're having problem with that:
%localappdata%\Arma 3
paste it in your explorer address bar and press enter
is there something i can do to optimise coroutines? this here looks really p**py but idk how to make it better:
[_expSound,_expposLocal,_expVol,_id,_distanceDelay] spawn {
params ["_expSound","_expposLocal","_expVol","_id","_distanceDelay"];
sleep _distanceDelay;
[[_expSound, nil, false, _expposLocal, _expVol, 1, 0]] remoteExec ["playSound3D",_id,false] ; // play sound !double array is required
};
"coroutines" oof.
Don't see much to optimize on that, besides the useless false for JIP flag in remoteExec
Not parallel. Maybe async code
coroutines it is
Only thing I can see you might wanna optimize is passing variables, but you can't really
just noticed i use the exact same code to spawn delayed sound somewhere else, so ill move it into a function
[this] execVM "lightinit.sqf";>
13:17:28 Error position: <this] execVM "lightinit.sqf";>
13:17:28 Error Undefined variable in expression: this```
you're running that in init.sqf
init.sqf doesn't have a this
As I mentioned, you should put it in the unit init
check that lightinit does not need any input params and get rid of this
or listen to leopard
[
_distanceDelay,
[[_expSound, nil, false, _expposLocal, _expVol, 1, 0]],
["playSound3D", _id]
] spawn {
params ["_delay", "_left", "_right"];
sleep _delay;
_left remoteExec _right;
};
```@spark turret?
you could also make a function that is called delayedRemoteExec ^^
much wow 😁
@idle whale Also, if you're planning to use that in MP, you should use this (it is safe to use in SP as well, because in SP isServer is always true):
if (!isServer) exitWith {};
[this] execVM "lightinit.sqf";
because every client that joins the server will run the init again (and the unit will have too many chemlights)
are you sure lightinit doesnt need to run locally? lights are local after all
just a wild guess
his code adds some chemlights to the unit
ah alright thats global then i guess
addMagazine has global effect yes
also quick tipp: if you add stuff to units or crates, check if theres cargo space. i think if you overstuff a vest, it doesnt get added, but it does for normal cargospace.
hm can i spawn a function instead of calling it?
okay 🙂
a function is just a variable containing a code
first time cleanly organizing my arma stuff so i wouldnt know
you can even use
if (true) then function
and everything else you can do with codes
hehe, lettuce know 🥗
i dont trust intuivity in arma
so you're right in trusting your instincts! so you're wrong! so you're right!
after i learned that remote [jip = true] isnt "also call on players that spawned later" but rather "collect all calls and spawn as soon as someone JIPs and kill them will a wave of sounds"
yeah i thought originally that it just asks if it should run to for clients who were added after mission start lol good thing dedmen corrected me
aaah I see now what you mean
yeah but I believe he thought that a currently present JIP player needed that flag to receive it
exactly
got it to work now thanks m8s
if i want to kill of the light of a tracer, do i check for alive bullet or bullet isEqualTo objNull?
/isNull
👍
if (isServer) then {
this setVariable ["RscAttributeDiaryRecord_texture","image\text.jpg", true];
[this,"RscAttributeDiaryRecord",["Mobile phone","Receiving Message:<br/><br/>We have the US NATO helicopter in a warehouse close by to you.<br/>We have asked our friendly Spetsnaz to help us guard it. Be on your look out.<br/>They have already taken our prison over. We have got some of our friends up north to send us a MBT, that should help!",""]] call bis_fnc_setServerVariable;
this setVariable ["recipients", west, true];
[this,"init"] spawn bis_fnc_initIntelObject;
};```
for some reason this works on lan but not our server any ideas?
ohhh i had damage disabled on the object would that be it? as intel gets "deleted" dont it
damage disabled does not impact deletion
and why mixing setVariable with BIS_fnc_setServerVariable?
https://community.bistudio.com/wiki/BIS_fnc_setServerVariable
Set variable stored **only on server**
@idle jungle ↑
Hey guys, probably a dumb question. I'm trying to hide the USS Liberty until a trigger reveals it, but it doesn't hide at all. Tried using the module in the editor, added this hideObjectGlobal true to the init and tried adding boat hideObjectGlobal true to the initServer.sqf, nothing seems to work. Is the Liberty a different kind of object that can't be hidden or am I doing something wrong? Thanks for the help.
Also wrong syntax for BIS_fnc_initIntelObject.
Liberty and Freedom are too large to be single objects, they consist of multiple "sub-objects", that probably has to do with it.
I got it off bi forums haha
Woops lol
https://community.bistudio.com/wiki/BIS_fnc_initIntelObject
Shows BIS_fnc_setServerVariable being used too. I'll get those comments formatted though, that's unreadable.
Oh ok those examples help a little
Thanks, makes sense. Solved it by moving it and using bis_fnc_Destroyer01PosUpdate instead. Thanks a lot.
Hello, is there any way i can make a car more though to explosion or something like that? still destructable tho
yes, playing with the "HandleDamage" EH @obtuse quiver
Nice, thanks!
and if i wanted to make the car resistant to crashes but not explosions?
Oki doki, trying to make a tank vs bad drivers lol
I was wondering, is there any way to "track" the last object that dealt damage to a target, even after the target is dead?
I'm trying to build an MP mission where players get money in the form of score for each kill. Incapacitation is toggled, and everything works fine if the incapped player gets executed, but if they force respawn, the "killer" does not get awarded any score. I'm trying to find a workaround for that.
Tag me if anyone has any ideas
you could store the (last) data from the HandleDamage EH locally at a player, and when he/she dies (Killed EH) and no killer is known, use the stored data to get the person who gave damage the last.
and for respawn you can do the same with the Respawn EH, simply check if there is data store about the last handled damage, and reward the score to the person who inflicted that
Hi so i just started making my first mission and i ran into a bit of a wall:
I want to make an AI run into a building and hide once the shooting starts, and then when a player interacts with them i want them to change from independent to WEST
Rn theyre just walking around with other units and i want that, but how could i make them break out of the patrol and hide once shooting happens?
And is there a list of various trigger conditions? like custom ones cuz i assume ill have to use a trigger for this?
I tried messing around with the event handler FiredNear
but couldnt get it to work
(so basically i want them to act as the enemy ai, so theyre like undercover, until the shooting starts, and then i want them to hide, and to avoid them getting killed by the enemy only have them change the side once someone interacts with them)
(feel free to @ me)
FiredNear is not a good Eventhandler for that. It ignored anything further than 50 m and is also local to the shooters machine i believe
Combatmode "red" is a good one imo.
= when they go into combat mode
i still dont understand how to use them to like... trigger something tho
like how do you use an event handler to like...
_opforGroup = createGroup WEST; [boy] joinSilent _opforGroup;
or like
is there a...Hm
there is like a create waypoint move, but how do you tell it where to move
like thats the thing im a bit confused about still is how do you use these things to then set off other things, sorry im very new to this
You dont really need an eventhandler. Eventhandlers react to hardcoded events and there is none which suits your needs.
You can use a trigger to continueosly check if YourGroupVarName combatmode == "red" or sth similar.
In the ontrigger actication, you do
Yiur group join code
So to break it down:
Trigger has condtion "group in conbat"
Trigger checks all the time if condition is true
If true, trigger executes code
if (combatMode _grp1 == "BLUE") then {_grp1 setCombatMode "GREEN"};
https://community.bistudio.com/wiki/combatMode
(combatMode Group01_specialbois == "RED")
is the condition to check if the group with the variablename "Group01_specialbois" went into combat mode.
watch out as they turn into combatmode red if they spot an enemy or a danger.
so not necessarily when shot at, but before.
@ember path
could this be done with a single unit, i need only one of them from the group to leave and hide
group members share the same combat mode.
right i see
but you can command the single unit by giving it a unique name and just ordering this name around
like you already suggested:
_opforGroup = createGroup WEST;
[boy] joinSilent _opforGroup;
okay cool that works, now how do i make him move to a building and stand still.....
is he the only one in his group?
btw, calling you WEST side group "_opforGroup" doesnt make sense 😉
if hes alone, you can just order the group around. create a waypoint at position of desire and the group will move there
should i make him leave the group then move
well that depends on what you want to do with him. does he still need the group afterwards?
if no, make a new one
no, he needs to hide and then wait for players to find him, but i dont want him to switch sides just yet so that he doesnt get shot by enemy ai
hes basically undercover
you can use "doMove". thats like his AI commander giving him an order and will overwrite group behavior
but once he reaches this position, he ll try to regroup i guess, so you ll need another check to prevent that
yeah, boy disableAI "path"
so i disable pathing until hes found and then enable it
enable by enableAI "Path"
i havent tried, but apparently "doStop" works better/more immersive. disable path will make him stuck, no matter what, so he ll die standing instead of taking cover. doStop is like a soft version of no pathing, he ll leave if its really necessary
oh could i maybe use garrison instead of doMove.. i mean idk how id do it in code
cuz i assume with doMove its only 1 position, or i guess hm i could set multiple positions and then make it randomly choose one
i think garrison is a waypoint, so he needs to be a solo-man group then
doMove is good for precise movement. might not work for going indoors
Ai is really bad with buildings.
waypoint system.
https://community.bistudio.com/wiki/addWaypoint
_wp = (group boy) addWaypoint [[0,800,2222222],0]; //add waypoint to boy`s group at position [0,800,2222222]
oh i just did
_newGroup = createGroup independent; [boy] joinSilent _newGroup; _newGroup addWaypoint [GARRISON]; hint "time to hide";
xd
does it work?
can u not just tell it to use one of the like waypoints u have on the right side in eden
no
Ai has enabled pathing?
without pathing, they dont do any waypoints
mhm
even ones that dont require moving.
syntax error
tip:
in c:/users/you/appdata/local/arma3 you find a .rpt file. its the log file
very important as errors get logged in there so you can see what you did wrong
1 elements provided, expected 3
which hm
so you cant just put names of waypoints like you see them in eden into code?
OH
wait
uhhhhhhhhhhhh
i could use lambs
right those are just scripts?
yeah ok ppfs
made my game crash
ok i gtg sleep ill continue this tomorrow, thanks for your help!
i assume i could also use
_tgt = [target1]
_wp =_newGroup addWaypoint [target1,1];
maybe? and then have like an empty marker be target1
Last thing before i go,is there a list or rule or something to what you can use in the Condition, for a trigger
For example I didn't even know you could use combat mode thingy
Okay, can anyone please help with a code I have no idea how to fix:
"respawn_west" setMarkerPos getMarkerPos ["dead_west", 1];
Getting the following error when code is called:
call{"respawn_west" setMarkerPos |#|getMarkerPos ["dead_west", 1]; ...
\\ Error type Number, expected Bool
I cannot for the life of me understand where the Boolean expect is coming from
The second param of getMarkerPos must be boolean (true/false), not number (0/1)
we aren't at v2.01 yet right for release?
v2.01 is dev @fair drum
and we'll never be
next stable release will be 2.02
^^
Anything that can be written in a way that returns a boolean can be used as a condition.
For example I didn't even know you could use combat mode thingy
you're just using a command, then comparing its return value against something (e.gcombatMode _unit == "RED"), so you get a boolean.
Some commands return boolean themselves (e.g.alive player)
just so i understand this better, combatmode == RED is asking: is the combat mode red now, and if its true then execute this. Is there a way to write it so it checks if its false?
!=
i see
thanks!
thats very useful
oh and i managed to get my boy to move
hint "time to hide"; _hidePos = [hidepos1]; _newGroup = createGroup independent; [boy] joinSilent _newGroup; [boy] doMove (getMarkerPos "hidepos1");
and then theres a trigger that triggers when he gets to the place that does doStop
it works really well so far
I don't see why you had to make him join a new group, but okay
I wasn't following your conversation with IRONSIGHT, so I'm out of the loop 😅
well maybe i dont need to, but i also dont want him to go back after the doMove
it works so why not, is there a command to make him join the players group, i wanted to just reuse
_goodGroup = createGroup WEST; [boy] joinSilent _goodGroup;
but thatll put him in a new group
not the one the player is in right
i also dont want him to go back after the doMove
doStop + doMove (or doStop + moveTo) usually does the trick
group player returns the player's group
i think i made the doStop thing kind of in a bad way xd, its just a triger that makes him stop when he enters in
cuz i tried just putting doStop; after doMove, cuz i thought it waits for him to move there and then stops him but nah
okay lets see if this will work
so i can just do
[boy] joinSilent group player;
yes
provided there is a player (e.g. not a dedicated server)
[boy] addAction ["Rescue undercover agent", [boy] joinSilent group player];
this is in a trigget
trigger
trigger is actiavetd by a player being present in the area
condition is the default: this
a code is wrapped in { }
gotcha, heck
also it should be boy addAction ...
not [boy]
the lefthand param is an object
not an array
oh i thought [] was for like any variable okay
i got into this like 3 days ago so yes i have no clue what im doing xd
No problem, but do youself a favour and read through the introduction, it will save you time in the long run.
will do
also i love this and i hate this, switched the independent side to enemy, and the pathing for my boy is all messed up in the best ways
idk if i should try and fix it or not xd
Helipad (invisible) is the mvp
Hi just want to double check, while using remoteExec, whatever variable is attached is related to the remoteExec command and not the command I am trying to remote execute?
For example BIS_fnc_holdActionAdd:
_actionID = [] remoteExec ["BIS_fnc_holdActionAdd", 0, _someObj];
The name of the variable _actionID would actually be false as its not the actionID its actually the remoteExec return? Ive been away from coding for a while just trying to re-remember things 🙂
Ah perfect thanks
to give you an overview over very helpful and important additions to scripting:
the biki has a documentation for every command:
get familiar with magic variables:
https://community.bistudio.com/wiki/Magic_Variables
get familiar with the magic files:
https://community.bistudio.com/wiki/Event_Scripts
visual studio code has extensions that help you developing by highlighting, syntax error detection and even a virtual machine to test code.
recommended by dedmen:
-SQF Language (Armitxes)
-SQFLint
-SQF Debugger
recommended by me:
-arma open last rpt
https://marketplace.visualstudio.com/items?itemName=bux578.vscode-openlastrpt
^ yesss that last one, found it ony recently but it is wonderful to have
I just pinned Arma appdata folder as a favourite in explorer 🙃
what would be nice, a extension that just live-displays the RPT in like, how the terminal panel works.
Just automatically detect when Arma is running, add a RPT panel that scrolls through live.
Does open last rpt do that maybe? I never used it
open last rpt opens the latest one if you press cntr alt R and / or jumps to the bottom of it
and VSC auto refreshes the file so thats nice
never going back to the days of .rpt in notepad bc poseidon would freeze 😂
auto scroll most important thing.. next to handling a 50MB RPT file getting spammed
Are Rpt's actually written live while the game is running or only created afterwards? I never thought about how that works
live-ish
main Arma live, it freezes the game while it writes to file.
Performance branch it queues up writes and does them as it has time while the game runs.
Which is technical info that you didn't even ask for, but here you go
Huh nifty, thank you
Oh ill have to check those out thanks @spark turret i already had some extensions in visual studio code. Also is it more performance impacting to have more scripts or to execute scripts in eden
Like to have them as files, or to just write them in eden
where the script code came from doesn't matter.
The performance impact when the script runs is the same
Quick question: Why should exitWith in a count code return a number and not boolean?
Isn't that a "bug"?
because count always returns a number(?)
count does, yes, but doesn't exitWith end the current scope?
if you return true within the code of count, it will return the last counted element
see wiki 🤷♂️
That's what I wanted to do, but it doesn't
{
if (_x >= 2) exitWith {true};
true
} count [1,2,3]
Strangely, breakWith works
that would return 2
not sure if bug or unintended feature
although comments from 2014/2015 already state that "feature"
so if it was a bug it should have been fixed by now
_result = {
if (_x isEqualTo 3) exitWith { "Hello" }
} count [1,2,3,4,5];
// _result = "Hello"
well, maybe no one realized it's a bug. afaik exitWith breaks the current scope with a code.
ie it should be the same as:
breakWith (call _code)
and you can definitely tell that by referring to the waitUntil behavior
well breakWith is only on DEV for now, so perhaps that one is broken
again... I doubt it if it is known to work like that since 2014/2015
Well let's see if Dedmen knows:
#arma3_scripting message
Ping me when you see this
and count was added in OFP, without any changes (according to the wiki), so must have been known/reported when it was a bug...
I use LogFusion Pro and/or Baretail for watching RPT
both do highlighting so spotting errors and debug messages is easy
execVM "myscript.sqf" shouldnt be able to clog up the main thread right?
like, if i have a waitUntil {false} in my script, the rest of arma wont be too much affected by it
Howdy folks... is there a way to open a strategic map on a "neutral" map? What I want to do is using a strategic map inside an Op-center for the player to choose multiple missions ON MULTIPLE MAPS. For that reason, the overview pics of the strategic map should be something "custom-made"...e.g.; a map of the earth image/pic...
you could copy and rewrite BIS_fnc_StrategicMapOpen to use a custom version of RscDisplayStrategicMap, which shows you custom map/image/etc
although not sure if that would work outside of a mission, and I don't think it's possible to switch missions from within a mission
and I would remove all other duplicate comments... before you get a warning or worse
I know is possible to have the strategic map starting any mission you want (and if it's inside a campaign folder with the correct "description.ext" set up is doable)..
Gotcha...
for the warning part..
A mission is build on a single terrain; so the moment you load a mission, you load the terrain. You can build multiple "missions" in a mission (like it's done in the Contact mission), but you can't switch terrains.
If it's a multiplayer system, you could have a script which would let the player exit the server and join a new server (with correct mission/terrain), but that won't work in SP.
I see...guess a change in plan is due then..thanks anyway
guys, forgive me, but there is a better way of doing this, but it escapes me right now
((str (floor servertime)) select [((count (str(floor servertime))) - 2),3]) isEqualto "00"
for doing something every 100 seconds
please remind me 🙂
there's a function, but I'm damned if can remember it
so many options...
(serverTime % 100) == 0
@finite sail yeah your question is a bit weird, i would say just sleep 100 lol
yeah, i could spawn a thread and sleep 100, but there's other conditions that might change during the sleep
Two contestants remaining!
It really depends on the situation; if you need to repeat code in a while loop, than checking if the current time (or serverTIme when it needs to be equal on all clients in MP) can be divided by 100 is a viable option.
Downside is that it will keep running the loop every n milliseconds.
With the waitUntil solution it will simply wait till it's time before continuing the script (which can be inside a loop as well); not sure what the performance difference is though
yes, the code is in a loop which has a sleep 0.5 in it
You can sleep in the waitUntil "condition".
the loop does other things beside this 100 second check
while {true} do {
private _maxWaitTime = serverTime + 100;
waitUntil {sleep 1; time > _maxWaitTime || COND1 || COND2};
//Put worker code here...
};
```Checks the `waitUntil` condition once per second (thus it can't work with `%`).
^^
Although time and serverTime return the time in seconds, it's possible to skip a second when using sleep 1; making % useless.
Running 0.5 sec sleep makes it possible again, but I don't think you need to check every half a second to know if 100 seconds are over.
no, but the loop it is in is doing other stuff
some of which does need to be half a second or so
now that I'm actually coding it, I'm thinking the %100 inside a loop might not be the best way 🙂
Modulo always rules for timed stuff
Downside is constant check for it. But i doubt thats a Problem
Combine sleep 1; with _iterationCounter % 100 ?
its sleep 0.5, but yes
It might get desynched to true servertime bc sleep 0.5 might not be exact. Never mattered for me
this is serverside
Is time incremented in whole second steps though?
Nope
baretail here too. But only if its spammy and I need to see stuff.
breakWith doesn't break "current scope" it breaks next loop
it exits the current scope/callstack item. The next thing up, is the count itself. And count just moves to next iteration when its code ended
or does it not?
I know that exitWith in loops is not intuitive, gladly you won't need to do that anymore.
It's super intuitive to me O.O
iirc exitWith exited the loop indeed
it might be a bug, but won't fix. I guess I can see how that might happen, but exitWith is just not intended for that, its intended for real scopes like call/spawn.
Not like, also somewhat scopes but not really like then/while/count/forEach
that is why you should not use it 🤪
exitWith == bad style
Pfffff
correct, can't
https://github.com/SQFvm/runtime/blob/master/tests/sqf/if.sqf#L2-L3 at least it exits with for and while
soooo ... with count too i guess
yes
Not sure how it really does/doesn't, but I know using it in loops like this is not supported and has issues
Just be angry at the bug and get hyped up about breakWith coming
refusing to join the hypetrain until we get hashmaps
change my mind
Should be able to start working on hashmap next week.
Hit small roadblock when I remembered the problem with circular references
But I think I got a better solution than what we did with Arrays, atleast better for people who write correct code...
So far it has always behaved as I expected...
You re oppresing me
Always bully ppl with incorrect code 👀
we bully the incorrect code, mostly 😄
I want hashmaps too. I really hate armas array search methods
Cost me 2 hours of my life to search and overwrite a string 2 days ago
Can you just steal javas methods? Pls
We'll youll get them before anyone else, so be happy
🥳
Actually.. I think we already have them in the modpack? My old implementation from 2 years ago
Is there any script I could put in an ai init to make them call one other backup squad with the same init after 30 seconds of contact? I'm wanting to somehow make ai squads that will, after 30 seconds of finding a player, will call one other squad and that squad will do the same when coming in contact.
@regal night
Not sure about existing scripts, but I can point you in some direction to make your own script:
You need a loop such as waitUntil or while to periodically check if the group knows about the player
You need a command to tell how well the group knows about the player. You can use a combination of knowsAbout and targetKnowledge
an example:
_knowledge = 0;
while {_knowledge < 30} do {
if (_group knowsAbout player > 1 && {
time - (leader _group targetKnowledge player select 2) < 5 //last seen less than 5 seconds ago
}) then {
_knowledge = _knowledge + 1;
} else {
_knowledge = (_knowledge - 1) max 0;
};
sleep 1;
};
//call for backup after the loop is done
a simpler approach:
waitUntil {
sleep 1;
_group knowsAbout player > 1 && {
time - (leader _group targetKnowledge player select 2) < 5 //last seen less than 5 seconds ago
}
};
sleep 30;//wait 30 seconds
For calling backup, you can either look for nearby groups using something like : allGroups select {side _x == side _group1 && {leader _x distance leader _group1 < 200}}
or use predefined arrays:
_availableSupport = groupArray - [_group1]; //any group except the original group is available to provide support to this group
and for calling them in, either give them waypoints (addWaypoint) or use a command like move
Howdy folks..
I have a little script where it needs to check if the surface is water, to move a diver at the position and at the right depth.
if (surfaceIsWater _pos) then { Diver1 setPosASLW and so on....
Now my question is that I read somewhere that 'surfaceIsWater' may give the wrong result if someone clicks on a small river or something, not the sea.
Is it like that?..and if it is, how to prevent that?
no it is not correct
probably they click somewhere where the map is showing there might be water but there isn't
that's like a map precision error
another case where you might not get any result for surfaceIsWater is if the surface is simply using a water shader but it isn't actually water
I just want to avoid players choosing a little stream or river..need to be sea..
ok you can try this then
_testObj = "Land_wrench_f" createVehicleLocal [0,0,0]; //not sure what to use, but this will work
_testPos = +_pos;
_testPos set [2, 0]; //terrain surface
_testObj setPosATL _testPos;
(getPosASLW _testObj select 2) * -1 > 2 //depth is larger than 2 meters
not sure if you meant depth or width by "little", but this covers the depth
you can use some grid check (points around the pos) to also account for the width
depth was intended...
I wish there was an ATLtoASLW command
that way there was no need for a test object
Unfortunately it never got implemented
Oh man..you have been so helpful in the last few day and helped me many time. Will credit you in the mission dude..thank you and anyone else helping lost folks like me here..
no problem!
@serene quiver btw, don't forget to delete the test object when that script is done
I forgot to include it
@little raptor Thanks! I will try and figure this out. I'm pretty clueless when it comes to scripting, but this helps a lot!
check out https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting if you're new
anyone knows why my mission music (played while I was in a vehicle) stops as soon as I leave my vehicle?
how do I check if one of the two objects are the nearest from the player?
Like, objject1 is 100m from player and object2 is 50m, how do I check that in a array? like [objject1,object2]
MyObjectArray = [Object1, Object2, ...];
private _nearestObj = MyObjectArray # 0;
{
if (_x distance player < _nearestObj distance player) then {
_nearestObj = _x;
};
} forEach MyObjectArray;
ARRAY # INDEX is the same as ARRAY select INDEX.
cool
Ok..I'm back again...
as I stated above, I have this little snippet to teleport the player group in a SDV positionable by a singleClick command on the map.
https://sqfbin.com/zizekosofutimoyelama
It works great...It checks if there's water...BUT...if the player group has more than 4 units, there's a problem. So I declare a variable in the init.sqf (SDVsquadlimit = 4;)
How do I get the add action on the object where I call the script not showing up or better hinting the player that the squad is too big?
Thank you all.
There is no addAction in that script.
// Place the following addaction on a flag pole or similar object at the base. // this addAction["<t color='#ff9900'>Move SDV</t>", "scripts\SDVinfil.sqf"];
Ah, got it.
this addAction ["Title", {if ((count (group player)) > SDVsquadlimit) then {systemChat "Too many group members!";} else {execVM "scripts\SDVinfil.sqf";};}];
Is it worth converting arrays to strings, sending them over network and then converting them back to an array on the server. I am asking as (i think) dedmen said arrays were not good for sending across the network.
TOP!!!!
Hello again, i wanted to play more song one after the other but i don't know how to do it and i don't know the classname for the songs since they're customs musics
Forgot to say..is SP
for network traffic, if the array contains basic datatypes that you can just turn into strings and back, yes.
performance probably no
Basically i don't know where to get Classnames for custom musics
Alright thanks for the answer
or can i do something with triggers? like they activate once the previous song
Perhaps you are looking for https://community.bistudio.com/wiki/CfgSFX.
"Multiplayer
The next sound is chosen randomly on each computer, therefore in multiplayer each client may hear different sounds."
And?
I don't really know what you're trying to do.
ambient music that plays one after the other
I guess playMusic (or playSound3D).
@obtuse quiver 3den enhanced has an ingame music selector to get the classnames and hear the music tracks
on the tool bar on the top
prego😉
eheheh
Sorry bro..not working.
I got an error: Type group, expected string,array..
count units player
So it should be:
this addAction ["Title", {if ((count units player)) > SDVsquadlimit) then {systemChat "Too many group members!";} else {execVM "scripts\SDVinfil.sqf";};}];
?
Nope...lol...
OK..now with this
this addAction ["Title", {if (count (units player)) > SDVsquadlimit) then {systemChat "Too many group members!";} else {execVM "scripts\SDVinfil.sqf";};}];
it say it's missing a ";"...LOL
this addAction ["Title", {
if ((count (units player)) > SDVsquadlimit) then {
systemChat "Too many group members!";
} else {
execVM "scripts\SDVinfil.sqf";
};
}];
```Brackets in the condition were (still / again) wrong.
Always think, look and copy-paste precisely when programming.
👍
working like a charm! Thank you man!
why have the if statement inside the callback, and not in the condition?
For the systemChat.
which you won't need when the option isn't available to begin with 😉
In terms of usability it'd props be good to give the player info on why it doesnt work though, no?
How do I get the add action on the object where I call the script not showing up or better hinting the player that the squad is too big?
Client suggested it himself and it's always better to communicate openly with the player instead of showing the action to some and having others guess why they don't see it.
THIS!!
"Client"? You're getting paid for this? I need to talk with Dwarden fast! 🤣
I'm sure he's referring to the one playng the mission the missio-maker delivered..right?
I wish 
😂
Damn,
is a cute little guy.
Triggers are executed globally right? so if i put player setdamage 1; it will kill everyone?
yup
hmm any tricks to make it local?
Krtecek best ever
dedmen can we have an option to make triggers local or global 🙂
Scripters have that option 😛
global or server already exists
so if i tick the server thing it wont kill everyone??
That's hardly scripting, is it?
no, but it also won't execute on any client
ohh okay
i could not spot any local target on remote exec either
but i have feeling im about to be proved wrong
Well that's easy
anyhow; in the activation code you have access to 2 variables:
thisList - list of all objects in trigger area, based on 'Activation'
thisTrigger - trigger object
So you can use:
{ _x setDamage 1; } forEach thisList;
iirc
which will execute for everyone who is in the trigger when it triggers
thats great thank you
PS. not entirely sure how that behaves with AI and vehicles though, but when it only triggers on players, it will only contain players