#arma3_scripting
1 messages ยท Page 270 of 1
Also I don't think opfor is a valid entry.
It's east thats valid
Not opfor.
To check just type side into the watch field
It will return values.
Code didn't even run?
Are you working with the current file?
yes
Does the control exist?
((uiNameSpace getVariable "RscMetaGame") displayCtrl 12454)
Exists?
yes
Whats the rest of the code?
what code?
The stuff that actually invokes the GUI?
private _display = uiNameSpace getVariable "RscMetaGame";
private _sideColour = _display displayCtrl 12454;
switch (_playerSide) do {
case west: {
_sideColour ctrlSetBackgroundColor [0, 0.3, 0.6, 1];
};
case independent: {
_sideColour ctrlSetBackgroundColor [0, 0.5, 0, 1];
};
case civilian: {
_sideColour ctrlSetBackgroundColor [0.4, 0, 0.5, 1];
};
case east: {
_sideColour ctrlSetBackgroundColor [0.5, 0, 0, 1];
};
};```
Is this called or spawn'd?
spawn'd
already have it
at the top?
yep
Okay so what value is target?
private _target = cursorObject;
ive set other values with like ctrlsettext and that works
its just the background that is not setting
that is rscbutton
im using RscText
and it worked
before
now its not working anymore
What did you change?
If it's not working anymore you changed something 100%
i know but i dont know what
Use a previous snapshot?
I dont commit until im done
...
Comment everything...
This is why...
When stuff breaks you know what happened.
But I cant commit for each line of code I write
Self-documenting vars?
etc?
Also
Who thinks this is dirty code
This is froma community I hate.
So what's the current error @rotund cypress ?
No errors
/*
File: fn_keyInfo.sqf
Author: Redacted
Desc:
Displays info for the selected key's vehicle in the key menu dialog
*/
private ["_selection","_distance","_display","_displayDistance"];
disableSerialization;
_selection = _this select 0 select 1;
_distance = round(player distance (life_ogVehicles select _selection));
if (_distance >= 100000000) then {_distance = 0};
waitUntil {!isNull (findDisplay 2700)};
_display = findDisplay 2700;
_displayDistance = _display displayCtrl 228804;
_displayDistance ctrlSetText format["Distance: %1m",[_distance] call life_fnc_numberText];
/* ---------- END OF SCRIPT ---------- */
Background is not setting @dusk sage
If you use self documenting vars, think of how easy it will be for other sneaky servers to snag your code!
Perhaps it's not their intent to make the code readable to a third party?
If it mostly works, they're usually happy enough
No their dev team is full of retards
They have no idea about computational feasibility.
It's all bastardised stuff too.
From other communities.
Give you another example.
private["_allVeh","_pUID"];
sleep 5;
_allVeh = allMissionObjects "Car" + allMissionObjects "Air" + allMissionObjects "Ship";
_name = profileName;
{
_owners = _x getVariable ["vehicle_info_owners",[]];
_index = [_name,_owners] call fnc_index;
if(!(_index == -1)) then {
life_ogVehicles set[count life_ogVehicles, _x];
};
} foreach _allVeh;
Lets iteratively search the entire map for all objects.
...
Ehh, that all's already tracked by the engine.
There isn't 1000000 vehicles
If they were using nearestObjects I'd be really worried
So what
There is a lot of traffic.
Shouldn't be much traffic. They're not public'ing it in there. Not sure why they're waiting before checking.
life_ogVehicles set[count life_ogVehicles, _x]; <--- Pushback?
aye
Why are you being so salty about it
The code you posted of one of your first projects was a thousand times worse
You seem to think that code is the scum of the earth
It's not perfect
But it's not going to crash their server
I plan on becoming a computer scientist / nanotechnologist?
huh?
So salty isn't the right word.
Also I have the hacker ethic.
Make elegent, efficient code.
Not a butchered mess.
They have NOTHING.
It's why I changed the EH handled mission code.
Seems pretty salt to me
Sure, so you've gone from awful code to code that could be good?
And you're slamming this, because it doesn't appeal to you?
Comparing it to ACE3 / CBA?
It's disgusting.
Also "calling themselves devs" is what really erk'd me.
Agreed.
can i get a hacker ethic too please?
teach me senpai
i don't care if that's bad scripting or not, but it seems very bad manners to berate them in public
there's a lot of people in this discord, some of which could be from this community you have a vendetta against
Yep, as usual as soon as I ask I find the answer myself right away
What was it?
Check if entity is backpack apart from isKindOf Bag_Base, there is isbackpack value in config that defines it
oh ๐คฆ
I wonder what "reversed" in config is
https://community.bistudio.com/wiki/CfgVehicles_Config_Reference#reversed doesn't really tell
I'm going to take a stab at it being a class thing
๐คฆ
This overrides the default
Reverse the reverse?
Kind of doesn't make sense
Yeah, that's why I'm wondering
@rotund cypress Solve your problem?
He did
So InventoryOpened is not fully fixed ๐
If you open body with crate nearby, EH only reports the body but not crate while both are available in the inventory menu
have they made the arma team significantly smaller?
But have they actually? The same was said during A2, but it was regarding QA (and players wondering why BI were releasing employees to other projects) and the employees that had moved on to another project were artists (iirc).
The destroyed vehicle problem is really annoying
The sound sticks on one side till the vehicle gets deleted, doesn't matter where you are, the sound is always there
Yes
Yes
120,887 people who own a free project are now more important than 2,782,910 people who own a product which people still buy ๐
Btw, setShotsParents works perfectly fine, am using it since it is available
There is no secret, just use it as it is described in the wiki
setShotsParents [vehicle _unit, _unit]
not vice versa
Is the facewear bug new? Any units that enter water, even if ankle deep, their face wear disappears. Only just noticed it this morning.
Yes, still server. I'm creating a CAS plane with an AI on the server and the player who called the CAS plane gets the points of the AI kills (just one example, doing the same with arty)
_plane setVariable ["d_who_fired", _caller];
_plane addEventhandler ["fired", {
params ["_vec"];
private _whof = _vec getVariable "d_who_fired";
if (!isNil "_whof") then {
private _aop = missionNamespace getVariable _whof;
if (!isNil "_aop" && {!isNull _aop}) then {
_this select 6 setShotParents [_vec, _aop];
};
};
}];
Code tags?
I'm using the variable name and reading the unit from mission namespace
is mouseButtonClick eventhandler broken? worth reporting it as a bug?
disableSerialization;
private _parentDisplay = (findDisplay 12);
waitUntil { !(isNull _parentDisplay) };
_ctrl = _parentDisplay ctrlCreate ["RscButton", 6557];
_ctrl ctrlSetPosition [SafeZoneX + (15 / 1920) * SafeZoneW, SafeZoneY + (795.25 / 1080) * SafeZoneH];
_ctrl ctrlSetText "default";
_ctrl ctrlAddEventHandler ["MouseButtonDown", {_this select 0 ctrlSetText "down" }];
_ctrl ctrlAddEventHandler ["MouseButtonUp", {_this select 0 ctrlSetText "up" }];
_ctrl ctrlAddEventHandler ["MouseButtonClick", {_this select 0 ctrlSetText "clicked" }];
_ctrl ctrlCommit 0;
};```
surely it should fire on mouse down + mouse up over ctrl, rather than after a second or so of mousedown?
^ can test by running that, opening map, clicking button
i think its because there's a seperate one for double click, so it waits if you don't do a double click
not 100% sure on it, but that's what i think it was
anyone ever succesfully use an X macro in arma?
when you go to properties on your arma 3 dedicated box to change the target or command line, you cannot fully enter it as it will cut off towards the end
@thick lintel Facewear disappearing in water is intentional
@rancid ruin your code is nonsensical
if #12 is null, the waitUntil loop is infinite
even if #12 appears later, you stored a null display in your variable
Hey all, just little question: Are the MissionEHs Local or Global, so do I have to add them for each client ? Thanks in advance ๐
they are only executed on the machine they were attached on
you have to use addMissionEventHandler on every machine
@little eagle cool thanks ๐
is there something like "ctrlFocused"? or any other way to detect whether a certain active text is selected?
no
damn, yet thanks :)
will this most likely lag out the server?
while { true } do {
if ( visibleMap && { "ItemGPS" in (assignedItems player) } || { "B_UavTerminal" in (assignedItems player) } ) then {
};
sleep 2;
};```
I just want to do stuff when those equals true
is it run on client or server? if on client, then it should be ok
you can also use this then:
its run on client init
oh I guess I could
So then when each user is opening map it will spawn for example if i spawn within that eventhandler?
@vague hull
only for that certain user who opened it but yeah
it will call that code you assigned
Any ideas why this isn't working?
["Initialize", [selectRandom (call Tactics_Core_GetPlayersInArena), [], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator;
Tactics_Core_GetPlayersInArena returns all units in the arena
those units are AI which are remote controlled by players
This works, but isn't what I want: ["Initialize", [player, [], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator;
Documentation on the EG Spectator system: https://community.bistudio.com/wiki/EG_Spectator_Mode
What does call Tactics_core_getPlayeresInArena return?
^
Tactics_Core_GetPlayersInArena =
{
(call Tactics_Core_GetPlayers) inAreaArray Tactics_Core_ArenaVolume;
};
Tactics_Core_GetPlayers =
{
allUnits select { alive _x && isPlayer(_x getVariable ["Tactics_Player", objNull]) };
};
The functions do return the correct units as expected
but it looks like BIS' spectator system doesn't like those units for some reason and won't initialize
It does return players yes?
_x getVariable ["Tactics_Player", objNull] <----- should point to the player who controls the unit
yes
Tactics_Player ?
everything on my end works
Have you looked at the functions viewer?
it's BI's spectator system that isn't working as I expect
What am I looking for in the functions viewer?
I took a quick glance at the EGSpectator function
Not take it apart.
I am hoping that there is a way to just position the spectator camera to where I want, instead of requiring that I pass in a unit to focus on
but I didn't see anything on who to do that
@tough abyss A3\functions_f_exp_a\EGSpectator\fn_EGSpectator.sqf
that's the path
Do you have ArmA 3 Addons dev environment setup?
/*
Author:
Nelson Duarte
Description:
Spectator instance
Returns:
Multiple values / none
Examples:
["Initialize", [player]] call BIS_fnc_EGSpectator; // Initializes spectator for given player
["Terminate"] call BIS_fnc_EGSpectator; // Terminates spectator for given player
Wrong params?
Thats it.
ah nvm I see.
I'm not opposed to using a third-party spectator script as long as I can specify the units available to spectate, as well as being able to terminate the spectator mode at ease.
I just prefer the fluidity of BI's spectator mode
or if you want to say, "splendidness" lol
I actually have another communities framework
Where they've hooked into this.
I don't steal stuff by the way.
I told them what I wanted it for, they said sure.
Anyones code I use to learn from new stuff.
[] call bis_fnc_respawnspectator;
Thats all I can see they used.
Have you tried to directly call the code?
["Initialize", [player, [], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator;
?
Old programming addage is if you can't solve something with complex code.
Simplify it.
See if that works @wispy cosmos
just tried [] call bis_fnc_respawnspectator;
it doesn't allow me to spectate my AI units
some background with how my mission works
when a player joins, it creates an AI unit which they switch in and out of using remoteControl
I want to only spectate those AI units
["Initialize", [player, [], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator; <-- this worked before, but it won't let me spectate AI units
it focuses on the dummy player unit but won't accept the remote-controllable AI units
does remoteControl, change locality?
if you want, you can join my server and tinker around with it
I have the debug console enabled in the mission
Sure.
I am wonder if it's locality realted.
does remoteControl, change locality?
Yes
except for gunners in those drones I guess. where only the turret becomes local when someone else is driving
here's my two functions which allow the player to control and revoke control of the unit
Tactics_Client_GainControl =
{
if(Tactics_Core_IsHardcoreMode) then
{
cutText ["", "BLACK IN", 0.1];
}
else
{
cutText [format ["Turn %1: It's your turn.", Tactics_Core_CurrentTurn],"PLAIN", 0.25];
playSound "defaultNotification";
};
["Terminate"] call BIS_fnc_EGSpectator;
switchCamera Tactics_Client_ControlledUnit;
player remoteControl Tactics_Client_ControlledUnit;
};
Tactics_Client_RemoveControl =
{
if(alive Tactics_Client_ControlledUnit && Tactics_Client_ControlledUnit call Tactics_Core_IsInArena || Tactics_Core_IsGameOver) then
{
if(Tactics_Core_IsHardcoreMode) then
{
cutText [format ["Turn %1: Please wait...", Tactics_Core_CurrentTurn],"BLACK OUT", 0.25];
}
else
{
cutText [format ["Turn %1: Please wait...", Tactics_Core_CurrentTurn],"PLAIN", 0.25];
};
[] spawn
{
_position = getPosASL Tactics_Client_ControlledUnit;
_tick = diag_tickTime;
disableUserInput true;
waitUntil { diag_tickTime != _tick };
objNull remoteControl Tactics_Client_ControlledUnit;
if(Tactics_Core_IsHardcoreMode) then
{
switchCamera Tactics_Client_HardcoreCameraGameLogic;
}
else
{
switchCamera Tactics_Client_ControlledUnit;
};
Tactics_Client_ControlledUnit disableAI "ALL";
Tactics_Client_ControlledUnit setPosASL _position;
disableUserInput false;
};
}
else
{
cutText [format ["Turn %1", Tactics_Core_CurrentTurn], "PLAIN DOWN", 0.25];
};
};
I wasn't sure how to do code formatting on here
that's not a block, but a line
2 seconds
Tactics_Client_GainControl = { if(Tactics_Core_IsHardcoreMode) then { cutText ["", "BLACK IN", 0.1]; } else { cutText [format ["Turn %1: It's your turn.", Tactics_Core_CurrentTurn],"PLAIN", 0.25]; playSound "defaultNotification"; }; ["Terminate"] call BIS_fnc_EGSpectator; switchCamera Tactics_Client_ControlledUnit; player remoteControl Tactics_Client_ControlledUnit; }; Tactics_Client_RemoveControl = { if(alive Tactics_Client_ControlledUnit && Tactics_Client_ControlledUnit call Tactics_Core_IsInArena || Tactics_Core_IsGameOver) then { if(Tactics_Core_IsHardcoreMode) then { cutText [format ["Turn %1: Please wait...", Tactics_Core_CurrentTurn],"BLACK OUT", 0.25]; } else { cutText [format ["Turn %1: Please wait...", Tactics_Core_CurrentTurn],"PLAIN", 0.25]; }; [] spawn { _position = getPosASL Tactics_Client_ControlledUnit; _tick = diag_tickTime; disableUserInput true; waitUntil { diag_tickTime != _tick }; objNull remoteControl Tactics_Client_ControlledUnit; if(Tactics_Core_IsHardcoreMode) then { switchCamera Tactics_Client_HardcoreCameraGameLogic; } else { switchCamera Tactics_Client_ControlledUnit; }; Tactics_Client_ControlledUnit disableAI "ALL"; Tactics_Client_ControlledUnit setPosASL _position; disableUserInput false; }; } else { cutText [format ["Turn %1", Tactics_Core_CurrentTurn], "PLAIN DOWN", 0.25]; }; };
there..
{
if(Tactics_Core_IsHardcoreMode) then
{
cutText ["", "BLACK IN", 0.1];
}
else
{
cutText [format ["Turn %1: It's your turn.", Tactics_Core_CurrentTurn],"PLAIN", 0.25];
playSound "defaultNotification";
};
["Terminate"] call BIS_fnc_EGSpectator;
switchCamera Tactics_Client_ControlledUnit;
player remoteControl Tactics_Client_ControlledUnit;
};
Tactics_Client_RemoveControl =
{
if(alive Tactics_Client_ControlledUnit && Tactics_Client_ControlledUnit call Tactics_Core_IsInArena || Tactics_Core_IsGameOver) then
{
if(Tactics_Core_IsHardcoreMode) then
{
cutText [format ["Turn %1: Please wait...", Tactics_Core_CurrentTurn],"BLACK OUT", 0.25];
}
else
{
cutText [format ["Turn %1: Please wait...", Tactics_Core_CurrentTurn],"PLAIN", 0.25];
};
[] spawn
{
_position = getPosASL Tactics_Client_ControlledUnit;
_tick = diag_tickTime;
disableUserInput true;
waitUntil { diag_tickTime != _tick };
objNull remoteControl Tactics_Client_ControlledUnit;
if(Tactics_Core_IsHardcoreMode) then
{
switchCamera Tactics_Client_HardcoreCameraGameLogic;
}
else
{
switchCamera Tactics_Client_ControlledUnit;
};
Tactics_Client_ControlledUnit disableAI "ALL";
Tactics_Client_ControlledUnit setPosASL _position;
disableUserInput false;
};
}
else
{
cutText [format ["Turn %1", Tactics_Core_CurrentTurn], "PLAIN DOWN", 0.25];
};
};```
got it
thanks
this is also relevant:
{
_side = param [0];
_unit = Tactics_Client_DummyGroup createUnit ["C_man_1", [0, 0, 0], [], 0, "FORM"];
[_unit] joinSilent Tactics_Client_DummyGroup;
[_unit] joinSilent grpNull;
if(_side == west) then
{
_unit call Tactics_Client_LoadSWATLoadout;
}
else
{
_unit call Tactics_Client_LoadTerroristLoadout;
};
_unit setVariable ["Tactics_Player", player, true];
_unit disableAI "ALL";
_unit addEventHandler ["HandleDamage",
{
_unit = _this select 0;
_damage = _this select 2;
_source = _this select 3;
if(_source != objNull) then
{
_damage = _damage * Tactics_Core_DamageModifier;
};
(damage _unit) + _damage;
}];
_unit addEventHandler ["Killed",
{
["Initialize", [selectRandom (call Tactics_Core_GetPlayersInArena), [], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator;
}];
if(!isNull Tactics_Client_ControlledUnit) then
{
deleteVehicle Tactics_Client_ControlledUnit;
};
Tactics_Client_ControlledUnit = _unit;
};```
Thats me Zooloo75
?
You should use CBA_A3
For development allows you to go backwards
in the code you've executed
And select previous code you executed
Just make sure you remove the CBA_A3 addon reference when your done.
Similar yes.
How do you do that in CBA? I've never noticed anything like that.
oh
you mean the debug console
I thought you were talking about CBA magically tracking everything that gets executed
It does.
Those previous execute buttons?
and next?
Allow you to select previous code to execute
it's just a history feature
not a call stack
don't even see how the latter would be possible
debug console has a history with CBA
yea
and in ACE we have call stacks
I know that
powered by CBA
but you have to set up all your functions in a way to support it
welp
magically it won't work
Of course
I'd imagine you could feed in the text from a script and programatically inject a variable that tracks the progress after each statement
needs to use PREP() macro to define those functions
then have a pseudo-call stack
no it's just a function header that can be added by enabling debug mode
don't even know why that was brought up
shrug
just trying to figure out why BI's spectator system doesn't want to spectate certain units
It was brought up because I've found CBA_A3's history feature to be really helpful.
yea, it's useful
why BI's spectator system doesn't want to spectate certain units
maybe
just maybe
it's broken
ยฏ_(ใ)_/ยฏ
kinda figured
wouldn't be the first time
going to do an isolated test to narrow down the possible issues
good. simple repros
could be because I'm a player who is remoteControl'ing into the AI unit which is created on my client system
idk
locality issues?
there's bound to be something preventing these units from being used by the spectator system
some illogical filter...
well, I know the AI units are local
they're created on the client system
and they're grouped to a dummy group created on the client system
gonna just try someone else's spectator system and see how that goes
Tried directly calling the unit spawn'd?
in the EGSpector function to see what happens?
already tried
{
["Initialize", [selectRandom (call Tactics_Core_GetPlayersInArena), [], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator;
}];```
this is where the spectator system is supposed to start up
Lets stick this in watch field
and do an exhaustive test.
selectRandom (call Tactics_Core_GetPlayersInArena)
See if it through someting wrong.
already did that
all my functions work correctly
something is happening in the EG Spectator system which doesn't accept my arguments
I haven't
the INC contains all the macros
What happens over network when you add magazine with addMagazineCargo (not global) to say your uniform container and then drop it on the ground? Will magazines somehow sync to everyone since it was active player uniform?
To the code.
Or same question from the other side, does calling addMagazine and have it added to your uniform broadcast it over network right away? (or even registers in BE's addmagazinecargo log)
@meager granite I'd figure that it would create a global weapon container in the world
and place the appropriate gear into it
just a guess
can't give a definite answer on that though
define "right away"
@Zooloo did you add a side whitelist?
@tough abyss no
Try that.
Right away, synced to other clients right away
it is synched as long as it was used on a local unit
Or maybe delayed sync somehow, I'm not exactly sure how it works for player-worn containers, maybe there is special behavior
Oh this is interesting
// Make sure call was not done by a dedicated server or headless client
if (!hasInterface) exitWith {};
// Make sure local player is fully initialized
waitUntil { !isNil { player } && { !isNull player } };
// Whether spectator systems are already initialized
private _bIsInitialized = ["IsInitialized"] call SPEC;
// Whether given unit is also local player
private _isPlayer = _spectator == player;
// Make sure that:
// * Spectator was not initialized already
// * We only execute spectator for local player if controlling unit
if (!_bIsInitialized && _isPlayer) then
ohhhhhh
!isNil { player }
good find @tough abyss
this does nothing
_isPlayer should be false in this case
Basically I want to add lots of magazines into three different containers (uniform, vest, backpack) without using addMagazineCargoGlobal to avoid BE getting lots of addmagazinecargo log messages (and possible mags/second kick)
When in doubt check. As I said assume nothing when it comes to programming
And order of addition is important so I can't use addMagazine
It will often wind you up in hot-water.
what's odd about the comment for that code is that...
I don't see the problem, Sa-Matra
// Make sure that:
// * Spectator was not initialized already
// * We only execute spectator for local player if controlling unit
if (!_bIsInitialized && _isPlayer) then
{
"local player if controlling unit"
So I was thinking if I can add magazines locally with addMagazineCargo and make sure that if player drops their uniform moments later everyone will see magazines in it
the local player is controlling the unit
as long as you use the commands on the machine of the unit, it will be synched correctly
#define SPEC { _this call (missionNamespace getVariable ["BIS_fnc_EGSpectator", {}]) }
but they use isPlayer to do the check
Thats the macro declaration that points to _bisInitialized
isPlayer doesn't check if the remote controlled unit is controlled by a player
Actually could answer this through simple test
private _bIsInitialized = ["IsInitialized"] call SPEC;
Noone is around to test with me though
welp
I guess I could modify the EG spectator system to change this one condition
I mean fix this condition
Actually there are dedicated addItemTo* commands, maybe I can use these
Would be interesting to implement ArmA Tactics into ArmA 3
Is ArmA Tactics anything like XCOM?
I haven't had much experience with it.
I played it a bit.
The free lite version.
Controls are kind as esoteric as arma 3's
Particularly for newbies
Is there a way to remove the "Release UAV Controls" action when using the remoteControl command?
Hi banana split comrades!
hey
_nul = NPC1 remoteExec [ "RemoveAllActions", 0, true ];
pass the AI you want into the removeAllActions
That will execute all of them.
The 2017 mod map will be released?
where can I hire a scripter to help me with my arma 3 servers
Will you pay per scripts, per month?
(sorry if i get the "hire" word wrong)
I was hoping to hire them onto my community as a scripter most likely paid every month or bi-weekly depending on the arrangement we come to.
but it would not be a lot of money sadly i do have a job but i only make so much
@tough abyss your community have a site or something on the internet so i can know more about? I'm not interested in a job but i'm a scripter and i'm interested in join a community.
I work in BRPVP, our Discord is https://discord.gg/DHfFPYW
at the moment it's still poorly setup but it's http://unitednationsspacealliance.net
Thankyou for the link.
and we do have a teamspeak
@little eagle ok my code is shit, but the real question is, is MouseButtonClick EH functioning as it should do?
I don't know why, but DrawIcon3D is not showing anything when I'm viewing through another camera such as Tactics_Client_SpectatorCamera = "camconstruct" camCreate (position Tactics_Core_ArenaVolume); Tactics_Client_SpectatorCamera cameraEffect ["INTERNAL", "BACK"]; switchCamera Tactics_Client_SpectatorCamera;
the draw script addMissionEventHandler ["Draw3D", { if(!isNull Tactics_Client_SpectatorCamera) then { { _player = _x getVariable ["Tactics_Player", objNull]; _position = getPosWorld _x; if(side _x == west) then { drawIcon3D ["", [0.10, 0.34, 0.50, 1], _position, 0, 0, 0, name _player, 1]; } else { drawIcon3D ["", [0.38, 0.49, 0.11, 1], _position, 0, 0, 0, name _player, 1]; }; } foreach (call Tactics_Core_GetPlayersInArena); }; }];
I did confirm that the drawing did work in a normal view of the unit (with the condition removed of course from the above code)
but the idea is that I want a freecam that shows the names of the players on screen
I can also confirm that the draw3d event handler is firing every frame while in camera by doing addMissionEventHandler ["Draw3D", { player globalChat str(diag_ticktime) }];
and seeing that the ticks are being printed to the chat
@tough abyss how so?
@wispy cosmos "I don't know why, but DrawIcon3D is not showing anything when I'm viewing through another camera such as " Remove the switchCamera line, cameraEffect already swaps the camera for you. Then you need to enable the HUD for Draw3D to be visible. Slightly modified so i could test from the debugConsole... ```Tactics_Core_ArenaVolume = player;
Tactics_Client_SpectatorCamera = "camconstruct" camCreate (position Tactics_Core_ArenaVolume);
Tactics_Client_SpectatorCamera cameraEffect ["INTERNAL", "BACK"];
cameraEffectEnableHUD true;
showHUD [true, false, false, false, false, false, false, true];
addMissionEventHandler ["Draw3D",
{
if(!isNull Tactics_Client_SpectatorCamera) then
{
{
_player = _x getVariable ["Tactics_Player", player];
_position = getPosWorld _x;
if(side _x == west) then
{
drawIcon3D ["", [0.10, 0.34, 0.50, 1], _position, 0, 0, 0, name _player, 1];
}
else
{
drawIcon3D ["", [0.38, 0.49, 0.11, 1], _position, 0, 0, 0, name _player, 1];
};
} foreach [ player ];
};
}];```
Awesome @thick lintel! I'll give this a try!
@tough abyss I've ended up just embracing the "Release UAV Controls" action as a feature for my turn based game mode. I check if the camera position is closer to the remote controlled unit, or the player. If it's closer to the player, I assume that the player has released control, and so I end his turn.
@thick lintel That did the trick! Thanks a ton!!
@wispy cosmos Your other problem from further back
{
["Initialize", [selectRandom (call Tactics_Core_GetPlayersInArena), [], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator;
}];```
I presume Tactics_Core_GetPlayersInArena returns players remote controlled units?
I notice in the previous code i posted you have
```_x getVariable ["Tactics_Player", objNull];```
Is this not a reference to the actual player? could you not use this to pass to BIs EGSpectator to get around the _isPlayer and then swap the current spectated target to the actual controlled unit.
```_unit addEventHandler ["Killed",
{
params[ "_killed" ];
["Initialize", [ _killed getVariable [ "Tactics_Player", objNull ] , [], true, true, true, true, true, true, true, true]] call BIS_fnc_EGSpectator;
_nul = [ selectRandom (call Tactics_Core_GetPlayersInArena) ] spawn {
waitUntil { !isNull ( uiNamespace getVariable [ "RscDisplayEGSpectator", displayNull ] ) };
[ _this ] call BIS_fnc_EGSpectatorCameraPrepareTarget; //BIS_fnc_EGSpectatorCameraSetTarget
};
}];```I presume this is the effect your going for, controlled unit dies, player whom controlled ends up spectating another players controlled unit?
Is my X working as it should do?
Why don't you try it? What's the point of asking here if only the game (reality) can judge
I guess, they want/expect a pat on the shoulder...
is that aimed at me? cos I of course did try it before posting, and as far as I can tell the EH is not functioning as it is supposed to
at everyone really
and as far as I can tell the EH is not functioning as it is supposed to
then why not ask: "Why does this do nothing?" After checking the RPT for errors of course
Or just use Diag_log everywhere. Starting from "the part where it gets attached"
it doesn't do nothing, it fires, but not as expected
my own logic & the wiki would expect MouseButtonClick to fire after mouse down + mouse up on the ctrl
but it really fires after mouse down
Yeah. diag_log and systemChat. debug it yourself and see where it goes haywire
You don't wanna know, how often i added a diag_log after every codeline just to find the source of evil
TRACE_X macro โค
the only difference between ASL and World is the models offset
so to convert you need a model
can do some math on the z component of getposASL and getPosWOrld on that object
@thick lintel I decided to abandon using BI's spectator system and just went with a freecam mode with player name's overlayed on-screen.
@thick lintel Thanks for helping
when the RPT is reporting an error in expression without a filename, is it safe to assume that it's originating from a spawn {} and/or FSM?
hmm well in my case it did originate from a FSM
@tough abyss "https://community.bistudio.com/wiki/inGameUISetEventHandler
if expression returns true action is blocked"
this looks promising, thanks for sharing!
That did the trick @tough abyss!! Thanks again!
Is there any directory for default arma 3 sounds name?
is there a list of all displays (ids) available in A3?
gotta dig through the config and pull your hair out afaik
defineResincl.inc in ui_f.pbo
#include "\A3\ui_f\hpp\defineResincl.inc"
Let me check if it works
Yes it works
Anyone remember config location of maximum unit load?
The number is 1000, I'd like to know where it is defined though
CfgInventoryGlobalVariable >> maxSoldierLoad
And I instantly found it right after I asked the question
gg
I'm having issues retrieving a variable in a location object using getVariable. I have created a location but can't use getVariable on the location object. Any ideas?
_Obj setVariable["VarName","Data",(if MP:) TRUE]; <- ?
I'm not in MP environment though
I shouldn't even need to worry about MP right now as I'm in the editor. Also when in MP environment, the script will be be ran on the server so no need to broadcast the variable to clients.
Keep in mind though the effects of createLocation are local
I think I might have figured it out give me one sec
with locations and getvariable you can't do this _loc getVariable ["bool", false];
it has to be this syntax _loc getVariable "bool"
It actually says so on wiki when looking at the syntax section https://community.bistudio.com/wiki/getVariable
yeah there is no <location> getVariable <array>
Also locations are local by definition
btw, does the active channel determine who sees the ping?
@opaque topaz This is a known and stupid limitation. Work around is this:
[_location getVariable _varName] param [0, _default];
Is there any list of current default ArmA 3 sounds?
ingame confg viewer
Could anyone explain to me why my custom .RVMAT (s) for the default AAF uniform doesnt want to load and instead the uniform ends with only the base texture and no normal map as well as specular map??????
where are you loading them from? paths right? error in rvmat?
Currently getting this error in my modpack when I try to launch it. I have a feeling it's causing my server to loop. any idea?
"15:20:18 [XEH]: Usage of deprecated Extended Event Handler "fired". Use "firedBIS" instead. Path: @OZZYLIFE\bin\config.bin\Extended_Fired_EventHandlers\All."
Also, I can't find "bin" anywhere.
Loading from my mod , just chaged the normal map in the rvmat coding to the new normal map i made , but as far as i know paths are correct , and the game does not give me any error with the RVMAT so i dont know
that said my camouflage faces give a pop up error saying rvmats are errors yet they work
guys i want to check how snow storm script will look on my map is there a way to enable it from editor ?
@chrome nebula Is OZZYLIFE your mod?
No, it's from a Youtube video.
@little eagle I had to look really closely at the wiki and figured out the limitation. Although, didn't think of your solution to get the same effect. Thx
@little eagle no it's from a Youtube Video...
?
OZZYLIFE
You're not the author?
Nope
Then don't worry about it
What's up?
about this:
Currently getting this error in my modpack when I try to launch it. I have a feeling it's causing my server to loop. any idea?
"15:20:18 [XEH]: Usage of deprecated Extended Event Handler "fired". Use "firedBIS" instead. Path: @OZZYLIFE\bin\config.bin\Extended_Fired_EventHandlers\All."
Also, I can't find "bin" anywhere.
What text editor and plugins do you guys use for editing anything Arma related?
I use atom with language-arma-atom plugin. I also use atom for web development
Sublime Text 3 with https://github.com/JonBons/Sublime-SQF-Language
I've never used Sublime. I always hear about it so maybe I will give it a chance and finally give in to it.
I usually just stick with the first thing that work for me. There is nothing special about ST as far as I can tell. It just works for me.
Ok well maybe I will just stick with Atom because it works for me ๐
If only atom could handle large RPTs
Yeah I had that problem last night lol. RPT was 16K lines long and opened up in Atom and it crashed it lol
I'd love to find good open source text editor, but there is (unfortunately) no substitute for EditPadPro.
I keep notepad++ around for those RPTs
Poseidon. And notepad++ for opening +500,000 line config/script dumps.
It doesn't even flinch when you open those
Hey everyone, im looking for at file called "h.sqf", anyone knows how to locate this file
๐ฎ
thanks @little eagle
@opaque topaz Atom with ACEs' syntax highlighting, file-header, file-icons and some other little handy plugins
The file-icons plugin is really handy for seeing different icons for the different languages
@buoyant heath yeah I'm thinking of just reinstalling notepad++ for the huge RPT files. It was amazing to me until I found Atom. Since then, Atom has been my go to for everything.
got a question: I should be using remoteExec instead of using BIS function because it's way faster processing correct? example of use old way [[0],"btc_fnc_show_hint"] spawn BIS_fnc_MP;
Thanks for answering Quiksilver
['"string" remoteExec ["hint",player];',[],100] call BIS_fnc_codePerformance; //Result ~0.1ms
['["string","hint",player ] call BIS_fnc_MP;',[],100] call BIS_fnc_codePerformance; //Result ~0.6ms```
- VariatoX https://community.bistudio.com/wiki/remoteExec
so something like [] remoteExec["btc_fnc_showhint",0];
Hello Guys. Will someone be able to assist me with a script for an auto save function in altis life?
Just take the saving script and run it in a 10 minute loop?
while {true} do { sleep 600; [] call autoSaveScriptName; }; ??
So many times I see while {true} do {} it is evil and should be avoided
I know, but if he wants something basic xD
Someone I know did it with a lightbar script and it destroyed my performance
xD
will that cause my server to crash
no
because of the sleep statement
while {true} do { _handle = [] call autoSaveFunctionName; waitUntil {scriptDone _handle; }; sleep 600; };
cool cool tnx i will try it. prob is i know nothing of scripting. i am more the hardware type of person
There is definitely better ways to do it but that will work just fine
the easy way is fine for now till i get a better understanding of scripting
while {true} do { _handle = [] call autoSaveFunctionName; waitUntil {scriptDone _handle; }; sleep 600; }; That will never work as call does not return a scriptHandle.
@thick lintel Explains why it works ๐
only spawn'd and execvm'd functions
return a script handle
Beware this is the scheduled environment so the possibility of the function executing in a timely manner is dependent on the current scheduler load.
Correction lol... I meant to put spawn. ๐
Is it originated from scheduled or unscheduled?
scheduled
Whats it not doing?
It's not related to this anyway. I just had that system working in a script I used awhile ago
{true} is okay... but I still find it dirty and have to wash myself everytime I use it.
Got the entire script source?
What if there is thread handle returned by autoSaveFunctionName? Kappa
xD I remember when I first came into ArmA and saw everyone using {true} it kinda made no sense to me at the time ๐
I've replaced many while {true} do stuff with EVH's
the other thing that killed me was constant loops without waitUntil statements in modside scripts.... that pissed me off many times
They can just trash the performance of their players because they can't script anything
Half the time I don't know why the engine doesn't have enough sense, to suspend if something isn't in sync with another...
@meager granite "What if there is thread handle returned by autoSaveFunctionName? " I think we both know that was not the point of the example ๐
Instead waitUntil feels like I am writing another scheduler within a scheduler.
I know some code takes faster or slower and waitUntil's ensure you don't end up with mismatched data.
Which is down right screwy in itself.
@tough abyssLogic
Maybe I should just write a scheduler script.
Call it use the code inside a [] spawn { };
and using waitUntil {scriptDone _thisScript};
๐ Anyway, I need to head off and have a shower. ๐
It would work wouldn't it @meager granite ?
params [["_code",{}],["_delayTime",0]];
_localHandle = [_delayTime] spawn {
_code
sleep _delaytime;
};
waitUntil {scriptDone _localHandle};
Then I've only got a temporary scheduled piece of code
that when finished will close.
and it can be called ๐
Did you mean spawn _code instead?
What's the point of this anyway?
It wouldn't work, no
Eh I'll fingure it out.
And spawn it?
Why do you even need spawn here?
why create another thread if rest of original one does nothing but waits for new one to end
Not sure I am for-ever typing {waitUntil} crap
I just thought wrapping into a function might make it less painful
What's your goal again? You need to execute something and wait some time?
Why even wrap it, its like 2 lines of script
Unless you need to wait until your wrapper is done somewhere else
The idea is to be able to suspend code universally.
It's an idea.
It might look useless but hey? Who cares?
Code above makes no sense, I have no idea what you're trying to achieve
Some of the stupidest of ideas can sometimes be useful.
If you can give me somewhat close to real world example I can help you
_handle = 0 spawn {
call myFunction;
sleep 5;
};
waitUntil {scriptDone _handle;};
// Something else here
is identical functionality-wise to
_handle = 0 spawn myFunction;
waitUntil {scriptDone _handle;};
sleep 5;
// Something else here
and
call myFunction;
sleep 5;
// Something else here
I want to call the function and put the sleep inside with the waitUntil
So if I pass say 0 as the delay time
It will just evaluate the waitUntil only
Why not just call your function and then do sleep, it will be the same thing
By the way @meager granite Do you even maintain KoTH anymore?
Yes
You can't use call MyFunction then sleep after it
If it originates from unscheduled
?
Your waitUntil assumes it is scheduled
I avoid the scheduled environment. For example this code.
params [
["_object",objNull],
["_state",false]
];
missionNameSpace setVariable ["towerDestroyed",false,true];
diag_log format ["_object: %1",_object];
_HandlerID = _object addEventHandler ["killed",{
diag_log "EH Fired";
missionNameSpace setVariable ["towerDestroyed",true,true];
diag_log format ["towerDestroyed: %1",towerDestroyed];
_handle = [] spawn {
//Mission needs to end when the groups count threshold is less than or equal to the east countside
waitUntil {towerDestroyed && (east countSide (enemiesInfs)) <= PARAMS_EnemyGroupLeftThreshold};
private _MarkersClean = AOMarker_IDs call MM_fnc_deleteMissionMarkers;
enemiesInfs call QS_fnc_AOdelete;
enemiesVehs call QS_fnc_AOdelete;
"Main Mission complete, give us 60 seconds and we will start the next" remoteExec ["hint",0,false];
};
}];
EH driven mission flow.
I didn't need the entire function to have all spawn'
Used it only where needed.
Keeps the speed of unscheduled and only switching to scheduled if necessary.
This is crude rudimentary code.
It's been chopped and changed a lot.
You can't waitUntil in unscheduled script environment
spawn creates separate scheduled thread
yes
Trust me that code above
Is atleast 10x faster than the old method.
EH is removed after used
New one created for next objective.
Got rid of triggers too
With that method.
There is no difference between creating a thread from scheduled or non-scheduled script environment
My point was that your original code piece already in scheduled, its pointless to create another thread and have original thread wait like in your example
I thought when a thread was created "VM thread" it switches an unscheduled piece of code
to scheduled
as a result able to sleep or use waitUntil inside it?
@meager granite
Or is that not the case?
And this is the most detailed piece of information I've found on the scheduler
So in thoery creating a function called
with a waitUntil should halt at that piece of code correct?
if it contains a [] spawn {} ?
Any spawn or execVM creates scheduled thread, no matter where you call it
^ no exceptions to that rule afaik
Yeah I know that, but I avoid going to scheduled unless I need to.
I thought when a thread was created "VM thread" it switches an unscheduled piece of code to scheduled
Yes it is the case but I think @meager granite is talking about this
_localHandle = [_delayTime] spawn { //This is unnecessary thread. Why spawn when vv
_code
sleep _delaytime;
};
waitUntil {scriptDone _localHandle}; //<< Must already be scheduled scope to be able to do this```
Whats the point of spawning a thread when you are already in scheduled as you have waitUntil so you must be.
Might aswell be
```params [["_code",{}],["_delayTime",0]];
call _code
sleep _delayTime```
if you want to be extra vigilant about the the scope then
```params [["_code",{}],["_delayTime",0]];
if !( canSuspend ) exitWith {
_nul = _this spawn ( missionNamespace getVariable _fnc_scriptName ) //<<Only works if defined by functions library else replace with function name.
};
call _code
sleep _delayTime```
Yeah most of my code is functions library
It's apart of a framework.
I need to create a tiny GUI on the ledt hand side that displays server FPS and client FPS
left*
Didn't notice stutters so far.
I can generalise that objective code even more.
And make it accept any objective variable state.
Anyone know how to use UnitCapture / Play?
params [
["_object",objNull],
["_variableName",""],
["_state",false],
["_isPublic",false]
];
missionNameSpace setVariable [format ["%1",_variableName],_state,_isPublic];
diag_log format ["_object: %1",_object];
_HandlerID = _object addEventHandler ["killed",{
diag_log "EH Fired";
missionNameSpace setVariable [format ["%1",_variableName],_state,_isPublic];
_handle = [] spawn {
"Main Mission complete, give us 60 seconds and we will start the next" remoteExec ["hint",0,false];
};
}];
Super-generalised function
Now I can be blowing objectives up to my hearts content.
Friend of mine did this too - why format ["%1",_variableName] if _variableName is already a string? If you do it for security purposes, you can make sure _variableName is of type string in params
I guess it depends on how you expect to be calling this function, aye?
It's for a community
That does Ops
Not a life server.
Even so this code executed SS anyway.
I use format over str
because str is slower @thin pine
I can plugin any kind of blow up objective into that code above. now.
๐
Except all the variables are out of scope (undefined) within the EH
@tough abyss I think you misunderstood @thin pine, he meant that _variableName is supposedly already of type string so the format is redundant
that is what I meant yeah but I'm now under the assumption he's feeding non-stringed variable names to his function so I get it - although..
you know what I'm done trying to think about this xD whatever works for him
lol ๐
๐คฆ
Thanks guys.
A local var declared at the beginning of a script
and the local var used inside of an EH?
The scope of the local variables value inside of the EH will not carry into the EH correct? so I'd have to make a TempGlobal variable
["_object",objNull],
["_variableName","", [""] ],
["_state",false],
["_isPublic",false]
];
missionNamespace setVariable [ _variableName, _state, _isPublic ];
diag_log format [ "_object: %1", _object ];
_HandlerID = _object addEventHandler [ "killed", format[ "
diag_log 'EH Fired';
missionNamespace setVariable [ %1, %2, %3 ];
'Main Mission complete, give us 60 seconds and we will start the next' remoteExec ['hint',0,false];
", str _variableName, !_state, _public ]];```
@thick lintel Do you know where the soldier FSM's are located?
What the danger and formation FSMs? \a3\characters_f\scripts
No, most of it is engine side I believe and their just external resources.
Why is the grouping not handled by the engine???
This is shocking...
and not shocking at the same time...
All the AI grouping potatoism is being handled by SQF / FSM scripts.....
๐ข
I have seen the darkside now I cannot unsee it.
has died a little inside now
I think only civilian AI use external behavior fsm Their config value is definately set for this. All soldier units are set to "FORMATION" rather than an fsm, not sure what this denotes unless its a flag for the engine to use an internal system.
Ah its probably a link to CfgFSMs class
@tough abyss Is there really any good EVH's for an auto save script really? I mean, there is eachFrame and that is basically the same.
Depends what your saving, players gear - InventoryClosed, Take, Put, SEH arsenalClosed for example.
Oh yeah course
But I don't really see a problem in an while loop with a 10 minute sleep timer
No not particularly a problem, just keep in mind when building a mission frame work of how many of these little scheduled loops you have started and not to fill up the scheduler with lots of them I suppose.
As long as you don't have 100 loops running simultaneously throughout the mission, you should be fine. Explicitly defining the behavior you want is a lot better than relying on an event handler as you leave less room for error or accidental execution.
Pretty much. Better to be explicit there.
Side question: does anyone still code Arma missions anymore?
I was 99% joking.
Which is complete bullshit
There's clearly an active community here.
For gear it depends where your saving. Saving to profileNamespace can be a little rough. I personnaly always find it better to handle it only when needed e,g leaving inventory screen or closing an arsenal etc, rather than have it happen at any time.
My discord won't stfu ๐
And all those other 1000+ communities
I was more thinking of DB saving @left helm
My mission has one more item in this current sprint. After that, we're moving to saving loadouts, scores, etc. to database ๐
What like mission objects and positional stuff?
While loops are just fine as long as they are used appropriately and sparingly.
Exactly
I agree
I mean
In the first place
Theyre there for a reason
Then of course if you're a complete moron while using them
My module wouldn't work without one
Like not sleeping or somth
I'd hate to calculate differences in serverTime just to get a heartbeat
Lol ๐
I'm sure at one point someone put a while loop in a while loop with a remote exec to a while loop.
From then on, while loops were shunned.
๐คฃ
per-frame handlers?
eachFrame?
so would _evh = addMissionEventHandler ["EachFrame",{hint "sup"; sleep 3; };]; work?
But then
Im rofl here
Armaology
so a while {true} do {sleep 3; hint "ye";}; is worse than an eachframe?
Why? Because they've never heard of a flag?
Then eachFrame would run all the time
Which will make lag even worse ๐คฃ
So then you would have to use while loop anyways if you wanna suspend
just have a flag surrounding the loop contents
if (flagIsTrue) {...}
won't execute if your global flag is false
skip contents until you flag it to turn back on
You mean variable?
It's a flag
If someone isn't waving it, it's not ok to execute
Wave that flag, then it's ok
๐
Oh lol ๐
So you aren't really suspending the loop so much as the execution of the contents
Yeah
You could add an event handler that listens for that variable to change
reduce overhead
I think I really only use onEachFrame for my HUD shit
Cant you just use Draw3d eventhandler?
Exactly. Outside of that, there's a better way.
I'd say, "cuz noobs" but that's probably just me being ignorant.
I didn't even play Arma a couple years ago. Picked it up for a project, learned it by trying to redo someone else's mission for Arma 2 for a guy. Flopped. Moved to Arma 3. Made another small mission. Flopped. And now Benargee and I are working on our big mission.
Hopefully third time's the charm ๐
So I'm sure I'm still an Arma noob, but I've seen so much garbage coding in Arma missions.
Lots of copy/paste
I know there are great programmers in the community, and I appreciate all of them, even if they are @queen cargo
๐
wasn't he banned
Erm...
Forever?
He appears to be here.
He's helped me a couple of times in the past, as well as a few others.
There's a difference between a troll and an asshole ๐
Because it just does it vs checking to see if it should do it
Oh man, wtf was I doing earlier?
Wait no, I was right.
If you use the flag in the evaluation itself, you can break the loop after the variable changes to false for the first time
You need the loop the keep checking it if you're trying to evaluate a value on the fly throughout the missiono
@rancid ruin no i was not
๐
you mean "a wild X39 appears" @tough abyss ๐
So good
oh, i thought dwarden said he banned you for a bit
Quiksilver you're full of shit
@little eagle Whats going on what did I miss
If i want to loop a sound, but not stop the script from continuing how can I do that?
There are event handlers for sounds
What kind?
You'd have to look. I don't recall off the top of my head, I just know they exist.
I dont see any eventhandler for that
But if I put a while true with a sleep timer of 3 seconds
before an for loop
It stops the script?
Thanks ๐
right now I have a for loop
In the script
Which has a sleep of 0.27
When i add a sound
Its all f-ed up
SO I want to add a while loop
with a 3 second sleep
But it will just hold on on that while loop and not do the for if im not mistaken?
Just spawn the sound instead of playing it directly?
Will allow the loop to continue and still plays your sound
Yeah?
This actually is already doing [ _curTarget, "alarmcar" ] remoteExec [ "FROG_fnc_playSound", 0 ];
Im looking to make an object move from one place to another and then back and then again. constantly. i want to use it as obstacles that would push players off the track. in a race. What command would i use for this?
Oh man, I was afk for a bit there
@rotund cypress is that what you wanted it to do?
I dont see what you mean
@torn jungle you'd want to make a loop to move that object's position
So, you have a for loop, right?
Yes
K, so
for {{_i=0}, {_i<10}, {_i=_i+1}} do {
if (flagIsTrue) then {
_curTarget spawn { params[_curTarget]; [ _curTarget, "alarmcar" ] remoteExec [ "FROG_fnc_playSound", 0 ]; };
};
};
@torn jungle Pushing will be a biggest issue here because you'll have to manually move players through script
Something like that, I think
So your loop iterates
then if the flag is true, also spawns a function that plays the sound
You can alter the spawn section to include a while loop.
Not recommended, but you can do it
@meager granite you don't like redrawing collision each frame?
๐
Ah ok thanks
Also, that syntax of for is not preferable to for "_i" from 0 to 10 do {
I literally copy pasted from the wiki because I was lazy
๐
So go fix the wiki ๐
Wiki states it fine
I was just trying to show how to use a flag in a loop for selective execution
flag, aka boolean
Yeah, it was brought up earlier that checking a condition for a while loop is slower than just iterating through a for loop
Which makes sense when you think about it
Usually in relation to an infinite loop
I love getting drunk and coming on here to pretend I know how to code with you guys ๐
It's annoying to see people who don't know what they're talking about, push false information on to others like it's fact.
I just read all that PFEH, while loops, etc @tough abyss
It all comes down to what you need to do. Essentially one's best judgement.
There's nothing wrong with using a while loop. It's just a control structure. It's going to give you the results the fastest (since it executes as fast as your CPU allows, and isn't tied to your framerate IIRC).
Sometimes you may want that, sometimes you won't.
It's also a matter of programming style.
There are too many factors for one to state as fact that one way is better than the other.
{
while {true} do
{
waitUntil { count (call Tactics_Core_GetSWAT) > 0 && count (call Tactics_Core_GetTerrorists) > 0 };
call Tactics_Server_Init;
while {!(call Tactics_Core_IsGameOver)} do
{
call Tactics_Server_UpdateTurn;
for[{Tactics_Core_CurrentTurnTime = Tactics_Core_TurnDuration}, {Tactics_Core_CurrentTurnTime >= 0}, {Tactics_Core_CurrentTurnTime = Tactics_Core_CurrentTurnTime - 1}] do
{
publicVariable "Tactics_Core_CurrentTurnTime";
uiSleep 1;
};
};
Tactics_Core_IsServerReady = false;
publicVariable "Tactics_Core_IsServerReady";
sleep Tactics_Core_EndRoundCooldownDuration;
};
};```
Above is a game loop for a mission I'm working on.
It's just spawned in a schedule environment.
No big deal.
It's a small mission and hardly a hit on performance in the big picture.
There comes a point where you as a programmer have to strike a balance between practice and practicality.
Anyone here have a clue as to how I could spawn in the RHS paradrop waypoint?
@wispy cosmos You just said you don't like people pushing false information, then made a statement as if it were a fact
There's nothing wrong with using a while loop. It's just a control structure. It's going to give you the results the fastest (since it executes as fast as your CPU allows, and isn't tied to your framerate IIRC).
Hey guys
Using RscXListBox, when trying to get curent selection with lbCurSel (1210) it returns -1, any idea ?
Nervermind, fixed
@dusk sage Please correct me if I'm wrong then.
@dusk sage Do note the "IIRC"
It is in fact a control structure though.
IIRC it executes independent of framerate
I guess depending on circumstances of course.
Just because it's a while loop doesn't mean it's going to magically kill performance....
In attempt to correct what I said, it's going to alter the flow of execution in whatever environment it's running in.
If you have a while loop in a spawn, it's going to change the flow of execution in that thread.
You said It's going to give you the results the fastest, then your IIRC was in relation to the reasoning, at least it seemed to be
Just seemed like a contradiction
@wispy patio Anyone here have a clue as to how I could spawn in the RHS paradrop waypoint? Dont know because I have not looked at it but im presumming it is a scripted WP in which case you would need to spawn a waypoint as normal, set its type as scripted and then use setWaypointScript to point to the script. You will need to look in the configViewer at the RHS waypoint definition see what it says it is.
But, as the wiki will tell you, for loops are much faster than while loops
If you have a bunch of "spawns" cluttering up the scheduled environment, the rate of execution in those spawns are going to degrade.
Correct?
How is a for loop faster than a while loop though?
The cost of a for loop is greater than a while loop in theory.
A while loop checks a condition to continue to the next iteration
a for loop manages an LCV, an iteration condition, and the iteration
but of course, you can manage that yourself in a while loop.
It's all about cost.
And the complexity of your algorithms.
@dusk sage
but of course, you can manage that yourself in a while loop.
You could, but it wouldn't be internal
You need to consider the fact the for loop is entirely internal
Obviously that isn't strictly true though
But the idea is there
(I hope)
wouldn't worry about it too much, "readability" before (potential) optimization IMO
while is for doing stuff while something is true and for is for iterating
no need to make things less "readable" for a 0.00001ms (obviously don't know the number.. ^^) improvement
or intuitive rather
^