#arma3_scripting

1 messages ยท Page 665 of 1

copper raven
#

don't know any other way of doing it

dusty whale
#

yeah, i was trying to avoid that

#

but if it comes down to it i'll just delete the weapon aswell

dusk gust
#

Potentially looking for setWeaponReloadingTime?

dusty whale
#

thanks for the help

dusty whale
#

not magazines

dusk gust
#

Ahh

copper raven
#

i had a similar issue aswell, that's the only solution i found, it's clunky but gets the job done

opal sand
#

is there anyway to get rid of this choppy running in unitcapture recording? my first idea of a solution would be to have humans playing instead of relying on unitcapture?

winter rose
#

BIS_fnc_unitCapture is for air vehicles and should appear smooth?

copper raven
#

what are you doing exactly?

dusty whale
#

removing the weapon from the turret

#

removing all magazines

#

adding the magazine i want

#

adding the weapon

#

the gun muzzle also flashes very briefly

#

i figure that's a side effect of removing and adding the gun

copper raven
#

hmm just tested again on the tigris titan missiles, works fine

dusty whale
#

can you share the script?

#

i can compare if im doing something wrong

copper raven
#
vehicle player removeMagazinesTurret ["4Rnd_Titan_long_missiles_O", [0]];
vehicle player removeWeaponTurret ["missiles_titan_AA", [0]]; 
vehicle player addMagazineTurret ["4Rnd_Titan_long_missiles_O", [0]];
vehicle player addWeaponTurret ["missiles_titan_AA", [0]];
gloomy aspen
#

Hey guys i'm facing an issue with a function i'm trying to implement via scripts.

The idea is a set of 'lockers' which players can only access if their UID matches that defined by a script and a marker.

In my init.sqf I have


[] execVM "scripts\cages\b70a.sqf"
[] execVM "scripts\cages\b71a.sqf"
[] execVM "scripts\cages\b71b.sqf"

Then three separate scripts named 'b70a.sqf','b71a.sqf','b71b.sqf' which look like this

private _myWhiteList1 = ["id1"];

while {true} do
{
    {
        if (!(getPlayerUID _x in _myWhiteList1) && (_x inArea "b70a")) then
        {
            _x setPos getMarkerPos "cageteleport";
        };
    } count allPlayers;
    sleep 0;
};
private _myWhiteList2 = ["id1"];

while {true} do
{
    {
        if (!(getPlayerUID _x in _myWhiteList2) && (_x inArea "b71a")) then
        {
            _x setPos getMarkerPos "cageteleport";
        };
    } count allPlayers;
    sleep 0;
};
private _myWhiteList3 = ["id1"];

while {true} do
{
    {
        if (!(getPlayerUID _x in _myWhiteList3) && (_x inArea "b71b")) then
        {
            _x setPos getMarkerPos "cageteleport";
        };
    } count allPlayers;
    sleep 0;
};

So far testing shows that the script works fine if there is just one working, but as soon as another is added they all stop functioning (Tested in SP & MP)

dusty whale
#

let me try this script on the tank

#

Nope

#

doesnt work for the tank

copper raven
#

modded?

#

or vanilla

dusty whale
#

nope

#

vanilla

copper raven
#

which tank and what ammo

dusty whale
#

here:

