#arma3_scripting
1 messages · Page 432 of 1
guides for scripting exist yeah
"context of adding scripts to addons with eventhandlers" .. what?
CfgFunctions. Add eventhandlers at postInit.
Right, I appreciate that my question lacked clarity, but just throwing out words is not useful or encouraging. What I'm looking for is if anyone's made a guide that has some detail to the process you just described, ideally with some examples
That's what I gave you
CfgFunctions That's how you add scripts in addons and have them execute automatically at preInit or postInit. Google these. You'll find guides and examples.
@still forum Thanks.
i want to suspend a script for a bit
_waitAfterInit = time + 30;
waitUntil
{
if ( (time > _waitAfterInit) AND (alive player) )
exitWith {true};
false
};
hint str "30s elapsed";
i tried it on the debug console localexec but it wont wait at all, i tried adding uisleep 3000 sleep 3000 still nothing
... thefuck
⚆ _ ⚆
What is createTeam supposed to do?
@lusty canyon try this in the console...
0 spawn {
_waitAfterInit = time + 30;
waitUntil {
sleep 1;
(alive player) &&
(time > _waitAfterInit)
};
hint "30s elapsed";
};
and you can check this https://community.bistudio.com/wiki/str
@meager heart that worked, is this because debug console is unscheduled env?
^
oh how shameful (i even had syntax highlights on)
but if the timer is in a spawn how do i suspend my actual respawn EH?
well i do want to suspend code, but nvm i got it working
is there a point in caching (in sqf land) (large or non large) arrays defined in config space?
yes
thanks. at what point would you draw the line - read more than once?
yes
once or twice is okey
as long as you can still definetly count it. It's probably fine
If you have a loop that reads the same entry up to infinite times... Then cache
cheers
use breaks defines/macros it seems
https://forums.bohemia.net/forums/topic/143930-general-discussion-dev-branch/?page=949&tab=comments#comment-3273639
wow, who would've thought....
@velvet merlin https://s.sqf.ovh/firefox_2018-03-02_09-02-24.png
Yeah.. Why did no one think about that before...
I SAID IT BEFORE YOU
Can't find it raises fists
Does anyone know how to get the selected player from a list box and then use that information to execute scripts with? so like _selectedPlayer = current selected player
So I can then do like _selectedPlayer getVariable "Variable";
You cannot select players in a list box
list boxes display text.
If you have the players name you could do something like
allPlayers param[(allPlayers apply {name _x}) find _theSelectedNameAsString, objNull]
Well I'm currently using this to load all the players names into a list box (Found it online) SQF _Selected_Players = []; { _index = lbAdd [24, name _x]]; lbSetData [24, _index, _forEachIndex]; _Selected_Players pushBack _x; } forEach allPlayers; I assume there is a way to grab the current list box selection, and link to it a user in the _Selected_Players array?
So yeah. You have name
Oh yeah..
If you can get the index of the listbox entry then you can _selected_players select _selectedIndex
Uhhh not entirely sure how I would do that. I just found this _player = _Selected_Players select (lbData [24, (lbCurSel 24)]); Do you reckon that would work?
nvm it comes back with Error Generic error in expression
does anyone know about these commands? https://forums.bohemia.net/forums/topic/187345-is-createteam-addteammember-etc-working/
im trying to make ai split into smaller teams at the group level
doStop and doFollow didnt seem to do anything
@modern sand Why not lbSetData the UID of a player and use lbData when selected?
@cyan pewter They are not what you think they are. They were something BI started to implement but never finished.
Basically useless commands
weeeeeell, for numbers they work
hmm... i though they looked incomplete. any clever ideas on how to do this?
Re:
0 spawn {
_waitAfterInit = time + 30;
waitUntil {
sleep 1;
(alive player) &&
(time > _waitAfterInit)
};
hint "30s elapsed";
};
Different idea:
0 spawn {
private _wait30 = 0 spawn {sleep 30};
waitUntil {scriptDone _wait30 || alive player};
hint "30s elapsed and player lives";
};
tries to find a throwable stone
Why?
BURN THE HERETIC
It's actually good code.. But...
0 spawn {
throws stone
BURRRRN
I mean. It takes getting used to, but it's so much nicer to work with.
we've lost him, ded, start CPR
The || should be a &&.
is there an arma/cba event on mission end?
how does "do while" affect the performance
Negatively?
ye
like every loop ever, just on different levels 😄
case 2:
{
_lootHolder addWeaponCargoGlobal [_itemClassName, 1];
if !(_itemClassName isKindOf ["Exile_Melee_Abstract", configFile >> "CfgWeapons"]) then
{
_magazineClassNames = getArray(configFile >> "CfgWeapons" >> _itemClassName >> "magazines");
if (count(_magazineClassNames) > 0) then
{
// Start Removal of BetaC Mags
_removeBetaCMags = ["CUP_100Rnd_556x45_BetaCMag","CUP_100Rnd_TE1_Red_Tracer_556x45_BetaCMag","CUP_100Rnd_TE1_Green_Tracer_556x45_BetaCMag","CUP_100Rnd_TE1_Yellow_Tracer_556x45_BetaCMag"];
{ _magazineClassNames = _magazineClassNames - [_x]; } forEach _removeBetaCMags;
// End Removal of BetaC Mags
_magazineClassName = selectRandom _magazineClassNames;
// Start Spawn Less Ammo
_numberOfMagazines = 1 + floor(random 2);
// End Spawn Less Ammo
_lootHolder addMagazineCargoGlobal [_magazineClassName, _numberOfMagazines];
_spawnedItemClassNames pushBack _magazineClassName;
};
};
thanks guys
I found the normal arma eventhandler to be extremly unreliable
True, but it exists.
because it's unreliable as fuck
https://github.com/michail-nikolaev/task-force-arma-3-radio/blob/1.0/addons/core/CfgEventHandlers.hpp#L36
Well.. That's a crappy workaround but it works.
same for ending the mission "manually"
Otherwise idk if there is a way to know a mission ended and execute code thereafter.
it's very inconsistent
works sometimes?
Depends on how the mission ends
do while doesnt exist?
Dedmen, the mission display is not always unloaded if the mission ends. E.g. loading a safegame.
while do does exist
do while doesn't.
do whole Doesn't exist no. do while also doesn't. while do does.
ha!
reminds me of that issue I never fixed with ACE Arsenal, the display is a child of display 46 (mission) but SOMEHOW someone was still playing a "previous" mission and still in arsenal while the mission restarted
uh
@lone glade Same thought as I found TFAR PFH's running after mission end AFTER leaving the server..
savegame, not safegame. I'm still tired.
no reports, means no repro hehehehehehhe
I have the same issue with my lobby script. Local hosted only though. If the host ends the mission, the client still in the lobby doesn't leave the mission.
how does it affect the server performance deadmen
Because it's a display on the mission display.
is it ok to use
deadmen? Who is that guy?
interesting there is loaded event but no saved
No I'm not deadmen
ded*
😄
😄
It affects server performance just like any other script command you might run.
Well slightly different in unscheduled... But... Don't use while loops in unscheduled 🗞
oh, fun thing to do, little sqf fun:
How many scopes down (minimum, doesn't need to be exact) is _magazineClassNames = _magazineClassNames - [_x];
i'd say at least 6, according to the arma wiki: 1
huehuehuehuehuehue
I can't english today
scopes down :thonk:
I meant to say how many parent scopes does it have
at a bare minimum, according to the wiki 1, or 0
well, func, switch, case, a few ifs and foreach.
my new favorite page of the wiki
Variables may store certain values. The kind of the value specifies the type of the variable. Different operators and commands require variables to be of different types.
Read the article Data Types for more information about variable types.
I love the question though. Essentially "How bad will my code wreck the server?" while posting a code snippet that could be executed once and wouldn't affect the server at all.
That just crashes.
lies
it gives you infinite frames
"the one code snippet #arma3_scripting doesn't want you to know about, COMMY HATES IT"
Doesn't mean much. I'm picky and probably would poke holes in stuff I'd post myself one day later.
_magazineClassNames = _magazineClassNames - [_x]; I'd say minimum number of parent scopes is 1
because of CallStackItemSimple always being the parent of any scripts
that's cheating ded
_x implies forEach, so yes, most likely one parent scope at least.
But if SallStackItemSimple is the actual script.. Instead of it's parent
This convo is tupid.
_X doesn't imply forEach though
You can use _x where you want ^^
no
I'm going with that.
apply and select code use it
”Ended” MEH doesn’t fire when using #missions iirc
Well, then alganthe, - [_x] infers forEach.
Yeah. that. And atleast one other case too. Like when you ALT-F4 too I think.
crashing the game with the debug console > alt F4
{ _magazineClassNames = _magazineClassNames - [_x]; } forEach _removeBetaCMags;
This line is so stupid btw.
_magazineClassNames = _magazineClassNames - _removeBetaCMags;
There. Makes so much more sense now.
¯_(ツ)_/¯
Actually no... If you look at the bigger picture
_magazineClassNames = _magazines + _removeBetaCMags;
{ _magazineClassNames = _magazineClassNames - [_x]; } forEach _removeBetaCMags;
->
_magazineClassNames = _magazines;
I think this isn't supposed to handle duplicates as it does atm.
Like, only remove one "mag1" if only one "mag1" is in _removeBetaCMags instead of all 3.
{
_magazineClassNames deleteAt (_removeBetaCMags find _x);
} forEach _removeBetaCMags;
There. Now handles duplicates correctly*.
*assumed
@little eagle about "Re:" and waitUntil i do loops that way, something like this...
_fnc_coolLoop = {
private _script = [] spawn {/* some code */};
waitUntil {scriptDone _script};
sleep 10;
[] spawn _fnc_coolLoop;
};
not sure is it better vs while {true} do {};
It's not.
the reason why I don't like while true loops is that people abuse them and then you end up with never-ending loops everywhere.
¯_(ツ)_/¯
btw endless loops everywhere not so bad compared to this piece of... art 😄 https://gyazo.com/77e3c4fa4e915d634668eb1ffb929856
😐
I am... not so shocked? Should I feel ashamed then
😀 ok... what about this ? that is from initPlayerLocal.sqf https://cdn.discordapp.com/attachments/262074246061096960/395533031743422465/image.png
refactor refactor refactor
You need a editor that supports UTF-8
^ and that too
lol
I think i'm gonna puke
You need a editor that supports UTF-8
that was uploaded in one discord server 😀
ok then... you won 😂
That's like the number 1 example. No one can beat that
Line: 7057 > hint parseText 'Uho! It appears something has gone wrong. Please report this error code to staff:<br/><br/>456<br/><br/>Thank you for your assistance.';
I love it when the indentations get so bad the code wanders off the right side of the screen.
This fn_clientcore.sqf is like having the same amount of code like infistar body do. 😐
No sorry, infistar has less.
👌
maybe he was trying to draw a snake with the code 🐉
I would write such code too. If I had to have a else statement with different code for each
But that....
We need a helper that executes code when a variable goes out of scope 😄
If I turn my screen 90 degree and start autoscrolling, it does look like watching the waves.
307344 characters
I think SQF will fail to compile it if you reach 10^7 chars, because that's the maximum a string can hold.
So it's only ~30% there.
I've actually never thought about that before this script.
10^7 ?
r_string buffer size variable is a signed 32bit integer
Which means max 2147483648
There are integers inbetween that cannot be represented.
Just because there is a largest doesn't mean the list is gapless.
From Arma 3 v1.55.133789 strings are limited to maximum of 9,999,999 (sometimes 10,000,000) characters
Are you mixing up float/int?
There are no integers in sqf.
No
But strings are not SQF
They are backend
SQF just points to the string in the backend
True, but then explain why they put a limit on strings.
That happens to be about what you can index with floats.
I even looked for that limit but couldn't find it
How do you get that? is readFile limited too? That returns a string and could read a huge file theoretically
yeah
Possibly. Don't know.
If there is a limit then it's just artificial. And not because "they can't hold more".
Basically like the + operator checking if left.size+right.size > 10 million then fail
Nice phrase being spoken about this Arma just doesn't
running this code sqf _fnc_uavinit = { diag_log "Running Init"; private ["_uav"]; _uav = _this; if (isNil "UavFogLoop") then {UavFogLoop = _uav spawn _fnc_uavrange}; _uav setVariable ["UavInSight",[],true]; _uav setVariable ["Active",true,true]; _uav spawn _fnc_uavpos; while {Alive _uav && fuel _uav > 0.05} do { _uav spawn _fnc_uavinsight; sleep SIGINT_sleep; }; diag_log "Exiting Init"; }; Returns two errors for existing functions _fnc_uavrangem _fnc_uavpos and _fnc_uavinsight. All functions are declared the same way as above function. What have I done wrong this time 😄
Any RPT log with errors?
two errors... What errors?
private ["_uav"];
_uav = _this;
->
private _uav = _this;
or better
params ["_uav"];
oh shit didn't know that was possible with the params. No, it claims that the _fnc_XXX functions don't exist
It probably doesn't exist then 😄
just your regular undefined error
No tags?
How do you call that function
_x spawn _fnc_uavinit;
and it doesn't complain about the UAV init function
the function is defined right under it
does it need to be listed above?
The function needs to exist before you use it yes.
And as I said. Local variables don't carry over into new scripts.
Use global variables and use a tag
even if it's all in the same sqf file?
totally irrelevant
hmm fair enough
_uav = _this; > _this params ["_uav"]; ?
>
no the string is clearly smaller. So no it's not bigger
is a _fnc_XXX = { lot of code }; a variable or a function?
okay, will keep that in mind
You also don’t need to do _this params
Just params as _this is params’ default argument
saves a lot in _this select X; with large arrays
no need _this there at all, use params
Also private doesn't make sense in a script without any parent scopes
and private <array> and private <string> are deprecated...
how do I get two squads to join together in the editor?
in the #arma3_editor or with #arma3_scripting
sorry i wasn't clear enough, when one squad gets close to another in the mission, how do I do that?
check distance between group leaders and if smaller than a certain distance, group the teams?
even if it's all in the same sqf file?
I find this amusingly naive.
how to optimize this? cache player player position and only change when distance > 1? anything else?
while {DEV_MiniMapActive} do
{
ctrlMapAnimClear _miniMapControl;
_miniMapControl ctrlMapAnimAdd[0,Dev_MiniMapZoomLevel,getPos player];
ctrlMapAnimCommit _miniMapControl;
_miniMapControl ctrlCommit 0;
waitUntil {ctrlCommitted _miniMapControl};
sleep 0.1;
};```
well diag_captureFrame says it lasts/runs for 0.13466 ms (second most in my current situation)
that said this is my main prob: 3.00083;"<spawn>#line 1 "DevCon\s\showUnitMapMarkers.sqf"
add a bigger sleep. But.. a local variable to check if changes are required would also help I guess
I don't see a need to optimize it though
whats the most optimized map makers solution these days - something from ACE?
0.1 is used trying to keep it smooth during movement - i guess the main problem is that i have it running in scheduled env
so if mission scripts take to much of the scripting VM, it gets slowed down or stuck - especially when in fast movers like cars or planes
yeah. Scheduled makes all scripts slower in general
And yeah.. Sleep in scheduled will lag
is it something to do about the 0.3s cycle?
@still forum would it be possible to have diag_captureFrame filter to only the scripting VM?
@winter rose do you mean running in unscheduled env instead?
https://community.bistudio.com/wiki/Scheduler @winter rose seen this yet?
scrsi and scrVM i think
you can filter diag_captureSlowFrame and I think it will only show that filtered area then
@valid arch https://community.bistudio.com/wiki/join
there's also a JOIN and JOIN AND LEAD waypoint in the editor https://community.bistudio.com/wiki/Waypoint_types#Join
@velvet merlin yup, sched vs unsched
so it's sensors I think that are 0.3s, that and/or Arma 2 modules that are "set in stone" after this delay
@inner swallow thanks
triggers have 0.5s cycle time for the condition from what i recall
@still forum unfortunately the parameter in diag_captureSlowFrame makes it only trigger for the said subset but still shows all of them in the dialog
Maybe it sometimes bugs out and only shows the subset 😄 I think I got it to do that a couple times. Maybe just by accident
the BIS_noCoreConversations is no longer used in A3, right?
Currently trying to use the GUI editor on our server but cannot export. We have tried Ctrl + Shift + S but cannot paste the output anywhere. Anyone have any Ideas what the problem may be?
Yes
copyToClipboard command is disabled in multiplayer
So the script can't copy it
Also GUI editor sucks
is there any way to enable it?
No
Or any suggestions on what to use instead?
Not sure why you want to GUI edit in MP anyway
Just do it in SP
And instead of GUI editor, learn how configs are setup for UI
Fair Play. Thanks for your help 😃
GUI editor you usually end up with very crazy configs that are hard to maintain and edit
Instead you should learn using controlsGroupCtrl
Important thing there is that within a ctrlGroup, x and y coordinates are relative to the group, but w and h are still based on everything
One of these days i should write an updated UI tutorial, it improved A LOT in A3 (still not great) and i think the latest tutorial on it is ancient (And not very good imo)
Uhm, guys i can't find right String...
If displayName shows main name of item's classname (in VR arsenal list for example) then which one would show 'on mouse hover' tip (additional info)?
Is it possible to emulate "module pattern" in SQF (JavaScript way) => http://www.adequatelygood.com/JavaScript-Module-Pattern-In-Depth.html
@spring dune This one?
descriptionShort = "Light Machine Gun
Caliber: 6.5x39 mm";
can property of the object be of type CODE?
someObject setVariable ["propertyName", value];
it's a namespace but I guess they wanted to do attribute/property emulation
What?
setVariable
It's a Variable.
You are asking if a Variable behaves just like any other Variable.
Yes. It's a variable. It behaves like a variable.
Because it's a variable.
i.e. "propertyName" is the name of a variable
it's not some predefined property of an object
you could have well written someObject setVariable ["fortehlulz", 2]; and then you'd have a variable called forthelulz with the value 2 within the namespace defined for/by the object someObject
how to detected UID of the player that received X item and make sure he can't give it to anyone else?
getPlayerUID
Make sure he can't give it to anyone else... Uh.. Well..
Eventhandler for Drop and if he drops the item.. Kill him
execVM an .sqf file with non-existant #include 😃
#include "dont_drop_the_fucking_items_you_fucker.hpp"
ez
Any unit enters a trigger setcaptive, any units who leave the area setcaptive false, for multiplayer.
I can get the effect I want on entering, but I'm trying to wrap my head around the effect on leaving;. I could just have it setcaptive false on all units constantly, but I want the safe zone to be really safe, not, "AI flipped out and shot you in the tick between being safe and not safe".
!thislist seems to not be an option for a foreach command :/
I wouldn't use a trigger for that. Way too annoying compared to a simple script.
Scripting isn't an option unfortunately, has to be the long run - admin console commands.
Well, you cannot use setcaptive without scripting.
// SERVER EXEC
0 spawn {
private _previousUnits = [];
while {
private _currentUnits = allUnits inAreaArray "zone_marker";
private _unitsThatEnteredZone = _currentUnits - _previousUnits;
private _unitsThatLeftZone = _previousUnits - _currentUnits;
{
[_x, true] remoteExec ["setCaptive"];
} forEach _unitsThatEnteredZone;
{
[_x, false] remoteExec ["setCaptive"];
} forEach _unitsThatLeftZone;
_previousUnits = _currentUnits;
sleep 5;
true
} do {};
};
Dunno, this is how I'd do this. But I'm weird.
Yeah, that's actually what I was looking at - allUnits - thisList for those who are free.
thisList
As I said, triggers are annoying and cumbersome to work with compared to scripts.
They are, but the official Zeus server's admin consoles kinda preclude using external scripts.
People use them because they lack imagination. And aren't used to inAreaArray.
I don't know what "admin console" refers to. I only know the debug console.
Same thing, more or less - fair enough, should call it what it is.
Well the debug console can be used to execute e.g. my script. Of course you'd have to create the marker named "zone_marker" too somehow.
Markers and such are easy to add. Honestly, I kinda enjoy scripting around the console input; you can't rely on calling on external files.
What's the difference between inAreaArray and thislist? o.0
thisList is a local variable in trigger scripts.
inAreaArray is a command that can be used anywhere.
Ooooh.
Yeah. I've said it before every time I ask, but locality is my great weakness :/
.... and the fact that I thought it does is also kinda telling t_t
Yep.
Local as in only exists in this script instance.
Well, usually local variables start with _
This one is a magic one (defined by some internals instead of a script) and therefore has a different name.
But it's a local variable.
@little eagle why are you doing the stuff above in the while condition and not the do {} block?
Because I could, so I did.
ah. so no performance difference?
No. That would be the for step 0 thingy probably.
for "_" from 0 to 1 step 0 do {
// looped code
sleep 5;
};
This one should have the least overhead.
Otherwise:
waitUntil {
// code
sleep 5;
false
};
But tbh, it's all the same and preference.
so basically there is no situation where while {true} do {// code} should be used?
Okay reading the last sentence before pressing enter might have helped 😄
It's kinda expensive because it has two code blocks, and one of them is a waste.
So if you want to optimize it then there are the alternatives I wrote.
is there a known reason why the while has a code block as condition? Was wondering that ever since i saw that construct.
Probably because the condition is a piece of code that itself is executed over and over again. It's just how the scripting language was designed.
In C it's parenthesis for the while "block", but curly brackets have a different meaning there and are less "strong"(?)
Yeah i learned Java a bit and starting with sqf i was really thrown of with the different syntax for the condition in while or if. But as always thanks for the anwsers 😃
In SQF curly brackets are essentially quote marks for code snippets. The while CODE1 do CODE2 doesn't execute CODE1 before the do command. Only after there is a while and a do code block defined the control structure evaluates the CODE1 / condition block.
I think you could for example put:
while {hint str 1};
everywhere into your script and they would just be ignored. Not tested though.
@little eagle Well, not ignored. But they won't be called
Same diff?
@little eagle that while without a do would essentialy be an expensive comment command
Can arma check if a player is scrolling (mouse wheel)?
Are you talking about the scrolling through the action menu?
@fleet wind https://community.bistudio.com/wiki/User_Interface_Event_Handlers
check there MouseZchanged
Thanks @meager heart
Hey all, I was hoping someone could help me with this issue I'm facing. I'm spawning a bunch of UGV stompers around the map, when an enemy comes into view of them, they turn on and aim at the enemy but do not shoot. I'm hoping to get the stompers to patrol areas and engage any enemy as soon as they see them.
_vehicle enableAI "ALL";
group _vehicle setCombatMode "RED";
_aiSide = side group _vehicle;
// [group _vehicle, getPos _vehicle, 100] call bis_fnc_taskPatrol
// _vehicle setBehaviour "SAFE";
[_vehicle, _aiSide, true] call fn_createCrewUAV```
I'm fairly new to Arma scripting, so any and all pointers here are appreciated.
Pointers:
_vehicle setAmmo [currentWeapon _vehicle, 100]; that can be fixed with this https://community.bistudio.com/wiki/setVehicleAmmo
_vehicle enableAI "ALL"; check this https://community.bistudio.com/wiki/enableAI
_vehicle setBehaviour "SAFE"; for this look there https://community.bistudio.com/wiki/setBehaviour
fn_createCrewUAV < that is... not good
check this https://community.bistudio.com/wiki/Functions_Library_(Arma_3)#Tag
@hot ember
Thanks @meager heart , the setVehicleAmmo makes much more sense, surprised I missed that one. However the stompers still aren't shooting.
I also changed the setBehaviour to the group of the vehicle, thanks for that.
However, do you mind explaning why you pointed out the enableAI and the createCrew call?
Also, any idea as to why the bis_fnc_taskPatrol wouldn't work here?
However, do you mind explaning why you pointed out the enableAI and the createCrew call?
unit enableAI skilltype unit != vehicle
that file fn_createCrewUAV.sqf from link above defined in cfgFunctions
class CfgFunctions
{
class someTag
{
class someCategory
{
file = "path_to_folder_with_function_files"; //--- there is `fn_createCrewUAV.sqf`
class functionName {};
};
};
};
@hot ember
once again read this https://community.bistudio.com/wiki/Functions_Library_(Arma_3)
you can execVM that file, not call it
Can someone tell me why this addAction wont work in MP?
[
player,
"Abrir Puerta",
"images\take_ca.paa",
"images\take_ca.paa",
"_target distance laptop < 2",
"_target distance laptop < 2",
{},
{},
{
sleep 0.1;
_target playaction "Putdown";
door_1=true;
},
{},
[],
3,
1000,
false,
false
] call BIS_fnc_holdActionAdd;
@meager heart Calling fn_createCrewUAV was working, even before I added it to CfgFunctions. Without it the stompers weren't being spawned.
I got taskPatrol to work, but still for the life of my I'm not sure what would be causing the stompers to not be firing. The side relations are fine, I'm giving it ammo, setting an agressive combat behaviour etc.
¯_(ツ)_/¯
Might have to do with default values of params for that function. Why are you using it, anyway?
You could do createVehicleCrew _vehicle and have the AI join your group and be done with it
@ornate pawn paste it in debug console, press local exec
if it will work, then possible "locality issues" check from where and how you call it...
and if that from player init scripts, you can add b4 that call waitUntil {!isNull player}; or waitUntil {time > 0};
Okay thank you
Except just as expensive as comment.
@strange urchin Honestly only using it because I'm still learning how Arma scripting works, I'll definitely give your suggestion a shot though 👍
I have a problem someone might be able to help me with. I'm using a Control Table, and the command ctAddRow to add rows to this table. https://community.bistudio.com/wiki/ctAddRow When I add the first row and modify the controls, I see them in the UI. However, any subsequent row after the first one will not display. The array returned does contain the proper index and controls, but when I modify the text of these controls, they just don't show up on the UI. Very frustrated with this.
Is there are helper BIS function to return an item's config parent? For example for a primary weapon CfgWeapons, or a magazine CfgMagazines
configName inheritsFrom (configFile >> "CfgWeapons" >> _item)
Will not work for glasses and backpacks.
how can i get a specific players object and run a fnc on that players machine?
i can cursortarget someone, but that would mean it will only be a localexec from my own machine right?
this locality stuff is hurting my porn filled walnut brain >.<
You mean get the player object by name?
Because you have to have something tangible and usually it already is the player's avatar.
say i want to do getUnitLoadout player
Well player reports the local player.
yeah i want the player i can see in front of me
cursorTarget
But that may not necessarily be a person.
Could also be an empty vehicle.
but that localexec? say i want to give that player a EH?
Or something else entirely.
So your script runs on machine A. cursorTarget happens to be the avatar of machine B.
And now you want to execute code on the machine B from a script on machine A?
private _target = cursorTarget;
private _script = {
hint "hello world";
};
_script remoteExec ["BIS_fnc_call", _target];
i tried doing cursortarget enablestamina false; (localexec debug console) but the player report stamina is still on
Will print "hello world" only on the machine where the target is local, not necessarily the machine that execute this script.
Well, LOCAL EXEC in the debug console runs the code on the machine of the person that pressed LOCAL EXEC.
Therefore LOCAL EXEC.
enableStamina has to run on the machine that owns the unit.
"Local arguments". At least iirc.
Therefore you have to remotely execute the command on the machine that owns the unit.
so the cursortarget in ur code above is run localexec (since the source is my own player?)
then the remoteexec command will then run everything on the target players machine?
Sounds right.
E.g:
private _target = cursorTarget;
private _script = {
player enableStamina false;
};
_script remoteExec ["BIS_fnc_call", _target];
i should run that as localexec in debug console?
Yeah.
Or shorter:
private _target = cursorTarget;
[_target, false] remoteExec ["enableStamina", _target];
First example again, your locally executed script will relegate _script to the machine that owns _target.
And execute it there.
how can i run that _script on all players except myself, dedicated, and HC?
allplayers array - something?
_target in remoteExec can be an array of objects, so sure.
private _targets = allPlayers - [player];
private _script = {
player enableStamina false;
};
_script remoteExec ["BIS_fnc_call", _targets];
Note how the first line player is execute on the local machine, and the third line player on every other machine (except stuff like the server or hc).
wont that still be added to the HC? i notice some of my player add EH have also been applied to the invisible HC entity
Is that a problem?
yeah i can see in game the HC near my mission base has stuff it shouldnt have
private _targets = allPlayers - [player];
private _script = {
if (hasInterface) then {
// do stuff
};
};
_script remoteExec ["BIS_fnc_call", _targets];
Well that's what hasInterface is for.
oh nice
I guess you could simplify this by removing _targets all together and just executing the code everywhere for simplicity.
{
if (hasInterface) then {
// do stuff
};
} remoteExec ["BIS_fnc_call"];
There. Much nicer.
HC's running around? 😄
i can see an invis HC inside the mission is that normal?
It's not normal to see something invisible.
you're using a script or mod that adds all entities
if i do globalexec, player entity on the dedicated server also applies?
On a dedicated server, player is <null> and most commands, e.g. enableStamina or addEventHandler just fail silently if used on <null>.
ok so i dont have to worry about them, say if the HC player dies somehow does that mean it will stop processing AI?
(better yet how can i even know the HC is actually doing its job?)
Doubt it. I think the dummy just exists for the HC to slot in.
it doesn't care, don't know if it even can die
Well duh. You missspelled allDeadMen.
allDeadMan is an undefined global variable.
allUnits + nil // nil
nil select {...} // nil
Now check the time again.
😄
😉
Found these scripts after quite a lot of Googling, and they work fine in SP and local MP. Will they also work in dedi MP? Can they be improved / cleaned up in any way?
is there a way to make player objects clip through all objects terrain etc while still enable simulation? (can still aim shoot atleast)
The script runs scheduled, so you could easily still place markers by just increasing your view distance so your game lags and never closes the display before you hit enter to place the marker.
would anyone knoe how i can change the delay for those excercise targets to pop up again?
is there a way to make player objects clip through all objects terrain etc while still enable simulation? (can still aim shoot atleast)
No.
oh i just found this ``` // target individual settings [DEV. VERSION ONLY!]
_target setVariable ["nopop", true];
_target setVariable ["popDelay", 10];
// handle target hit event
_target addEventHandler ["Hit", {
systemChat format ["Target %1 hit by unit %2", _this select 0, _this select 1]}]; ``` will try
Read it as poop delay at first.
If you do your regular morning poop, you have a healthy 24 hour poop delay.
Hello guys, i am trying to call a function like this.
[cursorObject] call myfunc;
this func is supposed to be called on sqm objects.
in my function, i want to get the variable name of the object, do you know how can i do this ?
What is a sqm object
an object i placed on the mission sqm
Do you mean a init script? When you double click the unit in Editor and put it in there?
Not the init, but the variable of the object
And now he wants to get the variable name out of thin air and have the game magically know which unit he wants?
i'm calling the function with cursorObject
What is that screenshot supposed to tell me?
Why are you calling it with cursorObject?
from the debug console while in-game?
Cause this is the only way i found to get the name of the object
Can you answer my other question
Where do you run the script?
Where do you want to do that?
init.sqf or trigger script or.. what?
it will be used in keyHandler, and console debug
Do you always want the same object?
Nope, it can be multiples objects, depend on what the players is loooking at
Or.. Do you want to get the variable name of the cursorObject?
If it has a variable set to it in the editor then just str cursorObject will return you the variable as text
hm i tried this it didnts work, i must have missed something, thanks
you have to actually look at the object
I know
ok
Anyone know how to stop the AI moving their heads? Trying to do some screenshots but they keep turning their heads!
disable their simulation @velvet star .
Anyone able to help me out with params?
init.sqf```
["player","T0",["Attack Civilian","Attack the civilian, infront of you, he's committed war crimes!"],Civ_00,"CREATED",1,true,"attack",true] execVM "taskCreate.sqf";
taskCreate.sqf```
params [
private _taskOwner,
private _taskNumber,
[
private _taskShortDescription,
private _taskLongDescription
],
private _taskObject,
private _taskState,
private _taskPriority,
private _taskNotify,
private _taskType,
private _alwaysVisible
];
[
_taskOwner,
_taskNumber,
[
_taskShortDescription,
_taskLongDescription
],
_taskObject,
_taskState,
_taskPriority,
_taskNotify,
_taskType,
_alwaysVisible
] call bis_fnc_taskCreate;```
Thank you Capwell!
@drowsy axle params takes array of strings. not array of variables and syntax errors
Read params wiki page
Do you guys use BIS_fnc_guiMessage ?
Hey @compact maple , yes, I guess BIS_fnc_guiMessage is well-used. Try rephrasing your question to be more specific and provide examples if needed.
Anyway, glad to see you found your way here. Any script-related questions you can ask here, this is the best part of A3 discord 👌🏿
@cosmic kettle Hey, i am using it in a function. This function is called in the keyHandler, when the player press win+F1.
It sends to the function, one argument, cursorObject, so with the cursorObject, im creating a BIS_fnc_guiMessage , the problem is, the box is created 10 times instead of one. I mean when i press a button, the display is still here. And i have to spam click to make it disapear. I didnt make a while or something, its called one time with the keyhandler
Oh, I assume it's just executing the keyhandler for the duration you press windows F1
you might see it as 1 press, but it might have seen it as 'the last 10 frames user pressed win+F1'
Oh, you're probably right, i quickly quickly pressed win+f1 and it created only 2 box
instead of 10
😉
But i do not know how to execute it just one time
Abort the function that opens the menu if the menu is already shown.
☝🏿
Hey gents, how would I steer a vehicle via user action without being the driver of the vehicle?
I don't think that is possible outside of commanding an AI driver.
Well I guess a better way of phrasing it is how would I set the steering angle?
With scripts? No such command.
To illustrate what I'm trying to do is I have a ship that's moving forward and I'm trying to turn the wheel, thus turning the rudder without being the driver since apparently ArmA doesn't let you get in as the driver of a vehicle while it is moving
Unless it's your model, so you can add User source/controller animations and then use animate it doesn't seem possible to me.
it is my model
Well, animate is how you can do animations that are defined as User source.
can you use a user animation to change the "drivingwheel" animation source?
ugh
It sounds to me like it would be simpler to just add a user action to the boat that mimics the base games "Get In blah" stuff.
to be honest I kind of want to avoid the whole get-in thing
how would I steer a vehicle via user action without being the driver of the vehicle
setvelocity?
no, you can't get into a ship while it's moving
player stuffHeadInsideVehicle _veh;
last I tried they did
You can move to the passenger seat after maxing out the speed and it'll maintain the same speed
passenger seats? lol my ship don't need no stinking passenger seat lol
Where do you put your weapons and beer then tim? 😄
still working on that lol
and if you get out when it's moving
The question is still: is the throttle up?
lets say yes
I've never had them go on forever if I slowed it all the way down
404
Does it behave like it does on say a regular boat like the RHIB or does it have it's own swimming model 😛
I don't want the ship to turn while it's still...atleast not noticeably, but when moving forward...since rudders generally only work while going forward.
So this is a static prop? 😄
What do you mean? It's a ship that moves
Well shit, that's pretty cool. I dunno what you're talking about necessarily though. You don't want the ship to turn when moving forward?
I want it to turn while moving forward if I turn the wheel
invisible AI driver that you give action commands
The AI is too stupid
^ Not true
the wheel controls the AIs commanding
how would I tell the AI to only turn the wheel 0.5 to the left?
Well, you could say "Hey, turn the thingy until I say stop" then once it reaches 0.5 , "Hey AI dude, stop turning"
it may not give you 100% accurate results (which I don't think it ever will). But close enough?
Doesn't the AI steer where ever it wants to? I notice while standing on the ship while it's moving the AI things it's going to hit me and steers all crazy
Make the ai an agent and just have it move directly to the left (which should translate into a wide left turning motion on the ship?) until you think it's appropriate then have it stop
what's the scripting command to make the ai turn left or right?
There is no "turn left" or "turn right" commands.
moveTo and doMove
literally just have them move left
left of the ship
I see what you're saying but that's not what I'm trying to do.
@ornate pawn building will have animation sources, use animate or animateSource with given animation source name and supply the number which will indicate the phase from 0 to 1
ty
@marble flare did you check out the addTroque Nigel suggested?
no, I'm not good with scripting but I'll give it a shot.
No one here is good at it.
🍌
triggered
Dedmen is okayish at best.
🙇
Wouldn't call it "good" tho.
ok, yea, if nobody here is good at it then I really suck
so I tried it and it does turn the ship momentarily, but not like what the rudder would
Make adjustments 🤷
this is particularly important because the rudder acted like a trim on a sail ship to compensate for lateral drift
I suppose if I was more experienced I could figure out something
I think you're too caught on the notion of "I have lack of experience, thus I can't do X".
It's literally just command based, utilize t he addTorque command and adjust your given values
I suppose I could come up with a user action that constantly applies torque to the ship based on the position of the wheel/rudder and relative to the speed of the ship
And you are what exactly commy?
Always right. Even if it turns out to be wrong in the end, it was right at the time.
@marble flare Why add that to a user action? You could loop it for as long as you want and then exit when position conditions are met
well I guess loop the action
loop the action
Huh?
"huh?" is exactly what goes through my mind when I think of this stuff
You can probably guess what he means
No, I don't. You can loop something inside the executed code when adding an action
But other than that it doesn't make sense.
I guess it would be a loop, something like "ship addtorque [0,0,(ship animationphase "rudder") * speed ship]"?
#define LEFT_EXIT (sailors_ship getVariable "LEFT_START")
while{alive sailors_ship} do
{
if !(LEFT_EXIT) exitWith {};
sailors_ship addTorque[0,0,(sailors_ship animationPhase "rudder") * speed sailors_ship];
};
I really don't know how far left yo uwant it, so 🤷 . Guess this could work
ok...where would I put this?
Slap that in a script and call compile preProcessFile "yourScript.sqf" it, or register it in cfgFunctions and spawn it.
there isn't any suspension, so if you want that -> Scheduled
That while loop wouldn't make sense in unscheduled..
Why would that be?
not sure what you mean, but I suppose the script can stop or pause when the ship isn't moving at all
while{alive sailors_ship} do
{
sleep 0.33; // suspends for 0.33 seconds
};
I suppose I could add a little torque to the vertical axis to simulate listing to one side during a turn?
Because he will never die
unscheduled executes the script till end.
LEFT_EXIT will never change. alive state also won't
This function will freeze the game for a second then the func will be killed
never die? 0_o the ship can die
In fact if the rudder is shot away then no steering
loops have a limited number of runs in unscheduled
It can't die while that script runs if that script executed in unscheduled
also sleep in unscheduled just causes a syntax error
that's exactly what I said above ^^
I'm sure glad you guys have an idea of what you're talking about. I feel like someone watching the spanish channel. Either way I'm sure this will point us in the right direction.
Thanks for your help guys!
I'd like your opinion on the following:
Initial Coding```sqf
northStand_1 addAction ["<t color='#44bd32'>Open</t>",{northWall setPos [4191,6800,2.204]}];
southStand_1 addAction ["<t color='#44bd32'>Open</t>",{southWall setPos [4191,6768,2.204]}];
eastStand_1 addAction ["<t color='#44bd32'>Open</t>",{eastWall setPos [4176,6785,2.204]}];
westStand_1 addAction ["<t color='#44bd32'>Open</t>",{westWall setPos [4208,6785,2.204]}];
northStand_2 addAction ["<t color='#44bd32'>Open</t>",{northWall setPos [4191,6800,2.204]}];
southStand_2 addAction ["<t color='#44bd32'>Open</t>",{southWall setPos [4191,6768,2.204]}];
eastStand_2 addAction ["<t color='#44bd32'>Open</t>",{eastWall setPos [4176,6785,2.204]}];
westStand_2 addAction ["<t color='#44bd32'>Open</t>",{westWall setPos [4208,6785,2.204]}];
northStand_1 addAction ["<t color='#e84118'>Close</t>",{northWall setPos [4191,6800,0.204]}];
southStand_1 addAction ["<t color='#e84118'>Close</t>",{southWall setPos [4191,6768,0.204]}];
eastStand_1 addAction ["<t color='#e84118'>Close</t>",{eastWall setPos [4176,6785,0.204]}];
westStand_1 addAction ["<t color='#e84118'>Close</t>",{westWall setPos [4208,6785,0.204]}];
northStand_2 addAction ["<t color='#e84118'>Close</t>",{northWall setPos [4191,6800,0.204]}];
southStand_2 addAction ["<t color='#e84118'>Close</t>",{southWall setPos [4191,6768,0.204]}];
eastStand_2 addAction ["<t color='#e84118'>Close</t>",{eastWall setPos [4176,6785,0.204]}];
westStand_2 addAction ["<t color='#e84118'>Close</t>",{westWall setPos [4208,6785,0.204]}];```
OR
Refined Coding: ```sqf
_stands = [
"northStand_1",
"northStand_2",
"southStand_1",
"southStand_2",
"eastStand_1",
"eastStand_2",
"westStand_1",
"westStand_2"
];
[
if (_x = "northStand_1" || "northStand_2") then {_wallSetPosOpen = northWall setPos [4191,6800,2.204]};
if (_x = "southStand_1" || "southStand_2") then {_wallSetPosOpen = southWall setPos [4191,6768,2.204]};
if (_x = "eastStand_1" || "eastStand_2") then {_wallSetPosOpen = eastWall setPos [4176,6785,2.204]};
if (_x = "westStand_1" || "westStand_2") then {_wallSetPosOpen = westWall setPos [4208,6785,2.204]};
_x addAction [
"<t color='#44bd32'>Open</t>",
{
_wallSetPosOpen
}
];
if (_x = "northStand_1" || "northStand_2") then {_wallSetPosClose = northWall setPos [4191,6800,0.204]};
if (_x = "southStand_1" || "southStand_2") then {_wallSetPosClose = southWall setPos [4191,6768,0.204]};
if (_x = "eastStand_1" || "eastStand_2") then {_wallSetPosClose = eastWall setPos [4176,6785,0.204]};
if (_x = "westStand_1" || "westStand_2") then {_wallSetPosClose = westWall setPos [4208,6785,0.204]};
_x addAction [
"<t color='#e84118'>Close</t>",
{
_wallSetPosClose
}
];
] forEach _stands;```
Is there any current bugs with ACE Arsenal? I am running, now only CBA and ACE, and [this, true] call ace_arsenal_fnc_initBox; does not work on a box.
@errant jasper You have to change to: sqf [_this, true] call ace_arsenal_fnc_initBox;
not in a init box
@drowsy axle Right now I am just testing it through init box
this is a reference to the object the init box belongs to
like Midnight says
[BoxName, true] call ace_arsenal_fnc_initBox;
This is called outside of the BoxName "Init. Field" say a function or init.sqf
Anyone have any opinions on my above script post?
Nvm. I am stupid. It seems it has been changed to the interaction menu now, rather than the scroll-action-list.
Yes. It has... I wondered what your problem/bug was. 😃
personally, I feel using a switch do control structure instead of multile if statements is better. Despite what others may have to say.
switch _yourVar do
{
case "value_1" :
{
//code
};
};
So... like this?
switch _wallSetPosOpen do
{
case "northStand_1" :
{
northWall setPos [4191,6800,2.204]
};
};```
Sure, your case check can be anything. Including the variable you are checking.
switch _var + 1 do { }; //can't do
switch (_var + 1) do
{
case 2 :
{
//can
};
};
{
switch _x do
{
case "northStand_1":
{
};
};
} forEach _stands
{
switch _wallSetPosOpen do
{
case "northStand_1":
{
northWall setPos [4191,6800,2.204]
};
case "northStand_2":
{
northWall setPos [4191,6800,2.204]
};
case "southStand_1":
{
southWall setPos [4191,6768,2.204]
};
case "southStand_2":
{
southWall setPos [4191,6768,2.204]
};
case "eastStand_1":
{
eastWall setPos [4176,6785,2.204]
};
case "eastStand_2":
{
eastWall setPos [4176,6785,2.204]
};
case "westStand_1":
{
westWall setPos [4208,6785,2.204]
};
case "westStand_2":
{
westWall setPos [4208,6785,2.204]
};
};
switch _wallSetPosClose do
{
case "northStand_1":
{
northWall setPos [4191,6800,0.204]
};
case "northStand_2":
{
northWall setPos [4191,6800,0.204]
};
case "southStand_1":
{
southWall setPos [4191,6768,0.204]
};
case "southStand_2":
{
southWall setPos [4191,6768,0.204]
};
case "eastStand_1":
{
eastWall setPos [4176,6785,0.204]
};
case "eastStand_2":
{
eastWall setPos [4176,6785,0.204]
};
case "westStand_1":
{
westWall setPos [4208,6785,0.204]
};
case "westStand_2":
{
westWall setPos [4208,6785,0.204]
};
};
_x addAction [
"<t color='#44bd32'>Open</t>",
{
_wallSetPosOpen
}
];
_x addAction [
"<t color='#e84118'>Close</t>",
{
_wallSetPosClose
}
];
} forEach _stands;```
ah {}
put a space between your case and string as well
hmm the _wallSetPosOpen/Close switch doesn't like the addaction
Also, none of those addActions work with outside variables unless you pass them in:
_x addAction["Close",
{
_action = (_this select 3) select 0;
hintSilent format["Action variable: %1",_action];
},[_action]];
_action is the Open/Close ?
_x addAction["<t color='#e84118'>Close</t>",
{
_wallSetPosClose = (_this select 3) select 0;
},[_wallSetPosClose]];
just so i dont mess up... can I do callbacks with an exitWith...
you mean?
if(var) exitWith
{
[] call fn_yourVar;
};
@subtle ore Fixed above.
i.e _bool = [] call function
if (true) exitWith {
something = true;
something;
};
Still nothing working Capwell?
Yes you can. Except when the return value is for eventhandlers like HandleDamage or KeyDown and you're in the main scope.
_wallSetPosOpen isn't defined 🤷
@commy its litteraly just to stop the code looping through the rest of the conditions.
in your code, it has no idea what _wallSetPosOpen is.
Post the whole code maybe.
if (_itemCategory == "equipped") then {
if ((_itemClassname == (uniform player)) && (!(_itemRemoved))) then {removeUniform player;_itemRemoved = true};
if ((_itemClassname == (vest player)) && (!(_itemRemoved))) then {removeVest player;_itemRemoved = true};
if ((_itemClassname == (backpack player)) && (!(_itemRemoved))) then {removeBackpack player;_itemRemoved = true};
if ((_itemClassname == (headGear player)) && (!(_itemRemoved))) then {removeHeadgear player;_itemRemoved = true};
if ((_itemClassname == (goggles player)) && (!(_itemRemoved))) then {removeGoggles player;_itemRemoved = true};
if ((_itemClassname == (primaryWeapon player)) && (!(_itemRemoved))) then {player removeWeapon _itemClassname;_itemRemoved = true};
if ((_itemClassname == (secondaryweapon player)) && (!(_itemRemoved))) then {player removeWeapon _itemClassname;_itemRemoved = true};
if ((_itemClassname == (handgunWeapon player)) && (!(_itemRemoved))) then {player removeWeapon _itemClassname;_itemRemoved = true};
if ((_itemClassname in (assigneditems player)) && (!(_itemRemoved))) then {player unassignItem _itemClassname;player removeItem _itemClassname;_itemRemoved = true};
};
``` basically so i can tidy this up xD
switch _wallSetPosClose do
{
case "northStand_1":
{
_wallSetPosClose = northWall setPos [4191,6800,0.204]
};
case "northStand_2":
{
_wallSetPosClose = northWall setPos [4191,6800,0.204]
};
case "southStand_1":
{
_wallSetPosClose = southWall setPos [4191,6768,0.204]
};
case "southStand_2":
{
_wallSetPosClose = southWall setPos [4191,6768,0.204]
};
case "eastStand_1":
{
_wallSetPosClose = eastWall setPos [4176,6785,0.204]
};
case "eastStand_2":
{
_wallSetPosClose = eastWall setPos [4176,6785,0.204]
};
case "westStand_1":
{
_wallSetPosClose = westWall setPos [4208,6785,0.204]
};
case "westStand_2":
{
_wallSetPosClose = westWall setPos [4208,6785,0.204]
};
};``` Would that solve it?
case sensitivity ?
No...it still has no idea what _wallSetPosOpen is. Does _x contain your strings you are checking for?
I always use toLower(_string) and put lower case on all my switch cases now
@subtle ore ```sqf
_stands = [
"northStand_1",
"northStand_2",
"southStand_1",
"southStand_2",
"eastStand_1",
"eastStand_2",
"westStand_1",
"westStand_2"
];
{
// code
} forEach _stands;```
// code is the code your having issue with ?
gonna pastebin
_stands = [
"northStand_1",
"northStand_2",
"southStand_1",
"southStand_2",
"eastStand_1",
"eastStand_2",
"westStand_1",
"westStand_2"
];
{
switch (toLower _x) do
{
case ("northstand_1") : {northWall setPos [4191,6800,0.204]};
case ("northstand_2") : {northWall setPos [4191,6800,0.204]};
case ("southstand_1") : {southWall setPos [4191,6768,0.204]};
case ("southstand_2") : {southWall setPos [4191,6768,0.204]};
case ("eaststand_1") : {eastWall setPos [4176,6785,0.204]};
case ("eaststand_2") : {eastWall setPos [4176,6785,0.204]};
case ("weststand_1") : {westWall setPos [4208,6785,0.204]};
case ("weststand_2") : {westWall setPos [4208,6785,0.204]};
};
}forEach _stands;
is that what you mean ?
No need for the brackets around your strings, not evaluating anything. Sort of like that yeah
thats more lines then it needs to be 😛
I try to condense my switches if i can xD
just looks cleaner
The stuff before LINE 22 works
The stuff after LINE 30 doesn't work
I just want to condense the code.
Variable.
nope
Looks better than 20 lines of
if(true)then{};
if(true)then{};
if(true)then{};
??
sec
in debug console watch
do
call (compile "southStand_2")
should return the object
even better
player setpos (getpos (call (compile "southStand_2")))
should tp you to the object.
@little eagle ```sqf
if (_itemCategory == "equipped") then {
if (_itemClassname == (uniform player)) exitWith {removeUniform player;true};
if (_itemClassname == (vest player)) exitWith {removeVest player;true};
if (_itemClassname == (backpack player)) exitWith {removeBackpack player;true};
if (_itemClassname == (headGear player)) exitWith {removeHeadgear player;true};
if (_itemClassname == (goggles player)) exitWith {removeGoggles player;true};
if (_itemClassname == (primaryWeapon player)) exitWith {player removeWeapon _itemClassname;true};
if (_itemClassname == (secondaryweapon player)) exitWith {player removeWeapon _itemClassname;true};
if (_itemClassname == (handgunWeapon player)) exitWith {player removeWeapon _itemClassname;true};
if (_itemClassname in (assigneditems player)) exitWith {player unassignItem _itemClassname;player removeItem _itemClassname;true};
};
@drowsy axle in your pastebin you are also switching variables that havent been declared. wallSetPosOpen and wallSetPosClose arent declared.
I don't need to... I'm declaring them in the switch cases
Oh wait
wtf
Just double checked the pastebin.
you cant declare something you want to check for :D. I think. At least declare it as "".
Nothing..
Otherwise it is Nil
Okay
have you got the object variables set at those in the array ?
_wallSetPosClose = "";
_wallSetPosOpen = "";```
this: sqf _stands = [ northStand_1, northStand_2, southStand_1, southStand_2, eastStand_1, eastStand_2, westStand_1, westStand_2 ];
or this: ```sqf
_stands = [
"northStand_1",
"northStand_2",
"southStand_1",
"southStand_2",
"eastStand_1",
"eastStand_2",
"westStand_1",
"westStand_2
];
They are variables (objs) in game
Yeah but that whole thing makes no sense imo.
_wallSetPosClose = northWall setPos [4191,6800,0.204]
Okay.. let me start from the top
setPos doesnt return anything
Not meant to
northStand_1 addAction ["<t color='#44bd32'>Open</t>",{northWall setPos [4191,6800,2.204]}];
southStand_1 addAction ["<t color='#44bd32'>Open</t>",{southWall setPos [4191,6768,2.204]}];
eastStand_1 addAction ["<t color='#44bd32'>Open</t>",{eastWall setPos [4176,6785,2.204]}];
westStand_1 addAction ["<t color='#44bd32'>Open</t>",{westWall setPos [4208,6785,2.204]}];
northStand_2 addAction ["<t color='#44bd32'>Open</t>",{northWall setPos [4191,6800,2.204]}];
southStand_2 addAction ["<t color='#44bd32'>Open</t>",{southWall setPos [4191,6768,2.204]}];
eastStand_2 addAction ["<t color='#44bd32'>Open</t>",{eastWall setPos [4176,6785,2.204]}];
westStand_2 addAction ["<t color='#44bd32'>Open</t>",{westWall setPos [4208,6785,2.204]}];
northStand_1 addAction ["<t color='#e84118'>Close</t>",{northWall setPos [4191,6800,0.204]}];
southStand_1 addAction ["<t color='#e84118'>Close</t>",{southWall setPos [4191,6768,0.204]}];
eastStand_1 addAction ["<t color='#e84118'>Close</t>",{eastWall setPos [4176,6785,0.204]}];
westStand_1 addAction ["<t color='#e84118'>Close</t>",{westWall setPos [4208,6785,0.204]}];
northStand_2 addAction ["<t color='#e84118'>Close</t>",{northWall setPos [4191,6800,0.204]}];
southStand_2 addAction ["<t color='#e84118'>Close</t>",{southWall setPos [4191,6768,0.204]}];
eastStand_2 addAction ["<t color='#e84118'>Close</t>",{eastWall setPos [4176,6785,0.204]}];
westStand_2 addAction ["<t color='#e84118'>Close</t>",{westWall setPos [4208,6785,0.204]}];``` this above WORKS.
yep.
However, I want to simplify it. So I can add more "DOORS".
I just want what i've got at the moment. In a more "adaptable" version.
I've tried the foreach
Basically you have 8 "stands" and each of them shall be open- and closeable?
The stand is the object that the player addactions. The *Wall is the object it's moving 2 up or 2 down. to either open or close.
yeah. But is there a limit how many can be open?
Nope
Or is it just a switch that there should be an action if it is currently open then you can close it and the other way round?
fnc_someFunction = {
params ["_str"];
switch (_str) do
{
case ("northstand_1_open") : {northWall setPos [4191,6800,0.204]};
case ("northstand_2_open") : {northWall setPos [4191,6800,0.204]};
case ("southstand_1_open") : {southWall setPos [4191,6768,0.204]};
case ("southstand_2_open") : {southWall setPos [4191,6768,0.204]};
case ("eaststand_1_open") : {eastWall setPos [4176,6785,0.204]};
case ("eaststand_2_open") : {eastWall setPos [4176,6785,0.204]};
case ("westStand_1_open") : {westWall setPos [4208,6785,0.204]};
case ("westStand_2_open") : {westWall setPos [4208,6785,0.204]};
case ("northstand_1_close") : {northWall setPos [4191,6800,0.204]};
case ("northstand_2_close") : {northWall setPos [4191,6800,0.204]};
case ("southstand_1_close") : {southWall setPos [4191,6768,0.204]};
case ("southstand_2_close") : {southWall setPos [4191,6768,0.204]};
case ("eaststand_1_close") : {eastWall setPos [4176,6785,0.204]};
case ("eaststand_2_close") : {eastWall setPos [4176,6785,0.204]};
case ("westStand_1_close") : {westWall setPos [4208,6785,0.204]};
case ("westStand_2_close") : {westWall setPos [4208,6785,0.204]};
};
};
_stands = [
northStand_1,
northStand_2,
southStand_1,
southStand_2,
eastStand_1,
eastStand_2,
westStand_1,
westStand_2
];
{
_varAsStr = str _x;
_x addAction ["<t color='#44bd32'>Open</t>","[format ['%1_open',_varAsStr]] call fnc_someFunction"];
_x addAction ["<t color='#e84118'>Close</t>","[format ['%1_close',_varAsStr]] call fnc_someFunction"];
}forEach _stands;
oh shit wait
you will have to edit the positions.
im not sure what they are supposed to be...
just ry that.
What do you mean @knotty mantle
Just a sec. Why do you have two stands each with exactly same positions?
i didnt do all the position, not sure where he needs all of them
I'll do you guys a gif. One sec.
It is basically getPos select 2 +- 2
Nothing else changes on positions 😃
That would be great 😃
Yeah. but I know the pos... so no need to get it. Because if someone open/closes too quick it bugs out.
would be better if you did a nice animation 😉 so it slides open and close instead of just snapping 😉
lets give him what he wants first and THEN improve what he got 😄
Ah and you got 8 of those little boards. But only 4 walls?
Eight Stands... Each side of the four walls
no i mean send the door through to a function, that slowly moves it up and down, only prob would be it might cause strain 😉
northWall northStand_1 northstand_2 x 4
you would also want to put a condition on the door, so it cant be closed whilst it is already closed
that might be the buggyness you described
I would've just placed them all and then hid or shown them using hideObject.
@little eagle Yeah... might do that for a secret door 😉
bookcase addaction
😛
@wary vine The bug was that it would move as the game sends the pos of object to 0,0,0 for a "tick"
and the way I first done it was that it got the pos of the object and just moved it down.
After multiple "bugs" it would be inside the other walls
@knotty mantle Did you like my gif?
yeah i am writing something currently. Might be PMing you shortly 😃
Does it start opened or closed?
check.
Open
I'm thinking of having a texture on the door... I could have it next to it.
That's a lot of planks..
Yup all simple objects and no simulation
100m x 100m of pallets 😛
pallets are actually not square 😦
?
wanna take a look at what i got ?
What you got?
fnc_animateDoor1 = {
params [
["_door",objNull,[objNull]],
["_anim","open", [""]]
];
private _startHeight = ((getpos _door) select 2);
private _steps = 1000;
private _distancePerStep = (2 / _steps);
private _finalHeight = 0;
private _calc = {};
systemChat str _anim;
switch (toLower _anim) do {
case "open" : {
_finalHeight = _startHeight - 2;
_calc = {((getpos _door) select 2) - _distancePerStep};
};
case "close" : {
_finalHeight = _startHeight + 2;
_calc = {((getpos _door) select 2) + _distancePerStep};
};
};
for "_i" from 1 to _steps do {
private _z = call _calc;
private _x = (getpos _door) select 0;
private _y = (getpos _door) select 1;
_door setPos [_x,_y,_z];
sleep 0.01;
};
};
[testWall,"open"] spawn fnc_animateDoor1;
not great
but works
it should already be 2
testWall,"open"] spawn fnc_animateDoor1;
that should be the call for it.
so with yours istead of set pos, use [doorVar,"open/close"] spawn fnc_animateDoor;
hmm that's good
gimmie 5, ill try to do the whole lot
This:
for "_i" from 1 to _steps do {
private _z = call _calc;
private _x = (getpos _door) select 0;
private _y = (getpos _door) select 1;
_door setPos [_x,_y,_z];
sleep 0.01;
};
Might be easier as
for "_i" from 1 to _steps do {
_door setPos ((getPos _door) vectorAdd [0,0,(call _calc)]);
sleep 0.01;
};
northStand_1 addAction [northWall,"<t color='#44bd32'>Open</t>"] spawn fnc_animateDoor1;
northStand_2 addAction [northWall,"<t color='#44bd32'>Open</t>"] spawn fnc_animateDoor1;
southStand_1 addAction [southWall,"<t color='#44bd32'>Open</t>"] spawn fnc_animateDoor1;
southStand_2 addAction [southWall,"<t color='#44bd32'>Open</t>"] spawn fnc_animateDoor1;
eastStand_1 addAction [eastWall,"<t color='#44bd32'>Open</t>"] spawn fnc_animateDoor1;
eastStand_2 addAction [eastWall,"<t color='#44bd32'>Open</t>"] spawn fnc_animateDoor1;
westStand_1 addAction [westWall,"<t color='#44bd32'>Open</t>"] spawn fnc_animateDoor1;
westStand_2 addAction [westWall,"<t color='#44bd32'>Open</t>"] spawn fnc_animateDoor1;
/// \\\
northStand_1 addAction [northWall,"<t color='#e84118'>Close</t>"] spawn fnc_animateDoor1;
northStand_2 addAction [northWall,"<t color='#e84118'>Close</t>"] spawn fnc_animateDoor1;
southStand_1 addAction [southWall,"<t color='#e84118'>Close</t>"] spawn fnc_animateDoor1;
southStand_2 addAction [southWall,"<t color='#e84118'>Close</t>"] spawn fnc_animateDoor1;
eastStand_1 addAction [eastWall,"<t color='#e84118'>Close</t>"] spawn fnc_animateDoor1;
eastStand_2 addAction [eastWall,"<t color='#e84118'>Close</t>"] spawn fnc_animateDoor1;
westStand_1 addAction [westWall,"<t color='#e84118'>Close</t>"] spawn fnc_animateDoor1;
westStand_2 addAction [westWall,"<t color='#e84118'>Close</t>"] spawn fnc_animateDoor1;```
The "" with open / close is the case yes.
is it the whole "" or just if open / close are found
switch (toLower _anim) do {
case "Open" : {
_finalHeight = _startHeight - 2;
_calc = {((getpos _door) select 2) - _distancePerStep};
};
case "Close" : {
_finalHeight = _startHeight + 2;
_calc = {((getpos _door) select 2) + _distancePerStep};
};
};```
what's that about? fnc_openDoor
it uses a switch case to launch the animate function on the right door.
Okay
@wary vine you have to set the "inUse" as false at the end :p
Aaaand _door setPos ((getPos _door) vectorAdd [0,0,(call _calc)]); that might be a bit better in the last for loop 😃
i'm waiting 😛
yup
turning the variable of the stand into a string, so I can use it in the switch case for open and close 😉
@wary vine you know what the problem with your idea is?
laaaaaaaaag
He has two boards 😄 and by doing it anim style you dont have absolute positions.
Which means. If he opens it 3 times. it goes through the roof 😄
shh
xD
ill do another var for that xD
wait wut ?
dafuq
i tested that bit o.O
yeah i was working on it as well. Even was showing only the open OR close action that he couldnt do it twice. But then i remembered the second stand.
That was the time i gave up and just started looking over your code xD
@knotty mantle NearestObjects 😉
nah missionnamespace getVariable [((str _x) + "status"), "opened"] 😄
huh?
_stands aren't "" they're vars
var > string > var > string > var
??
that´s why you str them. in your code
so why is varAsStr failing?
do me a solid
@drowsy axle put a _varAsStr = ""; above the foreach.
_stands = [
northStand_1,
northStand_2,
southStand_1,
southStand_2,
eastStand_1,
eastStand_2,
westStand_1,
westStand_2
];
{
_varAsStr = str _x;
systemchat _varAsStr;
}forEach _stands;
run in debug console.
do they output strings ?
I see
it's the "" with open and close
because the
"<t color='#e84118'>Close</t>","[format ['%1_close',_varAsStr]]
oh wait nvm
Couldn't you change _varAsStr = str _x; to _varAsStr = _x; _x str;
_varAsStr = (str _x);
are the doors the only object of that type nearby ?
feck
Oh yeah sorry
Sorry im getting mixed up. There no other objects like that. that aren't defined with a var
all objects of the door are var'd up
however, there are multiple doors.
name PositionWall
How do i exit a whole script instead of just the scope i am in?
@wary vine have a look at this. Made small changes to your anim switches. should prevent further opening of opened doors.
Ooooh and you might have mixed up the +/- 😄 Cause the open case actually reduces the z variable 😄
im working on it.
Okay.
RIGHT
feck
sec
that workd
once you have tested, you can remove the systemChats
@knotty mantle
scopeName "main"
call {
call {
127 breakOut "main";
};
};
Makes the function return 127 and works like the return command in other languages.
Thanks 😃
@wary vine you are not setting a status of the door anywhere. And you dont need the _finalheight var
if (_itemCategory == "equipped") then {
if (_itemClassname == (uniform player)) exitWith {removeUniform player;true};
if (_itemClassname == (vest player)) exitWith {removeVest player;true};
if (_itemClassname == (backpack player)) exitWith {removeBackpack player;true};
if (_itemClassname == (headGear player)) exitWith {removeHeadgear player;true};
if (_itemClassname == (goggles player)) exitWith {removeGoggles player;true};
if (_itemClassname == (primaryWeapon player)) exitWith {player removeWeapon _itemClassname;true};
if (_itemClassname == (secondaryweapon player)) exitWith {player removeWeapon _itemClassname;true};
if (_itemClassname == (handgunWeapon player)) exitWith {player removeWeapon _itemClassname;true};
if (_itemClassname in (assigneditems player)) exitWith {player unassignItem _itemClassname;player removeItem _itemClassname;true};
};
``` commy that should work right ? in regards to my question earlier ?
meeeeh
Hey guys does anybody knows how to make this addAction only to appear in the scroll menu when I'm close to another object?
[
player,
"Preparation",
"images\take_ca.paa",
"images\take_ca.paa",
"_target distance player < 2",
"_target distance player < 2",
{},
{},
{
p2 switchMove "Acts_JetsCrewaidL_idle_m";
sleep 3;
p2 switchMove "Acts_JetsCrewaidFCrouch_in";
sleep 2.9;
p2 switchMove "Acts_JetsCrewaidFCrouch_loop";
sleep 2;
p2 switchMove "Acts_JetsCrewaidFCrouchThumbup_in";
sleep 2;
p2 switchMove "Acts_JetsCrewaidFCrouchThumbup_out";
sleep 1;
p2 switchMove "Acts_JetsCrewaidFCrouch_out";
},
{},
[],
0.5,
1000,
false,
false
] call BIS_fnc_holdActionAdd;
Doesn't close the door.
oh and you still have +/- mixed up 😄
close action opens the door and other way round 😄
neither worked
Only display the addAction in the scroll menu if the player or designated target is close to a box or whatever object i just dont wanna have the addAction all the time in my scroll menu.
Done @wary vine
@ornate pawn _target refers to the unit the action is added to. So "_target distance player < 2" is basically "player distance player < 2" and that is always true
I need the addAction ONLY to appear if the player is close to an object that im going to assign
so either add the action to the box you mentioned or switch the player in the condition to something you want to check for
what i mean is if i'm not close to that object I don't want the addAction to be visible in my scroll menu
is for marshalling Area
yeah. That is what i said.
I've done it and the action still appears.
Either add the action to the object you want yourself to be close by or check in the condition if the object is nearby
@drowsy axle do the doors come up or down ?
"_target distance _yourBoxHere < 2" should work.
I want the action only to appear in the scroll menu only if im inside the Marshalling area
im confused.
a trigger for what?
would this in the init file of the object work? "_this distance _target < 2"
I have everything in an sqf file i don't wanna mess with init boxes
How big is your area?
nah i am talking about the function he is using. Not an initbox or something else. But. Bullseye do you have the area with a marker?
Place a marker in the center then do sqf player distance marker_12948273948234 <= 10
I just said that... 🤦🏻
Can i change player to Marshall_Dude_1 or something like that yeah? so the rest of the crew doesn't get thos addActions in the scroll menu
maybe he didnt read it yet. Not so harsh mate 😃
i see that Capwell
Yep
