#arma3_scripting
1 messages · Page 763 of 1
Yeah
so now that the file type is correct, let me see if that fixed the fall damage thing as well
it sure seems to have!
so I just needed the whole WaitUntil part of the code, as well as actually having the file not be a .txt, and it seems to be working
Good stuff.
I still need to test it with multiple people online to make sure it doesn't just apply to me, but I think that should hopefully do it
It should apply to every player.
Yeah, it should, but I've learned it's best to not rely on Arma to do what it should x3
Thanks a ton dude
your help and patience is much appreciated
All good.
Anyone know of the simplest way to replenish AI groups with the same units they lost?
I'm thinking about creating an array for each AI group and adding each AI to the array "onkilled," and using that as the respawn. Any input on that before I try it that way?
yes it will show up in that array
oh you mean as if you were to fly through the trigger... hmmm. I'm not sure. Would have to test it
Yeah I'm wondering if the uniforms allPlayer trigger will apply to that.
It doesn't list the tasks which are set to "all players". So I'm not sure.
But I know allPlayers does include headless clients
If I find that a unit is carrying a 40mm grenade round, is there a quick way to find out if their primary weapon is capable of firing it?
BIS_fnc_compatibleMagazines
just add a side check for good measure
Add it with delay then
is there a way to return the muzzle which can fire the round?
uh...where...?
Unless there's a better way than this to force the ai to fire a specific round out of their grenade launcher: _unit selectWeapon _muzzle; _unit fire [_muzzle,_muzzle,_mag];
Search in the muzzle compatible mags
It's already obvious where...
not to me, sorry
Before you add the EH
Yes
side check returns LOGIC
i mean put a side check in your script to filter it out in case
player addEventHandler ["animStateChanged", {
if ("halo" in _this#1) then {
_this#0 setVelocity (plane1 vectorModelToWorld [0, 10, -2]);
_this#0 removeEventHandler ["animStateChanged", _thisEventHandler]
}
}]```
this?
Yes
or lets just test it real quick and see if the trigger will fire when you fly through
In order to do that I'd need a second player to wear the uniform while the virtual zeus is around
nah just make a new trigger with a hint or something and fly through it
Oh duh.
How would I convert this: sqf [_identity] execVM "\Files\check_identity.sqf"; to remoteExec? IIRC, sqf {["check_identity.sqf"] remoteExec ["BIS_fnc_execVM", 0];} executes the sqf remotely but how would I pass my variable with it?
It fired the trigger
See the pinned messages
So what would be the best way to filter out zeus?
allPlayers findIf {uniform _x isNotEqualTo "U_I_CombatUniform"} == -1;
you can add a _x isKindOf "CAManBase" or something along those lines
or check allCurators, etc
I go by typeOf _x == "VirtualCurator_F"
I'm already using the VirtualCurator_F as my Zeus
no what we are saying is checking the type and comparing it
in a DRG game atm so i can't type it out
No worries. Take your time. No rush and appreciate the help. Just still trying to get my head around it.
So if you want to ensure that whatever code/action you want to perform should not be on Zeus then you'd write it as sqf if (typeOf _x != "VirtualCurator_F") then { /* do something to units that is not zeus */ } else { /* do something to units that is a zeus */ };
(allPlayers select {_x isKindOf "CAManBase"}) findIf {uniform _x isNotEqualTo "U_I_CombatUniform"} == -1;
//or
allPlayers findIf {_x isKindOf "CAManBase" && uniform _x isNotEqualTo "U_I_CombatUniform"} == -1;
etc etc, or you can check to see if the type is a virtualcurator_f as well
Compare classnames using =, not isEqualTo
two simple questions
Do dead units take cpu usage?
Do dead units deleted with deleteVehicle take cpu usage?
why do you say? because its strict case sensitive? so more prone to error?
So if I wanted to test this on the sample trigger I'd put _x isKindOf "CAManBase" in the condition along with setting activation to anyPlayer?
No. Copy the whole thing
The 2nd one is better
I'm just using this to test an area trigger for now. Not the uniform check.
Remove that part
Tho not sure what you wanted
If you want to filter virtual stuff that won't work for you
So allPlayers findIf {_x isKindOf "CAManBase"} == -1;
First answer this
I'm trying to configure a trigger to fire when all players except for the zeus are wearing a certain uniform.
First solution was just to put zeus on a unit already wearing the uniform and remove the model.
Which worked fine.
But I thought a virtual zeus would be better.
So what do you want to happen now?
I was creating an area trigger to test whether or not the virtual zeus was considered a player to see if it would fire when the zeus flew into it. It did.
So that's how I knew I'd have to filter the zeus out if I wanted to use a virtual one.
And I was just going to try to use the area trigger as a way to learn concepts rather than just copying and pasting stuff.
thisList findIf {!(_x isKindOf "VirtualCurator_F")} != -1;
Wait the class is wrong
It was virtual zeus 
Ok fixed
Test now
Works
So then using the uniform check script filtering out zeus players the code would be allPlayers findIf {_x isKindOf "CAManBase" && uniform _x != "U_I_CombatUniform"} == -1;?
allPlayers findIf {!(_x isKindOf "VirtualCurator_F") && uniform _x != "..."} == -1;
Put the uniform class in ...
Wasn't sure if Virtual curator is a CAManBase 
Right. So just to clarify. The one I listed checks to see if player is CAManBase and then the uniform, and yours checks to see if they're not VirtualCurator_F, right?
Come to think of it this won't work 
It triggers even if there are no players present
Aren't there always going to be players present though?
No. There are no players in empty dedi
And also even if you have just the Zeus it triggers
I spawned in as zeus and checks the trigger and it didn't fire
But it also won't assign the task to a zeus.
So the trigger isn't checking yet.
you want the task as zeus too?
No.
Not needed.
I mean beyond knowing when the task succeeds I guess.
Which is interesting because the taskAssign module is set to all playable units
Do this instead:
count allPlayers != 0 && {allPlayers findIf {!(_x isKindOf "VirtualCurator_F") && uniform _x != "..."} == -1};
That can't be right
Unless you've set the trigger as area and didn't even move into it 
The trigger for the task isn't an area. It's just a trigger that's set to fire when all players are wearing a uniform.
you have the trigger set to "Anybody" right?
I didn't have any activation set at all. It just fires when the condition is met.
Right nvm
It works with zeus
But not if server's empty
I'm gonna test the revised one with a friend now. I'll let you know how it works.
you can open multiple instances of your game btw
Ah okay. I have my launcher close on opening the game. Forgot I can do that.
trying to do a stress test, anyone has an idea about the answer for these?
they still count as objects
once deleted they cease to exist so less
@little raptor @fair drum seems to work fine. Is there any way to get notification of tasks being complete as a zeus on a neutral side?
if you gave him the task to begin with, he will see the changes
I have the owner set to "all playable units" right now. I don't see an "anybody" option.
Corpses are pretty expensive on client perf.
oh on the task owner?
should be fine then
well
do corpses send any orders or anything of sorts?
or do they only remain inactive until they prompted to ragdoll?
On the client side it should just be rendering. Still expensive apparently.
well, plus a bit of AI spotting as that runs everywhere and I think they still check corpses.
what is the best way of deleting units corpses (is there anything better than deletevehicle for that matter)?
deleteVehicle is fine.
nothing better?
Nope.
Players on Blufor see it fine but I as virtual zeus can't.
You also want to delete all the weapon holders that they create.
Try assigning the task to yourself too
Maybe it works that way
If not just show the notification manually
yep, how do I exactly do that
wanted to ask about dropped weapons too
{ deleteVehicle _x } forEach (allMissionObjects "WeaponHolderSimulated");
you can do "WeaponHolder" too but I think all the dropped ones are WeaponHolderSimulated.
is there a page with all these types?
What, like documentation
because I can't find "WeaponHolderSimulated" on
https://community.bistudio.com/wiki/allMissionObjects
yep
This is Arma :P
really depressing since I always have to come here and ask how to filter objects because I don't know their types
like "Air" and "Land" etc
do you think I should use vehicles for this purpose?
because wiki says allMissionObjects is heavy
from https://community.bistudio.com/wiki/vehicles
It will also return "WeaponHolderSimulated" of dead bodies (weapon on the ground).
if vehicles is less preformance heavy than allMissionObjects
vehicles is dirt cheap but filtering it won't be.
oof
Depends how often you do it really.
allMissionObjects used to be really slow but I think it was improved in 2.08?
yeah documentation is kinda dated but Idk
I will just test code preformance and see for myself
thanks
Someone here did have the cute idea of detecting dropped weapon holders using the "Put" EH on the killed unit.
haven't tried that personally though.
will add that to my stress test list then
and I hope it remains cute for 800 units
Does anyone know if there's a CBA discord server? Or alternatively, does anyone know why AI stop shooting at CBA invisible targets after the target is moved?
just use allmissionobjects
get your stuff working and complete and then optimize
the 800 units is the elephant in the room
find a way to give players the same experience with fewer spawned units
yeah they are not all spawned at the same time tho
that's the total through the entire mission
hey anyone knows how to toggle the rhs c-130s cargo lights with a script?
also leopard, worked beautifully btw, forgot to thank you 😅
so thank you
I think you should use
And look for an animation that has to do with lights
Then use
https://community.bistudio.com/wiki/animate
To animate it
where do i put this in?
Try looking at the aircraft in question and using
copytoclipboard str(animationnames cursorobject);
It should copy the animation names
so i put that, into the uhhh debug console
didnt work
nvm
got it
i just had to it in game
Send?
"jumplight_red_hide","jumplight_green_unhide","jumplights_hide"
so red is on by default, but there is none for jumplights red unhide
Hmm
I'm not sure why is that the case
and no only 1 name has red in it
Well
Try
object animate [animationName, 1, true];
Replace object with the vehicle
And animation name
With each one of these
See which one does the desired effect
how come?
So try all
Its a mod
ik, but it looks pretty obvious on what each one do
Yea
Just try all combinations
Is what I'm saying
In case something doesn't work
ok
So basically find the right combination
If you try everything
And nothing changes
Maybe try changing that 1 to 0
sitrep over
does anyone know of a way to remove tank tracks? damaging them only makes the crew dismount, whenever i set the hull texture to invisible theres kinda just floating tracks
I don't think they can be hidden unfortunately
fugg
Like
Go try hiding texture for any trackes vehicle
It does not work unfortunately
you can hide the tracks
if you wish to convert the tank into a simple object
unfortunatly i need it as a working object
no luck then
Is there specific method to make aircraft ai follow waypoints after taking off? In my test it just flies straight forever into the sky.
createVehicleCrew _vehicle;
for "_idx" from (count WEST_UAV_PAT_WPTS)-1 to 0 step -1 do {
(group (driver _vehicle)) addWaypoint WEST_UAV_PAT_WPTS select _idx;
};
_vehicle engineOn true;
(group (driver _vehicle)) setCurrentWaypoint [(group (driver _vehicle)),1];
it doesn't even take off unless engine is turned on manually
Hey how would a script look for moving an object smoothly?
Tried searching a for a bit, maybe just searching for the wrong words, but is it possible to get the current players weapon object, and therefore their muzzle position?
you can't get the position of a muzzle
Yes you can. With a bit of complicated script
😮
do you have an example
How complicated lol
I couldn't find a method
Like too complicated than it should. Let me write my method
all i can think is getting the position of a projectile when it's fired
which obviously isn't accurate to a muzzle position
- Create a dummy Simple Object
- Fetch the position of the object using config and
selectionPosition - Fetch the weapon pos/vectorDir, Up
- Sum it all
oh dear
See? Complicated
I'm not on my PC so can't write sqf but the idea is it
I can assist tho
what do you need the muzzle position for is a good question to ask first
Tru
Sure, ik the tiow mod does something similar ,but I wanted to spawn a charging laser at the weapons muzzle. RN it all works but spawns at the eye pos lol
@open fractal
ah yes, the classic laser problem
I was hoping maybe there was a command to get weapon object, that would help solve it all, but there isnt
also could help make minigun spool too, but the laser is a nice cherry on top lol
charge laser/ spool minigun kinda of same idea
Really thought there was a command to get a players weapon object
not for held weapons
dang, I think I mixed it up with unitBackpack
funny how u can get backpack object lol
idk what a charging laser is but an alternative would be adding effects with a fired event handler
I mean like u gotta hold the left mouse button to charge it up (in my case just left click and a second later it shoots) hence why I cant really on fired EH cause it happens after the charging
i think you'd need to make a mod for that
what you mean?
an addon
you can't create weapons with just sqf
well you can, sort of, but it won't look or feel organic
you'd have to do things like detect left click actions and delete bullets and (inefficiently) draw a laser while checking line intersections
why would I need to create a weapon?
isnt that essentially what you're trying to do?
I am usin https://community.bistudio.com/wiki/drawLaser to make the laser it self, and everything regarding charging works, just need that starting position, the first argument of drawlaser to be at weapon muzzle
drawLaser is flawed
you can't see the color in overcast weather
it sounds like you want to get the muzzle position on every frame. idk what polpox can cook up but that's a challenge
is this ticket visible to teh public?
oh okay cool
How do i deactivate a trigger. Not delete it.. Deactivate it. I cannot find any documentation on it all.
@sudden yacht Set its condition to false?
@cosmic lichen I will look into it.
setVelocityTransformation every frame
oh boy
You can
@open fractal
@shadow canopy
The sacred texts
@cosmic lichen So i figured it out. The trigger becomes deactivated when all sides/objects specified exit it automatically.
Wouldn’t creating and deleting a simple object on each frame be a big ask?
who's creating and deleting it every frame? 
Me.
Is there another way to force players into free look other than locking them in an animation?
Try stacking unload display event handler next time
do we have any idea why lobby slots can "break" and leave the player stuck on "receiving data"?
even next person to join into that slot will get stuck
only solution then is to join a different slot
with that bug present, we cannot have "skipLobby" enabled, since all joining players would get joined into the broken slot and they would not be able to switch to a working slot
Trying to let the group AI switching to rifles except for the player. Any idea why they don't switch weapons?
_x selectWeapon (primaryWeapon _x);
}forEach units group player;
hint "Switching to rifle";```
AI don't switch weapons
sorry, what do you mean?
I mean they select their weapon automatically
but you can force them to switch, no?
no
_x selectWeapon (handgunWeapon _x);
}forEach units group player;
hint "Switching to handgun";```
for example switches to handgun for player and group AI
I am just trying to exclude the player and just let the Ai switching weapons
what you wrote there misses {
it's temporary
they always select whatever they want
ah i see
got it
count your braces
that's unfortunate because sometime the group AI switches to handgun although there are no enemies close by
no idea why they do that
actually you miss both { and }
so count is correct rn
but anyway the code is wrong
think i fixed it
_x selectWeapon (primaryWeapon _x);
}}forEach units group player;
hint "Switching to rifle";```
but it's obviously useless if the AI switches automatically once they engage
yes
If i put them into disengage they stay with the weapon selected?
I don't think so. by engage I mean "firing at enemy". not those command menu things
but you can try
¯_(ツ)_/¯
is there a way to get all variables currently present on a unit/player?
allVariables
Bear in mind that other mods can and will put variables on units, so it's normally only useful for debugging.
The code you posted if you skim over the important bits 🧠
I'm not doing that every frame
(he skimmed over the important bits)
Does vehicles include dead vehicles?
yes
hey, so I'm using { commandGetOut _x } forEach units group player in a trigger to make my teammates dismount from a helicopter, as "Transport Unload" waypoint works only on my unit. However this makes my character give one command per person, how can I script it so I give order to everybody to dismount instead of "X - dismount" one after another?
manual counterpart of what I want to achieve is to select whole team with ~ and make them dismount, but I cannot find a command that would do the same, GetOut action is non-verbal
commandGetOut units player
😩
tho you might want to not give command to yourself 🤣
commandGetOut (units player - [player])
Is there a way to let the AI use their weapon lasers without being in combat mode?
no. that's hardcoded behavior
you can't, but you can override some AI attributes so they don't target anything, shout or lay prone
you can draw a laser manually tho... 
Thanks, i'll look into it
hey, how can i compare if two images have the same texture set with setObjectTextureGlobal
something like:
if (texture image1 isEqualTo texture image2) then {};
i know about getObjectTextures but i cant get it to work somehow, maybe an example?
a single texture or all?
yes single texture
getObjectTextures _obj1#_textureID == getObjectTextures _obj2#_textureID
that works thank you!
I'm working on a multiplayer mission and I would like to implement a check within my function of a player's distance from an AI. Once true then the AI does an animation, picks a weapon up and then join the player's team. What would be the best way of doing this? This is what I have done so far: ```sqf
waitUntil {count (allPlayers select { _x distance _hostage < 2 } select 0) > 0};
It just seems like this could be done much simpler then what I've done.
not simpler, but faster
first of all if you only want at least 1 instance of something, don't use count/select. use findIf
second of all, in this case since you're checking distance/area you can use inAreaArray
so the fastest version of what you wrote is:
count (allPlayers inAreaArray [ASLtoAGL getPosASL _hostage, 2, 2, 0, false, 2]) > 0
If you're fine with 2d distance then it's a fair bit simpler :P
So how would a findIf approach look?
findIf is gonna be a lot slower for that case, because most of the time there won't be anyone near the hostage.
oh, ok, defiantly don't want that then.
Now how would I go about getting the ai to join the player's group from ```sqf
count (allPlayers inAreaArray [ASLtoAGL getPosASL _hostage, 2, 2, 0, false, 2]) > 0
As of right now I have this bit of code for that: ```sqf
[_hostage] joinSilent group (allPlayers select { _x distance _hostage < 2 } select 0);
Store the array returned by inAreaArray and pick the first one.
It's not a good idea running the search twice because if it's scheduled then the two calls may actually return different results.
In some cases you can get away with it, but it's still bad code :P
Fair enough, the first part of code that counts the players is wrapped in a waitUntil and my code to have the AI play an animation, pick up a weapon and join the player group come after it. So would that interfere with storing the array?
allPlayers findIf { _x distance _hostage < 2 } > -1
also now that I look at this again it's wrong
you have an additional select 0 which selects an object
and you're counting an object
so it would never work
private _nearPlayers = [];
waitUntil {
sleep 1;
_nearPlayers = allPlayers inAreaArray [ASLtoAGL getPosASL _hostage, 2, 2, 0, false, 2];
count _nearPlayers > 0;
};
[_hostage] joinSilent group (_nearPlayers select 0);
So this is what the code looks like now: ```sqf
if (!alive _shooter) exitWith {
waitUntil {
sleep 1;
_nearPlayers = allPlayers inAreaArray [ASLtoAGL getPosASL _hostage, 2, 2, 0, false, 2];
count _nearPlayers > 0;
};
_hostage playMove "acts_executionvictim_unbow";
sleep 5.7;
_hostage enableAIFeature ["MOVE", true];
// _hostage setCaptive false;
[_hostage] joinSilent group (_nearPlayers select 0);
};
need to pre-declare _nearPlayers otherwise it might be overwriting something back down the scope.
IIRC you don't need to set it to anything but I'd have to check.
Yep, I have that in the top of the function
k
Why sleep doesn't work in OnActivation of a trigger?
Now my next question is that you have a sleep within the waitUntil, the if statement is already wrapped inside a while loop that counts down the time every second, which has a few checks via if statements, so would I need that sleep command?
Here's the entire function: https://pastebin.com/EmpP3Mj7
@broken forge In that case the structure is wrong and you shouldn't have the waitUntil.
oh, it's a state machine that's not written as a state machine. Never mind :P
yeah you still want the sleep in the waituntil.
Because once you're into the inner stage (shooter dead) you still don't want to be spamming the scheduler, ideally.
In this case I doubt you're running more than one of them so it doesn't really matter, but it's good practice.
Because triggers run in the unscheduled environment. You can learn more here: https://community.bistudio.com/wiki/Scheduler
@granite sky Thanks for the info, I'll keep it in then since it's good practice. My next question is to do with a trigger placed in the Eden Editor for a different function. This function is one to capture an HVT, as of now I have this for the condition: ```sqf
alive civ_hvt_0 && { _x distance civ_hvt_0 <= 10 } count allPlayers > 0;
Is there a better approach for this?
@winter rose would what you wrote work best for this? ```sqf
allPlayers findIf { _x distance civ_hvt_0 < 10 } > -1;
hi all so im trying to make a simple technical using an offroad (named "tahoe") and a static mg turret, my script works fine in singleplayer but when i attempt to use it in multiplayer it either violently explodes, shoots off into space or falls off the back of the offroad truck. im guessing im doing something wrong not quite sure what im missing. 🤔
if (isServer) then { [this, tahoe] call BIS_fnc_attachToRelative };
@broken forge inAreaArray is almost certainly better again.
Although triggers have distance checks as a built-in, so normally you'd structure them to use that.
@granite sky So this would the best option: ```sqf
count (allPlayers inAreaArray [ASLtoAGL getPosASL _hostage, 2, 2, 0, false, 2]) > 0;
in this case civ_hvt_0 instead of _hostage and 10 instead of 2.
Ok, would you be open to a private chat, I have a few other things that I would like to go through, and I don't want to clutter up the chat channel here, so others can get their questions in and answered
didnt work and the main issue is that the Turret ISNT attaching in multiplayer
works fine in singleplayer but soon as its put on a server it straight up refuses
what's the locality of the two objects?
one is a truck and the other the static turret is in the bed on the back of the truck
If I'm trying to call/spawn a function that has some animations that the AI do, would I use [params] remoteExec ["functionName"]; or would the [params] spawn functionName; work fine for that?
depends where and if local or not
@fair drum Ok, so because the mission is multiplayer I should use remoteExec?
its deeper than that.
oh thank you, I guess I have to look for another way around
this looks like it was written for the server itself as its using global effect commands. so run it on the server
if you’re trying to time it with the end of the animation consider adding an event handler to the unit (I think animchanged?)
@fair drum I have a few other functions that I created to that I could link for you to check if you'd like. @open fractal I'll have to look into that, I would prefer that over using the sleep command.
also, your playsound is going to be something you will have to remoteExec as it is local
See animDone as well
@open fractal I think the AnimDone would be the EH that I would want to go for. I'm just not certain on how to implement an EH within the script yet.
you can just do _unit addEventHandler before the animation
@fair drum Here are a few links to the functions I created if you're up to checking them really quick and let me know what they require.
https://pastebin.com/pH9mtV5E
https://pastebin.com/Rwx3bbw6
https://pastebin.com/4mUyrFxC
where are you running these and do you know how to tell if a command is local/global?
and are you using a headless client
They're all for a multiplayer mission and no headless client
You can just spawn your code from the On Activation field, that will allow you to use sleep.
Much obliged!
this should tell you what you need to know
for example https://community.bistudio.com/wiki/engineOn says Local Attribute Global Effect
this means the command must be executed where the vehicle is local
which would be the server if it’s driven by server-owned ai or the driver’s machine if a player is the last one to drive it
So the engineOn doesn't work with how I have it setup. I just have the hvt driving the vehicle and once a player is in range to shutoff the engine
that depends where you’re running it
if the hvt is a player then you need to execute it on the player’s client
if the hvt is a server ai then you execute on the server
The hvt is an AI so would it work then
where are you running the code
_acre2Group = createGroup sideLogic;
"acre_api_basicMissionSetup" createUnit [[0,0,0], _acre2Group, "this setVariable ['BIS_fnc_initModules_disableAutoActivation', true, true];this setVariable ['DefaultRadio',"""",true];this setVariable ['DefaultRadio_Two',"",true];this setVariable ['DefaultRadio_Three',"",true];this setVariable ['DefaultRadio_Four',"",true];"];```
Anyone spots any issues? This doesn't seem to work and I don't know why. No error is returned.
I have a trigger that when a player is detected, to then execute the function
yep, that is checked
then it will work
if you want a specific command or function to run on a specific client that’s where remoteExec comes in
pay attention to the effect logo in the wiki pages
if you also set a trigger to server only and it runs a command that has local effect for example playsound, you will have to remoteExec that on every client too
or else it will just play for the dedicated server/hosting client
for example, you have code running on the server where you have a line for the engine of a car driven by a player to turn on
[_car, true] remoteExec [“engineOn”,_car]
this will execute the engineOn command with [_car,true] arguments on the client that owns _car
you can also do this with whole functions
if you want to have everyone hear a sound you do
“SoundName” remoteExec [“playSound”]
Since playSound is local effect
just please check if the command has a global effect, if it does there is no need to remoteExec, it will lag the server and cause unneeded behavior
such as createVehicle
yeah this
basically check the locality behavior for every command you use and adjust your code accordingly
you’ll have them memorized if you write enough sqf
one of my first experiences with SQF was putting playSound3D in a trigger without checking server only. playSound3D is global attribute/global effect so the sound played 7 times simultaneously (once for every client) and it sounded horrible
i'd post this in the acre discord or slack or whatever they use
I'm trying to run some code on all groups on OPFOR. Would this be good syntax?
{
if (side _x == opfor) then {
//code to run
};
} forEach allGroups;```
should be
0.1127 ms vehicles
0.3146 ms allMissionObjects
oof
thats how much it took to filter "WeaponHolderSimulated" using each one
i think weapon holders may show up on entities, not sure though
https://forums.bohemia.net/forums/topic/238073-waypoint-stop-turn-hold-script/?tab=comments#comment-3457058 you mathematically construct anim, then execute with unitPlay.
well can I use that to filter blood drops?
its just a getter, just like vehicles/allmissionobjects etc but its faster than your allMissionObjects
yep
but
I'm using entities "#slop"
it doesn't return blood drops
entities does seem to include WeaponHolderSimulated (but not WeaponHolder)
so yeah, entities "WeaponHolderSimulated" should be the fastest method.
yep just checked it out
but what about blood drops?
i don't want to use allMissionObjects
Don't those typically have their own garbage cleaning?
like, I can't just manually delete them?
you probably could but if they're gonna be deleted anyway after a few minutes then you may not want to.
Depends on the entity manager settings.
i can't trust that really
there is a cas pilot
he can easily murder 60 units in one swoop
I'm trying to update the spawnHostage function to use an EH instead of sleep and been successful at showing a hint, but not when trying to get the unit to join the players group and picking up a weapon
I would guess that's an issue with how you're referencing the unit?
joinSilent itself isn't picky about where it runs.
if (!alive _shooter) exitWith {
waitUntil {
sleep 1;
_nearPlayers = allPlayers inAreaArray [ASLtoAGL getPosASL _hostage, 2, 2, 0, false, 2];
count _nearPlayers > 0;
};
// sleep 5.7;
_hostage addEventHandler ["AnimDone", {
params ["_unit", "_anim"];
_anim = "acts_executionvictim_unbow";
systemChat format ["%1 has finished %2.", _unit, _anim];
_unit removeEventHandler ["AnimDone", 0];
[_unit] joinSilent group (_nearPlayers select 0);
_unit addWeaponGlobal _hgun;
_unit addMagazines _hgunMags;
_unit enableAIFeatures ["MOVE", true];
_unit setCaptive false;
}];
_hostage playMove "acts_executionvictim_unbow";
{ _shooter removeWeapon _x } forEach weapons _shooter;
{ _shooter removeMagazine _x } forEach magazines _shooter;
};
Yeah so the trouble is that _nearPlayers (and _hgun etc) don't exist inside the EH.
If you only want to delete units killed by plane, you can do that in the Killed EH.
{
deletevehicle _x;
} forEach allMissionObjects "#slop";
it doesn't delete them, damn
no not that, i want to delete the blood drops and explosion carters etc
You realise perf will probably go up when 60 guys get murdered anyway :P
sorry what is perf (nvm got it)
@broken forge You'd need to make those vars accessible within the EH, for example by using setVariable on the unit.
@granite sky So how would I pass the hgun, hgunMags, to the EH? I already have them at the top of the function, do I need to make them global for the EH to find them?
Globals would also work but less-then-ideal.
So what would a setVariable look like for the loadout: ```sqf
_ld0 = getUnitLoadout _shooter;
_hgun = _ld0 select 2 select 0;
_hgunMags = _ld0 select 2 select 4;
IIRC entity manager culls based on quantity and chronological order, so that should not be a problem.
Look at Attributes -> Performance -> Garbage Collection in editor.
Example:
_hostage setVariable ["nearPlayer", _nearPlayers select 0];
_hostage setVariable ["handgun", _hgun];
_hostage setVariable ["handgunMags", _hgunmags];
And then in the EH you can do private _nearPlayer = _unit getVariable "nearPlayer" for example.
@drifting portal I would have to assume blood get culled with the bodies, but you can also test it with a script that spams units and instantly kills them... see what happens when the limit is passed.
slightly fancier way:
_hostage setVariable ["hostageVars", [_nearPlayers select 0, _hgun, _hgunmags]];
then in EH:
(_unit getVariable "hostageVars") params ["_nearPlayer", "_hgun", "_mags"];
The AI isn't joining the group
the blood pools, slowly fade
thats what I have noticed
they take like 4 minutes
but when limit is passed they are immediately deleted
so good I guess
limit is about 200 units
_hostage addEventHandler ["AnimDone", {
params ["_unit", "_anim"];
_anim = "acts_executionvictim_unbow";
systemChat format ["%1 has finished %2.", _unit, _anim];
(_unit getVariable "hostageVars") params ["_nearPlayer", "_hgun", "_hgunMags"];
[_unit] joinSilent (group _nearPlayer);
_unit addWeaponGlobal _hgun;
_unit addMagazines _hgunMags;
_unit enableAIFeature ["MOVE", true];
_unit setCaptive false;
_unit removeEventHandler ["AnimDone", 0];
}];
you’re setting _anim, you want to check if _anim matches your animation
@open fractal How would I go about that, would I just add this == ?
yeah that would return a Boolean, you then want to incorporate it into an if () then {} statement
if (_anim == "acts_executionvictim_unbow") then {}
well, != plus exitWith would be cleaner.
Just changed that, so what would be causing the issue of the AI not joining the group, he does everything else.
Including the gun?
yep
I am trying to use serverCommand via script to automatically kick or ban on dedicated server.
"password" serverCommand format ["#kick %1","Ceee"]; //works
but i cannot get the banning to work. Can anyone help me out with this?
"password" serverCommand format ["#exec ban %1","Ceee"]; //does not work
the problem would have to be _nearPlayer then
have you made sure that variable is properly passing a player unit
you set the body limit to 200?
systemChat format ["_nearPlayer: %1", [_nearPlayer, "nil"] select (isNil "_nearPlayer")];
@broken forge toss this in there if you haven't already debugged it
no, I meant the engine starts immediately deleting blood pools at about 200 units dead
@open fractal it returned _nearPlayer: nil
nothing is being passed as _nearPlayer then
so either you didn't setVariable correctly or give inAreaArray the correct parameters
you can use systemChat or diag_log to see where the issue is happening
This is what I have at the very top of the function: ```sqf
params ["_hostage", "_shooter", "_time"];
private _nearPlayers = [];
_ld0 = getUnitLoadout _shooter;
_hgun = _ld0 select 2 select 0;
_hgunMags = _ld0 select 2 select 4;
_hostage setVariable ["hostageVars", [_nearPlayers select 0, _hgun, _hgunMags, _shooter]];
Here's a link to the full code: https://pastebin.com/WqUhfWS2
you're setting the hostageVars variable before actually defining the arguments
put ```sqf
_hostage setVariable ["hostageVars", [_nearPlayers select 0, _hgun, _hgunMags, _shooter]];
right above addEventHandler
it seems to be working now, but still saying nil for the return, nevermind I had to move the systemChat format down below the ```sqf
(_unit getVariable "hostageVars") params ["_nearPlayer", "_hgun", "_hgunMags", "_shooter"];
Hello. I have one problem. My project uses a ticket system with players respawning. I would like to make a good protection against relogs, since when leaving the lobby and entering the server, the respawn time counter is reset. Now I have a banal system, and a very aggressive one:
Description.ext
onPauseScript = "antirelog.sqf";
antirelog.sqf
if (!alive player) then {((findDisplay 49) displayctrl 104) ctrlEnable false;};
I forcibly disable the "cancel" button at the time of respawn, but I use ACE and at the moment of unconsciousness of the unit, you can press another button called "abort".
I have two options: aggressively prohibit pressing the "abort" button as well (I don't know how to do this), and the second: I need help, who could help me so that when I leave the server at the time of the respawn timer, the server remembers the time player, and when entering the slot (even to another one), he could not appear and the timer was resumed for this particular player.
I would like the second option.
If it's not difficult, can someone help me with this?
It turns out that I have to somehow remember the time left before the respawn for the player?
Use PlayerDisconnected first?
Hey guys, how would I attach a laser to the rifle of a squad AI?
do you mean the actual attachment or a custom laser
the actual attachment
Can I change the value of respawnOnStart already in the mission after the freeze time?
I need to change from -1 to 0, but already in a running mission.
addPrimaryWeaponItem
they can't turn it on unless in combat tho
But they can turn on the laser in combat mode?
Is it possible to create Zeus modules and assign sub-modules entirely by script? I am trying to make an RTS interface based on Zeus that requires no editor setup (activated through a dialog in-game). I can create the ModuleCurator_F entity and then add player-side groups by script. However, when I do _module setVariable["addons",0];, it still gives the option to create groups and objects under the Create menu. Also, I am spawning in ModuleCuratorSetAttributesObject_F and other sub-modules, then trying to link them with _module setVariable["curator",_curator]; (where _curator is the spawned ModuleCurator_F entity). However, this does not work, the values I assign to the sub-modules do not take effect. When I replicate all of this with modules placed in the editor, I can get the result I desire (Zeus as an RTS interface, with the ability to modify stance, speed etc, but not damage/deletion).
My questions:
- Is it possible to create Zeus modules and assign sub-modules entirely by script?
- Is there a way to limit edit ability without spawning the sub-modules (for example, disabling the Create menu entirely or assigning variables to groups instead)?
yes
Sorry iphone correction
you can add any weapon attachment
yes
However, this does not work, the values I assign to the sub-modules do not take effect
make sure you execute the code in unscheduled environment
also better use the other syntax of createUnit to create modules
Do I need to remove an existing item in the weapon slot first before attaching the laser. Let’s say I have a light attachment in the slot. Or does it just override?
afaik it overrides
Thank you Leopard
Great, thank you
Thank you, the core module is working fine now. I am still having trouble linking the spawned sub-modules. In the spawn script, after I spawn the core module, I use this code to get the string to apply to other modules:
_m=(units _group)select 0; private _curator=str _m;
Then as I spawn each sub-module I use this code:
_m setVariable["curator",_curator];
It doesn't seem to link the modules though. Any ideas? I can post the whole .sqf if need be.
get the string to apply to other modules:
that's just wrong
you can't convert objects to string
_m setVariable["curator",_curator];
where did you get this variable?
is that even used by the module?
Not sure if this is the right place to put this, but if anyone has any experience with setting up servers would be interested in assisting me, i would greatly appreciate it
I have been using allVariables on each of the relevant modules to see the variable names. If I use the object, it gives an error saying that curator should be a string.
I assumed that the curator variable is what ties them all together.
well even if it has to be a string it can't be that string
then give the curator a variable and pass that variable name as string
synchronizeObjectsAdd did the trick. It is all working as desired now. Thank you very much for your help 🙂
Consider the below snippet: ```sqf
_mystring = "Land_OfficeCabinet_01_F,Land_ArmChair_01_F,OfficeTable_01_old_F"; // this will be generated or manually entered by user (without spaces with commas)
_myarray = _mystring splitString ",";
Now, when I try to spawn an object using the classname from ``_myarray`` it also includes the ``,`` with the classname resulting in: ```
Cannot create non-ai vehicle Land_OfficeCabinet_01_F,``` How'd I fix this?
I thought the splitString will remove the , from the string before adding it to the array
It does. The error probably isn't where you think it is.
finally figured out that I added in a space
that threw this error
Grv_i=0;
{
{
_equip = _x spawn ASG_FNC_RLIGear;
waituntil {scriptDone _equip};
_x addEventHandler ["Killed", {
//add to deadpool (select Grv_i append _x)
All_Grvs select Grv_i append [_x];
}];
Grv_i = Grv_i+1;
} foreach units _x;
} foreach [RD11];
Why isn't this working (Specifically "All_Grvs select Grv_i append [_x];")?
Getting: Error zero divisor
All_Grvs = Grave (2D Array of units)
RD11 = type Group
If it's supposed to use a different index (Grv_i) value for each unit then it's not going to work as intended.
Also _x doesn't exist inside that event handler.
Grv_i is to represent an Array of "dead" units in the Array All_Grvs
I think my problem is the scope of _x as you mention
The goal is to add the "dead" unit to a "grave" Array in order to be respawned later
according to the wiki, you have the following params available in this EH
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
}];
if you just want to append the unit to the dead units array, just do
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
All_Grvs pushBack _unit
}];
Grv_i is a global variable in your code
and it's always going to equal the number of units in your group (it looks like)
although you're going to end up with an array of objnulls
so im actually a bit confused on the usefulness of that array
Thanks but I'm doing it on a prop, will that work?
I'm having some problems with my tasks not working correctly for a demo in multiplayer. I have a parent task to Find and Rescue a Hostage which has three child tasks to be completed for the parent task to succeed.
1.) Download intel from a laptop
2.) Rescue the hostage before time runs out
3.) Escort the hostage to safety.
The first task succeeds when my hackLaptop function completes and set a global variable hackComplete = true. So in the trigger I have Condition: hackComplete and then On Activated: [params] remoteExec ["jas92_fnc_spawnHostage"];
Which does spawn my function, but it doesn't set the task to succeeded. Then the next task never shows up, it's just skipped to the last task which is to Escort the hostage to safety. Once the hostage is at the waypoint this task succeeds and the parent task succeeds as well. But I don't see the other two tasks listed.
Now if I were to host the mission myself all the tasks show up and complete like intended. So what would be causing the issue(s) stated above? Here's a link to my function: https://pastebin.com/LwDED2yc
From what I understand the first task fails at checking if hackComplete is true
so player can hear VoN while tabbed out of game. are there any sounds that can be heard out of game as well?
how are you setting up the tasks?
I don't see anything in that function related to the task framework
also is the trigger set to server only?
The function is called via addAction on the laptop. Then each child task has a create task, task state, and trigger synced, none of the triggers are server only.
why are you using remoteExec in a global trigger
The function that is being called has two AI that start playing an animatoin
?
From what I understand if there's an animation being played in a multiplayer environment, you have to use remoteExec, I could be wrong though
afaik there's no command that always requires remoteExec
commands like switchMove and playMove take a local attribute, so you have to execute on the server for server ai*
So I can just use a [] spawn functionName?
ok, I'll change it, for the first task trigger it is setup as followed. Condition: hackComplete
On Activation: [params] spawn jas92_fnc_spawnHostage;
This trigger is then synced to a succeeded task state, which is synced to the task. The trigger is also synced to the next child task
I'm not sure what the issue may be with the tasks, but to go with your hypothesis about the variable try adding publicVariable "hackComplete"; to your function
that will set hackComplete to true on every machine
given that it's being set to true for just the client
you can just throw that line in after the variable is set
Thanks again, that fixed it
Oh cool, just got back lol. thanks I will take a look at this. I suppose there wouldn't be a way to suggest a new command for arma to be able to get the object of a units weapon for version 2.11+ lol.
Anyone have any ideas on this block?:
/* RESPAWN ALL SIDES UNITS ON ANY SECTOR CAPTURE */
{
_unitType = typeOf _x;
_unitNew = createVehicle [_unitType, (getPos RRPD), [], 0, "CAN_COLLIDE"]; // recreate the unit.
[_unitNew] join RD11;
} foreach All_Grvs;
//Clear Grvs array
//All_Grvs deleteRange [0, ((count All_Grvs) -1)];
All_Grvs = [];
PublicVariable "All_Grvs";
All_Grvs is an Array of unit type objects.
Adding to and clearing the Array functioning fine.
But failing on call to typeOf:
"Error units: Type Array, expected Object,Side,Group"
Couldn't find a good ambient search light script that didn't run in some unscheduled forever loop and generate a ton of traffic... so i attached a spotlight to a dying VR soldiers head, and hid the model... just in case anyone needs a good face palm...
#include "script_component.hpp"
if (!isServer) exitWith {};
private _logic = param [0, objNull];
_logic spawn {
_this setDir random 360;
_light = createSimpleObject ["A3\data_f\VolumeLight_searchLight.p3d", getpos _this, true];
_fakeanimsoldier = "C_Soldier_VR_F" createVehicle getPos _this;
_fakeanimsoldier isDamageAllowed false;
_fakeanimsoldier isStaminaEnabled false;
hideObject _fakeanimsoldier;
sleep random[3,4,7];
_fakeanimsoldier switchmove "AinvPpneMstpSrasWpstDnon_G01";
_fakeanimsoldier setAnimSpeedCoef 0.5;
_fakeanimsoldier attachTo [_this,[0,0,0]];
_fakeanimsoldier disableAI "ALL";
_fakeanimsoldier enableAI "ANIM";
_light attachTo [_fakeanimsoldier,[0,0,0],"head",true];
};
Well it is telling you that All_Grvs is infact an array of arrays. Where is it being set and how?
Initial declaration:
All_Grvs = []; // Array of dead units.
PublicVariable "All_Grvs";
Append Array, where RD11 is a Group
{
{
_equip = _x spawn ASG_FNC_RLIGear;
waituntil {scriptDone _equip};
_x addEventHandler ["Killed", {
//add to deadpool;
//select Grv_i append _x
All_Grvs pushBack _this;
PublicVariable "All_Grvs";
}
];
} foreach units _x;
Player HCSetGroup [_x,""];
} foreach [RD11];
You are adding the _this array of arguments to All_Grvs. Why not just only the new body?
The new body?
We want the respawn to be of same type and group
Just get only the killed unit and store it's type? https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed
Don't see why you are storing all arguments of the EH for just a respawn script.
Thank you for your help, we will review this. We were under the impression that in the context _this would be of type unit. The point was to keep the unit calling the EH in an Array.
_this is an array of params
No _this is just the argument array. It is so in all contexts.
i sent some code earlier
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
All_Grvs pushBack _unit
}];
you can get the unit loadout using getUnitLoadout as well
so if you just want the unit loadout, try getUnitLoadout _unit
and then the inverse, you can use setUnitLoadout
Aaaaah I see now, we just reference with _unit instead of _this
No. No.
Great to know about getUnitLoadout!
Index the _this array and get the _unit reference. Either with params or select
[apple, pear, orange] call {
_this select 0; //apple
_this select 1; //pear
_this select 2; //orange
};
[apple, pear, orange] call {
params ["_apple", "_pear", "_orange"];
_apple;
_pear;
_orange;
};
Got it, thanks everyone!
Before the edit you had me confused there Hypoxic 
brain went faster than my typing
i missed the edit, but i dont understand why you want him to index it instead of parsing that arguments using params
oh nvm, i missed the second part
you didnt say that, i misread
Is it possible to pull out the animation's length using condig?
If you have the string name of the animation obviously
well take a look at the config for anything that resembles the duration 😉
I tried looking for length
thats why I asked
I will admit thou that I'm sleepy
So i will check again
You can get the speed but without knowing the amount of frames in the animation (Which I don't think you can get from config) it is not possible.
What are you trying to do?
Maybe just time it with the animationFinish EH? On a dumb unit then save the result?
well
make a function that seamlessly switches between animations
AnimDone
If it's that then that yeah.
Just use the unit itself as the nameSpace with setVariable?
yep
Seems a lot cleaner then trying to time an animation.
i believe that works with gestures
yep thanks
well
another problem arises
playmove barely plays any animation
switchMove?
and if I used playswitch which plays most animations, it will not trigger the EH you mentioned
how
No
It's not an object
It's a proxy
You can't do anything with it, so even if the game returned it to you it's useless
switch _anim do {
case "anim1": {_unit switchMove "anim2"};
case "anim2": {_unit switchMove "anim3"};
The EH doesn't trigger in the first place
You can't "make a sequence" with it
I thought it did
nope
I'll have to check one of my scripts
You have to use switchMove and playMoveNow together
hmm
in what sequence if I may know
oh
just saw your comment
lol
_unit switchMove _move; _unit playMoveNow _move;
If you know what those command do it's fairly obvious
Yes
well
would this work
for animations
that won't work for playmove?
Yes
like "Acts_welcomeOnHUB04_AIWalk_5"
do I just replace the playmove in my script with this combination?
_unit switchMove _move; _unit playMoveNow _move;
Yes
lets try
why does this work tho
so
I think
the playmove
doesn't play
but just have the same delay
as the animation
correct?
so it is not running the animation, but its still running its "length"
If your script is scheduled make sure you wrap that in isNil to make it unscheduled
Wat?
Just try it first
well I have waituntil in the script
Because animation system uses paths
If two anims are not connected with paths you can't use playMoveNow or playMove
makes sense
You have to jump to that node first
smooth transition
yes
it will just do nothing because there is no transition
but I don't think
i can make the script unscheduled
because i'm running a loop that runs a number of scripts in an array
foreach
I mean the switchMove playMoveNow duo
Not all of it
isNil {_unit switchMove _x; _unit playMoveNow _x;};
Yes
good stuff thanks
Speed
In config
That's the inverse of length
Or if negative the negated length
[blufor, getPos thisTrigger, "FOB"] call BIS_fnc_addRespawnPosition
Can anyone help me with this, it's supposed to create a respawn on a trigger when activated for blufor, but it's not currently functioning
hmm is negation event in the commands?
make sure the trigger is firing
systemChat format ["%1 Fired!",thisTrigger];
or diag_log if you working from the rpt
i know its too late but
is there a way to know if paths are connected for two animations?
maybe through comparing config? or is there a command?
Read the connectedTo and interpolatedTo properties in config...
It's a graph so you can't know if A is connected to B without iterating the whole graph (or at least enough to reach the other node)
playMoveNow is the only command
If you do playMoveNow but the other animation doesn't play (it's not immediate tho) they're not connected
and I don't think there is a way to detected if animation is not played right?
AnimChanged EH maybe?
Yes
but doesn't that also fire when playmove actually works?
basically trying
to detect
if playmove works or not
if it doesn't
switch to leopard's solution
is attachTo considered bad for MP network traffic or performance/fps?
I can't speak for MP network traffic (I had no problems in that case but I don't have the technical knowledge so don't take my word for it) but as for the fps, well, it depends on how many things you are going to attach
A general rule would be, if you just want the attached object for the looks and not to be interacted with (or basically simulated in any form) , then make the attached object a simple object
It’s global command and broadcasted to everyone so it can affect MP performance
what are you trying to do exactly?
Yes. Both client FPS and MP network traffic are affected
Because attachTo moves/updates the object every frame
And doesn't let the game optimize out "non-updated" objects
well how severe is it
¯\_(ツ)_/¯
yeah it seems only dedmen knows
It's most likely worse than placing an AI
i guess BIS_fnc_attachToRelative is the same?
yes
That's just a function
It's a wrapper for attachTo
it just changes one of the behaviours associated with using attachto
is there any alternative to attachTo command?
Depends what you mean by "alternative"
honestly from experience its not that bad
If you don't need something to be attached just don't attach it
and if you don't need it simulated , make it a simple object
and if you attach to vehicles, add MPKilled or Killed event handler based on your usage case, so you can use it to delete all attached objects to a dead vehicle
also use this if you use deleteVehicle https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Deleted
It is bad. Try attaching a few dozen objects and watch your FPS fall
Now detach them and watch how big a difference it makes
thats a real obvious no no
i only attach 3 simple objects at most
Well you most likely won't notice anything with that many objs yes
yes
its the same as using while {true}, goes back to how much you care about optimisation
if you want to brick your game, its up to you lol
No. It's not
ill test with and without attachTo i want to see the FPS difference
use https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#CuratorObjectDeleted if you have a zeus slot
Maybe I didn't elaborate, basically I'm saying that if you use while{true} with no delay, you know your game will be bricked, same for attaching lots of objects without them being simple objects and being in rational numbers
That's not the same
A while loop with no sleep still takes 3 ms per frame and never hurts your FPS
attachTo can use as many ms as it needs
depends on what code you have for it
If it's scheduled it's always around 3ms
unscheduled
Unless a single command exceeds it
is what I'm speaking
Which has nothing to do with while anyway
You can't use sleep in unscheduled environment
yep i said no delay
Hello, I have a question regarding remoteExec statement.
Last year, I had issues to send huge data from server to a specific player.
For instance, I can pass a long string of 2k characters or an array of 4 dimensions with 100 entries (don't ask me why, this is for the exemple)
But I noticed that Arma could drop that kind of request or trim it.
(Extra question: if I pass a huge hashmap, will it be the case too?)
It is the case nowadays with the 2.0+ update?
What do you recommand me to do in order to send properly a huge amount of data over the network?
(As I read in the docs, publicVariable is not recommanded and remoteExec should be prefered)
you should be able to design so you dont have to send huge data
If I can't do otherwise, you advice me to split it in multiple parts?
what are you sending
By the way what is the limit of data we can pass in remoteExec ?
Data gathered from the database, for instance a collection of vehicles the player owns
And I had some cases where a player could own 200 vehicles ...
you could use setVariable instead of remoteExec
on what
you advice me to set a variable over an object instead of broadcasting it directly to the client?
are you sure it is really efficient
moreover setVariable broadcast it to all players, this is insanely wrong
I see you can set it to an unique machine but man, I think remoteExec > setVariable
on missionNamespace
from server to client?
idk what you mean. instead of publicVariable you can do setVariable
doesn't matter from who to whom
My goal is to send data from server to a specific player
then do setVariable
But why would it be better than remoteExec ?
_database_result = ... callExtension ...
missionNamespace setVariable ['DB_playerVehicleData',_database_result,(owner _unit)]; // propagate the data to that client only
missionNamespace setVariable ['DB_playerVehicleData',nil]; // nil the var locally on server after propagation
_database_result = nil;
// CLIENT
if (!isNil (missionNamespace getVariable ['DB_playerVehicleData',nil])) then {
_playerVehicleData = missionNamespace getVariable ['DB_playerVehicleData',nil];
missionNamespace setVariable ['DB_playerVehicleData',nil]; // nil the var locally on client after data received and sent to private variable\
};```
because you can't send variables alone using remoteExec
you can for example do:
[my_huge_array, {my_huge_array = _this}] remoteExec ["call", client]
but what's the point? 
Yeah I understand
could also send just numbers/scalar and have a function on client to interpret the incoming data
Yeah I will pass huge data through setVariable and will notify client how to deal with it through a remoteExec
or maybe I just can make an EVH on the setVariable?
just remoteExec the data and the function together
no need for setVariable
if ((_playerVehicleData # 5) isequalto 4) then { // vehicle is an SUV };
setVariable or equivalent needed because when data becomes too huge, the request is dropped
yeah?
so you are just sending an array of mostly numbers and client is reconstructing the data from that
ok but I have to make an strong algorithm in order to make this conversion efficient
if your arrays of numbers are too huge then that indicates design problems, like why is the player allowed to own 200 vehicles
which is not that simple
it is not an array of numbers
it is an array of multiple dimensions with mixed data types inside
more precisely a hasmap nowadays, but it used to be an array last year
I send the minimal data required for the player to understand what vehicle it is through an UI
For instance : id, classname, ...
So when the player opens its garage, he doesnt need to ask server each time what vehicles he has
even things like classname are unnecessary. use a client-side lookup table to store classname as a scalar
so server sends the key and the value is stored locally
this is what I do at the client first spawn
"a client-side lookup table" what do you mean?
I should store all of its vehicles in the profileNamespace ?
Hi, the code below adds a laser to the AI primary weapon and activates it. It works perfectly fine if the AI uses an AR (like a HK rifle) but if it uses a sniper rife it seems that the attachment does not get replaced. Any idea why?
_x addPrimaryWeaponItem "tier1_rahg_ngal_m300c_black_fl";
_x enableIRLasers false;
hint "Laser Off";
}
else {
_x addPrimaryWeaponItem "tier1_rahg_ngal_m300c_black";
_x enableIRLasers true;
hint "Laser On";
}
}
forEach units group player;
So basically the sniper AI does not turn on the laser. For the other AI it works fine.
do sniper rifles even support lasers?
the attachment does not get replaced
is the attachment even compatible?
yes and yes
they do support lasers
if i attach a laser on the rifle initially it works fine
so the issue that the laser does not get attached to the sniper rifle
no not profile namespace, just a function that evaluates the received data and converts to useful info
then the attachment is not compatible
are you sure it's the same attachment with the exact same classname?
instead of sending the SUV classname, i should "hash" it and find the correspondence client-side?
a simple array works too, but yes
do you have an exemple of a "hash" function that can do that efficiently?
send only keys in number/scalar form, client interprets and replaces with associated values
it means I have to "hash" the content of CfgVehicles entries at the game init for instance?
you can't do that in sqf
no, there are only a few dozen vehicles in arma
I am working on a modded version of the game, there are plenty of vehicles
more than a few dozen?
But I could try to add a different attachment to the sniper unit. I just wonder how I have to alter the code so that it changes to a different laser attachment just for the sniper.
?
[2,6,5] <----- 2 = the vehicle base class, 6 = the variant, 5 = the texture/etc
if the list of your vehicles are known and fixed you don't need to hash anything
it can just be an array
e.g. ["veh_class1", ...]
and you just send the index
In the modded version,
count configProperties [configFile / "CfgVehicles", "true", true]
Result : 24848
Idk in the vanilla one
~9k iirc
but it doesnt mean every class is a vehicle the player can drive
i know there are not more than a few dozen spawnable vehicle classes
for a typical Life RPG garage
there is no such thing as "sniper"
you have to check if the attachment is compatible
you can use this:
https://community.bistudio.com/wiki/BIS_fnc_compatibleItems
and then pick the first laser pointer from the list of compatible items
count (configProperties [configFile / "CfgVehicles", "true", true] select { count (getText (_x / "driverAction")) > 0 })
Result: 2643
And my problem is that I am not based on the Tonic framework, I do not have necessarily a config that regroups all the vehicles the player can buy at the car shop
or if this exists, it is a dynamic config provided by the DB and represented as a hashmap (so keys order is fucked)
that data isnt realistic, like it includes "I_Ejection_Seat_Plane_Fighter_03_F" and other nonsense
dont you have a whitelist of spawnable vehicles?
or can players spawn anything from config
yeah they can but it is a dynamic config
this kind
Ok, thanks Leopard. I’ll look into it.
Hello everyone, how can I check if an item with the specified class is a backpack?
@tough abyss if i trim out just some of the duplicates (there are 17 hatchbacks for instance) im down to 259 for vanilla
and thats still with many reskin variants of the same asset
still 25+ offroad variants, when there are only 5-6 that matter + re-skins
i could probably get that number under 90 after trimming out re-skins, for vanilla assets
try and see if they are isKindOf "B_Backpack_F"? maybe the wrong class here, but you see the idea
including assets unlikely to be in Life RPG, like mobile artillery
what script did you use?
Im check Cfg and found only this
B_Bergen_Base_F
And it wont work
Bag_Base
``` Work correctly, thanks for idea
There is an actual isBackpack flag in CfgVehicles too, IIRC
Does anyone know if there is a possiblity to script an option with ACRE 2 to make a vehicles commander have a loudspeaker outside of the vehicle, like being able to broadcast over speaker or if that is an impossible Idea to execute ?
Is there a way to check if an attachment is attached to a primary weapon in an IF clause?
Or to be more precise if a muzzle attachment is attached or not?
The array returned by getUnitLoadout contains that information: https://community.bistudio.com/wiki/Unit_Loadout_Array
or you can use _item in primaryWeaponItems _unit
Thank you guys, i'll give it a try.
is there a way to disable the activation of a trigger while a player is already inArea of that trigger?
but the trigger must stay repeatable but only useable by one player at the time.
very stupid question, what is the sign for OR in an IF clause please?
you can just type or/OR
or ||
thank you
found something, maybe like this?
allPlayers findIf {(_x in thisList)} == 1
_x removePrimaryWeaponItem "rhsusf_acc_aac_762sd_silencer";
_x removePrimaryWeaponItem "muzzle_snds_m";
hint "Silencer off";
}
else {
_x addPrimaryWeaponItem "rhsusf_acc_aac_762sd_silencer";
_x addPrimaryWeaponItem "muzzle_snds_m";
hint "Silencer on";
}
}
forEach units group player;
getting an error in the IF clause
not sure where the syntax is wrong
you are doing if (a) or (b)
ah got it
yep
well, you got 💡 first 😄
in check is case-sensitive
would be probably easier if I could just check for muzzle attached?: yes/no
but i guess that's not possible?
private _itemsLC = primaryWeaponItems _x apply { toLowerANSI _x };
if (("rhsusf_acc_aac_762sd_silencer" in _itemsLC) || ("muzzle_snds_m" in _itemsLC)) then
so everything is lowercase and you don't convert the array twice
findIf is not the correct way in this case; I recommend something like this:
{isPlayer _x} count thisList == 1
```If the trigger activation is set to *Any player* you can get rid of the condition entirely (i.e. just `count thisList == 1`).
instead of using _x, is there a variable which i could use for all AI squad members except the player?
_x removePrimaryWeaponItem "rhsusf_acc_aac_762sd_silencer";
_x removePrimaryWeaponItem "muzzle_snds_m";
hint "Silencer off";
}
else {
_x addPrimaryWeaponItem "rhsusf_acc_aac_762sd_silencer";
_x addPrimaryWeaponItem "muzzle_snds_m";
hint "Silencer on";
}
}
forEach units group player;```
For some reason it just add/removes the silencer for the unit with the attachment rhsusf_acc_aac_762sd_silencer but not for the others. Any idea why?
count (units group (thisList # 0)) ?
and you can do - [thisList#0] to remove the player from the array
sorry I’m on mobile can’t properly write this out
just tried this but unfortunately it did not work
you’re just trying to count how many units are in the group of the player that activated the trigger correct?
that's not what _x means
it just means the current element that the forEach is iterating on
just subtract the player element from the array
like I've shown you several times
it's not a trigger...
my bad it was someone else that had the trigger
I'm having some issues with getting a trigger to fire when a player is driver of a vehicle in my multiplayer mission. veh_0 isEqualTo (isPlayer driver _x)
you're comparing an object to a boolean
it has nothing to do with multiplayer
So something like this: alive veh_0 && {isPlayer (driver _x)}
yes
Ok, I was able to get it to work by using this: ```sqf
allPlayers findIf {_x in crew driver veh_0} > -1
why not
(isPlayer driver veh_0)
that way you do t have to iterate through every player
or even if not that, iterating through the crew itself is still a lot faster