vehicle player removeMagazinesTurret ["24Rnd_120mm_APFSDS_shells_Tracer_Red", [0]]; 
vehicle player removeWeaponTurret ["cannon_120mm", [0]];  
vehicle player addMagazineTurret ["24Rnd_120mm_APFSDS_shells_Tracer_Red", [0]]; 
vehicle player addWeaponTurret ["cannon_120mm", [0]];```
#

slammer

winter rose
#
[[_id1, _id2], "b70a"] execVM "areaTeleport.sqf";
gloomy aspen
#

@winter rose do you think the over complication is causing the non-functionality?

#

Thanks btw, ill try that

winter rose
#

I have no idea why it stops and it should not

gloomy aspen
#

yeah its odd, it works perfectly if theres only one of the scripts being called, as soon as the second goes in it stops

opal sand
#

How do i play a series of multiple animations together smoothly?

winter rose
#

playMove

copper raven
dusty whale
#

wouldnt setWeaponReloadingTime remove it?

#

because it doesnt

#

so it cant be reloading the round

copper raven
#

vehicle player setWeaponReloadingTime [player, "cannon_120mm", 0]; after it seems to work

dusty whale
#

i'm running vehicle player setWeaponReloadingTime [gunner(vehicle player), currentMuzzle (gunner(vehicle player)), 0.0]; which doesnt

#

basically the same, just more general purpose script

copper raven
#

currentMuzzle won't work because you're on MG when you run that script

#

atleast in slammer

dusty whale
#

๐Ÿ˜“

#

yeahhhhh

#

youre right

#

big dumb dumb

#

thanks for the help

#

really appreciate it

copper raven
#

np^^

dusty whale
#

โค๏ธ

opal sand
#

@winter rose so like 'man1 playmove 'insertanimhere'; playmove 'insertanimhere'; playmove 'insertanimhere'; etc?

winter rose
#

man1 playMove "..." every time

gloomy aspen
opal sand
gloomy aspen
#

@winter rose Alright pal, thank you ๐Ÿ™

winter rose
copper narwhal
#

sorry for butting in on the convo but would you guys know if it is possible to prevent a player changing weapon attachments in the vanilla inventory but still allowing something like the ace3 interaction menu to change attachments? If so would it be done using an eventhandler of some sort or how would i begin?

crude vigil
#

@copper narwhal It should be possible.. You can first create an event handler , check if player has opened inventory, when opened, retrieve the attachments first and create a while loop till inventory is closed, check continuously the weapon attachments, if anything modified, change them back according to the retrieved attachments?

opal sand
#

@winter rose Hey thats great, thanks so far, but it seems as though some animations wont play after other specific ones (e.g 'loop', or 'terminal'), is this right?

copper narwhal
opal sand
#

And, guys, how do i an activate a trigger, but delay it (e.g 15 seconds) so i can set up the camera ready to record? (tried radio delta, countdown/timeout 15 seconds, but that doesnt work)

crude vigil
#

@copper narwhal That is indeed the better solution regarding user experience. People will still be able to attach stuff using right click. That is what will be annoying if you take the GUI modification approach. You ll need to prevent a lot of stuff..

As for the performance part.... if code is on client side(which should be in this case), every man computes for himself for their own opened inventory, so ' a lot of people opened inventory ' is not a case to worry about. And a single while loop wont hurt you at all, let alone it is not even run always but only while inventory is opened. :)

#

Either way, you ll need to implement what I said because, iirc, even taking a weapon mod from ground is automatically adding to your primary weapon if there is space. Although not sure what exactly you are up to, so maybe u do not need.

copper narwhal
crude vigil
#

If you manage, better do it the way you called. Because without any information on UI side, players may not understand why attachments cant be added to weapon.

dusty whale
#

Funny issue. If a vehicle collides with something, the gunner will no longer take lookAt commands

#

even if AUTOCOMBAT is disabled in the AI

copper narwhal
#

the reason why im doing this is because infistar is being a pain and blocking the function of a mod when using the vanilla inventory but not when using the ace interaction menu surprisingly

dusty whale
#

even if the combat state is set to careless

#

even if i repeatedly set it to careless

#

the ai returns to the default gun position

robust tiger
#

try doWatch

dusty whale
#

setBehaviourStrong doesnt help either

#

doWatch is too slow

#

there is considerable lag compared to lookAt

dusty whale
#

and it doesnt matter if the thing you crash into is an enemy tank

#

but if it's a dead tank, then it triggers the AI to just look forward

#

ONLY dead vehicles do this

#

empty vehicles are fine

#

scratch that

#

empty vehicles do the same

#

if it's Civilian units, then there is no issue

#

let me set blufor and opfor friendly

#

see what happens

spark turret
#

DoTarget works for me for giving suppressive fire

dusty whale
#

nope

#

setting friendly sides doesnt work

#

civilians it is, then

copper narwhal
winter rose
dusty whale
#

now there's considerable lag in aiming

#

with both lookAt and doWatch the AI pauses for a moment before fixing the vertical allignment

#

is it ranging?

#

and can i tell it to not do that?

#

i've set aimingSpeed to 1

robust tiger
#

I made a nasty workaround

{car forgetTarget _x}foreach (car targets [false]);
group car setBehaviour "AWARE";
 car dowatch getpos player;
dusty whale
#

?

#

problem is now that the AI is supposedly doing ranging

#

or something like that

#

the horizontal aiming is immediate

#

but the vertical lags behind

robust tiger
#

I'm not 100% sure what the issue is. Could you tell me what is the goal here? I missed it ๐Ÿ˜…

opal sand
#

@winter rose thankyou so far sir, heads up, gif coming your way soon, take cover ๐Ÿ˜‚ , last question, how do i delay a triggers activation? need to get the camera setup in position ready to record, prior to triggers actions being played out

winter rose
opal sand
#

[] spawn { sleep 10; /* stuff */ }; (Whats this stuff stuff all about?)

winter rose
#

before, what is immediate
in the "stuff" part, what is to be delayed
10 being the delay (in seconds)

#
hint "triggered!";
[] spawn {
  sleep 5;
  hint "waited 5 seconds";
};
opal sand
#

the trigger has a fair few lines of animation code in the on activation field, so, what do i do?

winter rose
#

I DON'T KNOW!! ๐Ÿ˜ฑ

#

add them in the spawn?

opal sand
winter rose
#

wrap them with the spawn {}

opal sand
#

i think i got u

#

@winter rose if im triggering you will ask someone else, sorry but what is easy to you is very tough for me, still dont get it, but thanks for trying

winter rose
#

spawn creates a new script where you want use sleep (you cannot use sleep in a trigger's code)

opal sand
#

hey how do you do that crop screenshot thing again? got an error msg

winter rose
#

Windows+Shift+S, or printscreen+paste in mspaint

opal sand
#

(How i put my code in, in on act):

[] spawn {
sleep 10;
man1 switchmove "thing1";
man2 switchmove "thing2";
man3 switchmove "thing3";

{man4 switchmove _x } forEach ["thing4", "thing5", "thing6"];

{man5 switchmove _x } forEach ["thing7", "thing8", "thing9"];
};

copper raven
#

comments don't work in those boxes

opal sand
#

@copper raven what? i dont understand what youve just said

copper raven
#

remove the //

opal sand
#

right lol

copper raven
#

talking about comments why don't we have a preprocess <STRING>?

still forum
#

Because game crashing preprocessor. And in general no

copper raven
#

writes sqf preprocessor in sqf

opal sand
copper raven
#

do something like furb_dummy = [] spawn ...

#

or just anything, _stuff = ๐Ÿ˜„

glass zinc
#

Im having a issue trying to pull a specific phrase from a string.
Is there any way to pull "CargoTurret" from a longer string of "Dfljlekwfadfskljflksjef/adshflksejflsakdjf/hsdflksjflejkf/CargoTurret/dslfjksdlfjas/CargoTurret/alkdfjalsdkjf"
and count the number of times it occurs?

#

there are lots of options to filter by characters or elements

#

but does not seem to be a way to pull by specific words

#

and count them

#

any ideas?

copper raven
#

think we've had something similar in the past

#

uh

#

modify it abit, you might not want it returning an array if you don't care about where exactly they occur

glass zinc
#

yeah i saw that on the wiki

#

but i cant seem to figure out how to apply it to my problem

#

as the wiki does not really explain what each part of it is doing

still forum
copper raven
#

e.g count (["Dfljlekwfadfskljflksjef/adshflksejflsakdjf/hsdflksjflejkf/CargoTurret/dslfjksdlfjas/CargoTurret/alkdfjalsdkjf", "CargoTurret"] call _fnc_findStringsInString)

#

@glass zinc

glass zinc
#

ok will give that a try

warm hedge
#

I never thought it was a bug...

copper raven
#

wonder what would happen if you did 0 = compileFinal "" before the object init is ran xD

#

would break so many missions

winter rose
#

would not attribute the value to 0 afaik

#

in Arma 2 and before you could do true = falseโ€ฆ

opal sand
glass zinc
#

@copper raven it works!

#

thank you

still forum
dusty whale
#

currently it aims at the position in horizontal axis immediately, but the vertical axis takes quite long

opal sand
still forum
#

Huh?

#

I meant you should use perf_prof branch (the branch, not the channel), not post there about a bug thats fixed on the branch

opal sand
cold mica
dusty whale
#

why is setWeaponZeroing dev branch only notlikemeowcry

#

me want set-zeroing-delight

still forum
opal sand
mighty vector
#

my server needs to be restarted each 4 hours or so. i have a working script but it's time for improvement.
so far, my best bet is to have a looong uisleep 14400;

is this a crime?

related: i want to cancel. my best idea so far is to terminate a waiting script, using something like:
_wait = [] spawn {sleep 1440};
//on certain condition
terminate _wait;

is this another crime?

winter rose
hallow mortar
#

Is #include case sensitive?

mighty vector
#

@winter rose that second waitUntil IT'S a crime xD. no need to check time each half frame if event is going to be in 4hours!!!!

winter rose
#

what is your use case?

mighty vector
#

my server needs to be restarted each 4 hours or so

winter rose
#

I mean, what is condition1 ^^

still forum
mighty vector
#

well...restarting might be delayed/canceled...and that's what i havent tried yet...
lets suppose restart is set in 4 hours, and im in the middle of my assault. a simple "delay 1 hour" could work.
i have 2 approaches in mind:

use uisleep+terminate and reschedule restart to the new time (quiter dirty)
keep waiting until the old time and wait again (as the new restart time has changed)

winter rose
#

you can sleep and check every minute if you prefer ^^

robust tiger
# dusty whale have the AI aim at a spot immediately

Some things I've noticed using doWatch and the like:

  1. Using a position instead of an object won't have the gunner wandering around (When he targets something, he's not really aiming at the unit but its last known position. If you've ever played Arma on recruit with an AI squad leader you'll sometimes notice the target icon is not on the unit's actual position and wanders a lot without direct LOS)
  2. Disabling the AI "TARGET" and "AUTOTARGET" might help, preventing the AI to "override" your commands
dusty whale
#

TARGET AND AUTOTARGET are disabled and i am using a position

#

with both lookAt and doWatch

#

doesnt matter

mighty vector
#

@winter rose but that sucks!...
acording to documentation waituntil checks every frame...that's useless. it might be much better (optimized) to just sleep 14400!
already have a draft i have to test...but this code seems much cleaner

#

let me try it and i'll come back

winter rose
#

also,

Premature Optimization is the root of all evil

mighty vector
#

knuth!

winter rose
#

Yes!

dusty whale
#

I wish i could solve this

#

๐Ÿ˜“

#

but it looks like i'll have to abandon this idea

#

the AI refuses to cooperate

#

i wish there was just a way to tell the AI too aim their gun at stuff without all this extra

#

i've disabled every single bit of the AI i can

#

and it still goes wondering off with the aim

#

it's unresponsive at times aswell

#

why is this game like this?

#

why are there like 50 scripting solutions to one problem but all of them are broken

robust tiger
dusty whale
#

as far as im aware of, you need AI to set the direction of a vehicle's turret

#

you can rotate the turret without AI

#

but you cant elevate it

robust tiger
#

I posted something similar earlier with the setVelocityTransform command, except you would do it manually and only with dir vector

dusty whale
#

no, but what i mean is that there is no command to set the weapon direction of the AI

#

please prove me wrong and say there is

robust tiger
#

you do it over small steps so it's smooth and neat looking

winter rose
#

there is no command to set the weapon direction of the AI
correct

dusty whale
winter rose
robust tiger
#

but the gunner is

winter rose
robust tiger
#

ok, it worked on the hunter

dusty whale
#

can i use animateSource to set the elevation of a gun?

robust tiger
#

it does not work on the tank, my bad

dusty whale
#

i can calculate the correct degree, but if im not able to, i wont even start

#

i think i can

#

need to try this in practise

#

if i can, then i'm neutering the AI the rest of the way

#

this is going to be so annoying to script in sqf

mighty vector
#

time + 120 works. i guess serverTime+120 too. are there any functions to add time? eg: systemTime+120

dusty whale
#

vehicle player animateSource ["mainturret", 1]; doesnt seem to work

#

(vehicle player animationSourcePhase "mainturret"); returns a coherent number

#

that solves it

#

no overriding animation source

mighty vector
# winter rose _wha'?_

lol.
servertime=time in seconds since server started=>number. if I add 120 is like adding 2 minutes (future time when the server will be restarted)
seems I cant easily add minutes to systemTime. is there an "add_seconds_to_time(systemTime,120);" ? i dont hink so

dusty whale
#

one more broken solution to add to the pile

#

it's VERY interesting that BI cant expose a command to the script that would be able to animate the turrets of vehicles

#

How old is this feature? Like 20 years?

#

granted, sqf hasnt existed for the entire duration of Arma

winter rose
winter rose
dusty whale
#

i suppose

#

but it's still a bummer

#

well, atleast the AI simulates the average soldier perfectly

#

disagreeable at best

#

well, 16 hours of that down the drain

winter rose
dusty whale
#

only because the AI cant work with me

mighty vector
winter rose
#

for display, ok

#

I thought it was for "real world precision" ๐Ÿ™ƒ

mighty vector
#

wont time work on server side?

winter rose
#

it will !

#

hence why my earlier solution will work!

mighty vector
#

...i dont understand. sorry.
reason to use diag_tickTime instead of time?

winter rose
#

microsecond precision ๐Ÿ˜„

mighty vector
#

for a 4h restart? not needed xD

winter rose
#

correct ๐Ÿ˜„

#

for display, though, it might be another trick
but you can also do a countdown, e.g restart in 2h, 1h, etc

mighty vector
#

sure...but that v3.0 xD

winter rose
#

well, countdown is easier than converting time array

mighty vector
#

sometimes i wonder why some things in arma were made the way they were made...๐Ÿคทโ€โ™‚๏ธ

dark ivy
#

I'm using the Vehicle Respawn module in a mission, and I want to empty out the vehicle's inventory and give it a custom inventory after it respawns, but don't know how. Any help?

#

I was thinking of something along the lines of placing

execVM "vicInv\RU_vic.sqf";

in the Vehicle Respawn "Expression" field, and that file would contain

clearWeaponCargoGlobal _this;
clearMagazineCargoGlobal _this;
clearItemCargoGlobal _this;

_this addItemCargoGlobal ["rhs_10Rnd_762x54mmR_7N1",14];
_this addItemCargoGlobal ["rhs_30Rnd_545x39_7N10_AK",30];
_this addItemCargoGlobal ["rhs_45Rnd_545X39_AK_Green",7];
_this addItemCargoGlobal ["rhs_GRD40_Red",7];
_this addItemCargoGlobal ["rhs_VOG25",7];
_this addItemCargoGlobal ["rhs_mag_rgo",20];
_this addItemCargoGlobal ["rhs_mag_rdg2_white",20];

Obviously the problem here is that I can't use _this or the old vehicle's variable name.

winter rose
dark ivy
#

Module says that passed arguments in expression field are [<newVehicle>,<oldVehicle>] so by doing clearWeaponCargoGlobal _this select 0; it should hopefully work, right?

winter rose
#

yes?

dark ivy
#

Just tested and it works! Thanks Lou.

dusty whale
#

AI gunner of vehicle doesnt take any lookAt commands if you bump into something with the vehicle

#

instead, reverts to a forward looking position

#

despite being entirely disabled

#

apart from "WEAPONAIM"

#

because i need that for lookAt

#

why is this AI so broken?

#

FSM is disabled too

#

so it should not be doing ANYTHING

#

any idea what's causing this behaviour?

#

same behaviour persists even if the vehicle and crew are set to not take any damage

#

I dont know anymore

little raptor
#

AI need TARGET and AUTOTARGET to aim properly

dusty whale
#

there's a video to the issue

#

^^

#

on that clip, only the scripts in the debug console were run

#

disableAI was untouched

dusty whale
dusty whale
#

or is this intended behaviour?

little raptor
#

you were told wrong

#

when AUTOTARGET is disabled AI won't keep track of the target

dusty whale
#

im not using target, im using lookAt

#

as featured in the video

#

and "target" is not disabled in the video

dusty whale
#

is this a bug or a feature?

little raptor
#

ยฏ_(ใƒ„)_/ยฏ

#

I don't think the current devs will bother with the AI either way
The "AI devs" are gone

mighty vector
#

hmm...second time i crash arma

dusty whale
#

"yes"

mighty vector
#

whats the proper way of exiting a function?
exitwith{}; shouldn't work?

dusty whale
#

well, i guess i cant bother with arma anymore, then

#

such a shame

little raptor
#

exitWith exits the current scope

little raptor
mighty vector
#
PMCES_set_restart = { 
  systemchat format ["%1",_this];
  systemchat format ["%1",time];
  _r=time+_this*60*60;
  systemchat format ["%1",_r];
  _remaining_time=_r - time;
  systemchat format ["%1",_remaining_time];
  //...
  if(isNil "_myvar") exitWith {}; <-----------this seems to crash
};
1 call PMCES_set_restart;
dusty whale
#

Why is support for one game dropped when the other game isnt out yet?

copper raven
#

i guess you can try manually setting the turret direction or something like that(would be hard to detect when you should actually do that), that looks like just some regular arma ai weirdness

dusty whale
little raptor
#

it's not dropped, the majority of the team has just moved to other projects

dusty whale
#

i'm just really frustrated at this point

#

because of how much i did to try and make it work and it gets destroyed by this bug

#

/"feature"

little raptor
#

@dusty whale does lookAt just stop working completely?

dusty whale
#

once you bump into something, yes

#

running the command again doesnt help

#

the AI just flatout ignores it

copper raven
#

what about doWatch?

little raptor
#

send the script

#

let me take a look

dusty whale
dusty whale
little raptor
#

you just run "execVM"

dusty whale
#

i didnt

#

that was there from previous test

#

i deleted that and ran the script i wrote

little raptor
#

ah ok

#

so this:

gunner vehicle player lookAt position player
```?
dusty whale
#

