#arma3_scripting
1 messages Β· Page 208 of 1
It doesn't halt time, but at least makes it 10 times slower
@winged thistle <ding.
Thank you sir!
hello all: How would i cods this better: for the player to have to stay within 3m of a LabTop:
or the script will exitWith:
i must be doing something wrong:
if ((_player distance _object1) >=3) exitWith
{
"Downloading Canceled\nYou Must Stay Near The Laptop" remoteExec ["hint", 0];
"invalidCoords" remoteExec ["playSound"];
};
is there anything else to this around it?
ummm yes
here ill put it all up
private _timeleft1 = 50;
while {true} do {
hint format ["Downloading... :%1", [((_timeleft1)/60)+.01,"HH:MM"] call bis_fnc_timetostring];
if (_timeleft1 < 1) exitWith {"HintSound" remoteExec ["playSound"];};
if ((_player distance _object1) >=3) exitWith
{
"Downloading Canceled\nYou Must Stay Near The Laptop" remoteExec ["hint", 0];
"invalidCoords" remoteExec ["playSound"];
};
_timeleft1 = _timeleft1 - 1;
"HintSound" remoteExec ["playSound"];
sleep 1;
};
it seems to go past the exitWith
even if i go away from the labtop
i'm assuming this script is run every time they reenter and hit like an action or something?
yes addaction in a labtop
move your distance conditional into the while conditional
have the stuff in the exitWith after the while loop
lol hahahah good 1
Exactly what I was looking for.
"I feed on the braincells leaving your ears" is what I tend to say :D
dam they shot my Ex chopper while i was at the labtop π
now i must call the chopper and w8 till it gets here π
hey guys, new on scripting here, i wanted to know if its possible to make the pilot of any armed chopper with a main rotatory gun that is controlled by the gunner ,make it fully controlable from the pilot seat without the restriction of the main gun locked to only shoot and not move, is principaly because where i play there is no one that wants to be the gunner
you can just put Manual fire on in the menu commands of the chopper or just have a Ai guy in the Gunner seat and the Ai will do Aswome : even at very low skill
and group the Ai guy to you and you can order him to target diff targets
after Manual fire Mode is on: switch to diff fire mods like the main gun or rockets
i forget if you can not have the main gun locked or not, as pilot, i guess not maybe
cuz i kinda remember having to get in the gunner seat and make the main gun be set where i wanted it then getting back inthe pilot seat π
yes, that what am using right now
I have a problem, task doesn't create on a FOB positions
I have all fob pos on Altis as public variable
KIB_fobPos =
[
[12299.7,8874.09,0],
[8315.24,10063.8,0],
[10009.4,11235.1,0],
[3037.7,13185.6,0],
[5233.49,14192.8,0],
[4867.37,21911.1,0],
[9706.21,22308.9,0],
[9961.02,19355.7,0],
[13819,18967.9,0],
[16600.2,19037.1,0],
[12809.9,16683.8,0],
[15357.4,15874,0],
[16770.3,14982.8,0],
[20591.4,18813.2,0],
[21022,18981,0],
[20596.2,20113.7,0],
[25301.2,21797.8,0],
[28317.4,25775.4,0],
[22636.5,16819,0],
[14280.3,13031.8,0],
[15407.3,11343.7,0],
[20083.5,6730.44,0],
[23062.8,7279.58,0],
[16664,12293.8,0],
[16824.5,12047.8,0]
];
publicVariable "KIB_fobPos";
then I want to create a task on a random FOB pos
_uberPos = selectRandom KIB_fobPos;
[KIB_mySide, "tsk", "fob", _uberPos, "CREATED", 1, true, "attack", false] call BIS_fnc_taskCreate;
the task marker ends up somewhere completely random in the see π
Is it actually completely random or is it the same wrong position every time?
its random, FOB positions are legit, I tested them one by one with
player setPos [12299.7,8874.09,0]; //for all positions etc
Test the _uberPos variable
good idea
yeah it gives false positions
_uberPos = selectRandom KIB_fobPos;
player setPos _uberPos;
player ends up in random place, not in the predefined position π€
wtf is wrong here ...
test with sytemChat str _uberPos
and what did you get from that
if it matches with the predefined positions
no, it doesn't
so, what I can recommend for you rn, is to have empty markers in those positions, in the editor, and get the markers using the same command, and then get the position of the selected marker instead
place one or two markers and test it
Where KIB_fobPos is set and where tasks are created? Both should be on the server.
I don't want to have so many markers for performance reasons π«£
the same thing with comm towers is working fine
KIB_enemyCommTowersPos =
[
[18708,10222.2,0],
[19359.1,9687.59,0],
[17851.4,11735.9,0],
[25295.5,21817.8,0],
[26454.4,22175,0],
[26279.2,22188.7,0],
[4264.85,20663,0],
[6839.78,16163.1,0],
[4572.56,15389.6,0]
];
publicVariable "KIB_enemyCommTowersPos";
then
_uberPos = selectRandom KIB_enemyCommTowersPos;
[KIB_mySide, "tsk", "comms", _uberPos, "CREATED", 1, true, "download",false] call BIS_fnc_taskCreate;
works perfectly
@faint burrow both executed on server
performance? lol
Then check if KIB_fobPos is overwritten.
@faint burrow you are genius/me idiot, I have it defined again at the end with positions from the previous map I made, so it got overwritten, thank you so much π»
π
I, like @thin fox, recommend using markers, as it is more visual and easier to maintain.
yeah, generally but there are zillions of positions for things on the map - fobs, bases, convoys, comm towers, trenches, etc and markers cost resourses (much less then triggers but still)
And markers don't affect performance, only the size of mission.sqm file.
Trying to follow logic ... Placed markers make mission.sqm file bigger since they are like every object placed in eden. Predefined positions don't , they are stored in other file called from server. π€·
the question is, do you really need to worry about the performance?
Right.
Let's imagine you need to change a position relative to others. If you use markers, you simply open Eden and move the marker. If you use positions, you need to somehow visualize them in the editor (for example, create markers), change the position, and save it in the variable.
Obviously, the first approach is simpler, even though the mission file will be larger.
Plus, since you have a lot of positions (for FOBs, convoys, etc), you can place markers in different layers and hide them, use different colors, etc.
if you're not doing a liberation 2.0, that is know to have performance issue because of bad scripting, you shouldn't be worried about the performance in your mission, most of dynamic scenarios use markers because it's easier to maintain, like Schatten said
i am making a sandbox on liberation scale but different gameplay
if it was coop mission I won't be concerned with performance so much
Plus, mission file binarization can be used, this slightly reduces the size.
I don't even use custom pics because the .sqm size I said bs π
I was going to say something haha
pvp?
pve
how to check the "class type" of object ? I have garrison script, its working for houses, some towers but I want to add bunkers
_validHouse = nearestObjects [_uberPos, ["house"], 100];
What's the purpose of sleep .5 in there?
it doenst
check parent class in configs, but you can add the classname of the object itself in that array afaik
@thin fox yeah, quicker this way ...
I have a question connected with what @faint burrow said about mission.sqm size ... When things spawn after the mission start does mission.sqm gets bigger like dynamically or it doesn't matter?
I have played around with putting an addAction in the init of various in game items. Specifically ones that can be picked up and kept in inventory by players. The action works when walking up to the item and triggering it. However, when you pick it up and place it inventory, the command no longer works when placed on the ground again.
Is there a script way to force the action to be available, or is this just a quirk of the engine?
I am thinking that it erases the line each time. I am hoping there is a work around to add the script to all items of that class variable, when they are accessed or spawned.
So far cell phone and laptop. Vanilla/DLC, no mods.
@tough abyss setVariable
Thanks, looking at the wiki now. How do I tie this example to an SQF? I am still new to writing stuff off the cuff, but should be able to swing it if I know how to retrieve the correct script.
_myTruck setVariable ["TAG_myPublicVariable", 123, true];
if the object gets destroyed
missionNameSpace setVariable ["MAR_someName", 123, true];
//then
_variable = missionNameSpace getVariable "MAR_someName";
but if its just addAction you can reapply to the new object
you can use EH
(backpack player) addEventHandler
[
"Take",
{
params ["_unit", "_container", "_item"];
if (_item == "classname_of_item") then
{
_item addAction ["Something",{your_code}];
} else {};
}];
@tough abyss this will add addAction to an item with specific classname you take out from your backpack
Thanks, I can see how that works, should be perfect. The goal is a cellphone or laptop with online shopping features. We have the shops and websites working in NPCs, and static objects, but want players to be able to purchase (with game money) these usable items in our tech shop for portable access to game features.
I call this "buying laptop" the player have to put on the ground first and start buying π
better solution will be just addAction to player that opens a proper buying menu but good luck with GUI scripting
Haha, I thought of that. Would it be possible to make that like a "key" to access a new menu page with our gui? Then it would feel much more natural!
I can add a button to the main one, and all of the shops to a web browser that pops up.
I have the gui made, and can add new pages/scripts no problem. Just need an idea of how to make the "if" to use that new button, be possession of the item class.
just check if the player have it
Wow, overthought that one, lol. Can you send me the variable for that? I can read the wiki. Should have it sorted now.
this can be used to check if player has an item with specific classname
everywhere - uniform, vest and backpack
Thanks, you helped me get this one ready to finish. hasItem will be helpful for many things. I wanted to add a debit card (currently cash only system with bank account), so that is done now, as well. π»
That's because the action was added to the invisible container, not to the item itself. And when you place it on the ground again, a new container is created.
That makes perfect sense. I only tested it three times, and knew that it was not going to work that way.
One last thing. Just want to be sure I have it, fully. We wanted to make these usable only in major towns, and at Internet cafes. I can use a trigger area and hasItem for that?
As if using WiFi
Yes, I believe this is the most optimal option.
I sense Jagged Alliance inspired scenario π
Is there a way to disable all damage to players from vehicle impacts?
What is "vehicle impacts"
Like from being hit by a vehicle
I have found something fishy, there is no position in "Land_HBarrierTower_F"
_bunker buildingPos 1;
returns [0,0,0];
no available pos a unit can spawn
same command applied to "normal" bunker "Land_BagBunker_01_large_green_F"
gives [5886.69,3064.83,23.6902] and a unit can spawn inside
take a look at this https://github.com/KillahPotatoes/KP-Liberation/pull/975
First, don't forget to try buildingPos 0 as well. Arrays are typically zero-indexed, meaning the first element is index 0, so if there's only one position in the building, then it may be position 0 and position 1 doesn't exist.
Second, building positions are manually set up as part of the building model. If whoever made the building model didn't put any in it, then there aren't any to find. Not fishy, just lazy or inexperienced modellers.
Not really for vanilla, the vehicle isn't passed to handleDamage. You could try grabbing nearby vehicles and checking if the ammo is empty, but won't be reliable
I think with ace you may be able to, they have a setting for if you should take damage when the vehicle you're in hits an object. I imagine it's the same story though, vehicle isn't passed to the wound handler iirc
@hallow mortar doesn't give good position neither, its [0,0,0]
but a vanilla bunker "Land_BagBunker_Large_F" have 12 perfectly fine positions π€
It's different per object (technically model)
Second, building positions are manually set up as part of the building model. If whoever made the building model didn't put any in it, then there aren't any to find. Not fishy, just lazy or inexperienced modellers.
Lots of things in Arma are inconsistent because they were made by different people and/or at different times.
@hallow mortar unfortunately you are right, same thing with towers, some have positions and some don't π€
you can still use relative position
https://github.com/PiG13BR/KP-Liberation/blob/cd235cfbab26ffdfd447b9979900f4280e548afc/Missionframework/KPLIB_staticsConfigs.sqf#L39
take a look in this preset. I use this to spawn static weapons in liberation, in pre-defined positions in some buildings.
My idea is, when no position is found, then it uses the preset
i was thinking you were going to say something about fish π lol
@thin fox is the code working with unit class names because I want to spawn infantry ?
no, but you can adapt to it, it's just a matter of spawning an unit instead of a static weapon
got it, I will work it out tomorrow, it will be very helpful for no pos buildings, bunkers, etc
@crimson lion About #arma3_feedback_tracker message:
For the six-digit grids in vanilla A3, converting from grid to position is simple. If I remember correctly, each grid square has a size of 100Γ100 meters.
You take your grid string (e.g. "018056"), split it in the middle to get X and Y (["018", "056"]), parse each part as a number ([18, 56]) and multiply that number by 100 ([1800, 5600]).
The longer the grid string, the more accurate the location: If the grid string only had four characters, you would multiply by 1000; if it had eight characters, you would multiply by 10.
What I have is a script that is putting a dot on every grid that has an eligible building within it (eligible buildings are calculated external of this part of the script as Bro_NmeBuildings), please forgive me if this is sinfully bad. I want to make a working thing before I make an optimized thing: https://pastebin.com/pXGQQsge
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
// find any building within 50m of this grid center
private _nearby = Bro_NmeBuildings findIf {
_x distance2D _gridPos < 50
};
```This part is not correct. `_gridPos` is the center of a 100Γ100 square. You want to know if that square contains `_x`, but you search a circle with radius 50. That circle does not cover the entire square.
Have you seen https://community.bistudio.com/wiki/mapGridPosition ?
You could do ...
private _grids = Bro_NmeBuildings apply { mapGridPosition _x };
```... to get an array with all grids that contain an eligible building. Then you could calculate the position of each grid with `BIS_fnc_gridToPos` and place your markers.
A more efficient approach would be taking the position of an eligible building (e.g. `[1234.5, 6789.0, 42]`) and doing some math magic to round the X and Y coordinates down to the nearest multiple of 100 (`[1200, 6700, 42]`). Then you could place your marker at `[1250, 6750]`.
man you do all that: man i just place down markers near where i want: ( what ever to happen) like i have like 50 markers at per defined locations: then i just select random a marker and make happen what ever i want to happen at the random selected marker
if i'm dealing with houses or buildings then i place some markers within some buildings area around the map
but every grid pos wow oh man
i knida see what you are doing there but wow lol π
i reason i place the markers at per defined locations is so no docks or over water locations can be picked
it all depends on the radius i'm using from the markers also
really the most markers i ever had was 35
can be more if i want
the current version thankfully works but its just a bit heavy handed. I'll try doing some rounding with the building's position and maybe pushbackUnique to an array of eligible grids? If I'm understanding that one right. BIS_fnc_gridToPos doesn't work on servers apparently
Total time to run is 1.072 sec on Malden but 9.71 sec on Altis lol, maybe that's worth it for something that only has to run once at mission start. Hmm... just kinda thinking through this one, thank you for the inputs
you bet my friend
You could run the search beforehand e.g. in editor and just include the results in the mission maybe?
do you spawn them markers in
I'd like to have it require a minimal amount of editor setup or pre-determined things, so that if a new map comes out someone can just plop down whatever from the existing version into a new map and it adapts. Which it does wonderfully so far, just this part is the biggest drag. And yes, I spawn in markers- I can use them to simulate a pseudo heatmap of sorts, here exaggerated for effect:
i use empty markers also
The final product will have grids marked as rectangles actually, really similar to how the Insurgency gamemode does it. I guess I'm making a knockoff, lightweight insurgency
ok i see: yes Insurgency was fun i remember that
What about using precalculated positions if available and if not, defaulting to the dynamic search at start?
you may as well use EOS framwork form bangerBob that is Awsome
EOS_1_98
i know its fun to make your own π
as i did
Right now, you are running upto NumberOfBuilding times NumberOfGridPositions checks. If your "rectangular" dist is 50, and your grid is 100, then by definition each building defines at exactly one grid position as ansin11 suggests. By flipping the search logic you can reduce the number of checks hugely. For example Altis 20km x 25km is 50000 points. So if you flip the logic you might get sub <10ms runtime.
True, managed to miss his message x)
yeah i try to keep the number of building checks low as i can
but i only make 10 player missions so well you know
Something like this:
private _gridPositions = [];
{
_gridPos = (getPos _x) call Bro_NmeNearestGridPos;
_gridPositions pushBack _gridPos;
} foreach Bro_NmeBuildings;
// TODO: remove duplicates (grid positions that "contained" multiple buildings.)
Something like this could also work:
private _gridSize = 100;
private _grids = createHashMap;
private _buildings = nearestObjects [[worldSize/2,worldSize/2,0],["House"],worldSize,true];
{
private _pos = getPosASL _x;
private _gx = floor ((_pos select 0) / _gridSize);
private _gy = floor ((_pos select 1) / _gridSize);
private _key = format ["%1_%2", _gx, _gy];
if (isNil {_grids get _key}) then {
_grids set [_key, true];
private _center = [_gx * _gridSize + _gridSize / 2, _gy * _gridSize + _gridSize / 2, 0];
private _mkrName = format ["mkr_%1", _key];
private _mkr = createMarker [_mkrName, _center];
_mkr setMarkerType "mil_dot";
_mkr setMarkerColor "ColorRed";
};
} forEach _buildings;
Gahhh okay it's down to 1.5 sec on Altis!!!! Thank you all
{
private _thisPosX = floor ((getPos _x select 0) / 100) * 100 + 50;
private _thisPosY = floor ((getPos _x select 1) / 100) * 100 + 50;
private _assembledGrid = [_thisPosX,_thisPosY];
Bro_NmeGrids pushbackUnique _assembledGrid;
} forEach Bro_NmeBuildings;
{
private _markerString = format ["marker_%1", _foreachIndex];
private _mark = createMarkerLocal [_markerstring,_x];
_mark setMarkerShapeLocal "RECTANGLE";
_mark setMarkerSizeLocal [50,50];
_mark setMarkerColorLocal "#(1,0,0,1)";
} forEach Bro_NmeGrids;```
How do I get pretty codeblocks with color formatting like that?
Please use !sqf from now on (!enforcescript soonβ’)
!sqf
```sqf
// your code here
hint "good!";
```
β turns into β
// your code here
hint "good!";
Ohh shit sick
My solution above it only takes 0.169 seconds to compute on altis why not just use that ?
I am filtering out buildings on criteria, with yours ists about 1.39 sec
Thank you though! Thats very robust
Also i would recommend you to just cache the buildings so you dont have to do a check everytime you lanch the gamemode or what ever you are building. At least for vanilla. Basically just casche for vanilla stuff and if its modded world then do the check.
btw. this may interest some https://forums.bistudio.com/topic/187670-new-command-createobject-for-decorative-objects/
New command createObject for decorative objects - posted in ARMA 3 - DEVELOPMENT BRANCH: since 134151 there is a new command in dev. version - createObject
(will not yet be part of next patch)
Β
what is it good for:
Β - will create object, that is based only on shape (no config needed)
Β - object is not simulated, so it will save some performance (no physx, no sounds, not a interesting target for AI,....)
Β - unlike whole vehicle, it needs very little information to synchr...
@twin garnet paste your addAction in here please?
player addAction ["Script1", { hint "test" }];
(sorry if its a silly error. I havent done scripting in a real long time.)
The code block is since TKOH
use " for arma
player addAction ["Script1", " hint 'test' "];
Oh it works now. Thanks nick! π
Yeah its A2
yea brackets are since TKOH
Ah right, thanks for the heads up.
you can also do diff for git like edits for when you help others
- private _fruit = _this select 0;
- private _veg = _this select 1;
+ params ["_fruit", "_veg"];
Woah, that's sick didn't realize that was an option.
Right, is there any way you are able to read the contents of a WeaponHolder in A2?
isnt it just a vehicle with cargo?
I suppose it is, yeag
Does anyone know how to restart a server or mission on a dedicated server after the mission ends using ["win"] remoteExec ["BIS_fnc_endMission", 0, true];?
When I rejoin from the lobby, it triggers the mission end again.
Yeah*
Thanks will try this again π€
Im trying to make a script to veiw the contents of the weapon holder without the player needing to interact with it
getMagazineCargo is hopeless -_-
For the handleDamage EH, does a mine count as a source or instigator? Ex: APERSTripMine, APERSMine, or APERSBoundingMine
Well, you can test it by adding a systemChat str _this and walking into a mine, but I'm pretty sure mines are ammo
Okay, thanks
Ammo will be the mine, source / instigator should be the unit that placed it
Could someone DM me about sending game data like player x y and z to an external application? I can't do any coding right now but will be able on the weekend
Look into https://community.bistudio.com/wiki/Extensions . Maybe you can a pre-existing one that does what you need.
So for example I made an extension and I submit it to be whitelisted by BattlEye... Will I need to ask BattlEye to white list the extention again if I update the .dll?
or make any changes to it
Don't know, but would imagine any change to the file would require it, yes.
or just have the server turn off BattlEye? as that looks like the easy way lol
Yes, you can do whatever, if you don't need BattlEye active.
This worked fine for me in small trust-based clan. For public servers probably not so wise, but I don't have experience there.
okay thx
My wish back in the day would probably have been a "generic" extension whitelisted by BattlEye that supported general sqlite and JSON over HTTP calls.
Confirmed! I got it to work today like this. Grabs the huts around a position and turns off damage.
[
{
{
_x allowDamage false;
} forEach (nearestTerrainObjects [[7809,9098], ["HOUSE"], 80]);
}
] remoteExec ["call", 0, true];
nicee, but why are you remote exec this? and it's not recommended doing in this way
are you calling this inside a trigger?
allowdamage has global effect
I put the code in initServer.sqf. It wouldn't turn the damage off on clients until I remoteExec it.
Then do this in init.sqf then. Don't remote it.
Copy that. This begs the question though, how do I know what goes where? I read the initialization order wiki and some info on the individual .sqfs but can you give some example of why this code works better in initPlayerLocal so I can understand why better?
But still, allow damage should be run locally to who owns the building, which should be the server for map objects unless they are local objects. Would need to test to see where these buildings are local to.
Well, the best place would probably just be in init.sqf, because it's run on every machine
The buildings are terrain objects if that helps.
That way every machine has their own copy. Which remoteExec is doing but now without the network usage.
But what about JIP players? Their machine wouldn't receive the code to turn off the damage, right? I don't know what behavior that could result in. Maybe they would be the only ones that could damage the buildings?
Every machine when they join the game runs init.sqf
It's why you have to be careful with it.
That's where I get confused because the wiki says init.sqf Executed when mission is started (before briefing screen). Which made me think that if someone missed the mission start they would'nt get any of the code in there. Hence, that's what initPlayerLocal.sqf is for. Otherwise, what is the difference between them?
They both run when the mission is executed by their related machines. Init.sqf for all machines, and initPlayerLocal.sqf for machines that have a player.
So if a player JIP, then every client runs init.sqf?
When a player JIP, only their init.sqf is run.
As well as their initPlayerLocal too?
yes
think that the server is another machine, so event scripts like initServer, init.sqf, it only runs once at mission start (a server machine cannot enter the mission π ), the server machine loads the mission once, the client loads the mission when they enter the server/pass the lobby and they can rejoin, and read all those files again...
Whats the proper way to ensure a player has completely loaded into the game before executing a function using CBA_fnc_WaitUntilAndExecute?
I've run into an issue in playtesting. Players must use a holdAction on a unit in order to proceed. However the way ARMA works is if that unit is in a vehicle that explodes, they disappear, which breaks the mission.
Solution? Add a killed EH to their vehicle that checks if the unit is in their vehicle and teleports them out, so players can still progress?
by using initPlayerLocal.sqf
No can do - From a mod perspective, I have the XEH_postInit prepped but on rare (now seemingly common) occasions, the race conditions fails
The isNull player is faster than the functions being initialized properly for it to work
ah okay
Got the solution from Dart - Use CBA_missionTime > 0 instead
Have you tried force ejecting the body when killed?
I haven't tried anything yet. I thought about moveOut when the vehicle explodes. But now that I've put more thought into it maybe I like that the corpse can't be recovered. I forgot that it wouldn't break the mission since I redesigned it. And might add a nice layer of challenge for players to only disable the vehicle. Might sleep on this one and decide.
Hey @lavish ocean, any chance the RscObjects will be improved like in DayZ SA? I would love to have a projected character with animations instead of a T pose. :)
REST api is on my plan, but dunno when.
But it will need to be quite limited on clientside for security.
I don't think BattlEye does submissions anymore, they depend more on the auto whitelist (many people try to use your extension for a while, it'll be auto checked and whitelisted).
Yes any update would need re-whitelist.
Also note that server-side extensions, don't need BattlEye whitelist. So if you can do your work on the server, that's better
If someone makes a properly good open source one, I can whitelist it.
So far I've only seen quickly mushed together ones made for one specific use case.
Not a proper one with proper API that does all the things and can be used for everything, preferably also with proper security like webbrowsers do.
I even made my own one, but it has a shit API (that is optimal for my specific use case though) and doesn't support all the HTTP things you'd want to mess with.
Now with native JSON and Hashmap support in script, its easier than ever to pass complex commands to an extension.
With Extension Callbacks and upcoming async task script feature it also becomes easier than ever handling the results of such things.
But someone who knows this stuff would need to properly sit down and invest a few weeks of time. I would if I had the time. I would start the project if I had someone to help me finish it, but no-one ever did for all my past projects so that won't happen either.
But I'll probably do one inside the game anyway. Or get someone else to do it π
Found a fun locality issue and workaround.
In MP, if you force a local AI into a remote turret on a local vehicle, it will jump out of the vehicle when the turret becomes local, which usually takes a few seconds. As far as I know, there's no way to force the AI to stay in the vehicle when that happens (I think I tried everything). You must either get into both the driver and turret (to immediately force both to become local) before forcing the AI in, or delay forcing the AI into the vehicle turret until the locality propagates to the turret. I ended up doing the latter. There is a third option, which is to force the AI into the turret, wait until the turret becomes local with turretLocal, and then force the AI back in. That looks mostly seamless, but can be trouble if the vehicle is moving (the AI can fall out, get knocked over, and then refuse to get back in until it gets back up) and wasn't necessary for my use case.
Another solution is to spawn an alive checker. If the unit is no longer alive or no longer exist, progress / fail the mission / make alternative route.
Beware there may be some issues with moving/ejecting units out of destroyed vehicles.
that's funny: i never had any problem with that at all in MP or SP or DeD, Ai stay in any turret any time i move them in: or spawn them in a turret: But then: i only use vanilla:
anyone interested in a script chalange? im trying to get buildings to spawn a certin way but its not smooth and im getting 2 building spawning ontill one deletes .. id like to just have one and a smother script.. sorry if this is hard to read .. but if interested ill post it on paste bin in a moment
Can I get players location on the server side and also if there's object in between two players?
yes
Yeah that's normal and quite irritating.
Related issue is that it takes pretty long for a unit to switch locality from server->HC. I figured it'd be remoteExec speed but it's much slower.
Hello everyone, is there any quick easy solution, to unload cargo (in example jeep in cargo of chinook) on choosen place? whatever I am trying to do Chinook is just landing and immediately takes off with jeeps still in cargo
how to check if building pos is used by a unit ? I need to spawn some units in a bunker but they keep spawning on the same pos
private _allpos = _bunker_a buildingPos -1;
private _runit = selectRandom KIB_enemyInf;
private _unitpos = selectRandom _allpos; //need to remove this pos from all pos array
private _bnkunit= _bnkgrp createUnit [_runit, _unitpos, [], 0, "NONE"];
_bnkUnit setUnitPos "UP";
_bnkUnit disableAI "PATH";
you should rather keep track of that yourself I would say
oh, I misunderstood, you're trying to do this with AI
A combination with these commands should do it
https://community.bistudio.com/wiki/landAt (syntax 3)
https://community.bistudio.com/wiki/setVehicleCargo
oh thanks I am stupid, i was looking at this but I thought it is only for loading
Any ways I can render an aircraft pilotcamera unusable via script? Ideally unable to rotate. Would go into the code called by a vehicle config init eventhandler.
ViV commands are not intuitive
what is the best method to storing ammo value in a current magazine and returning it back later in a script?
Is it possible to for example to clear a weapon with 102 rounds in the magazine, empty the magazine, store the count, then restore it back to the exact amount?
There is no good way to do this.
there⦠is?
To be more specific I'm trying to empty the ammo completely while a armed vehicle is inside a trigger, and then restore it once it leaves the trigger.
I believe there is an addMagazine or some other command's alt syntax to add a mag with x bullets
Oh, vehicles are different anyway. Not messed with vehicle mags much.
Yeah sorry should have mentioned it was vic
Yeah but you can't add it into the weapon directly.
not even if it is the first magazine you insert?
You have to remove all the valid magazines, add only the 102-bullet one, then add the weapon, then add the other magazines.
I don't know of any way to finesse which magazine is chosen.
yeah ok, missed that one.
I never used it, but I carefully stored it in a side memory cell for when I would need it π
Not sure if there's a command to get the current ammo in the weapon magazine either...
But there's probably another one I missed in this mess.
ammo
i've got this code to pop up a discord link, i want to use this in public zeus but i assume its not working because of the remote exec. could anyone give me some pointers as to how i could fix it:
[{
0 spawn {
if (isServer && isDedicated) exitWith {};
waitUntil {sleep 0.1; !(isNull (findDisplay 46))};
if !(isNull (findDisplay 312)) exitWith {hint "Discord notification send."};
private _display = (findDisplay 46) createDisplay "RscDisplayEmpty";
private _button = _display ctrlCreate ["RscEdit", -1];
private _xCord = safeZoneX + 0.02 * safeZoneW;
private _yCord = safeZoneY + 0.02 * safeZoneH;
private _w = 0.2 * safeZoneW;
private _h = 0.05 * safeZoneH;
_button ctrlSetPosition [_xCord, _yCord, _w, _h];
_button ctrlSetBackgroundColor [0, 0, 1, 0.5];
_button ctrlSetText "Our Discord: https://discord.gg/";
_button ctrlCommit 0;
hint "You can join our discord by copy pasting the link. Once you are done you can press ESC to close the menu."
}
}] remoteExec ["call", 0, true];
the idea is that zeus/ co zeus dont get the link
you⦠remote exec a call of a spawn to then avoid the server :D
only if not self-hosted
[0, -2] select isDedicated
and the (isServer && isDedicated) check can be replaced by (!hasInterface)
this way even headless clients won't have it
alr, ty.
i tried before to use: [0, -2] select isDedicated
but that made no difference
[0, { /* code */ }] remoteExec ["spawn", [0, -2] select isDedicated, true];
```saves the spawn's call
ah i see, thats clean
but ofc it is better to make a function to ask for a call of it, this way you don't send the code through the network, only the function's name
everything remote exec related is locked down?
Never dealt with it personally but I remember someone else having that issue.
I guess see what happens with various test code when you click run as server.
What would be the muzzle for a main gunner cannon on a btr?
im trying to be able to put it in a composition so the zeus can place it whenever someone asks for the discord link. since its annoying to copy the whole link letter by letter. but ig i might just be stuck by the remote exec
you can find it using e.g currentMuzzle (or weaponState)
is there a page somewhere explaining the RE limits on public zeus?
So I cant just remove a muzzle's magazines if theres nobody in it? It seems to only return muzzle if player/ unit is currently using it. The goal is to seamlessly remove mags of all muzzles and restore them back to exact ammo counts. But maybe the idea is not as easy as I thought
Its for vehicles not infantry
so?
i/e: BTR enters trigger > ammo value stores > magazine removed > BTR leaves trigger > magazines restored with previous ammo counts
I think I will just work on a different approach tbh
Does not quite work with vehicles. If you need to remove all weapons from a vehicle, remove each weapon individually (see removeWeapon)
β removeMagazinesTurret β
something tells me you don't want to do all that, rather your need is to prevent vehicles from being able to fire, correct?
Yeah this would be ideal but it would probably require some type of keydown detection
Removing / adding mags to the vehicle is no issue. The issue is it restores them to full capacity. So that means players would exploit it for free ammo replenishment.
In order to set the stored ammo value, I need to define the current muzzle etc. If no player or unit is in the btr gunner, it returns with " "
I had my fingers crossed there was a 1-2 step solution π
what is your exact goal, that's the trick π you don't want to play around with mags, what do you want to achieve?
"Armed vehicle (all vehicles of any type with a weapon) not allowed to operate/fire in given trigger area"
Essentially just that
you can:
- remove magazines as you are doing now
- remove weapons (which implies re-adding them and re-inserting the magazine or setting the mag/count)
- add an event handler that would delete all fired things as long as they are in the area
- kill the gunner :-p
etc
@silent cargo you don't need to empty the ammo: you can just restore it as you say:
@silent cargo do you mean like a Rearm Repair and Reload statrion
oh i see: not allowed to operate/fire in given trigger area"
_unit setVehicleAmmo 0; //take ammo away
_unit setVehicleAmmo 1; // give all ammo back
Yeah. basically just something to emulate "safety" when "InSafeZone.sqf"; triggers (clears all ammo, and stores partial mags), and then restore the ammo when "LeftSafeZone.sqf"; (ammo restored to previous values without giving free full replenishment)
Because with that, players will just drive out, shoot, drive back in, leave area and keep getting free ammo lol
I will just do event handler for fired and delete the projectiles. Seems to be the better route
ok cool
I appreciate the help though. Thanks bro
rgr
I have an alternative that I use in my ops, I'm not at home rn
it's an addAction with fire button as keybind
like the one from I&A
If you remember later, feel free to drop it here and I will check it out
I have an issue regarding leader. If a player, who is the leader of the group, disconnects from the mission, then the new leader becomes an AI that was added during the mission with join.
I was wondering if there is a command that could set a unit as unable to take leadership?
As a temporary fix, right now I have an EH that monitors when leader changes addEventHandler ["LeaderChanged". When that happens, I have it check if an AI is the leader and, if so, to reassign it to a human. Seems to work ok but maybe there is a better solution?
is it possible to use scripts to draw lines on the map?
i've tried
drawLine3D [start, end, color, width]
and
map drawLine [from, to, color, width]
i can't seem to figure out how it works
Post your cureent code and result
addMissionEventHandler ["Draw3D", {drawLine3D [(ASLToAGL getPosASL player), getPos cursorTarget, [1,1,1,1]];}]; last thing i've tried
result: nothing appears, outputs growing number
The end-goal is making a box around an object, if i can get a single line to work i think i can handle the rest, but not even that works
draw uiEventHandler for things on map
You can also use markers, via setMarkerPolyline or setMarkerShape "RECTANGLE"
@blissful current can you have that Ai die if the player disconnects ?
No but in testing with the EH the switch from AI leader to player leader happens so fast I don't even notice it. This temp solution might be a permanent solution now π€ π
oh wow cool nice
its kinda funny i never had anyone disconnect from 1 of my mission: thats why i did not know about this π
that's maybe cuz i only make 10 player missions
unless its a PvP mission then its 20 players of course: 10 on each side
I would use the same method
Not sure if this belongs in this channel but someone might be interested:
With the new web browser hud, it's now possible to get players' battleye id (beid) from their guid with javascript. Previously we were only able to do this by triggering the beclient guid server command and intercepting the systemChat and reading it off with regex.
Now, all you need to do is import an md5 library like cryptojs in the hud and do this:
if (!uid) return "";
let id = BigInt(uid);
let payload = "BE";
for (let i = 0; i < 8; i++) {
const byte = Number(id & 0xFFn);
id >>= 8n;
payload += String.fromCharCode(byte);
}
return CryptoJS.MD5(CryptoJS.enc.Latin1.parse(payload)).toString();
}```
You need to use a ctrl eh on map to use draws
Draw3D draws in the world
Call these scripts on a trigger (activation: any player, untick only server, player in thisList as condition), on activation field and deactivation field, respectively.
It prevents players from firing its weapon and also veh weapons, and it deletes any grenades throwed by the player in the safe zone
Hello everyone,
I am looking for a way to manipulate or set the player's customWaypoint via script without having to set a βsimpleTaskβ or similar for them.
I have already figured out that I can read the waypoint set by the player via customWaypointPosition.
But is there any way I can set it?
Will give this a look thanks !!
what do you want to do with it?
@thin fox
In a mission, I would like to be able to double-click on a location in a tablet where you have to make an external load flight.
However, since the destination can be freely selected, a task system does not make sense.
Depending on the progress of the mission, there can be as many as 10 or 15 possible destinations.
Once the load has been dropped, the waypoint should automatically be set back to the base, etc.
what about markers?
and what about waypoint?
adding a waypoint should work the same way
Do you mean simple map markers?
I need something that can be seen outside the map on the horizon.
The problem with waypoints is that I can only set them for the whole group, not for individual players.
But I don't need them for the groups, I need them for the individual players.
So there's no way to replicate these waypoints using a script, and you have to get creative or just leave it?
So, what do you have there? A logistic team?
put them into a group in particular, that way it separates from the others players
Thank you very much for your help and information. I'll experiment a little.
I was mainly hoping that there might be something like βSetCustomWaypointPositionβ or something similar that I just couldn't find in the wiki, or a workaround that isn't described in the wiki.
But that doesn't seem to be the case.
You could use a combination of markers and draw3D
There's no way to manipulate the built-in custom waypoint system but you can make something of your own that works similarly
Can anyone help me with this script?
hiddenUnderwaterSelections[]=
{
"hide",
"hide1",
"hide2",
};
shownUnderwaterSelections[]=
{
"unhide"
};
hiddenUnderwaterSelectionsTextures[]=
{
"Omega_Maritime\data\Textures\swim_fins_co.paa",
"Omega_Vest_Core\data\Accessories\Lanyard\sa_militia_carabiner_CO.paa",
"Omega_Vest_Core\data\Vests\Comms\Acc\wire_co.paa",
"Omega_Maritime\data\Textures\swim_fins_co.paa"
};
Does this look correct for a diver uniform? It works in game but the I have been crashing if I try to jump in water
this is a config #arma3_config
Curious problem: When I apply enableSimulationGlobal false to an invisible crate - it no longer falls under terrain. But it is impossible to take/put any items π€
Is there a way to disable simulation but keep the ability to interact with the crate?
UPD: trying _invisibleBox awake false; now, will see if that fixes both problems at once
do you really need to disable its simulation?
I saw 'falling under terrain' crashing the server previously, so yeah.
Are you sure that's what crashed the server? "object falling under terrain" generates a message in the RPT, but all that actually happens is the game resets it to a safe altitude.
yeah, we used to have those routinely. Tends to spam the logs a bit but doesn't crash.
Is there any way to set a texture as a video playing on the screen for any of the vanilla TVs or computers? I have changed static textures on them, and made a video pop up over the entire game screen with a trigger in the past. Never attempted this combo, so any ideas are welcome.
quick question, can BIS_fnc_objectsGrabber get marker names? π€
Probably not, because markers are not objects. Try it or check the source code of the function π€·ββοΈ
hey guys
is there a way to make AI teammates turn their IR lasers on?
I tried some years old scripts / solutions but nothing seems to work
https://community.bistudio.com/wiki/enableIRLasers should do it. They'll activate them when in Combat state with that alone; you might need to use enableGunLights to force them to use them in other states.
ok, but please bear with me
where do I put this?
this is the group box
is this the correct way to use it?
try it out
jesus christ it worked!!!
Because you're using the group's init field, you can use this to refer to the group whose init field the code is in, rather than hardcoding a reference to a specific variable name like shiv
can you check if the units return to safe/aware mode, they turn off the laser?
this is huge
is just to force them to use it, like nikko said
hey if it's working if enableIRLasers you shoudn't worry about enableGunLights
Missing ""
o-oh
hmmm
still doesn't seem to be working
looks like this, but it's not working
well
either they don't have lights, or it may need a delay
or it doesn't affect IR pointers?
they do have both IR lasers and flashlights mounted on tho...
Both are controlled by the same system (that's why the same button controls both, and if you have both a laser and light mounted at the same time, it will turn both on)
Note that most modded combo attachments are not actually both at the same time. They are one or the other, and when you switch, you're engaging a scripted system that instantly swaps the laser item with a light item.
For a number of reasons, AI don't handle this well, and unless specifically forced to switch, they'll only use the mode they started with.
ok so it's more complicated than expected
I see now
I will be happy with the IR on in combat mode
altho what I wanted to be able to do was see where the AI teammates are looking and which targets they are spotting while stealthly getting closer to the target
that's why the ideal thing would be having them have the IR lights on
at the same time, maybe I can find some sort of spotting mod
idk why but the classic spotting brackets are gone in my game, must've messed with the settings
anyway, @hallow mortar thank you very much for the help! π
so it needs a delay?
can you tell me how to acheive that?
can I simply input these commands during the game after a few seconds?
or can they be written only in the editor?
I never touched editor scripting but i guess it works the same way.
Edit: Was wrong
Like this ^^
this spawn {
sleep 1;
_this enableGunLights "ForceOn";
};```
just use my module in modules enhanced
Is there an EH or something that can tell when a player disconnects?
I've noticed an edge case scenario; When the player who is the leader of the group leaves, the AI will take over. This results in an AI group leader, and players unable to control the AI group members.
The leader changed EH doesn't fire in this case because I assume it's looking at the object which exists whether or not a player occupies the unit.
So maybe there's a way to look if a player disconnects, then I can do a check so see if the remaining unit is AI and leader then reassign leadership to a player.
I see this one too. Is one better for my idea?
https://community.bistudio.com/wiki/onPlayerDisconnected
use the MEH version
it literally says that in the link
What are some pitfalls for uiSleep? Are there any reasons I shouldn't do a find/replace on my entire project and convert all sleep to uiSleep, provided I don't ever expect time accel/decel? I guess I'd keep the sleeps that are just intended to progress the frame (loops like sleep 0.001) but everything else can be uiSleep? (Or is that last part not even necessary because uiSleep seems to do that too?)
It is just about usecase. Not that overthink is required
I'm tired of unexplained and intermittent instances of sleeps freezing my loading in during briefing. Like maybe once every 50 games, it seems to happen.
Just wondering if there's any reason, other than time accel/decel, where I would not use uiSleep?
Post your problematic code
Well, I don't know what the problem is. There's 324 sleeps in my project and it could be any of them that causes the intermittent failure. I can rule out any that are only triggered on user action, but that leaves around 150 left.
https://github.com/Gamer-Dad/warlordsredux.altis
That's why I'm considering just converting all sleep to uiSleep and wondering if it'll have any downsides.
Firstly, in theory, "just" using uiSleep instead of sleep, or vice versa, will not magically crashes or freezes the game
I was like 80% sure it's in the server code though, but then there was one incident where like 3 people were able to play while everyone else was stuck in loading, so now I don't know.
But not the other way around, right? Because sleep can sometimes cause UI hangups?
So it seems like to me uiSleep is better in every way except when I care very much about timing during time accel/decel events
If the code is broken, yes. It is not about sleep, but around it
"uiSleep is better in every way except when I care very much about timing"
That is also not the case, uiSleep is precise while sleep can be unprecise depending on how busy the sheduler is.
I think the issue was caused by:
Start loading screen
spawn some init functions
while...
sleep
End loading screen
I thought because it's spawned in a scheduled spawn that means it would be fine.
Timing during time accel/decel events, like during SP missions.
In that context, you should to wonder what part of while is stuck, not sleep
Well, it spawned into a scheduler so it shouldn't be stuck normally, right? But I think in the context of a loading screen might be different?
And no, in MP you cannot expect sleep behaves differently than uiSleep
Wait, in MP, I can't expect sleep and uiSleep to behave differently? I must not be understanding.
Because in MP accTime is ALWAYS 1
Except in briefing and inside loading screen, yes, I believe that's the case.
And I think sleep does not behave well in the map screen.
Hmm ok, it might have been something that was in my map code that was init during briefing then.
I cannot think such cannot happen only just in the map, and just because a sleep
Very likely some code is simply broken or looping
Yes, like I said, probably a sleep that is triggered in briefing..
I know I had one that triggered much more frequently, and when I changed it to uiSleep, the broken init became much less common.
One simple debug is removing loadingscreen
That's how I'm debugging it, but unfortunately it's refusing to trigger for me. It's some timing thing I'm sure. And there's no script errors on either the server or client when it occurs.
Start loading screen > Endless loading screen
I had that for ages for ExileMod, its random tho, just press ESC and join again.
Yeah, but the problem is when it happens on the server and because the client waits for the server to finish init, nobody can load in when the server chokes.
dedicated server? that shouldn't be the case
sounds like you have some error in your serverside code
Yes, imagine this server code in briefing:
start loading screen
some init
sometimes, sleep
some other init
mission set variable "server is done loading"
end loading screen
And this client code
start loading screen
wait until "server is done loading"
end loading screen
So if during the briefing that sleep is triggered on the server, the game can't start
That used to happen very frequently. But I changed some sleeps to uiSleeps and now it's less frequent but still occurs. Which is why I had the question... why not simply find/replace all sleeps to uiSleep?
Because of usecase, both behaves similar and still differently
Yeah, that's my question, in what use cases would sleep work and uiSleep not?
Or in what use cases does sleep work better than uiSleep?
Server should not execute "loading screen" or briefing, that's only for the client with a interface.
Not really sure what are you trying to tell us xD
if !(hasInterFace) exitWith {false};
Yeah, that might eliminate my error. I'll give that a shot.
Along with doing a find/replace on all my sleeps I guess.
It's not about one being better and whatnot
uiSleep, well the name says, it works not depend on accTime so you can make a sleep for something that does not rely on simumation speed like sound
Yeah sounds like uiSleep encompasses nearly all the use cases that sleep covers.
If not, what are some examples?
A sleep that relies on the ingame speed. Such as making particle or vehicle or something
You don't want millions of particle in one ingame second in slow simulation speed or vice versa
sleep = in-game pause
uiSleep = UI pause
if you pause the game in SP, uiSleep will trigger still
etc
That would better explanation
So the difference seems to be mostly in SP, mostly relating to pausing the game, and time acceleration/decel.
Is what I'm learning so far.
yep
there is no "one is better than the other", only "one is better suited to one need than the other"
Ok, I think I might need to think more about this example because it seems like uiSleep would cover that use case too.
But thanks for all your help/explanations. Was hoping that somebody said, "actually I replaced all my sleeps with uisleep and it craters mission performance" or the opposite, but seems like the difference is subtle enough that it shouldn't affect my mission.
I actually might try some test about sleep in briefing
This seems to be an intetestimg caae
Hold up, I know how it should behave
In init.sqf it will just suspend the entire script until you click Continue
...Or does it? I might have hallucinations
init.sqf? iirc yes
basically it will run everything until it hits a time check
Game simulation isn't available when in the briefing screen in mp afaik. You can look at the time in the map, it should be frozen.
player setDamage 0.25;
sleep 1;
player setDamage 0;
this might be only for players connected at the start of the mission; JIP players's simulation may be going
Oh God that actually explains some things
ye there is a difference π
It would explain why when the server chokes some players can connect and play and some can't
to me: uiSleep 1; does not really stop Kinda: but sleep 1; does π
and that's a wrong way to look at it
it's a matter of scope: do you want to pause for 1 IRL second or 1 in-game second
well, it's scheduled so Roughly 1 Second
Some Amount Of Time Between 1 And n Seconds
depends on how overloaded your scheduler is really
I've found even like fifteen handles can cause weirdness like that so I just do the Ace thing and completely avoid the scheduled environment
sleep 1; = at least 1s yes π 1.0003+
KP lib used to have that problem before it moved to using cba wae and pfh's
Imo scheduled environment should really only be used for quick and dirty mission scripts you'll use once or twice
(though I have noticed that by using cba events and wae and wuae in my quick and dirty scripts, there's a way lower chance of failure since I'm forced to write decent code)
Nah, sleep is preferable if you genuinely don't care whether something waits for 10 or 11 seconds.
Engine scheduler is faster than SQF scheduler, and because it's restricted to 3ms per frame there's no risk of causing long frames when events coincidentally hit at the same time.
"It's faster because it's slower" is quite the take
It's better to spread load across multiple frames.
You can do that intentionally with execnextframe
Yes, when you do it intentionally
If you have stuff "randomly" spread over multiple frames that's stupid
it's not random. Scheduled just guarantees you 3ms per frame without effort. Which is usually about what you want.
Well, it guarantees that to someone
If you're not picky about when exactly something happens then that's fine.
It's based on scheduler load, which is why random is in quotes
If you are picky then you shouldn't be doing slow stuff :P
It's not about "doing slow stuff", it's about consistency
That point makes no sense, at all
Consistency of what?
I'm also pretty sure that CBA's stuff is still faster, though I haven't checked it after Dedmen did his scheduling improvements
Code finishing within the same frame
If code runs in the same amount of time but one takes two frames and the other only takes one then a single frame is clearly better. And why would you want inconsistent behavior based on how much other stuff is in the scheduler
because you want consistency of frame rate.
iirc scheduler usually leads to lower framerate overall for the same code anyway
At least it did before dedmen improvements, haven't checked again
And using the scheduler will give you worse framerate
Scheduler has almost zero overhead IIRC

