#arma3_scripting
1 messages · Page 116 of 1
Just run the task creation function on the server and install the handleDamage there?
again. i have no issue a this particular moment with locality per se. that ill figure out. i just want the handleDamage EV to run the code in it once.
init.sqf:
initHostageUnitGlobal = {
_this addEventHandler ["HandleDamage", {
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit"];
// If new damage is about to be big enough AND unit is not unconscious yet, means its time to make them unconscious
if(_damage >= 0.7 && {lifeState _unit != "INCAPACITATED"}) then {
_unit setUnconscious true;
["Hostage is down!"] remoteExec ["systemChat", -2];
};
_damage min 0.7; // Never exceed 0.7 damage for any hit parts
}];
};
and when you create a hostage somewhere in some script do:
_hostage = ... createUnit ...;
_hostage remoteExecCall ["initHostageUnitGlobal", 0, _hostage];
EH*
Have the EH check for lifeState, but make sure to setUnconscious right away if check passes
ok, lets go back to the simplest expression.
HostageUnit = _this select 0;
private _damage = _this select 2;
private _Selection = _this select 1;
if (_damage >= 1) then {[format ["%1", _pickone]] remoteExec ["systemChat", -2];}}]] remoteExec ["addEventHandler", HostageUnit];
forget about keeping the unit alive and everything else. lets show a systemchat message ONCE if the unit gets killed.
uh, that's part of it.
The setUnconscious is used as a flag for the first time the condition hit.
You could manually setVariable on the unit instead, but the setUnconscious is convenient here.
Like if you didn't want to keep the unit alive you could do this:
if(_damage >= 0.7 && !{_unit getVariable ["downCondition", false]}) then {
_unit setVariable ["downCondition", true];
["Hostage is down!"] remoteExec ["systemChat", -2];
};
(this wouldn't really be correct because a lot of damage > 1 values won't down the hostage, but whatever)
I don't think you can check if unit is about to get killed reliably inside HandleDamage, you'll need to use setVariable flag like in @granite sky's example
setVariable also needs to broadcast in case unit locality changes later
no message
Change -2 to 0, you're probably a server client
I don't know what you're inserting that snippet into. Your handler code doesn't define _unit.
!{_unit getVariable ["downCondition", false]} => {!(_unit getVariable ["downCondition", false])}
now, yes, no message.
post whole code
[HostageUnit, ["HandleDamage", {
_unit = _this select 0;
private _damage = _this select 2;
if(_damage >= 0.7 && !{_unit getVariable ["downCondition", false]}) then {
_unit setVariable ["downCondition", true];
["Hostage is down!"] remoteExec ["systemChat", -2];
};}]] remoteExec ["addEventHandler", HostageUnit];
! is still not fixed here
the error was that i had hostageunit this select 0, instead _unit this select 0; copy/paste missahap. went to edit the photo, photo didnt want to upload, noticed the error... photo went up.
unleess im missing something else.
The error on a screenshot is not about _unit but about ! being in the wrong place
Do this
its a variable name, can be anything
[HostageUnit, ["HandleDamage", {
_unit = _this select 0;
private _damage = _this select 2;
if(_damage >= 0.7 && {!_unit getVariable ["downCondition", false]}) then {
_unit setVariable ["downCondition", true];
["Hostage is down!"] remoteExec ["systemChat", -2];
};}]] remoteExec ["addEventHandler", 0];
It's probably trying to do !_unit instead of ! getvariable because order of precedence. Try some () to force the getVariable to evaluate first
note: the EH is remoteExec to 0 in that code, but setting to the unit also does not show the system chat. message. i used 0 so i could get the error message
You missed the parentheses {!(_unit getVariable ["downCondition", false])}
[HostageUnit, ["HandleDamage", {
_unit = _this select 0;
private _damage = _this select 2;
if (_damage >= 0.7 && !(_unit getVariable ["downCondition", false])) then {
_unit setVariable ["downCondition", true];
["Hostage is down!"] remoteExec ["systemChat", -2];
};}]] remoteExec ["addEventHandler", 0];
that works
Hey, is there a way to make one specific helicopter and its passengers be untargetable by enemy AI, but still have the players inside be targetable once disembarking?
I thought about setting anyone to setCaptive when entering the heli, and then disabling it upon disembarking, but how does one achieve that feat?
addEventHandler, GetOut or GetOutMan 🙂
@meager granite do you happen to know what triggers the vanilla unconscious state upon being damaged?
I had done some test but its a bit inconsistent, seems like when you damage well enough any of the structural damages or the "unconscious" hit point you can go uncon, but it also appear that certain damages upon any of the other hit points are able to trigger it without the other structural damages being high enough.
Nope, haven't looked into it
is there any documentation in the matter?
Haven't seen to be able to find explicit how-to's on that and the function itself for reviving doesn't mention how the system gets triggered to set the unconscious state in the function itself. Everything seems to be managed into with that same function though.
Anybody has a working script snippet to crash the server? All my methods are outdated.
Need it for legit reason to stop the server since #shutdown doesn't always work.
callExtension. Make a extension that crashes
I'd prefer a scripting way, but gonna resort to extension if I won't find a new way.
I think the usual way is to use an external process controller rather than scripting a murder
Good idea
Takes a few seconds to run out of stack though :P
Thats fine, gonna run at mission end anyway
Maybe try: [] resize 1e30?
Never tried it but I guess it could crash your game
(either that or it displays in-game error)
but I guess if it does we'll have to fix that 
arrays have a limited 10M size iirc
yeah but what happens when you exceed that limit?
it most likely trims it
just tested, and it shows an in-game error
so won't crash 
but it has to be an integer so 1e30 won't work. [] resize 10000001 does
private _code = {
while { true } do {
0 spawn _code;
};
};
call _code;
```?
good ol' fork bomb
spawn-spam might kill more than just Arma.
You really want to burn stack rather than memory.
as Dedmen said the only reliable way is extensions
even if you do find a way to actually crash the game using scripts, it will be fixed (or at least it should)
https://community.bistudio.com/wiki/openMap
addMissionEventHandler ["Map", { openMap false }];
https://community.bistudio.com/wiki/create3DENEntity
create3DENEntity an animal
https://community.bistudio.com/wiki/setCurrentWaypoint#Notes
setCurrentWaypoint in a waypoint (A2 1.05 though)
Hmm, recursive addEventHandler did crash but it took a lot longer than it used to.
Actually threw "out of memory".
4GB stack cap or something.
the first one is kinda bad 
I'll see if it can be fixed 
The openMap one should be fixed by the recent UI stuff fixes
Also can't open a map on a server can you?
yeah if it's dedicated you shouldn't be able to
Why not just use
endMission "end";
I inadvertently crashed Arma yesterday but it didnt fully crash. Had two hashmapobject definitions. In A's create method it was supposed to create B but I mistakenly typed in definition A into it's own constructor. Just froze. No memory or cpu usage spike but it wouldn't leave the main monitor screen and my task manager wouldn't kill it. Tried to create a new desktop (win 11) and the Arma screen just followed me on to each new one like it was just a poster stuck on my main monitor. I could operate windows just fine. It was just the window that stuck. So to get rid of it I had to sign out and then cancel the sign out when the window/process was finally closed. No idea what the effect would be on a server but if it was anything like I experienced you can use it to turn it into a brain dead server. Or if you want to turn Arma into like a permanent JPG lol
Hi, could someone help me im trying to make a shot timer which counts the shots a player shoots and calculates the time difference between the start and the time of the last shot
_player = player;
_shotCount = 0;
_countShots = {
_shotCount = _shotCount + 1;
};
_eventHandler = _player addEventHandler ["Fired", {
[] remoteExecCall _countShots; // Schuss zählen
}];
_startTime = time;
sleep 10;
_endTime = time;
_player removeEventHandler ["Fired", _eventHandler];
if (_shotCount > 0) then {
_lastShotTime = _endTime - _startTime;
} else {
_lastShotTime = 0;
}
hint format ["Schüsse in 10 Sekunden: %1 | Letzter Schusszeitunterschied: %2 Sekunden", _shotCount, _lastShotTime];```
Thats where i want to implement it after line 9if ([player, 'KSK_Shot'] call BIS_fnc_hasItem) then { whistle_name = _this select 0; if (isNil {missionnamespace getvariable 'shot_soundsource'}) then {} else {deleteVehicle shot_soundsource;}; shot_soundsource = 'Land_HelipadEmpty_F' createVehicle position player; shot_soundsource attachTo [player,[0,0,0]]; _waitTime = random 3; hint "Timer pressed... standby"; sleep _waitTime; [shot_soundsource,[whistle_name,5,1]] remoteExec ['say3D', 0]; sleep 1; hintSilent ""; };
Have not tried since making the ticket, but I assume it still works as the ticket is still open: https://feedback.bistudio.com/T162112
@queen cargo Java has had lambdas since Java 8 which is more than a year old already
rly?
kinda lost track after 7
yep
there's also the streams api, new comparator api, new date api that doesn't suck (third time's a charm)
lots of good stuff in version 8
most of it being copied from scala
which is a good thing
I don't really understand what you want to do with this part, can you give some details about this second part you want implemented?
The idea is that the script will count the shoots a player has shot and will also calculate the time that the player needed to take those shots. And im trying to get the script to execute in the line 9 at the lower code
Yea, but the second part has nothing to do with counting shots and works more or less like a horn per say.
yea thats a snippet where i want to implement it
The lower code works i just need help at the shooting timer
shotCount = 0;
private _eventHandler = player addEventHandler ["Fired", {
shottime = time;
shotCount = shotCount + 1;
}];
sleep 10;
player removeEventHandler ["Fired", _eventHandler];
_lastShotTime = [0, time - shottime] select (shotCount > 0);
hint parsetext format ["Schüsse in 10 Sekunden: %1<br/>Letzter Schusszeitunterschied: %2 Sekunden", shotCount, _lastShotTime];
this should work
there are some physx crashes with ropes, like attaching rope from parent object to parent object
i once managed to make my graphics drivers break as a result of trying to ropecreate and ropecut on every frame
Interesting to see people can't make servers crash, because all I need is a broken script in a random mod to take it down 🤷
I don't run random mods :P
We neither, but had enough cases in the past years where a mod worked perfectly fine when testing and even runs perfectly fine with less than 10-20 people on the server, but the moment you increase the amount of people (we run 60+ player missions) it crashed the server within seconds after a script got executed.
Worst one we had with another mod is RHS breaking the arsenal init, which was an alt-f4 case but not an actual crash.
The 32-bit servers fall over pretty easily but that's expected.
Worst one we had was the USAF AC-130 mod, everything was fine till someone started the engine of that thing; because it was executing it on all machines (server and clients), causing memory leaks and massive desync everywhere. And with 3 HC's and 60 players it crashed everything within seconds. With smaller player groups it usually crashed everything within an hour or so.
Got fixed pretty soon after it got reported though, so not an issue anymore 😉
Just use ADTs config search with full depth. That always causes a memory crash after sometime.
Is there anyway to add all the items from a Unit Loadout Array into the inventory of an object?
Any other ideas? You'd have to add a check to figure out how many of that item are in
Once flattened, quantity numbers will no longer be associated with their item; there's also no way to determine which command to use (addWeaponCargoGlobal vs addItemCargoGlobal etc).
It would be better to not flatten it, and instead try to split out the arrays since they're in a defined structure.
Start of an example:
_loadout params ["_primaryInv","_secondaryInv","_handgunInv","_uniformInv","_vestInv","_backpackInv","_items1Inv","_items2Inv"];
_uniformInv params ["_uniform","_uniformItems"];
_container addItemCargoGlobal [_uniform,1]; // Don't quote me on uniforms being items
{
if (count _x == 3) then {
_container addMagazineCargoGlobal [_x#0,_x#1,_x#2];
} else {
_container addItemCargoGlobal [_x#0,_x#1];
}; // you probably need a way to detect weapons in inventory too...not sure how
} forEach _uniformItems;
for detecting weapons in inventory, it looks like they should be formatted as an array the same length as the primary weapon array, so that would be how you detect them. You can put them in the container with addWeaponWithAttachmentsCargoGlobal.
Is it possible to remove current magazine from turret then add it and skip reload phase ?
That's what i am trying to do with no success:
_target removeMagazineTurret [_magazineName, _turret];
_target addMagazineTurret [_magazineName, _turret, (_oldAmmoCount - 1)];
_target setWeaponReloadingTime [_player, _weapon, 0];
_target loadMagazine [_turret, _weapon, _magazineName];
Once again, i need to remove current magazine (because i need to decrease ammo count) then add it back with no reloading
https://community.bistudio.com/wiki/addWeaponItem
I don't know if this works but worth a try?
its not working. This command are for hand weapons not for turrets
Need a script-driven server restart
@meager granite @granite sky @hallow mortar thanks for the help last night guys. ended up opting for 2 EH. 1 handledamage thats sets unconscious, and from there an animationchanged EH for the holdaction and revive thingy. works like a charm. even had an action eject for if the unit is in a veh.
I thought i remembered it was shutting down the server, maybe i'm wrong (been a while).
It eventually makes a new round to start
"if ("unconsciousface" in _anim) then {...}" ... feeling the need to change the unit's name to unconsciousface lol
It's very difficult to target specific magazines. Although they are notionally unique and can have unique IDs, we don't really have the commands to work with them in that way. So, uh...
- save the details of the existing weapon and magazines
- remove the existing weapon and magazines
- re-add the magazine you want to load
- re-add the weapon (the magazine already present should be automatically and instantly loaded)
- re-add the remaining magazines
Complicated? Yes. But I don't think there's a way to do it better with the available commands.
Note thatsetWeaponReloadingTimeis for the time between rounds in a magazine, not the time between magazines.
like how long it takes to chamber a round?
SetWeaponReloadingTime maybe?
I haven't read anything, but maybe lmao
"This command does not change a weapon's (e.g soldier's rifle) magazine reloading time but changes the ammo reloading state before the next round is shot."
Ty for answer. But which magazine in new weapon should be automatically loaded first ? In what order are magazines loaded for new weapons?
Also, as a solution i found this command https://community.bistudio.com/wiki/setMagazineTurretAmmo . It does what i need. But your case are reserv one )
I don't know how it's decided if there are multiple existing magazines.
That's why I said to remove all the other magazines, making sure only one (the one you want to load) is present when the weapon is added. The other magazines can be re-added after the weapon is added and loaded.
That command has a huge red warning saying it's broken if there are multiple magazines of the same type.
Yeah i see. But anyway i am sure that my magazines would be 100% unique
Can anybody confirm this function actually works?
(vehicle player) setFuelConsumptionCoef 2
I found it here but it just gives a script error when executed.
https://community.bistudio.com/wiki/setFuelConsumptionCoef
https://i.imgur.com/AcE3Vo4.png
As of now, the command is not in game. It will be introduced with Update 2.16
Thankyou 🙂
You already can try in Dev-Branch
Glad it's finally coming, means I can clean up a lot of my use fuel scripts
It only took two decades 😄
Does anyone have a script or composition for an area arsenal?
Part of a radio trigger:
_radio_2 setTriggerStatements["this","[30, 150, 10, "WHITE", -8] execVM "scripts\skyFlares.sqf"",""];
Do you include the middle "[]" or is it something else? TIA
The use of [] is correct; can't speak for what's inside it as I don't know how skyFlares.sqf does.
However, you have a problem with your "".
pets C#
Because "" denote the ends of a string, you have to be careful using them inside a string. The game can get confused. You need to either escape them by doubling them, or differentiate them by using ' instead.
Soon..
In this case, you need to change "WHITE" to either ""WHITE"" or 'WHITE', and the same for the execVM file path
Is there a way to add a downward force? I tried addForce and addTorque, but I can't seem to be able to add a downward force (maybe I am using the commands wrong?)
Just put minus?
I'll try that, but I don't think addForce works on the up/down axis, only lateral
at least thats what it looked like in my testing, I could be using it wrong as well
It should
addForce is a 3D vector in world space, so down should be a negative force on the Z axis (third number) in the first array
Keep in mind that things commonly found above the ground may have an upwards force keeping them there (for example, engines). You might need to increase your downwards force to overcome that.
Yeah, that might be it. I'm trying to use it on a helicopter, but haven't had any luck
I'm launching my game again to test it again with a negative third value
You might also want to try applying the force repeatedly over several frames, depending on how you want the helo to be affected. Because you're pushing against both its active lift and its aerodynamic surfaces, it will lose the added speed quicker than you might expect.
You can also try setVelocity for a slightly different approach.
addForce also can be affected by the object's mass
It can, but it sounds like they've already figured out a good value for overcoming the mass since they mentioned lateral force working.
I think multiplying with getMass can repro very similar result regardless how heavy it is
actually addVelocity works a lot better for what I am trying to achieve, I did not know of the function before, thank you
Thanks for the reply, i will give it a shot.
_radio_2 setTriggerStatements["[delay, height, heightRandom, 'color/type', speed] execVM 'scripts\skyFlares.sqf'",""];
skyFlares.sqf is a custom script for simulating firing a flare above the player who triggers it through the radio.
Edit: Works, thanks
Different question, is there an SFM version for collectiveRTD?
I think inputAction to detect
while {not isNull p1} do {"pm1" setMarkerPos getPos p1; sleep 0.5;{;}}
};```
if placed in init.sqf,
will this run on respawn or do i copy the code to onPlayerRespan.sqf?
Or can someone point me to a script that would work better. TIA
While cannot recall respawned unit is the same unit with before, one thing I should to point is {;} is very broken and will cause an error
Visual Studio Code added the extra when i was typing. Fixed.
Was meant to be
while {not isNull p1} do {"pm1" setMarkerPos getPos p1; sleep 0.5;};
};```
It'll run until p1 is null. Whatever p1 is. No point running it twice anyway.
Sry for the questions, im forcing myself to improve my scripting. I can read and understand the code, but as soon as i try to type it myself, my brain makes itself absent (so to speak)
Im making a dynamic armor campaign with the players as tank commander and want markers to follow each player to allow coordination.
To answer your "whatever p1 is":
p1 is the variable name of the first player slot.
In addition, pm1 is p1's personal marker.
I have a trigger with:
Condition: !alive p1
Activation: deleteMarker "pm1";
and the above code in init.sqf.
When starting, the marker is visible,
on respawn the marker is gone.
(it occurs to me, as i write, to use createMarker in onPlayerRespawn.sqf instead)
Why are you deleting the marker?
When you respawn, p1 is set to the new player. It's probably never null because even when the player is dead and awaiting respawn, it's still pointed to a valid corpse.
Is it possible to export all the items and their quantity to use in a different mission into a file or something easily saved to reuse? Like Mission 1 would be to Raid and acquire weapons/items/vehicles and Mission 2 would make use of everything you gathered?
I should be able to gather the gear and vehicles myself but I'm not sure how I could easily transfer it to another mission other than printing everything in chat ingame and writing it down by hand
You can save whatever you like in profileNamespace.
Can you plz make a ticket with repro?
I see, that's like a variable that's saved between game sessions?
It's saved to the [username].vars.arma3profile file in the profile.
Be a bit careful about how much stuff you dump in there, because it's probably gonna be there forever.
Another option is to use missionProfileNamespace, but that's a bit busted on Linux.
So long as I remember to clear it (setting it/them to nil) after I'm done it should be okay right?
That would be above average behaviour :P
Make sure you tag your vars properly too, because everything gets dumped in there.
Sounds good, thank you :)
I'm trying to code an ammunition for a training style weapon, that when it hits an AI unit it deletes the AI as if Zeus had done it. How would I go about this?
think the other way around, use a "Hit" or "HandleDamage" event handler to delete the unit if said ammo is used 🙂
I hadn't thought about it that way but makes sense. Would you have an example in mind? I'm still learning EventHandlers and scripting.
[_VRsoldier, false, 10] spawn BIS_fnc_VREffectKilled;
```perhaps 🙂 not sure
I'll give it a whirl and look into it more. Definitely somewhere to start
In this case it makes more sense to use projectile event handlers
In what regard? Like I said I'm new to this but with some help I pick it up quick
see https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Projectile_Event_Handlers
player addEventHandler ["FiredMan", {
params ["", "", "", "", "", "", "_projectile"];
_projectile _addEventHandler ["HitPart", {
params ["", "_hitEntity"];
if (not alive _hitEntity) then { deleteVehicle _hitEntity };
}];
}];
```I _think_ this would work - as soon as they are dead, poof they disappear
Could someone help me im trying to spawn ai with a random preseted loadout and position. And does anyone know how to trigger a script via ace or a button on someone who is standing on a marker/ in a trigger?
Does anyone know how to reduce Recoil when at all? Ive tried 2 ways and it hasnt done anything:
Method 1:
initPlayerLocal.sqf
player addMPEventhandler ["MPRespawn", {player setCustomAimCoef 0.1}];
player setUnitRecoilCoefficient 0.5;
player addEventHandler ["Respawn", {player setUnitRecoilCoefficient 0.5}];
player enablestamina false;
player addEventHandler ["Respawn", {player enablestamina false}];```
Method 2:
I followed this Forum Post: https://forums.bohemia.net/forums/topic/186415-player-setcustomaimcoef-1-what-does-1-mean/
Still nothing works, if there another way please @me or Reply to me on the message.
I like the number 28. What does the number 1 mean in the command? .
is there a way to remove all objects starting with land_ on a map ?
or an way to get all classnames used in an map?
remove all houses and existing buldings
for what purpose, if I may ask?
yes, its for an server with civil war era, and its now modern buildings on it.
I see
Try this (beware - may take time!)
if (isServer) then
{
private _allTerrainObjects = nearestTerrainObjects
[
[worldSize / 2, worldSize / 2],
["BUILDING", "HOSPITAL", "HOUSE"],
worldSize * sqrt 2 / 2,
false
];
{ _x hideObjectGlobal true } forEach _allTerrainObjects;
};
see https://community.bistudio.com/wiki/nearestTerrainObjects for the available search types
Did the job thanks 😀
would probably recommend that gets scheduled but shouldnt be too dreadful for most maps
is there a way to get mission id from RPT log to use it in scripts?
19:14:26 "User/BIS_fnc_log: [BIS_fnc_preload] ----- Scripts initialized at 573.997 ms -----"
19:14:29 Mission id: ff5a621422e2cfa61e2fb358a424d076a6466e61
anyone got a function to create either an array of strings of all ANSI characters, or a single string of all ANSI characters?
like the opposite of toArray syntax 1
oh I'm blind, I think toString does it
having an odd issue and was wondering if anyone could help, I have a backpack that swaps textures when you perform a specific action and it works for literally everyone except for one guy
this one guy has the bits turn invisible (not pulling the correct texture) everyone else it fine
is*
Does anyone know how to spawn ai on a random marker but not twice
yes
coud you maybe help me there i use an array for the position
do you use an array of markers and spawn multiple AI units?
i send you the code via private message
example with BIS_fnc_arrayShuffle:
private _arrayOfPositions = [_pos1, _pos2, _pos3] call BIS_fnc_arrayShuffle;
private _unit = objNull;
while { _arrayOfPositions isNotEqualTo [] } do
{
_unit = _grp createUnit ["UnitClass", _arrayOfPositions select 0, [], 0, "NONE"];
_arrayOfPositions deleteAt 0;
waitUntil { sleep 1; not alive _unit };
};
serverNamespace setVariable ["BIS_WL2_cappingValues",
compileFinal createHashMapFromArray [
["B_Quadbike_01_F", 1], ["B_LSV_01_unarmed_F", 1], ["B_MRAP_01_F", 1],
["B_Truck_01_transport_F", 1], ["B_Truck_01_fuel_F", 1]
....
]
];
how come i'm getting the error: Attempt to override final function - bis_wl2_cappingvalues?
should the compileFinal happen before the setVariable?
How to correctly unload gunner interface that was loaded by onLoad event from turretInfoType of vehicle when player leaves vehicle ?
Found that some kind of RHS vehicle e.g. rhs_t72bb_tv still have opened gunner display after leaving vehicle. It closes when player enter to different vehicle or another seat of current vehicle but still persist if player leave the vehicle and enter to another same vehicle (and same seat).
Is it possible to set a condition so that when a helicopter lands, units only then start moving towards the helicopter?
Tons of ways, here are a couple of easy ones.
Without Scripting
- Use
Set Waypoint Activationwhen right clicking a waypoint. Link two waypoints together, one from heli, one from infantry group.
With Scripting
- Create your waypoints for both the heli and infantry
- Disable
PATHon infantry - Use
On ActivationunderWaypoint: Expressioninside of the attributes of the heli's waypoint - enablePATHin that expression box using the array of units of the infantry group
Does anyone know what the shift-click local waypoint is referred to as programmatically? I'm looking for a way to set it on a specific client
Does "player" variable exist on headless clients, or is it objNull like on the server?
(please ping me if you reply)
You can get it with https://community.bistudio.com/wiki/customWaypointPosition but I don't think there's a way to set it via script
Headless Clients are rather similar to players:
The Array returned by the allPlayers command also contains Headless Clients.
The player command returns the Headless Client Entity on the Headless Client's machine.
Using isPlayer with a Headless Client Entity returns true if a Headless Client is connected to the corresponding slot.
Headless Clients execute init.sqf and initPlayerLocal.sqf.
Headless Clients trigger initPlayerServer.sqf.
thx, missed that
@queen cargo How is it large overhead to make an extension? Is it because the game has to wait for the extension to finish? If so use threads.
does BIS_fun_objectGrabber not grab objects from the spearhead cdlc?
??
you said "@vocal mantle thats correct! however, it is also a kinda large overhead to create an extension and most people are not capable of doing so"
@queen cargo I dont know if you are using "overhead" in the same way I am thinking.
Na XD most people simply cannot write c/c++ thus its an overhead for em to learn
The only thing that I do not like about Killzone Kid's extension is that you can not edit any file, only the last file you created. I know it was done for security reasons, but I suggested including a header to the file that would let the extension know that the file can be modified.
Write your own :P
It doesn't seem to me like there should be any reason why it doesn't, but I can't investigate it in the function viewer right now.
For anyone else looking, the actual function name is BIS_fnc_objectsGrabber
Well that was me a few months ago. I'm no expert but it's easy once you know file I/O, threads and a basic Arma extension.
I probably will at some point
I'm working on another project in C++ at the moment
What exactly have you tried to use it on? There are a few instances where an object wont show up with that function. Namely when its a terrain object or an object with soldier type simulation.
You do not need threadding for file io
us radio
classname: SPE_Radio_Us
I did find a way around it though
Strange
Im working on a tank commander mission and im trying to create a flare system to allow players to fire a flare above them at night.
Myself and TenuredCLOUD have been working on this but we have run into a problem.
We can get the script to do what we want but they fall to the ground fast instead of slow.
Any help would be appreciated.
_count = _this select 1;
_Height = _this select 2;
_Fallrate = _this select 3;
_c = (random _count);
while {(_c > 0)} do
{
_SmokeClass = selectRandom [
"SmokeShell",
"SmokeShellYellow",
"SmokeShellGreen",
"SmokeShellRed",
"SmokeShellPurple",
"SmokeShellOrange",
"SmokeShellBlue"
];
_pos = getPosASL player;
_pos set [2, (_pos select 2) + _Height];
_flare = _SmokeClass createVehicle _pos;
_flare setVelocity [0, 0, _Fallrate];
_c = _c - 1;
sleep _delay;
};```
We are using smokes to test
called with
```_radio_2 = createTrigger["EmptyDetector",[0,0]];
_radio_2 setTriggerActivation["Bravo","PRESENT",true];
_radio_2 setTriggerStatements["this","[5, 3, 500, -1] execVM 'scripts\skyFlares.sqf'",""];
2 setRadioMsg "Fire Flare";```
It just helps in some cases, instead of making the engine wait for the RVextension function to finish. Its not required but I imagine it helps with performance.
setVelocity only applies once, not continuously unless you specifically script that. The object will quickly accelerate to its natural falling velocity under gravity.
You could try adjusting the projectile's weight with setMass (note that actual flares have a slower natural descent rate and will behave a bit differently). Otherwise you'll need a continuous application of setVelocity or setVelocityTransformation.
Here is my other C++ project if you are interested in checking it out https://github.com/Benargee/SimpleChat . It's just a project for learning C++. It's a console based chat program that will hopefully work over the internet.
Hello dear armaholics 🙂 If we talk about scripting, i'm just hydrogen compared to DNA. Maybe someone can help me. I want to multiply the fuel consumption, so the crew have to manage fuel too. is there a possibility to use the Init. so i can just past the script into it?
you mean something like this?
https://community.bistudio.com/wiki/setFuelConsumptionCoef
it's currently only available in dev branch
yes it looks like it is. so 2.16 means i have to wait right? We're playing coop in multiplayer so we don't use dev branches. do you know how long does it takes until they release 2.16?
yes. it'll probably be released around Feb-March
Tell all of your players to install Dev, it is MP compatible
okay thanks for your help 🙂
Hi everyone! can you tell me how to make a helicopter shoot off heat traps?
Flares and countermeasures are actually a weapon (CMFlareLauncher usually), so it's just a question of making the pilot fire that weapon. Well, and adding the weapon and its ammo if the helo doesn't come with countermeasures by default.
Hi all, I'm looking to add some teleports on my map. I want to have two that link to each other and are bi-directional, for placing on the Tanoan skyscrapers and used as 'elevators'. I have the issue though that the current teleports I use the user can choose to go to any teleporter on the map. Does anyone have a solution to linking two teleports together and limiting the user to switch only between those?
how do you get list of all valid factions? I tried CfgFactionClasses but it may not have all...
Get all unique faction from CfgVehicles?
maybe
hi folks.. can anyone explain how I can restore a player's incapacitated state to 'healthy'?
I feel like this is on the right track, but have not been able to make it work so far: https://community.bistudio.com/wiki/BIS_fnc_reviveOnState
try
player setDamage 0;
["#rev", 1, player] call BIS_fnc_reviveOnState;
player setVariable ["#rev", 1, true];
its #rev state 1
just do the call on the function BIS_fnc_reviveOnState as mentioned above, no need for other things as the function handles the damage resetting too
Thanks guys .. seriously appreciated ❤️
Question, essentially I want to write a script that would spawn 2 IR strobes and attach them to different parts of the vehicle (I know how to do that), it would be via addaction (I know this too), BUT how do I than later delete it?
I could name the strobes, but than if I want multiple vehicles to have that ability, the variable names would duplicate and it would break
Use setVariable to make vehicle-specific variables
Ye thats the thing that I do not know, can u explain?
@cobalt path He means, if you have, say, vehicle with the local name _veh in the current scope, then you can:
_veh setvariable ["myvar",value of myvar];
Also you can specify the target for the variable (needed for multiplayer games to make individual variables or just to decrease the network traffic), like
_veh setvariable ["myvar",value of myvar,2];
sets the variable only for your server (local or dedicated).
This makes the variable to "live" inside the individual scope, linked to the vehicle itself, so you can retrieve the value with
_veh getvariable ["myvar",define the default value here];
So I write this before the code?
"myvar" being the valua I give to IR strobe?
And instead of _veh I use (_this select 0)
You better to show us your code, to give you a correct example. Like, if the vehicle got destroyed, you need to remove IR strobes too - it it better to be implemented via Killed/MPKilled event handler.
https://community.bistudio.com/wiki/setVariable
https://community.bistudio.com/wiki/getVariable
setVariable allows you to create a variable within a specific Namespace. Normal global variables exist within the missionNamespace - a Namespace associated with the mission as a whole rather than anything more specific - but every object in the mission also has its own Namespace (there are some other kinds of Namespace too but we care about objects here). A variable in one Namespace is separate from variables in any other Namespace, even if they have the same name.
For example:
_vehicleOne setVariable ["my_var_name",true];
_vehicleTwo setVariable ["my_var_name","test"];
// Returns true:
_vehicleOne getVariable ["my_var_name",false];
// Returns "test":
_vehicleTwo getVariable ["my_var_name",""];
Notice how the two variables contain different values, even though they have the same name, because they are in the Namespaces of different vehicles.
C++11/14 = god mode
So when you create your strobe, you might do this:
_currentVehicle setVariable ["marki_var_strobeLight",_strobe,true];
and then when you want to delete it later, you can do this:
_currentVehicleStrobe = _currentVehicle getVariable ["marki_var_strobeLight",objNull];
deleteVehicle _currentVehicleStrobe;```
seriously, makes learning C++ not hard (well not as hard lol)
mainly by making sure you cant fuck up
if you fucked up then shit wont compile
Quick question: does HandleChatMessage fire on server when receiving a message from client? If not, is there an alternative handler which does so?
using naked char pointers for strings is asking for problems down the road
Quick question: does HandleChatMessage fire on server when receiving a message from client?
If the server is dedicated - then no, if it is the local serv er - of course, like any other client.
If not, is there an alternative handler which does so?
If you need some code to be executed on the dedicated, then just call the needed command from any client with remoteexec.
My challenge is that I want to handle chat messages sent by clients from a server-only mod. The only requirement I want to impose on client is to run CBA. Is there a way for server to install an event handler on clients in a JIP-compatible fashion?
Yes, remoteExec
std::string is way safer, but if you need the speed of a naked char pointer (which really is going to be minimal, especially with optimizations turned on in the compiler) you should use std::shared_ptr or std::unique_ptr or std::array
cba has a chat command thing iirc
(don't make the code to be remoteExeced too complex, otherwise you'll clog the network)
Right, it does have JIP flag, I forgot about it - thanks!
imposing cba as the only requirement for players is pretty pointless too
given its made to be a framework for other mods to use
On server:
addMissionEventHandler ["HandleChatMessage",fnc_ChatMessageHandler];
fnc_ChatMessageHandler = {
[] remoteexec ["some command",2] // Execute on the server
};
publicvariable "fnc_ChatMessageHandler" // needed if you didn't add it as a client function
EH is JIP-compatible already, to make commands JIP-compatible just add additiona JIP params to the remoteexec
My point is I don't want clients to download "my" mod as it's server only, and only require "common" things like CBA. If I don't need it, even better. But thanks for correction
off-topic, but is it stupid trying to write C# without using VS? i figured i might learn more doing everything manually in notepad++ but it's quite a struggle.
If what you said before is true, and HandleChatMessage doesn't fire on the DS, then this is not JIP-compatible, or anything-compatible, because the EH is only added on the server...where it doesn't fire
If HandleChatMessage doesn't fire on the DS, then addMissionEventHandler needs to be remoteExeced to the clients with JIP true
Note that addMissionEventHandler is a local effect command, meaning that event handlers are only added on the machine where the command is executed. Mission EHs are not automatically added on all clients or JIP - they're not the same as MP EHs, which are global.
So when I create the stroke I do _strobe = createvehicle etc etc etc
And than
_currentVehicle setVariable ["marki_var_strobeLight",_strobe,true];
To assign it to be under that vehicle variables?
I believe that is what I said, yes.
Note that _currentVehicle is a placeholder name, use whichever variable you're already using to refer to the vehicle in question
I understand, the _currentVehicle, will most likely be replaced with (_this select 0)
You can use params to quickly turn the contents of _this into readable private variables, instead of having to do _this select x every time you want to refer to something
Combining the above, it seems like I do need CBA dependency on clients, and need something like this in XEH_PostInit:
MyServerSideHandler = {....code.....}
["cba_events_chatMessageSent", {
_this remoteExec ["MyServerSideHandler", 2, false];
}] remoteExec ["CBA_fnc_addEventHandler", 0, true];
Does that make sense?
Hello I have a question a script of mine
No fly zone
Condition
(vehicle player in thisList) && {vehicle player iskindof "Plane"}
On Activation
while {triggerActivated (_this#0)} do {
private _position = vehicle player getRelPos [900,200];
_position set [2,10];
private _missileDir = _position vectorFromTo getPosATL vehicle player;
private _missile = createVehicle ["ammo_Missile_rim162", _position, [], 0, "CAN_COLLIDE"];
_missile setVectorDirAndUp [_missileDir, [0,0,1]];
[_missile, vehicle player] spawn {
params ["_missile", "_tgt"];
sleep 0.1;
_missile setMissileTarget _tgt;
};
sleep 7;
};
}```
What I must change so it also aims at ai planes as well
if you have VS why wouldn't you?
In designing the language, they had a goal to make intellisense (the backend for the vs autocomplete among other things) easy to make, and so they probably assumed you'd have it when you wrote code.
yea, remember C# is a MS language, and VS is designed to handle it
they go hand in hand
Is there any easy way how to select/collect all first elements of arrays withing an array, similarily to select column command in SQL? Thanks
if you were doing like mono on linux or something
_firsts = _array apply {_x select 0};```
noice XD thanks
then that'd be a different story, but im sure there are plenty of IDEs that handle C#
Would just vehicle not vehicle player make it aim at all alive planes
if its a matter of understanding templates that VS spits out for classes etc
i come from a web design background so c# is the first compiled language i've used...VS is pretty confusing to a noob to be honest
No, and if you read this you'll see why: https://community.bistudio.com/wiki/vehicle
Oh..
I see just vehicle will return the unit
The thing I want to do is that if it's blufor plane it gets whacked
No matter ai or player. Should I keep vehicle or do an object parent check
I'll put when blufor present for the side check
@hallow mortar
addMissionEventHandler is a local effect command
Yes, you're right, I forgot I use client commands there 🙂
how would I check with objectparent if vehicle is plane?
I saw the note
Use objectParent instead of vehicle to get a soldier's vehicle. Apart from being faster it is also more reliable, as when used on dead crew, vehicle command may surprisingly return the unit itself.
Why do I get NOID <no shape> error when I do playsound "windxxx"? The sound is placed within the misison folder for editing.
class CfgSounds
{
sounds[] = {};
class windxxx
{
name="windxxx";
sound[] = {"Sounds\wind.waw",2,1};
titles[] = {};
};
};
objectParent and vehicle are used for getting the vehicle a unit is currently inside. Because this is not what you are trying to do, you should not use either of those commands.
Is it actually a script error, or are you reading the return line from the debug console? playSound returns a reference to the proxy object the sound is played from, which is not easily represented in human-readable format, and indeed has no shape.
what shall I use?
It is from the debug console, but I can't hear a thing. Even when I try to test the sound in the trigger sound selection, it's just mute.
Targeting any arbitrary vehicle is more complex than targeting the local player's vehicle. There is no one command substitution, you need to make some structural changes to the code. I don't have time to explain it in detail right now - someone else may be able to help.
ok
You might need to reload the mission in order to pick up newly-configured sounds.
Also, .waw is not a super common file extension and there's no guarantee the game can understand it - try using .wav (or ideally .ogg as it's compressed and therefore smaller)
You said the sound is in the mission folder, but the configured file path is for it to be in the Sounds folder inside the mission folder. Make sure the file path matches the actual path.
LOOL, I have mistyped the file extension. 😄
Is there any way how can I get all the sound names, not file names, that are present in the base game? So I can use them in scripts.
And what is the best way to loop a sound?
For cfgSounds classes, open the Config Viewer and find cfgSounds.
For actual files, https://community.bistudio.com/wiki/Arma_3:_Sound_Files (you can make CfgSounds classes for these in description.ext if you need to).
For looping, a while loop is the usual method
Can Arma work with embedded loop stamps in WAV files?
no
So, the right way is to repeatedly play the sound?
quick question about remoteexec/remoteexeccall: I don't have a way to test this at the moment but, I understand they can be called in both SP and MP. If I have a preInit function that remoteexecalls another function that I want to delay until after all addons go through their preInit phase but prior to say.. init.sqf, if I run a mission in SP it will exec after init.sqf but before init.sqf in MP? As a result, I have no reliable way to execute something after all preInits but before init.sqf in SP? So the only possible way to delay something until after preInits but before init.sqf, I should check if MP in preInit and remoteexec but then, also have an init.sqf check if SP and run it first before everything else? Or is there a more fanciful way of approaching this?
Sorry if confusing. does remoteexeccall delay in SP until after init.sqf?
Execute the code at the top of init.sqf?
I guess that's the crux of my question. Making an addon that has a hashmapobject as a collection. I want other addons or mission makers to be able to add to the collection or override values in the collection before it processes and compileFinals for general use thorughout the mission. I just want to know if I have to document a warning saying, if using in SP you need to process it manually (call the second function) in init.sqf on your own.
private _missile = createVehicle ["ammo_Missile_rim162", _position, [], 0, "CAN_COLLIDE"];
for some reason it tells me 301 elements provided expected 3
before the createvehicle
I am still using the given code
check your _position variable to make sure it's not an array of 301 elements somehow.
yea I accidentally changed the wrong value
:P its way more confusing to have to remember all the shit that goes into the thing you are writing
Is there any way how to make a looped sound fade in and fade out without muting other sounds? Like a wind or storm, so that it doesn't start at maximum volume?.
does BIS_fnc_attachToRelative work with JIP?
i think it's time for me to man up and open VS again
Could be useful to look at a couple youtube videos or such about how the basics of vs works.
Not directly... buuuuuut though I haven't tried it, you could use playSound3D and the soundParams of its created source to grab the current volume and time stamp. You then terminate the old sound, and create the new one at the new volume and start at that timestamp. Interpolate it with a series of these. I have no idea if it will work or if the game will have a fit.
The easier way would probably be to just put fading in the audio file itself
Won't work for every kind of looped sound but for wind it'd be fine
That's basically how I do that, fading in the sound file itself. Is it possible to create a SFX sound without a specific spacial source?
Anyway to get a units launcher and it’s ammo cause you got like primaryWeapon and primaryWeaponMagazine
But not finding those commands for the launcher
secondaryWeapon, etc.
VS is easy peasy if you just want to write a program that compiles
Open it, write code, click compile
is there a way to play a sound with radio filter through script?
maybe at least fake it if not possible?
for example in radio protocol if unit is close to the player you hear the unit normally but if far away the unit sound will have a radio filter applied
I don't think so. You gonna have to create a extension in the language of your choice in order to create your own radio filter and play the sound
like many other IDE's
any tips on how to find UNS_SIMC_61_LIGHT from the config? it's not in CfgWeapons, CfgMagazines, CfgGlasses or CfgVehicles.
what is that supposed to be? where did get it from?
idk its unsung item
what kind of item?
i really have no idea
well where does it come from?
from this ```sqf
{
_a = getArray (_manConf >> _x);
{
diag_log format ["--> %1", _x];
} foreach _a;
} foreach ["magazines","items","linkedItems"];
the _x
dunno. what about cfgNonAIVehicles, cfgAmmo?
checking....
nope didnt find. it sounds like its a light. or is it light as in weight :/
it sounds like it's weight
yea
well just dump the config and search 
how do I do that?
on dev branch you can use the diag_dumpConfigToFile iirc
ok
dont have that :/
odd I ran diag_exportConfig in debug console and it copied some stuff to clipboard
it doesn't copy to clipboard
oh
if you don't want to use dev branch you can also use this:
https://forums.bohemia.net/forums/topic/191737-updated-all-in-one-config-dumps/
you must download its extension too
it's 32 bit 
well it's open source so you can just compile it to x64
ok thx
What's weird though Is that I found the guy who has the item but I cannot get the item listed using any of the script commands
_f = {
{
if(configName _x == "UNS_SIMC_61_LIGHT") then {diag_log text (configHierarchy _x apply {configName _x} joinString " >> ")};
_x call _f;
} forEach ("true" configClasses _this);
};
configFile call _f;
Searching for "RscCompass" like this:
17:22:58 bin\config.bin >> RscCompass
17:22:58 bin\config.bin >> RscTitles >> RscCompass
How to detect when the player is leaving the mission ? I tried to use Ended and MPEnded event but it's not working
thx for the code. it didn't find the UNS_SIMC_61_LIGHT for me but it found the RscCompass. which makes me think the item doesn't exist, its just a glitch
PlayerDisconnected through addMissionEventHandler on server
Isn't there a way to detect it locally ?
Not precisely. Best way would be to send a notification from server side to all clients, that would be guaranteed signal that player left
Server
addMissionEventHandler ["PlayerDisconnected", {
_this remoteExecCall ["client_onPlayerDisconnected", 0];
}];
Client
client_onPlayerDisconnected = {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
systemChat format ["Player UID=%1 just left!", _uid];
};
Definitely not working because the client is already disconnected
I found a way around anyway
Wait, are you trying to check when YOUR client is leaving the game?
Exactly
Or more precisely, when my client is leaving the mission
findDisplay 46 displayAddEventHandler ["Unload", {diag_log "I just the game!"}]
Display 46 closes when mission ends for whatever reason
Wont trigger if game crashes or you kill the process of course
I just needed to release a dll but it actually doesn't need to be released precisely when my client is leaving the mission so i'm just reinitialising it on postInit
Oh ? I tried Destroy event but it din't work
Destroy is for controls, Unload is for displays
My bad, i'm too tired
Is there a way to know when you got the last message from server or something similar?
Main purpose - lagswitch detection. At the moment thinking about sending players a RE or PV each X ms and if they stop getting it for longer than a threshold then they lost a connection
Such delays can then be double checked with the server to make sure it wasn't the server being frozen but client losing the connection
could you do something like server move an invisible object or invis marker around to a new map grid every X seconds.. on the client if the marker stops moving, then …
How often does server updates markers though? Probably not as often as scripted REs and PVs
Objects are not often at all, depending on distance to camera
setmarkerpos is global
Yes, but how often it updates it? Does it send the message right away?
Also doesn't it send the whole marker instead of just position? Might be too excessive 🤔
@grizzled cliff Thanks for the tips, will look into that. Yes it is VS2015. Otherwise I have accepted that my code starting out wont be perfect. Right now I am happy enough with the functionality of the UI. Next task is implementing sockets.
lol trust me, doing it the "right" way when learning solves about a billion issues down the road
I'm working on a script I found a while back to make an custom AI unit spawn with random weapons determined by this function. It runs the function without errors, but nothing happens. Can someone tell me why?
_this setVariable ["BIS_enableRandomization", false];
sleep 0.2;
_class = typeOf _this;
_randomWeaponChance = floor (random 100);
_randomWeapon = floor (random 100);
_randomWeaponProbability = 50;
if (_randomWeaponChance <= _randomWeaponProbability) then // replace default weapons
{
if (isServer) then
{
removeAllWeapons _this; // delete default weapons / ammo
switch _class do
{
case "AuxNSWGX_OPFOR_VE_Territorial_Base":
{
switch (_randomWeapon) do
{
case (_randomWeapon <= 40):
{
_this addWeapon "AuxNSWGX_VE_ARM_47M";
_this addMagazines ["AuxNSWGX_VE_762x39_30Rnd_Mag",5];
_this addMagazines ["AuxNSWGX_VE_762x39_Tracer_30Rnd_Mag",3];
};
case (_randomWeapon > 40 and _randomWeapon <= 70):
{
_this addWeapon "AuxNSWGX_VE_ARM_74S";
_this addMagazines ["AuxNSWGX_VE_556x45_30Rnd_Mag",5];
_this addMagazines ["AuxNSWGX_VE_556x45_Tracer_30Rnd_Mag",3];
};
case (_randomWeapon> 70 and _randomWeapon <= 80):
{
_this addWeapon "AuxNSWGX_VE_ARM_37";
_this addMagazines ["AuxNSWGX_VE_762x51_32Rnd_Mag",5];
_this addMagazines ["AuxNSWGX_VE_762x51_Tracer_32Rnd_Mag",3];
};
case (_randomWeapon > 80 and _randomWeapon <= 90):
{
_this addWeapon "AuxNSWGX_VE_ARM_MX";
_this addMagazines ["AuxNSWGX_VE_762x51_32Rnd_Mag",5];
_this addMagazines ["AuxNSWGX_VE_762x51_Tracer_32Rnd_Mag",3];
};
case (_randomWeapon > 90 and _randomWeapon <= 100):
{
_this addWeapon "AuxNSWGX_VE_ARM_CT";
_this addMagazines ["AuxNSWGX_VE_95x40_36Rnd_Mag",5];
_this addMagazines ["AuxNSWGX_VE_95x40_Tracer_36Rnd_Mag",3];
};
default
{
_this addWeapon "AuxNSWGX_VE_ARM_47M";
_this addMagazines ["AuxNSWGX_VE_556x45_30Rnd_Mag",5];
_this addMagazines ["AuxNSWGX_VE_556x45_Tracer_30Rnd_Mag",3];
};
};
};
};
};
};
Your switch is wrong, you're checking exact string match (case-sensitive), you probably want inheritance check
switch(true) do
{
case (_class isKindOf "AuxNSWGX_OPFOR_VE_Territorial_Base"):
{
...
Also use https://community.bistudio.com/wiki/selectRandomWeighted it is much more convenient
_this call selectRandomWeighted [
{
_this addWeapon "AuxNSWGX_VE_ARM_47M";
_this addMagazines ["AuxNSWGX_VE_762x39_30Rnd_Mag",5];
_this addMagazines ["AuxNSWGX_VE_762x39_Tracer_30Rnd_Mag",3];
}, 40
,{
_this addWeapon "AuxNSWGX_VE_ARM_74S";
_this addMagazines ["AuxNSWGX_VE_556x45_30Rnd_Mag",5];
_this addMagazines ["AuxNSWGX_VE_556x45_Tracer_30Rnd_Mag",3];
}, 30
,...
]
(40 and 30 are not percent here, they're 40/70 and 30/70 chance)
Probably can just do call instead of _this call
Gotcha. That makes sense.
Definitely simplifies it. Scripting is not my specialty but I'm getting there. Thank you for the help
Another bit of advice, to avoid deep indentations you can replace if(isServer) {... which adds another tab, with if(!isServer) exitWith {};, will make your code more readable
I think learning SQF first has made me worry too much about performance, like my use of char pointers over strings.
if (_randomWeaponChance <= _randomWeaponProbability) then // replace default weapons
{
if (isServer) then
{
removeAllWeapons _this;
...
};
};
```=>```sqf
if (_randomWeaponChance <= _randomWeaponProbability) then // replace default weapons
{
if (!isServer) exitWith {};
removeAllWeapons _this;
...
};
Or even a one-liner
if(isServer && {_randomWeaponChance <= _randomWeaponProbability}) then ...
And that would reduce the tab again?
No, just less clutter to focus on important stuff
You probably can make this one-liner an exitWith too but I assume you're doing something else for non-servers later
Up to you though, your code looks nice already
I didn't have any plans for non-servers as this is for use with a faction for my unit. Just to keep some diversity with the weapons they use. But cool. I'm gonna adjust and give it a whirl
Hello!
I am currently running into a small AI related issue.
This is the code that I am using to check if the AI group is inside the helicopter:
{alive _x && {_x in evacHELO}} count units natoSQUAD isEqualTo ({alive _x} count units natoSQUAD)
This works all fine, but when I shoot the legs of an AI in the group (for example the sharpshooter), the AI refuses to board the vehicle, but it still completes the check and triggers the hint.
I've also tried moveInAny after the activation, but that doesn't get the injured AI inside the vehicle.
Does somebody have an idea to force the AI to board the vehicle in any other way? (Already saying sorry if I missed something very obvious :D)
Video for reference: https://www.youtube.com/watch?v=3TH42Pblv9o
Is it possible to create a SFX sound without a specific spacial source?
playSound
playSound can't create SFX classes. It only uses cfgSounds.
oh you mean CfgSFX ones. well those can only played with createSoundSource afaik
you can play them manually tho
all you need is the path to their sound files
You'd have to fully reconstruct all the randomisation and looping features though, which is presumably why they want to use SFX in the first place
oh my brain assumed that was a secondary like a pistol. I should've read the wiki better
How do I access a parent element (_x) in forEach within a forEach? Should I declare a private variable for it?
yes. you should save it into another var before entering the nested forEach
Which type of position is returned by this command?
https://community.bistudio.com/wiki/buildingExit
There is written just Position. So is it ATL or ASL or AGL?
"line 167: '/CfgRespawnInventory/Blufor9.': '{' encountered instead of '='"
161 {
162 displayName = "LAT (M4A1 Tac)";
163 icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa";
164 role = "LAT";
165
166 weapons[] = {"SMA_M4MOE","launch_NLAW_F","hgun_Pistol_heavy_01_F","Rangefinder","Throw","Put"};
167 magazines[] = {"SMA_30Rnd_556x45_M855A1","11Rnd_45ACP_Mag","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SmokeShell","SmokeShell","SmokeShell","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","SMA_30Rnd_556x45_M855A1","HuD_ChemFlare_Red_Mag","HuD_ChemFlare_Red_Mag","SmokeShellRed","SmokeShellPurple","SmokeShellGreen","HandGrenade","HandGrenade","HandGrenade","HandGrenade","11Rnd_45ACP_Mag","11Rnd_45ACP_Mag","11Rnd_45ACP_Mag","11Rnd_45ACP_Mag"};
168 items[] = {"ACE_EarPlugs","ACE_EntrenchingTool","ItemAndroid","ACE_IR_Strobe_Item","ItemcTabHCam","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_morphine","ACE_splint","ACE_splint","ACE_tourniquet","ACE_tourniquet","ACE_tourniquet","ACE_tourniquet","kat_chestSeal","kat_guedel","kat_larynx","ACE_epinephrine"};{"ACE_EntrenchingTool","ItemAndroid","ItemcTabHCam","ACE_EarPlugs","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_packingBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_elasticBandage","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_fieldDressing","ACE_morphine","ACE_splint","ACE_splint","ACE_tourniquet","ACE_tourniquet","ACE_tourniquet","ACE_tourniquet","kat_chestSeal","kat_guedel","kat_larynx","ACE_epinephrine"};
169 linkedItems[] = {"USP_CRYE_CPC_FAST_BELT_MC","opscore_highcut_cover_mc_US","USP_BALACLAVA_ESS_CBR","SMA_eotech552_3XDOWN","SMA_SFPEQ_M4TOP_BLK","ItemMap","ItemCompass","Foski_IRStrobeBeaconItem","TFAR_anprc152","ItemGPS"};
170 uniformClass = "USP_G3C_KP_MX_MC";
171 backpack = "USP_CRYE_BELT_PACK_MC";
172 };``` No clue whats up here, or maybe im blind, sorry its kinda unreadable
this is config isssue not scripting
#arma3_config and please use pastebin
so i dont know why i do average times, but really need to not do that...
18:09:46 avg: 0.135632324218750000000000ms @ 10000
18:09:46 median: 0.000000000000000000000000ms @ 10000
18:09:46 min/max: 0.000000000000000000000000ms/1.098632812500000000000000ms @ 10000
18:09:46 0ms count: 8644
Maybe I need to sleep, but...
Why this doesn't work?
~~```sqf
[player, unit] select (isPlayer _x);
It says ```Error 3 установлено элементов, 1 ожидалось```~~
Yes, I need to sleep...
Here, take these: {}
No, I mean why in this case it doesn't work as expected. I want to select element 0 or element 1 depending on boolean condition.
Like
["", "0"] select (date select 1 < 10)
returns "" or "0".
But what is wrong with the command above?
Assuming _x is a valid reference to a unit that can be checked with isPlayer, and unit is indeed a single unit, logically nothing is wrong
Check other nearby lines for missing ] or variables with unexpected contents
Because an open [ somewhere before might only be caught now, when a ] catches up to it
When you test the line alone, without any other code, are you still using _x?
trying my hand at a script, having an issue I am having difficulty solving.
class EventHandlers
{
class onfire
{
fired =
"_myWeapon = _this select 0; \
_vehicle = vehicle _myWeapon; \
_targetRadius = 50; \
_objects = nearestObjects [getPosATL _vehicle, ['Man'], _targetRadius]; \
{ \
_object = _x; \
if (side _object != side player) then { \
hint format['Firing at enemy: %1', name _object]; \
diag_log format['Firing at enemy: %1', name _object]; \
_bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) vectorAdd [0,0,50]), [], 0,'CAN_COLLIDE']; \
_bullet setVelocityModelSpace [0,0,100]; \
diag_log 'Bullet created'; \
}; \
} forEach _objects;";
};
};```
The end goal is to make this fire a bullet at all enemies within X range.
The current error it is generating is:
``` 0:46:34 "Firing at enemy: Stavros Strambopoulos"
0:46:34 "Bullet created"
0:46:34 Error in expression <]; _bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) ve>
0:46:34 Error position: <createVehicle [((getPosATL _myWeapon) ve>```
_myWeapon is a string there, I assume?
I am not 100% sure on terminology as I am very, very new to scripting.
My understanding is that this would be appropriate as a variable indicating the weapon firing - this script is found in the cfgWeapon
As far as I can tell those event handlers are undocumented.
which ones?
maybe chuck a diag_log str _this at the top of it.
config event handlers in general.
It is identical with Fired unit EH IIRC
Yes, but it doesn't say what the parameters are.
hm
Like this?
class EventHandlers
{
class onfire
{
fired =
"diag_log str _this;\
_myWeapon = _this select 0; \
_vehicle = vehicle _myWeapon; \
_targetRadius = 50; \
_objects = nearestObjects [getPosATL _vehicle, ['Man'], _targetRadius]; \
{ \
_object = _x; \
if (side _object != side player) then { \
hint format['Firing at enemy: %1', name _object]; \
diag_log format['Firing at enemy: %1', name _object]; \
_bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) vectorAdd [0,0,50]), [], 0,'CAN_COLLIDE']; \
_bullet setVelocityModelSpace [0,0,100]; \
diag_log 'Bullet created'; \
}; \
} forEach _objects;";
};
};```
you missed the semicolon.
you're right
1:11:58 "Bullet created"
1:11:58 Error in expression <]; _bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) ve>
1:11:58 Error position: <createVehicle [((getPosATL _myWeapon) ve>
1:11:58 Error 4 elements provided, 3 expected
1:11:58 "Firing at enemy: Abdul-Latif Khusraw"
1:11:58 "Bullet created"
1:11:58 Error in expression <]; _bullet = 'B_9x21_Ball_Tracer_Green' createVehicle [((getPosATL _myWeapon) ve>
1:11:58 Error position: <createVehicle [((getPosATL _myWeapon) ve>
1:11:58 Error 4 elements provided, 3 expected```
It doesn't seem to be running the new code.
repacking just in case
no change
Maybe that stuff needs the whitespace before the backslash. I wouldn't know.
Wrong createVehicle syntax
you're using half of the main syntax and half of the alternative syntax
oh?
https://community.bistudio.com/wiki/createVehicle
You're doing this:
_class createVehicle [_position, _markers, _radius, _placement];
But that isn't a valid syntax. Because you're putting the class as the left argument, like the main syntax, the game is trying to interpret the right argument array as a position (3-element array), as it expects from the main syntax, and getting confused because it's not actually a 3-element position array.
You need to commit to either of the two syntaxes specified in the documentation. I suggest the second one since it has the exact placement parameter.
so to be clear:
type createVehicle position
Parameters:
type: String - vehicle/object className
position: Array format Position - desired placement position. If the exact position is occupied, nearest empty position is used.
Return Value:
Object```
You are saying I am mixing type and position
OH
I see
createVehicle [type, position, markers, placement, special]
Parameters:
type: String - vehicle/object className
so I am using this:
createVehicle [((getPosATL _myWeapon) vectorAdd [0,0,50])
You are suggesting I use:
createVehicle [type, position, markers, placement, special]
You're currently using neither of the actual syntaxes, which is why it isn't working. You have the classname arranged as it would be for the main syntax (left of the command), and everything else arranged as it would be for the alternative syntax (in an array right of the command). Syntaxes can't be mixed like that. You must choose one of the two syntaxes - either _class createVehicle _position or createVehicle [_class, _position, _markers, _placement, _special]. I think the second, alternative syntax is best for what you're doing.
_bullet = createVehicle ['B_9x21_Ball_Tracer_Green', getPosATL _object, [], 0, 'CAN_COLLIDE'];
does this appear better to you @hallow mortar ?
That matches one of the available syntaxes, so it should work.
cool. Sorry, I am slow at this, I am really new to scripting and kinda trying to fumble through this.
class EventHandlers
{
class onfire
{
fired =
"diag_log str _this;\
_myWeapon = _this select 0; \
_vehicle = vehicle _myWeapon; \
_targetRadius = 50; \
_objects = nearestObjects [getPosATL _vehicle, ['Man'], _targetRadius]; \
{ \
_object = _x; \
if (side _object != side player) then { \
hint format['Firing at enemy: %1', name _object]; \
diag_log format['Firing at enemy: %1', name _object]; \
_bullet = createVehicle ['B_9x21_Ball_Tracer_Green', getPosATL _object, [], 0, 'CAN_COLLIDE']; \
_bullet setVelocityModelSpace [0,0,100]; \
diag_log 'Bullet created'; \
}; \
} forEach _objects;";
};
};```
I'm pretty sure you don't need those \. Dunno if they'll actually break anything by being there, but they don't do anything useful either.
just a means for the script to be recognized across lines. Easier to see, when implementing I use a single line to prevent those problems
great news! That appears to be a step in the right direction
Do you think it will be hard to make it originate from a memory point and fire the spawn ammo type at the targets?
@hallow mortar
Probably not very hard. Well, in comparison to things that are very hard in SQF. Might be a bit complex to figure out from basics. Here are some starting points:
https://community.bistudio.com/wiki/selectionPosition
https://community.bistudio.com/wiki/modelToWorld
https://community.bistudio.com/wiki/vectorFromTo
I appreciate you deeply. Thank you.
Hey everyone!
So i am running Liberation server and i have restart script in the mission file.
The problem is, that after scripted restart HC isnt joining server, and after trying to start it manually it says that server is stopped.
Anyone have idea how to fix it?
i'm only learning c# to make a game in Unity, i just don't like monodevelop so started using np++ instead. will probably switch to VS express soon.
#server_admins probably
Hello 😄 I have a mission where a blufor is in a static weapon trying to push enemy waves. Sometimes he'll die, but I want him to respawn in the same static weapon. How can I do ?
@tough abyss Maybe - just disable damage for him? 🙂 Or you just want him to die?
_unit allowdamage false;
That's for a server, I would like him to Spawn again when killed
Disable damage for him would be not very réalistic in my case 🥺
Ok. So how do you suppose it should looks like? Describe in details. Like, you want him to fall unconscious, and maybe then he should "wake up" and return to his place, or to remove him completely, or to keep the body in place, and spawn a new unit?
The basics is very simple - just create a unit with the same loadout (see getunitloadout/setunitloadout) and order him to occupy the gun. The real algorithm depends on the desired design.
Yeah I'm not a fan of MonoDevelop at all either, so I can't blame you there.
Well I want his body to disappear and Spawn a New unit wich will take his place in the static weapon
But I want it to be 30sc After
You need the Killed/MPKilled event handler. In its code something like that:
OT_gunner_handler = {
_this spawn {
params ["_unit"];
_loadout = getunitloadout _unit;
_type = typeof _unit;
_gun = gun
_group = if ({alive _x} count units group _unit > 0) then {group _unit} else {creategroup blufor}; // set the needed side
_pos = ... // set the needed pos for new unit to spawn, I suppose you wanted him not to be visible for players initially?
sleep 30;
if (isNull objectParent _unit) then {
deletevehicle _unit;
} else {
vehicle _unit deleteVehicleCrew _unit;
};
_newunit = _group createUnit [_type,_pos,[],0,"NONE"];
_newunit setunitloadout _loadout;
_newunit assignAsGunner gun;
[_newunit] orderGetIn true; // This variant is for more realistic behavior. If not needed, use _newunit moveInAny gun
_newunit addEventHandler ["Killed", OT_gunner_handler];
};
};
// Define the gun, in your case it is better to have a global variable to handle it, like gun
gunner gun addEventHandler ["Killed", OT_gunner_handler];
Thank you very much ! Where should I put this code ?
Anywhere where it runs during mission init 🙂
I recommend to put it in the gun or gunner init fields.
Don't forget to adjust the name for the gun.
If using it in the gunner init, you can use
this addEventHandler ...
``` instead of gunner gun
Ah, I forgot to add the same EH for the new unit. Is it needed? If so, I edited the code above a bit.
Man thx very much, tho i'll be honest with you I don't understand anything in coding so it seems like you talk chinese to me
I don't even know how to get the pos
I'll try putting this code as it is in the gunner init field and see what happens
Yea didn't worked, guess i don't know how to use it
Thank you very much tho 😦
Next day working on this. I have used selectionPosition, and I understand its need. I have used vectorFromTo. (Selection position defining a selected point in the memory lod) and I am using vectorFromTo in order to create the vectors from that point to enemy troops/vehicles in range.
What is modelToWorld used for in this scenario?
is there a way to improve VLS targetting ? https://streamable.com/9ere4k
west reportRemoteTarget [t1, 3000];
t1 confirmSensorTarget [west, true];
g1 fireAtTarget [t1,"weapon_vls_01"];
selectionPosition returns coords relative to the model center, so you need to translate them with modelToWorld first before comparing them to other world coords (eg. object positions).
is that true for the second syntax of it?
Syntax:
object selectionPosition [selectionName, LOD, returnMode]
My understanding was this would be able to define a specific memory point
They all claim to return values in model space.
hm
A LOD's just a set of geometry for a model.
yeah, I understand that.
Currently my script looks like this:
params ['_unit', '_weapon', '_muzzle', '_mode', '_ammo', '_magazine', '_projectile', '_gunner'];
if (_weapon == 'TESTWEAPON') then {
_vehicle = vehicle _unit;
_targetRadius = 300;
_objects = nearestObjects [getPosATL _vehicle, ['Man', 'LandVehicle'], _targetRadius];
{
_object = _x;
if (side _object != side player) then {
_muzzlePos = _object selectionPosition ['pos_barrel_end', 'memory', 'FirstPoint'];
_direction = _muzzlePos vectorFromTo (getPosATL _object);
_bullet = createVehicle ['B_9x21_Ball_Tracer_Green', _muzzlePos, [], 0, 'CAN_COLLIDE'];
_bullet setVelocityModelSpace (_direction vectorMultiply 100);
hint format['Firing at enemy: %1', name _object];
diag_log format['Firing at enemy: %1', name _object];
diag_log 'Bullet created';
};
} forEach _objects;
};
};```
you're saying to use modelToWorldto translate a location from selectionPosition, to be clear?
yeah, this part is wrong: _muzzlePos vectorFromTo (getPosATL _object);
wait, is it?
_muzzlePos is in model space, getPosATL _object is in world space.
Oh
so modelToWorld is used to convert _muzzlePos into world space
then I use that value as (for example)
_modelToWorldValue vectorFromTo (getPosATL _object);
am I understanding that correctly?
yes.
_bullet = createVehicle ['B_9x21_Ball_Tracer_Green', _muzzlePos, [], 0, 'CAN_COLLIDE']; would also need adjusted, correct?
Yes.
got it. So once _muzzlePos is defined in the model space, it needs converted to the world space. Then use the new world space value for all further instances it in this case.
Sorry, I am new to scripting and actively taking notes, but I want to make sure they are clear for me in the event I need them again.
There are a couple of extra complicating factors that might be relevant here.
selectionPosition uses render time scope rather than simulation time scope, so you should probably be using modelToWorldVisual and getPosWorldVisual.
getPosWorldVisual then needs translating with ASLtoAGL to match.
in which case do I still need to use modelToWorld or selectionPosition?
you'd use modelToWorldVisual instead of modelToWorld.
selectionPosition is required to get the muzzle position.
so I would use selectionPosition, modelToWorldVisual and getPosWorldVisual then?
or getPosASLVisual maybe. Depends what bit of the target you're intending to shoot at.
ideally, center of mass for men and (land) vehicles
Most models are centered I think, so getPosWorldVisual might be better.
Not sure where getPosASL puts the Z. I recall getPosATL using the floor contact point.
do you mind if I post the new version when I make the adjustments? @granite sky ?
params ['_unit', '_weapon', '_muzzle', '_mode', '_ammo', '_magazine', '_projectile', '_gunner'];
if (_weapon == 'TESTWEAPON') then {
_vehicle = vehicle _unit;
_targetRadius = 300;
_objects = nearestObjects [getPosASLVisual _vehicle, ['Man', 'LandVehicle'], _targetRadius];
{
_object = _x;
if (side _object != side player) then {
_muzzlePos = _object selectionPosition ['pos_barrel_end', 'memory', 'FirstPoint'];
_muzzlePosWorld = _object modelToWorldVisual _muzzlePos;
_direction = AGLtoASL _muzzlePosWorld vectorFromTo (getPosWorldVisual _object);
_bullet = createVehicle ['B_9x21_Ball_Tracer_Green', _muzzlePosWorld, [], 0, 'CAN_COLLIDE'];
_bullet setVelocityModelSpace (_direction vectorMultiply 100);
hint format['Firing at enemy: %1', name _object];
diag_log format['Firing at enemy: %1', name _object];
diag_log 'Bullet created';
};
} forEach _objects;
};
};
missing the ASL/AGL conversion
f
_direction = _muzzlePosWorld vectorFromTo (ASLtoAGL getPosWorldVisual _object);
well....
on second thoughts, conversion should be the other way around:
_direction = AGLtoASL _muzzlePosWorld vectorFromTo (getPosWorldVisual _object);
3d directions from AGL positions are not correct.
updated. Like this?
wait, I misread this.
What are you actually trying to do?
It feels like the object shouldn't be trying to shoot itself, but people do some weird shit.
Specifically, this is an eventhandler in a cfgweapon using "fired" to trigger.
The goal is for the script to fire a round, at all men and land vehicles that are not of the same side within 300m.
Testing it, what it appears to do is spawn the round at their feet.
(though it does not appear to function after that.)
_object is the wrong var in both of these. Not sure if you meant _unit or _vehicle.
_muzzlePos = _object selectionPosition ['pos_barrel_end', 'memory', 'FirstPoint'];
_muzzlePosWorld = _object modelToWorldVisual _muzzlePos;
as this is firing from a vehicle, should it use _vehicle then?
huggggeee hype! It is working!! thank you so, so, so much!
the rounds appear to be falling short, wondering if they are targeting the ground point or if their velocity is too low and gravity is winning that fight
well, 300m is a long way for 9mm.
I switched to 120mm HE for visual confirmation as I couldn't see the 9mm
Also trying an ammo class that doesn't have bullet drop now.
It appears to be aiming at their feet
@granite sky do you think adding another variable to set this to aim a little higher would be a good fix?
_this call {
params ['_unit', '_weapon', '_muzzle', '_mode', '_ammo', '_magazine', '_projectile', '_gunner'];
if (_weapon == 'TESTWEAPON') then {
_vehicle = vehicle _unit;
_targetRadius = 300;
_objects = nearestObjects [getPosATL _vehicle, ['Man', 'LandVehicle'], _targetRadius];
{
_object = _x;
if (side _object != side player) then {
_targetPos = _object modelToWorldVisual [0, 0, 1]; // Adjust the offset as needed
_muzzlePos = _object selectionPosition ['pos_barrel_end', 'memory', 'FirstPoint'];
_muzzlePosWorld = _object modelToWorldVisual _muzzlePos;
_direction = _muzzlePosWorld vectorFromTo _targetPos;
_bullet = createVehicle ['B_9x21_Ball_Tracer_Green', _muzzlePosWorld, [], 0, 'CAN_COLLIDE'];
_bullet setVelocityModelSpace (_direction vectorMultiply 100);
hint format['Firing at enemy: %1', name _object];
diag_log format['Firing at enemy: %1', name _object];
diag_log 'Bullet created';
};
} forEach _objects;
};
};```
the comment is only there to show intent, I don't think arma scripts like comments.
MS offers the full VS product (well mostly full) now for open source stuff
VS2015 community edition
@green quail Do you need a working script for correcting bullet trajectories?
god yes
the round fire but appear to be aiming below the ground
@young current is this your doing?
((I was working with the Goat on this. He was offering advice/solutions to this problem))
As for me, I had problems with FoW static machine guns. I'm not good with configs, so I made a simple workaround for it, in Fired event handler:
private _velocity = velocitymodelspace _projectile;
private _newvelocity = _velocity vectoradd [3,0,-4]; //You need to set your own values
_projectile setvelocitymodelspace _newvelocity;
Considering the effective range for bullets usually is not higher than 300-400 meters, it works very well
I do have to get going here in a moment, would you mind if I pinged you tomorrow?
@unreal scroll
I appreciate you!
How performance consuming is attaching "handleDamage" on multiple units? Does it trigger only on hit or just it being added on many units also gonna affect performance? How preferable is editing ammo config for damage edit?
It only triggers on hits but it does trigger several times per hit.
@unborn bramble Why to ask if you can just test it by yourself? 🙂
Your testing environment and conditions could seriously vary from other players experience.
Place a hundred of units, and kill them without and with EH to see the difference.
"How preferable is editing ammo config for damage edit?"
Simple arithmetic operations almost have no effect.And almost every command could be tested in console for it's burst time.
On a client, the ragdoll cost is far, far higher than the handleDamage cost.
Adjusting damage by changing the ammo config is probably not a great idea, firstly because there are so many ammo types to modify and secondly because of the wide-ranging balance implications.
If you want to make certain units more or less resilient and you're willing to make a mod to do it (config changes of this type can't be done without a mod), it would be better to change the armour rating of those units, or give them new vest or uniform variants that have appropriate armour.
HandleDamage is the best solution for per-mission changes - mods are overkill for a single mission and depending on the change, can affect gameplay outside of the mission.
Q: does a mission or a server get an ID of any sort? i.e. that we might use to inform a persistence variable?
There's no ID for a mission or server, however you could use profileNamespace on the server to save certain variables. Could also use the missionName to identify if its the same mission, or the serverName to save the exact server.
https://community.bistudio.com/wiki/serverName
https://community.bistudio.com/wiki/missionName
missionNamespace can be used to save values to the mission for persistence
If I know what persistence means, I assume he is meaning after someone leaves and rejoins the server or the server restarts. I could be wrong though, wouldnt be the first time lmao
Im not sure if missionNamespace will save after the mission/server is restarted. But players leaving wont affect it. If its a player related thing to save, then use profileNamespace, and that will save between leaving and joining
There are some mods out there for specific persistence that save info to an external file. Thats the only way I know of that works for saving mission/server related info after a restart
Any one have a script to see your breath when its cold?
thanks, actually, combination of those, and briefingName, worldName, could all serve as keys, to a HASHMAP variable value, let's say. that'll work, thanks...
@candid sun writing c# without VS is like breathing air without O2
you can do it
you should not as it is harmful
Is it possible to find out how many doors (entrances) a building has? Through a command or config parameter?
yes you are looking at building objects, models, lods... I forget the exact lods you want, has to to with path, positions, along these lines.
apparently animationNames might work too
have a look here, might give you some insights...
https://github.com/mwpowellhtx/KP-Liberation/blob/redeux/legacy/Missionframework/scripts/shared/buildingPositions.sqf
will have to experiment with selectionNames, and then convert from modelToWorld, etc...
There is a specific command: https://community.bistudio.com/wiki/buildingExit
you could loop that until it returns [0,0,0], I guess.
I don't think you get full script access to the path LOD though.
which is kinda annoying because the building pathfinding is broken.
it can be done with the function I posted, need to experiment with the selections is all...
It doesn't seem to return any associative data. It's just a list of positions and exits.
oh, unless there's stuff other than "pos" and "in" prefixes in there.
he wants to know doors, entrances, I believe that is the "in" prefix...
but you get the other selection goodness as well. experiment, have fun!
there are other scripting commands you can use, but I don't think they are nearly as reliable...
I would expect buildingExit to find anything with "in" on it, but I might be wrong.
Prefixing commas in arrays gang 
Currently I do it by looking through buildingExit and grouping them by distance into individual exits
yessir, I like dealing with arrays I can select or apply through... the selections offers that. 😉
also like dealing in deterministic results. i.e. not iterating until magic numbers are discovered.
Meant starting new line inside array with , instead of at the end of the line
Considering it's a language designed and developed by Microsoft, it only makes sense to use their IDE.
oh that... style. it's a delimiter, not an EOL character. and I like the readability, usually.
i would appreciate it if SQF supported the extra trailing comma, which coincidentally someone else mentioned to you a few years ago, but i guess using leading commas is a way to get mostly the same benefit
Would anyone wanna help me with an old script that's messing I guess with a mod I have?
Okaaaaayyyy, I get it but- also don't at the sametime, although tbh my brain also just hurts atm so uh.. yeah.. thanks I guess..
he's saying just ask the question instead of asking for permission to ask it
cuz it's a waste of time
give details
That's- how did I ask for permission? I am not aware of these social norms
Also yeah, I guess let me figure out how I'm gonna word this..
So I'm working on a mission that deals with an AI script, "Bon's infantry Recruitment Redux" something created a long time ago back in the ARMA 2 days, now it's a fine script, setting it to an object or player as an addaction, or alternatively too yourself (which is kind of funny ngl). But at the current moment, I have a mod called "MGI's Advanced modules" and I think I've narrowed the problem down to the Bon's script stuff itself. I say this because the mods can work in an absolute environment, but considering that my scenario has some virtual elements too it, not absolute, so things like (Alive/MGI/etc) I think that Bon's script is conflicting with some stuff, I've already fixed one thing with the loadout transfer stuff and getting it disabled on another mod in the mission, but so far MGI's "AI can heal and revive" aswell as "AI can respawn", Bon's script might be conflicting with those two modules within the Mod, because without the sudden Recruiting, AI teammates can actually work with MGI's stuff.. I just don't know where I would be scanning to find such a confliction, mainly because I don't know any SQF myself, so I was wondering if anyone could help..
(First time asking on this kind of stuff btw..)
(Also if it helps the mission itself is a Zeus sandbox Scenario using CUP, has a total of 7 supports, ambient Civs using Alive, and Ambient Traffic using MGI's stuff, Spyder's addons having a loadout Transfer for AI and saving classes in subfolders for yourself and others, Ace Arsenal, and Revivable AI both by them and you alike..)
Is there an Event that's fired when someone tries to equip a restricted uniform? And could you make use of isUniformAllowed and forceAddUniform to bypass the uniform restrictions that prevent you from wearing a uniform from another faction?
Do you mean if you tried to drag and drop the uniform on gear screen?
Yeah or right click to equip or equip in arsenal
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#SlotItemChanged
This should detect upon an inventory item change, but not sure about gear d and d
Not even sure if there is a “good” way to detect dragging item or such
Gear screen is very Engine-driven as far as I can tell
Yeah, I've been looking at 'Take' and that one, not able to test right now if it's fired when trying to equip a restricted item as well
You can add drag events to the inventory lists, I remember playing around with it but not sure how reliable it is.
Why is kbAddTopic taking 10 minutes to get executed?
.bikb is 2 million lines (isn't 10 minutes still an exaggeration?)
Anyways to go about optimizing it?
…reduce the file size?
It has all radio protocol lines that are in default game, file size is 55MB
¯_(ツ)_/¯
Directory of each line is taken from the game archieve of course
try splitting it in at least 10 different files, it may help 😬
Is stacking the whole file into a single line also helps?
But why? Why not include only the lines you're going to use?
I guess that's fair
I was testing if the game could load the lines properly
almost certainly not
hi guys. im still playing around with handleDamage EH on a AI unit to give it a revive. went back and forward with different methods and find 1 reliable one. not the prettiest but reliable. however, im still having issues with the locality of the EH, since the unit starts server owned but will eventually join a player's group.
if i add the EH with remoteExec 0, it fires twice, if i remoteExec to the unit (where ever is local atm of adding), when the unit changes owner the EH does not register. im confused af.
Add the EH everywhere and put an if !(local _unit) exitWith {}; in it
Don’t mean to be sarcastic but is a run on sentence easier to read or multiple sentences. That’s the way I look at it
Does anyone know how to delete opfor/bluefor npc via script
and also is there an function the save the current goggles, set other ones then wait for a random time and set the old ones again
deleteVehicle _theGuy?
There is not a specific function for that; it's not a terribly common use-case. But it's not too hard to make one yourself.
private _oldGoggles = goggles _unit;
removeGoggles _unit;
_unit addGoggles "new_classname_here";
sleep (random [5,10,20]); // minimum time 5 seconds, max 20, weighted towards 10
removeGoggles _unit;
_unit addGoggles _oldGoggles;```
thank you
There's no need to DM me. This channel is for asking scripting questions.
"Suspending not allowed" means the context you're trying to use it in is "unscheduled" - the code is run immediately and without interruption and can't be managed by the game's script scheduler. To prevent freezing the game, sleep is not allowed in unscheduled code.
You can easily fix this by creating a scheduled context, where sleep is allowed, using spawn (https://community.bistudio.com/wiki/spawn)
🤦♂️ it's because im zeus deleting the unit and the EH persists. so everytime i run the script i get 1 fire from each previous run. also, why couldn't we have a life state EH for AI. geeez.
well like I said, it is a delimiter. style is style, it's a personal preference. some code helps are rather opinionated on the subject, as it turns out, in dotnet realms at any rate.
I tried it once, started to really like it.
up to you what you do with that.
cheers m8 🍻
is it:
[unit, "handleDamage"] remoteExec ["removeAlleventHandlers", 0];
or
[unit ["handleDamage"]] remotexec...
The first one
Leading logic operators are great too
The left and right arguments of the original command remain the same, just in a different place. Left argument is unit (Object), right argument is EH type (String) so they stay that way.
If removeAllEventHandlers took an Array as its right argument it would look more like the second one (plus a comma), but it doesn't.
I do that quite frequently as well, sir. yes.
i just wanna say, again, a life state EH for AI would have come SO handy.
Well, we don't even have one for players, and AI only use like 1 of the lifestates beyond healthy and dead (and that one is covered by handleDamage)
wait, what one's covered by handleDamage?
Injured (essentially, I mean yeah it'll fire for damage that doesn't quite hit the INJURED threshold but that's an easy check)
well, lifeState does return "injured", and if setUnconscious it returns "Incapacitated".
for players we got the scriptedEH handlers.. which are complicated in their own way.
handleDamage is a mess cos it fires for each hit part. im using it to setunconscious then have a while (alive unit) { waituntil {unit lifeste == "incap.."
could you just check the anim state?
Maybe, but there's a lot of variation due to various unconscious-dragging systems.
You really just want a lifeStateChanged EH to fire on unconscious and wakeup.
i've had a animchange EH. the thing is if the AI gets blown it changes briefly and all goes to hell
(for compatibility with other people's medical systems)
Is the goal here to just have something happen once an ai goes unconcious?
and when they wake up, yes.
is it allow to post files here? like, its too long to copy/paste.
use pastebin
It might not be the most performant option, but if you create your own eh using a while loop and incapicatedState or lifeState that would fire when the unit is uncon/awake again
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.
don't laugh too hard lol
off of this, this is what I was thinking:
[_this#0]spawn{
params ["_unit"];
_previousState = lifeState _unit;
while {alive _unit} do
{
_state = lifeState _unit;
if (_state isNotEqualTo _previousState) then{
if (_state isEqualTo "UNCONSCIOUS") then{
//Do stuff for when they become uncon.
};
if (_state isEqualTo "ALIVE") then{
//Do stuff for when they wake up.
};
};
_previousState = lifeState _unit;
sleep 1;
};
};
the formatting of this is very odd, impossible to read
set it to raw on pastebin
hm, still is
eeerr. yeah. i swear is nice on my script hahaah
what was the point of posting it? Like what do you want us to look at?
well, its relates the idea of what im attempting to do. it also gives you the chance to tell me how wrong some of the code is, which is welcome ahahah
do you think some of the code is large enough to make it into functions instead of publicVariable? i mean it is safer and better that way, but its also not that much code. perhaps fn_x = compilefinal "code"?
Using compileFinal does not automatically make the resulting function available on all machines. You'd still have to publicVariable it to make it globally usable. And even if compileFinal did do that, it would still be broadcasting all the code over the network, which is the whole issue.
The absolute best practice would be to use cfgFunctions functions. However, if you're truly opposed to doing that for some reason, the second best would be to define your functions locally using compileFinal on all clients (init.sqf, for example), instead of defining them on the server and then broadcasting them.
i get that the best practice would be to declare the functions in .ext and all. i was just wondering if that's a thing people do for just a couple lines of code. in my head, theres's maybe 3 parts that can be turn into functions and are small enough to, i think, not cause lag when broadcasted, which only happnes once when the script is run. 1.46kb of data is broadcasted.
(per player, in addition to everything else that gets broadcast at the start of a mission)
The thing is, it's very easy to simply define them locally and not need to broadcast anything, without even using CfgFunctions, as I mentioned towards the end of the previous message.
Does anyone know if this target UI still exists in game? I was thinking of making one myself, but wont bother if it's already made. https://youtu.be/efC6gAO6exA?t=4m26s @4:26
can someone help me with a script where when all subtasks are completed the main task completes. not sure what im doing but in tried this in a trigger killmortar setTaskState "SUCCEEDED" && killbox setTaskState "SUCCEEDED" && killAA setTaskState "SUCCEEDED"; as a test
Is this meant to be the trigger condition? Because you're using the task state setter, not getter
maybe like this ??:
_tasks = ["killmortar", "killbox", "killAA"]
{[_x, "SUCCEEDED"] call BIS_fnc_taskSetState} forEach _tasks.
I put it under a trigger condition. am i suppose to be using the task create module ?
The issue you have is that you're not checking the task state, you're setting it. That's no good for a condition - hopefully you can see why. Try this instead.
({taskState _x == "Succeeded"} count [killmortar, killbox, killAA]) == 3```
ahhh i missunderstood what he was trying to do.
Will do thank you.
How can I check that variable is code (for optional parameter)? Something like
_test_fnc = {
hint "Test";
};
_main_fnc = {
params ["_fnc"];
if (isNull _fnc) then { 0 call _fnc; }; // error - isNull cant be called with code
};
[_test_fnc] call _main_fnc;
i would imagine just use params with {} in the type
I didnt want to call fnc, but .... I will test it
isEqualType?
look good (so as typeName)
man no wonder why there aren't many ai revive scripts. ok.. i think i've pinned down the main issue to a []spawn that starts a countdown loop. that issue im seeing is that it runs for every unit i've ever created in the session. as in, i run the script once, all works ok, delete the unit, run script again, now i get two contdown loops, and so on. why could this be? the loop does have a working break under conditions, and it breaks everytime. its not about deleting the unit while the loop is running. and its not the EH firing multiple times cos i've tried without it. the amount of loops run is consistent with how many times the script is run.
You'd have to show the code.
this starts the loop
if (lifeState HostageUnit == "INCAPACITATED") then {[] spawn RPR_HostageCountDown};
and the loop goes like this:
{
RPR_time = 300;
RPR_counter = 30;
while {RPR_time > 0} do
{
if (lifeState HostageUnit != "INCAPACITATED") then {
["HQ: The hostage has been revived!!"] remoteExec ["systemChat", 0, true];
["Hsave", "SUCCEEDED"] call BIS_fnc_taskSetState; sleep 1; ["Hsave", west] call BIS_fnc_deleteTask;
break;
};
if (RPR_time == 1) then {
HostageUnit setDamage 1; ["HQ: The hostage has died!"] remoteExec ["systemChat", 0, true]; sleep 1;
["Hsave", "FAILED"] call BIS_fnc_taskSetState; sleep 1; ["Hsave", west] call BIS_fnc_deleteTask; removeAllActions HostageUnit;
[HostageUnit, "HandleDamage"] remoteExec ["removeAllEventHandlers", 0];
};
if (RPR_counter == 30) then {
[format ["HQ: The hostage is dying, you have %1 minutes %2 seconds to revive him", floor(RPR_time / 60), RPR_time % 60]]
remoteExec ["systemChat", 0, true]; RPR_counter = 0;
};
RPR_counter = RPR_counter + 1;
uiSleep 1;
RPR_time = RPR_time - 1;
};
};
publicVariable "RPR_HostageCountDown";```
You're using global variables everywhere. This doesn't seem sensible.
i will get to that once the thing runs as intented. unless you are saying that its the publicVariable that's causing the loop to do this werid stuff.
What's the trigger for the spawn?
if (lifeState HostageUnit == "INCAPACITATED") then {[] spawn RPR_HostageCountDown};
Yes I saw that, but that doesn't tell me anything about how and where it's called.
HostageUnit spawn {
while {alive HostageUnit} do {
waitUntil {sleep 2; damage HostageUnit >= 0.65};
[HostageUnit, true] remoteExec ["setUnconscious", HostageUnit];
[HostageUnit] remoteExec ["removeAllActions", 0];
[west, "Hsave", ["The Hostage has been Shot! Hurry!!", "SAVE HOSTAGE"],
HostageUnit, "ASSIGNED", -1, true, "heal"] call BIS_fnc_taskCreate;
sleep 3;
if (lifeState HostageUnit == "INCAPACITATED") then {[] spawn RPR_HostageCountDown;}
....
There's only one hostage unit or what?
yup
btw your indentation is terrible :P
Where's this code executed?
server side (pated on console for testing)
otherwise execVM by server.
same issues tho
What's after that code? You have a conditions of the hostage being alive and >= 0.65 damage, and nothing in there that resets that state.
the holdaction has a call there
call RPR_HuReviveAct
in there, setuncious false, some animation and re add an addaction. nothing fancy.
oh and setDamage 0
the holdaction is only added once if the loop is spawns several times.
ok, further testing. added a hint under the waituntil {damage hostag.. blah blah}; and it displays several times as well. now im even more confused since the holdaction is only added once, when in other tests it added many.
think i got it. it didn't like the fact that the unit was once server owned then player owned. so i changed it to _this inside the health and life state check, then the call goes out _this as param. and then again _unit = _this select 0 on the soon to be functions.
Im sorry but someone needs to call an exorcist for this abomination
Unsure if this is scripting but anybody knows why this is the case. It was working before it’s for my dedicated it was working a couple days ago
Error looks pretty clear? You have an object in the mission with class "livefirearea" that doesn't exist in your modset.
Thanks but it’s weird bc the live fire thing is already in dagger island
At least the prop wise of what I placed
Might be when I deleted it
Unsure if it was more a editor related issue
Does it work fine locally?
It worked fine for me originally
But when it was loaded in the dedicated as a MP mission it just like bugged tf out
It might’ve been a prop I added but wouldn’t make sense because all of it is the the modest
Modset*
Load it locally (editor or whatever) and then run configSourceModList (configFile >> "CfgVehicles" >> "livefirearea");
That'll tell you what it's from.
Okay sick man appreciate it I’ll try that rn
Where would I run the cmd? @granite sky
In the debug console.
In this case, yes.
I said a bad word mb
I’m dumb
I’ll check it out now loading it up
@granite sky
you have a stray backquote at the end of the line.
I guess it's not loading correctly on the server.
How would that happen
At this point should I delete the prop if it’s still in and that might fix it
Nah, if it got past that it'd probably fail to load the mission anyway.
You're well outside scripting anyway here.
I'm rewriting some old (and in all honesty, kinda bad) code for an air movement system.
Previously, I just checked if a movement key was pressed: if it is, increase speed in that direction (as well as some other math).
The one thing that bothered me about it though is that it suffered from the same issue/feature that a lot of other movement system in games do, where moving diagonally increased your overall speed since it was being increased in two directions.
I could keep this and try and cap the velocity in a given direction if other keys are being pressed, but that seems like it would get sloppy fast.
https://sqfbin.com/jodidofavugusibucazi
Make your conditions change _direction and then velocity calculations
Or like this
private _vector = [0,0,0];
if(inputAction "MoveForward" == 1) then {_vector = _vector vectorAdd [0,1,0]};
if(inputAction "MoveBack" == 1) then {_vector = _vector vectorAdd [0,-1,0]};
if(inputAction "TurnLeft" == 1) then {_vector = _vector vectorAdd [-1,0,0]};
if(inputAction "TurnRight" == 1) then {_vector = _vector vectorAdd [1,0,0]};
private _speed = _jetSpeed * BASE_SPEED * diag_deltaTime;
private _velocity = velocityModelSpace _vehicle vectorAdd (vectorNormalized _vector vectorMultiply _speed);
_vehicle setVelocityModelSpace _velocity;
Probably could also multiply by inputAction amount in case its an analog input
Not sure how exactly these analong inputs work though
what values you'd get there if any at all
Hooked up the controller, looks like you need "HeliCyclicForward", "HeliCyclicBack", "HeliCyclicLeft", "HeliCyclicRight" for heli\jet controls
Interestingly these return 3 for keys, 1 for gamepad stick and up to huge numbers for fast mouse movements 🤔
Something like this might work
private _vector = [
(inputAction "TurnRight" max inputAction "HeliCyclicRight") - (inputAction "TurnLeft" max inputAction "HeliCyclicLeft")
,(inputAction "MoveForward" max inputAction "HeliCyclicForward") - (inputAction "MoveBack" max inputAction "HeliCyclicBack")
,0
];
if(vectorMagnitude _vector > 1) then {_vector = vectorNormalized _vector};
This will account for both WASD and analog input
Its way too sensitive for mouse though, but I guess its fine
Quick question how to get array of all objects that are off the map ? So basicly i need to get all objects like vehicles, players, and static objects that are outside the map border in array ?
private _all = 8 allObjects 1;
private _out = _all - (_all inAreaArray [[worldSize / 2 ,worldSize / 2, 0], worldSize / 2, worldSize / 2, 0, true]);
Thank you very much.
Made me think that an argument to return objects NOT in area could be useful
For all inArea* commands
Yea notInArea command could actually be usefull.
Having it as inverse flag inside existing commands could be better
If you want i could make like a feature request on FT ?
Sure
Just a question what would be resnable for flag how would you put it something like this ?:
//Get all objects off the map:
private _allObj = 8 allObjects 1;
private _out = _allObj - (_allObj inAreaArray [[worldSize / 2 ,worldSize / 2, 0], worldSize / 2, worldSize / 2, 0, true]);
//Instead we could do
private _allObj = 8 allObjects 1;
private _out = _allObj inAreaArray [[worldSize / 2 ,worldSize / 2, 0], worldSize / 2, worldSize / 2, 0, true,(true/false)//inArea, notInArea]);
//or like this:
private _allObj = 8 allObjects 1;
private _out = _allObj !inAreaArray [[worldSize / 2 ,worldSize / 2, 0], worldSize / 2, worldSize / 2, 0, true);
```?
third one is invalid
moving more and more towards JS compatability: https://github.com/NouberNou/carma2/issues/12#issuecomment-158736836
need to work on performance
but its not bad as it is
i love the way you abuse locations lol
Hey Sa-Matra, do you make any mods?
Monodevelop is a pile of shit
escp Unity version that is like 3000 year old and made of shit
But there is really any reason to use it now since we got VS2015 for free + unity intergation
i'm gonna make the switch soon, it's pretty painful not having autocomplete in particular
No, I'm mainly scripting, configs and models aren't my thing
Well, more like I'm not good at them
Have you done any projects besides koth?
I did Wasteland in both OA and A3
hey for someone who's brand new to scripting triggers, how would I have a convoy start moving once an enemy unit/player passes into my trigger area? I know it's something like if inarea connected to the first move waypoint but I couldn't find anything good on youtube/forums
Your first problem is you are trying to do a convoy. Convoys in arma almost never work as intended. Second, look up some youtube videos on triggered waypoints. 'RimmyDownUnder - how to make a mission' youtube video has a good example of this. For your convoy, set the group formation to be collumn and set the speed to medium or slow. Make sure all drivers in all vehicles of the convoy are in the same group. Add vehicles to the group one at a time, and in the same order as their position in the convoy. 1st vic is leader, 2nd vic is added, 3rd vic added.....
For the trigger, you will probably want either Blufor detected or Player detected.
another thing i was thinking of (I've run into the convoy issue before) was just have individual vehicles and connect them all to the trigger
okay but do I need to place anything in the init script for the vehicles so that they wait for the trigger or is that just automatic
Check the video i recommended.
...im guessing the second one?
No scripting. iirc, its something like you put a hold waypoint then a move waypoint, the hold waypoint never completes, and the trigger is synced to the hold waypoiny. The effect (third option) for the trigger is skip waypoint.
The first video
But watch the video. See what he does, then trial and error.
thanks my guy 👍
Ya know most people learn this the hard way after their first failed convoy mission, right? 😁
well I made a couple convoys that failed miserably and so I just started placing each vehicle individually and stacking the waypoints on top of each other, it worked a lot better. Now I'm trying to slowly step into figuring out triggers for my little missions 🙂
whispering: they dont make it better
eh
Goodluck
I can jumpscare my friends with tanks without actually spawning them and controlling them though XD
Thats fair
The waypoint thing you are wanting to learn is useful for creating prespawned reinforcements. Which as rimmy will explain is a better way to handle ot than spawning them as zeus
yeah my entire purpose for learning triggers and scripting is so I can have as much as possible already in the mission ready to go instead of me running around trying to do everything
I didn't even see setVelocityModelSpace on the wiki when I first made this project, that would've been nice to know.
Still getting that issue where holding two movement makes you speed up faster, but I haven't re-implemented any kind of speed limiter (yet) so it could also just be that.
Hm, trying to think of a good way to actually limit the speed, since a single min or max statement doesn't really work since they could be positive or negative.
Use the absolute value and then check if the original one was negative?
// ...
_velocity = velocityModelSpace ace_player vectorAdd (vectorNormalized _vectorSpeed vectorMultiply _speed);
systemChat format ["velocity: %1", _velocity];
_velocity =
[
_velocity#0 min (_someValue),
_velocity#1 min (_someValue),
_velocity#2
];
ace_player setVelocityModelSpace _velocity;
take vectorMagnitude _velocity and vectorNormalized _velocity. Cap the magnitude however you like, and then multiply by the unit vector.
What do you mean by the unit vector?
Been a while since I've worked with them
_velocity = velocityModelSpace ace_player vectorAdd (vectorNormalized _vectorSpeed vectorMultiply _speed);
_magnitude = vectorMagnitude _velocity;
_magnitude = _magnitude min (_someValue);
_normalized = vectorNormalized _velocity;
vectorNormalized _velocity is the unit vector (length 1) in the direction of the velocity.
Gotcha
So multiply what exactly?
If you mean _magnitude * _normalized, wouldn't that just be _magnitude if the unit vector is just 1?
If you mean _vector * _normalized, then I don't see how capping the magnitude does anything
_normalized is a vector, not a number.
Oh gotcha
So something like this?
_velocity = velocityModelSpace ace_player vectorAdd (vectorNormalized _vectorSpeed vectorMultiply _speed);
_magnitude = vectorMagnitude _velocity;
_magnitude = _magnitude min (_someValue);
_normalized = vectorNormalized _velocity;
_normalized = _normalized vectorMultiply _magnitude;
systemChat format ["velocity: %1", _normalized];
ace_player setVelocityModelSpace _normalized;
slightly iffy variable name re-use, but yes.
Yeah I realized that, just changed it to _newVelocity, unless there was something more fitting
Seems to be working perfect, thanks for the help 👍
hi does anyone have a script to spawn in a missle and make it shoot at a specific target? thanks
Q: what are the types (i.e. classes) for terrain objects, for instance:
_y = player;
_types = ['road', 'main road', 'track', 'trail'];
_radius = 2500;
_objects = nearestTerrainObjects [_y, _types, _radius];
_classes = _objects apply { typeof _x };
[count _objects, _classes arrayintersect _classes]; // [1944,[""]]
for nearestTerrainObjects?
no I mean like the literal class (i.e. config) names? if any? i.e. typeof
if there aren't any that's fine
If typeOf returns "", it is what it is
or its model or whatever... fair enough, sure.
there is something like modelInfo or so
if typeOf returns "" it means the object wasn't created from a config (it's just a model with no special feature). like super simple objects
sure no worries I know how to work with it
getModelInfo can work after all no?
yes
I don't need to drill into the model, per se, just workaround whether there was a class.
that said, appreciate the insights, regardless, thank you.
so I have a #include in a file: #include "..\..\..\macros\testMacros.hpp"
In it is a single macro: #define TEST(world) "hello WORLD"
I have a file from mission root: components\testComponent\testCategory\fn_testFunction.sqf
in this file is: systemChat TEST(wOrLd);
Expected file is after preprocess: systemChat "hello wOrLd";
Actual file: systemChat TEST(wOrLd);
Any ideas as to why?
Here is the test world for this issue.
Probably easier if you used getMissionPath instead of relative includes
Actually, nevermind, that doesn't work
Yeah, would be nice though
@vapid scarab use single quotes
😑 no way
also, don't personalize the macro arg, just name it ARG_1 for instance
Why this?
just makes it way easier to read, especially when stacking macros. for instance, CBA uses var1,var2,etc arg_1,arg_2, etc
using # for quotes is also used
from CBA:
#define QUOTE(var1) #var1
What all do you want me using single qoutes for? I swapped the double qoutes in the macro to single qoutes and nothing changed
from your uploaded file:
#define TEST(ARG_1) 'hello ARG_1'
#include "..\..\..\macros\testMacro.hpp"
systemChat TEST(wOrLd);
Returns: hello wOrLd
If you use " you get:
hello ARG_1
If you're using an ide like vs code, you can make it so that files save "On focus change", so if you go to a different file, alt-tab somewhere else, etc. it'll save your work
Is there a way to delete a display? I dont want to delete ctrl's. I want to delete the actual display
depends which one
hmm I've found closeDisplay... I think that will work? Its a display created with UionTexture
Ok that did not work 
I guess its more designed for closing an active desploy and not deleting it entirely
I think just overwriting the texture will atleast stop rendering it, which is what I needed. That will work.
scripting is so addicting 😄
Until you hit some Arma bullshit and you have to spend a week to make a reliable crutch
am i the only one that plays alot with scripts than playing the actual game?
You're did something wrong then, my code (both examples) produced normalized vector
Yeah it was the lack of a speed limiter
Send help
I can say 90 percent of playtime is editing scripting and configuring, rest is playing SP 😄
Hell, maybe 96 to 97
I'm through half of that and my head already hurts
Yeah, most of it is having Arma running so I can get back to scripting as soon as I can. I didn't use launcher for long time, if I did and left it running too the number probably would've been even larger.
_westGroup = [markerPos "m1", WEST, 2] call BIS_fnc_spawnGroup;
[_westGroup, "SIT2"] call BIS_fnc_ambientAnim;
//Not working
ambientAnim takes an object not a group
What polpox said and to make it work you would do something like this:
private _grp = [getPosATL player, west, 5] call BIS_fnc_spawnGroup;
{
[_x, "SIT2"] call BIS_fnc_ambientAnim;
}foreach units _grp;
im not very skilled at creating scripts but that works like a charm, thnx both for the assistance
can someone explain the purpose and use case for CBA_fnc_createNamespace? The function it self just create a object on the map, whats the benefit of doing that and not just say using a hashmap?
Is there any way to set which seat owns a pylon by script?
Before hashmaps, creating dummy objects (Location, Logic, etc.) and using setVariable/getVariable on them was a preferred way to have a new variable namespace
Ah okay, is there any preference to use the CBA function over hashmap now or is it just down to preference
Guys, I'm learning how to create SQF scripts and I'm having difficulty with the logic of my script. Basically it should generate roadblocks at the map markers, at first I used the player's distance to the marker and thus generate and delete roadblocks but I was having the same problems. Now a trigger is created (I thought it would solve) at the marker position and if someone activates the trigger, the main logic of creating the road block happens and then the trigger for that marker is deleted. The main problem is that more than one roadblock is being created on the dedicated server, for example: if there are 3 players online and someone activates the trigger, 3 roadblocks and 3 groups of soldiers are generated instead of one. Does anyone have any suggestions to correct this error in my logic 😔 ?
code is here >> https://github.com/kaiotcp1/ARMA3-SCRIPTS/blob/main/rb/rbbuild.sqf
I don't think there is a reason to use the old way.
Perhaps the only upside is that you can broadcast setVariable on that entity but it all comes down to how you design things
Trigger statements are local for each client (dedi is a client too, just not a player). Wrap your code in if(isServer) so statement only creates the roadblock on the server
Okay cool, I am not sure if I need that broadcast just yet, but will keep in mind. thank you
Oh wait you're using triggerActivated check instead of running your script from trigger statement. How do you start your rbbuild.sqf then?
You probably also start instance of your script on each client, thus the multiple creation of the roadblock
Only start your script on the server or if you need it for something else, only do creation on server
Yeah, init.sqf execute on each client when their game loads into the mission, so you have same script running on each machine in the network
With your explanation I see that I'm doing it completely wrong ;-;
(you don't need nul = stuff for execVM its a remnant of a past editor's init field bug where it needed to end in assignment)
Its find, just wrap your code on screenshot with
if(isServer) then {
...
};
Thank you in advance, today when I have time I will test this then
Imagine the game as being a singleplayer, each client executes init.sqf, then each client executes your script, then each script creates their own copy of your roadblock (which then gets syncronized and sent over the network)
Always keep locality and context of your scripts in mind
Thanks for the explanation, I have a lot of questions about these scopes between server and location...
That afaik is the only reason.
Networking syncing hashmap is not very efficient because you can only send the whole hashmap, even if only one entry changed.
Whereas entity with setVariable can send only that one specific variable you're setting.
Heya all, does someone know how to remove all current ACE3 Actions via Script from an Object? 🙂
Does anyone know if this command have local or global effect?
setDynamicSimulationDistance
Highly assume global effect
https://community.bistudio.com/wiki/setDynamicSimulationDistance
I would definitely assume it is a server-only, global effect command (but still may be wrong ^^)
You can obtain all the actions from here:
_allActions = cursorTarget getVariable ["ace_interact_menu_actions",[]];
_allSelfActions = cursorTarget getVariable ["ace_interact_menu_selfActions", []];
You can remove a action using this:
[cursorTarget,0,["ACE_TapShoulderRight","VulcanPinch"]] call ace_interact_menu_fnc_removeActionFromObject;
You can just do a loop removing all the action:
_allActions = _target getVariable ["ace_interact_menu_actions",[]];
{
[_target, 0, _x] call ace_interact_menu_fnc_removeActionFromObject;
} forEach _allActions;
_allSelfActions = _target getVariable ["ace_interact_menu_selfActions",[]];
{
[_target, 1, _x] call ace_interact_menu_fnc_removeActionFromObject;
} forEach _allSelfActions;
However; doing this will make the game and ace unplayable and i would strongly recommend that you do not under any circumstance do it.
Guessing this as well
works perfectly, thanks ❤️
Is there a way to specify that a parameter should be an array of a given type?
Didn't seem to be a way on the wiki and trying in-game didn't seem to work but I wanted to double check
yes, see params
Yeah I have the wiki page pulled up, but the examples it has only seems to specify three datatypes being accepted, not an array of them
// Example 6
[1, "ok", [1, 2, 3]] call {
if (!params [
["_var1", 0, [0]],
["_var2", "", [""]],
["_var3", [0,0,0], [[], objNull, 0], [2,3]] // Can accept array of array, array of object, or array of int
]) exitWith {};
hint "ok";
};
// Passes validation
I basically want to do:
[["1","1","1"], 5] params
[
["_velocity", [0,0,0], [[0]], 3],
["_speed", 0, [0]]
];
_velocity; // should be default value, since parameter is not array of Number
I am not sure what you need, do you need to ensure a param is an array, or that a param is an array of said types?
for the latter, see isEqualTypeParams
Ooo alright yeah that helps a lot
Never came up when I searched for params, appreciate it 👍
nice
question, how do I check if a variable exists? I mean I have:
_uv80 setVariable ["marki_var_interior_red",_mf_interior_red,true];
I have a code that spawns an object "_mf_interior_red" and attaches it to the "_uv80". I want to write a check to see if "_mf_interior_red" (or "marki_var_interior_red", not sure which one I should use for this) exists, so I wouldnt spawn 2 of them when execiting it twice. But I do not know how to check if one exists. This variable is tied to the vehicle _uv80
If its an entity you can try:
isNull(_uv80 getVariable ["marki_var_interior_red", objNull])
if variable is nil (wasn't set) or if it was set with some entity but deleted, this will be true
Thanks I will try
this is interesting, which version should we prefer for precise drawn bounding boxes? have a btr named object out there, just for example.
_x = btr;
_geometry = 2;
_bb = _geometry boundingboxreal _x;
// [[-2.10255,-5.00469,-2.98067],[2.10255,5.00469,2.98067],8.01536]
versus, this one seems far more precise, although I have not tried the draw aspects, bit more involved...
_x = btr;
_lod = 'geometry';
_bb = boundingboxreal [_x, _lod];
// [[-1.49762,-4.33178,-1.50323],[1.17009,3.27059,0.957344],3.96751]
what's the difference and which one should I generally use?
I'd say whatever fits your needs. If you feel like you can afford more spacing or "room for error", go with the first syntax.
Also a little modification on **BIS_fnc_drawBoundingBox **'s code and you can visualize the differences...
Asking again, is there any way to switch who has control over weapon pylons by script? I'd like to grant someone firing authority at key moments.
Use the turret parameter for setPylonLoadout
Quick question how to set velocity 180* in oposite direction. Basicly, If vehicle is going dir 90 at 100km. How to set it so it goes dir 270 at 100 km ?
multiply vector by -1
Like this ?
private _velocity = velocity _veh;
private _dir = getDir _veh;
_veh setDir (360 - _dir);
private _negVel = _velocity vectorMultiply -1;
_veh setVelocity _negVel;
yyyup
although I would do the same for vectorDir/vectorUp
setDir sets a "flat" 2D direction
Thank you very much.
Can someone help me figure out why my sqf works in the editor but not on the dedicated server? https://sqfbin.com/ewojihovahaxayugufol
It's being executed from initServer.sqf with [] execVM "VS_Boat.sqf";
ACE action menu functions are local, not global, meaning they only take effect on the machine where they are executed. So the script is working (probably) but the actions are only being added on the server, since you're running it from initServer.sqf, which is only executed on the server.
Oh dang, I would not have guessed that. Thank you, I'll try running from init.sqf then
hey guys, moving forward with my project. moving thigns around, changing repited execVM's for calls to compiled scripts. as suggested, i've also moved functions that i had publicVariable'd (for testing purposes) to functions. now, my question is for things that have loops and sleeps, i can't just "call AcompiledScript". i have to [] spawn those (i did try call and all hell broke lose). right? so, should i just "[] spawn AcompiledScript".. or "[] spawn {call AcompiledScript}"- did some reading but still unclear.
always talking about scripts whith waituntils and sleeps.
[] spawn AcompiledScript
The latter will work too but it's an unnecessary extra layer.
"function names" are just a variable with code assigned to it.
I have heard that it's slightly better to use 0 rather than [] for argumentless spawn because making an empty array is a very little bit slower
thanks!
also wanted you to know my indentations are now "normal". had em weird like that exactly for the purpose of copy/paste them out into a functions script. used #include in init.sqf . compiled my tasks scripts since they are run many times. so again, thanks for the advices.
anyone know of any reasons why agents might be ignoring moveto commands?
I have a _agent moveTo getPos player to test and I have 2 of 10 agents who are actually moving
for Agents, use setDestination
Is it possible to remotexec more than 1 function by using addAction?
Why not call remoteExec twice?
Or call a function that calls two or more functions?
messing around with altis life framework, having trouble calling that function inside my own function at the moment
if the above was possible... would make my life easier
You can do such in regular scripts. So in remoteExec