gunner (vehicle player) lookAt getPos player;

#

just something that came to mind

little raptor
#

that's literally the same thing

#

anyway

#

let me test it

dusty whale
#

just tested

winter rose
#

doTarget?

dusty whale
#

needs a target

winter rose
#

glanceAt ๐Ÿ˜„

winter rose
dusty whale
#

the AI refuses any and all commands after you bump into something

#

it nicely keeps the gun level to the front, though

copper raven
#

after some time it works again

#

xD

dusty whale
#

setBhevaiour doesnt help

mighty vector
#

systemchat format ["%1",_remaining_time]; prints 5
uiSleep _remaining_time;

error generic error in expression ?

copper raven
#

probably uiSleeping in unscheduled

dusty whale
#

prints doesnt exist

#

or

#

that's part of the message

mighty vector
copper raven
#

yes debug console is unscheduled

dusty whale
#

but it is a good point

#

how long did it take?

mighty vector
dusty whale
#

maybe it can help debug the issue

dusty whale
#

use spawn

mighty vector
#

oks

dusty whale
#

[parameters] spawn {script}

mighty vector
#

its a function...so [parameters] spawn {call function}, isnt it?

copper raven
dusty whale
#

So it does

#

let me break out the stopwatch

little raptor
#

@dusty whale using a fake target works just fine

#

as for lookAt:

after some time it works again

#

as sharp. said

dusty whale
little raptor
#

use a fake target instead

#

forget about that command

dusty whale
#

for which command?

little raptor
#

doTarget

dusty whale
#

copy

little raptor
#

do you have CBA?

dusty whale
#

i'll have to reveal target, dont i?

#

yes

#

i use CBA for the extended debug

little raptor
#

use this

_target = "CBA_O_InvisibleTarget" createVehicleLocal ASLtoAGL getPosASL player;
createVehicleCrew _target;
gunner vehicle player doTarget _target;
#

he won't stop aiming according to my tests

copper raven
little raptor
#

it may also work without createVehicleCrew

#

since the simulation for that object is of "TankX"

#

and it has a high cost

exotic tinsel
#

can someone point me in the direction of what i would need to do to get the class/type name from a terrain object .p3d name.

little raptor
#

typeOf

exotic tinsel
#

that works on terrain objects?

little raptor
#

but some terrain objects have no type

exotic tinsel
#

rgr

little raptor
dusty whale
#

ok, now it works

#

the AI also finds it fun to engage it with fire

dusty whale
#

but most

#

some terrain objects dont have a type

little raptor
dusty whale
little raptor
exotic tinsel
#

so typeof does not work on the terrain object which is a fence. so any idea how i can get the class name from the .p3d name? i know the fence exists in the props so it is an object with a class name

copper raven
#

scan cfg with the model name

dusty whale
exotic tinsel
#

yeah im new i dont know how to do that. do you have alink i can get started with?

dusty whale
#

the gunner registers the contact but doesnt actually turn to face it

#


