#arma3_scripting
1 messages ยท Page 617 of 1
thanks to both of you guys, leopard i really like your mods, hyped for the super ai
don't worry ill find it myself no problem!
just click on the link I just posted
didn't saw that thanks!
0,0.5,0,1 - noice!
@winter rose Why not simply use the eyedrop tool in photoshop or something?! ๐
I wouldn't risk that with Arma :p
arma scares me
Why not: not using markers, and directly selectRandom vehicles?
@winter roseI have no idea how it will work.
But, I think I'll find easier way by using respawn module. How hide respawn module icon on map?
@little raptor https://prnt.sc/udunka goood jooooobbbbbbbbbb
had to tweak position and size a bit, other than that its perfect
thanks a lot!
Im trying to use ctrlRemoveEventHandler but I cant figure out how to get the ID portion of these syntax control ctrlRemoveEventHandler [handler name,id]
Any advice?
You save the ID yourself
Id is an integer returned by ctrlAddEventHandler that you have to save yourself
//Adds the EH
_zone = findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",
{
_this select 0 drawEllipse [
[13472, 12003], 20, 20, 0, [1, 1, 1, 1], "#(rgb,8,8,3)color(255,0,0,0.4)"
];
}];
//Removes the EH
findDisplay 12 displayCtrl 51 ctrlRemoveEventHandler ["Draw", _zone];
So _zone would be the id?
Yes
leopard i just realized the vanilla uav info panel has a much better resolution compared to the live feed module :/
is it possible to resize that instead?
_xzone = 20;
_yzone = 20;
//Adds the EH
_zone = findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw",
{
_this select 0 drawEllipse [
[13472, 12003], _xzone, _yzone, 0, [1, 1, 1, 1], "#(rgb,8,8,3)color(255,0,0,0.4)"
];
}];```
Im getting an error that says "Type Any, expected Number"
I think it is caused by me setting the x and y to variables but Im not sure how to fix this
Yes, an EH runs in it's "own" scope, so he doesn't know about variables defined outside of it. One possible solution for that is storing them in global variables
That worked. Thanks!
@ripe sapphire I don't know. I don't think so
Is there a way to make it so popup targets always stay up?
you can try this allowDamage false in the init of the popup target
still gets knocked down
even with simulation disabled it happens
this animate ["terc", 0];
this addEventHandler ["HitPart",
{_target spawn
{
params ["_target"];
Sleep 3;
hint "Pop-Up";
_target animate ["terc", 0];
};
}];
tried this, but it doesn't seem to work
I don't get a hint and target doesnt pop back up
prob because _target doesn't have a definition within the spawn scope.
okay, yeah I put it in brackets before the spawn to properly pass it as an argument, but I get undefined variable within the spawn itself now
Replace _target _this and use waitUntil to check if terc isn't 0
[] array . _target is passed directly as the only argument
private _popupTarget = cursorObject;
_popupTarget animate ["terc", 0];
_popupTarget addEventHandler ["HitPart", {
[_popupTarget] spawn {
params ["_popupTarget"];
uiSleep 3;
hint "Pop-Up";
_popupTarget animate ["terc", 0];
};
}];
``` @radiant needle see if this works at all
A trigger activates whenever a player is detected within it. How do I find out which player activates it?
@copper needle https://community.bistudio.com/wiki/Magic_Variables#thisList
does thisList return the player that activates it or a list of all players that trigger it?
I recommended creating a function that is spawned/called when the trigger is activated
defines an array of objects that have been detected by the trigger (same as what is returned by the list command)
Alright Ill give it a try. Thanks!
So I'm having this issue with a PIP UAV screen, all of these screens are grainy as shit except one http://prntscr.com/udyptr
aa1 setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
aa2 setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
aa3 setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
aa4 setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
aa5 setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
aa6 setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
displayMain setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
uavCam1 = "camera" camCreate [0,0,0];
uavCam1 cameraEffect ["Internal", "Back", "uavrtt"];
uavCam1 attachTo [uavRecon1, [0,0,0], "laserstart"];
"uavrtt" setPiPEffect [3];
uavCam1 camSetFov 0.03;
addMissionEventHandler ["Draw3D", {
_dir =
(uavRecon1 selectionPosition "laserstart")
vectorFromTo
(uavRecon1 selectionPosition "commanderview");
uavCam1 setVectorDirAndUp [
_dir,
_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
];
}];
could it have to do something with my config?
I have PiP set to ultra
@warm hedge So this is me trying to use the waitUntil
this animate ["terc", 0];
this addEventHandler ["HitPart",
{[_target] spawn
{
params ["_target"];
waitUntil {_target animationPhase "terc" > 0};
hint "Pop-Up";
_target animate ["terc", 0, true];
};
}];
^ is in the init of the target
However I'm getting this error
error undefined behavior waitUntil returned nil
I said replace _target _this
oh yeah I made a whoops
this animate ["terc", 0];
this addEventHandler ["HitPart",
{
(_this select 0) params ["_target"];
[_target] spawn
{
params ["_target"];
waitUntil {_target animationPhase "terc" > 0};
hint "Pop-Up";
_target animate ["terc", 0, true];
};
}];
this works
I forgot
(_this select 0) params ["_target"];
before the 'spawn'
makes sense, was trying to pass an arg to the spawn that wasn't defined
In the EDEN editor you can place down a trigger that is visible for example: https://gyazo.com/c63f8883d919923dc7f9e2ca7e84eec3 Is it possible to make that blue box visible to the player?
Afaik not with the trigger object itself
You'd have to use something else to denote that area
Unless I'm wrong
no, triggers are invisible.
Although you could place a marker so it will be visible on the map
and I believe there are some VR objects to create a "virtual wall" which you could place at the borders
I have a marker on the map right now but I would prefer to also make it visible to the player
I made a ticket about visible trigger, and developers claims the suggestion. Let's see if this happens or not
Anyone got any idea for my question?
Are there any objects that I can the size of?
mhmm next problem is trying to get what zone the player shot
apparently the zone targets, the selection hit is always just "target"
You can do that but requires a lot of script that wouldn't fit into Discord
I want to make a script that creates an array with a list of players within a circular area on the map. Any advice?
Ok this is weird, when I switch my PiP setting to disabled, the screens lose the grainy stripes effect
nvm, its because the feed cuts out
could draw3d be the reason for this?
@copper needle inArea or thislist?
Anybody familiar with ACE know if it has a scripting command to holster the players current weapon?
Is there no way to have && with waitUntil?
waitUntil { (check1 && check2) };
The "last" entry in waitUntil must be a bool.
So stuff like is also possible:
_a = 1;
waitUntil
{
_check = false;
_a = _a + 1;
if(_a >= 10)then{_test = true;};
_check //<-- no trailing ;
};
trying to figure out how to tell if player is facing more than 90ยฐ from a certain compass direction
getDir?
Basically a waitUntil the player faces more than 90ยฐ away (either left hand or right hand) from a set heading
I think getRelDir is what I'm looking for
_baseDir = _pos1 getRelDir _obj;
_pos = _baseDir + 90
_neg = _baseDir - 90
+you need to check if the baseDir is above 90ยฐ
Since the Dir only goes from 0-360ยฐ -> _neg could result in negative values. So check for that too.
Can I get all that in a waitUntil though?
sure, see the example i posted above
As long as the "last value" in the waitUntil check is a bool, it works
I'm trying to make a simple addaction with an addWeapon inside of it
how can I call only the player who activates the addaction so only he recieves the weapon?
I believe addAction gives you params too
oh so Player would work in SP
Sure.
sorry meant MP
Also
thanks
this is surprisingly hard to calculate
most of the parameters are optional
I guess I can do abs(course-heading) up to 180 degrees difference
so abs(course-heading) % 180
that wouldn't work though. If my course was 30 and my heading 345, simple subtraction would give me an error of 315ยฐ. 315%180 would be 135
I think I just need to do
abs(Course-Heading)
360-(abs(Course-Heading))
and compare which one is smaller
or just simply ignore abs
I don't think it'd work if you didn't do the absolute
deduct curDir, check if it's negative, add 360 to it, done.
I think you'd need to do mod if you did it that way
Try around ๐
yeah looks like you still need the abs
If you course is 5, and heading is 20, that'd be negative so you add 360.
So I got this working
[] spawn {
_trueBermDir = (bermDir + 180) % 360;
While {true} do {
Sleep 0.25;
_dirRH = abs(_trueBermDir - (getDir player));
_dirLH = 360-abs(_trueBermDir - (getDir player));
Hint "Good";
If ((_dirRH > 90) && (_dirLH > 90) && (isNil (currentWeapon Player))) exitWith {Hint "STOP!"};
};
};
however for some reason it seems to ignore the last isNil
it'll exit regardless of if I have a weapon or not
isNil checks for a string
isNil can check for both a string and code
if you want to check if a weapon is empty:
currentWeapon Player == ""
So I'm having this issue with a PIP UAV screen, all of these screens are grainy as shit except one http://prntscr.com/udyptr
Anyone got any ideas for my question earlier?
Put a plain white (or grayish) texture on those screens, see if it's a problem with the screens
Think I did, textures display just fine on them
I'll do it again just for screenshot
@tough abyss Actually, put an actual image on it to see the distortions too. You can try a flag:
(configfile >> "CfgFactionClasses" >> "CIV_IDAP_F" >> "flag") call BIS_fnc_GetCfgData
will try that
http://prntscr.com/ue2cpo @little raptor
works perfectly fine
http://prntscr.com/ue2gna @little raptor comparison
It looks like some sort of effect (or bug?!)
The displays do not have any other textures right?
getObjectTextures
Nope, emptied in the editor
I'll try that too
how could I display the getObjectTextures?
afaik hint only works with strings not arrays
hint str ...
ah ok
aspect ratio is .8 because I was fucking around with that
seeing if it does anything
I might just try this on another map and see if the bug repeats
I was acually gonna ask about that! cuz you were using 1
no difference, i tired between 0.7 and 1.3
im just going to try this on another map, since im doing it on a modded one
see if that makes a difference
ok
nope, altis is also fucky
@tough abyss Why are you using a color correction for the pip?
Did you try without?
color correction, the
setPiPEffect
?
yes
yep, I just put it in there to set it back to normal effects to see if it made a difference
normal is [0] tho
put it there again just to be sure
http://prntscr.com/ue2nf3 this is the obj textures for the working display
nothing extra there
maybe that's why?
I'm not sure how that would make a difference seeing as they have their texture fields cleared in the editor anyways
I could try running this without any mods
I don't think so. How about you tried:
{
_x setObjectTexture [_forEachIndex, ""];
} forEach getObjectTextures otherDisplay;
Before using your code? (It probably hides them but you can try it if you want)
otherDisplay was your aaN monitors
what does that do exactly?
ah ok so in otherDisplay i put the variable name of the monitor i want to clear?
right, i'll try this without mods first and then test that out
no mods, same result
let me try that
Are there no other monitors in the game you can use? Or even a laptop?
That's the screen I need as its big enough for a briefing
the other one that works only shows the top half of the camera
so its not good enough for a UAV locked camera
@tough abyss Didn't you say this was the reason?
Ok this is weird, when I switch my PiP setting to disabled, the screens lose the grainy stripes effect
nvm, its because the feed cuts out
could draw3d be the reason for this?
as in?
The PiP setting
everything but disabled has that effect for some reason
disabled just locks the last frame
and doesn't continue hte feed
Try a different monitor (or object). Maybe the monitor is buggy
I don't mean with PIP disabled tho. Try normally
I've tested out every other screen I could find, everything has the effect BUT the one that I found that doesn't
also, i get this error: http://prntscr.com/ue2zei
Maybe its a scaling bug. Because that one doesn't seem to be scaled
My bad:
{
otherDisplay setObjectTexture [_forEachIndex, ""];
} forEach getObjectTextures otherDisplay;
Told you it will hide them!
Ask here: #arma3_feedback_tracker
Problem is...
I've seen videos online with people using that screen with no problems like myself
Are you on dev build?
No. Its stable.
I asked because they changed something about the shadows recently. Thought it might be related
ahh
hmm I could try testing that, setting my shadows to min 50 and getting away from the screens
If you want, you can send me the mission and I'll test on my dev build
Maybe its fixed already
Or just the monitors
sent the script already, the screens are Land_TripodScreen_01_large_F
ok
I just use execvm to execute the file itself
It doesn't matter
ye ye just mentionign it just in case
Day or night doesn't matter right?
Have you tried other screens?
^^read above, all of them BUT Land_BriefingRoomScreen_01_F display the effect
I can't use that screen because it weirdly only displays the top half of the camera itself
I don't think so
Could you by any chance test it out with the stable build?
Try this code:
aa1 setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
uavCam1 = "camera" camCreate [0,0,0];
uavCam1 cameraEffect ["Internal", "Back", "uavrtt"];
uavCam1 attachTo [uavRecon1, [0,0,0], "laserstart"];
"uavrtt" setPiPEffect [0];
uavCam1 camSetFov 0.03;
addMissionEventHandler ["Draw3D", {
_dir =
(getPosASL uavRecon1)
vectorFromTo
(getPosASL player);
uavCam1 setVectorDirAndUp [
_dir,
_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
];
}];
Put the uav directly above the player
Also, why do you copy-paste your code?! Use "smarter" methods!
{
_x setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"]
} forEach [aa1, aa2, ...];
Im only in the process of learning sqf, I usually do those things but I don't want to overcomplicate things for myself ๐
Same result...
Ok. I recommend trying the dev branch, see if it was an issue that's been fixed. It's like a 2~3 GB download
You can switch to dev branch by right clicking on the game in Steam, going to properties and then going to the Betas tab
I'll just try that later, if it works on another machine I'm satisfied honestly
even if it doesn't its only point is just to look nice lol
Thank you so much for your help man, you were very helpful
sorry for the headache ๐
No problem!๐
Here to annoy again, is there a command/function/thing to move a unit into a specific position from a certain object before executing an animation?
yes ๐
how do
google is being a bad boy again
maybe my queries are too specific
guess I was right
Ok so.. my issue is that setpos takes set values, while I want the player to move directly infront of an object no matter its orientation/pos before doing an animation
ty ๐
Is there a way to get NPCs to just stand still and look around with binoculars from time to time?
Maybe with selectWeapon, and disabling some AI features @vague geode
Ok, I'll try that.
//protocol.bikb in mission root
Depends on what did you do though didn't you copy & pasted into an sqf?
Follow the comment instead
Make protocol.bikb and paste it
Not entire of course. The part of bikb thing
hello guys, how can we add JIP players to the zeus editable objects list like in the official zues mission ?
I de-pbo'd the official zues scenario but dont find any addCuratorEditableObjects code at all (either in .sqm, .sqf, or description.ext files)
hideOnUse does only hide the action menu IIRC. Use removeAction instead
here's how it looks like in game https://prnt.sc/ue9bu1
no player unit is synced to the game masters, yet in game every player including JIP are added to zeus editable objects?
Could it be that its handled by the game master MP game mode module? though i cant find any information about it (https://community.bistudio.com/wiki/BIS_fnc_moduleMPTypeGameMaster)
ok so in theory the script will wait until the group's waypoint is finished.
_wp setWaypointCompletionRadius 50;
_wp setWaypointStatements ["true", "deleteWaypoint [group this, currentWaypoint (group this)]"];
waitUntil {sleep 5; (count waypoints _PatrolTeam) = 0};
Is this correct?
Im having an issue where Im drawing an ellipse within an ellipse but I need the order of the layers switched on the map. Anyone able to help?
I need the order of the layers switched on the map
What do you mean?
I need to switch the bottom and top layer. So the ellipse currently on top needs to be below
I don't think there's a command to change Z coordinates. How about to recreate the marker?
I just decided to make them both similar colors so 1 doesnt tint the other. Sorted
Can markers be moved to different editor layers in the left panel and if so, does that help with the issue?
Does anyone here have experience with the "onEachFrame" BIS_fnc_addStackedEventHandler?
I am plannign to use drawIcon3D to have some icons for the player. Is it better for performace to split each different drawIcon3D to its own eventhandler or to have multiple drawIcon3D's in a single "onEachFrame" ?
I would say multiple in one @wet shadow
you can move markers to different layers for organisation, but this won't change anything z-index wise @hallow mortar
does BIS_fnc_moduleAnimals do anything or its deprecated? if it is, any examples on how it works would be great ...
I'm trying to create a large seagulls "flock" via animals module via script and its the only command I've found
it might do something, if the wiki doesn't say anything try reading the function itself @bright stirrup
wiki is missing info yeah
https://community.bistudio.com/wiki/BIS_fnc_moduleAnimals
the Animals module still exists and still works, so I would say it does something
I'm trying to make a script that waits until the number of players in a trigger is equal to 1 but it isnt working. waitUntil { (count(list _trigger)) isEqualTo 1 };
Any ideas?
did you name your trigger _trigger in Eden? If so, remove the underscore, it is a local variable
@copper needle โ
what are the trigger's settings?
probably not the case, but make sure the script is scheduled
I think my main issue is that(count(list _trigger)) isEqualTo 1does not return true
isEqualTo / == return a boolean
try```sqf
waitUntil {
private _list = list _trigger;
systemChat str _list;
count _list == 1;
};
@copper needle โ
That still doesnt work which leads me to believe the issue was that I was using list too quickly. Under list on the wiki it says Calling list immediately after creating a trigger via createTrigger (and setting up activation, area, statements, timeout, etc..), will return <null> instead of an array. It seems the trigger needs about 1 second to initialise, after which it will behave as expected: returning an array of all the objects inside the trigger (the ones matching the criteria), or an empty array.
this has been fixed not in stable yet probably
is it pointless to make a basic hit counter with HD EH and instead use damaged EH?
or
is caching the time/diag_tickTime (with some rounding) (per selection/hitpoint?) to determine if its still the same hit/penetration or a new hit/projectile?
I'm trying to set up randomization for units, now this works for all AI units, server and locally, they get randomized gear, but it does not work for players
class ALiVE_orbatCreator
{
init="if (local (_this select 0)) then {_onSpawn = {_this = _this select 0;sleep 0.2; _backpack = gettext(configfile >> 'cfgvehicles' >> (typeof _this) >> 'backpack'); waituntil {sleep 0.2; backpack _this == _backpack}; if !(_this getVariable ['ALiVE_OverrideLoadout',false]) then {_loadout = getArray(configFile >> 'CfgVehicles' >> (typeOf _this) >> 'ALiVE_orbatCreator_loadout'); _this setunitloadout _loadout;[_this] call CFP_main_fnc_randomizeUnit;reload _this};};_this spawn _onSpawn;(_this select 0) addMPEventHandler ['MPRespawn', _onSpawn];};";
};
It works on:
AI: Singleplayer, locally hosted multiplayer, dedicated server
Player: Singleplayer, locally hosted mp
The problem arises on a dedicated server, it does not want to randomize the loadout
Any help would be appreciated
The problem seems to be that this
[_this] call CFP_main_fnc_randomizeUnit;
doesn't seem to run on individual players on a dedicated server
Context: I am trying to make a script that draws two ellipses, one within the other. It should be able to detect when a player leaves the inner circle, but is still in the outer circle which would then cause the player to take damage every few seconds. This damage would stop whenever they reenter the inner zone. I also want to add players to an array when they are inside marker areas (1 array for each marker) and removing them from it when they leave.
Question: What would be the best way to detect if the player is outside the inner circle but inside the outer circle then causes damage to specifically that player?
The problem seems to be that this
[_this] call CFP_main_fnc_randomizeUnit;doesn't seem to run on individual players on a dedicated server
@tough abyss
Now I don't work with alive, but if this is true for you, try remote exec'ing this?
I did execute
this call CFP_main_fnc_randomizeUnit;
Is there a way I can put this in the actual config of the unit, so it executes on players after they load in?
I'm assuming player call CFP_main_fnc_randomizeUnit;
It works when I do it that way, but I want it done automatically when someone loads in, so it doesn't have to be done via init field each mission
Does anyone know how to get the pos of your map and also force set a the location of your map pos?
If you get what i mean
Like if i open my map and move it around, i want it's location and then to copy that information and be able to force a map location, I didn't find much information on the internet
Question: What would be the best way to detect if the player is outside the inner circle but inside the outer circle then causes damage to specifically that player?
@copper needle
use thedistancecommand to check when the player is within [radius] of the outer circle('s centre position) but not within [radius] of the inner circle
if it is a round trigger, otherwise there is inArea
yeah that would probably work better actually
same structure though
@tawdry harness https://community.bistudio.com/wiki/BIS_fnc_zoomLock and https://community.bistudio.com/wiki/BIS_fnc_zoomOnArea are probably good places to start looking
@tough abyss you should use remoteExec to apply that call, e.g. sqf [[_this],CFP_main_fnc_randomizeUnit] remoteExec ["call",_this]
using initPlayerLocal.sqf may be more JIP/locality safe but I'm not familiar with how Alive systems work
Thanks @winter rose and @hallow mortar Iโve been trying to work with inAreaArray unsuccessful so Iโll give those two a go
Alright awesome, thanks @hallow mortar
Thanks man! I'll be testing it later on to see if it all works, I imagine I'll have to add a delay with sleep in order for it to override after ALiVE adds their loadout 0.2 seconds after
Also I'm trying to randomize weapons with units, the CFP script unfortunately uses removeAllWeapons, that removes ACE medical, flashlights, literally everything
They use:
removeAllWeapons _unit;
I know there is removeWeapon but then I need to specify which weapon, that creates a problem since I want my own script to be reusable for many roles
I would want something that can remove the
Primary Weapon + Magazines
Launcher + Magazines
Handgun + Magazines
these types of things, but as stated before removeAllWeapons deletes things I don't want it to
Is there a version of this command, in which I don't have to specify a classname
Basically I'd prefer to use
removeHandgun _unit;
And for it to remove the handgun and its magazines
Also, is there a way to find the zoom at which a map is at?
Best I can find is https://community.bistudio.com/wiki/BIS_fnc_isInZoom, but using that would be...very non-optimal.
^ and if there are any wiki wizards reading, that should probably be added to Function Group: Map
pshhht
@tough abyss _unit removeWeapon (primaryWeapon _unit) is a start. You can also detect what magazines are loaded into the weapon and remove matching classes using primaryWeaponMagazine and removeMagazines, although this won't account for similar-but-not mag types like tracer mags, different colours etc. There is probably a way to find what magazine classes a weapon can accept in its magwell, which would allow you to remove all compatible types not just the loaded type, but I can't find what that way is.
@hallow mortar added
Alright, seems like I will be seeing what I can come up with, thanks again for the help!
// Either use removeWeaponGlobal or removeWeapon depending on what you are doing.
private _itemsArray = ["arifle_MX_ACO_pointer_F", "arifle_MX_ACO_pointer_F", "arifle_MX_ACO_pointer_F"];
{
private _currentItem = _x;
// Check if we need to remove
if (player hasWeapon _currentItem) then { // Checks if a unit has the given weapon in hands or on back/in holster. Weapons inside unit containers such as vest and backpack are not counted.
player removeWeapon _currentItem;
};
} forEach _itemsArray; // Loop for each weapon defined in _itemsArray
@tough abyss Here's an example I made for you ๐
And for some reason I thought that making randomization of weapons and apparel of units would be pretty easy ๐
It is easier (less complex but a little more tedious) if you are willing to completely blank-slate the unit and add everything back in your script
I thought about rather than having the weapons, grenades and etc in the unit
I just have what I want in there, and then add those via randomization, sure is a lot easier
I just have to make sure it applies to players on dedicated servers as well otherwise, well no one will have weapons ๐
private _arr = [];
private _cases = {
case 1: {_arr pushBack "inside 1"; "a"};
_arr pushBack "past case 1";
case 2: {_arr pushBack "inside 2"; "b"};
_arr pushBack "past case 2";
case 3: {_arr pushBack "inside 3"; "c"};
_arr pushBack "past case 3";
default {_arr pushBack "inside default"; "default"};
_arr pushBack "past default";
};
private _res = switch 2 do {
[] call {
[] call _cases;
_arr pushBack "past cases inner"
};
_arr pushBack "past cases call outter";
};
_arr pushBack _res;
systemChat str _arr```
could someone check what the output of this is?
need the exact output
@queen cargo
["past case 1", "past cases inner", "past cases call outter", "inside 2", "b"]
crap
how on earth is arma doing it then !?
https://github.com/SQFvm/runtime/issues/110
private _outarr = [];
private _testarray = [0, 1, 2, 3, 4 ,5, 6];
switch (3) do
{
{
case _x: { _outarr pushBack _forEachIndex };
} foreach _testarray
};
systemChat str _outarr```
i guess ... this outputs a fancy and neat `[3]` ... correct?
sets a flag of what the result is
after first matching case. makes a exitWith out of the scope
then at end of switch scope, execute code that was matched previously, or that was registered as default
nope
in that case, ["past case 1","inside 2","past cases inner","past cases call outter",3] is the output
@queen cargo it returns an empty array []
wut
private _testarray = [1, 2, 3, 4 ,5, 6];
private _a = 3;
switch (_a) do
{
{
case _x: { hint str (_testarray select (_forEachIndex + 1)) };
} foreach _testarray
};``` what is this doing?
it returns an empty array []
yes because _forEachIndex is nil
[]
case _x: { hint str [(_testarray select (_forEachIndex + 1))] };
-> [any]
the bug i am trying to fix was raised by you :O
so nothing to fix here then i guess?
https://discordapp.com/channels/365800217871908864/365800498965643264/714440518217629776
not sure what that was talking about
seems like it was in context to some other conversation
Anybody know how to detect a hit on a VR wall? I've tried using Hit, HitPart & HandleDamage eventhandlers but they aren't working.
Would count(allPlayers inArea "triggerName") return the number of players in an area or am I thinking about this wrong?
yes and no;
inArea accepts
- trigger <OBJECT> - result of
createTrigger - marker <STRING> - name of marker
- location <LOCATION> - Pos3D <ARRAY>, Pos2D <ARRAY> or object
- or an array with some parameters [center, a, b, angle, isRetangle, c]
also, inArea takes one object/position, not an array
so
allPlayers count { _x inArea myTrigger }; // or "myMarker"
``` @copper needle
no wait, code count allPlayers, it's the other way around
Iโll give that a go
Is that the most efficient way to do it? I need to run it every few seconds on a server with around 100 people with about 40 in the zones
Seems like it could get intensive
do you want to know the number of players, or do you want to know if players are in the area?
then count is the way to go
is there an event-based technique for checking if a player is suppressed? as opposed to going over the distances of every bullet near the player on each frame?
Is it possible to have a unit, or vehicle inherit traits of another vehicle through an init?
Thing like turn radius, fuel consumption, traction, ect?
can you use && this way? if (a && b && c)?
if a b and c are booleans or b and c are code returning booleans
If a b and c are true then (something)
Also @winter rose the tip really helped. It goes```sqf
{ _x inArea myTrigger } count allPlayers;
it is inefficient this way use inAreaArray
also depending on what you need you can use list trigger to get detected units in trigger
@copper needle Why are you needing to count allPlayers?
@unique sundial count(allPlayers inAreaArray markerName); gives me "Error Generic error in expression". Any idea why?
@robust brook I need to count the number of players within the area of a marker
@copper needle are you needing to see how many players are in the trigger or names of everyone in the trigger
[] spawn {
private _playersInRadius = nearestObjects [(getPos testingTrigger), ["MAN"], 300]; // Pos of trigger, object type, radius of the pos
{
systemChat format ["triggerName: %1 | playerObject: %2 | playerName: %3 | playerUID: %4", testingTrigger, _x, (name _x), (getPlayerUID _x)];
uiSleep 0.1;
} forEach _playersInRadius;
hint format ["Array of players inside the radius: \n %1", _playersInRadius];
{
if ((_x in _playersInRadius) && (alive _x)) then { titleText ["You are inside the radius", "PLAIN"]; };
} forEach allPlayers;
};
``` @copper needle
did the example with an actual trigger instead of a marker but same concept, hope this helps you a little bit. ๐
It just an a example to show you ONE way to find players in the area
if ((vehicle player) inArea yourMarkerName) then { hint "You are in the marker radius!"; };
// OR
{
if ((vehicle _x) inArea yourMarkerName) then { hint "You are in the marker radius!"; };
} forEach allPlayers;
@copper needle Another way you can also try
if ((vehicle _x) inArea yourMarkerName) then { hint "You are in the marker radius!"; };
} forEach allPlayers;``` is what Im using right now
But since there will be so many players it will likely be more efficient to go with the one above
Yeah looping all those players isn't the best, calling/spawning a script once a player has entered the marker radius / trigger is your best bet performance wise.
allPlayers includes dead players so be careful with using that for counting (e.g. include an alive check)
The simple solution for counting the players, to me, seems to be placing a matching trigger, setting it to player activation, and using count thisList
Could add a alive check in the if, but also add a check in the forEach from "allPlayers" to {} forEach (allPlayers-[allDeadMen]);
Added
@hallow mortar But what Nikko said using thisList magic variable is very useful for calling a function on trigger activation
Tried and failed using that. I want to try a different route
I'm curious what went wrong with it since it's pretty simple
I needed the trigger to constantly shrink and did this changing the x and y of the trigger which would cause activation/deactivation issues. I might go back to it now that I have a better understanding of how they work
// On trigger activation
_triggerFNC = {
params ["_thisList"];
if !(player in _thisList) then {}; // Do something
};
// Do something in init on editor or spawn in a trigger and set the conditions there
[thisList] call _triggerFNC;
``` example of using thisList
@copper needle no idea
Is there a way to diable pilot ejection seat for player?
@quasi rover try locking the driver seat when speed > 0?
oh... I didn't. If I just lock the door, pilot can't get out before departure. (speed > 0) is good idea.
It's really scripted feature. Try to find them in functions viewer, may find something useful, maybe
maybe this:BIS_fnc_PlaneEjection ? but no idea how to handle.
IIRC so. I'll back to my PC in few so may tell you some. Maybe not
thx
Probably doing sqf _plane setVariable ["bis_ejected",true]will do? @quasi rover
that's for getting -if- someone ejected from the plane, right?
You see nothing
that's prevent pilot from ejecting the flight?
Probably
I mean ejecting seat.
when pilot eject, the ejecting seat is out from plane. I want to disable that thing.
Prevent ejection menu option
I would say to lock until the plane is stopped, but there might be something else
I want I can disable ejector seats or make ejection unsurvivable forcing a re-spawn.
setting the variable as Polpox says doesn't remove the option, but it prevents the action to be done
not yet. I'll give a try.
thx guys. ๐
Yeah...
player in this && {speed this > 1}```
This is the condition of the ejection
Shame the lock is not considered (was before Jets iirc)
Is there any way to only display drawIcon3D for a particular side/unit?
I've been looking around and can't see anything on it. Would it be a case of calling the draw3D on that particular client?
Correct
Thought that was the case. Makes the most amount of sense
anybody know of a way to fix planes bouncing as they're taxiing during unitplay?
weird
were they the same planes that were used and for recording and for playing?
yeah they're on a carrier so that's probably why
ah yep, perhaps
Afternoon all, is it possible to script a hunter killer system for a tank, ie commander is independent scanning for targets, spots a target hits a button/triggers action and the turret automatically turns and elevates to the target, I know u can with AI but want to try implement this with players in the gunner slot
โฆwhat would be the gunner's role then?
This is a real life system where you can have the commander and gunner scan for targets
And if the commander spots a target he can hit a button and the turret auto rotates and aims
To reduce the engagement time
Skip to 7:20
Explains it
dont think its possible to yank the control from player gunner
_tt = format ["[""%1"",'succeeded'] call BIS_fnc_taskSetState;", _tsk];
what does 2 double quotes "" ""mean?
The way to use " inside ", basically doing the same with '
Is it different with
_tt = format ["[%1,'succeeded'] call BIS_fnc_taskSetState;", _tsk];
``` ? @warm hedge
now you're missing the quotes, that's probably a syntax error
Anyone know off the top of their head if the EntityKilled mission event handler fires for remote units?
yes
How can I respawn players with a custom uniform texture?
Calling setObjectTextureGlobal in onPlayerKilled is not working with dedicated server
That's because 'onPlayerKilled' will only be called when people are killed... and when they respawn they'll get a new uniform ;)
Try 'onPlayerRespawn'
If I want a script to be applied to everyone on a dedicated server, aka clients and AI
I should switch all instances of 'local' to 'global'
If they're only on local, this means clients will be unaffected, correct?
Is it allowed to use sleep command in trigger activation field?
trigger setTriggerStatements [condition, activation, deactivation]
e.g. ```sqf
_trgcnd = format ["!(alive %1)",_obj];
_trgact = format ["deletevehicle %1; ['%2','succeeded'] call BIS_fnc_taskSetState; sleep 1; deleteVehicle thistrigger;", _obj, _tsk];
_trg1 setTriggerStatements[_trgcnd,_trgact, ""];
thx.
while do {} is also needed? @winter rose
e.g.
[] spawn {
while {true} do {
..trigger..
};
};
what do you want to do?
if this:
_trgact = format ["deletevehicle %1; ['%2','succeeded'] call BIS_fnc_taskSetState; sleep 1; deleteVehicle thistrigger;", _obj, _tsk];
No
What you're doing is wrong tho
You can't put the object there with format
An "object" is an object. What you do gives you the stringized version of the ingame object ID, which causes the game to throw an invalid expression error
Instead, use setVariable to register those variables in the trigger's namespace
And use getVariable to get them in your statement
player setObjectTextureGlobal [0,"mytex.paa"] is not working in onPlayerRespawn
On dedicated
@tough abyss
You mean it works otherwise?
You can try spawning the code and adding some sleep delay.
I need to globally draw an Ellipse on the map. How would I do this?
hello guys is the onPlayerKilled.sqf and onPlayerRespawn.sqf a scheduled environment? if not, is there a workaround to run the codes in them as scheduled?
@quasi rover no, spawn.
@ripe sapphire I would say yes scheduled
if at any point you want scheduled code from an unscheduled environment, use [] spawn { /* your code */ };
In any case, you can always check which environment is scheduled using:
canSuspend
@winter rose So there are such files?
onPlayerKilled.sqf
and onPlayerRespawn.sqf
ahh ok, such as in triggers you'd use []spawn yes?
I'd never seen them!
yeah, just realized i actually used sleep in my onPlayerKilled and it worked, so i guess it is scheduled
was unsure at first cause it wasnt listed here https://community.bistudio.com/wiki/Scheduler#Scheduled_Environment
@little raptor what would be a good way to do that? just add a sleep statement before the texture is applied?
Yeah.
[] spawn {
sleep 1;
player setObjectTextureGlobal [0,"mytex.paa"]
};
what will that do exactly to fix the issue?
I don't really understand the issue to begin with, so I can't think of a solution
Does the command setObjectTextureGlobal work in general?
yes
You're using onPlayerRespawn.sqf?
Yes
So there's no need for spawn either
params ["_player"];
//sleep 1;
_player setObjectTextureGlobal [0,"mytex.paa"];
what does params ["_player"] do vs just saying player?
I need to globally draw an Ellipse on the map. How would I do this?
Set the alpha to 0 at the beginning, then have a trigger that sets it to 1 when they get to the point where it should pop up
But it's safer to use my code
He said it doesn't work
no it works
works on my mission
The issue is it doesn't work on dedicated
It works in local
So the word player isn't the issue
try the sleep maybe like leopard suggested?
@tough abyss Just try this code with sleep:
params ["_player"];
sleep 1;
_player setObjectTextureGlobal [0,"mytex.paa"];
It probably will work.
how can i replace specifics word of my string ?
example : "abc cba abc" i want to replace all "abc" in my string
how can i do that ?
You'd have to select a number of chars in your string that is equal to the number of chars in the word you're searching for. If they match, pushBack the new replaced word, otherwise the original
but a function exist for that ?
Not sure
ok
It's not difficult to make one
@little raptor i have already a function to do that
_stringReplace = {
params["_str", "_find", "_replace"];
private _return = "";
private _len = count _find;
private _pos = _str find _find;
while {(_pos != -1) && (count _str > 0)} do {
_return = _return + (_str select [0, _pos]) + _replace;
_str = (_str select [_pos+_len]);
_pos = _str find _find;
};
_return + _str;
};
it's not made by me
So why do you ask?
If it did, it wouldn't be any different
ok
why ?
There are string replace fnc on the forums
His func is one of them
yes
@little raptor but to make a function how can i do ? because i need to check letters or word ?
non-case sensitive right?
does the string have a mix of uppercase and lowercase?
Or is it just one type of case?
@little raptor thx for your help but i will search how can i do that because it's very complex
it's lowercase and uppercase
and it's not a letters
it's a word
Then you should use the method I said.
You'd have to select a number of chars in your string that is equal to the number of chars in the word you're searching for. If they match, pushBack the new replaced word, otherwise the original
ok
I didn't test it
Hold on!
It was wrong!
There's no "find"
lol
corrected
@faint oasis I tested it and it works now
ok
@little raptor why you have deleted your function ? i want to see it
ok
_a = [];
_cnt = count _find;
for "_i" from 0 to count _str - 1 do {
_testStr = _str select [_i, _cnt];
if (_testStr == _find) then {
_a pushBack _replace;
_i = _i + _cnt - 1;
} else {
_a pushBack (_str select [_i,1])
}
};
_a joinString ""
ok thx @little raptor
@faint oasis Actually, there's even a faster method
_stringReplace = {
params["_str", "_find", "_replace"];
private _return = [];
private _len = count _find;
private _strL = toLower _str;
_find = toLower _find;
private _pos = _strL find _find;
while {(_pos != -1) && (count _str > 0)} do {
_return append [_str select [0, _pos], _replace];
_str = (_str select [_pos+_len]);
_strL = toLower _str;
_pos = _strL find _find;
};
_return pushBack _str;
_return joinString ""
};
yeah
but it's in toLower
but don't worry i have understand the code
so now i understand
yes
but my code is in "not case sensitive"
i will add an option to select the "lower" or "upper"
but thx
I know
I don't think you understand what's going on
You can try the code
It's 6X faster than the last one
yes i know
don't worry
but if you convert the word in "tolower" for find
yes
it will be more faster
Not because of that
ok
Because I use the find command
๐
np
How do I make this global on multiplayer? sqf {if (_x in playersOut && !(_x in playersIn)) then { _x setHitPointDamage ['hitBody', ((_x getHitPointDamage 'hitBody') + 0.1)];}; } forEach playersOut-[allDeadMen];
@copper needle
[[], {
{if (_x in playersOut && !(_x in playersIn)) then {
_x setHitPointDamage ['hitBody', ((_x getHitPointDamage 'hitBody') + 0.1)];};
} forEach playersOut-[allDeadMen];
}] remoteExec ["BIS_fnc_spawn", 0, true];
only if playersOut and playersIn are global and public variables
ive been trying to make a mission for peer to peer, and i got 2 questions, for the CBRN mod, do i need to use a dedicated server to be able to run scripts? and also, i keep getting an error although everything is in place, im just now dipping into codes, with help from my friend for finding the right scripts for the job. any help would be appreciated!
if you respond ,ping me so i can see the message!
...cant seem to post images. but lemme text it out..
Include file C:\Users(username)\documents\Arma 3- Other Profiles(username)\mpmissions\CBRN%202.chernarusredux\scripts\cbrn\funcs.hpp not found
I'm using a script where if a player is in the "playersOut" array but not in the "playersIn" array then they will be damaged. The script works fine on my screen and I see the player slowly get damaged and then eventually die, but on their screen they don't. They can even shoot while dead on my screen and I can see/hear the bullets.
Damage Script:
[[], { {if (_x in playersOut && !(_x in playersIn)) then { _x setHitPointDamage ['hitBody', ((_x getHitPointDamage 'hitBody') + 0.1)];};} forEach playersOut-[allDeadMen]; }] remoteExec ["BIS_fnc_spawn", 0, true];
How do I keep the damage consist on a server?Anyone able to help? Thank you in advance!
I'm not sure that snippet is doing what you want it to. It is making all players loop through all players (in playersOut) to set damage. setHitPointDamage apparently only works for local arguments so each player can only set their own damage, not anyone else's. Are you sure that is correct? Or are you looking for something more like this where it only sends the remoteexec to players who need their damage modified, and only sets the damage once.
[[],{
player setHitPointDamage ['hitBody',(player getHitPointDamage 'hitBody') + 0.1];
}] remoteExec ["call",playersOut - playersIn - allDeadMen - [objNull]];
Iโll give it a try, thanks!
also is there something for the opposite of arrayIntersect. So something that returns array of uncommon elements
_a - _b
ehh, thats not right
i think there would be a command for it but this the best i can think of right now
_c = (_a + _b) - (_a arrayIntersect _b);
not entirely right either ๐
The wiki says: "The subtraction will remove all elements of second array from the first array:
_myArray = [1, 2, 3, 1, 2, 3] - [1, 2]; // _myArray is [3, 3]"
so _c = _a - _b? I cant test right now
_c = (_a - _b) + (_b - _a); ?
_c = [];
{_c pushBackUnique _x} forEach ((_a - _b) + (_b - _a));
maybe ๐คทโโ๏ธ idk. it is possible somehow.
will give each one a go and see if any work lmao
Thanks for the help the both of you
How can I force the player to lower their weapon? Not put on back but sorta force lower it so they have to double control to raise it back up
Looked up on the wiki but couldn't find anything (I was looking over at Actions and stuff)
edit: Ah got it
@astral carbon can you post the code? im interested also
player action ["WeaponOnBack", player]
Guess "WeaponOnBack" just lowers it in his hand
does that work for both primary and secondary wep?
however it isn't working for some odd reason with people who are walking to a waypoint
Not sure, I just tried it for secondary
I got this one dude with a pistol walking to a waypoint and the only time it works is if I exec it from the console
Executing it via a file doesn't work for example
exec it from the waypoint before that?
Should I delay the waypoint by like a sec?
@robust hollow @ionic orchid Ended up just doing: ```sqf
outsiders = [];
{ if (_x in playersOut && !(_x in playersIn)) then {outsiders pushBackUnique _x;} } forEach playersOut;
[[],{player setHitPointDamage ['hitBody',(player getHitPointDamage 'hitBody') + 0.1];}] remoteExec ["call",outsiders];``` Avoided figuring out how to do it using subtraction. Thanks again!
im thinking you can set a variable, and while this variable is true, execute that script
you could probably just use outsiders = playersOut - playersIn;
in player's init:
lowwep = true
and in init.sqf:
while {lowwep} do {
[player action ["WeaponOnBack", player];
}
and then in player's waypoint's onAct:
lowwep = false
@ionic orchid Didn't work the first time but now it does. Not sure what happened lmao
this way game will check every 3ms if lowwep=true and if it is, force player to lower his weapon, once player reach his waypoint, it turns to lowwep=false and script stops
i think thats how it should work, im still very new tho so please cmiiw
@ripe sapphire Never use an indefinite while loop like that without sleep.
And what you say is absolutely wrong. It checks multiple times every frame until it burns out through the 3 ms period and doesn't let other scripts do their jobs either.
First of all, there is waitUntil that does this.
Second of all, if you still wanted to use while:
while {...} do {
...
sleep 0.001;
};
will pause the code until the next frame.
Third of all, for something so slow such as player movement, you must use even bigger sleeps. The player (infantry) moves at most at 6 m/s so the value of sleep should be rather large. I'd say anything between sleep 0.1 and sleep 1 is small enough.
thank you for the correction ๐
No problem! ๐
what will happen if we dont use sleep? for a while control structure
The while loop keeps checking in that frame
until the 3 ms period is up
So basically it's wasting performance
For conditions that change over time, you must always use sleep
Such as this case. Your condition doesn't need to be checked multiple times every frame. Because the player cannot move until the next frame. So you must suspend the code and wait for the condition to change.
There's no need for sleep in waitUntil. It automatically waits until the next frame
i see so we add the sleep as big as possible before any change is done to the condition?
Yeah. The sleep period should be as big as possible (minimum period where you expect the condition to change).
If it's a condition that is expected to change very often, use sleep 0.001. It means "until the next frame"
Any value smaller than that won't work
so that means, after it checks, it will wait until the 3ms period is done before restarting?
It will wait until the next frame
The 3ms period is the maximum time in each frame that is given to scheduler
But since FPS in Arma is typically low, your next check will be after 1/FPS seconds later
@60FPS : 1/60: 0.0167 seconds later
or 16.7 ms
3 ms is a safe period which is impossible to reach: 333 FPS
and with waituntil, is this the correct code?
waituntil {lowwep};
player action ["WeaponOnBack", player];
yeah, but you should remove the first [
ah right xD
so that means, a sleep 0.001 @60fps will wait for 0.016 seconds?
Yeah. It cannot wait shorter than your FPS
and if we do sleep 5 that means it doesnt check condition every frame?
No
It puts a timer on the current code
So the scheduler continues processing it after 5s
ok, so @60fps, thewhile loop without sleep, will use the entire 3ms to keep checking the condition, but with sleep 0.001 then it checks the condition every 0.016 seconds?
Exactly
The 3ms belongs to everyone! Without sleep, your script consumes it all! ๐
Thanks a lot leopard! you have been super helpful! ๐
No problem! ๐
leopard, so i tried using this code
while {lowwep} do {
[player action ["WeaponOnBack", player]];
sleep 1
}
and it doesnt work, however this one does, do you know the problem?
waituntil {lowwep};
player action ["WeaponOnBack", player];
while {lowwep} do {
[player action ["WeaponOnBack", player]];
sleep 1
}
also, the "WeaponOnBack" action seems to work BOTH raising and lowering the gun, so when looped what it does is alternate between the two, any ideas on how to force players to keep the gun down?
yes the idea is to force their guns down so they cant fire, so i guess must use while loop
you're still keeping the [
@little raptor omg xD
ok i tried this, still doesnt work
while {lowwep} do {
player action ["WeaponOnBack", player];
sleep 1;
}
Not sure the context though is the lowwep even declared?
put gun to safety here's from wiki Description: Soldier 'unitName' does nothing, 'target unit' moves his weapon from/to the safety position (gun held across chest pointing at the ground).
Ok
yes, what i did:
in player's init: lowwep = false
and then trigger radio alpha onACT: lowwep=true
And when the while executed? Of course if lowwep is false, won't work
@ripe sapphire
You should use the reverse condition
for waitUntil
waitUntil{!condition}
while is executed right at init, but shouldnt it keep checking ?
waitUntil {
if (animationState player select [13,3] != "low") then {player action ["WeaponOnBack", player];};
!lowwep
}
what do you mean?
Anyway, this does what you wanted
Keeps checking until lowwep is false
And keeps the weapon lowered
Oh yes, that actually is a smart way
i mean, the while loop is gonna keep checking if the condition is met right?
yes
so does the above code
Add a 1 second sleep to it tho
I checked it and it's still bugged
waituntil {lowwep};
player action ["WeaponOnBack", player];
while {lowwep} do {
player action ["WeaponOnBack", player];
sleep 1;
}
with this one, the while code is executed, however this one below has no effect?
while {lowwep} do {
player action ["WeaponOnBack", player];
sleep 1;
}
roger will try that one
If lowwep is false when the while is called, it won't do anything
@ripe sapphire
waitUntil {
if (animationState player select [13,3] != "low") then {player action ["WeaponOnBack", player];};
sleep 1;
!lowwep
}
@ripe sapphire The better way is to use animStateChanged event handler
Do not use loops when you can do something with eventhandlers
They're wayyyyyy better
player addEventHandler ["AnimChanged", {
params ["_player", "_anim"];
if (!lowwep) exitWith {_player removeEventHandler ["AnimChanged", _thisEventHandler]};
if (_anim select [13,3] != "low") then {_player action ["WeaponOnBack", _player];};
}];
If
lowwepisfalsewhen thewhileis called, it won't do anything
@warm hedge but after i activated the trigger with onAct:lowwep = true, it still doesnt fire?
This one does what your loop did. And it's both faster and better
nice!!! perfecto leopard ๐
If the while is already executed even if didn't anything, won't be executed again
wait, actually its making me stuck into a loop of gun transition lol
ohhh, this right?
If CONDITION is false from the beginning on, the statements within the block of the loop will never be executed.
so that means the loop should be triggered right as lowwep becomes true ?
Yes, if you still wanted to do with while
i see, leopard's solution is much better, just wanted to know why code didnt work, i see the reason why this code worked, was because script was suspended by waituntil until the lowwep=true, so when while loop is called, lowwep is already true ?
Yes
thank you !
btw leopard is there a way to like disable input from aim and fire button? i think that would be an easier solution to prevent bringing gun up?
@ripe sapphire
player addEventHandler ["AnimStateChanged", {
params ["_player", "_anim"];
if (!lowwep) exitWith {_player removeEventHandler ["AnimStateChanged", _thisEventHandler]};
if ((_anim splitString "_") findIf {_x select [13,3] == "low"} == -1) then {
_player action ["WeaponOnBack", _player]
}
}];
Fixed
niceee, however when aiming i can still fire 1-2 shots ?
Maybe make a condition if the anim hasdisableWeapons or some config is better?
The action simply doesn't work if it's not possible to lower the weapon
I noticed there's a bug. If you run and bring out the weapon, you'll get stuck in a loop! ๐
I think the loop method is still better
ahh yes i just reproduced, my legs wont stop ๐
found a fix tho, just hit ' to make ur char sit
and the anim resets
so that's taken care of, only thing left is that you can still fire 1-2 rounds if you click fast enough
I just realized why that bug occurs. It's an engine issue. It keeps sending the request so that the player can keep the gun up.
i see, well this should be good enough, thanks mate
hmmm, found another problem, player can still fire when prone
Found a safezone script, it utilizes allowdamage and fired EH to delete any projectile shot.
if (isNil "inSafezone") then {
inSafezone = false;
};
while {
true
}
do {
private["_safeZoneDamageEH", "_safeZoneFiredEH"];
waitUntil {
inSafeZone
};
player allowDamage false;
_safeZoneDamageEH = player addEventhandler["HandleDamage",{false}];
_safeZoneFiredEH = player addEventHandler ["Fired", {
deleteVehicle (_this select 6);
systemChat ("You can not fire your weapon in a safe zone.");
}];
waitUntil {
!inSafeZone
};
player allowDamage true;
player removeEventhandler["HandleDamage", _safeZoneDamageEH];
player removeEventHandler["Fired", _safeZoneFiredEH];
};
i guess i'll use this + leopard's script
You can also use:
player addEventHandler ["AnimStateChanged", {
params ["_player", "_anim"];
_anims = _anim splitString "_";
if (_anims findIf {_x select [13,3] == "low"} == -1) then {
_lastAnim = _anims#(count _anims - 1);
_anim = [_lastAnim select [0,9], "stp", "slow", _lastAnim select [16, 5], "non"] joinString "";
if (isClass (configFile >> "cfgMovesMaleSdr" >> "states" >> _anim)) then {
_player switchMove _anim;
_player playMoveNow _anim;
};
};
}];
It still loops, but you can unloop by pressing fire again
The player can't fire with this script (except for prone)
And with missiles
@ripe sapphire Hold on!
What are you doing?!
Don't use that script!
never mind
My bad!
o.0 its something i found on the net lol
damn got me in the first half not gonna lie lol

You can simply use triggers
What I don't get is why it is deleting some vehicle
And doesn't recreate it again!
That's a bug
Maybe?
it deletes the projectile?
this addEventHandler ["Fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
}];
xD
I can't read code if it's not properly indented! ๐
leopard that script works good but veery unnatural, my guy just yeeted himself into crouching form prone ๐
yeah
but it gets the job done, i will use it! ๐
well the goal is to make player not try to shoot, so making it look weird is not really a bad idea i guess
xD for sure
Do you want to use safezones?
I mean no firing zones
If so, I can do it with triggers
If it can happen in any place, then I'll just use eventhandlers
yeah i implemented your last code into trigger areas
so triggers it is
when player enters are, lowwep=true
ok
when outside, false, and its already coded in your script to delete EH when its false
so its working properly now curently
@ripe sapphire
MY_fnc_SafeZone =
{
params ["_trigger"];
_lastPlayers = list _trigger;
waitUntil {
_players = list _trigger;
{
_x enableReload false;
_player = _x;
_ammoArray = [];
_lastAmmo = _player getVariable ["MY_lastAmmo", [0,0,0]];
{
_ammo = _player ammo _x;
if (_ammo > 0) then {
_player setAmmo [_x, 0];
};
_ammoArray pushBack (_lastAmmo#_forEachIndex max _ammo);
} forEach [primaryWeapon _x, secondaryWeapon _x, handgunWeapon _x];
_player setVariable ["MY_lastAmmo", _ammoArray];
} forEach _players;
{
_x enableReload true;
_player = _x;
_lastAmmo = _player getVariable ["MY_lastAmmo", [0,0,0]];
{
_player setAmmo [_x, _lastAmmo#_forEachIndex];
} forEach [primaryWeapon _x, secondaryWeapon _x, handgunWeapon _x];
} forEach (_lastPlayers - _players);
_lastPlayers = _players;
!triggerActivated _trigger
}
};
_trigger setTriggerStatements ["this", "[thisTrigger] spawn MY_fnc_SafeZone", ""]
Not tested
Updated and fixed some issues
so in trigger onAct i run this?
this setTriggerStatements ["this", "[] spawn MY_fnc_SafeZone", ""]
or do i copy the whole thing
updated again btw
triggers dont have initbox?
in OnActivation field, place
[thisTrigger] spawn MY_fnc_SafeZone
```*edited
[thisTrigger] spawn MY_fnc_SafeZone
IF you define your function before.
https://discordapp.com/channels/105462288051380224/105462984087728128/753946743682629733 this code goes in onAct too then?
ok tested it nice, though it means people actually lose 30rnds of ammo
both this and the EH one works, but i think i prefer the EH one
strange, it doesnt for me?
so i put this code in the onACT of my trigger yes?
MY_fnc_SafeZone =
{
params ["_trigger"];
_lastPlayers = list _trigger;
waitUntil {
_players = list _trigger;
{
_x enableReload false;
_player = _x;
_ammoArray = [];
_lastAmmo = _player getVariable ["MY_lastAmmo", [0,0,0]];
{
_ammo = _player ammo _x;
if (_ammo > 0) then {
_player setAmmo [_x, 0];
};
_ammoArray pushBack (_lastAmmo#_forEachIndex max _ammo);
} forEach [primaryWeapon _x, secondaryWeapon _x, handgunWeapon _x];
_player setVariable ["MY_lastAmmo", _ammoArray];
} forEach _players;
{
_x enableReload true;
_player = _x;
_lastAmmo = _player getVariable ["MY_lastAmmo", [0,0,0]];
{
_player setAmmo [_x, _lastAmmo#_forEachIndex];
} forEach [primaryWeapon _x, secondaryWeapon _x, handgunWeapon _x];
} forEach (_lastPlayers - _players);
_lastPlayers = _players;
!triggerActivated _trigger
}
};
_trigger setTriggerStatements ["this", "[thisTrigger] spawn MY_fnc_SafeZone", ""];
[thisTrigger] spawn MY_fnc_SafeZone
It has a bug hold on
roger
leopard mate i found a very easy code to prevent shooting but still keep weapon xD
basically since the lower weapon anim is buggy af, we can use another "holster" anim which works perfect
trigger onAct:
hint "In Safe Zone";
player allowDamage false;
isSafe = true;
while {isSafe} do
{
derp = player action ["SwitchWeapon", player, player, 100];
sleep 1;
};
onDeact:
isSafe = false;
hint "Leaving Safe Zone";
player action ["SwitchWeapon", player, player, 0];
player allowDamage true;
MY_fnc_SafeZone =
{
params ["_trigger"];
_allUnits = [];
waitUntil {
_players = list _trigger;
{
_x enableReload false;
_player = _x;
_ammoArray = [];
_lastAmmo = _player getVariable ["MY_lastAmmo", [0,0,0]];
{
_ammo = _player ammo _x;
if (_ammo > 0) then {
_player setAmmo [_x, 0];
};
_ammoArray pushBack (_lastAmmo#_forEachIndex max _ammo);
} forEach [primaryWeapon _x, secondaryWeapon _x, handgunWeapon _x];
_player setVariable ["MY_lastAmmo", _ammoArray];
_allUnits pushBackUnique _x;
} forEach _players;
{
_x enableReload true;
_player = _x;
_lastAmmo = _player getVariable ["MY_lastAmmo", [0,0,0]];
{
if (_x != "") then {
_player setAmmo [_x, _lastAmmo#_forEachIndex];
};
} forEach [primaryWeapon _x, secondaryWeapon _x, handgunWeapon _x];
_player setVariable ["MY_lastAmmo", [0,0,0]];
_allUnits = _allUnits - [_x];
} forEach (_allUnits - _players);
!triggerActivated _trigger
};
};
trigger setTriggerStatements ["this", "[thisTrigger] spawn MY_fnc_SafeZone", ""]
Yeah that one is also possible
This one works too
roger testing now
poggers mate it works, though it looks like you must be careful not to reload inside the trigger, coz reloaded mags doesnt get returned
can you remove the grenades too?
If the units are not expected to change their gear inside the trigger, you can just save their whole loadout
grenades are mags
I can just remove all their magazines
only keep the weapons, uniforms, backpack, etc.
basically only their clothes will remain! :p
hello everyone! Do you guys have an idea how can i tell that certain vest have iteminfo inherited from iteminfo or vestitem?
i.e.
class BHD_TACV1DSS: Vest_Camo_Base
...
class ItemInfo: VestItem```
```cpp
class rhsusf_iotv_ocp_base: Vest_Camo_Base
{...
class ItemInfo: ItemInfo```
Well, i kinda prefer the EH and loop ones as they add the nice lower / holster weapon effect... but you have created some nice scripts here mate, you should post them in BI Forums, someone might be looking for it :p
Is there a way to stop the player from being able to hold the key with KeyDown and instead have them actually press it every time?
https://community.bistudio.com/wiki/inheritsFrom @calm bloom i guess
thank you @copper raven , hope it works for subclesses!
im doing a scenario where one man is escaping from a city and a team is trying to track him down, when the searching team is near the runner they hear a sound, is it possible?
Yes
teach me master
translated: Write me the code ๐
ok, but you should wear this schoolgirl uniform first
waitUntil { units group _team findIf { _x distance _runner < 20 } != -1 };
hint "ping!";
is that better than an eventhandler?
does such EH exist though?
waitUntil { units group _team findIf { _x distance _runner < 20 } };
inAreaArray maybi
!= 1 *
fixed
Roger roger
now the question is, do you understand what he wrote?
because I don't
oh weird I was sure there was an eventhandler for "detected"
was wrong
back to the shamecorner again!
I live there anyway
plus it would be a distance EH ๐
also true
Basically every โdistancesโ are based on meters
phew good to know
i have another idea, a marker on the map that appears every minute?
and โ

i don't know how to do it ๐
Absolutely! just wanted to know if it's possible
If you show 0 effort to try, you will have a hard time to find any help.
Can you que moves?
Yes, it's possible.
Que what?
moves/anims
you mean queue?
lol yes
Can you que moves?
@timid niche I think one of the commands does that, erm...
playMove
fantastic, ill search on the wiki now thx for the help!
playMove? idk atm
playMove

ha, it was ๐
If you do playMove one after the other it will be queued
Description:
When used on a person, smooth transition to given move will be done.
The difference between playMove and playMoveNow is that playMove adds another move to the move queue, while playMoveNow replaces the whole move queue with new move (see Example 2).
i found a better, easy way! a flare gets launched every now and then
For what?
I mean randomly? Without an event?
If so, find one of my scripts I wrote for exocet (where I thought him how to fire an rpg)
Here:
_pos = getPosASL player;
_rpg = createVehicle ["r_pg7_f", _pos];
_rpg setPosASL _pos;
_dir = _pos vectorFromTo (aimPos aheli vectorAdd (velocity aheli vectorMultiply (_pos distance aheli)/200) vectorAdd [random 1, random 1, random 1]);
_xx = _dir#0;
_yy = _dir#1;
_up = _dir vectorCrossProduct [-_yy, _xx, 0];
_rpg setVectorDirAndUp [_dir, _up];
_rpg setVelocity (_dir vectorMultiply 200);
Just create a flare "ammo" instead of rpg
And of course, it should fire up, not at something. So it's simpler
addction1 = [
stan1, // Object the action is attached to
"CASH TRANSPORT ", // Title of the action
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", // Idle icon shown on screen
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unloaddevice_ca.paa", // Progress icon shown on screen
"_this distance _target < 3", // Condition for the action to be shown
"_caller distance _target < 3", // Condition for the action to progress
{}, // Code executed when action starts
{}, // Code executed on every progress tick
{[] execVM "STAND1.sqf";
[stan1,addction1] call BIS_fnc_holdActionRemove;
}, // Code executed on completion
{}, // Code executed on interrupted
[], // Arguments passed to the scripts as _this select 3
1, // Action duration [s]
10, // Priority
false, // Remove on completion
false // Show in unconscious state
] remoteExec ["BIS_fnc_holdActionAdd", 0, stan1]; // MP compatible implementation
how comes hold addaction remove doesnt work?? i put it in code completion just to see if it will work .
I mean randomly? Without an event?
@little raptor i used triggers, thanks for the script tho i'll try it!
@harsh vine if you set the
// Remove on completion
part to true it will be removed automatically
or change the completion code to
params ["_target", "_caller", "_actionId", "_arguments"];
[] execVM "STAND1.sqf";
[_target,_actionId] call BIS_fnc_holdActionRemove;
addction1 = [
stan1, // Object the action is attached to
"CASH TRANSPORT ", // Title of the action
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_loaddevice_ca.paa", // Idle icon shown on screen
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_unloaddevice_ca.paa", // Progress icon shown on screen
"_this distance _target < 3", // Condition for the action to be shown
"_caller distance _target < 3", // Condition for the action to progress
{}, // Code executed when action starts
{}, // Code executed on every progress tick
{[] execVM "STAND1.sqf";}, // Code executed on completion
{}, // Code executed on interrupted
[], // Arguments passed to the scripts as _this select 3
1, // Action duration [s]
10, // Priority
true, // Remove on completion
false // Show in unconscious state
] remoteExec ["BIS_fnc_holdActionAdd", 0, stan1]; // MP compatible implementation
or what Grezvany13 said
i knw how to do that ... i was trying to see if if would work, and it still doesnt work while using the script.
Can you enable buttons while being in animation/playing move?
depend on animation and method of animating
Okay well what way allows you to then?
question:
Automatically fail the mission once all players are dead (for NONE, BIRD, GROUP and SIDE respawn types) or when all respawn tickets are exceeded (for INSTANT and BASE respawn types with Tickets template)
will this fire when tickets reach 0 even if there are players still alive? or will it only fire once all players are dead AND tickets reach 0
I believe the latter
@timid niche What do you mean by enable buttons? Buttons are not disabled. (?!)
If you mean like move around and stuff, no, you can't (at least not while the current move is in progress).
What's the correct lock command for locking the copilot seat of an unarmed helo? Is it a cargo seat or a turret?
I suppose it is locking a turret
It seems that is the case
Is there a way to reload a weapon instantaneously (without reloading action or waiting period)?
Remove the weapon, then readd it (don't forget the attachments!)
You'd have to remove one of the compatible mags from the unit's inventory as well
If you want a "cheat-like" reload, just use
unit setAmmo [weapon, 1e9]
setAmmo will refill the current magazine instantly
This method doesn't work on Launchers tho
The "remove weapon, then readd" method does
hey guys, i wanted to finish a mission once a cache is destroyed, i think i need to use these two scripts
if (!alive cache1) exitWith {};
"SideScore" call BIS_fnc_endMissionServer;
But i don't know how :/ (p.s. i wanted to get into scripting in arma, any guide?)
no
That's not how you do it
Add a "killed" event handler to the cache.
Once it's dead, end the mission
thank you
As for guides, there are several on the forums and Armaholic
thanks! i will check them out
will do!
i will read all of them, notepad++ is my jam
Do you know any programming?
let's see, first i'll read some scripting and if i don't understand im going to read some guides about programming
scripting mostly, programming logics are not needed at first
oki doki
im writing everything down so launch everything at me
*throws bugs at @obtuse quiver*
The two links I gave you are good starting points
a software bug or a literal bug?
thanks really helped!
and linked in "Introduction to Arma Scripting" is https://community.bistudio.com/wiki/Code_Best_Practices, which should prevent you from doing bad things you don't realise yet ๐
like, how they are already? ๐
(except for Functions)
sorry, how do you mean?
pin something in this Discord or make a wiki page?
well two of the three you mentioned are pinned, but you mean one message with them all, right?
np, I really didn't get what you meant ๐คฃ
Can I get a code check? Just want to make sure I have the right idea about updating a global variable then making it public to the server so it votes can be tallied later.
I made a quick video on arma scripting, is it a good place to post it ? ๐
i don't see why not. maybe the armadev subreddit might be better since many new mission makers frequent there first? @jagged mica
plus, that juicy karma
is it beginner or veteran
it's hard for me to judge tbf, but I think it's rather beginner-ish
id lean more towards reddit then, heck, even the normal arma subreddit. Go ahead and post it here first that way the vets can give feedback or request changes that way you have the most up to date info
Gotcha, thanks
I'll leave the link so that it's not like I just came in and departed without giving context
https://youtu.be/R6VWiBxTZfs
cheers
@fair drum why the need to make _voted a string, especially if it is to store "false" or "true" in it? ๐คจ
i think it was left over from the condition of the addAction... I was trying "voted == true" and I kept getting comparison errors
wait, _voted and voted ๐
and i got frustrated and just turned to to true period
what do you mean and? It should all be global so that I can change it within the inside scope
did I miss one?
I did...
params ["_target","_caller","_actionID","_arguments"];
_voted = _this select 3;
also, _this select 3โฆ
is _arguments
yeah I think that was when I was trying to keep it all local but had trouble updating _voted from within the addaction scope.
cause I wanted the second addAction to see the _voted from the first one
also, please indent >.<
what do you mean? Maybe its a view difference when I copy it over from VSC?
too big of spaces?
no, just your if isServer that is lacking one level
oh probably cause I added it after I realized i needed it lol

