#arma3_scripting
1 messages Β· Page 173 of 1
Is passible to forcing the player to look in the indicated direction VIA script ? (Camera)
forcing hmmm why would you have to force the player cant you just tell them to look there π
and is it important? π , but if so, the point is that I want to make a distant nuclear explosion and at that moment my player should look in that direction.
Yu can help me witch this ?
well i know one thing is theres a nuclear explosion im looking at it for sure
Like cod hehe
Aa ok, but i need script for this.
you could make them go into like a intro script and set the camera to look there
that will force them to look
Exactly im talking about this, but i dont know how force rotate cam for player. For ai i know how.
you dont need to roatate the the camera just make the canera look at that pos
Ok. Now im on phone discord, but i will try when i go to pc. Thx
I wesoΕych ΕwiΔ t π
did you want an Exsample of a cam script i use
No, no mate. I try myself . But thx
Anyone know what triggers this in server-side RPT?
2024/12/24, 16:04:38 Tried to AccessTargetList for non-local AI group while non-local targeting was disabled! Engine will now enable non-local targeting which will hurt clientside performance.
Never seen it before. Currently on latest profiling branch, so might be related?
It says what triggers it right there
Tried to access the target list for a non-local AI group.
If you run game with -debug you'll probably get a call stack for it
For example using knowsAbout or targets on a non-local group.
Yeah I feel stupid now, been dealing with Arma since 3 AM x_x. Thanks guys
Antistasi undercover code breaks that optimisation due to use of knowsAbout. Aiming to sort that out at some point.
fixed the map opening for only 1 player when chopper call
fixed the dubble call text
fixed added time limit to open the map if map not opened in 7 seconds script exits
thx Dart for your insite
Hell Yeah Arma 3 WooHoo
lol im a Happy Guy
so, let's refactor a bunch of crap then
im reviving part of my project of import ocap data back to arma to do an 3d player
its posible to open a .pbo from the AppData\Local\Arma 3\MPMissionsCache in the editor, or play the mission?
i guess i can run a script to remove all units, triggers and modules after it, so i can run the replay with the editor placed buildings
well @bold comet ... writing a proper book-like guide is a damned hard topic
a full time project for somebody
over the course of like 5 month
could produce something useful
or complete gibberish
make it peer reviewed to avoid the gibberish but that's all the more effort
i'm not saying it would be easy, i'm saying it would be useful
then again, we are where we are now
many different people tend to think different about different topics
eg.
loops or PFEs
you say that like it's a bad thing
some say no PFEs at all
some say no loops at all
and the rest is somewhere inbetween
you don't consider outsiders like me who like to read civil arguments on the topic
which is why i'd like a damn book
civil arguments
hahah
ye ... no
you can, just unpbo the pbo, and put the (unpbo-ed Folder) in your Mydocuments Arma 3 Missions, and play the mission in the editer.
btw thats 9 things i got right WooHoo lol
and counting π
with the help of others ofcorse
Hey there folks, just need a little help. I'm using 'say3D' with 'remoteExec', which is in a loop, done on trigger activation. I'd like to stop the sound on the triggers deactivation. Any ideas? I've seen say3D returns a value you can delete, but I cannot figure out if I can do it with remoteExec included
The idea is automate the process ( I can do this with python, but I prefer not so much file movements in a client pc)
Say3d returns a sound object. So technically, you could be able pass the object to remoteExec.
BUT...
Looking at that, the object type is #soundonvehicle, and afaik the particle and light source objects have that # at the start of their class, and they are local only objects. If that is the case for #soundonvehicle, then you cant use remoteExec to stop it, because you practically cant pass a local only object to remoteExec
Assuming #soundonvehicle is local only, a way around is to create a proxy object, invisible helipad is my go to, attach that proxy object to the object you want to play the sound on, then use say3d on the proxy object. Once you want to stop the sound, run [_proxyObject, 1, false] remoteExec ["setDamage", 0]. Killing the proxy object that the sound is attached to will stop the local #soundonvehicle from playing sound.
Thank you for responding! I've done a quick and dirty job that works, but with some undesirable results, I'll look into your suggestion tomorrow (It's late for me). Thank you!
I dont know how to get the position of a weapons accessory. player selectionPosition weapon something something idk...
It's pretty established practice to put variable declarations as close to thier first use.
grabs popcorn
It's more a pity the word private wasn't deprecated in favor of a more advanced syntax for local, e.g.
local _a, _b, _c = 123;
Hello everyone :D
Another question. In the case below, have I set it up properly so that _moduleInfo parameter wils accept any of the 4 formats of an array that are provided? (The main difference is that the first 2 items in the array can either be a string or an object).
params [
["_moduleInfo", [objNull, "", true, false, false, false, true, true], [
[objNull, objNull, true, true, true, true, true, true],
[objNull, "", true, true, true, true, true, true],
["", objNull, true, true, true, true, true, true],
["", "", true, true, true, true, true, true]
]],
["_unit", objNull, [objNull]],
["_mode", "REQUEST", [""]]
];
Do _moduleInfo params [...]
Ah, I was trying to to basically provide 2 possible data types for the first 2 elements of an array.
So I take it this wouldn't work.
I sometimes wonder if my programming degree is worth anything...
Am I supposed to understand you understood it or not
I understood it yes. I am just surprised and annoyed it didn't occure to me, that's all.
Thank you
SQF'ing is as gaming as cardgames. You may not realize something until you combine them accidentally play it
Fair enough 
(I implied pretty much I sometimes don't)
What happen in player dies? Do other players still respawn on his position or do I need to re-add function on respawn?
// initPlayerLocal.sqf
[ playerSide, player, name player ] call BIS_fnc_addRespawnPosition;
i think you should only add respawn positions in server code and they should stay
i could be wrong but thats how i have always used them
dead objects can't be spawned on.
does anyone know how i can make eden enhanceds hold action activate a trigger or a show/hide module. i can even make it a addaction if thats easier to do i just need a player be able to activate something and a thing appear
Try using a global variable.
how i do that?
Assign true to a global variable, and then use this value to activate a trigger.
wait i think i found a weird ass work around
ok yeah it works basically how it works is i have this set up with no special parameters this is set up so that the show/hide module will activate when i delete the trigger then i set the trigger a variable have a seperate deltevehicle the trigger then poof it works
how do you determine how many players there can be in server? i know there is setting in description.ext but doesnt it also depend on the host's limit and playable players from the editor?
what you mean determine how many there can be? setting slot limit is in the server config
playable slots are due to playable things
but actual slots on the server is server config. so like say 100 playable slots, but only 20 server slots
but how to get the number?
to get slots per side https://community.bistudio.com/wiki/playableSlotsNumber
or do you want the server limit?
whichever determines how many players can join
like the numbers you can see in server browser x / max
_map = findDisplay 46 ctrlCreate ["RscMapControl", -1];
_map ctrlMapSetPosition [0.87 * safezoneW + safezoneX, 0.09 * safezoneH + safezoneY, 0.09 * safezoneW, 0.12 * safezoneH];
_map ctrlMapAnimAdd [0, 0.01, getPosWorld player];
ctrlMapAnimCommit _map;
Is it possible to make the control circular?
What does PFE stand for? π
How would I randomly select a sound to play as long as a mission is loaded? π€
Play a sound, wait a bit, play another, so on and so on.
As if a radio was playing, basically x3
I can only think of weird way to do it xD
Per Frame Handler Event.
Array of sound names, while true selectRandom from the array and play it
a.k.a. the quickest way to kill your frame rate if you don't know what you're doing.
ah ok, so the while true wont overlap into another mission? (it's from the main menu so x3)
Scripts usually end when the current mission ends
Alright. And- using playSound3D?
But if it's a concern, you could use another condition for the while. If you know what the mission's called, you could check whether the current mission is that mission.
Well that depends on whether you want to play the sound in 3D π€·
maybe ui sleep for 10 seconds or so-
aaahhh
No, shitty loops would be a faster way to kill your frames. PFEHs are pretty straightforward if you actually plan to do stuff well.
or maybe 300 seconds-
aaaaand we start again π
How about neither? π
I mean... it should be pretty rare when you need to use something on every frame. isn't it?
Hi gusy quick question. How would i make a puzzle with ace interactions.
Basicly. I have 5 pillars on witch interactions need to be interacted certain way. like they need to interact with pillar 5 then 3 then 4 and so on.
If players didnt interact with correct interaction they would be punished and they need to start again ?
Let me rephrase that properly -
In making missions? Not really.
In making an addon or a framework that needs to do calculations or check for events all the time, yes, its quite useful.
[
{
["InitDummy",["RCHT_Primera_Isla",[4518.87,4419.6,1.86083],343.213,0.75,[13.6039,0],0,0,1110.02,0.3,0,1,0,1]] call bis_fnc_camera;
setviewdistance 700;
...
}
] call BIS_fnc_initWorldScene;
hmm- this ain't working for some reason-
it's loading the scene it seems, from the log file, but then it isn't moving the camera?
playersNumber / playableSlotsNumber
obviously, build those numbers and combine from every side
wait is it running the script
And if you've ever taken a course in coding etiquiette or done professional coding: Loops you cannot exit without killing the entire process is literally how you lose your job.
It seems initIntro nor init are being ran-?
might be a better question for scenario now- but idk if that'd be considered- posting in more channel or whatever-
soo- why might it not be running init scripts-?
That describes almost every application.. ever.
e.g. every Windows application is running a bunch of loops that have an iteration per event.
A loop that contains code that executes within an application; which is non-essential to application function that cannot be exited without application termination is shit coding.
initIntro.sqf is an event script, called by the game automatically
k and
I- think it was because I used a \ at the start of the scene directory string-??
well, the main menu only uses intro, not the rest of the senario
right so whats not working correct
it was the fact the senario's introInit wasn't running, and I guess it's b/c it was silently failing to load the mission-
oh i see so you have it fixed ?
we shall see! It loads, but black screen- might know the issue for it tho
buy the way i put my intro.sqf in my scripts folder and i execVM it from there
it is now
ok cool
but the camera is being funny
if it has a camera creation, sure x3
["InitDummy",["RCHT_Primera_Isla",[4518.87,4419.6,1.86083],343.213,0.75,[13.6039,0],0,0,1110.02,0.3,0,1,0,1]] call bis_fnc_camera;
my camera creation
wow all that holy
my intro is way simple
but that looks beond me there
is that just locations
it's the splendid camera params
oh ok i see
Is "non-essential" critical to the argument though?
yeah i dont think i can help you with that sorry
my intos are way easy to make and ajust
do yours have characters?
i just command the cam to move around
a player character
it that red triangle thing
wha
you can command that camera around to where ever you want
no no really i create a camera and then i command the cam to move
did you want to see my intro.sqf
E.G. running a unit spawner/location checker within a giant while true loop is inefficient because it clogs the engine and you cannot terminate it without stopping the mission.
Running it within a PFEH set to check maybe every 150 frames is a lot easier.
Anyhow, I don't have the effort to argue with you about it. I'm going back to finishing modelling.
and I'm thinking that might have messed up the music playing- so-
ok what ever you think
keep in mind, you can't change time acceleration in MP
this is just the main menu x3
oh wait, for the mission sound- DUH
missionName == "RCHT_Primera_Isla_Intro" but the name is actually RCHT_Primera_Isla_Intro1
it helps if the while loop actually is told to proceed xD
needs more murder
Can someone show me how to make a randomized shoot house, I can make a asset group, is there a script where I can make a spawn point and by a scroll wheel action on the ground randomly spawn one of the different shoot houses.
For example I have shoot house a, b, and c, is there a script where it can randomize them and spawn one of them in in one location.
What is the best way to do nearestObject on simple objects?
Just generate a random number from 0 to 2 and depending on the number it hits, spawn one shoot house or another.
https://community.bistudio.com/wiki/random
https://community.bistudio.com/wiki/round
You got this
Whaa? Clogs what in the engine?
The engine keeps a list of scripts that are suspended and can check if a script is ready to run again in a handful of assembler instructions.
A sleeping script has practically zero overhead.
A PFEH however has to execute a substantial amount of SQF every frame to figure out if it should run.
When your script is actually running the only difference is that a sleeping (scheduled) script is interruptable if it is taking up too much time and would otherwise cause frame-rate reductions.
Before any rumors are spread.
The "substantial amount"
is one addition and one less than.
I am looking for a revive mechanic where all players and ai teammates an only be incapacitated on not killed outright and the ai can revive each other and the players
As in:
activateAt = diag_frameNo;
["moo", "onEachFrame", {
if (diag_frameNo >= activateAt) then
{
activateAt = diag_frameNo + 150;
call my_thing;
};
}] call BIS_fnc_addStackedEventHandler;
?
Something like that.
CBA and ACE simply wouldn't work in sheduled environment
I tried it with AGM
And it was shit.
What are you trying to do?
In general I don't recommend using nearestObject at all
What makes it not reccomended?
Why do you even need it?
Do you mean in this specific use or at all?
In that case, if you wanted to get the nearest non-unit object, what would you use instead then?
Oh I completely missed the distinction
I thought that was only about nearestObjects
Yeah but you know what you're doing.
You can kill performance just as easily with a while loop as you can with a pfh O_o
How? The engine suspends you if you exceed your budget.
Every "thread" has a time limit and every frame has a total time limit for scheduled execution.
while {true} do {allMissionObjects ""};
that... that applies for both pfhs and loops...
0 spawn {while {true} do {allMissionObjects ""}};
The engine can't suspend a PFH.
Except it can
It it could there would be zero difference between a PFH and a loop except in the priority.
(If the engine runs out of total time for scripts, your script won't get any time that frame)
commy2: that loop has far less impact in scheduled vs unscheduled though. π
I was incorrect, it seems
But in a real enviroment you can still kill performance by using a while true
In scheduled if "allMissionObjects" takes too long in a scheduled script it gets run once per frame. In an unscheduled script the game locks up until you hit the loop limiter. π
Especially if you consider a bunch of other addons using while true
while (true) with a sleep in there somewhere is absolutely fine.
because the scheduled enviroment still has to complete before the frame ends
The ideal way to do things is sleep in a scheduled environment (lowest overhead for waiting) and then trigger unscheduled code for anything that needs to be atomic.
No, the scheduled environment can suspend at any point in SQF, except while actually inside of an engine function like "allMissionObjects".
If you do:
1 + 2 + 3
It can suspend between when it added "1 + 2" and when it then added "3".
It's pretty established practice to put variable declarations as close to thier first use.
@tribal crane thats BS
@gleaming rivet nop, loops are waqy better in frame performance due to how they work
The script doesn't have to ever finish, it will run until it sleeps or hits the time limit.
You are not reading what I am typing
If you save your game, the execution state gets serialized into the save game file (which is, by the way, how you can see that SQF can be suspended anywhere).
Also I'm ignoring the difference between:
while (true) do { sleep 1; ...
and
while (scriptNotSignalledToExit) do { sleep 1; ...
feel more like you dont know what youre talking about @sullen marsh (could also just be that you did not used the right words for the message) as it reads out that scheduled env. is the complete oposite from what it is
most important thing is: scheduled environment EVERY script command can be suspended after or before its execution
not within
thats why using callExtension can be extremly cost intensive
Yes I am aware of this...
and thats also why it is in theory the only way you can sleep in a non-scheduled environment (which will then however affect your framerate greatly!)
The script commands that run other code (call, forEach, etc) can be suspended. They just add stuff to the execution stack (visible in save game files if you derap them).
not 100% correct
they just also run in a VM env
but their actual job
also cannot be suspended
forEach can't be suspended?
any script way to rearm countermeasures ? π€
but not what it does
Countermeasures are magazines. So such commands can do it
the value it receives contains code that then is ran
however, the forEach command --> no exception in regards of suspendable
its execution --> can be suspended
turns out _vehicle setVehicleAmmo 1 rearms countermeasures too
Huh? All it does is push a "forEach" object onto the execution stack and return.
yes
but that "pushing blabla" cannot be suspended π
thus it blocks until it returns
Oy, stop splitting hairs. π
it looks like but thats the fundamental point in understanding SQF
ty will try this!
as that is why a scheduled environment also can affect your framerate even thought it should not
And if it does, it will be substantially less than a PFEH (because it will suspend immediately after the first instance of a long running engine command).
In VBS 3 I have a script called βClick to Shootβ
It turn off the function where the aim always are in the middle of the screen and I can point with my mouse all over the screen. When I click the left button I shoot where the mouse pointer are located. Have you heard about this function in ARMA?
I think we can all agree that shit like allMissionObjects does not belong in a loop or a PFH
Do you mean... Aiming Deadzone
Almost. But must be all over the screen. Not just a small box in the βmiddleβ
Do you have a reference video/pic I can see
Someone posted a PFEH in here that used it, and then exhaustively got properties of pretty much every object it returned.
it's scriptable by creating a bullet and "throwing" it in direction of the click's 3D pos
a solution for that could be btw. some sort of special "XXXXXPart" command
that would be executed like so:
waitUntil{ _result allMissionObjectsPart [nil, "Air]; };
_result```
the command itself would then just check on regular base if it should be suspended and suspend itself by exiting itself with a false whilst _result would always contain a special vartype for progress infos
those then could be used for the next itteration
but ye ... thats magic π
Which is why the "everything in PFEH" lore is silly.
You could make allMissionObjects interruptable without changing the syntax at all, X39.
depends on the SQF "VM"
I have no application for whatever that piece of code above is.
if it is not supporting pausing a VM stack, then no
It's how sleep works.
yes, but for sleep you need no progress info
long running commands which pause need to exit their own function
Yeah, they do.
They push an object to the execution stack and return.
And they never re-enter again.
You can see them in the save games; even for "sleep".
there are various ways to do that which are WAY to OT but in the end, it all depends on how the SQF "VM" is built
Unrap a save game and put a breakpoint on the entry for sleep, you'll see that it comes out and never goes back in. π
well as i said
dont know how its inner is working
thus all can be possible
I think I have some on my youtube channel. Search for erpesjo and Lasershooting.
I have tryed that, but havnβt reached any success. Any script examples? So I can test.
Yeap, what I'm getting at is that is how it works internally, unless they've changed it since I last looked. π
So, what is your goal? Do you want to use Arma 3 as a virtual shooting range training system or something?
There's one interesting exception...
configClasses and configProperties aren't done properly; they don't suspend.
So you can abuse them to run unscheduled code within a scheduled environment; e.g. have small atomic bits of code that won't suspend, while the outer script will suspend.
you can set floatingZoneArea in your <username>.Arma3Profile to 1 or something (max in-game slider is 0.3) π
Exaclyππ
Hmmmm can you test that please? And if you have time maybe send a video. I am away and celebrating christmas by friends and dont have my computer here.
If you're trying to use Arma 3 to use in real life virtual shooting range, you cannot due to EULA
TXπ. I looks better then I expected, but still not full screen. The best have been if the screen could be frozen and then aim all over the screen.
Ops, I have not read that. Can you link to the right chapter. Strange hmmm
full height at least
and setting the number to be higher than 1 only seems to increase the vertical size of the aiming box, horizontal stays the same 
Yes, seems like that.
https://www.bohemia.net/community/licenses/arma3-end-user-license
- B. iv. Use the Program for anything other than entertainment and recreation purposes, including but not limited to using the Program for training, educational, occupational or vocational purposes.
disregard me, wrong paragraph
I cant see why we cant use it as a entertaiment trainer for personal use. But, maybe my english is to bad to understand the meening by their written words.
Yeah, there's very little overhead.
Personal use, means you and only you.
Not you and friends.
I am making a bulldozer that deletes everything it steps on, so to know which patch of dirt it should delete I just use nearestObject
Old code with createvehicle worked good, I am using simpleobjects now because its said to be 43x faster
I don't know if looping through all the simple objects and getting the closest is worth it though, if thats the only solution
Doing regular nearestObjects on a small radius is not a big deal
Doing it say each frame could also be fine
Doing it each frame x100 times (for say 100 objects) will be too much
That I understand. And I will do a shooting game for me and my entertainment.
id go with something like one per second (bad experience with nearestObjects each frame)
Uhhhh damn, yeah, I completely missed that fact
You are right
By the way, are servers limited to 45.4545 FPS? Just getting info for when my boss wakes up because his server won't go any higher than that
Itβs impressive that you have read the EULA. Big salute for that. I have never even tryed. To much text and impossible to understand if you not speak english as native language. But, I think itβs a good idea. Tx
Don't most of them require config level event hooks?
Add -limitFPS=100 to server start params.
https://community.bistudio.com/wiki/Arma_3:_Startup_Parameters#limitFPS
There is a fall back for incompatible units
Ahh.
You don't just tell them to write their own repair .pbo? π
Why not? I made the one in AGM, so someone else can do it this time.
Yeah, if you can't write configs/make a .pbo you should just go back to vanilla. grin
Or just don't use addons that UBC class AllVehicles just because there is one plane inside that will be used every 3 months.
Best one I found was a mod that redefined the voices array and made every single AI speak russian.
For some reason, using CUP, RHS and AiA TP, I have now rabbits spawning in the VA.
seems reasonable
I was debuging init events when suddenly 4 or 5 additional entries appeared in the RPT.
I tab back in the game and see rabbits everywhere
Troll rabbits
It is many times faster
But it doesn't pick up CfgAmmo and CfgNonAIVehicles objects
It is so much faster that I consider allMissionObjects as bugged.
X39: What's the reason for not putting variable declarations near their use? I would say it is one of the few areas of programming style that there isn't disagreement on.
basically yes, but entities is way faster
Oh, entities "WeaponHolder" doesn't pick up the weapons either
@tribal crane #offtopic_arma
You'll have to use allMissionObjects. Entities seems to ignore weapon holders
entities "WeaponHolder"
[]
allMissionObjects "WeaponHolder"
[35edc800# 9: dummyweapon_single.p3d]
cursorTarget isKindOf "WeaponHolder"
true
position player nearEntities 50
[B Alpha 1-1:1 (Gefr. commy2)]
Seems like weapon holders aren't "entities"
[B Alpha 1-1:1 (Gefr. commy2),3764a400# 10: wpnsbox_f.p3d]
weapon boxes are
entities relates to allMissionObjects the same way as nearEntities relates to nearObjects
I have no idea what the definition of an entity is though
Seems to be soldiers, vehicles, non-map strcutures etc.
But not bullets and butterflies
Which are in allMissionObjects
at least it looks like isnt it like so?
an entity is basically an instance of a logic bound object
feeling better now?
Why is a butterfly not an entity then?
different list
So you don't have any definition either, thank you
you got multiple lists
for performance
and the definition is more or less the common one π
So how do I know, if say a mine, is an entity or only a "mission object"
lemme repeat: every instance which runs on logic on a regular base can be considered as entity
Butterflies run logic frequently.
There is a logic in the butterflies though and they aren't entities apparently
just because you cannot receive them in common way does not means they are non
just means getting them is harder
or that they are organized "in the cloud"
But I want to know which objects are entities. And that before testing it with #logentities or anything like that.
shall i repeat myself again?
you ask the wrong questions
you got the base which is an entity
now the question is not are butterflies entities
the question is: what kind of are they
Is a butterfly an entity?
could also be a particle effect (which could also just be an entity depending on its implementation)
Is a weapon holder an entity?
would consider it as static one
if it is is simple checkable
if it can be moved
via velocity
its an living entity
as it has movement logic enabled
If a weapon holder is an entity. Then why isn't it listed in (entities "") ?
because the command does not needs to give you all entities @tough abyss π
What does the entity command return then?
a range of entities
"entities"
Heli1 Say2D "sound1";
sleep 5;
titleCut ["", "BLACK OUT", 0];
enableCamShake true;
addCamShake [5, 20, 25];
"dynamicBlur" ppEffectEnable true;
"dynamicBlur" ppEffectAdjust [6];
"dynamicBlur" ppEffectCommit 0;
"dynamicBlur" ppEffectAdjust [0.0];
"dynamicBlur" ppEffectCommit 15;
titleCut ["", "BLACK IN", 10];
Heli1 SetDamage 0.97;
Heli1 AllowDamage False;
if I put this into a .sqf file and put a execVM in a trigger (serverside ticked on) will it then play for all players in a multiplayer mission?
So basically "Some entities"
testing, checking the documentation (ohhh wait ...), Reverse Engineering the data
You need remoteexex for every client or make your trigger global.
Your effects are local, so you need to create those on the client.
alternativly: ask BI
Part heli1 damage and allowDamage part should be executed once, so you could use local heli1 check there
no, they made a command which returns what you want
because the rest you are not supposed to work on
or at least not via using that ocmmand
gwhs?
ground weapon holders
Sure, but not with entities, which says to me that they are not considered as "entities"
I wanna know why.
entities "all"
tried using the GWHSs classname directly?
then the GWHSs are listed on a different list
which explains again why entities is faster
just means you now know how many lists there are a command could check π
ammo containers are in entities, only GWHs are not
WeaponHolders are simulation=house
It's probably just something in the base classes of the internal object that handles simulation=house vs something like thingx
That seems to be it.
I createVehicle'd a hospital
ANd it's not listed in entities
So my definition is:
An entity is:
I feel like I'm trying to reinvent the wheel, and someone has probably done a better implementation already. I'm trying to upgrade my ACE Medics into ACE Doctors when they're within a certain distance from my ACE Doctors. What I have so far is
player spawn {
{
if ((_x getVariable "ace_medical_medicclass") == 2 && (player getVariable "ace_medical_medicclass") == 1) then {
player setVariable ["CGEM_hasMedicPerms",true];
player setVariable ["ace_medical_medicclass",2];
sleep 10;
player setVariable ["ace_medical_medicclass",1];
};
} forEach (player nearEntities 100);
sleep 1;
};
};```
which is running locally (a script execVM'd from initplayerlocal if the character has "_medic" in its vehicleVarName).
It seems to work OK, at least when testing locally, but is there any better way of doing it? Will the above implimentation run into any obvious failure modes?
Will the above implimentation run into any obvious failure modes?
When player dies and respawns that script stops working.
Houses are probably entities. The function name is bad.
also you are grabbing all the entities when you just need players
that means the AI as well.
The script is restarted in the respawn EH (with the same criteria; only for players with "_medic" in their vehicleVarName).
I'm thinking I might want to be able to spawn in an AI "doctor" as a fallback if the player-controlled doctor buys the farm (and nearEntities allows me to have an object as a kind of medical facility thing, should the need arise).
- a CfgVehicles object that does not belong to the map, is not of type "house" and is not a soldier inside a vehicle.
more missleading @tribal crane
myb to lower the search for the nearentittes just put type as a Cammanbase so it wont include rabbits and snakes if you have them enabled.
like (player nearEntities ["CAManBase",100])?
Yea also spawn is getting executed each second while the foreach has a 10 second delay witch is bad imo.
nop @tough abyss
you just think to closeminded and do not specify your entity
you talk about a generalized term
Also if you are running this code in InitPlayerLocal you dont need spawn becouse InitPlayerLocal is all ready sceduled.
and want specialized entities
Yeah, that's kind of what I'm getting at. If I want the medic to lose his doctor permissions when he's not within range of a doctor anymore, you kind of need the sleep 10 there, unless you can think of some smoother implementation. I mean, you could have a longer sleep for each round of spawn, but that would introduce a latency between the doctor showing up and the medic getting granted doctor permissions.
That's what I thought, but then arma hit me with a "suspension not allowed in this context".
I don't care for general terms. I want to communicate what entities "" and nearEntities actually does.
Since there are at least two commands I think it's worth having a definition
My confusion comes from "house"s not considered as entities for no apparent reason
it is an entity
but it is not an entity of that kind you want to receive using entities
You have a performance leak in this.
while is executing as fast as it can, potentially multiple times per frame. Every time it runs, it generates a spawn.
The spawn contains a sleep, but spawn is a new separate thread; the while does not wait for the first spawn to complete - it just keeps going. So you are creating thousands of spawn threads, each running separately. That's unnecessary for what you're doing and it's probably clogging the scheduler.
My first definition is:
an entity is whatever is returned by entities ""
And now I wanna know what these are.
which is already invalid
as i said
you use a generalized term
on an command that is not named nicely
to get all items
using something that is designed to get not all items
@dire island Try this:
while { true } do {
if (((player getVariable ["ace_medical_medicclass", 0]) < 1) or (!alive player)) then {
sleep 10;
continue;
};
private _isNearMedic = (((player nearEntities ["CAManBase", 100]) - [player]) findIf { (_x getVariable ["ace_medical_medicclass", 0] > 1) && !(_x getVariable ["valross_var_upgradedMedic",false]) }) > -1;
if _isNearMedic then {
if !(player getVariable ["valross_var_upgradedMedic",false]) then {
player setVariable ["valross_var_upgradedMedic",true,true];
player setVariable ["CGEM_hasMedicPerms",true,true];
player setVariable ["ace_medical_medicclass",2,true];
};
} else {
// safety: don't downgrade "natural" doctors
if (player getVariable ["valross_var_upgradedMedic",false]) then {
player setVariable ["CGEM_hasMedicPerms",false,true];
player setVariable ["ace_medical_medicclass",1,true];
player setVariable ["valross_var_upgradedMedic",false,true];
};
};
sleep 10;
};```
you try to hunt ducks using a stick
Edited: added a safety to stop upgraded medics self-sustaining each other without a real doctor present, and also fixed an error
Edited 2: fixed another error
Edited 3: ok I think we're finally there
hf and happy new year π
always keep track of your bracket pairs :U
why do i feel like this can be shortend:
if _isNearMedic then {
if !(player getVariable ["valross_var_upgradedMedic",false]) then {
player setVariable ["valross_var_upgradedMedic",true,true];
player setVariable ["CGEM_hasMedicPerms",true,true];
player setVariable ["ace_medical_medicclass",2,true];
};
} else {
// safety: don't downgrade "natural" doctors
if (player getVariable ["valross_var_upgradedMedic",false]) then {
player setVariable ["CGEM_hasMedicPerms",false,true];
player setVariable ["ace_medical_medicclass",1,true];
player setVariable ["valross_var_upgradedMedic",false,true];
};
};
Why isn't a simulation=house an entity, X39?
^ spot the troll
I don't see how.
The number of lines comes mostly from the setVariables. You need all of those, one of them has a different value so can't be included in a forEach, so using a forEach instead of separately-listed setVariables wouldn't save any significant amount of space.
@tribal crane it is an entity (never said it was not) but it is not the same as eg. an soldier
and entities simply does not checks for houses
thats what i try to communicate :]
What's the difference between a "bad" function name and a "misleading" function name? Is all the new years alcohol making us argumentative? π
did not yet drunk something
bad function name ==> missleading function name
im trying to find an efficient way to fire a script using an event handler in a combat zone, relating to combat modes
however it seems that combat modes dont apply to player owned squads which (iirc) always stay in aware mode
currently i have
// initPlayerLocal.sqf
(group _player) addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
if (_newMode == "Combat") then {
_leader = leader _group;
_nearestEnemy = _leader findNearestEnemy _leader;
_factionNearestEnemy = faction _nearestEnemy;
enemyFaction = "the enemy";
if (_factionNearestEnemy == "fact1" || "fact2") then {
enemyFaction = "the said faction";
};
...
but this wont work im guessing due to the issue above and also if it did it would work only on that group specifically
Works on local and ds as far as I can tell. Thanks!
I just see no value in the term "entity" anywhere else, so I use it for the "entities" and "nearEntities" commands, which behave very similar.
and thats why it is so important to understand that pretty much everything is an entity
but there are different kinds of entities
If you were pointing out that "misleading" is a subset of "bad" and therefore my phrase was imprecise then all I can do is... Ask if you speak German?
yes i do
π
myb instead combat mod you could use behaviour
https://community.bistudio.com/wiki/behaviour
would that work for players?
AI units in player groups - maybe, test it.
Player units - well players don't have AI behaviour [citation needed], so it might work in the sense that it will return a technically valid result, but I wouldn't expect to get anything useful out of it.
If pretty much everything is an entitiy, then the term becomes useless.
Yeah, it pretty much is.
this method when a player is in an ai squad
but yea that doesnt give a lot of compatibility
well @tough abyss ... you ask why dog X is not covered by a book for german shepherd
I'd hazard a guess that if you made a list of simulation='s that it works for you can predict what it will return.
There's some internal hierarchy of simulations, too; a "church" seems to be a "building" with extra bits to animate a clock, for instance.
Isn't that a script?
Nah, there's a special simulation=church that is used for clock towers. It has an extra animation driver with the current time.
I've always been tempted to try to make a rotating restaurant. π
most likely just another subset @tribal crane
more or less like so:
entity --> house --> church
thus this could be found on the entities list
the houses list and the churches list
Map objects have them too, via the class= named property in the .p3d, e.g.:
class = church [C:\Development\P\a3\structures_f\civ\BellTowers\BellTower_02_ V1_F.p3d]
class = house [C:\Development\P\a3\structures_f\Bridges\Bridge_01_PathLod_F.p 3d]
class = housesimulated [C:\Development\P\a3\roads_f\Runway\RunwayLights\Flush_Light_green_F.p3d]
The closest object is not necessarily in front of the bulldozer and it's not necessarily the simple object you want
So yes in your case you must use nearestObjects to get the objects, do an inAreaArray to filter those in front of the bulldozer, and also filter them by their models using select (if you create simple objects using their models they don't have a type)
You don't have to loop thru all simple objects. Just the ones in a small radius in front of the bulldozer, so performance will not be impacted noticeably
is there a function similar to sqf firstBackpack _box;
that would work to detect a vest and uniform in a contianer?
(goal is to fill specific uniform and vest in a container like i'm doing for backpacks currently.)
nvm, "everyContainer" might be what i need.
Has anyone used the Intercept mod ? When using this mod, the inventory stops opening. Is there any way to fix this?
I use Intercept and I've never seen that happening
Which way should I dig to figure this out?
The problem is definitely related to it, since everything is fine when playing without mods, but when Interceptor is connected, the inventory breaks.
Do you just load Intercept or do you also do something with it? (e.g. with your own plugin)
Also are you using dedmen Intercept mod or is there other mod named same ?
Initially, I noticed a problem when using the Intercept Database.
After that, to check who the culprit was, I disabled the Intercept Database and connected Intercept - but the problem remained.
The problem was resolved only after Intercept was disabled.
Is it possible to use the script to make the smoke that spawns already in the air and not just arise from the ground???
yeah with particle effects https://community.bistudio.com/wiki/Arma_3:_Particle_Effects
I haven't played with particle effect editing (programming) yet. but thanks, I'll try
Well this is outdated and probably doesn't work anymore (unless you update its Intercept)
As for this, did you build it yourself?
No, I took it ready.
Do I need to rebuild the intercept-database to update intercept, or is it enough for me to give it a new DLL?
Take "Intercept minimal dev" from steam workshop.
And the intercept database release from GitHub should be ok
That's exactly what I did initially. That's probably not the problem.
Inventory specifically, could be a InventoryOpened Eventhandler denying the opening.
But intercept minimal, doesn't add any
Good day to everyone.Can someone tell me how to make the Eventhandler "AnimDone" work for a specific animation from the unit's animation list (By animation name), rather than any one that is currently playing?
by checking
this addEventHandler ["AnimDone", {
params ["_unit", "_anim"];
if (_anim in ["youtAnimation1", "youranimation2"]) then {
//do stuff
};
}];
Depens how many you want check
Depending on your use case, it might be easier to just build the shoothouses you want, build each shoothouse in a separate layer. Hide all shoothouse objects, then use
_activeLayer = selectRandom _layers;
{
_x hideObjectGlobal False;
} forEach ((getMissionLayerEntities _activeLayer) select 0);``` to select one random layer out of "House1" and "House2" and un-hide all objects in the chosen layer. Since getMissionLayerEntities includes sub-layers, you could have one layer "Shoothouses", with "House1" and "House2" as sub-layers, and run
```{
_x hideObjectGlobal True;
} forEach ((getMissionLayerEntities "Shoothouses") select 0);``` both at mission start to hide all shoothouses, and after the shoothouse has been ran through in order to reset it.
Thank you very much.
_layers = ["House1", "House2"];
_activeLayer = selectRandom _layers;
missing s
If this is due to the same issue I remember, it's actually due to CBA and an inventory event handler. There is a variable you can change to fix this, I'll grab it for you if I remember
I would be very grateful. 
Probably isnt the "correct" way to fix this, however I've used
player setVariable ["cba_xeh_inventoryopened",nil];
Hi !
I'm currently trying to learn about compile and preprocessFileLineNumbers to optimise a bit my scritps, I have a Mission that has multiple .sqf functions, I've looked at the wiki page of both compile and preprocessFileLineNumbers , but I want to use my function on a object in game, how can I call the compiled function ? Where should I compile it ? In one of the Init.sqf file (initServer or initPlayer ?)
CfgFunctions in description.ext is the easiest way.
Otherwise you'd use compileScript, and store it in a variable.
But afaik doing that in init.sqf is unsafe, the script may run after whatever you have in the mission tries to use it
Understood, I'll try this. Thank you very much !
Is there a way to set a fixed view distance in my MP mission for all players ?
Should i use a trigger for this or a description.ext file ?
Cause im sure that the config panel where you can execute scripts locally etc. is disabled in MP
Place the first command in https://community.bistudio.com/wiki/Event_Scripts#initPlayerLocal.sqf.
Oh i should just make an init.sqf, thanks
initPlayerLocal.sqf
"config panel" -> "debug console"
Whether it's enabled in MP depends on the mission's settings, which you can change in description.ext or the Eden Editor. It can be set, per-mission, to be unavailable, available for everyone, or available only for the admin.
description.ext is not used for scripts, it's used for config. You can use it to make CfgFunctions, which is related to scripting, but that's essentially a list of scripts for quick reference, not the scripts themselves. You'd almost never put an SQF command directly in description.ext.
Yeah i have used the description.ext to make some voiced messages with subtitles etc. in some older missions but now i have got a year or so to make a mission and i got rusty π
Thanks for the help
Ok, I will look into it.
It's unbelievable. Thank you very much, you helped me out a lot.
Is there anyway to closedialog by name?
I see to make a define, but doesn't that still just reference a number?
Quick question, if I remoteExec an addaction that is placed on a spawned object, do I need to give it 0 so that all players can interact with the spawned item? or would 2 for server work too?
Addaction is local event, so yes you need to use 0
Wonderful thankyou
what math would one need to do to turn a direction to a position every few metres? been thinking of the math but not really sure how even looking at vectors
What do you mean by "turn a direction to a position every few metres"?
Do you mean like, getting the position X meters away from where something is facing?
Do you mean a relative direction from unit to position?
https://community.bistudio.com/wiki/getRelDir
Example 2 might work for you if I understand what you want correctly
@lime rapids Sorry for the ping but are you still looking for a solution for your problem or can I post my own problem here?
dw im good plus its not a rule to wait for ppl to post
Thanks.
_hostage = this;
_hostage disableAI "ALL";
_hostage addAction ["Drag Hostage", {[_this select 0, _this select 1] call dragHostage}];
_hostage setVariable ["isDragged", false, true];
_hostage setVariable ["draggedBy", objNull, true];
dragHostage = {
params ["_caller", "_hostage"];
private _isDragged = _hostage getVariable ["isDragged", false];
if (!_isDragged) then {
_hostage setVariable ["isDragged", true, true];
_hostage setVariable ["draggedBy", _caller, true];
_caller attachTo [_hostage, [0, 2, 0]];
_hostage addAction ["Undrag Hostage", {
params ["_caller", "_hostage"];
_hostage setVariable ["isDragged", false, true];
_hostage setVariable ["draggedBy", objNull, true];
detach _hostage;
detach _caller;
_hostage removeAction (_this select 2);
}, _hostage];
};
};
_hostage addAction ["Insert Hostage into Nearby Vehicle", {
params ["_hostage", "_caller"];
private _nearbyVehicles = nearestObjects [_caller, ["Car", "Helicopter"], 10];
private _teamVehicles = _nearbyVehicles select {side _x == side _caller};
private _vehicle = _teamVehicles select 0;
if (!isNil "_vehicle") then {
_hostage setVariable ["isDragged", false, true];
_hostage setVariable ["draggedBy", objNull, true];
detach _hostage;
_hostage moveInAny _vehicle;
_actionId = _vehicle addAction ["Force Hostage Out", {
params ["_caller", "_vehicle", "_actionId"];
private _hostage = Hostage_1;
unassignVehicle _hostage;
_vehicle removeAction (_this select 2);
_hostage action ["Eject", _vehicle];
}];
};
}, [], 1.5, true, true, "", "_this distance _target < 5"];
When I force the NPC to leave the vehicle, the action button for "Force Hostage Out" remains, despite trying to remove it. Any help?
The NPC does leave the vehicle for the record.
If you are just trying to get "x meters in front of something", then modelToWorld is going to be pretty slow for that
You can instead do:
private _direction = getDir _someObject;
private _positionASL = getPosASL _someObject vectorAdd [
sin _direction,
cos _direction,
0.02 // For spawning an object, you usually want a bit of extra height to prevent clipping into the terrain
];
dw i got it sorted just forgetting modl to world exists
Which is why I said modelToWorld is going to be slow if that's what you're using it for
Hi guys, can I get some help? I play with friends and I am mission maker for us. Me and my brother play on the same network and MY PC i server hosting. We got 7 people and when I try alone in my mission to run animations for AI it works perfect. But when I play with friends the position of AI is somewhere else than when testing and animations look silly. :/
You're probably not playing the animations where the unit(s) are local
I got trigger on map with "Anyone is in trigger" and in onActivation I got animation stuff like switchMove etc... That is wrong?
Do you have the "Server Only" box checked?
I do not. Will it help?
Shouldn'tβ’οΈ make a difference, since that trigger would run on every person's machine, and the units would be local to one of them
I will look again if it is checked or not. To be sure. π
If I have this in unit INIT:
this disableAI "PATH";
dostop this;
[this, "BRIEFING", "ASIS"] call BIS_fnc_ambientAnim;
It makes same thing. Everything works but when I play with friends, the unit is every restart somewhere else. Hosting on my PC where mission is. π¦
if (!(local this)) exitWith { };
Where do I put this?
At the beginning, obviously.
In every trigger spawning animations and in every unit's INIT?
The second. We don't know how your triggers are set up.
When it is BIS_fnc_ambientAnim I got it in unit's INIT and when it is SwitchMove animation type I got trigger placed on map.
We need trigger's settings. But most likely you need https://community.bistudio.com/wiki/remoteExec.
Will look through. Thanks alot. π
An useful article: https://community.bistudio.com/wiki/Multiplayer_Scripting
So can anyone lend me some aid?
looks like the params is wrong. should be: params ["_vehicle", "_caller", "_actionId"];
Let me check
The one under the 'force hostage out' right?
yes
I'm gonna kill myself this fixed it
I need to get myself some glasses because I didn't see this
thank you very much
Wait how did you know that this should be in this order?
I'm borrowing this code from a friend to create a system where the players load a box into a vehicle through ACE to rearm it.
private _cargoHandler = {
// params are [_item, _vehicle]
// specifies the vehicles to be used, under variable name in the editor, name the vehicle and change
// veh below to match, or name the vehicle "veh" and don't change anything. You can also add more
// by doing something like [veh1, veh2, veh3]
private _allowedVehicles = [truck, truck_1, jeep, heli];
if !(_vehicle in _allowedVehicle) then {
return;
};
// specifies the type of box that is used. Change the name in quotes below to whatever class name you want.
// the class name is the one below the actual name. e.g, a quad bike is B_Quadbike_01_F
private _className = "VirtualReammoBox_small_F";
if (typeOf _item != _className) then {
return;
};
// the two above if statements can be combined, I separated them to be clear on what each does
// had to hunt for where ace stores the loaded cargo, it's here:
// https://github.com/acemod/ACE3/blob/master/addons/cargo/functions/fnc_loadItem.sqf#L35
private _cargoItems = (_this # 1) getVariable ["ace_cargo_loaded", []]; // get items currently in the vehicle
private _num = { typeOf _x == _className } count _cargoItems; // get the number of boxes that are the right type
// if there are more than 2 boxes (change this number to be whatever, but also change how many are removed below if you lower it)
if (_num >= 1) then {
[_className, _vehicle, 1] call ace_cargo_fnc_removeCargoItem; // removes 1 box
_vehicle setVehicleAmmo 1; // set ammo to full
};
};
// event name function to call
["ace_cargoLoaded", _cargoHandler] call CBA_fnc_addEventHandler; // add the event handler```
It's throwing "typeof: Type String, expected Object"
for ```sqf
private _num = { typeOf _x == _className } count _cargoItems; // get the number of boxes that are the right type```
What can I fix about this? I don't want to bother that friend more than I have because he made this entire system.
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
Thanks, just fixed it.
ChatGPT?
How do I fix that error? IDK which is a string. I assume it's _className but I removed the quotes around the part where the box is defined but that broke it.
I don't want to check with that because I've gotten broken code for other projects.
I didn't get this from chatgpt, I asked a friend who's a scripting wizard for how to make this system and he gave me this code for it.
I put it in the mission and it threw the error. The system worked outside that though.
private _num = { typeOf _x == _className } count _cargoItems;
ACE vehicle cargo items can be stored as a "string" rather than as an object reference. If the object is saved as a string, then _x (an element of the _cargoItems array) will be a string sometimes. typeOf doesn't accept strings, it's for getting a string classname from an object reference.
You need to have a way of accounting for both object references and strings.
You should provide to typeOf the variable of the expected type.
Try something like this:
private _num = {
private _type = _x;
if (_type isEqualType objNull) then {
_type = typeOf _x;
};
_type == _className
} count _cargoItems;```
I guess _cargoItems is already array of strings.
Like replace that line of code with that?
No, it can be both strings and objects. If you read the full code, it's the ACE Vehicle Cargo stored items variable, and per the ACE code, such items can be stored as either strings or object references.
Yes
Awesome. I'll give it a shot.
Hm, strange decision.
Not really, it's necessary for how ACE works. You can put both unique objects (object reference) and non-unique objects (string) inside vehicle cargo using their system. It has to preserve both types - converting a unique object to string would be bad, while at the same time there's no point storing e.g. spare tyres as unique objects.
I just tried that, it doesn't throw the error, but it doesn't seem to work with the next bit of code which deletes the box and refills the vehicle's ammo
Debug it.
The code changed doesn't have any effect on the following code (except ensuring the number reported is correct).
Also, if do (finddisplay 46) createdisplay "menu", how can i close the display? (Finddisplay 46) closedisplay 0, does not seem to work. Some of my variations end the game
Where you might have a problem is one of the if statements at the start.
if (typeOf _item != _className) then {```
Although ACE can save the cargo items as either string or object reference, what it reports in the `ace_cargoLoaded` event handler is only the string classname, and this code is taking place in that EH. So `_item` here is _already_ the classname of the object that's just been loaded into the cargo, and you're once again trying to use `typeOf` on a string, which doesn't work. So remove `typeOf` here.
There's actually another problem with both of those if statements, which is that return is not a valid command in SQF. I assume it's meant to be a placeholder for some actual code that was never put in - but since it's there, it'll cause problems.
I would also check the values of _vehicle and _item vars.
We know exactly what they're going to be because they're provided by the EH.
https://github.com/acemod/ACE3/blob/master/addons/cargo/functions/fnc_addCargoItem.sqf
_vehicle is the vehicle (object reference) into which the item has just been loaded.
_item is the classname of the item that's just been loaded into the vehicle.
(The event is called with call so the EH code is running in the same scope as the ACE function and the variables are already defined with those names)
So you don't need to use params at the beginning?
I don't believe so, I think that's just him explaining how the code works.
Have you checked?
https://community.bistudio.com/wiki/Variables#Scopes
When you use call, the called code is executed in the same scope, and existing variables in the parent scope are available to the called code.
At line 45 in the linked ACE function, the EH (which is where this code is executed) is called with call.
It would be good practice to use params in case you want to also use this code with another EH, or in case ACE changes their variable names, but it's not strictly necessary.
Fixing the things mentioned here is strictly necessary though #arma3_scripting message
I just removed the typeOf part and that still doesn't do anything.
I honestly can't make heads or tails of what's wrong. The code w/out the modifications here threw the error but still refilled the vehicle's ammo and deleted the box.
//Seige's script for rearming vehicles through loading boxes into their cargo.
private _cargoHandler = {
// params are [_item, _vehicle]
// specifies the vehicles to be used, under variable name in the editor, name the vehicle and change
// veh below to match, or name the vehicle "veh" and don't change anything. You can also add more
// by doing something like [veh1, veh2, veh3]
private _allowedVehicles = [truck, truck_1, jeep, heli];
if !(_vehicle in _allowedVehicle) then {
return;
};
// specifies the type of box that is used. Change the name in quotes below to whatever class name you want.
// the class name is the one below the actual name. e.g, a quad bike is B_Quadbike_01_F
private _className = "VirtualReammoBox_small_F";
if (_item != _className) then {
return;
};
// the two above if statements can be combined, I separated them to be clear on what each does
// had to hunt for where ace stores the loaded cargo, it's here:
// https://github.com/acemod/ACE3/blob/master/addons/cargo/functions/fnc_loadItem.sqf#L35
private _cargoItems = (_this # 1) getVariable ["ace_cargo_loaded", []]; // get items currently in the vehicle
private _num = {
private _type = _x;
if (_type isEqualType objNull) then {
_type = typeOf _x;
};
_type == _className
} count _cargoItems; // get the number of boxes that are the right type
// if there are more than 2 boxes (change this number to be whatever, but also change how many are removed below if you lower it)
if (_num >= 1) then {
[_className, _vehicle, 1] call ace_cargo_fnc_removeCargoItem; // removes 1 box
_vehicle setVehicleAmmo 1; // set ammo to full
};
};```
That's the code as it stands now, I probably messed something up
Yeah so I've made a mistake and I forgot to add remoteexecs wherever they were needed for actions. Can I enclose this whole script in a function that I'd remotely call like this?
pls_run_this = {
// pretend that code I replied to is here
};
[this] remoteExec ["pls_run_this",0];
The point of this is to make it work for Zeus on public servers, so that the hostages he spawns can be interacted with by other clients.
Also I don't know why I wrote [this] argument.
So on reading this again, this was definitely supposed to have you replace some bits with your own names/script according to what you need, and not just use the whole thing as-is.
For example, those things at the start are meant to be used for filtering for specific vehicles, which you're not doing. (return still can't be used because it's not a valid SQF command, btw).
Let's strip all that out and get down to the core parts.
Oh, derp. I should have realized this. This was my first foray into actual scripting so I didn't notice.
// specifies the vehicles to be used, under variable name in the editor, name the vehicle and change
// veh below to match, or name the vehicle "veh" and don't change anything. You can also add more
// by doing something like [veh1, veh2, veh3]
private _allowedVehicles = [truck, truck_1, jeep, heli];
if !(_vehicle in _allowedVehicle) then {
return;
};```
So remove this?
Or when you say "Strip all that out" you mean ignore that?
private _cargoHandler = {
params ["_item","_vehicle"];
private _className = "VirtualReammoBox_small_F";
private _cargoItems = (_this # 1) getVariable ["ace_cargo_loaded", []]; // get items currently in the vehicle
private _num = {
private _type = _x;
if (_type isEqualType objNull) then {
_type = typeOf _x;
};
_type == _className
} count _cargoItems; // get the number of boxes that are the right type
// if there are more than 2 boxes (change this number to be whatever, but also change how many are removed below if you lower it)
if (_num >= 1) then {
[_className, _vehicle, 1] call ace_cargo_fnc_removeCargoItem; // removes 1 box
_vehicle setVehicleAmmo 1; // set ammo to full
};
};```
Now there might still be a problem here but at least we're only working with the parts we actually need
Gotcha
So basically this would refill the ammo for any vehicle the box is put into? Rather than just the ones specified at the first block right?
Currently yes
We can add the filtering back later if it's important (and make it actually work)
It's not really all that important. I can lock the other vehicles in the editor.
Just to be clear, you do still need the CBA addEventHandler stuff right at the bottom after all this. There wasn't anything wrong with that so I'm just ignoring it for now.
["ace_cargoLoaded", _cargoHandler] call CBA_fnc_addEventHandler; // add the event handler```
This one right?
Yes
Alright. I've got that.
So IDK if this is like sqf basics. But I took one coding class in university so I'm kinda having a hard time reading this code.
Is it like creating a function with _cargoHandler, then telling it the variables it's supposed to look for are "_item" and "_vehicle"? Then stuff like _Classname, are defined and just used within that function?
It's creating a function, and telling it to expect two arguments, and telling it to call those two arguments _item and _vehicle, in that order. It doesn't matter what those variables were called in the originating scope, it just matters that they were passed in that order.
Let's say you do this:
["myString1", "myString2"] call my_fnc_something;```
In `my_fnc_something`, the magic (auto-generated) variable `_this` will then contain an array, `["myString1", "myString2"]`. By default, `params` looks at the `_this` variable and parses its contents out into the private variables you tell it to, in order.
So if in `my_fnc_something` you do this:
```sqf
params ["_varName", "_someOtherVarName"];
then _varName will contain "myString1" and _someOtherVarName will contain "myString2".
Yup, like he said. Params extract the arguments in the order that they're provided with.
Gotcha, so when I'm calling CBA_fnc_addEventHandler, the second variable will be telling it to look for the cargo handler thing right? And since that's a built in function it's got the params built in too?
It works! Thank you so much!
If it's not too much. How would you filter the vehicles? For future reference.
Now try removing params as it was in your code.
So you're doing this:
["ace_cargoLoaded", _cargoHandler] call CBA_fnc_addEventHandler;```
then when ACE does its cargo loading, it does this:
```sqf
["ace_cargoLoaded", [_item, _vehicle]] call CBA_fnc_globalEvent;```
and that means _CBA_ does this:
```sqf
args call _x;
which is basically the same as doing [_item, _vehicle] call _cargoHandler
It makes a lot of sense when you unfold each command like that. Thank you!
I was slightly wrong about this btw.
I was looking at ACE_cargo_fnc_addCargoItem. Everything I said is true for that. But what's actually being used here is ACE_cargo_fnc_loadItem. That function does not flatten down the item to only ever be a string, so _item in our code could actually be either a string or an object.
Fortunately we don't actually use _item for anything here so it doesn't matter.
There are a few ways to approach it depending on how you want to filter, and how safe you want to be.
A couple of basic options:
if !(_vehicle in [myVicName1, myVicName2]) exitWith {};
if !(typeOf _vehicle in ["className_1", "className_2"]) exitWith {}; // CASE SENSITIVE!```
The first one has a notable weakness, in that if any of those variable names are _undefined_ (the vehicle never existed, or the variable was overwritten with `nil`) then you'll get a script error. There are ways to make it safer, for example using `getVariable`, which can handle undefined variables, but again it depends exactly what behaviour you need.
So the former filters with the variable names from the editor, and the latter filters with the class name right?
(you can work around the case sensitivity of the second one, if you need to, by using toLowerANSI to force everything to lowercase)
Or using findIf and ==.
Variable names from the Editor, or if the vehicle was otherwise saved to a global variable name, e.g. my_vehicle_var = createVehicle ...
Really you can construct the list of vehicles to check against using any method for making an array of vehicles. vehicles, nearEntities, etc.
I will try that when I get more experience with scripting, that sounds like a good idea.
So basically I put either of those at the start of the cargohandler function to filter it right?
After the params, ideally
Perfect. Thank you! You've been a ton of help!
@hallow mortar Hey, can you help me with my remoteexec question I asked earlier? I want to know if I enclose an entire script within a function, and then call that function using remoteexec, will it work?
I'm specifically talking about addAction events and if they will display for the players.
If you use addAction in Init field, you don't need to use remoteExec.
But the script in question is inside of an object that the Zeus will spawn.
And the Zeus isn't the server, but one of the connected clients, that decided to take the Zeus slot.
Then you need remoteExec.
I know, what I need to know is if I can do it the way I described, or if I need to add remoteexec to every action individually.
Post a link to your script or the script again.
Yes, BUT:
the function must be defined on every machine that's going to receive the remoteExec. Despite their name, global variables (pls_run_this) aren't automatically defined on all machines. "Global" in this sense means "all scripts on this machine".
You'll need to either define it in CfgFunctions (if you control the mission file) or use publicVariable to broadcast the variable before sending the remoteExec.
I wouldn't suggest using Lua syntax highlighting for SQF :U
Is there highlighting for sqf on discord?
Yes
pls_run_this = {
private _targetObjArray = curatorMouseOver;
_hostage = _targetObjArray select 1;
_hostage disableAI "ALL";
_hostage addAction ["Drag Hostage", {[_this select 0, _this select 1] call dragHostage}];
_hostage setVariable ["isDragged", false, true];
_hostage setVariable ["draggedBy", objNull, true];
dragHostage = {
params ["_caller", "_hostage"];
private _isDragged = _hostage getVariable ["isDragged", false];
if (!_isDragged) then {
_hostage setVariable ["isDragged", true, true];
_hostage setVariable ["draggedBy", _caller, true];
[_caller] joinSilent createGroup (side _hostage);
_caller attachTo [_hostage, [0, 2, 0]];
_hostage addAction ["Undrag Hostage", {
params ["_actionCaller", "_target", "_actionId"];
_actionCaller setVariable ["isDragged", false, true];
_actionCaller setVariable ["draggedBy", objNull, true];
_actionCaller removeAction _actionId;
{ detach _x } forEach attachedObjects _actionCaller;
}, _hostage];
};
};
_hostage addAction ["Insert Hostage into Nearby Vehicle", {
params ["_hostage", "_caller"];
private _nearbyVehicles = nearestObjects [_caller, ["Car", "Helicopter"], 10];
private _teamVehicles = _nearbyVehicles select {side _x == side _caller};
private _vehicle = _teamVehicles select 0;
if (!isNil "_vehicle") then {
_hostage setVariable ["isDragged", false, true];
_hostage setVariable ["draggedBy", objNull, true];
detach _hostage;
_hostage moveInAny _vehicle;
_actionId = _vehicle addAction ["Force Hostage Out", {
params ["_vehicle", "_caller", "_actionId", "_hostage"];
unassignVehicle (_this select 3);
_vehicle removeAction (_this select 2);
(_this select 3 ) action ["Eject", _vehicle];
},_hostage];
};
}, [], 1.5, true, true, "", "_this distance _target < 5"];
deleteVehicle _this;
};
[this] remoteExec ["pls_run_this",0];
Yeah so you need to publicVariable "pls_run_this" before you do the remoteExec, so it exists on all clients.
You should probably also look into JIP handling for remoteExec. Currently you have none, so pls_run_this won't be executed on clients that join after you place the object.
Oh yeah that's a truth nuke, people who join after I place this down won't feel the effects of the script, because it won't run again just for them.
Thanks for reminding me of that.
I don't really have time to go over the contents of your addActions, but you should watch out for locality there too. For example, action IDs are machine-specific and removeAction is local effect, so when someone does an action that's meant to remove itself like that, you need special handling if you want to also remove the action on other machines.
You could probably also have more complex conditions for the actions - like only being able to use them if the hostage isn't already being dragged by someone else, for example.
I sure could but I felt overwhelmed by just doing what I did, and I had to work for half an hour to fix an issue that was very short, so I'm thinking that I'm not going to do that until I feel comfortable doing so. I'm talking about adding additional layers of complexity, when it comes to dragging conditions for instance.
Wait, so if someone for instance puts the hostage in the car, and the action to take out that hostage appears on the car, will it only appear for the person who inserted the hostage, or also appear for other people?
Hey guys, I have a question. How to script other colour's (like a blue background or something else) in a ENVG-II thermal? How I script my own coulering?
Won't appear for others because action code is only executed on the machine that did the action, and that inner addAction isn't remoteExec'd
So I should go through the actions and give them remoteexecs?
In a word yes, but it's more complicated than that because of JIP and stuff.
I would suggest, instead of doing all this on-the-fly adding and removing, just add all the actions at the start, as part of the initial function that's executed by everyone, and just use the action conditions to determine when they should be shown.
Sorry I can't help further, I really need to get on with some other stuff.
You still helped me a lot, thank you.
https://community.bistudio.com/wiki/Post_Process_Effects
Specifically ppEffectCreate and ppEffectForceInNVG
(findDisplay 46) closeDisplay 0 will end the mission. Because you closed the main display.
You have to close the dialog you created instead.
uiNamespace setVariable ["my_dlgMenu", findDisplay 46 createDisplay "menu"];
(uiNamespace getVariable ["my_dlgMenu", displayNull]) closeDisplay 0;
[getMarkerPos "enemySpawn1", independent, I_L_CriminalGang] remoteExec ["BIS_fnc_spawnGroup", 2, true];
why is this code not working on a trigger that is set to Server only
Before making a wild guess, any error messages or how it is not working
lets find out
it does work
btw
it is being used on a player hosted multiplayer server
Then "I_L_CriminalGang" instead of I_L_CriminalGang
error encountered
17:01:21 Error in expression <"_charsType", "_types"];
_chars = _this param [2, [], [[], 0, configFile]];
_cha>
17:01:21 Error position: <param [2, [], [[], 0, configFile]];
_cha>
17:01:21 Error Type String, expected Number,Array,Config entry
17:01:21 File \A3\Functions_F\Spawning\fn_spawnGroup.sqf..., line 42
I can get it to spawn 5 random dudes on indep, but not the group I defined
I defined?
nvm
just figured it out
heres what worked
looterGroup1 = [getMarkerPos "enemySpawn1", independent, (configFile >> "CfgGroups" >> "Indep" >> "IND_L_F" >> "Infantry" >> "I_L_CriminalGang")] call BIS_fnc_spawnGroup;
You are the man. Awesome possum thanks a bunch. Works great
Anybody familiar with grad persistence? I got it working on local MP and singleplayer, but on my dedi (where I actually need it), running #gradpersistencesave as the logged in admin or manually running [false,0] call grad_persistence_fnc_saveMission with the executeCode module in zeus on the server, but nothing happens. grad_persistence vars are created in my server's profile at dedi.vars.arma3profile, but they are all empty in values, its like the persistence framework isn't exporting anything. Maybe locality issue? I dont know.
i have this code that is ran when an action on a civilian is done. but for some reason the animations only play for the world host. any clue why?
_detainAction = {
_unit = _this select 3 select 0;
removeAllActions _unit;
[_unit, "ApanPknlMstpSnonWnonDnon_ApanPercMstpSnonWnonDnon"] remoteExec ["switchMove", 2];
sleep 0.966;
[_unit, "AmovPercMstpSnonWnonDnon_AmovPercMstpSsurWnonDnon"] remoteExec ["switchMove", 2];
sleep 1;
[_unit, "AmovPercMstpSsurWnonDnon"] remoteExec ["switchMove", 2];
};
it didnt work without remoteExec and it doesnt work with remoteExec so i have no clue if its a locality issue or not
even though switchMove is a global command, it has update delays to remote clients. To have an immediate effect on every machine, execute it globally
is that not what remoteExec does?? i was under the impression that remoteExec just executed it globally
so do i use 0 instead?
aye, or leave that arg blank
alright, ill try that, thank you.
im also having an issue with this script:
_x addMPEventHandler ["MPKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
if (side _killer == west) then {
removeAllActions _unit;
[format ["%1 Killed a civilian (%2)", name _killer, name _unit]] remoteExec ["systemChat", 2];
};
}];
on the host machine, it executes the systemChat command 3 times, but on clients it only does it once. any clue why?
Left: Host
Right: Client
Hey folks, a little bit of code here that needs fixing. I'm at my wits ends, no clue why it's going wrong. The sound should stop playing on the triggers deactivation, but it doesn't, and rather continues to play, with a new sound being played on top if the trigger is exited and then entered again.
I suspect its an issue with the private/public, but not certain
Any ideas?
MPKilled is executed on each machine, you have each client in the game, including server, send the server text to show in chat
You're correct, _proxyMusic is a local variable that vanishes once On Activation executes
Triggers are entities, you can store it in its variable
so do i not need remoteExec? when i didnt have remoteExec, it still showed the message twice for the host.
thisTrigger setVariable ["proxyMusic", _proxyMusic];
```in the end of activation, then
```sqf
private _proxyMusic = thisTrigger getVariable "proxyMusic";
```to retieve it back into local variable in on deactivation
How do you add that event in the first place? You only need to add it once on one machine and it gets added everywhere
If you add it on each machine, it will be sent out everywhere multiple times
its in a function that is set to post-init in description.ext
MP event handlers are tricky, very niche and easy to mess up
would it be easier to just use a normal one then?
Depends on what you need, Killed only executes where unit was local at the moment of death AND had Killed EH added
i want for, when a civilian is killed by a player, for it to send a message in chat saying who killed the civilian.
Lovely, thank you for the help!
i can post the whole function if needed via pastebin
And also remove the actions?
yes, apologies. there is an action to "detain" the civilian as well but that part works fine.
Make sure to add MPKilled only on one client, preferably server client
And show chat locally, don't RE it as MPKilled is executed everywhere already, no need to send anything over the network
i do that with if (isServer then {//...} correct?
Depending on where you call this script
If its postInit CfgFunctions, then it should be executed everywhere and you'll need to limit MP EH addition to only happen on server
So wrapping it into isServer should be enough
alright, ill try that, thank you for all the help π
interesting, it now shows the message twice for both host and client :/
You probably added the EH twice
{
if ((count units group _x) == 1) then {
removeAllActions _x;
_x disableAI "MOVE";
_x switchMove "ApanPknlMstpSnonWnonDnon_G01";
_x addAction ["Detain", _detainAction, [_x], 1.5, true, true, "", "", 2];
if (isServer) then {
_x addMPEventHandler ["MPKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
if (side _killer == west) then {
removeAllActions _unit;
systemChat format ["%1 Killed a civilian (%2)", name _killer, name _unit]
// [format ["%1 Killed a civilian (%2)", name _killer, name _unit]] remoteExec ["systemChat", 2];
};
}];
};
};
} forEach units civilian;
Where is this called from?
inside of a function set to postInit = 1
Sure you don't call this function again eslewhere?
Do this, add:
diag_log text format ["!!! %1: Added MPKilled to %2", diag_frameno toFixed 0, _x];
```before `addMPEventHandler` inside `isServer` check
alrighty
Also make sure client mission is redownloaded so they have up to date scripts
Not sure what kind of setup you have for testing
in case client still uses old script without isServer
im just using a player hosted server as i dont expect to be using a dedicated server for this scenario.
Should work with dedi too
getting an error on load now
Forgot format
ah lemme add that rq
script seems to be working correctly now actually
it might have been an issue of the client not getting the updated script
thank you for all of the help though! π
Check if server has this line only once per unit
Is there a script to make a door/gate locked for everyone except certain units? Like only the guy with variable name "door_opener" can open it
Do you mean players by units?
Yes sorry
Basically I (the Zeus in this case) want to walk through a door for cinematic effect but don't want any other players to follow me
If it's easier to lock an entire "building" that'd be fine too, since the prop is literally just a wall with a door in it
Do setVariable for locking depending on player unit
I guess you're doing it in Init field?
I was planning to yeah
For default BI locking variables:
this spawn {waitUntil{alive player}; _this setVariable["bis_disabled_Door_1ο»Ώ", if(player == door_opener) then {0} else {1}]};ο»Ώ
Init field of the object
Waits until player loads, then sets locked flag depending on player being door_opener
Anyone know how to script the formation commands like flank and advance? Can formations be further scripted to make custom formations?
Would appreciate a ping with the answer
#arma3_ai would be the place to ask, I think. Dealing with AI is a major PITA, so be ready for complex stuff.
Okay the game says it's missing a closing curly bracket, guessing it's for the "alive player" part. {waitUntil (alive player)}; would be the right formatting, right? Just wanna make sure I don't break it lol
aaa more errors, I'll look up the scripts to see if I can learn how to fix it, thank you though!
(though if anyone isn't busy this is the error I'm getting)
No, that's not correct. waitUntil requires Code data type for its check, indicated by { }. ( ) are just for managing order of operations, which isn't what you need here.
The problem is simply a missing } right at the very end, to match the { after spawn.
Oh okay, thank you!
Sorry, forgot the } at the end
if ((getAssignedCuratorLogic player) isEqualTo (getAssignedCuratorLogic _targetCurator)) then
{
curatorCamera setPosASL (GVAR(ZeusTPLastPos) select 0);
curatorCamera setVectorDirAndUp [(GVAR(ZeusTPLastPos) select 1), (GVAR(ZeusTPLastPos) select 2)];
GVAR(ZeusTPLastUsed) = time;
hint "b";
"b"
};
["zen_common_execute", [{
["zen_common_execute", [{
params ["_posASL", "_vectorDir", "_vectorUp"];
curatorCamera setPosASL _posASL;
curatorCamera setVectorDirAndUp [_vectorDir, _vectorUp];
}, [getPosASL curatorCamera, vectorDir curatorCamera, vectorUp curatorCamera]], _this] call CBA_fnc_ownerEvent; // Send up private position for teleport
}, clientOwner], _targetCurator] call CBA_fnc_targetEvent;
GVAR(ZeusTPLastUsed) = time;
"a"
```i get the hint "b" part but i also get the return value "a" rather than "b", am I misunderstanding something?
If statement is executed if your condition is true.
And the rest of the code will be executed after that.
So you will get hint b if your condition true.
And will get return "a" always.
What you want achive?
You want if else or exit from code if your condition is true?
basically return b value in the if
i guess i would need to use exitWith?
Yes if you want exit from your code if your condition is true.
Then it will exit , and the rest of the code won't be executed.
thanks, though saying "b" would just work as return "b" in other languages
Hi guys. Not sure if it is correct channel, but how do I delete unsubscribed mods from steam? I have got subscribed to 70 mods and in my:
G:\SteamLibrary\steamapps\workshop\content\107410
I have 86 probably old mods. :/
@junior moat Plus you need to define a few more things i think
if (isPlayer _instigator && side group _instigator isEqualTo west &&
side group _unit isNotEqualTo west && _unit isKindOf "man") then {}
or what ever you need in there
I already unsubscribed but the mods are still there.
Hey :Phen_WAVE:
I am trying to move a 'core object' using setVelocityTransformation in a loop to keep this core object moving towards a pointer object, this is all spawned on the Zeus side with a CBA_A3 Perframehandler; a localVehicle model of a scifi ship is then attached to that core object simulating scifi ships moving in the mission/mod. This works great for the ZEUS client but for other clients the ship/core coreobject appear to move in a very laggy sort of fashion, likes it stuttering.
Here is the weird part, when you zoom in with a binocular or 'eye-ball zoom' it shows up perfectly; see attached videos for visual reference.
see: https://streamable.com/5mnwrg
If you spawn it as ZEUS it work fine regardless of zoom, distance to it or anything. its always smoothly simulated.
see: https://streamable.com/ai0tol [timestamp > 0:19]
all of this is from a dedicated server testing environment with 2 connected clients (players), local testing presented no issues whatsoever
- I have tried the following commands/functions in many ways to try and work around this issue:
enableSimulation
hideObjectglobal
enableDynamicSimulation
enableDynamicSimulationSystem
setFeatureType - I have changed the core to a custom unit/vehicle, which have higher render priority but that only fixes the issue at very close ranges
- I have played around with 12k View distance or 12k Object View Distance, No results
Q: Is there any way to FORCE it to render the ship core object as if I were looking at it while zoomed/binos?
Question have you try to change sceduled enviormente if its in sceduled have you tried to put it in unsceduled ? And vice versa. If its in unsceduled try and put it in sceduled and do you see any diffrence there.
my function, It's unscheduled.
the CBA PFH is unscheduled as well?
https://cbateam.github.io/CBA_A3/docs/files/common/fnc_addPerFrameHandler-sqf.html
spawning/running it scheduled inside a PFH seems like it would create other issues, constantly spawning new threads and all that.
have you myb tried with a diffrent object instead the ships. It might be how the ships are setup with LOD that is causing that ?
I have tried:
- Actual ship model
- a core object, red gul can and attached the ship model to it
- CBA_A3 invisbile airplane target and attached the ship model to it
- black fish VTOL vehicle as core and attached the ship model to it (BEST results as its the biggest object and stays the biggest on the screen regardless of zoom, least stuttery but not clean)
Quick question about this:
This works great for the ZEUS client but for other clients the ship/core coreobject appear to move in a very laggy sort of fashion, likes it stuttering.
Have you tried to create local vehicle for each player and control it via server.
Basicly
Still haveο»Ώ the server authoritatο»Ώiveο»Ώ on when to stop/start the movement but witο»Ώh each ο»Ώclient havο»Ώing ο»Ώtheir own ο»Ώlocal object ?
good idea, but setVelocityTransformation doesnt work well on servers in my experience
I can rewrite it and try it.. I guess.
instead of that you could use https://community.bistudio.com/wiki/vectorLinearConversion
I will give these a try and get back to ya
is there any similar handler to onLoad that pops off when the UI element is rendered?
onLoad sends a very early signal, not what I'm looking for
@flint topaz
https://steamcommunity.com/sharedfiles/filedetails/?id=3393234585
we need to tweak that ZERO G script of yours lol
Could you be more specific? What "UI element"?
Its a button
I put it on the main menu
And onLoad is triggered when my arma is still loading the main menu lol
Yes, because that's then the button would be loaded
What do you need it delayed for?
Because I modify the button's appearance once displayed
Are you comitting the changes after you make them?
Yeah
I modify it externally, on an overlay
Lemme show you
But I think it can be solved with a loop or a waituntil that checks for ctrlShown
Its a progressbar that lets you know about mods loading, when it reaches main menu I made my own menu so it can call the GUI back and update the progressbar with a "Join Server" button
Thatβs awesome, there wasnβt many terrains for the right atmosphere prior.
does anyone know how to make a dedicated server ignore errors like no entry for mods
In MP how do I make an objective that is visible to everyone, and if someone triggers its completion or failure, make sure that everyone sees the objective status change?
maybe you can achieve that with https://community.bistudio.com/wiki/Arma_3:_Task_Framework . not entirely sure
Please tell me how to make the sound repeat in this handler after a certain time, during the time when the animation is playing.
(_this # 0) addEventHandler ["AnimChanged", {
params ["_unit", "_anim"];
if (_anim in ["krovosos_TurnL", "krovosos_TurnR"]) then {
_Krovosos say3d "idle_1";
};
}];
@steady minnow something like ```sqf
[_unit] spawn
{
params ["_Krovosos"];
for "_i" from 0 to 2 do
{
_Krovosos say3d "idle_1";
sleep 2;
};
};
I would create a sound source that repeat sfx sound and delete if anim changed, no needed loop/ spawn/ sleep
didnt know such system existed... π€
Thank you.I need to think about it.
Probably talking about this https://community.bistudio.com/wiki/createSoundSource
Thank you
Anybody recall a mod that adds a generic "Sector" module? I often used it to create big trigger areas to quickly dynamically hide/show squads of enemy AI
Can't think of what it was for the life of me
This is probably a dumb question, is there a way to call a trigger from the editor in a script?
Basically, I want to put a few triggers down in the editor, and then while those are not activated, a timer will go on. Once the timer goes off, a variable gets added to by an amount, and then the timer resets.
I think this is best to do with a while loop, something like this.
While {[trigger is not activated]} do
{ sleep [arbitrary amount of time]
variable += 500};
Is there a way to do this?
how do I get the position of a weapon accessory ( as in ASL/AGL or model position )
alternatively how do I get the selection positions of an optic or other attachment or something
You can't directly, both the attachments and the weapon (when held) are proxies
ah thanks fellas
I've been looking into that, this might be another dumb question. I'm looking to put it into a function. Do I pass the trigger names as strings in the params statement?
Likesqf params ["triggerName"]
or
params [triggerName]```
triggerActivated triggerName```
But like I want to put it in a while loop. Something like
civSaved = {
params ["trigger1","trigger2"]
_this = 0; //Number of civilians evacuated
while {} //Basically while the end trigger hasn't been updated
do
//timer stuff which adds to the civilian evacuated vehicle
};
};```
I'd then call this function at the end which gives a tally of the number of civilians the players bought time for.
The while statement would have something like sqf while {!trigerActivated triggerEnd}
Which would be called in Params
Your params usage is invalid. You need to remove that line
Oh it can just read the names of the triggers without the params line?
tldr, params is used NOT to declare a declared variable
I tldr'd it because it is complicated to understand the concept of it due to you need to understand scopes, local variables and much more
Gotcha
So I just put the variable names of the triggers I made in the editor in there right?
Yes
Awesome. Thank you!
I was thinking you'd have to pass the names of the triggers to the function when you called it
And Params was what's listening for that
There is no listener in RV Engine/SQF. If it is declared globally, which, in this case, they are, can be used everywhere/anywhere
copyToClipboard is described on the Biki as only working on the server for safety. in that case, who's clipboard does it copy to in multiplayer and would I be able to copy to a clipboard of a client on a dedicated server?
It is a local command. What copyToClipboard'd is copied into local computer which executes it. On the other words, you won't be able to transfer somebody's clipboard into one
is there an existing empty simple object in the game I can use
For what purpose. I don't even think what you think does even exist
well I just needed like one single vertex or something to have the position of
And, what purpose
I want to draw some lines ( drawLine3D )
Then just draw using positions? I see no reason to create objects
I want to attach one to the player somewhere
Then use some hidden objects. Like Sphere
Anything can work. Just hideObject it
alright, thank you
For the HoldAction script (I'm using 3den Enhanced though), is _target == "yes"; a valid thing to use for the conditionShow parameter? Or do I only need one equals? Or is that entire thing just totally wrong
(To clarify I have another action that sets the contents of the _target array to the value "yes" so that's why it's there)
Depends on what you really wanted to do
_target == "yes" should return and error and won't work anyways
Would it error because of the ==?
Because you are comparing an object to a string
What if I used 1 instead of yes and used the script {_x == 1} count _target > 0;?
Again, what you really wanted to achieve?
I want the hold action interaction to only show up if a requirement is met, like the conditionShow parameter says on the website
https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd
And what is "yes"?
"yes" was just what I used as the variable to put something into the _target array, but I can change it
using _target set [0, "yes"];
_target in conditionShow is not an array, but an object
Okay, new and maybe dumb question. When it says passed arguments are _target and _this does it mean I can ONLY use those, or does it just mean that they're able to be used?
Latter. I still don't know what you wanted to achieve in the condition
"passed arguments" means they're auto-generated variables provided by the function. You can use other variables too - except for local variables that were defined outside the condition code, which won't be available because they were created in a different scope.
I'm looking for a script to make a medic have unlimited first aid kits/bandages, anyone who can help me?
Hey folks,
Any reason the following wouldn't be giving all players on my server an action on the spawned box (_vehicle) to delete it? Tested on server and it appears for no-one, not even the spawning player (which a normal local addAction succesfully does of course).
[_vehicle,"<t color='#00FF00'>Store Box", {_veh = nearestObjects [s1, ["Thing"], 10] select 0; deleteVehicle _veh;}] remoteExec ["addAction",0,true];
It's part of this larger section if that helps;
_pos = [(getPosATL s1) # 0, (getPosATL s1) # 1, (getPosATL s1) #2 + 5];
_vehicle = createVehicle ["dm_crate1", _pos,[],0,"NONE"];
{ _x addCuratorEditableObjects [[_vehicle], true] } forEach allCurators;
_vehicle setDir (getDir s1);
_pitchbank = s1 call BIS_fnc_getPitchBank;
_vehicle setPosWorld (AGLToASL(s1 modelToWorld [2.535254,9.3811,0.253628]));
[_vehicle, _pitchbank#0, _pitchbank#1] call BIS_fnc_setPitchBank;
[_vehicle, Hdropship] call BIS_fnc_attachToRelative;
[_vehicle, true, [0,2,0],0] call ace_dragging_fnc_setDraggable;
[_vehicle, true, [0,2,0],0] call ace_dragging_fnc_setCarryable;
_vehicle addAction ["<t color='#008000'>Tool Box",{}];
_vehicle addAction ["<t color='#FF0000'>Unclamp Box", {_veh = nearestObjects [s1, ["Helicopter","Plane","Car","Tank","Thing"], 10] select 0; detach _veh;}];
_vehicle addAction ["<t color='#00FF00'>Clamp Box", {_veh = nearestObjects [s1, ["Helicopter","Plane","Car","Tank","Thing"], 10] select 0; [_veh, Hdropship] call BIS_fnc_attachToRelative;}];
[_vehicle,"<t color='#00FF00'>Store Box", {_veh = nearestObjects [s1, ["Thing"], 10] select 0; deleteVehicle _veh;}] remoteExec ["addAction",0,true];
_vehicle addItemCargoGlobal ["tsp_paperclip", 10];
_vehicle addItemCargoGlobal ["ToolKit", 1];
_vehicle addItemCargoGlobal ["ACE_wirecutter", 1];
_vehicle addItemCargoGlobal ["B_UavTerminal", 1];
_vehicle addItemCargoGlobal ["ACE_surgicalKit", 1];
_vehicle addItemCargoGlobal ["ACE_EntrenchingTool", 1];
_vehicle addItemCargoGlobal ["ACE_DefusalKit", 1];
_vehicle addItemCargoGlobal ["tsp_lockpick", 5];
}]; ```
You pass wrong params to https://community.bistudio.com/wiki/remoteExec.
I think I see it, another {} encasing all the addAction params?
[_vehicle,{"<t color='#00FF00'>Store Box", {_veh = nearestObjects [s1, ["Thing"], 10] select 0; deleteVehicle _veh;}}] remoteExec ["addAction",0,true];?
No, use square brackets.
There is example on addaction.
Correct way is
[_vehicle,["<t color='#00FF00'>Store Box",
{
_veh = nearestObjects [s1, ["Thing"], 10] select 0;
deleteVehicle _veh;
}
]] remoteExec ["addAction",0,true];
So close, thankyou so much!
Addaction I'm familiar with so I wasn't looking at that wiki entry for examples π More the fool me huh?
When you're rearranging things into a remoteExec, all the arguments are rearranged, not changed type. The only thing that changes type is the command name becoming a String. Arrays [] remain as arrays, Code {} remains as code, etc. so you would never change [] to {} or vice versa.
Can you tell me how to create a condition?If a certain animation is being played, then, for example, a certain sound is being played, repeating itself after, for example, 5 seconds?
I try to do this, it plays once.
(_this # 0) addEventHandler ["AnimChanged", {
params ["_unit", "_anim"];
if (_anim in ["krovosos_Run", "krovosos_Sprint"]) then {
_Krovosos say3d "bloodsucker_breath";
};
}]; ```
Π’he sound, I mean.
Although the animation is playing all the time
None sense what I was writing.
But anyway,
Your sound is played once because your event is called once.
I want someone to tell me how to write a permanent check to see if the animation is playing, and if it is playing, then the audio file should be played before the animation finishes playing.
_unit addEventHandler [
"AnimChanged",
{
params ["_unit", "_anim"];
if (!(_anim in ["krovosos_Run", "krovosos_Sprint"])) exitWith { };
localNamespace setVariable ["krovososSoundPlaybackAllowed", true];
_unit spawn {
_soundSource = objNull;
while { localNamespace getVariable ["krovososSoundPlaybackAllowed", false] } do {
_soundSource = _this say3d "bloodsucker_breath";
_time = time + 5;
waitUntil { !(localNamespace getVariable ["krovososSoundPlaybackAllowed", false]) or { time >= _time } };
};
if (!(isNull _soundSource)) then {
deleteVehicle _soundSource;
};
};
}
];
_unit addEventHandler [
"AnimDone",
{
params ["", "_anim"];
if (_anim in ["krovosos_Run", "krovosos_Sprint"]) then {
localNamespace setVariable ["krovososSoundPlaybackAllowed", false];
};
}
];
is there SQF function/command to check if object is under layer in editor ?
more specific: if object is under layer in editor which is locked
clarify: need to determine if object is under locked layer during mission
found getMissionLayerEntities
^thats the only one, plus getMissionLayers. Unfortunately there doesnt seem to be a way to get whether a folder is locked
i have played around with some options and I do need a global core object to make many of my zeus modules work with attach to and what not. I will try and play around with other options like maybe 1 big geo LOD as the core or the drawimportance named property.
can you somehow detect if current server is password locked?
There does not seem to be any scripting solution to check for a password lock. The script would have to be able to access the server's config file because there does not seem to be a way to call the server directly for a variable, only to have the server process information or call other files on the server (generally other sqfs and scripts). I've been digging and this seems to be the ubiquitous answer.
If its a server that you own or use you could probably work with the API of your server host if they have one to automatically update a file that WOULD be visible to the mission file, but that's also a lot of work