_target = "CBA_O_InvisibleTarget" createVehicleLocal ASLtoAGL getPosASL player;
gunner (vehicle player) reveal _target;
gunner (vehicle player) doTarget _target;```
exotic tinsel
#

@copper raven thx mate

copper raven
#

it's gonna be expensive, might wanna consider caching

little raptor
mighty vector
#

any ideas?

PMCES_set_restart = { 
  systemchat format ["%1",_this]; //<----------first time invoked it says 1, but on recursive call it also says 1! (although it may be null)
  //...
  call PMCES_set_restart; //<-this call is also showing "1" ???
};
1 spawn { call PMCES_set_restart; };
dusty whale
little raptor
dusty whale
#

i dont care

#

i'm simulating my own firing already

#

animating the gun barrel and doing the flash

#

aswell as spawning the projectile

#

but this is satisfactory

dusty whale
#

not fun, but enough

#

if the AI can keep the gun on target, that is enough

mighty vector
little raptor
#

no

little raptor
#

what did you expect?

#

but anyway, you have to pass new args to the call

winter rose
little raptor
#

if you want it to change

mighty vector
#

[] call ๐Ÿ˜‰

#

not working...let me debug...xD

dusty whale
#

Thank you!

#

โค๏ธ

#

@little raptor thank you leopard, i mean

#

i quoted myself there by accident

#

so it needs to have a crew

dusty whale
#

now it travels a bit

#

THE AI has a hard time keeping track of the target

#

๐Ÿ˜“

#

but i'll look after that tomorrow

#

doTarget tooltip in the debug console says "unit doTarget position" despite the fact that doTarget doesnt take a position, but an object or an array

stuck rivet
#

how do I refer to an object that I haven't made a reference to in the editor in the debug console without being physically present? Say I want to destroy an object X setDammage 0 what would take the place of X? Usually I would do cursorObject but that requires to be present and looking at it

winter rose
#

you could e.g grab it with a nearestObject command

stuck rivet
#

that gets me something like 21c272cc080# 1780805: ah64d.p3d

winter rose
#

yep, that's the object

stuck rivet
#

how do i use it in a script?

#

getPos 21c272cc080# 1780805: ah64d.p3d

#

doesn't appear to work

robust tiger
#

save it into a global

willow hound
#
str cursorObject //Can return something like "21c272cc080# 1780805: ah64d.p3d"
```Because it's just the string representation of your object.
robust tiger
#
myObj = nearestObject [...]
stuck rivet
#

ah ok thanks it works

#

out of curiousity can you remove global variables?

robust tiger
#
myObj = nil
#

usually works for me

stuck rivet
#

I see

willow hound
stuck rivet
#

thanks ๐Ÿ‘

mighty vector
#

this works

if(!foo) exitwith {};

but how can I do something like:

if(bar) then {
//...
//...
exitwith {}; <-------------------------exit/end script here
};

still forum
#

See

#

No. But please read it

mighty vector
# still forum No. But please read it

sorry, but I dont get it. (spanish native :S)
would a "false" do the trick?

to give some context:

PMCES_set_restart = { 
  if (isNil "_foo") then {
    if (isNil "_bar") exitwith {};
    //doC
  } else {
    //Already waiting and minutes given -> update and exit
    if (!isNil "_bar") then {
      //doA
      //doB
      //exit <------------this is what i want, for cleaner code
    };
  };
  //...
}; 
[1] spawn { call PMCES_set_restart; };
robust tiger
# dusty whale now it travels a bit

I'm gonna come back with my favorite doWatch ๐Ÿ˜›
After the AI successfully acquires it with doTarget you could do a while{true} loop with doWatch. Like so:

watch_script = [] spawn
{
  while{true}do
  {
    _unit doWatch (getPos _target); //argument as position seems more reliable than object; emphasis on 'seems'
    sleep 0.05;
  };
};

Then you could terminate that with:

terminate watch_script;
_unit doWatch objnull;
still forum
#

while true loops should always have a sleep

dusty whale
still forum
#

its nonsense to call doWatch a hundred times every frame

robust tiger
#

well it's a workaround for hard to crack problem

still forum
dusty whale
#

im using doTarget already

#

and it works ok

#

this is just so stupid in general

#

please expose something that i can use to set the rotation of the turret

#

just animateSource is enough

#

i'll work out the math

#

because working with the AI is the bane of all existence

mighty vector
still forum
#

no.. not really

valid abyss
#

Is there any way to create a new inventory item?

still forum
#

scripting, no

mighty vector
heady quiver
#

Hi guys, why does my a jet take off when its linked to a CAS Bomber Support ?

mighty vector
#

can I get an script handle within the script? like using _this ?

unique sundial
#

there is nothing wrong with goto

mighty vector
#

...

#

there is...and inside your heart, you know it

unique sundial
#

you can tell me what is wrong with it

mighty vector
#

well...its unestructured

#

and thats enough evil for me ๐Ÿ˜›

still forum
#

its only unstructured if you can't make it be structured

mighty vector
unique sundial
#

switch is basically subset of go to, do you hate it too?

still forum
#

yes, if you write bad code its bad code

mighty vector
#

goto its the proper way for spaghetti code...and people who use it (except for switch), will met satan in hell ๐Ÿ˜›

#

anyway...going back for my fusillini code...i have a long running sleep and i want to cancel it.
AFAIK, terminate supports spawn handles...

#

can that handle be linked somehow to _this? can i make "terminate _this" ? (not doing the exit, just for another crappy code)

unique sundial
#

you canโ€™t

#

when you add slip the script is rescheduled for the time after sleep

#

this is why you canโ€™t sleep less but likely more

#

so the script is on hold and will not respond to terminate unless it is simulated

heady quiver
#

Guess no body knows ๐Ÿ˜ฆ

mighty vector
#

so...

PMCES_set_restart = { 
  systemchat "hello";
  sleep 14400;
};
_handle=[1] spawn { call PMCES_set_restart; };
sleep 10;
terminate _handle;

wont terminate until sleep 14400 ends.

unique sundial
#

script wonโ€™t run?

mighty vector
#

my bad...i mean, it will not terminate "immediatly", but only when sleep ends

#

is that right?

unique sundial
#

depends on what is before sleep

mighty vector
#

my bad again

#

ill put it simpler

unique sundial
#

if it has to suspend before sleep it will terminate before sleep

mighty vector
#

updated, for better understanding

still forum
#

terminate will stop your spawn before the long sleep ends yes

unique sundial
#

also how do you know it doesnโ€™t terminate until after sleep?

mighty vector
#

...sorry for my english...but aren't u guys saying opposite answers?

crimson walrus
#

Why
_handle=[1] spawn { call PMCES_set_restart; };
instead of
_handle=[1] spawn PMCES_set_restart;
?

unique sundial
#

if you keep on changing question

still forum
mighty vector
still forum
mighty vector
#

ill try to explain the best i can

#

i scheduled a server restart in 4hrs, so instead of checking periodically, my script will sleep 14400

#

if someone wants to "cancel" or change restart time, it could "terminate" the previous process(sleep) and run another

still forum
#

yep. and you can do that with terminate like you posted above

mighty vector
#
//serverinit.sqf or whatever
PMCES_set_restart = { 
  systemchat "hello";
  sleep 14400;
};
_handle=[240] spawn { call PMCES_set_restart; };

//someone wants to reschedule
terminate _handle;
_handle=[120] spawn { call PMCES_set_restart; };
still forum
#

local variable obviously won't work, but yes something like that you can do

mighty vector
#

ok, perfect...now, the initial question was

#

if theres a way to get handle within script, in order to change PMCES_set_restart to set "global_handle"=this

still forum
#

how about
global_handle =[120] spawn PMCES_set_restart;

#

Or how about reading the wiki?

unique sundial
#

_thisScript

mighty vector
#

thats not the issue...

#

or at least, again, i didnt explain myself

still forum
#

Thats exactly the answer to your question.
If you don't ask what you wanna ask then its hard to help

mighty vector
#

AND I'M MUCH APPRECIATED FOR YOUR PATIENCE๐Ÿ’Œ

still forum
mighty vector
#

what i was thinking was about the scope of the handle

#

the restart script is inside initserver.sqf or whatever

#

but the "cancel" this restart and reschedule is going to be used from console/debug while playing

#

so i have to rewrite PMCES_set_restart to terminate older handle and register the new

#

like a global variable...

still forum
#

yes

mighty vector
#

