#arma3_scripting
1 messages ยท Page 286 of 1
Afaik 1 refers to the server
Oups.. Yeah you're right
https://community.bistudio.com/wiki/remoteExec
[default: 0 = everyone]
Number - the function will be executed only on client with the given owner ID. When 0, the function will be executed on each client including the one where remoteExec was called from. When 2, it will be executed only by server. When negative, it will be executed everywhere except for machines with the given client ID. Use -2 to target everyone except the server.```
Or send it to someone specific:
[_NiceVariableToSendOver] remoteExecCall ["My_fnc_IsAwesome",(owner _Player)];
Yes, but the question is does 1 represent something in particular? @jade abyss
(owner _Player) = Number
The first connected client is 3
So 1 was... ermm... can't remember
The server is 2
and 1 should be... [FillAnswerHere]
1 is Dscha, because he is always #1
If 1 is nothing, makes me kinda sad that the server isn't 1
owner still reports a different id than is used by remoteExec in loaded MP savegames. : (
Saving in MP worked? ^^
Alright so if I want to remotely execute a scripts to @jade abyss I use 1
I just find it funny that it's not defined, I figured it would be something like local or something
Yep. Exactly. Then i magicly appear and bitchslap you around the room cause you highlighted me without any purpose and then i will steal your milk out of your fridge! HA!
(P.S.: I just guess, that we all forget what 1 was)
No! I drink milk all the time! I need it!
lol
I don't drink coffee
just found this function https://community.bistudio.com/wiki/BIS_fnc_neutralizeUnit
wondering if it fires the missile a distance away or detonates directle on the vehicle
Question for our performance cowboys:
Counting bytes of a character given by its unicode value.
First (using toString + count):
count toString [_value]
0.0046 ms
Second (using switch):
switch (true) do {
case (_value < 128): {1};
case (_value < 2048): {2};
default {3};
}
0.0085 ms
Third (using if-else):
if (_value > 127) then {[2, 3] select (_value > 2047)} else {1}
0.0051 ms
lookup the function in the in game function browser and you can see it @plucky beacon
I'm not home atm but ya I wanna test it for fun later
I'm just reading through the known functions
Also that looks like a Dscha question
@plucky beacon it creates an I_static_AA_F at 500m distance and fires at the target
Cool
@deft zealot is _value an array or a number? what are you attempting? but when chosing between case-switch and if-else chains, its better to call { if condition_one exitWith { CODE}; if condition_two exitWith {CODE}; etc };
Better if you have a large amount of cases that is
_value is a number
and the call-if-exitWith was indeed faster than switch but there was a patch (about half a year ago?) where switch got improved and got better performance now
i cant tell which path it was
Are you expecting toString [a single number] to give you more than 128 characters ๐ ?
^
method one is best tho
0.0011 ms, cant really beat that with complexer if else / switch cases
no no he checks the number itself
count toString [_value]
those are the boundaries where one number will turn into a 2 length string
yea
haha nah 3 it the largest it gets, and counting the toString is definitively most optimal
@deft zealot We were looking into array select bool the other day, it was super slow
i thought its faster than if (BOOL) then {A} else {B}
BoGuu, select BOOL or select CODE? the difference between select BOOL and select NUMBER is within margin of error for me
It would be yes, but you used both in combination @deft zealot
select is still faster than then
if BOOL then CODE else CODE is my favourite for explaining how SQF commands work, tho
The mere existence of the IF type is an insult.
i suspect you dont regard the WHILE type favourably, either
you can come close to it with call { if condition_1 exitWith {code}; if condition_2 exitWith {moreCode}; };
the main thing I sometimes run into is huge conditions, but thats a problem in every language i guess
dat haydouken thingy (or however its beeing spelled)
ye
yep, that one
PHP allows you to make money, SQF doesn't really ยฏ_(ใ)_/ยฏ
Please buy my status bar
๐
lol "buy my status bar"
"Yeah it works but you're leaking memory everywhere. Perhaps we should fix that" - "I'll just restart Apache every 10 Request"
๐ ๐คฃ
No clue what that means. Explain pls.
Note the first diagram ๐
Means he had to name functions purposefully, just so he could get a nice distribution ๐คฃ
oh wow that is hilarious, ive always avoid php it felt so just gross to use
_ActivePlayers = {alive _x} count _BluforUnits;
Am I doing this right?
I used
_ActivePlayers = {alive _x && {side _x == east}} count _OpforUnits;
as an example
allPlayers?
_ActivePlayers sounds like it's an array of player objects, but it's actually a number.
But Nitro wants the number of players and not the objects apparently
ah
I'm getting all sorts of errors, I tried this way too...
{
_checkedVariables pushBack _x;
if (alive _x) then
{
_ActivePlayers pushBack _x;
};
} forEach _BluforUnits;
https://i.gyazo.com/0b5bb69760b3b4f63aea725f4d8003f8.png
isn't forEach supposed to use _x as the variable for whatever element it's processing?
wut
IKR?
Because there are undefined elements in _BluforUnits
well that was clear /s
We went over this already. Wrap it all inside {...} call CBA_fnc_directCall;
that gave me a whole 'nother error, let me get that for you
Yo hope this is the right textchannel ๐ Is there a way to put allow two license to go in civ car on altis life? ๐ case "civ_car": {_ret = license_civ_driver;};
@plucky beacon use
private _BluforUnits = [Leader_1,Leader_2,Leader_3,FTL_1,FTL_2,FTL_3
private _aliveCount = {{alive _x && {side _x == west}} count _listOfUnits} call CBA_fnc_directCall;
or
private _BluforUnits = [Leader_1,Leader_2,Leader_3,FTL_1,FTL_2,FTL_3];
private _aliveCount = {alive _x && {side _x == west}} count (_BluforUnits arrayIntersect _BluforUnits);
like we discussed earlier today ๐ you picked the one variant that didnt work.
I want to get rid of the side check but it returns as _activePlays undefined
just remove the side check from those two snippets
you need to handle the array in a special way to circumvent the nonexistent units
you cant use the snippets you posted earlier because of that
_ActivePlayers = {{alive _x} count _BluforUnitsVariables} call CBA_fnc_directCall;
wait wtf
use the two snippets i just posted
dont use the other 300 snippets you have in your file
that one gives me the error in the image
bu-bu-bu you said just remove theside check :<
yes but thats a different snippet than the ones i posted
private _someArrayOfJustUnits = [Leader_1,Leader_2,Leader_3,FTL_1,FTL_2,FTL_3
private _aliveCount = {{alive _x} count _someArrayOfJustUnits } call CBA_fnc_directCall;
so like this
private _aliveCount = {{alive _x} count _BluforUnits} call CBA_fnc_directCall;
same error
the private array
ya
_BluforUnits = [Leader_1,Leader_2,Leader_3,UAV_1,FTL_1,FTL_2,FTL_3,FTL_4,AR_1,AR_2,AR_3,AR_4,AAR_1,AAR_2,AAR_3,AAR_4,Gren_1,Gren_2,Gren_3,Gren_4,Marksman_1,Marksman_2,Marksman_3,Marksman_4,Scout_1,Scout_2,Scout_3,Scout_4,Medic_1,Medic_2,Medic_3,Medic_4,Medic_5];
well somewhere in the process you managed to turn it into a number since thats what arma is complaining about
yes. the following works when pasted into the debug menu. A = 2.
0 = [] spawn {
private _array = [nil,player,nil,nil,player];
private _aliveCount = {{alive _x} count _array } call CBA_fnc_directCall;
A = _aliveCount
};
you got some things interfering in your script files @plucky beacon
pbpbpbpbpbpt
okay
something to do with the names of the nil units, because I did the same debug menu thing and it stopped on the second element because there is no Leader_2
ah so you can use nil but not non-existing variables
gotta build the array inside of directCall then
so this...
0 = [] spawn {
private _BluforUnits = [Leader_1,Leader_2,Leader_3,UAV_1,FTL_1,FTL_2,FTL_3,FTL_4,AR_1,AR_2,AR_3,AR_4,AAR_1,AAR_2,AAR_3,AAR_4,Gren_1,Gren_2,Gren_3,Gren_4,Marksman_1,Marksman_2,Marksman_3,Marksman_4,Scout_1,Scout_2,Scout_3,Scout_4,Medic_1,Medic_2,Medic_3,Medic_4,Medic_5];
private _aliveCount = {{alive _x} count _BluforUnits} call CBA_fnc_directCall;
A = _aliveCount;
hint a;
};
oh shit you can do that?
no not that
We went over this already. Wrap it all inside {...} call CBA_fnc_directCall;
You so dirty
haha
turns out even CBA_fnc_directCall doesnt like that
gotta use some other way @plucky beacon
check every unit for isNil
Although the real question is why aren't they defined
If you purposefully put all those units into that array
because players didn't take the spots
0 = [] spawn {
{
private _array = [someUnit,nil,player]
} call CBA_fnc_directCall;
};
``` gives a funky error
๐ ?
would fail on the first
lol my better array
trying to add a nonexisting unit to the array since youre referencing an undefined variable
can we just find a way that's not directCall
just move to unscheduled
Because that's just ugly
so much easier haha
the actual issue is the fact you cant use the unitVarNames at all
unless theyre not nil
so gotta check the string version of them all for isNil then add them to the array
okay okay, so make a list of strings
["unit1","unit2"] apply {if !(isNil _x) then {missionNamespace getVariable [_x,objNull] } else {objNull} }
then remove all instances of objNull
or something like that
["unit1","unit2"] select {!isNil _x}
part of me wants to stop asking questions simply out of guilt
everyone's gotta start somewhere, don't be afraid of asking questions
it's been like 2 days all day xD
this missionNamespace stuff is alien to me
never seen it before
missionNamespace is all global variables I believe
Global variables that are defined in the missionNamespace, yeh
how do you turn a string into an object? gah...
_veh = missionNamespace getVariable "refString";
this must be it
yes
Victory
private _bluforUnits = ["Leader_1","Leader_2","Leader_3","UAV_1","FTL_1","FTL_2","FTL_3","FTL_4","AR_1","AR_2","AR_3","AR_4","AAR_1","AAR_2","AAR_3","AAR_4","Gren_1","Gren_2","Gren_3","Gren_4","Marksman_1","Marksman_2","Marksman_3","Marksman_4","Scout_1","Scout_2","Scout_3","Scout_4","Medic_1","Medic_2","Medic_3","Medic_4","Medic_5"];
_numberOfElements = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _bluforUnits;
\o/
Anyone here intreseted in zombies that can parkour ?
mah immersion
Are you guys still working on this. lol
@plucky beacon Might be worth adding a default value, just in case
Where is the full code?
I think that is the full code
oh the full code
hang on
wtf
my ctrl.c isn't working?
@little eagle
private ["_BluforUnits","_aliveCount"];
_BluforUnits = ["Leader_1","Leader_2","Leader_3","UAV_1","FTL_1","FTL_2","FTL_3","FTL_4","AR_1","AR_2","AR_3","AR_4","AAR_1","AAR_2","AAR_3","AAR_4","Gren_1","Gren_2","Gren_3","Gren_4","Marksman_1","Marksman_2","Marksman_3","Marksman_4","Scout_1","Scout_2","Scout_3","Scout_4","Medic_1","Medic_2","Medic_3","Medic_4","Medic_5"];
waitUntil {MissionActive};
_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _BluforUnits;
if(_aliveCount == 1) then
{
[[],"LastMan.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 0) then
{
[[],"BluforFailure.sqf"] remoteExec ["execVM",0,false];
};
Last man and Blufor failure run only once
so I didn't see a need to precompile them
Wait. Is this supposed to execute LastMan.sqf when everyone but one unit is dead?
Like, after 30 minutes of playing for example?
@little eagle ye? Everyone gets the notification.
please no execVM ๐ฆ
Well it won't work like that.
Because your script runs once at mission start and if they're not dead immediately, nothing will happen, because your script is long finished.
Also, that whole array of blue units... Isn't that basically all the blue units?
Why name them?
Can't be. You can't use waitUntil in an event handler.
so every time they die it runs a check
You can't use waitUntil in an event handler.
that's for the first iteration after the mission is activated by the group leader
You said this script is executed every time a unit dies by killed eh.
There is waitUntil
verboten
yes, AND when the mission is active
[] remoteExec ["BluforLeft", 2, false];
```when mission activated
```sqf
this addEventHandler ["killed", {[] remoteExec ["BluforLeft", 2, false];}];
``` per unit
oh my
god what sacrilige did I commit now?
That must've been painful to name all units and to add that line into every init box.
Just to make sure.
You're using CBA?
ya?
@CBA_A3 addon
ya?
That doesn't sound very confident.
I'm asking why that's relavent
I'm so confident I'll bet you $1000 I have CBA running
Idk man. I still don't understand why you only execute this for certain blue units.
Because these are the playable units, and the playable units have a specific number of each infantry type, because for each autorifleman on blufor, one autorifleman on opfor is present.
Then why not iterate through the playable units? It seems like a huge inconvenience to name all the units.
Because I need to compare the unit's existence to it's opfor equivalent, and each class has a custom loadout
and It was easier for me to apply arsenal loadouts in Eden then write a function that applies a loadout for each class using kindOf
Couldn't you also check for playableUnits per side?
Well ya that's not the issue
Blufor chose to take 3 rifleman and a medic, I need 3 rifleman and a medic on the enemy team. I CAN write the script for checking the classname of each playable unit and spawning the equivalent with the custom loadout
but I didn't (yet)
Sorry for jumping in like that - but could you elaborate what you are trying to achieve? Maybe that will make it easier to find a better solution.
Ah IC
It was originally a game mode I made up in zeus
and designed to have one zeus play "opfor" and in a PVP type game style, remote control the enemy in an attempt to kill all blufor
but only using the same exact amount of forces
I only recently said "Fuck, I could script this"
So eventually, the plan is this will work as a template, that could be used on aany map or mission with a few markers and objects pasted in
If you want to make it reusable I'd script it, leave away that predefined array and create the array dynamically at beginning of misison
right that's the plan ultimately
something like _BluforUnits = west countSide playableUnits;
just working on it one piece at a time, even if ultimately it's a bit out of order
but the remaining players was definately most broken
and I learned how to use missionNameSpace
So - you have an array of certain named units per side, once only 1 unit from this side is left, you exec lastman.sqf and if a side has completely lost all players the mission ends with failure
ye
and similar for the other side too
almost identical
besides the fact they're not players
So the opfor side is AI?
ya
Aaaah
might work on a PVP variant once this is a-okay
but want to get it all done for one side first
I already have the failure and victory scripts side specific
Here's my messed up backwards upsidedown way of balancing the sides
_BluforUnits = ["Leader_1","Leader_2","Leader_3","UAV_1","FTL_1","FTL_2","FTL_3","FTL_4","AR_1","AR_2","AR_3","AR_4","AAR_1","AAR_2","AAR_3","AAR_4","Gren_1","Gren_2","Gren_3","Gren_4","Marksman_1","Marksman_2","Marksman_3","Marksman_4","Scout_1","Scout_2","Scout_3","Scout_4","Medic_1","Medic_2","Medic_3","Medic_4","Medic_5"];
_OpforUnits = [OpLeader_1,OpLeader_2,OpLeader_3,OpUAV_1,OpFTL_1,OpFTL_2,OpFTL_3,OpFTL_4,OpAR_1,OpAR_2,OpAR_3,OpAR_4,OpAAR_1,OpAAR_2,OpAAR_3,OpAAR_4,OpGren_1,OpGren_2,OpGren_3,OpGren_4,OpMarksman_1,OpMarksman_2,OpMarksman_3,OpMarksman_4,OpScout_1,OpScout_2,OpScout_3,OpScout_4,OpMedic_1,OpMedic_2,OpMedic_3,OpMedic_4,OpMedic_5];
_count = count _BluforUnits;
for "_x" from 0 to _count do
{
if(isNil (_BluforUnits select _x)) then
{
deleteVehicle (_OpforUnits select _x)
};
};
so basically two arrays, exactly the same size, and when something is nil, it deletes the opfor one
and naming wasn't that hard, I have a decen naming convention
but it's not dynamic, and like anything in code, if it has to be repeated, it can be coded
because it used to be a diffrent number of blufor depending on number of zeus'
but I use the virtual entity now so I can
Why so complicated? You already are using the killed eventhandler - the names in the blufor array are jus strings, just delete the "OP" + bluforstringname. Unfortunatly Arma does not have good string manipulation though
Would that not work?
the variable names really won't be necessary besides Leader_1
I could use AllUnits blufor
Unfortunatly Arma does not have good string manipulation though
Not much you can't do
No regex afaik?
Why would you need regex for that
Also you could just do OP+bluforstringname
And I'd use regex and string manipulation loosely in the same sentence
but the importance is the unit classes, so Scout vs. Grenadier vs. Marksman
I need to make the scripts for the loadouts which is pretty easy with arsenal but it's busy work :P
so grab the unit classes from the config
ya that's what I'll do
I could use classname too because that's consistent
so ever B_medic_F is given a loadout for medic
sure - it seems like you would want to grab as much stuff without writing it down manually in an array, because as mucha s I've understood the composition of units can change depending on setup
ya, so basically I would make a public array at the beginning
and that array is the reference for the rest of the mission
@dusk sage I am not sure what string manipulation function are inherent to A3? Last time I checked you would need to write your own functions or sth like that no?
and in that case (for me) it would be simpler to just use regex
So yeah - maybe that will help you get things going, sounds like a cool idea players vs zeus (or TVT)
You need to write your own functions in most things, but there is a large amount of commands avaliable
You would want to only use regex when it's necessary
Ok I admit I forgot that there are these things like trim split and in. I used to work a lot with CF, which even though has great string manipulation - in the end we did a lot with regex because it showed better performance ๐
What is CF?
ColdFusion App Server .. I think now it's part of Adobe
Well enough of that - it was a long time ago ๐ Hope I could help DriftingNitro
You did, thanks @weak obsidian
some really weird stuff happens when i run this (initServer.sqf) on a dedicated server, but not on a listen server
LostSquad_friendlyFactionSide = selectRandom [east,west,resistance];
_nlostSquad = createGroup (LostSquad_friendlyFactionSide);
(units lostSquad) joinSilent _nlostSquad;
_nheliPilots = createGroup (LostSquad_friendlyFactionSide);
(units heliPilots) joinSilent _nheliPilots;
waitUntil {!(isNil "BIS_fnc_init")};
_startPosVariance = [-20,0,20];
_randomStartPos = call BIS_fnc_randomPos;
{
[0,false] remoteExec ["enableChannel",_x];
[1,false] remoteExec ["enableChannel",_x];
[2,false] remoteExec ["enableChannel",_x];
_x setPos [(_randomStartPos select 0) + (random _startPosVariance),
(_randomStartPos select 1) + (random _startPosVariance)];
[_x, 'randomUnitLoadout.sqf'] remoteExec ["execVM", _x, false];
} forEach units _nlostSquad;
- the setPos seems to do nothing at all and 2. the AI units kill each other like they were enemies
what is lostSquad
What's with all this similar looking code that doesn't work recently.
well mine only breaks in dedicated servers
the AI units killing each other after changing their sides is really curious
I've seen this glitch before when the unit is owned by a headless client
I didn't know you could edit scripts mid mission while testing in eden now
in SP at least
hmmm just about ready to get this loadout applicator going. So what's the best way to implement a switch:case or some other alternative to nested if-loops considering I need to check for a unit's classname, and then run the loadout script on them?
update: if i check for the units' individual sides w/ the debug console they show up as WEST no matter what, even if they're in a group that isn't WEST
but also if i run the exact same code for switching sides on the debug console (with server exec of course) nothing of the sort happens and they don't kill each other
so i wonder what is it about initServer.sqf that makes that behave so strangely
@stoic sphinx AI zombies path finding + parkour? Did you pull that off yet?
always check a group's side, not the unit
unit is civ when dead, group is still correct
_posRelToPlayer = player selectionPosition "LeftHand";
_pos = player modelToWorldVisual _posRelToPlayer;
(vehicle player) worldToModelVisual _pos;
};
_posRelToVic = [] call _leftHandToVicModel;
_obj attachTo [vehicle player, _posRelToVic];``` this works fine when vehicle is stationary but when it moves, offset is affected by velocity, any idea why?
Try attaching to a memory point if that's possible with your object
i'm interested in littlebirds
no selection suits me, don't know about any mempoints
@mortal bobcat
As cuel pointed out, ALWAYS use side group _unit instead of side _unit, no matter what you see EVERYWHERE, it's wrong and will lead to wrong results.
woop, finally we got a weaponholder which doesnt delete itself (when empty)
Wat
how?
Those objects must be new.
Means i can update an old script of mine that used an invisible item as placeholder
.<
I've read last week something, about the new WeaponHolder (or was it earlier this week?)
check the link
Inb4 these are eternal and never deleted even when you pick up the last item normally
Not a fix at all, but very lazy
wich is good.
All I wanted is to not delete the weapon holder when you remove the last item via script command and immediately fill it again with new items.
Because atm that will still delete it, even if all of that is done in the same frame...
Now that will never be addressed. issue is closed after all ๐คฆ
who was the guy talking about scripting company of heroes as an arma mission?
What's the best way for me to make a bunch of functions for diffrent loadout applications, do I make a file with inline functions and preprocess it?
so in the description?
I'd like to keep it clean in seperate files though
for easy to edit purposes
then use cfgfunctions
I can define funciton by file?
oh I guess so
class cfgFunctions
{
class BIS
{
class category1
{
class Test1 {description="Testing file 1"};
};
};
class CSLA
{
class category1
{
class Test2 {description="Testing file 2"; file="test.sqf"};
};
};
};
class CfgFunctions
{
class F // Defines the "owner"
{
class setGroupID
{
file = "f\setGroupID";
class setGroupID{};
};
class groupMarkers {
file = "f\groupMarkers";
class localGroupMarker{};
class localSpecialistMarker{};
};
class FTMemberMarkers
{
file = "f\FTMemberMarkers";
class SetLocalFTMemberMarkers{};
class GetMarkerColor{};
class LocalFTMarkerSync{};
};
};
};
So I found this, interesting that you can set the file to adirectory
and as far as I can figure out, setting class is the name of the file without the fn_ prefix
Yes, imo the better Choice.
neat
class CfgFunctions
{
class Loadouts // Defines the "owner"
{
class Loadout_Blufor
{
file = "Loadouts\Loadout_Blufor";
class asstAutoRifleman{};
class AutoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
class Loadout_Opfor
{
file = "Loadouts\Loadout_Opfor";
class asstAutoRifleman{};
class AutoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
};
#include "taw_vd\CfgFunctions.hpp"
};
Neato
neatastic
When I do this the entire file is a function right? So I don't even need define the function inline
With loadouts i recommend taking a real good look at how others have solved it
There some interesting sides to it you need to know about
I've worked a lot with loadouts but not as a function
I don't really know anywhere else that does this off the top of my head anyway
class CfgFunctions
{
class La // Defines the "owner"
{
class blu
{
file = "Loadouts\Loadout_Blufor";
class asstAutoRifleman{};
class AutoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
class Op
{
file = "Loadouts\Loadout_Opfor";
class asstAutoRifleman{};
class AutoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
};
#include "taw_vd\CfgFunctions.hpp"
};
So I'm having trouble understanding the syntax for calling the function.
[Leader_1] call
fnc_La_blu_autorifleman;
the way they explain it is a bit weird because they're using something from teh game files not a mission directory
CSLA_fnc_Test2 - will load script test.sqf
Oooh
Category only gets used in the function browser
Yea thats not gonna work then
It is what it is
class CfgFunctions
{
class blu
{
file = "Loadouts\Loadout_Blufor";
class asstAutoRifleman{};
class AutoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
class Op
{
file = "Loadouts\Loadout_Opfor";
class asstAutoRifleman{};
class AutoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
#include "taw_vd\CfgFunctions.hpp"
};
would this work?
sure
I mean if categories are useless then...
so a class with one category
class cfgFunctions { class blu { class loadouts { class Autorifleman {}; }; }; }; sorry for the horrible indentation
it's alright, I can still read it
class CfgFunctions
{
class blu // Defines the "owner"
{
class Loadouts
{
file = "Loadouts\Loadout_bluFor";
class asstAutoRifleman{};
class autoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
};
class op
{
class Loadouts
{
file = "Loadouts\Loadout_opFor";
class asstAutoRifleman{};
class autoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
};
#include "taw_vd\CfgFunctions.hpp"
};
Okay so trying to call the function like this, maybe I'm not passing the argument correctly, but even still the systemChat in the script isn't coming up.
[Leader_2] call blu_fnc_autoRifleman;
oh wait
wait wait wait
If 'file' path is not set, system will search for file 'functions\category\fn_function.sqf" (if function is defined in description.ext) or 'ca\modules\functions\category\fn_function.sqf" (if function is in config.cpp).
https://community.bistudio.com/wiki/Functions_Library#Adding_new_functions
doesn't this mean it should automatically be looking in the functions folder or do I need to specify?
i couldn't get that layout of cfgfunctions to work last time i tried it
ended up just going for the simple
class mytag
{
tag = "mytag";
class functions {
class someFunction {file = "somefolder\fn_someFunction.sqf";}; // [args] call mytag_someFunction
};
};
the fk happened to the indentation there
Considering I have like 20 functions though, I'd liek to learn to do it the right way :/
I can use that just to make sure the script works
i've got 82 functions...works fine
class CfgFunctions
{
class dpm /*dynamic patrol mission*/
{
class missionFunctions
{
file = "functions";
class aStar {};
class buildPaths {};
class calcRoute {};
class gear {};
class generateRoute {};
class getNearestRoad {};
class huntFinal {};
class huntZone {};
class squadZone {};
};
};
};
does what it says
oh
grabs everything in the \functions\ subfolder > dpm_fnc_gear
thanks it worked
needed to define the functions directory
the cfg functions really confused me on that, because they clearly highlighted everything but that part of the directory, and their example didn't reference it
because you were on the A2 page
https://community.bistudio.com/wiki/Functions_Library_(Arma_3) [be sure to manually add trailing ) ]
thats the A3 one
class CfgFunctions
{
class blu // Defines the "owner"
{
class Loadouts
{
file = "functions\Loadouts\Loadout_bluFor";
class asstAutoRifleman{};
class autoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
};
class op
{
class Loadouts
{
file = "functions\Loadouts\Loadout_opFor";
class asstAutoRifleman{};
class autoRifleman{};
class grenadier{};
class marksman{};
class medic{};
class scout{};
class squadLead{};
class teamLead{};
class uavOp{};
};
};
#include "taw_vd\CfgFunctions.hpp"
};
//[unit] call blu_fnc_<function>;
LOL IT HAS NO TEXT
nothing in a loadout should require sleeping tho
ya it's not the loadout, just makign some other recursive scripts functions
sleep thing though purely has to do with scheduled vs non scheduled environment
read up on that and itll be clear
ah okay, threads
okay so I have this function fn_getUnits
BluforPlayers = [];
OpforPlayers = [];
{
if(side _x == west) then
{
if(alive _x) then
{
BluforPlayers pushBack _x;
};
};
}forEach allUnits;
{
if(alive _x) then
{
if (side _x == east) then
{
OpforPlayers pushBack _x;
};
};
}forEach allUnits;
publicVariable "BluforPlayers";
publicVariable "OpforPlayers";
_formattedBlufor = format ["Units: %1, number of units in array: %2", BluforPlayers, count BluforPlayers];
_formattedOpfor = format ["Units: %1, number of units in array: %2", OpforPlayers, count OpforPlayers];
hint _formattedBlufor;
hint _formattedOpfor;
[BluforPlayers] call missionStarter_fnc_loadoutApply;
[OpforPlayers] call missionStarter_fnc_loadoutApply;
//[BluforPlayers] remoteExecCall ["missionStarter_fnc_loadoutApply", 2, false];
//[OpforPlayers] remoteExecCall ["missionStarter_fnc_loadoutApply", 2, false];
//[] remoteExec ["BluforLeft", 2, false];
//[] remoteExec ["OpforLeft", 2, false];
it outputs the hint and clearly has the units in the array, but nothing happens when the function is called
and it calls to this function
_arrayOfUnits = _this select 0;
{
//Blufor functions
if (typeOf _x == "B_Officer_F") exitWith {[_x] call blu_fnc_squadLead;};
if (typeOf _x == "B_Soldier_SL_F") exitWith {[_x] call blu_fnc_squadLead;};
if (typeOf _x == "B_Soldier_TL_F") exitWith {[_x] call blu_fnc_teamLead;};
if (typeOf _x == "B_Soldier_UAV_F") exitWith {[_x] call blu_fnc_uavOp;};
if (typeOf _x == "B_Medic_F") exitWith {[_x] call blu_fnc_medic;};
if (typeOf _x == "B_Soldier_AR_F") exitWith {[_x] call blu_fnc_autoRifleman;};
if (typeOf _x == "B_Soldier_AAR_F") exitWith {[_x] call blu_fnc_asstAutoRifleman;};
if (typeOf _x == "B_Soldier_GL_F") exitWith {[_x] call blu_fnc_grenadier;};
if (typeOf _x == "B_Soldier_M_F") exitWith {[_x] call blu_fnc_marksman;};
if (typeOf _x == "B_Soldier_lite_F") exitWith {[_x] call blu_fnc_scout;};
//Opfor functions
if (typeOf _x == "O_Officer_F") exitWith {[_x] call op_fnc_squadLead;};
if (typeOf _x == "O_Soldier_SL_F") exitWith {[_x] call op_fnc_squadLead;};
if (typeOf _x == "O_Soldier_TL_F") exitWith {[_x] call op_fnc_teamLead;};
if (typeOf _x == "O_Soldier_UAV_F") exitWith {[_x] call op_fnc_uavOp;};
if (typeOf _x == "O_Medic_F") exitWith {[_x] call op_fnc_medic;};
if (typeOf _x == "O_Soldier_AR_F") exitWith {[_x] call op_fnc_autoRifleman;};
if (typeOf _x == "O_Soldier_AAR_F") exitWith {[_x] call op_fnc_asstAutoRifleman;};
if (typeOf _x == "O_Soldier_GL_F") exitWith {[_x] call op_fnc_grenadier;};
if (typeOf _x == "O_Soldier_M_F") exitWith {[_x] call op_fnc_marksman;};
if (typeOf _x == "O_Soldier_lite_F") exitWith {[_x] call op_fnc_scout;};
} forEach _arrayOfUnits;
the alive check is pointless. allUnits only reports alive units. allDeadMen is for dead units
oh it does?
Yup
What about empty vehicles
They are reported by neither allunits nor alldeadmen
alright well I'll fix that
but in any case this isn't calling the loadout applicator
just old code
So you're saying it doesn't work
ye, I'm gonna test it with a system chat in the loadoutApply and see if it's even reaching it
could be the public variable?
looks fine to me, but idk what blu_fnc_squadLead actually is.
blufor squad lead loadout
show it
private _unit = __unit select 0;
comment "Leader Unit";
comment "Remove existing items";
removeAllWeapons _unit;
removeAllItems _unit;
removeAllAssignedItems _unit;
removeUniform _unit;
removeVest _unit;
removeBackpack _unit;
removeHeadgear _unit;
removeGoggles _unit;
comment "Add containers";
_unit forceAddUniform "Gen3_Tan";
_unit addItemToUniform "ACE_EarPlugs";
_unit addItemToUniform "ACE_IR_Strobe_Item";
_unit addItemToUniform "ACE_Flashlight_XL50";
_unit addItemToUniform "ACE_MapTools";
for "_i" from 1 to 2 do {_unit addItemToUniform "ACE_tourniquet";};
_unit addItemToUniform "ACE_morphine";
_unit addItemToUniform "ACE_epinephrine";
for "_i" from 1 to 10 do {_unit addItemToUniform "ACE_elasticBandage";};
for "_i" from 1 to 2 do {_unit addItemToUniform "ACE_CableTie";};
_unit addItemToUniform "SmokeShellBlue";
_unit addItemToUniform "SmokeShellRed";
_unit addItemToUniform "CUP_15Rnd_9x19_M9";
_unit addVest "lbt_operator_coy";
for "_i" from 1 to 8 do {_unit addItemToVest "30Rnd_556x45_Stanag";};
for "_i" from 1 to 4 do {_unit addItemToVest "SmokeShell";};
for "_i" from 1 to 2 do {_unit addItemToVest "HandGrenade";};
for "_i" from 1 to 2 do {_unit addItemToVest "ACE_M84";};
_unit addHeadgear "rhsusf_mich_bare_norotos_arc_alt_tan_headset";
comment "Add weapons";
_unit addWeapon "SMA_MK18MOEBLK";
_unit addPrimaryWeaponItem "CUP_acc_ANPEQ_2";
_unit addPrimaryWeaponItem "RH_ta31rmr";
_unit addPrimaryWeaponItem "SMA_Gripod_01";
_unit addWeapon "CUP_hgun_M9";
_unit addWeapon "Binocular";
comment "Add items";
_unit linkItem "ItemMap";
_unit linkItem "ItemCompass";
_unit linkItem "ItemWatch";
_unit linkItem "tf_anprc152";
_unit linkItem "ItemGPS";
_unit linkItem "ACE_NVG_Gen4";
Watch out when doing find an replace lol
le derp, I didn't even check because the laodout function I tested I changed the variable manually
ยฏ_(ใ)_/ยฏ
Hi all, is anyone having issues with the disableAI command or is it just me? It doesn't make a difference where or how I execute it either, Wiki says to execute it where the AI unit is local, still doesn't work for me. I'm not sure what I'm doing wrong, I haven't had any issues with this command before. I'm on the latest stable version. _dummyUnit disableAI "ALL";
are you on a dedicated server?
Testing just in the editor for now.
Nope, no mods.
Ah, hold on.
so _dummyUnit must not be found correctly
I just did this in debug console: dummyUnit = (createGroup civilian) createUnit [(typeOf player), (getPos player), [], 0, "LINE"]; dummyUnit disableAI "ALL";
It seems to work BUT, the ANIM part doesn't.
Maybe I am misunderstanding something? Does ANIM stop all animations? Including head turning, etc...?
everything but head turning
you want to disableSimulation then
disableAnim stops the switchMove
0 = [] spawn {
_dummyUnit = (createGroup civilian) createUnit [(typeOf player), (getPos player), [], 0, "LINE"];
_dummyUnit disableAI "ALL";
_dummyUnit enableSimulationGlobal false;
};
Ah, okay.
Yeah, I know about that but, I can't use that command atm. It seems to break something else I'm doing, lol. ๐
I guess he'll just have to retain his freedom to move his head, lol
Haha lol
Not just what is causing the issue exactly but, when I use it, the camera zoom (Fov) doesn't appear to work. ๐ฆ
for the player?
"ALL" - all of the above Available since Arma 3 v1.65
Yeah, we are on 1.66, no?
I think so. Maybe it's broken.
that's what my game says
๐
_dummyUnit = (createGroup civilian) createUnit [(typeOf player), [0, 0, 0], [], 0, "LINE"];
_dummyUnit setUnitLoadout (getUnitLoadout player);
_dummyUnit switchMove "AmovPercMstpSrasWrflDnon_Salute";
_dummyUnit disableAI "ALL";
_dummyUnit enableSimulation false;
_camera = "camera" camCreate (getPos _dummyUnit);
_camera camPrepareTarget _dummyUnit;
_camera camPrepareFov 0.31;
_camera attachTo [_dummyUnit, [0, 3.55, 1.79]];
_camera camCommitPrepared 0.03;
_camera cameraEffect ["internal", "back", "characterPreview"];
How do you do the code tags?
you mean like functions?
```sqf
code
```
oh on Discord
Yes, lol. On Discord.
I got it working commy, the unit has the loadout applied based on their classname
wait, today?
Anyway, that code I pasted. It all works good. The enableSimulation stops the Fov some how... ๐ฆ
Yes, you can dl the RC branch now.
oh shit I oughta do that
Is it okay to send screenshots here? Just want to send two, so you can see the issue I am having.
rgr
Okay, so... When I use the enableSimulation command, it messes up, like so:
When I don't use the command though, it shows fine...
well simulation disables any kind of zoom and stuff
For the camera though? Is it suppose to?
you might want to spawn them looking at something, maybe targeting scripts
The zoom is by the camera, enableSimulation is on the unit.
simulation does some weird stuff
What you mean, targeting scripts?
there are scripts like https://community.bistudio.com/wiki/aimedAtTarget
I don't know if any of them will do what you want but that's what I'd guess
I don't see why I need this? Also, read notes, doesn't work with soldier weapons.
there is one that does but I can't find it
I don't want the AI to do anything really, that's why I tried disableAI but the head turning still happens, enableSimulation stops all that and is great however, it breaks the zoom thing.
???
I don't think you are understanding what I'm saying.
I'm not trying to get the unit to target or do anything.
If a unit is looking at a dummy target in front of them they won't move their head
No.
no?
That is PIP (picture in picture) made with ctrlCreate (RscPicture)
yes
One of us is confused, lol. ๐
Ah, are you saying that doTarget/doMove will stop the head turning?
You said "camera doesn't zoom because simulation is disabled" and "head moves around when simulation is enabled" so I said leave simulation enabled and have him stare at a dummy target in front of him.
I guess that's what you meant.
but I'm an idiot because he literally can't target anything
๐
It would be nice to just know why it breaks the camera zoom thing, even if I have to do a work around.
the only reference to dummytarget is the position anyway right?
haz try doing the cam stuff before disabling simulation
rgr - Will try.
Ah, yeah... I forgot that I already tried that I think, I just tried it again to be sure. Doesn't make a difference.
Issue still happens.
pastebin the script
ah i see
do it without attaching
get a pos using modeltoworld and then put the cam in that position
Ah... Thank you, it works now! I commented out the attachTo line and changed the camCreate line with:
_camera = "camera" camCreate (_dummyUnit modelToWorld [0, 3.55, 1.79]);
Thanks again. ๐
no problem
i was searching my arma folder, i made a gear selector using PIP in a dialog, couldn't find it though
The one I have is for the A3 Inventory dialog, was just an idea I was trying I guess.
i remember the problem i ran in to - if you disable PIP in options then the ctrl will just show black
Yeah.
Think I'll just check to see if PIP is enabled, if not, hide it. If possible, I think it is. Yeah, it is, using this command. https://community.bistudio.com/wiki/isPipEnabled
doesn't DayZ do this? the inventory witha clone of yourself on the menu?
๐
That's where I kinda got the idea, that and a few other games.
I don't play DayZ though, nor do I own a copy of it. Just saw it in a video.
I regret buying
(:
Is there a way at all to make sure rscTitles appear above dialogs/custom created displays?
Hello, Ive made a rope and ive attached it to a helicopter
then ive used ropeAttachTo on another object but the object ive attached to the rope doesnt stay with the rope and just breaks away
they break when too much tension si applied so their probably just breaking
also make sure the simulation of the object being picked up is enabled
QS, sounds like they're moving some assets from ebo to pbo.
_x addEventHandler ["killed", {[OpforPlayers] remoteExecCall [remainOpfor, 2]; }];
uhmmm
https://i.gyazo.com/afef4b67abc6f82f707cfc94fa2fa516.png
what is remainOpfor ?
private ["_aliveCount","_OpforUnits","_tempString"];
_OpforUnits = [];
{
_tempString = str _x;
_OpforUnits pushBack _tempString;
}forEach (_this select 0);
_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _OpforUnits;
_formattedOpfor = format ["Units: %1, number of units in array: %2", _OpforUnits, count _OpforUnits];
hint _formattedOpfor;
if(_aliveCount == 1) exitWith
{
[[],"LastOne.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 0) exitWith
{
[[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
};
more embaressing code
is a unit leaves mid game should I be checking to see if they're nil?
unit meaning player
So it's a function?
ya
You have to pass the function by name (string) and not the function
That would be huge network traffic.
You understand?
brb looking at wiki
lol
oh I see
just put some quote marks around it
so "remainOpfor"
yup
just wanted to see if teh example confirmed my understanding
I personally use this though: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers/addMissionEventHandler#HandleDisconnect
@plucky beacon enabled simulation on the object being towed but still no luck
it must be too heavy
there are setMass commands I think, don't know if that will work though
tries lifting house
house dosn't get picked up
rip my dreams of a house sized wrecking ball
nooooo
so I have this function that after checking what's on the blufor side, spwns the appropriate counterpart for the opfor side.
Choose Enemies
private ["_bluforUnits"];
_bluforUnits = _this select 1;
{
if (typeOf _x == "B_Officer_F") exitWith {[_x , "O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Soldier_SL_F") exitWith {[_x , "O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Soldier_TL_F") exitWith {[_x , "O_Soldier_TL_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Soldier_UAV_F") exitWith {[_x , "O_Soldier_UAV_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Medic_F") exitWith {[_x , "O_Medic_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Soldier_AR_F") exitWith {[_x , "O_Soldier_AR_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Soldier_AAR_F") exitWith {[_x , "O_Soldier_AAR_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Soldier_GL_F") exitWith {[_x , "O_Soldier_GL_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Soldier_M_F") exitWith {[_x , "O_Soldier_M_F"] call missionStarter_fnc_spawnEnemies;};
if (typeOf _x == "B_Soldier_lite_F") exitWith {[_x , "O_Soldier_lite_F"] call missionStarter_fnc_spawnEnemies;};
}forEach _bluforUnits;
Spawn Enemies
priavte ["_bluforUnit","_opforClassname","_markerPos","_newUnit"];
_bluforUnit = _this select 0;
_opforClassname = _this select 1;
_markerPos = getMarkerPos "Opfor_Start";
_newUnit = createVehicle [_opforClassname, getMarkerPos "marker1", [], 5, "NONE"];
Whats the best way to make sure opfor are all in a group
Use a switch ๐ @plucky beacon
make it case insensitive so you can actually use it @BuGuu
put the opfor class on a var / return, and pass that instead of having the function name 10 times
what else? ๐
switch (toLower ....)```
use params or at least inline private _bluforUnits ? ๐
create a pseudo namespace, assign these functions as variables with the varname being the classname once and then just read the correct function from the namespace.
that is also faster with more than one unit
Way to blow his mind commy
@austere granite I can't inline because the opfor are spawned individually by the function.
Lets start with making this a switch case
Need some dictionaries in SQF
Well we talked about namespaces yesterday but i don't know how I would make a psuedo one
I know how to reference the missionnamespace to find a global variable.
So basically
Switch(_classname) do {
Case "B_Soldier_AR_f" :{code}
}
Im on my phone rn but that's the idea of it
Yes
Commy pointed out possible problems with case
You can combat that by using toLower and writing your hard coded class names in lower case
once:
missionStarter_spawnEnemiesNamespace = [] call CBA_fnc_createNamespace;
missionStarter_spawnEnemiesNamespace setVariable ["B_Officer_F", {[_x , "O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_SL_F", {[_x , "O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_TL_F", {[_x , "O_Soldier_TL_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_UAV_F", {[_x , "O_Soldier_UAV_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Medic_F", {[_x , "O_Medic_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_AR_F", {[_x , "O_Soldier_AR_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_AAR_F", {[_x , "O_Soldier_AAR_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_GL_F", {[_x , "O_Soldier_GL_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_M_F", {[_x , "O_Soldier_M_F"] call missionStarter_fnc_spawnEnemies;}];
missionStarter_spawnEnemiesNamespace setVariable ["B_Soldier_lite_F", {[_x , "O_Soldier_lite_F"] call missionStarter_fnc_spawnEnemies;}];
per unit:
call (missionStarter_spawnEnemiesNamespace getVariable typeOf _unit);
that is case insensitive
adds a mod requirement doe
If it's possible to I want to keep dependy out
does CBA technically need to be a mod in the first place? isn't it just scripts?
CBA as a whole?
yeah it doesn't have any .dlls in it or anything does it?
if you write them all in lower case, yeah
XEH uses config changes. there are a bunch of other config changes too
oh yeah
If A4 ever comes around and it's still useful, then rewrite everything from scratch and try to not have configs I guess.
But it's just not possible in some cases.
do I also need to lowercase the string next to "case" ?
yes
oh good, I did
Running into a bit of an issue with the lineIntersects commands - seems like it doesn't detect static map objects far away from the player when the game first starts. If I move the player where it stops detecting static map objects, and then restart the mission, the command starts detecting them.
Seems like the static map objects aren't loaded it memory unless the player is nearby
what's the relation between text size and safezoneH? trying to have a control that is exactly as high as the text size
hi master of ropes. good to see you. choochoo! can't wait for the train man. looks liek a lot fo fun to play around with
text size is ui height value
Text size = SafeZoneH = letters as high as entire screen
hm yea. in dialogs but inside parseText stuff it seems different
You mean <t size=> size?
ye
ah. let me test some stuff with that thought. thx so far
Sa-Matra, thanks that fixed it
gaaah this thing, keep getting the error in the image
BluforPlayers = [];
{
if(side _x == west) then
{
if(alive _x) then
{
BluforPlayers pushBack _x;
};
};
}forEach allUnits;
publicVariable "BluforPlayers";
{
_x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2];
} forEach BluforPlayers;
private ["_bluforUnit","_classname","_LowerClassname"];
_bluforUnit = (_this select 0);
_classname = (typeOf _bluforUnit);
_LowerClassname = (toLower _classname);
switch (_LowerClassname) do {
case "b_officer_f": {["O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;};
case "b_soldier_sl_f": {["O_Soldier_SL_F"] call missionStarter_fnc_spawnEnemies;};
case "b_soldier_tl_f": {["O_Soldier_TL_F"] call missionStarter_fnc_spawnEnemies;};
case "b_soldier_uav_f": {["O_Soldier_UAV_F"] call missionStarter_fnc_spawnEnemies;};
case "b_medic_f": {["O_Medic_F"] call missionStarter_fnc_spawnEnemies;};
case "b_soldier_ar_f": {["O_Soldier_AR_F"] call missionStarter_fnc_spawnEnemies;};
case "b_soldier_aar_f": {["O_Soldier_AAR_F"] call missionStarter_fnc_spawnEnemies;};
case "b_soldier_gl_f": {["O_Soldier_GL_F"] call missionStarter_fnc_spawnEnemies;};
case "b_soldier_m_f": {["O_Soldier_M_F"] call missionStarter_fnc_spawnEnemies;};
case "b_soldier_lite_f": {["O_Soldier_lite_F"] call missionStarter_fnc_spawnEnemies;};
default { hint "Classname not valid" };
};
and all those private variables are me trying to figure out where exactly it's coming from, I've changed it back to [] for the arguments but then it says it wants an objcet
because I guess select 0 is an array, but an array of one object?
now it's working now that I made the arguments in brackets again, but I'm getting another error
because it says this
if (MissionActive) then
{
_newUnit addEventHandler ["killed", {[OpforPlayers] remoteExecCall ["missionStarter_fnc_remainOpfor", 2]; }];
};
can't work like
[_x] addEventHandler ["...
do I have to (select 0 (select 0))?
@plucky beacon https://hastebin.com/cexobuzuqu.cpp
Also, it's telling you that you're selecting an from an object type. You are using _x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2]; so _this is an object, not an array, you need to pass [_x] or do _bluforUnit = _this
oh shit it has to equal something?
Why not more that table into config?
huh?
class MyTableOfWhatever {
b_officer_f = "O_Soldier_SL_F";
b_soldier_sl_f = "O_Soldier_SL_F";
b_soldier_tl_f = "O_Soldier_TL_F";
b_soldier_uav_f = "O_Soldier_UAV_F";
b_medic_f = "O_Medic_F";
b_soldier_ar_f = "O_Soldier_AR_F";
b_soldier_aar_f = "O_Soldier_AAR_F";
b_soldier_gl_f = "O_Soldier_GL_F";
b_soldier_m_f = "O_Soldier_M_F";
b_soldier_lite_f = "O_Soldier_lite_F";
};
and then do
_opforUnit = getText(missionConfigFile >> "MyTableOfWhatever" >> typeOf _bluforUnit);
because every time I do it one way someone else tells me to do it another way. I've changed it 4 times now
Well you now learned 5 ways to do same thing
yes
and no matter what way it checks the cases it's still not working so I'd like to get that problem solved
Day well spent ๐
where the hell are all these brackets coming from, they're littered in my code
wtf happened
So what are you trying to do again?
Spawn some opfor units depending on blufor units?
ya
client of the group leader
so they are the only ones that can "start" the mission
and then it sends to the server
as well as a few redundancies
Why do you iterate all units and not just client's group units?
because they're not all in one group?
well you just said client of the group leader
starts the script
So practically all this is gonna be executed only once?
yes
Why not do everything on server?
it does, I'm just redundant like that
Client on add action or whatever:
remoteExecCall ["missionStarter_fnc_gimmeEnemies", 2];
Server's fn_gimmeEnemies.sqf:
allUnits select {
side group _x == blufor
} apply {
_class = getText(missionConfigFile >> "MyTableOfWhatever" >> typeOf _x);
if(_class != "") then {
// createUnit or whatever you want here
};
}
init_mission.sqf
_unit = _this select 1;
if (_unit != Leader_1) exitWith {hint "You are not the leader, mission must be initiated by the leader.";};
//if (isNil "Leader_1") exitWith {hint "There is no group leader"};
hint "Unit is leader, calling initMission script locally";
systemchat "Unit is leader, calling initMission script locally";
MissionActive = true;
publicVariable "MissionActive";
[[],"initMission_local.sqf"] remoteExec ["execVM",0,true];
sleep 12;
[] remoteExecCall ["missionStarter_fnc_getUnits", 2, false];
init_mission.sqf is triggered from addAction?
ya
Do you need MissionActive flag only so server does something on addPublicVariableEventHandler?
It's used in some if checks
I don't see any check for activating the action again
the action is deleted in the local script
๐
Well you can call action several times on same frame with macros
Don't trust the player
can we solve problem #1 first
the case switch
private ["_bluforUnit","_classname","_LowerClassname","_caseResult"];
_bluforUnit = _this;
private _caseResult = switch (toLower _bluforUnit) do {
case "b_officer_f": {"O_Soldier_SL_F"};
case "b_soldier_sl_f": {"O_Soldier_SL_F"};
case "b_soldier_tl_f": {"O_Soldier_TL_F"};
case "b_soldier_uav_f": {"O_Soldier_UAV_F"};
case "b_medic_f": {"O_Medic_F"};
case "b_soldier_ar_f": {"O_Soldier_AR_F"};
case "b_soldier_aar_f": {"O_Soldier_AAR_F"};
case "b_soldier_gl_f": {"O_Soldier_GL_F"};
case "b_soldier_m_f": {"O_Soldier_M_F"};
case "b_soldier_lite_f": {"O_Soldier_lite_F"};
default { hint "Classname not valid"; "" };
};
if (_caseResult isEqualTo "") exitWith {};
[_caseResult] call missionStarter_fnc_spawnEnemies;
blufor unit is the classname that's being passed
Well you forgot typeOf
from...
You're trying to lower actual unit, not its class
_classname = (typeOf _bluforUnit);
_LowerClassname = (toLower _classname);
this bit
From your last
yes
neat
I'll keep because they look neat
fuck your bytes
Think how much world traffic you can save by removing parenthesis
I paid for mine faire an square
also what was that about event handlers? I can create my own?
Event handlers are engine event handlers
There is set of engine events that can call whatever scripts you assign to them
remoteExec* is ideal for that
You can do it through pveh if you want too
To make sure you send it once just add a check before sending it again
init_mission.sqf:
_unit = _this select 1;
if (_unit != Leader_1) exitWith {hint "You are not the leader, mission must be initiated by the leader.";};
if (MissionActive) exitWith {hint "Its already on"};
MissionActive = true;
publicVariable "MissionActive";
remoteExecCall ["missionStarter_fnc_gimmeEnemies", 2];
oh so it's just another if?
Actually MissionActive might not be initialized at all so
if(missionNamespace getVariable ["MissionActive", false]) exitWith {hint "Its already on"};
Of course, just dont let player send the flag again
Since its the only source where this flag can be set from right now
stupid strings, I messed up my code where it didn't need to be fixed
trying to get that other part workign
This is weird
private ["_aliveCount","_OpforUnits","_tempString"];
_OpforUnits = [];
{
_tempString = str _x;
_OpforUnits pushBack _tempString;
}forEach (_this select 0);
_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _OpforUnits;
_formattedOpfor = format ["Units: %1, number of units in array: %2", _OpforUnits, count _OpforUnits];
hint _formattedOpfor;
systemChat _formattedOpfor;
if(_aliveCount == 2) exitWith
{
[[],"LastOne.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 1) exitWith
{
[[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
};
it's output to system chat shows the 34 elements but the count is incorrect and ends the mission.
it happens after this in the getUnits file
{
_x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2];
} forEach BluforPlayers;
{
if(alive _x) then
{
if (side _x == east) then
{
OpforPlayers pushBack _x;
};
};
}forEach allUnits;
publicVariable "OpforPlayers";
/*
{
[_x] call missionStarter_fnc_loadoutApply;
if (MissionActive) then
{
_x addEventHandler ["killed", {[OpforPlayers] remoteExecCall ["missionStarter_fnc_remainOpfor", 2]; }];
};
} forEach OpforPlayers;
*/
[OpforPlayers] call missionStarter_fnc_remainOpfor;
oh, it's at the end of getUnits
gimme a second I'll copy it here after I delete some comments
BluforPlayers = [];
OpforPlayers = [];
{
if(side _x == west) then
{
if(alive _x) then
{
BluforPlayers pushBack _x;
};
};
}forEach allUnits;
publicVariable "BluforPlayers";
_formattedBlufor = format ["Units: %1, number of units in array: %2", BluforPlayers, count BluforPlayers];
hint _formattedBlufor;
{
[_x] call missionStarter_fnc_loadoutApply;
if (MissionActive) then
{
_x addEventHandler ["killed", {[BluforPlayers] remoteExecCall ["missionStarter_fnc_remainBlufor", 2]; }];
};
} forEach BluforPlayers;
[BluforPlayers] call missionStarter_fnc_remainBlufor;
{
_x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2];
} forEach BluforPlayers;
{
if(alive _x) then
{
if (side _x == east) then
{
OpforPlayers pushBack _x;
};
};
}forEach allUnits;
publicVariable "OpforPlayers";
[OpforPlayers] call missionStarter_fnc_remainOpfor;
So this, being called from the initMission, the Opfor players gets passed onto remainOpfor
private ["_aliveCount","_OpforUnits","_tempString"];
_OpforUnits = [];
{
_tempString = str _x;
_OpforUnits pushBack _tempString;
}forEach (_this select 0);
_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _OpforUnits;
_formattedOpfor = format ["Units: %1, number of units in array: %2", _OpforUnits, count _OpforUnits];
hint _formattedOpfor;
systemChat _formattedOpfor;
if(_aliveCount == 2) exitWith
{
[[],"LastOne.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 1) exitWith
{
[[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
};
This is so bad I'd just Ctrl+A & Del it
LOL
no
_aliveCount = {!isNil _x && {alive (missionNamespace getVariable _x)}} count _OpforUnits;
it's probably this line
because originally it was designed to take out nil units
Why do you turn units into str and then trying to turn them back into units with getVariable ๐ค
because isNil doesn't work from objects
because he had undefined units which were erroring him out ๐
isNull
Vehicle var names are cancer ruining the day for new scripters
How do you create opfor units btw?
private ["_bluforUnit","_opforClassname","_markerPos","_newUnit"];
//_bluforUnit = _this select 0;
_opforClassname = _this select 0;
_markerPos = getMarkerPos "Opfor_Start";
_newUnit = group OpGrpLead createUnit [_opforClassname, getMarkerPos "opfor_start", [], 0, "NONE"];
_newUnit disableAI "MOVE";
[_newUnit] call missionStarter_fnc_loadoutApply;
if (MissionActive) then
{
_newUnit addEventHandler ["killed", {[OpforPlayers] remoteExecCall ["missionStarter_fnc_remainOpfor", 2]; }];
};
zMod1 addCuratorEditableObjects [[_newUnit],true ];
zMod2 addCuratorEditableObjects [[_newUnit],true ];
zMod3 addCuratorEditableObjects [[_newUnit],true ];
this is after the case switch
and this part is working already, it creates the units and outputs the array of them in system chat
Ok, I expected you naming each unit individually or something
allUnits already returns only alive units btw
I know, that's why alive count is probably the issue
Not really, it just does nothing
allUnits command already returns alive units only
Anyway, you don't need any str _tempString stuff
it used to be a problem of detecting nil units but not anymore
you already get array of units, work with it
I get what you're trying to do, but your newly created units don't have vehicle var names so you can str them into variable name
(_this select 0) is already array of units
Just work with it
Even more there is no point in checking which units are alive, allUnits already returns alive units only
You're sending it into another function and doing alive check 2nd time
It all makes no sense
but it's not all units because the global variable is only updated when using the publicVariable command
Why do you even publicVariable it?
this meant to be run on every death
it used to be for using in other files
but if I'm passing throuhg functions I don't need to anymore
Also you know what "Killed" event handler is local to whoever owns the unit?
Looks like you assigning it to blufor units only on server
It will never run in real MP
I wish drawTri3D or drawPoly3D was a thing
well I guess fillTri3D or fillPoly3D, really
even with remoteExecCall?
It wouldn't even get to remoteExecCall
If you assign Killed event handler to remote unit, it will never ever get executed
Unless ownership transfers to you
(Nobody say anything about MPKilled, it will make things worse)
So how else would I run the function on each death
Anyway, the whole thing is really badly designed
Its really hard to help you fix it
In your situation I'd create a scheduled thread and check alive units each second or something
BUT if you really want to do it through Killed event handler you'd have to do it differently
I originally did that but was told to do it another ay
You need to understand who will own units in the mission and in which situations
I guess OPFOR units will always be owned by server, right?
yes
You can use Killed event handler there, might as well assign it right after you create the unit
that's what it does already
There will be situations where it's only players
so you have disableAI = 1 in mission config?
So when player leaves unit just dies
I probably will, haven't decided yet
Anyway, lets make it work either way
Basically you will need to either:
a) Assign Killed event handler to each blufor unit on each client, preferably including server
b) Assign MPKilled to each blufor unit but only from server
How initMission is called again?
by an addaction
So client pressed action, remoteExec starts initMission on server?
this addaction ["<t color='#4286f4'>Start Mission</t>", "initMission.sqf",nil,6,true,false,"","",2];
the remote exec is after it checks if the local unit is the leader
ya it's in the script
_unit = _this select 1;
if (_unit != Leader_1) exitWith {hint "You are not the leader, mission must be initiated by the leader.";};
//if (isNil "Leader_1") exitWith {hint "There is no group leader"};
if (MissionActive) exitWith {hint "Its already on"};
hint "Unit is leader, calling initMission script locally";
systemchat "Unit is leader, calling initMission script locally";
MissionActive = true;
publicVariable "MissionActive";
[[],"initMission_local.sqf"] remoteExec ["execVM",0,true];
sleep 12;
[] remoteExecCall ["missionStarter_fnc_getUnits", 2, false];
so it checks there, then says that it passed
calling initMission script locally
Your remoteExec calls it for each client + ones that will join afterwards
yes
Its not locally then
local for each client?
Its globally
I guess? the point is it runs on each client, and stuff happens locally on each client
does local have to only happen on one unit?
And then each client does
[[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
in the end?
Each client sends execVM remote exec to each client resulting in ^ 2 remote execs
You don't need to count dead units on each client if you're gonna remoteExec victory to everyone
just count in one place (server) and then when server decides its game over, remoteExec victory
EndScreen = true;
sleep 1;
playMusic "Victory";
sleep 2;
Command sideRadio "MissionAccomplished";
["Command", "Mission Accomplished! Well done!"] call BIS_fnc_showSubtitle;
sleep 2;
["End1",True,True,False] call BIS_fnc_endMission;
that's what the remainOpfor does
remainOpfor happens on the server
private ["_aliveCount","_OpforUnits"];
_aliveCount = {!isNull _x && {alive _x}} count (_this select 0);
_formattedOpfor = format ["Units: %1, number of units in array: %2", _OpforUnits, count _OpforUnits];
hint _formattedOpfor;
systemChat _formattedOpfor;
if(_aliveCount == 2) exitWith
{
[[],"LastOne.sqf"] remoteExec ["execVM",0,false];
};
if(_aliveCount == 1) exitWith
{
[[],"BluforVictory.sqf"] remoteExec ["execVM",0,false];
};
[OpforPlayers] call missionStarter_fnc_remainOpfor;
Its called in that initMission
Then it needs to be remoteExecCall because that's supposed to be the first check?
Nevermind last message, forgot about Killed event handlers
oh
Basically you're doing useless work on clients, clients don't need to even know about opfor units
what work is uesless ont he client
The logic should be following:
Client: Press action, send flag to server
Server: Create units
Server: Assign event handlers to handle remaining units
Server: On event handlers send out game over remoteExec's
client presses action, initmission local starts
removeAllActions vehicleSpawner_1;
removeAllActions vehicleSpawner_2;
removeAllActions vehicleSpawner_3;
removeAllActions vehicleSpawner_4;
removeAllActions vehicleSpawner_5;
removeAllActions vehicleSpawner_6;
removeAllActions vehicleSpawner_7;
removeAllActions SpawnerSign;
removeAllActions MissionStarter;
INIT_TIME = 10;
Button_Time = 0;
BEGIN_TIME = diag_tickTime + 0;
while {Button_Time < INIT_TIME} do
{
Button_Time = diag_tickTime - BEGIN_TIME;
uiSleep 0.99;
_time = INIT_TIME - Button_Time;
_finish_time_minutes = floor(_time / 60);
_finish_time_seconds = floor(_time) - (60 * _finish_time_minutes);
if(_finish_time_seconds < 10) then
{
_finish_time_seconds = format ["%1", _finish_time_seconds];
};
_formatted_time = format ["%1", _finish_time_seconds];
hintSilent format ["Operation starting in: %1", _formatted_time];
};
cutText ["", "BLACK OUT"];
sleep 1;
player setPos (getMarkerPos "west_start");
cutText ["", "BLACK IN"];
MissionActive = true;
publicVariable "MissionActive";
hint "timer script calling";
systemchat "timer script calling";
playMusic "Intro";
setPlayerRespawnTime 999999;
if(isServer) then {
[[],"timer.sqf"] remoteExec ["execVM",0,true];
};
this doesn't go anwywere else it ends here
then the server runs the timer
[] remoteExecCall ["missionStarter_fnc_getUnits", 2, false];
starts the server functions
getUnits use remoteExecCall to the server redundantly but still to the server nonthe less
You're confusing me with all these script listing without naming what files are which
MissionActive = true;
publicVariable "MissionActive"; in that script above
I have no idea what the hell is going on
You just said that MissionActive sets in addAction
Or that huge script above is now addAction or something?
initMission_local.sqf is global
initMission.sqf is local
initMission_local.sqf is called for every client including server
initMission.sqf is called only on client that pressed addAction
หขแต แถฆ หขสฐแตแตแถซแต แตสณแตแตแตแตแถซสธ สณแตแถฐแตแตแต แตสฐแตแต
Why do you do
if (MissionActive) then
checks in fn_getUnits if you set MissionActive to true in initMission.sqf anyway?
if fn_getUnits is called only on server, why do you remoteExec server again with
_x remoteExecCall ["missionStarter_fnc_chooseEnemies", 2];
Just do _x call missionStarter_fnc_chooseEnemies
because I'm an doofus who does redundant things
I was under impression your getUnits script was executing on each client because of that
Why else you would need to remoteExec server if its already server
because I'm a doofus who does redundant things
[_x] call missionStarter_fnc_loadoutApply
also the event handler should remain remoteexeccall shoudln't it? because the unit's ownership might not be on the server?
You added event handler on server, it cannot execute anywhere else
if it will ever execute (which would not for blufor in real MP)
[_x] call missionStarter_fnc_loadoutApply
Setting loadouts from server to remote clients might not always work, some loadout commands require unit to be local
That's where you will need remoteExec, to make sure client does loadout themselves
so I need to target the unit?
[_x] remoteExecCall ["missionStarter_fnc_loadoutApply", _x];
Tell them to loadoutApply themselves
This doesn't handle JIP players though, but lets not touch that for now
Anyone know the differences of a camera created with camCreate and the camera used in players? I'm having problems to make a created camera show the player view even if its placed in player eye position and the correct direction is set.. .seens Fov is different or something.
Its completely different simulation, when you look through camCreate'd camera you get camera simulated viewport, when you look through unit you get to see their weapon, where they turn their head, etc.
Placing camera in some unit's eye will still mean you're just getting basic camera viewport
@plucky beacon Since locality of blufor units is unknown and to make things easier you will need MPKilled event handler on blufor units
okay
_index = player addMPEventHandler ["mpkilled", {Null = _this execVM "playerkilled.sqf";}];
from the BI wiki
addMPEventHandler ["MPKilled", {if(isServer) then {BluforPlayers call missionStarter_fnc_remainBlufor}}]
okay so this just makes sure the event is handled by the server
MP event handlers actually transfer your entire code that you have for event over network to all clients saving you work adding same thing everywhere
But you will need to add isServer check in your case so that code proceeds only on server and does nothing on other clients
@meager granite but a created camera have the same default FOV of the player default FOV?
oh I get it, it's globally synced but you block clients with a server check
Yes, we only need to make sure it fires when unit dies regardless of who owns the unit
Just Killed would fire only if died unit was local to current client\server
Yes
Alternative but harder solution would be to add Killed everywhere and if it was not server that fired the code, remoteExec the server
In case with opfor units you can use Killed as server creates the units and other players never own them
right
So they're always local to server and Killed is sufficent
but the MPeventhandler is good to know because I might convert it to PVP later
@tough abyss No idea really, I think unit\vehicle fov is defined in CfgVehicles or something
Well do MPKilled for both then
_newUnit addMPEventHandler ["MPKilled", {if(isServer) then {OpforPlayers call missionStarter_fnc_remainOpfor}}];
Holy shit, you guys are still doing this.
dude we been doing this for days now
I saw a movie in the mean time.
fuck that shit
I saw "we" because I'm embaressed
Anyway, you're already sending an array of units (dead, null or not, doesn't matter)
You don't need any of that str and getVariable shit that people do for vehicle var named units
I think I deleted it
Doesn't the new entityKilled mission eh trigger for remote units?
So just iterate through _this to see how many units are still there
in the opforRemain I deleted the string stuff
ahahaha