It used to be kinda iffy once you stacked it, but that's fixed.
but like 50-100 threads is barely measurable.
(even when it was bad)
waitAndExecArray in CBA runs sort on the whole array each time it changes. sort is the most unreasonably slow function remaining in SQF :P
they should probably do a manual insert there actually. Those are quite good with simpleVM.
Hey folks!
If I recorded movement of a transport helo with unit capture, then played it back, would players be able to ride in the back of the helo during playback?
Should work. I expect it's just setting pos/vel/dir of the helo during playback.
Yes.
Cheers!
I'm assuming recording at a lower framerate will cause the journey to be pretty choppy?
ye
How low are we talking?
Ideally it'd interpolate and still set the data per-frame on playback, but if it's obviously worse at like ~10-20fps capture then it probably doesn't.
Can someone help me with the "remoteExec" syntax?
cause i'm still not completely understanding this
i have a command, that needs to be executed on every pc
_soundID = _object say3D (((MissionNamespace getVariable "SongList") select (abs (_songNumber - 1) % count (missionNamespace getVariable "SongList"))) select 0);
how do i format remoteExec for it to understand, what is "from" and what is "sound"?
[_object, (((MissionNamespace getVariable "SongList") select (abs (_songNumber - 1) % count (missionNamespace getVariable "SongList"))) select 0)] remoteExec ["say3D", [0, -2] select isDedicated];
shortly
[_object, * that big text on the right of say3D*] remoteExec ["say3D", [0, -2] select isDedicated];
is that right?
You need to start using local variables :P
Also missionNamespace is almost always the default namespace, so missionNamespace getVariable "SongList" is the same as SongList.
Where are you running the code from?
init pole of the object
Editor init box?
yep
In that case it runs on every client anyway.
If you need to control the timing from the server then you'd want to use isServer to block execution elsewhere for a start.
the way i structured the code, it's not true
may i send here the full version of the code?
i checked the execution, and the sound is played only on server
[this, this getVariable "CurrentlyPlaying"] spawn {
params ["_object", "_songNumber"];
if (isServer) then {
while {true} do {
waitUntil {(_object getVariable "JukeBoxWorking") == 1};
while {_object getVariable "JukeBoxWorking" == 1} do {
_soundID = _object say3D (((MissionNamespace getVariable "SongList") select (abs (_songNumber - 1) % count (missionNamespace getVariable "SongList"))) select 0);
for "_i" from 1 to (((MissionNamespace getVariable "SongList") select (abs (_songNumber - 1) % count (missionNamespace getVariable "SongList"))) select 1) do {
if ((_object getVariable "JukeBoxWorking") != 1) exitWith {
deleteVehicle _soundID;
};
if (_songNumber != (_object getVariable "CurrentlyPlaying")) exitWith {
deleteVehicle _soundID;
_songNumber = _object getVariable "CurrentlyPlaying";
};
sleep 1;
};
deleteVehicle _soundID;
};
};
};
};
the very thing we need is to execute say3D on every machine. Everything else is all right, i tested it multiple times
But yeah:
private _song = SongList select (abs (_songNumber - 1) % count SongList) select 0;
private _target = [0, -2] select isDedicated;
[_object, _song] remoteExec ["say3D", _target];
thx
i still not completely understand remoteExec syntax
how does it understand, what is "from" for say3D and what is "sound"?
does it take every argument from [] and arranges it from left to right for every say3d's arguments?
For a binary command, remoteExec is [leftarg, rightarg]
so if command have more than 1 left and 1 right args, i need to do an arrays ?
A command can't have more than a left and a right arg.
For addAction, the right-hand argument is an array.
sorry, english is not my first language.
yeah, thanx
you really helped me to understand that
so it looks like [_object, [giant pile of shit]] remoteExec ["addAction", 0]
thx for calling my code shit, but it is true i know.
i am really new to arma scripting, this is my first big project
I'm testing this code and noticed an issue. The EH correctly fires if a player disconnects, and I get the systemChat for that event. However, the condition for the if statement returns false for some reason. Maybe a timing issue?
addMissionEventHandler ["PlayerDisconnected", {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
["A player has left"] remoteExec ["systemChat", 0];
if (!isPlayer (leader playerGroup)) then {
["AI is the leader"] remoteExec ["systemChat", 0];
It would make sense that the unit either doesn't exist or is no longer a player, given that the EH doesn't give you the unit.
might still be isPlayer for this one: https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#HandleDisconnect
(might not be though)
All he uses is global variable
I'm testing a sleep in the code I posted then I'll try the one you posted John, thanks!
Adding a sleep before the if statement allows the condition to return true.
Interesting.
sleep doesn't do anything there except throw errors. You mean spawn + sleep?
Its like the server still see's a player as the leader even if he disconnected.
You haven't actually stated your test case.
Like what's in the group before the disconnect?
So I got a group of 8 units. 2 are occupied by humans, the rest are AI. I use the client human to do an addAction that makes him the leader. Then I disconnect that client (back to the lobby). Alt tab over to the local host where I see both remoteExec messages I posted earlier. The rest of the code transfers the AI leader to a human, so players aren't stuck with a AI leader.
The rest of the code transfers the AI leader to a human
You mean you have code somewhere that does this automatically?
Yes, if the if statement resolves as true then that code runs.
Well, if you have this:
0 spawn {
if (!isPlayer leader playerGroup) then {
["AI is the leader"] remoteExec ["systemChat", 0];
};
};
Immediately followed by code that makes a player the leader, then the systemChat will not fire.
Because whatever is in the spawn will run afterwards.
I have all code within the spawn. I see the systemChat on the local host at least. If I'm understanding correctly, if I were to place code after and outside the spawn then I would run into the issue you speak of?
I have it working so far but I wonder if I should try the handleDisconnect one. They seem similar but I'm unfamiliar with either so I dont know their best use cases.
I don't know what you're trying to achieve and you're describing your code too poorly to continue a theoretical discussion.
They're two event handlers that run at different points in the disconnection process.
If you want access to the player unit then you use HandleDisconnect.
If you don't care about the unit then you use PlayerDisconnected.
Ah perfect. I dont need to acces the player unit for this I don't think.
The end goal here is to prevent an AI as leader of the group because in that situation players lose the ability to control the AI (tell them to move, board heli, etc).
When a player who is the leader disconnects then the AI is now the leader.
But you have code that selects a player as leader?
So I use an EH to monitor when a player disconnects. Check to see if the new leader is AI and if so give it to a human.
Does that make more sense?
No. What's the problem?
When a player who is the leader disconnects then the AI is now the leader.
And you're saying that they're not?
I'm saying I don't want that situation to happen.
And so far the EH (with a sleep added for some reason) has fixed it.
Ah, so you're saying that the current leader when PlayerDisconnected fires is still the guy who disconnected, and isPlayer returns true for them?
Or did you not check the value of leader groupPlayer?
Yes. And I did check the value before and after the disconnect, and all that checks out.
That's kinda fun, but yeah, these functions don't document that sort of state.
spawn/sleep will work. Otherwise use HandleDisconnect and check if _unit is the group leader.
Nice I always like it when I have more than one valid options!
Is it normal for PlayerDisconnected EH to fire after loading in to the map screen (screen before mission start)?
Maybe an oddity of me having two instances of Arma open and alt tabbing?
hey there!
I tried using it but it's not working either!
I got the mod, put the module in and synched it to the group selecting the "force on" option
Do you have any AI mods on?
AI avoids prone
AI can't detect through grass
AI helicopter deceleration
Try without any ai mods
lemme try
just to be sure
I synch the module to the group leader and I'm not using any triggers
Maybe it's broke again. If it doesn't work I'll be home in about an hour.
Would be silly to ask, but you are looking at them under night vision right?
I am π
Alright give me a bit
sure!
What am I doing wrong with this FiredMan EH?
if ("vn_m18_purple_mag" in _magazine && _projectile inArea "Grenade_Marker") then { hint "fired"; };
if I change it to _unit inArea "Grenade_Marker" I can get it to fire. But design wise it would work better if I could check for the smoke grenade being in the marker area.
After some testing, it seems that it takes the position of _projectile immediately when the EH fires. So even if the _projectile lands inside the marker area, the condition can return false because it evaluates the condition as soon as it leaves the player.
So I need some solution where it's evaluating the condition after the smoke grenade lands. I suppose I could put a sleep somewhere that is more or less the amount of time it takes for a smoke grenade to be thrown, arch, and land somewhere?
maybe a projectile event handler?
Is that this oneProjectileCreated?
Oh I see.
try deflected, not sure if works for grenades
Ok I'll try that. Maybe explode too. I wonder if the smoke plume counts as an explosion?
idk, I've only used deleted and explode for missiles/arty shells
Oh look at this one: HitPart
Triggered when the projectile hits any surface.
The ground is a surface right?
just try them all lol
it's your best answer
how would I write this?
_projectile addEventHandler ["Deflected", {
params ["_projectile", "_position", "_velocity", "_hitObject"];
}];
do I replace _projectile with player?
Or does _projectile fire literally every time that happens in the mission?
no, you put this inside the firedEH
and get the projectile
Ah I see it takes the param from that EH
This works pretty good. There is an edge case if I throw it in a really high arc that it can fire inside the marker area but land outside the marker area, which could end up looking a little jank for my mission, but it's a lot better than what I had.
player addEventHandler ["FiredMan", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
// If purple smoke thrown
if (_magazine == "vn_m18_purple_mag") then {
// Add an Explode handler to the projectile
_projectile addEventHandler ["Explode", {
params ["_proj", "_pos", "_vel"];
// Check if the projectile exploded inside the marker
if (_proj inArea "Grenade_Marker") then {
systemChat "fired";
};
}];
};
}];
So Explode does work for smoke too. Thanks!
good to know xD thanks for testing this for us
seems its a deeper bork. all my work arounds don't work anymore
Is there any way to check if file exists before including it by #include?
Oh, thanks. I've only read #include description
It's limited to paths starting with \. I wanted to check mission files
I have big doubts about that note, because I work with a mission template that makes extensive use of it for mission files and it works just fine
* that is, for mission files checking against other mission files. I dunno about trying to check mission files from mod config. I don't think mission files are accessed until the mission is loaded, so mod config that's preprocessed during game launch won't be able to get into mission files.
I have an issue where I placed an aircraft in the editor at a high altitude with plane1 flyInHeight 6000;, with a loiter WP.
whenever i play the scenario the plane just drops to its demise and the engines are off. how to i fix this problem.
Also in the waypoint attributes, i have the desired flyInHeight & loiter radius
Give it some velocity at start
with setVelocity correct?
How high are you placing it? Editor-placed aircraft are supposed to start in flight mode if they're uhhhh ~75m? off the ground, without needing a manual velocity boost. I've just tested it and it appears to be working.
Does the aircraft have a crew, and have you disabled any of the crew's AI?
yes the aircraft have a crew and its at 5000m
What aircraft is it? Some modded aircraft need a bit of "juice" to enusre they fly
USAF KC135
Assume you are trying to setup the auto refuel script?
yea, and i know they have a module but thats just to loiter around the map and the mad i'm using is one of the big ones like south asia
SO thats the reason why I'm using the loiter wp
OK ye that thing bugs on some maps. Can not remeber how I did it last time but it was something in the lines of forcing it to height and damage disabled via script.
Really I didnt think the map would affect it
did you change some lines in the code to fix it when you had the same problem
I just placed a USAF KC-135 in the air in the Editor and it successfully spawned in-flight with engines running π€
it was something like flyInheight or something on the module
Ye most maps it is fine. Just tested it and works on the map I am currently on but had issues before
For experimentation's sake, can you (OhMyGengar) quickly try it on a vanilla map? Just an empty mission with the KC-135, a loiter waypoint, and an observer. It could be one of your other mods stopping it from working properly.
ok no problem, one sec
If and when you get it working, keep in mind that the default loiter waypoint radius is quite tight for such a large aircraft. It's basically doing a permanent wingtip turn and it doesn't always hold altitude very well doing that*. You might need to increase the radius by quite a bit.
*the AI flew it into a hill, and that's how I found out the model doesn't have any destroyed textures, the wreck just turns into a sky-coloured void :U
I recreated the same scenario on a vanilla map (altis). It works just fine, granted i set the aircraft to flying height i think 75m off the ground
i'm going to try that exact same thing ion the modded map and see if i get a different result
Never thought of that but you're right its basically doing a wingtip turn however i gave it a massive radius of 30,000. I also noticed that it didnt crashed when i set the aircraft to fly altitude
Everything seems to be working fine, I lowered the initial altitude from 6000 to near the ground and it just corrects itself to the desired altitude with flyInheight. Thank you all for your help.
can a task have two markers on two different objects?
[west, "tsk", "convoy", veh_1, "CREATED", 1, true, "car",false] call BIS_fnc_taskCreate;
its a convoy and want to put two markers on two vehicles in the convoy
If you are still using default module I have also learned that you often get better results on waypoints if you add a move module before the loiter module. Especially if it inits on mission start.Allows you to have better control on trajectory to the loiter point.
Short answer - yes but you have to define where the second marker goes
@drifting copper assume the second vehicle of the convoy is called veh_2, I want to put second task marker on it
you can have several task at the same time
I know this, I just wanted from the task framework to be able to have more then one marker for a task π
I want this
[west, "tsk", "convoy", [veh_1, veh_2, veh_3], "CREATED", 1, true, "car",false] call BIS_fnc_taskCreate;
When JIP parameter of remoteExec is set to true, will it execute ONLY for JIP?
No, it will execute for its current targets and any JIP players that match
E.g. for 0 as the target, it will run for every connected machine at the time its called and for any player who joins later
If you do actually want to target only JIP players, you can use https://community.bistudio.com/wiki/isRemoteExecutedJIP in the remoteExec'd code to exclude non-JIP machines
(or use onUserConnected, onUserSelectedPlayer, playerConnected etc. mission EHs on the server to only target JIP players in the first place)
How do I turn off the lights of the vehicle controlled by AI? I tried to remoteExec to the vehicle, and even global ( 0 ) but setPilotLight is not working on both (or they immediately turn off / on again)
maybe disabling AI "LIGHTS" on the driver could do https://community.bistudio.com/wiki/disableAI
otherwise break lights π or set their behaviour as COMBAT or STEALTH
I think I'd go with breaking light hitpoints as I don't think I can reliably set the vehicle lights to be on/off at will using disableAI
you could try:
- disable lights usage in AI
- setPilotLights off
if they turn them back on it's something else
but if breaking lights is easier and non-noticeable, go for it ^^
However, there still is a possibility that breaking and later fixing the lights wont necessarily have it activate
Well, use a combination of both - fix the lights and use setPilotLight to tell the AI to turn them on
I wonder how the zeus interface executes this though (turn lights off and on similar to engine)
maybe behavior to "STEALTH" or "COMBAT" ?
afaik, that disableAI mentioned by Lou will stop AI from changing the lights status (on/off), so will not turn it off like you want, you need a combination of commands like Nikko said. That disableAI + setPilotLight, and I think it only works on careless behaviour (at least for planes as I tested it only works this way)
In ZEN it's setPilotLight / setCollisionLight, remoteExec'd to the vehicle, followed by disableAI "LIGHTS" on the driver.
This is my current process ```sqf
if (_action == "lights") then {
_invalidOption = false;
private _valueLower = toLower _value;
private _hasAI = (crew _vehicleObject select {alive _x && !isPlayer _x}) isNotEqualTo [];
private _isLightOn = isLightOn _vehicleObject;
// Dynamic detection of all light-related hitpoints
private _hitPoints = getAllHitPointsDamage _vehicleObject select 0;
private _lightKeywords = ["light", "lamp", "spot"];
private _lightHitPoints = _hitPoints select {
private _lower = toLower _x;
_lightKeywords findIf {_lower find _x > -1} > -1
};
// Functions to destroy or repair light hitpoints
private _destroyVehicleLights = {
params ["_veh", "_hitPoints"];
{
_veh setHitPointDamage [_x, 1];
} forEach _hitPoints;
};
private _fixVehicleLights = {
params ["_veh", "_hitPoints"];
{
_veh setHitPointDamage [_x, 0];
} forEach _hitPoints;
};
switch (_valueLower) do {
case "on": {
if (!_isLightOn) then {
if (_hasAI) then {
_vehicleObject enableAI "LIGHTS";
[_vehicleObject, _lightHitPoints] call _fixVehicleLights;
[_vehicleObject, true] remoteExec ["setPilotLight", 0];
} else {
[_vehicleObject, _lightHitPoints] call _fixVehicleLights;
[_vehicleObject, true] remoteExec ["setPilotLight", _vehicleObject];
};
};
};
case "off": {
if (_isLightOn) then {
if (_hasAI) then {
_vehicleObject disableAI "LIGHTS";
[_vehicleObject, _lightHitPoints] call _destroyVehicleLights;
[_vehicleObject, false] remoteExec ["setPilotLight", 0];
} else {
[_vehicleObject, _lightHitPoints] call _destroyVehicleLights;
[_vehicleObject, false] remoteExec ["setPilotLight", _vehicleObject];
};
};
};
};
};
Shoving what I expect one way or the other to the game logic. Not ideal, but gets the job done 
I am using ace_medical_fnc_addDamageToUnit on a AI spawn for a medical trainer. Though it feels as if the damage calculation from damage type and value range is off. Most of the time even on a low value range the AI insta dies on spawn and the damage types is weird. hit bullet often just gives a bruise. I tried adding ace_medical_damageThreshold which somewhat stops them from insta dying but their unconscious rate is low and if they do go unconscious they wake up a few seconds later. Trying to make a trainer that works better for the ACM/KAT addition. Anyone maybe have some advice?
Hey,
i got one script "spawn.sqf" with
[thisList select 0, _tree, _trigger, _mine] execVM 'scripts\trees\hitting.sqf'
"hitting.sqf" has
_vectorHeading = (getPos _player) vectorFromTo (getPos _tree);
Upon execution i recieve "Error: Undefined variable in _tree"
am i right to assume locality? can i just remove the underscore or do i need to do more?
(and just as a reminder, if i remove the underscore, the variable is global to all scripts and mods right? So i should rename "tree" into something better?)
what
hello All: does this look Correct or do i have it messed up
if (_player in Helo2) exitWith {
["Pilot: Huey Must Be Empty Before You Call Insertion"] remoteExec ["systemChat", TO_ALL_PLAYERS];
};
figured it out, thank you
params is your friend π I did reread and figured what you meant (the screenshot helped π)
how can I check if a "phrase" is within a string? I want to run a script if hmd player returns a string that has cig0 in it.
regexmatch
oh thx @cosmic lichen
Also don't use OneDrive for any of the Arma stuff, otherwise you're guaranteed to have major issues with the game at some point
if (_hmdString find "cig0" != -1) ?
Does JIP means only players who are already in process of joining at the time of running remoteExec? Like downloading mission and loading it?
Bullets often do inflict bruises with ACE. It's probably just a narrow range between bruise and large velocity, like 0.15 -> 0.45.
Had some mistakes in code I couldn't see for quite some while. All good now
how to check if vehicle is immobile for a long time (>5min) ? π€
a loop
works for both a short and a long time π
I guess I will check speed https://community.bistudio.com/wiki/speed
but how to check if speed is zero for a period of time ?
Well, fundamentally you do need to check at multiple time intervals. There's no way to ask Arma whether a vehicle hasn't moved for 5min. You have to check the position and then check again. And you can't guarantee that it didn't go somewhere in between.
1 sec intervals then ?
What are you trying to achieve exactly?
Arma vehicle AI unstick procedures are so bad that they can actually be successful after minutes of failure.
yeah, it can just not moving for 2 sec when turning and it will register as "not moving"
or just waiting for some unknown reason like they like to do in a convoy
I just want to find if there is vehicle stuck in a convoy and if there is I will just teleport it to the next waypoint
If you know they have orders to move away from their current location then a two-point check is sufficient. If they failed to move more than X metres in Y time then you can consider them stuck.
https://github.com/PiG13BR/PIG-Air_Supremacy_PVP/blob/aba8cda1987c30cd82649b5dd2536bb905806642/functions/objectives/fn_convoyObjective.sqf#L136
I used the Engine EH for that case, check example
I don't think they ever turn off the engine unless they abandon a waypoint.
if they get stuck, they do
They can ram the same house for like 10min
I don't even remember if they abandon eventually in that case.
in that case ofc they won't turn the engine off, but sometimes they do
it's like a state that they are unable to move for some reason
Abandoning the waypoint is usually when the pathfinder can't find a path.
happens particullary with bridges
Yeah that's the common pathfinder failure case.
but there are plenty of other stuck cases.
yeah
Sometimes they'll refuse to drive despite having a waypoint 100m in front of them down an open road.
that framework in particular I had this problem with vehicles getting stuck for no reason, just stopped in the middle of the road
yeah π€£ that what happened in my case
The more common one is that they'll stop on approach to a waypoint, because the vehicle slows down too fast and never enters the completion radius.
Seen that with vanilla prowlers, so it's not just mod config fuckups.
In that case you can just skip to the next waypoint though. It's not really stuck.
that's why I recommend to put completion radius >50m on convoy scripts, it usually solves problems related to this
also for bridges, one waypoint before the bridge and one after it generally solves it
Depends on the bridge and the vehicle. Some maps just have broken bridges. Some vehicles can't cross them.
well in those cases... π
actually I'm not sure which case the waypoints work on. Maybe if it was gonna decide to ford instead.
from my testing the convoy veh get stuck 90% of the time because little objects next to road like lamps, umbrellas, signs, railroad tracks, etc. What I do is removing these objects on the convoy route.
I really want map creators to make maps to be milsim proof not beautiful, I hate little objects π€
How can I find what acceptable strings are for this EH? Specifically _surfaceType.
_projectile addEventHandler ["HitPart", {
params ["_projectile", "_hitEntity", "_projectileOwner", "_pos", "_velocity", "_normal", "_components", "_radius" ,"_surfaceType", "_instigator"];
}];
There's no specific list, it'll vary per model and mods can also add their own
I'm wondering if _surfaceType relates to ground textures maybe?
Test _surfaceType with a simple systemChat
Like this? systemChat format ["SurfaceType: %1", _surfaceType];
Yeah
Interesting. Ima try that, thanks you all.
cln_grasstall unless I shoot a rock which returns nothing. Interesting.
Why doesn't this prevent code from running in single player?
if (isMultiplayer) then {
It does.
I have that code in initServer.sqf but it is activating in single player:
if (isMultiplayer) then {
// leader changed EH, activating in SP but I don't want it to.
};
Sanity check, what do you think single player is?
Anything that isn't multiplayer?
Maybe because the mission is running in preview mode in the editor and it's saved in MPMissions folder?
singleplayer in arma is multiplayer where server and player are the same client
missions saved wherever you choose to save
never tested them, why you need them ?
then make one player and save the mission in single player folder
you want to make single player and multiplayer mission at the same time ? π΅βπ«
I've noticed on the Steam workshop that many missions list that it can be played in SP or MP. Is this frowned upon?
multiplayer mission can be played by only one player
single player mission cannot be played by many players
the thin difference is if you make a unit player (check "player" when you double click the unit) or many units playable in the editor
Ah got it thanks!
you mean !isMultiplayer
There is an actual singleplayer mode, which is what you get from running missions from the scenario menu or directly from the editor (no hosting screen).
i hear you 5, 5, Niner π 5, 5, 9= Load and Clear
It doesn't matter how many players there are. MP hosted is still isMultiplayer
Do I have the correct idea here?
if (isMultiplayer) then {
// This code will not run when running missions from the scenario menu or directly from the editor
};
yes
Okay, so what I am saying and getting confused by is that code is running from the editor.
singleplayer or multiplayer, from the editor
?
Single, which is the one without the lobby screen, right?
right @blissful current
Hmmm, I don't think so. It's in initServer.sqf. Maybe that's an issue? It's too much code to paste but its basically a few EH regarding Leader Changed.
i don't like doing MP from the Editor
please check it, make sure it's not running somewhere else
i only like SP from the Editor
do a simple systemChat check
why not just use Rank for leader change π
Okay
why not just make a SP mission and have a diff Mission for MP
but that in itself seems funny too π
Checked. Nowhere else. I did this so see the behavior. In single player neither message is shown below:
if (isMultiplayer) then {
["This is Multiplayer. This code is in initServer."] remoteExec ["systemChat", 0];
};
if (!isMultiplayer) then {
["This is NOT Multiplayer. This code is in initServer."] remoteExec ["systemChat", 0];
};
And I did the same for initPlayerLocal, which did display the correct message.
if (isMultiplayer) then {
["This is Multiplayer. This code is in initPlayerLocal."] remoteExec ["systemChat", 0];
};
if (!isMultiplayer) then {
["This is NOT Multiplayer. This code is in initPlayerLocal."] remoteExec ["systemChat", 0];
};
So I guess you can't do isMultiplayer from initServer. π€·ββοΈ
Wait something is screwy with VScode. It's not recognizing that I've modified initServer. Usually there is an M next to the file. Maybe this isn't getting ran...
Yep! I did a manual save and now the M is next to the file and it's all working!
I've never had an issue with autosave with VScode, but glad to know now!
Is there a way to extract all zeus modules (vanilla and mod-added) via debug console?
@finite bone you mean spawn?
No like zeus module logics from ZEN, ACE, LAMBS, etc. (along with vanilla fire support, teleporter, scenario name) that I can extract
they are not existing in the mission and you want to make them appear?
or you want to have the code of these modules ?
Just a list of names of modules currently loaded into zeus curator..
Modules exist in CfgVehicles and have a function attribute. So you could make a script that searches CfgVehicles and reports the name of everything that has a function attribute.
Everything that inherits from Module_F is another way you could approach it
is there a command to get the position of whatever surface the cursor is pointing at? essentially line intersect from camera to cursor point on screen
(i.e something that'd work with zeus cursor for example, but i dont want the object i want the position so curatorMouseOver wouldn't work)
_object = curatorMouseOver;
_pos = getPosATL _object;
systemChat str _pos;
wouldn't work for terrain tho :/
also technically not accurate since it'd be the object root pos not the surface on the object
you said position, not terrain π
fair lol
to be exact then essentially getPos but for the cursor; AGLS, i.e affected by the geometry/roadwayLOD as well as terrain
_object = curatorMouseOver;
systemChat str (getPosWorld _object);
"I don't want the object's position, so curatorMouseOver wouldn't work"
"OK, here's how to use curatorMouseOver to get the object's position"
π€
Try a combination of getMousePosition, screenToWorldDirection, and lineIntersectsSurfaces
object position and world pos are kinda very close (practically similar), the object is where he is pointing with the mouse cursor, right?
What if you're pointing at something that isn't an object?
What if you're pointing at the top of a tall building, or the edge of a wide building? You can easily find its base or model centre position, but your actual cursor could be 100m away.
Hi ! I'm having trouble with a little thing i'm trying to make.
I'm trying to make an upward force so that a player can be lifted up, the problem is that everytime I try setVelocity or addForce the player ragdolls, or takes damage (For setVelocity) is there a way to make the player have a Force vector without those constraint ?
true, didn't think of this
forgot to reply - yeah i ended up using screenToWorld getMousePosition with lineIntersectsSurfaces; it's not perfect since it breaks if the mouse is aiming towards the sky even if there's a building in the way, but it works well enough
@charred monolith what is the reason you want to lift the player up: did you want to set the player on top of a roof or ?
I'm trying to make a gravity lift like in Halo either from CE where you just go up to a ship or when you have the little towers around and you can lift up to them.
That's why I said to use screenToWorldDirection rather than screenToWorld. Cast your own line, from AGLtoASL positionCameraToWorld [0,0,0] to (screenToWorldDirection getMousePosition) vectorMultiply _distanceLimit, and if it's pointing at the sky then there'll be no intersections and you can make an if case to handle that
setVelocity shouldn't cause ragdolling π€ I've used it for simulated jumping before.
what i do is set a little trigger at the bottom of the ship: or object: and i have another object on the deck of the ship: or object: then i just setPos getPos player in the trigger its like a telaport script kinda like
AddForce ragdoll, however setVelocity just cause damage it seems.
They also shouldn't take damage unless they hit something at a good speed. But if they are having issues with that, you could give them a stealthy allowDamage false for a short safety period during the movement. If it's not too long, it's likely no one will notice.
I'm glad you have that working for you, but teleporting is not what they're trying to do
agree
There's also the option of using handleDamage EH to nullify damage from sources where there is no ammo type, the instigator is null or the same unit, etc, which usually means fall damage. It's a bit complicated to work with that EH though.
Hmm yeah seems complicated. I've discovered that you could attach The player to PhysX object and use addForce on that object, however it cause a multitude of problem, like if the object collide with something the player just follow the objects axis so it moves in all direction cause by the collision, and it also block the player from moving their view, they are force to look in only one direction.
i guess thats why i did it my way π
i used the way i said: to jump up on a wall or roof of a building
but that was only in 1 PVP mission: The mission was a Attack and defend mission near the Castle
If I do allowDamage false the player is not hurt by the setVelocity command however, nothing happens, the unit doesn't seems to be affected by the forces applied by setVelocity at all
Have you properly removed the stuff with attaching the player to a physics object? If they're still attached then it won't work on them.
Yes, I execute the code directly into the missions. So I execute one code with the attach separatly and manually. I've just restarted my mission, so there is no attachTo done, and it's still doesn't seems to work
Can't reproduce, setVelocity works fine on a player with allowDamage turned off
I'm gonna try in vanilla see if there isn't some external influence
i never played Halo: So he wants to see the player: lifting up: is that correct: like in a tornado kinda like
Just tried it in VR, without any mod except ADT. still doesn't seems to work, there is what i'm doing :
player allowDamage false;
player setVelocity [100,100,100];
is this in SP or MP
If it's in SP then simulation is paused while you have the debug console open, and setVelocity may not take effect. Try testing in MP mode or adding a 0 spawn { sleep 1; ... };
Just lifting up, just like a force pulling up something or gravity inverted, not a tornado effect.
copy that
That's what cause it ! Just tried with the spawn method.
Executed in SP as of right now but will be implemented in MP
nice
Thanks for you help guys ! I will now always test my script in local MP.
Still thanks ^^ all help is appreciated.
cool thx m8
Yeah, it works just fine. Using it now for several mission includes
Task with objNull destination has no marker. You can later change destination to show the marker.
task framework is such BS ... π
Why objNull doesnt work on your usecase
I wanted to have task marker to exist so I can get its grid, something like
private _gridPos = mapGridPosition taskMarker;
systemChat format ["Task GPS GRID : %1", _gridPos];
so player can check GPS GRID instead of having magic marker on the map
but I solved this otherwise, with global var uberPos I use as a center of spawned task, units, etc. \
Why on earth should the Task Framework incorporate an API that allows users to create tasks with invisible markers?
If you're using the Task Framework to interact with a task, you already know where the task marker is supposed to be. If your specific use case requires that there is an invisible marker at that location, you can easily create that invisible marker yourself.
private _gridPos = mapGridPosition uberPos;
systemChat format ["Task GPS GRID : %1", _gridPos];
when I have time I want to make "real" radio call to observer
@willow hound issue is solved, but task framework is very limited, how you will get pos of task marker for example ?
I cannot find something like BIS_fn_getTaskMarkerPos π
Aren't you the one who creates the tasks in the first place? In that case, you already know where the tasks are located, because you created them there ...
what are we talking about ? π΅βπ«
I found solution 3 comments before your comment
Why sleep command doesnβt seem to work?
Trying without a scheduled event or in the wrong place.
Could you provide your code where it isn't working
Iβm trying to make a radio chat in the beginning of a mission, for the code just a sec (I write it on the trigger btw)
There we go (it's my first mission):
sleep 20;
cpt sideChat "Carlos, do you copy?";
sleep 3;
playerof sideChat "Hey Lieutenant...";
sleep 7;
cpt sideChat "Damn it, I dropped my radio...";
sleep 6;
cpt sideChat "You still there?";
sleep 4;
playerof sideChat "Obviously...";
sleep 2;
cpt sideChat "I need you to go somewhere. We've got some report about suspicious activity...";
sleep 4;
playerof sideChat "And where to?";
sleep 3;
cpt sideChat "Just get in the damn car. It's behind your post.";
You need to use a scheduled event.
See
https://community.bistudio.com/wiki/Scheduler#Where_code_starts_scheduled
So I make a sqf file and run it with trigger?
Yes.
Alternatively, you can avoid the SQF file by using spawn in the trigger ...
[] spawn {
sleep 20;
cpt sideChat "Carlos, do you copy?";
sleep 3;
//Add the rest of the dialogue here ...
};
```... but I recommend using SQF files for scripts that are longer than a handful of lines. It's much easier to read and write code in a text editor instead of the small trigger expression input fields in the Eden Editor.
Thanks so much
Hello, complete smooth-brain noob here. I have a question regarding this code: #arma3_scripting message
which was a reply to this original question: #arma3_scripting message
Rather than scripted autosaves, i would like to utilize player-triggered saves via an addAction on an object. What's more, i'd like to implement a cooldown timer that requires a certain amount of time to pass in-game before it's usable again. My rudimentary understanding leads me to believe that enabling/disabling saving is an all-or-nothing proposition, and can't be worked around via script. Is this still the case three years later?
What's the standard when it comes to using remoteExec in mods? Ive got some local functions but I need them run globally, is it safe to use it or does it open pathways for abuse? Do I need to add them to CfgRemoteExec? Or is event-listener approach the game, such as CBA Global Events?
CBA events often force better coding practices, so I'd always reccomend them over remoteExec
Also removes the chance for your mod / script to simply not work because someone blocked things through CfgRemoteExec
CBA events also make the networking pretty easy, because you can just only add the event handlers where needed, e.g.
if (isServer) then {
["YourPrefix_doSomethingServer", {}] call CBA_fnc_addEventHandler;
};
if (hasInterface) then {
["YourPrefix_doSomethingClient", {}] call CBA_fnc_addEventHandler;
};
There's also the serverEvent, targetEvent, and ownerEvent functions as well
holy moly π
?
You can just save, disable saving, and then re-enable after X amount of time passes
Here's the situation (if my understanding of the conversation you linked is correct):
It is possible to disable all saving (including scripted autosaves with saveGame and manual saving from the pause menu) using enableSaving [false, false]. It is also possible to reenable saving with enableSaving [true, false].
The problem discussed in the original conversation is that saveGame did not work immediately after saving had been reenabled. As such, after reenabling saving with enableSaving [true, false], one had to wait at least until the next frame before using saveGame. That is what the code you linked to does: It enables saving, waits, saves and then disables saving again.
I do not know if one still has to wait between enableSaving and saveGame today.
You do not need enableSaving to implement a cooldown for your addAction-triggered saves (unless you want to disable manual saving from the pause menu so that addAction-triggered saving is the only available form of saving).
how can I apply a damage texture to a unit without showing the option to heal said person? Thought that setting a hitpoint damage would bypass this but nope, I guess it's because the treshold to show blood on unit is 0.51
hello guys , can you plz share with me a good video for arma3 scripting ?
Yes, i forgot to mention that aspect; I want the normal pause menu save to be disabled, so that the player is only capable of making a save at a given interval in-game. Thank you both for your replies. Do you know if this method would effect the number of save game slots available? I believe the default is 5, at which point you must choose to overwrite previous saves.
If you want one on multiplayer scripting, there's one on my channel π
Much appreciated. I used them to handle user actions globally (every player has a local effect to a players input) and I was tempted to do it for non-action events also
ok
hello chat
i have a script
works great in SP and local hosted MP
does not work in dedicated servers properly
Generally speaking, the script does this
- When you place down a command post object dynamically in zeus or instantiate one in eden, it should load command post init, which does this
/*
Function:
AWR_fnc_commandPostInit
Author:
Queen
Description:
initializes Command Post capture function on object
breaks when placed in Eden on certain maps
Parameters:
_object - Command Post object <OBJECT>
_name - Sector Name <STRING>
_designation - Sector Designation <STRING>
_owner - initial owner <INTEGER> (OPTIONAL)
_size - trigger size for sector <INTEGER> (OPTIONAL)
_isRespawn - is command post a respawn <BOOLEAN> (OPTIONAL)
Returns:
Nothing
Examples:
[this, "Imperial Command Post", "I", 1, 10, false] call AWR_fnc_commandPostInit;
[this, "Rebel Command Post", "R", 0] call AWR_fnc_commandPostInit;
*/
params ["_object", "_name", "_designation", ["_owner", 1], ["_size", 10], ["_isRespawn", false]];
if (is3DEN) exitWith {};
private _hasRun = _object getVariable ["Initialized", false];
if (_hasRun) exitWith {};
//[] call AWR_fnc_progressBarInit;
private _position = getPosATL _object;
// createGroup and createUnit are needed to create modules
// creating them with createVehicle will not work
private _group = createGroup sideLogic;
private _sector = _group createUnit ["ModuleSector_F", _position, [], 0, "CAN_COLLIDE"]; // _position is [x, y, z]
_sector setVariable ["FirstRun", true];
//creates respawn if is respawn
_respawn = [_owner, _isRespawn, _object, _name] call AWR_fnc_commandPostRespawn;
// it is possible to change the sector's parameters using setVariable
_sector setVariable ["Name", _name, true];
_sector setVariable ["Designation", _designation, true];
_sector setVariable ["OwnerLimit", 1, true];
_sector setVariable ["sides", [west, east], true];
_sector setVariable ["DefaultOwner", _owner, true];
_sector setVariable ["CommandPostObject", _object, true];
_sector setVariable ["isRespawn", _isRespawn, true];
_sector setVariable ["respawn", _respawn, true];
_sector setVariable ["OnOwnerChange", "params ['_sector', '_owner', '_ownerOld']; [_sector, _owner, _ownerOld] call AWR_fnc_captureCommandPost;", true];
[_sector] call BIS_fnc_moduleSector; // initialises the sector
// after initialisation, sync an area trigger to the module, it will be the capture area
private _area = createTrigger ["EmptyDetector", _position];
_area setTriggerArea [_size, _size, 0, false, _size]; // change values depending on the size you want
_area setTriggerActivation ["ANY", "PRESENT", false];
_area setVariable ["isServerOnly", true, true];
_sector setVariable ["areas", [_area], true];
_object setVariable ["Initialized", true, true];
_sector setVariable ["FirstRun", false, true];
true;
code above creates a sector, and stores variables within the sector itself to store the current object state and whatnot.
when the sector is captured / swaps sides, it runs this
/*
Function:
AWR_fnc_captureCommandPost
Author:
Queen
Description:
Object replacer for when command post is captured
Parameters:
Returns:
Nothing
Examples:
*/
params ["_sector", "_owner", "_ownerOld"];
private _firstRun = _sector getVariable "FirstRun";
if (_firstRun) exitWith {};
private _object = _sector getVariable "commandPostObject";
private _isRespawn = _sector getVariable "isRespawn";
private _respawn = _sector getVariable "respawn";
private _objectPosition = getPosATL _object;
private _won = ["won", "won2", "won3", "won4"];
private _lost = ["lost", "lost2", "lost3", "lost4", "lost5", "lost6"];
switch (_owner) do
{
case west:
{
private _newObject = "ls_commandPost_imperial_blue" createVehicle _objectPosition;
_newObject setPosATL _objectPosition;
_sector setVariable ["commandPostObject", _newObject, true];
_sector setVariable ["Name", "Imperial Command Post", true];
_sector setVariable ["Designation", "I", true];
if (_isRespawn) then {[west, _newObject, "Imperial Command Post"] call BIS_fnc_addRespawnPosition;};
playSound selectRandom _won;
deleteVehicle _object;
};
case east:
{
private _newObject = "ls_commandPost_rebel_red" createVehicle _objectPosition;
_newObject setPosATL _objectPosition;
_sector setVariable ["commandPostObject", _newObject, true];
_sector setVariable ["Name", "Rebel Command Post", true];
_sector setVariable ["Designation", "R", true];
if (_isRespawn) then {[east, _newObject, "Rebel Command Post"] call BIS_fnc_addRespawnPosition;};
playSound selectRandom _lost;
deleteVehicle _object;
};
case sideUnknown:
{
if (_isRespawn) then {_respawn call BIS_fnc_removeRespawnPosition;};
};
default
{
private _newObject = "ls_commandPost_rebel_red" createVehicle _objectPosition;
_newObject setPosATL _objectPosition;
_sector setVariable ["commandPostObject", _newObject, true];
_sector setVariable ["Name", "Imperial Command Post", true];
_sector setVariable ["Designation", "I", true];
if (_isRespawn) then {[east, _newObject, "Imperial Command Post"] call BIS_fnc_addRespawnPosition;};
playSound selectRandom _lost;
deleteVehicle _object;
};
};
which changes the commandpost object, plays a sound file and saves new variables into the sector
ignoring the respawn portion as that's an optional fun thing,
in dedicated MP, the script seems to refuse to actually spawn in the new object, and doesn't play the sound file
oh and here's my init
class AWR_commandPostImperial: AWR_commandPostImperial_Base
{
displayName = "[80th] Imperial Command Post";
editorCategory = "AWR_Props";
editorSubcategory = "AWR_Utilities";
class EventHandlers
{
init = "params ['_entity']; [_entity, 'Imperial Command Post', 'I', 1] call AWR_fnc_commandPostInit;";
};
};
would love some help
thanks
Pretty sure those BI functions need to be run on the server, and spawning one in Zeus makes it local to your machine

so it would theoretically only work in eden?
well
when i spawn in zeus
it creates the sector
and that works for everyone
Oh actually init will run on all machines there, so not that
and i know it's calling properly
bc it deletes the commandpost on side change
but it doesn't create a new one
I think the save slots used by saveGame are separate from the slots used for manual saves. I think there are like two slots for saveGame and four or five for manual saves. I'm pretty sure that there is no limit to the number of saves you can create with saveGame; it almost certainly just overwrites previous saveGame saves automatically.
You should be able to play around with this stuff in the mission preview in the Editor. There, you should be able to create manual pause menu saves and you can also run saveGame through the debug console. You can see all available saves in the pause menu where you can load a previous save.
How do I add a zeus entity slot on the lobby screen? I already have a zeus module that gives gamemaster to adminLogged. But can I do both?
Just sync the module to the unit for the slot
I tried that but it's not showing up in the lobby.
I'm used to seeing it below the blue icon:
I think that's only if the forced interface option is enabled
Ok just tried that with and without syncing to a unit. Maybe I'm misremembering but I swear that you could make zeus slot over there.
There are some virual entites that you can place in the Editor, including Virtual Curator ... under modules somewhere I think.
Maybe that's what I'm thinking of.
Systems β Logic Entities β Virtual Entities
Oh interesting. Why is there one that doesn't have a side?
All of them should be sideLogic.
What is that?
Does anyone know offhand if it's possible to find the world position of a memory point of an equipped weapon? usti hlavne, for instance
IIRC Leopard posted recipes for that sort of thing here. Might be able to find it in search.
The rub here is that I can't get an object ref to a proxy, so SelectionPosition won't work here.
i must thank all you Guys: ("To Many to say all the Names") for helping Me with my missions: its so Nice to play withOut any Erras: and everything working so perfect: WooHoo Arma 3: Many Many Thanks" i love it
How to I make the safe zone script apply to all BLUFOR units
wdym?
if blufor units or players are inside the trigger, it will apply the safe zone script for them
This is what I'm suppose to have in the OnActivation Field correct?
Because i cant fire any weapons in hand but i can in a vehicle, let me know what i did wrong
try player in thisList || {(vehicle player) in thisList}
I did all of that and I know the script works because I got this message Zona Segura when i try to shoot a rifle, but still I'm able do use a vehicle's weapon, but never mind that i can work around it but I noticed i still take damage in the trigger area because i got shot down in an airplane, there must be something I did wrong.
the script doesn't handle damage
tomorrow I'll take a look what I did for vehicles, but I'm sure that I've just added that condition in the trigger
Ok no problem
Need guide for spawn a weapon from array list on ground and when player pick gun it will respawn after a few second
If your age is really what you're saying it it be, then I suppose it's kind of challenging to learn coding.
On the other hand it must be good brain exercise keeping your mind sharp
@eternal spruce try this line, I fixed it
@hushed turtle yes it keeps my mind sharp: along with playing music and studying music: and along with Golfing: also i'm a nutritionists: iv been studying nutrition way back as far as when i was like 18 years old: So yes you are correct Sir
and yes im 64: but im a kidd at Heart
i learned so much in the last year with all you guys helping me: its Amazing
Spawn a simple object with the model of that weapon
That was the solution dart used in ages past. Plan is make a "your gun too long" mod and I needed to find the barrel end.
So yeah, I'll do that and cache it for later
How can I check if a string can be parseSimpleArray'd? Doing some UI work and I want some feedback to players that the input is invalid
it needs to sort the scripts before executing, the more the worse.
Also during exection after every statement it has to check for the 3ms timing, which adds overhead
Actually we can multithread sort now π€
If I get a "its slow" repro
count quotes (both types) and brackets. Make sure they match up open/close correctly. For quotes inside quotes you also need to consider escaped quotes
Make sure outside of strings can only be numbers and ,[] characters. And -+ infront of numbers
Sounds like a canParseSimpleArray ticket π
Or just let them run into the error for doing it wrong
run it directly after their input, if empty array tell them
Oh does parseSimpleArray still return [] if it fails?
I hadn't checked what it returned on error yet, still trying to set the ui up how I want it
Oh it does neat, so yeah just check if the parsed one is empty and the input isn't "[]"
Good morning, i have 30 mods on the server right now and I dont like the performance hit we are getting. I would like to have the mods in a folder on the desktop. Is there a current how to or a script to go off of or something that will let me do this? Thanks.
BTW new to scripting but made it thru the server setup
If only thirty mods are hurting you, your mods should be replaced with better ones
I get that server doesn't have clashes but I want to expand further to alot more. Rather than have them in the servers folders. Thx
Do you mean you lack, like...storage space? I don't see why moving the folders would do something
No space is fine. Keeping them in the game folder and using the -mod= is being a pain in the ass tbh
what are you playing? are you sure that is only mods causing it?
I'd like to keep them separate in a folder on the desktop and running out of space on the shortcut line is run out of space
That's what I want to do just dont have the k ow how to get this done. Folks have said you can do it just there's no how to for it from where I have looked. I know some servers running over 100 I just want this in place in case we get there too