missionNamespace setVariable ["pmces_next_restart_handle", _pmces_next_restart_handle];

#

would that be the correct approach?

still forum
#

just store handle into global variable at the beginning of yur PMCES_set_restart

#

terminate (missionNamespace getVariable ["PMCES_restartHandle", scriptNull]);
PMCES_restartHandle = _thisScript;
...

crimson walrus
#

PMCES_set_restart = {
if (not isNil "global_handle") then { terminate global_handle; };
global_handle = _thisScript;
sleep 14400;
};

How's that?

unique sundial
#

global_handle = _thisScript;

mighty vector
#

that's what i was looking for. your 3 answers toghether

#

@still forum yes, terminating a global variable
@unique sundial yes, using _thisScript
@crimson walrus you summarize, but i love u too

#

thank u...going to try it rn.

mighty vector
#

Okay...lets check for QA/advices:

PMCES_set_restart = { 
  //Schedule next restart to PARAM minutes from now.
  params["_minutes"];
  private _pmces_next_restart_handle = missionNamespace getVariable "pmces_next_restart_handle"; 
  //It's already waiting?
  if (isNil "_pmces_next_restart_handle") then {
    //Not waiting and no minutes given -> nothing to do
    if (isNil "_minutes") exitWith {};
    //No, but minutes given -> Start waiting
    //systemTime doesn't allow to easily add minutes. Using time
    _pmces_next_restart_time = missionNamespace setVariable ["pmces_next_restart_time", time+_minutes*60]; 
    //Register handle
    missionNamespace setVariable ["pmces_next_restart_handle", _thisScript]; 
  } else {
    //Already waiting and minutes given -> update and terminate older
    if (!isNil "_minutes") then {
      _pmces_next_restart_time = missionNamespace setVariable ["pmces_next_restart_time", time+_minutes*60]; 
      terminate _pmces_next_restart_handle;
      missionNamespace setVariable ["pmces_next_restart_handle", _thisScript]; 
    };
  };
  //So far ready to wait or restart
  private _pmces_next_restart_time = missionNamespace getVariable "pmces_next_restart_time"; 
  //systemchat format ["_pmces_next_restart_time: %1 and now: %2",_pmces_next_restart_time, time]; 
  //Wait until restart time 
  if (_pmces_next_restart_time > time ) then { 
    private _remaining_time = _pmces_next_restart_time - time; 
    uisleep _remaining_time; 
    diag_log "PMCES Restarting in 2 minutes..."; 
//TODO hint vs BIS_fnc_showNotification
    uisleep 120; 
    [] call PMCES_set_restart; 
  } else { 
    diag_log "PMCES Restarting..."; 
//TODO hint vs BIS_fnc_showNotification
//TODO restart; 
  }; 
}; 
[60] spawn PMCES_set_restart;
still forum
#

you know that you do't need the getVariable/setVariable right?

#

Please use sqf highlighting

#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
โ†“

// your code here
hint "good!";
still forum
#

pretty hard to read that mess above

mighty vector
mighty vector
still forum
#

how are you waiting until the restart?

#

you are just repeatdly calling yourself?

unique sundial
#

you can edit your posts

still forum
#

and you are restarting even though the time is not up?

mighty vector
#

...sorry...too many questions and didnt understand them. :S
on first run, last line start the first restart schedule (1hour)

#

if someone invokes another thing, it would be overwritten and a new start is made. previous is terminated

#

the wait its just an sleep and a final recursive call

still forum
#
PMCES_set_restart = { 
  //Schedule next restart to PARAM minutes from now.
  params["_minutes"];

  terminate (missionNamespace getVariable ["pmces_restart_handle", scriptNull]);
  pmces_restart_handle = _thisScript;
  
  // wait until restart
  sleep (_minutes-2)*60;
  diag_log "PMCES Restarting in 2 minutes..."; 
  //TODO hint vs BIS_fnc_showNotification
  sleep 120;
  diag_log "PMCES Restarting..."; 
  //TODO hint vs BIS_fnc_showNotification
  //TODO restart; 
};
[60] spawn PMCES_set_restart;

how about just that?
assuming your minutes are always bigger than 2

mighty vector
#

let me read, understand and probably cry...
BUT i dont want to check if i need to restart every 2 minutes. dont need to...

still forum
#

Your code maybe does that, mine doesn't

mighty vector
#

why did u write:

terminate (missionNamespace getVariable ["pmces_restart_handle", scriptNull]);
whats the scriptNull? where is that initialized? its like a default param=nil?

isn't missionNamespace setVariable needed to make the script handle global?

pmces_restart_handle = _thisScript;

still forum
#

its default value, and its a null script

#

"isn't missionNamespace setVariable needed to make the script handle global?"
No. I told you that above. You don't need that

#

global variables and missionNamespace are the same thing

mighty vector
still forum
#

because syntax error

#

thats why not

mighty vector
#

f**k

#

ok...now, should I start crying now, here...in front of everyone...or can I go to the corner and cry alone?

still forum
#

no you should spend the time to read the wiki instead

mighty vector
still forum
#

The worst scripts I've seen so far are mostly people copy pasting stuff together, not knowing what they are even doing besides "uh, it just works"

mighty vector
#

its my second "working script"...and im afraid to QA the first

crimson walrus
#

Hi folks,
I'm trying to use createVehicleLocal to make a "#lightpoint", but have encountered trouble in multiplayer.
My script fails to make the light when hosting the mission on a dedicated server, but succeeds when hosting locally.
I use an addAction prior to creating the light, and the action consistently shows up in both situations, so I know it's not a locality issue with createVehicleLocal.
Google had some mention of the command being disabled for security reasons - any thoughts?

unique sundial
#

itโ€™s not disabled unless it is disabled by mission maker

cosmic lichen
crimson walrus
#

Sure thing, thanks. I'll double check that I'm not disabling it, too.

cosmic lichen
#
// executed using [_buyStationObject] remoteExec ["item_fnc_buyStationAddAction", 0, true];
 
private _buyStation = _this select 0;
 
_buyStation addAction
[
    "Open Buy Station",
    {
        [] spawn item_fnc_buyStationMenu;
    },
    nil,
    1.5,
    true,
    true,
    "",
    "true",
    6,
    false,
    "",
    ""
];
 
private _brightness = [16, 12, 10, 8, 6] select ((round (daytime - 12)) min 4);
private _light = "#lightpoint" createVehicleLocal (getPos _buyStation);
_light setLightBrightness _brightness;
_light setLightAmbient [0, 1, 0];
_light setLightColor [0, 1, 0];
_light setLightDayLight true;
_light setLightUseFlare false;
_light setLightFlareSize 0;
_light setLightFlareMaxDistance 0;
_light setLightAttenuation [1,6,6,0,0.25,1.75];
``` I'll just repost it here
#

@crimson walrus Check the pinned post to find out how to post code properly

crimson walrus
#

I'll also note that daytime is always between 12 and 24

cosmic lichen
#

Have you tried for testing with createVehicle?

crimson walrus
#

nope, thought lights had to be made locally. I'll give it a shot.

cosmic lichen
#

Basically, just remove all code and just try to make it appear, then go on from there. Could be something with the settings for the light.

crimson walrus
#

It does work fine when hosted locally

cosmic lichen
#

ah okay

#

The script is called where?

crimson walrus
#

[16, 12, 10, 8, 6] select ((round (daytime - 12)) min 4);
maybe daytime doesn't sync up fast enough with the client and this tries to select a negative number?

#

it's remoteexec'd once from the server

cosmic lichen
#

or is that light part of the create shop function?

unique sundial
#

do what R3vo said, createVehicle and see if it works

#

if it does but not with local version, please make a ticket and ping me with link

agile pumice
#

Can I get some help with this proof of concept? Its a simple scoreboard formatted as a hint.

private _headlessClients = entities "HeadlessClient_F";
private _humanPlayers = allPlayers - _headlessClients;
onEachFrame {
  {
    _playerName = name _x;
    _playerScore = _X getVariable ["score",0];
    _hintLine = format ["\n%1 - %2", _playerName, _playerScore];
  } forEach _humanPlayers;
  _hintArray = [];
  _hintArray pushBack _hintLine;
  hintSilent format _hintArray;
};

I know it won't work, obviously

#

for every player, I need a new line in the hint with the _hintLine = format ["\n%1 - %2", _playerName, _playerScore]; formatting

little raptor
agile pumice
#

how are you so good at this

little raptor
#

I'm not even sure if it works meowsweats

#

also, note that it is very slow

#

you shouldn't do it every frame

agile pumice
#

I'll do it every 5 seconds, just to avoid the fading effect

little raptor
#

does it work tho?

agile pumice
#

nah, syntax is iffy

#
19:23:00 Error in expression <%2", name _x, _X getVariable ["score",0]}) joinString toString [10]);
};
>
19:23:00   Error position: <}) joinString toString [10]);
};
>
19:23:00   Error Missing ]
#

working it out

little raptor
#

I left out a ] (format)

agile pumice
#
while {true} do {
  _headlessClients = entities "HeadlessClient_F";
  _humanPlayers = allPlayers - _headlessClients;
  hintSilent str ((_humanPlayers apply {format ["%1 - %2", name _x, _X getVariable ["score",0]]}) joinString (toString [10]));
  sleep 1;
};```
#

That's what I got to work

#

prob don't need the str

little raptor
#

no

agile pumice
#

but thank you for sharing your genius

little raptor
#

np

agile pumice
#

I'm looking for that wiki page with the fancy structured hints but I can't remember where I found it

little raptor
#

you mean hintC?
or just structured text?

agile pumice
#

not hintc

#

structured text

little raptor
agile pumice
#

I'm already there haha

#

already started whiping up some code

#

something like this?

#
_headlessClients = entities "HeadlessClient_F";
_humanPlayers = allPlayers - _headlessClients;
_separator = parseText "<br />--------------------------------------------------------------<br />"; 
_txt1 = text ((_humanPlayers apply {name _x) joinString (toString [10]));
_txt1 setAttributes ["align", "left"];
_txt2 = text ((_humanPlayers apply {_x getVariable ["score",0]}) joinString (toString [10]));
_txt2 setAttributes ["align", "right"];
_structuredText = composeText [text "Chickens Killed", _separator, _txt1, _txt2];
hintSilent _structuredText;
#

The name works, but the score shows any

crimson walrus
#

Thanks for the help

exotic tinsel
#

is there a way to detect if an object can take damage?

agile pumice
#

isDamageAllowed

#

@little raptor I don't fully understand what the purpose of joinString (toString [10])) is

little raptor
agile pumice
#

so that isn't going to work with the new revision

#

also it seems that enableEnvironment [false, true]; will also prevent new ambient life from spawning via script

agile pumice
#
while {true} do {
  _headlessClients = entities "HeadlessClient_F";
  _humanPlayers = allPlayers - _headlessClients;
  _separator = parseText "<br />--------------------------------------------------------------<br />";
  _composedTextArr = [text "Chickens Killed", _separator];
  {
    call compile format ['
      _txt1_%1 = text (name _x);
      _txt1_%1 setAttributes ["align", "left"];
      _txt2_%1 = text str (_x getVariable ["score",0]);
      _txt2_%1 setAttributes ["align", "right"];
      _composedTextArr append [_txt1_%1, _txt2_%1];'
      , netId _x
    ];
  } forEach _humanPlayers;
  _structuredText = composeText _composedTextArr;
  hintSilent _structuredText;
  sleep 1;
};```
copper raven
#

what's the point of the call compile format?

torpid palm
#

so dumb question, if i want to to call for all vehicles/weapons/gear for a store script how could i implement that?

hallow mortar
#

You could do a config dump, but it's a bit risky because config can have a lot of minor variants and hidden stuff that you might not want to put in your store

#

If you really don't want to manually make a list, you could try making an Arsenal with all the stuff you want, and then reference it using one of the getVirtualArsenal[stuff] functions

#

But making a deliberate and considered list, one item at a time, is probably the best way

spark turret
#

See pinnes messages for Dialog

tough abyss
#

Hello everyone! Hope everyone is having a great day. So I have a question and I am looking for someone who can help me solve this problem. I'm looking for maybe a mod or a unit randomization guide. Perhaps, as in the example, there is a rifleman who sometimes wears a hat, helmet, uses other weapons, ammunition, or other equipment.

spark turret
#

Use cba init eventhandler, then run a script that selects randomly from arrays of equipment

#

Thats how i do it.

mental prairie
#

How do I make an AI go to the nearest player in the 10 meter radius?

winter rose
#

1/ get the nearest player
2/ order to move
3/ ????
4/ profit ๐Ÿ˜Ž

#

which step is the issue? ๐Ÿ˜‰

mental prairie
#

I use the following code to get the nearest player position and move:

_nearestPlayer2 = _nearestPlayer select 0;
_ai moveTo [getPos _nearestplayer2];
winter rose
#

yes, but objects of type "player" do not exist; it must be a class ๐Ÿ˜‰

#

so it would be a near entities, filtered by a select { isPlayer _x } ๐Ÿ™‚

mental prairie
#

okay, so once I get a classname of entities, I filter them all by select { isPlayer _x }, and I'm good to go?

winter rose
#

yes
I recommend filtering by CAManBase, or usingโ€ฆ allPlayers select { _x distance _myObject < 10 }

mental prairie
#

In that case, I think I should replace nearestObjects with nearEntities

winter rose
#

or allPlayers?

#

it's a list of all players ๐Ÿ˜„

#

ah wait you want the nearest

#
private _closePlayers = allPlayers select { _x distance _theObject < 10 };
if (_closePlayers isEqualTo []) exitWith { hint "no one here"; };
hint "hey, someone here! getting the closest";
// filter by distance
// pick the first one (closest)
// move
mental prairie
#
_nearestPlayer = _nearestPlayer select { isPlayer _x }
_nearestPlayer = selectRandom _nearestPlayer
_ai moveTo [getPos _nearestplayer];``` What I came up with.
winter rose
#

don't forget to check if the list is not empty

mental prairie
#

okay. Thanks!

vague geode
#

Does anyone happen to know how exactly the allowFleeing-command operates? Like what does a cowardice-value of e.g. 0.25 actually mean? (Hopefully not that a quarter of the men is just going to run at first glance of an enemy...)

https://community.bistudio.com/wiki/allowFleeing

tough abyss
little raptor
#

at least that seems to have some effect

#

or it could be the aggregate percent of suppression for all team members

#

all I know is that the more suppressed and outnumbered a group is, the more likely they are to flee

cosmic lichen
#

The page explains it actually

#

If the group losses by injury/damage or death/destruction are higher than the max strength, multiplied by leader's courage or allowFleeing level , then the group will start fleeing.

#

So it's just a multiplier of some sort

clever radish
#

Does anyone know why Hardware3 setPos getPos HardWare3Pos2 works, but
GeneratorVillage setPos getPos GeneratorVillagePos1 does not? It says "Generic error in expresion"

cosmic lichen
#

Are all four objects?

clever radish
#

Yes

vague geode
# cosmic lichen The page explains it actually

Now it does because you added it one hour and 15 minutes after I asked the question.

But now I have a followup:

If the group losses by injury/damage or death/destruction are higher than the max strength, multiplied by leader's courage or allowFleeing level , then the group will start fleeing.

But if that's the case 0 should make them always flee and 1 should make them take a stand no matter what but according the old version of the page it exactly the other way around.

Also the the infantry's armour just their health?

PS: I would add the note from the old version of the page as well since it shows you which effect increasing/decreasing the value was.

clever radish
#

Could it be that GeneratorVillage has an object attached to it? (BIS_fnc_attachToRelative;)

little raptor
#

at least that's what the name says

#

also what is GeneratorVillage? we don't have a "village" object

cosmic lichen
#

Now it does because you added it one hour and 15 minutes after I asked the question.
Not really. There was a link in the desciption saying "More info here"

clever radish
cosmic lichen
#

what

little raptor
#

check what they are
execute:

[typeName GeneratorVillagePos1, typeName GeneratorVillage]

in debug console

#

then paste the result here

cosmic lichen
#

no var names in editor

clever radish
#

It is a CUP object, btw

cosmic lichen
#

yeah

#

bool ๐Ÿ˜„

#

That's a nice object

little raptor
#

then you see it yourself

#

they're not both objects

#

paste the attach code here

clever radish
#

The class name of the object is "PowGen_Big_EP1", but because I've got multiple of them I have set a variable name being "GeneratorVillage" It should work as I have done the same with Hardware3

cosmic lichen
#

but it doesn't as you see.

#

Just double check your var names. Nothing else we can do here

clever radish
#

I just tried in VR and it works. Every code being the same as well as the var names.. weird

clever radish
#

Found the problem. I had a trigger condition named GeneratorVillage. Thanks for the help

dusty whale
#

is there a way to force the player to freelook? can you simulate keypresses?

little raptor
#

nope

heady quiver
#

Hi guys how would i constantly check (or every 10 seconds) if [0] call BIS_fnc_countdown has reached 0.

#

I was thinking a EH but not sure if there is something like that.

cosmic lichen
#
waitUntil {sleep 10; ([0] call BIS_fnc_countdown == 0)};
little raptor
#

Why tho?

cosmic lichen
#

or

_serverTime = serverTime;
_countDown = 50;
waitUntil {sleep 10; _serverTime + _countDown >= serverTime};
little raptor
#

It is known when a countdown reaches 0

cosmic lichen
#

true

#

just sleep _countdown ๐Ÿ˜„

heady quiver
#

Because i am working on a secure area mission and once the timer reaches 0 i want the mission to be completed and all remaining AI to be removed.

#

or killed.

little raptor
#

The question is why check evry 10 seconds?

heady quiver
#

uhm

cosmic lichen
#

Just spawn a script and
sleep _countdown;
//Delete stuff

little raptor
#

When you know when the countdown ends

heady quiver
#

Because i want something like:

%1 seconds remaining.

#

so maybe every 30 seconds.

heady quiver
cosmic lichen
#

sleep 30;
hint "countdown is x seconds"
sleep 30;

#

...

little raptor
heady quiver
#

What are you thinking off leo?

little raptor
heady quiver
#

Uhm

#

That gonna be ugly if i need to check it 10 times lol

cosmic lichen
#

#loop

ember path
#

could i somehow display car stats, like an ai is driving a car and i as player need to know which parts of the car are red, or yellow

#

(this is a race mission and i wanna have car degradation in play, and you'd have to call the ai to the pitbox to repair the car and change wheels and so on, but the players need to know how the car is actually doing)

heady quiver
#

@cosmic lichen One problem the timer start when WEST unit steps in a trigger.

#

[300] call BIS_fnc_countDown;

cosmic lichen
#

get away from that countdown function

#

you don't need it.

heady quiver
#

oke ๐Ÿ˜ฆ

#
trg2 setTriggerStatements ["this", "
  'Enemies are moving into the area...' remoteExec ['systemChat'];
  [pos, 25] call spawnPatrolUnits;
  [300] call BIS_fnc_countDown; <-- Remove this for?
  deleteVehicle trg2;
", ""];
little raptor
ember path
#

oh god im gonna have to make a gui arent i..

little raptor
#

yes

#

if that's how you want to display it

ember path
#

softly fuck

little raptor
#

but why don't you use the ingame GUI?

#

the vehicle stats

ember path
#

yeah, like thats what i want

#

just be able to see that like..car stats you usually get but when youre outside of it..

#

do you know how to just use the ingame gui? or should i ask in #arma3_gui

heady quiver
#

@cosmic lichen can you please help my with it ๐Ÿ˜› ?

#
trg2 setTriggerStatements ["this", "
  'Enemies are moving into the area...' remoteExec ['systemChat'];
  [pos, 25] call spawnPatrolUnits;
  // Start timing for 5 minutes <---
  deleteVehicle trg2;
", ""];

๐Ÿค”

ember path
#

so wait you want it just to do a timer and when the timer runs out delete the thing?

heady quiver
#

When the timer runs out i will perform a couple of things yes.

ember path
#

sleep

heady quiver
#

can't do that

ember path
#

oh oka

little raptor
ember path
#

y

#

why cant....you do sleep?

heady quiver
#

Cuz i am in a setTriggerStatements

ember path
#

ok

#

huh.........well

little raptor
#

spawn

exotic flax
#

setTriggerStatements can handle sleep as well if you use spawn (except for condition of course)

heady quiver
#
        trg2 setTriggerStatements ["this", "
                    'Enemies are moving into the area...' remoteExec ['systemChat'];
                    [pos, 25] call spawnPatrolUnits;
                    null=[]spawn {
                        sleep 60;
                        '4 minutes remaining...' remoteExec ['systemChat'];
                        sleep 60;
                        '3 minutes remaining...' remoteExec ['systemChat'];
                        sleep 60;
                        '2 minutes remaining...' remoteExec ['systemChat'];
                        sleep 60;
                        '1 minute remaining...' remoteExec ['systemChat'];
                        sleep 60;
                        [player call BIS_fnc_taskCurrent, 'SUCCEEDED'] call BIS_fnc_taskSetState;
                        { player say2D 'cp_mission_accomplished_1'; } remoteExec ['call'];
                        'Mission Completed ($2500).' remoteExec ['systemChat'];
                        [2500] remoteExec ['updatePlayerMoney'];
                        deleteVehicle trg2;
                    };
        ", ""];
tough abyss
#

Is there a way to script a one time check of a players mods then let them join the server?

#

not sure which channel this question is most appropriate in

heady quiver
#

it works ๐Ÿ˜› ty

fair drum
tough abyss
#

hmmmm

#

okay I see the issue

#

cause this array would be massive

#

have to check against 100 addons but I only want it to run 1 time

#

_loadedMods = getLoadedModsInfo;

#

would this not work better?

ember path
#

i mean you can use keys right?

fair drum
#

yup, the array is massive lol. you could. I like activatedAddons when I have to pull out a specific addon, like ace medical.

tough abyss
#

I want to set up a whitelist for mods that might not be on the server

#

client side mods that are on my approved list

ember path
#

i see

fair drum
#

so an easy way to do that

#

is to just add the keys of the mods to the server, but not the actual mod itself

tough abyss
#

okay total noob at that lol

#

how does one add keys

fair drum
#

so if you look in the mod folder, there is usually a folder called keys

#

it is a bisign key

tough abyss
#

okay I follow

fair drum
#

that needs to go in the keys folder in the server root

tough abyss
#

ahhh okay

#

then set the server signatures to 2?

fair drum
#

yup

tough abyss
#

yea thats much easier XD

fair drum
#

the only mods that are forced are the ones that are loaded on the server. all other standalone keys allow mods that are optional

tough abyss
#

Thanks I appreciate that

#

and these keys they don't change if say the mod is updated?

fair drum
#

the activatedAddons method is for things like say... i make a mission with standard arma, but I want to make it compatible with ACE Medical, so I would have a fsm that changes the game state if ace_medical is in the activatedAddons array.

fair drum
tough abyss
#

Okay cool

#

That's easy tho

#

just drag and drop

dusty whale
#

is there a getRelPos but which takes a vector direction instead of compas direction?

winter rose
#

vectorFromTo?

dusty whale
#

i would use weaponDirection, but it's inaccurate ๐Ÿ˜“

#

so i have to play around a bit

#

is there an internal function in arma to find a point at distance along a given line or should i just calculate it myself?

winter rose
#

there is, but can't remember it

dusty whale
#

oh, damn

#

into the BIS-functions i go

#

oh cool, there's matrix multiply and transpose functions here

#

not what im looking for today, though

#

who needs timers when you have this

#

wait, does it just call a timer internally

#

i'll just call BIS_fnc_lerp on the 3 points

#

cant be asked to look deeper

#

never mind

dusty whale
#

[[0,0,0], [10,10,10], 1, 0.5] call BIS_fnc_interpolateVector

this gets you 5,5,5

winter rose
#

I usually multiply a normalised vector, does the job ^^

dusty whale
#

which is the middle point along that line

dusty whale
winter rose
#

you wanted a distance, here you have a percentage

dusty whale
#

that's true

#

but i know what the distance is

#

because i know the components

#

so i can figure out the appropriate percentage

#

but can i just multiply my position vector with the normalized direction vector

#

and get it that way

#

i love how some of the selection names are in middle-european gibberish and some are english

winter rose
#

-english +Western-European gibberish

dusty whale
#

debatable

winter rose
#

for the record, the language is Czech

dusty whale
#

i know

#

i'd say Czech Republic is smack right in the middle of europe

winter rose
#

yup

dusty whale
#

BIS_fnc_interpolateVector is inaccurate

#

๐Ÿ˜“

#

it ends up a bit below from where it's supposed to be

#

but only at longer distances

winter rose
#

of course, number precision

little raptor
dusty whale
#

oh, alright

dusty whale
little raptor
opal sand
#

Hey guys, im trying to play the executioner/victim kill animation (via trigger>radio delta), ('Acts_Executioner_Kill', ''Acts_ExecutionVictim_Kill')
but the executionerkill anim unit tries to holster his pistol first which ruins the timing of the two animations which should play at same time, Had tried 'this disableai anim' in the (executioner) units init field, to no avail/effect, how to fix?

dusty whale
#

Same issuer with vectorLinear

dusty whale
#

im not sure if my math is correct

#
arrow2 = "Sign_Arrow_F" createVehicle [0,0,0];
addMissionEventHandler ["Draw3D",{
    private _end = [0,0,0];
    private _ins = lineIntersectsSurfaces [
            AGLToASL positionCameraToWorld [0,0,0], 
            AGLToASL positionCameraToWorld [0,0,viewDistance], 
            player,
            vehicle player,
            True,
            1,
            "FIRE"
            ];
    private _start = vehicle player modelToWorld (vehicle player selectionPosition ["konec hlavne", "memory"]);
    if (count _ins > 0) then {
            _end = ASLToAGL(_ins select 0 select 0);
        } else {
            _end = positionCameraToWorld [0,0,viewDistance];
        };
    drawLine3D[_start, _end, [1,0,0,1]];
    
    private _perc = 100/(_start distance _end);
    
    private _pos = vectorLinearConversion [0,1,_perc,_start,_end,True];
    
    arrow2 setPos (_pos);
    
    hintSilent str(_pos);
    
}];```
#

the arrow should be along the line, but it isnt

#

this is done with a smaller

#

look at a hillside and see the arrow go and do its own thing

little raptor
#

getPos

#

position

#

visualPosition

#

getPosVisual

misty niche
#

noob question here, if i want to run this code in debug consul in game, what should i change? assuming i have named one object of the target group as A.
_localityChanged = _someGroup setGroupOwner (owner _playerObject);

dusty whale
little raptor
#

anything but setPos

#

whichever you're most comfortable with

#

I personally recommend ASL

dusty whale
#

makes no difference (ofcourse converting the AGL coordinates to ASL)

#

also, why not use these commands?

little raptor
#

they use AGLS format

#

which simply put are not convertible or compatible with any other command

#

they should be used in special places

dusty whale
#

roger

#

anyway, even with converting the AGL to ASL and using setPosASL, it fails the same way

#

the arrow is not at the path of the line

#

the coordinates get scewed by vectorLinearConversion

#

i'll try flipping some numbers around

#

๐Ÿ˜“

little raptor
dusty whale
#

unimportant

#

it doesnt actually change the accuracy of the result

#

it's what i use as the percentage distance

little raptor
#

try this:

arrow2 = "Sign_Arrow_F" createVehicle [0,0,0];
addMissionEventHandler ["Draw3D",{
    _p1 = eyePos player;
    _p2 = AGLToASL positionCameraToWorld [0,0,1000];
    private _ins = lineIntersectsSurfaces [
            _p1, 
            _p2, 
            player,
            vehicle player,
            True,
            1,
            "FIRE"
            ];
    // private _start = vehicle player modelToWorld (vehicle player selectionPosition ["konec hlavne", "memory"]);
    if (count _ins > 0) then { _p2 = _ins # 0 # 0;};
    drawLine3D[ASLToAGL _p1,ASLToAGL  _p2, [1,0,0,1]];
    
    private _perc = 100/(_p1 distance _p2);
    
    private _pos = vectorLinearConversion [0,1,_perc,_p1,_p2,True];
    
    arrow2 setPosASL (_pos);
    
    hintSilent str(_pos);
    
}];
#

in other words, it's drawLine3D that's causing the "error"

#

not vectorLinearConversion

dusty whale
#

what?

#

no it's not

dusty whale
#

demonstrate to yourself by doing drawline3d to end and _pos

#

those lines should not diverge

#

but they do

little raptor
#

they don't

#

as I told you it's just a visual error

dusty whale
#

they do diverge

#

trust me

#

i can send you the math

#

independent of arma 3

#

your p1 is wrong

#

it NEEDS to be the muzzle of the vehicle

little raptor
dusty whale
#

not the eye position of the player

little raptor
#

that's the proper way to test divergence

#

which doesn't happen

dusty whale
#

youre using wrong values

#

the starting position of the vectorLinearConversion is the muzzle of the vehicle not the eye position of the player

#

private _start = vehicle player modelToWorld (vehicle player selectionPosition ["konec hlavne", "memory"]);

little raptor
dusty whale
#

my code says that the start is the muzzle position of the vehicle

little raptor
#

yeah forget that code I sent you

#

it was just to show you it's a visual error

dusty whale
#

it's not a visual error

little raptor
dusty whale
#

i have another arrow being set at the _end location

#

and the ray from the muzzle goes directly to the root of the arrow

little raptor
#

do you check that visually?

dusty whale
#

so it's not a visual error

little raptor
#

with your eye?

#

or with math?

dusty whale
#

listen to the end, please

little raptor
#

I did listen

#

but you're checking it visually

dusty whale
#

then i set the second arrow to the position give by the vector conversion

#

then i draw a line to the location of the vector conversion from the same starting position

#

and the lines diverge

#

i should be seeing 1 line

#

but im seeing 2

#

VERY clearly 2

little raptor
#

again, don't check visually

dusty whale
#

further evidence is the muzzle device of the vehicle

#

i have another script set a target at the position of the arrow

little raptor
#

send me the code

dusty whale
#

the 2nd arrow

#

the one with the diverging lines?

little raptor
#

i'll prove to you it won't diverge

little raptor
dusty whale
# little raptor yes
arrow2 = "Sign_Arrow_F" createVehicle [0,0,0]; 
arrow3 = "Sign_Arrow_F" createVehicle [0,0,0]; 
addMissionEventHandler ["Draw3D",{ 
 private _end = [0,0,0]; 
 private _ins = lineIntersectsSurfaces [ 
   AGLToASL positionCameraToWorld [0,0,0],  
   AGLToASL positionCameraToWorld [0,0,viewDistance],  
   player, 
   vehicle player, 
   True, 
   1, 
   "FIRE" 
   ]; 
 private _start = vehicle player modelToWorld (vehicle player selectionPosition ["konec hlavne", "memory"]); 
 if (count _ins > 0) then { 
   _end = ASLToAGL (_ins select 0 select 0); 
  } else { 
   _end = positionCameraToWorld [0,0,viewDistance]; 
  }; 
 drawLine3D[_start, _end, [1,0,0,1]]; 
  
 private _perc = 100/(_start distance _end); 
  
 private _pos = AGLToASL(vectorLinearConversion [0,1,_perc,_start,_end,True]); 
  
 arrow2 setPosASL  _pos; 
 arrow3 setPosASL AGLToASL _end; 
 drawLine3D[_start, ASLToAGL _pos, [1,0,0,1]]; 
  
 hintSilent str(_pos); 
  
}];```
little raptor
#

it'll be 1

#

therefore no divergence

dusty whale
#

that still doesnt change the fact that the arrow nor the line is along the start-end line

little raptor
#

that's how you see it

#

but they are aligned

dusty whale
#

but they are not

#

that much is obvious

#

look at the picture

#

you cant credit that much divergence to a "visual error"

little raptor
#

do you want them to be aligned visually?

#

or mathematically?

#

what is your end goal?

dusty whale
#

i want the red arrow to be along the path of the start-end line

#

currently it is not

#

hold on

#

i'll post an exhibit video

#

so that you can see the issue

#

here you go

little raptor
dusty whale
#

you see how the target strays from the line when the line extends too far

#

yes, it is the same code

#

want me to walk it all the way from main menu?

little raptor
#

no

dusty whale
#

desktop?

#

is the floating point accuracy of vectorLinearConversion poor?

dusty whale
#

yeah, youre right

#

it's elevation that breaks it

#

so there must be one of the aslagl conversions

#

that im not doing right

#

but im not sure which one

little raptor
#

it's not that either

dusty whale
#

really?

little raptor
#

it's probably positionCameraToWorld

dusty whale
#

no, it's not

#

positionCameraToWorld is only used to find _end

#

both the _pos and _end lines use the same position

#

so it wouldnt matter what positionCameraToWorld gives

#

they use the same value

#

positionCameraToWorld can be whatever

#

because vectorLinearConversion and the non-linear conversion lines both use the same _end

#

so it wouldnt make a difference

#

even if the error was in positionCameraToWorld

#

which it isnt

robust tiger
#

are they in the same vertical plane or not, it's really hard to see

dusty whale
#

theyre not

robust tiger
#

couldn't you just cut the _start to _end vector and use that?