#arma3_scripting

1 messages ยท Page 352 of 1

rotund cypress
#

Local variable can only be accessed in the scope it's initalized in and it's child scopes. If you wanna do a local variable you do an underscore

#

before the variable name, like this: _hello = "hello"

#

Instead of hello = "hello"

indigo snow
#

In his case it would be the name of a unit, most likely though

tame portal
#

I think it's SUPER unconvenient that the variable he uses is called ain this case and you're saying things like "a variable" ๐Ÿ˜„

rotund cypress
#

^

astral tendon
#

yes is the name of the unit

#

i already rename they

rotund cypress
#

@tame portal ๐Ÿ˜‚ ๐Ÿ˜‚ ๐Ÿ˜‚ ๐Ÿ˜‚ ๐Ÿ˜‚ ๐Ÿ˜‚

astral tendon
#

there are 4 rifleman

#

they are named player1 player2 player3 player4

rotund cypress
#

Do you need to access them globally in any function?

#

If the answer is no, then add an underscore before the name

indigo snow
#

My dude simzor no

#

No

little eagle
#

Surely no one else will use the name "a" and will cause a collision.

tame portal
#

Give it a unique tag

#

a_a

little eagle
#

I'm laughing.

tame portal
#

Alright alright I'll stop ๐Ÿ˜„

little eagle
#

my god

#

๐Ÿ˜‚

indigo snow
#

Those are the names he gave to the unit under attributes. You dont put underscores there.

rotund cypress
#

Oh what, in editor?

#

Then yeah, no

astral tendon
#

yup, editor

rotund cypress
#

Okay, then don't put an underscore ๐Ÿ˜„

indigo snow
#

This is Roques first foray into sqf, stuff is basic still :P

tame portal
#

@little eagle I can't do these jokes because I'll get banned, you're just gonna get a rank removed ๐Ÿ˜„

rotund cypress
#

Get banned for an innocent joke? ๐Ÿ˜ญ

indigo snow
#

Banned for using underscores wrongly

little eagle
#

I elevate the quality of this chat with it.

astral tendon
#

yup, im a noob

indigo snow
#

Its cool

astral tendon
#

im doint this as a love letter for another game

rotund cypress
#

U wot? @astral tendon

astral tendon
#

im recreating a mission the Delta Force black hawk down game

north vortex
#

Hello

peak plover
#

hey

#

Have you seen anything?

north vortex
#

Yes it says hello i say hello back

#

Oh shoot

#

Whoops

peak plover
#

Yes, I saw, enemy man, 500m east, just now

astral tendon
#

i wanna set a trigger to detect exac 4 players not only one

#

any idea?

#

or better say, a group of blurfor

peak plover
#

inAreaArray

polar folio
#

any way to move a control to the front? other than recreating it

peak plover
#

_backgroundCtrl ctrlEnable false;

#

_foregroundCtrl ctrlEnable true;

astral tendon
#

inAreaArray wiki does not talk about group

peak plover
#
_inAreaUnits = ((units group1) inAreaArray trigger1)

if (count _inAreaUnits >= 4) then {
    systemChat ' there are atleast 4 dudes from group 1 in trigger1';
};
#

use units to get an array of units inside a group

#

count to count them

astral tendon
#

there is a size limit to the triggers work?

peak plover
#

I have no clue what that means

astral tendon
#

the are size of the triggers

peak plover
#

the are size of the triggers

I am unable to authenticate a question...
Is that a statement?

astral tendon
#

area

#

now i smash my A button

peak plover
#

Triggers do not have a size limit. They can be 10m X 10m or 100km x 100km

astral tendon
#

if (isNull gunner _x) count [car1, car2, car3, car4];

#

this is a condition to a trigger

#

i wanna trigger when all those 4 vehicles have gunners

waxen tide
#

This works perfectly fine if i host locally, but on dedicated the _carrier vehicle isn't spawned.

#

the _sonicboom ones work just fine

robust hollow
#
{isNull gunner _x} count [car1, car2, car3, car4] == 0```
thats what it should be roque
astral tendon
#

Thanks Connor, it worked

#

triggerActivation [move1, move2, move3, move4];

#

i wanna this to be activated by a trigger to set off other triggers

#

but its gives a error expecting a object

robust hollow
astral tendon
#

i have a verry strange problem

#

the AI dones not move if they dont have a Player gunner

#

if i swap slots the car will move

#

but if i am not in the car they will not follow their setDriveOnPath

rancid ruin
#

maybe something to do with ranks? are you their leader or something?

astral tendon
#

they are alone in the squad

#

so they are their only leader

rancid ruin
#

hmmm have you checked their family trees?

#

maybe one of them was wed to another king in a secret ceremony

astral tendon
#

this is how it is set up

waxen tide
#

how can this be any different? i create a local vehicle, why does it care about multiplayer editor vs dedicated? jeez

peak plover
#

anyone know macros?

#

#define DESCFIND(var)        ((_roleDesc find (toLower var))> -1)
if DESCFIND("recon") exitWith {

waxen tide
waxen tide
#

._.

peak plover
#

Post problem, tag commy

#

works 7 times out of 10

#

I think there were a few a couple of days ago ๐Ÿ˜•

waxen tide
#

i'm on the border to insanity. mission works flawlessly on locally hosted dedicated, weird shit happening on remote dedicated. suddenly pictures not found that work despite not being found? objects spawning 100m under water that spawned at perfectly good height? jeez.

peak plover
#

๐Ÿค”

waxen tide
#

well

#

i got one picture.

#

ONE.

#

its in the mission root

#

??????????????

#

i mean c'mon.

peak plover
#

So loading screen does not work?

#

But does it work in single player/

#

or local dedi?

waxen tide
#

well it does work. is displayed perfectly fine. still "error: loading.jpg not found"

#

it works in SP, local dedi, but not remote dedi

peak plover
#

path might be bad

waxen tide
#

remote is linux, local is windows.

#

path? its in root.

peak plover
#

ohh

#

ohh

waxen tide
#

besides, it is being displayed just fine.

peak plover
#

maybe path is case sensitive

#

linux does not like

waxen tide
#

yeah i lowercase everything.

peak plover
#

odd

#

have you tried on windows server/

waxen tide
#

and i don't get the error consistently, it pops up every other time

#

yeah works on win

#

thats not the weirdest stuff to, my aircraft carrier turns into a submarine on the dedi.

#

spawns under water no matter what. i'm on it for hours now, just doesn't want to spawn above the water line.

astral tendon
#

is there a script to increse the vehicle turret speed?

waxen tide
#

mkay so i logged the carriers position basically each frame and compared the outputs locally and remote, the position is supposedly identical. so my carrier is invisible? great.

peak plover
#
_unit setSkill ['aimingSpeed',1];

@astral tendon
If ai, this might work.

astral tendon
#

this is to work with players too

peak plover
#

no

#

You'd probably have to make a mod for that

waxen tide
#
_pos1 = ((getPosATL player) vectorAdd [300,0,200]);
_pos2 = ((getPosATL player) vectorAdd [0,300,200]);
_carrier1 = createVehicle  ["Land_Carrier_01_base_F",_pos1,[],0,"CAN_COLLIDE"];
_carrier1 setPosATL _pos1;
_carrier2 = "Land_Carrier_01_base_F" createVehicleLocal _pos2;
_carrier2 setPosATL _pos2;
#

can someone explain that to me?

#

seems like setPos has zero effect on local vehicles?

#

ahh no, it is just the carrier.

#
_pos1 = ((getPosATL player) vectorAdd [300,0,200]);
_pos2 = ((getPosATL player) vectorAdd [0,300,200]);
_carrier1 = createVehicle  ["Land_LightHouse_F",_pos1,[],0,"CAN_COLLIDE"];
_carrier1 setPosATL _pos1;
_carrier2 = "Land_LightHouse_F" createVehicleLocal _pos2;
_carrier2 setPosATL _pos2;
#

mmhm okay [_carrier1] call BIS_fnc_Carrier01PosUpdate; fixes it.

#

nice 6 hours spend.

#

still, there is a difference between createVehicleLocal and createVehicle when it comes to the freedom, and somehow it is also treated differently in MP.

#

doesn't help. BIS_fnc_Carrier01PosUpdate doesn't work in dedicated MP environment when used with createvehiclelocal apparently.

robust hollow
#

just to confirm, you executed BIS_fnc_Carrier01PosUpdate from the server right (in MP)?

waxen tide
#

no.

#

i'm creating a local vehicle? it isn't transfered over network? the server shouldn't know about it?

robust hollow
#

thats why i ask. BIS_fnc_Carrier01PosUpdate MUST be run on the server. You could try duplicating the function but without the isserver check at the start if you havent sorted it out already.

waxen tide
#

._.

#

thanks.

#

i've just realised i can loop up the functions content

waxen tide
#

i've duplicated the function and removed the server check. it's being executed alright but it is not doing its job

#

or, well, maybe it is but the carrier is still invisible

astral tendon
#

is there a comand to change AI to stop following the road?

peak plover
#

aware/safe make ai drive on road

astral tendon
#

thanks

#

the setDriveOnPath also get roatation?

peak plover
#

no

astral tendon
#

setBehaviour only works to goups?

peak plover
#

no, it also works on units, but affects the whole group anyway

astral tendon
#

for some reason my AI driver is struguling to get on a new possition i made in the middle of the road

#

he keeps going back and foward

peak plover
#

hmm

#

Could be anything

astral tendon
#

i just added a extra point

peak plover
#

Did that fix it?

astral tendon
#

no

#

i mean i added a extra point

#

and he just cant get in there

#

he just go with the car back and foward

peak plover
#

stuck ๐Ÿ˜•

subtle ore
#

quick question here, (entities "Air") doesn't return anything, _forEachIndex returns zero every single time:

#

jesus, letme pastebin this shit

peak plover
#

(vehicles )

#

entities

subtle ore
#

Ohhh ๐Ÿค”

astral tendon
#

what is the command to cancel the setDriveOnPath?

peak plover
#

you gotta do a type check in the loop

#

doStop ?

subtle ore
#

Yep, I did a _x isKindOf 'Air' Still nothing, this is hilarious.

subtle ore
#

OH DUH , Damn it all to hell. I gave it a unit variable on accident

peak plover
#

works on my machine

#

s๐Ÿ˜ด

subtle ore
#

Yeah, I think I've got it down now. Lol.

peak plover
#

More coffee or more sleep ๐Ÿ˜„

#

โ˜• โ˜• โ˜• โ˜•

subtle ore
#

Had two pots already! ๐Ÿ˜›

peak plover
#

Are you smoking indica? that shit makes you slow...

subtle ore
#

Not a smoker, that shit is bad for you.

peak plover
#

exactly

#

Stupid, Why would you want to be slow?

subtle ore
#

Who knows ๐Ÿคท

peak plover
#

scripts would never be finished...

#

Do you know macro?

subtle ore
#

macro....?

peak plover
#

Macros in preprocessor?

subtle ore
#

can't say I do.

indigo snow
#

This almost sounda like a setup for a bad ding dong, whos there? Joke

#

Macro who?

subtle ore
#

hahaha, sure enough.

astral tendon
#

i tink i got it

#

its looks like its mandatory to setDriveOnPath have two possitions

#

otherwise the unit will not move

subtle ore
#

I would only hope so.

astral tendon
#

car1 setDriveOnPath [[3690.78,11090.7,0],[3690.78,11091.7,0]];

#

i just edit one number and it worked

indigo snow
#

A path is a line segment, and a line segment needs at least two elements

#

But youre just doing this fornthe car to drive to that location? Other commands might work better for you

subtle ore
#

like I said earlier : doMove

peak plover
#

oh my god, I still stuck at macros

subtle ore
#

๐Ÿค”

peak plover
#

#define IFDO(var1,var2)        if (!isnil {var1} && {!(var1 isEqualTo "")}) then {var2};
#define IFDOT(var1,var2)    IFDO(var1,_target var2 var1)
#define OVERLOAD(var1)        systemChat format ["%1's inventory has been overloaded by %2!",(typeOf _target),var1];
#define ADDITEMUNI(var1)    if !(_target canAddItemToUniform var1) then {OVERLOAD(var1)};_target addItemToUniform var1;
#define ADDITEMVEST(var1)    if (_target canAddItemToVest var1) then {_target addItemToVest var1}else{ADDITEMUNI(var1)};
#define ADDITEMBACK(var1)    if (_target canAddItemToBackpack var1) then {_target addItemToBackpack var1}else{ADDITEMVEST(var1)};
#define IFLIST(var1,var2)    if (var1 isEqualType []) then {private _nil = {for _i from 0 to (_x select 1) do {IFDO(_x select 0,var2)};false} count var1}else{IFDO(var1,var2)};
#define IFARR(var1,var2)    if (!isNil {var1} && {var1 isEqualType []}) then {private _nil = { IFDO(_x,var2) false} count var1;};
// Code begins

IFDOT(_uniform,forceAddUniform)
IFDOT(_vest,addVest)
IFDOT(_backPack,addBackpack)
IFDOT(_helmet,addHeadgear)
IFDOT(_goggles,addGoggles)
IFARR(_commonItems,linkItem)
IFARR(_commonMedicalItems,ADDITEMBACK(_x))
IFARR(_commonExtraItems,ADDITEMBACK(_x))
#

help

subtle ore
#

Hey, that's better than what I would've done. high five

peak plover
#

This is definately not how to macro, but, how do you macro?

#

I've read the documentation, but I lack the ability to macro

#

Tbh, it's quite useless macro and makes things unreadable, BUT, saved me ~10 lines of repeating code

#

phew

rancid ruin
#

why not just use functions? macros like that are so fkn unreadable it's not worth it

subtle ore
#

Isn't the mentality -> If you repeat the code - > Function it

rancid ruin
#

i dunno my but mentality is readability above all else

subtle ore
#

readability is good for when you are sharing or looking back at code later on. But final product is performance imo

#

does this look correct?

if(count(crew(_this select 0)) < 2 && (_this select 1) isEqualTo "driver") then {
        (_this select 0) animateSource["DoorL_BackOpen",0];
        (_this select 0) animateSource["DoorR_BackOpen",0];
    };
#

this is placed in a getIn event handler, back door won't close.

indigo snow
#

Whats _this select 1 look like exactly

#

Might be "Driver"

#

Then IsEqTo fails

subtle ore
#

position that was entered in as, returns a string. it's all lowercase on the biki

indigo snow
#

Yes but can you check? Even just a diag_log of _this

subtle ore
#

yeah, one sec.

#

yep, returns "driver"

#

I'm just gonna pastebin the entire thing

peak plover
#

But that is a function

#

it's a function in a function in a function.... Didn't wanna go any deeper

subtle ore
#

The mind just doesn't understand the depth of it all! ๐Ÿ˜›

peak plover
#

fnc_commonCode used in fnc_defaultCode used in fnc_unit ( can be used anywhere) but used on postInit

subtle ore
#

yep postInit = 1;

peak plover
#

What's the change scope command called?

daring pawn
#

Lads i'm struggling a little bit to find the position in an array of a nested array if I only know certain info.

For example my array is

[ ["Cache_1",["Box_FIA_Wps_F",[2033.22,3448.04,63.1198]]],["Cache_2",["Box_FIA_Wps_F",[546.874,3248.17,39.8989]]] ]

How i'm struggling using examples from KK and one from Zeno's framework to search my array for that and return 0 or 1 for the array position that its in

peak plover
#
_array = [ ["Cache_1",["Box_FIA_Wps_F",[2033.22,3448.04,63.1198]]],["Cache_2",["Box_FIA_Wps_F",[546.874,3248.17,39.8989]]] ];
_target = "Cache_1";
_found = _array select {(_x param [0]) isEqualTo _target;};//edit extra parenthesis //edit2 CAUTION case sensitive
_found = param [0];// because it's [["cache-1"...
_found params ["_name","_class","_pos"];

Maybe?๐Ÿค”

#

Also you can make array (slightly) readable

#
_array = [ 
    ["Cache_1",["Box_FIA_Wps_F",[2033.22,3448.04,63.1198]]],
    ["Cache_2",["Box_FIA_Wps_F",[546.874,3248.17,39.8989]]]
];
daring pawn
#

Oh yea that was just copying into discord. I'll give that a spin, its simmilar to what i've got at the minute.

peak plover
#

If in trouble put

systemChat str _target;
systemChat str _found;

between the lines

daring pawn
#

So hold up, _found is returning "Cache_1" so what i'm after hopefully is to return 0 as the array ["",["",[]]] is element 1

#

Unless i've goofed

#

Reason being btw, so it doesn't sound crazy, is the array is actually created each session, its not set. So it'll create that array with the positions of those box's

peak plover
#

// Get task list from profile
_taskList = ["mission_tasks_list",[]] call seed_fnc_getVars;

// check if task already excists and quit if it does
private _matchedTask = (_taskList select {(_x param [0]) isEqualTo _taskVar}) param [0,""];
if !(_matchedTask isEqualTo "") exitWith {systemChat 'tasks_fnc_add task already exists'};

Works on my machine โ„ข ๐Ÿคท

daring pawn
#

That checks if "mission_tasks_list" is at element 0 though right?

peak plover
#
_taskList = [["blu_task1",[WEST,["blu_task1"],["Liberate the town by any means.","LIBERATE TOWN"],town_3,"Attack","CREATED"],1,[{true},{false},{false}],[{},{},{}],"added"]]
#

blu_task1 is the unique taskID

#

_x param [0] means it will get the first (0) element of the array

#

because it's select { /*code*/} it will loop through all elements of _taskList;

#
_x = ["blu_task1",[WEST,["blu_task1"],["Liberate the town by any means.","LIBERATE TOWN"],town_3,"Attack","CREATED"],1,[{true},{false},{false}],[{},{},{}],"added"]```
#
_x param [0] /*"blu_task1"*/ isEqualtTo _taskVar /*"blu_task_1"*/ // true, so it returns it
daring pawn
#

_found in your first example. It should return a number is that correct?

peak plover
#
_array = [ ["Cache_1",["Box_FIA_Wps_F",[2033.22,3448.04,63.1198]]],["Cache_2",["Box_FIA_Wps_F",[546.874,3248.17,39.8989]]] ];
_target = "Cache_1";
systemChat str _array;
_found = _array select {(_x param [0]) isEqualTo _target;};
systemChat str _found;
_found = param [0];
_found params ["_name","_class","_pos"];
systemChat str _name;
#

try

#

wait a second...

daring pawn
#

returns that ๐Ÿ˜›

peak plover
#
_array = [ ["Cache_1",["Box_FIA_Wps_F",[2033.22,3448.04,63.1198]]],["Cache_2",["Box_FIA_Wps_F",[546.874,3248.17,39.8989]]] ];
_target = "Cache_1";
systemChat str _array;
_found = _array select {(_x param [0]) isEqualTo _target;};
systemChat str _found;
_found = _found param [0];
_found params ["_name","_class","_pos"];
systemChat str _name;
#

lmao

#

_found = param [0] < false
_found = _found param [0] < correct

daring pawn
peak plover
#

That's the correct return, what did you want to return anyway?

daring pawn
#

Well in the case of Cache_1 I want it to return 0 or in Cache_2 1 or Cache_3 2 as its the element number in the array

peak plover
#

ugh, why?

daring pawn
#

unless i'm missing something for now deleting that element with what you've given

peak plover
#

aah

#

in that case

#
_array = [ ["Cache_1",["Box_FIA_Wps_F",[2033.22,3448.04,63.1198]]],["Cache_2",["Box_FIA_Wps_F",[546.874,3248.17,39.8989]]] ];
_target = "Cache_1";
systemChat str _array;
_newArray = _array select {!((_x param [0]) isEqualTo _target)}; // added ! so it only returns the ones that don't have cache_1
#

_newArray should now only contain cache2

daring pawn
#

Oh wow yea thats perfect and works in the situation i'm using it in. Outstanding, never would have thought of that. Super appreciate it

little eagle
#

Should use a namespace and not an array.

#
myTag_CacheNamespace setVariable ["Cache_1",["Box_FIA_Wps_F",[2033.22,3448.04,63.1198]]];
myTag_CacheNamespace setVariable ["Cache_2",["Box_FIA_Wps_F",[546.874,3248.17,39.8989]]];

myTag_CacheNamespace getVariable "Cache_2";
#

Depends on how big it gets I guess.

peak plover
#

namespace?

#

like a game logic?

little eagle
#

I'd use a LOCATION for this.

peak plover
#

I'd use profilenamespace, because it would be nice to have persistance ๐Ÿ˜‰

daring pawn
#

It is persistent yea, i'm not using profileNameSpace though, i'm using INIDBI2 to save to

#

I'm saving just the array

little eagle
#

How big it gets?

daring pawn
#

Depends on map size. Wouldn't be anywhere more that probably 30 odd

#

I'm on Aliabad which is 5x5 from memory. SO theres a fair few grid squares (similar to Insurgency grid squares or MSO ones) and it bases how many to make off the amount of enemy squares

little eagle
#

Are they all named Cache_N ?

daring pawn
#

PMF_Cache_N yea

#
    _cz = ceil ((count PMF_Zones) / 16);
    for [{_i=1},{_i<6},{_i=_i+1}] do {

It gets its number from the above

little eagle
#

Maybe you don't even need the name then, because it's implicit.

daring pawn
#

I did think of that, but if say, I go "PMF_Cache_6" is element 5. The others then, the numbers remain so they aren't the same anymore

#

so i delete element 5. Element 5 then is PMF_Cache_7

#

And I didn't think it was ideal to then rename each of them and resave the array with their new names

#
_cnt = count PMF_Caches;
if (_cnt == 0) then {
    _cz = ceil ((count PMF_Zones) / 16);
    for [{_i=1},{_i<6},{_i=_i+1}] do {
        if (markerColor _mkr == "ColorBLUFOR") exitwith {};
        _CacheZone = selectRandom PMF_Zones;
        _cacheZoneMarker = str(_CacheZone);
        _gridHouses = [(getMarkerPos _cacheZoneMarker),50,2,true] call findHouses;
        _cacheHouse = _gridHouses select 0;
        _housePositions = _cacheHouse buildingPos -1;
        _cachePosition = _housePositions call BIS_FNC_SelectRandom;
        _cacheType = ["Box_FIA_Ammo_F","Box_FIA_Support_F","Box_FIA_Wps_F"] call BIS_FNC_SelectRandom;
        _cache = _cacheType createVehicle _cachePosition;
        _cacheName = format ["PMF_Cache_%1",_i];
        _cache setVehicleVarName _cacheName;
        _cachePosition = getPosASL _cache;
        PMF_Caches pushBackUnique [_cacheName,[_cacheType,_cachePosition]];
        publicVariable "PMF_Caches";

        //Save array to INIDBI2
        ["write",["PMF","PMF_Zones_Caches",PMF_Caches]] call PMF_DB_Zones;

        _cache addEventHandler ["killed",{[_this select 0] remoteExecCall ["cacheFromDB",2];}];
    };

Thats the code for spawning the crates for the first time if theres none saved

#

Its a bit sketchy but it works until I clean it up a bit

little eagle
#
_cacheType = selectRandom ["Box_FIA_Ammo_F","Box_FIA_Support_F","Box_FIA_Wps_F"];
#

They have this ^ now

daring pawn
#

Any performance difference? I'll change it now though

#

I guess its engine not function so should be faster

little eagle
#

Command is always better than function.

#

And it looks better for sure.

#

setVehicleVarName has local effects, dunno if that's an issue.

daring pawn
#

Its serverside so shouldn't matter

#

Players only interaction with it is when they shoot the box and it is destroyed, but thats also a server eventhandler so It shouldn't cause strife

#

Whilst its kinda messy, i'm happy with what i've managed so far really. Its pretty fun i think anyway the mission

#

Getting stuck on some specific things but this channel bails me out. I feel like I've asked too many questions

little eagle
#
_cache addEventHandler ["killed",{[_this select 0] remoteExecCall ["cacheFromDB",2];}];

^ This seems weird to me. You add an eventhandler on the server and it sends a function call to the server?

#
_cache addEventHandler ["killed",{[_this select 0] call cacheFromDB}];

???

daring pawn
#

Yea that was some confusion. If a player blows the crate up, whether its the player calling the eventHandler or the box

little eagle
#

The killed eventhandler is fired on the machine that owns the box.

#

Not the shooter.

#

And even if it were the shooter, it would never fire on a client.

#

Because addEventHandler itself has local effects.

#

And is only executed on the server.

#

If it were an object witch changing locality, i.e. a car

#

Where the locality is transferred to the driver

#

Then this wouldn't work anymore if someones enters as driver.

daring pawn
#

Yea i've added to the player getInMan and getOutMan eventhandlers to save vehicle positions

little eagle
#

GetIn(Man) is a bit different in that it also fires for remote objects, but also only if the eventhandler was added on the local machine.

#

Killed is more strict.

rancid ruin
#

but what if a vehicle is moved after it has no passengers any more?

daring pawn
#

So, the vehicle only saves when a player gets out from the driver seat

#

When they get in, its removed

#

then added when they hop out

#

rather than updating as it moves

rancid ruin
#

not an ideal solution to the problem

little eagle
#

Why not?

rancid ruin
#

you can move vehicles by means other than driving them

little eagle
#

Slingload? How else you move a vehicle

daring pawn
#

Its something the lads playing on the mission are aware of. We don't use helicopters currently so its not something that crossed my mind.

rancid ruin
#

crash in to it with another vehicle, slingload, getting arma'd...

#

rolling down a hill

little eagle
#

It's good if getting thrown away with 15000 km/h thanks to PhysX by NVidia doesn't update the logged position.

daring pawn
#

I've rarely seen vehicles roll down hills without a driver

little eagle
#

They can't. PhysX "Handbrake" is always on.

daring pawn
#

Again, even still, if a player parks like a spud and it moves, they're likely to get back in and correct it anyway

rancid ruin
#

you're definitely both wrong on this one i'm afraid

daring pawn
#

Other than helicopters maybe sliding down a hill if a pilot ejects on a slope

#

Cars/tanks won't slide/roll down a hill without someone in it afaik

little eagle
#

Yes.

daring pawn
#

Oh and boats can move after a player hops out

rancid ruin
#

you are too trusting of this engine ๐Ÿ˜„

daring pawn
peak plover
#

#define ADDITEM(var1)\
    call {\
        if (_target canAddItemToBackpack var1) exitWith {_target addItemToBackpack var1};\
        if (_target canAddItemToVest var1) exitWith {_target addItemToVest var1};\
        if !(_target canAddItemToUniform var1) then {OVERLOAD(var1)};_target addItemToUniform var1;\
    };\
#define IFDOT(var1,var2)    _target var2 var1
#define IFDO(var1,var2)        if (!isnil {var1} && {!(var1 isEqualTo "")}) then {IFDOT(var1,var2)}
#define OVERLOAD(var1)        systemChat format ["%1's inventory has been overloaded by %2!",(typeOf _target),var1]
#define LOOPARR(var1,var2)    {IFDO(_x,var2)}count var1


#define IFARRAY(var1,var2)    if(var1 isEqualType []) then {LOOPARR(var1,var2)} else {IFDO(var1,var2)}
#

macros are so annoying

#

don't work ๐Ÿ˜ฆ

#

literaly spent 3 hours working on these, still nothing, shoulda just made normal code ๐Ÿ˜ญ

rancid ruin
#

yes, you should have

#

you think macros are smart but then you end up taking 3 hours to write something simple that doesn't even work

indigo snow
#

You are putting too much into them

peak plover
#

yeah

little eagle
#

#define IFDOT(var1,var2) _target var2 var1

why?

peak plover
#

_target COMMAND ITEM

little eagle
#

Yes, why?

rancid ruin
#

cos macros are clever so it makes the code cleverer

peak plover
#

why not ?

little eagle
#

You're supposed to put the ugly stuff into the macro and give it a nice name, so you can write clean code.

#
#define SELECT_BY_NAME(array,element) (array select {(_x select 0) isEqualTo element} param [0, []] param [1, []])

private _array = [
    ["Cache_1", ["Box_FIA_Wps_F", [2033.22,3448.04,63.1198]]],
    ["Cache_2", ["Box_FIA_Wps_F", [546.874,3248.17,39.8989]]]
];


SELECT_BY_NAME(_array,"Cache_1"); // ["Box_FIA_Wps_F", [2033.22,3448.04,63.1198]]
SELECT_BY_NAME(_array,"Cache_2"); // ["Box_FIA_Wps_F", [546.874,3248.17,39.8989]]
#

Example from earlier.

#

If the macro does less stuff than want you have to do when you put down and write it, there is no point.

#

"LOOPARR" is not a nice name and leaves me more confused than before. ๐Ÿ˜ฆ

peak plover
#

loop through that array

#

lol ๐Ÿ˜„

#

I get it

#

it's bad

#

#define DESCFIND(var)        ((_roleDesc find (toLower (var)))> -1)
#define DESCIF(var,var2)    if (DESCFIND(var)) exitWith {_role = var2};
#define TYPEIF(var,var2)    if (_typeName isEqualTo (toLower (var))) exitWith {_role = var2};

I got this now

I rewrote that script in normal sqf (mostly)

#

This one "seems" to work

#

๐Ÿ˜„

compact current
#

Anyone know why i get this ?

#

12:11:10 Call extension 'MainDll' could not be loaded: Insufficient system resources exist to complete the requested service.

indigo snow
#

Memory full?

compact current
#

Nope

indigo snow
#

Everything I find seems to either indicate that or a lockup

#

But no experience, sorry

compact current
#

Not a problem at all, thanks anyway

indigo snow
#

You might try #arma3_tools since apparently the C guys hang out in there

compact current
#

Allrighty thanks ๐Ÿ˜„

little eagle
#

I read it as "loo-parr". Underscores!

grand berry
#

Can anyone see anything wrong with this - it just doesn't work. The only error i can get when breaking down the code is line 16 _noOfPos not defined but it is.

_this params ["_buildings", "_classname", "_maxUnits", "_side", "_maxUnitsPos"];

{
  _positions = [_x] call BIS_fnc_buildingPositions;
  _noOfPos = count _positions;

  if (_maxUnits > _noOfPos) then {
    _noOfUnits = _noOfPos;
  } else {
    _noOfUnits = floor random _maxUnits;
  };

  switch (_side) do {
    case ("CIV"): {
      for "_i" from 0 to _noOfUnits do {
        _pos = _positions select floor random _noOfPos;
        _group = createGroup [civilian, true];
        _unit = _classname createUnit [_pos, _group, "this setPosATL [getPosATL this select 0, getPosATL this select 1, (getPosATL this select 2)+1]; dostop this; this setDir floor random 720;"];
        if (_maxUnitsPos == 1) then {
          _positions deleteAt _i;
        };
      };
    };

    case ("OPF"): {
      for "_i" from 0 to _noOfUnits do {
        _pos = _positions select floor random _noOfPos;
        _group = createGroup [east, true];
        _unit = _classname createUnit [_pos, _group, "this setPosATL [getPosATL this select 0, getPosATL this select 1, (getPosATL this select 2)+1]; dostop this; this setDir floor random 720;"];
        if (_maxUnitsPos == 1) then {
          _positions deleteAt _i;
        };
      };
    };
  };
} forEach _buildings;
#

I had no idea there was one!

still forum
#

use selectRandom instead of _noOfPos and floor random

grand berry
#

ok will try that

#

new error of line 15 undefined _noOfUnits...

still forum
#

that is correct.

grand berry
#

How to pass local variables into the switch?

still forum
#

that's not the problem

#
  if (_maxUnits > _noOfPos) then {
    _noOfUnits = _noOfPos;
  } else {
    _noOfUnits = floor random _maxUnits;
  };

change to

  private _noOfUnits = _noOfPos;
  if (_maxUnits <= _noOfPos) then {
    _noOfUnits = floor random _maxUnits;
  };
#

you variable doesn't exist anymore at line 12. So switch can't see if if it doesn't even exist before the switch

grand berry
#

Yea that worked, cheers

still forum
#

use private keyword more often. If you use it you'll see these problems more easilly

grand berry
#

Ok will do. Why does the varible cease to exisit? Is it beacuse it's only defined inside the "if" statement

still forum
#

yes

#

local variables get deleted if you leave the scope

#

which the } from the if/else is doing

grand berry
#

Yea, i was just stupid to not notice it...

#

Thanks for the assist.

#

When is the appropriate time to use or not use private

still forum
#

almost always private (Stolen almost always auto :D)

#

Always.

#

private makes your script faster.

grand berry
#

Lol ok.

still forum
#

but only the private keyword. private STRING or private ARRAY variants are bad

queen cargo
#

can switch really be used with ARRAY types? Oo

still forum
#

internally using isEqualTo

atomic epoch
#

Is it a good idea to use private in the main scope? Seems kinda pointless

still forum
#

you could also register your own type #Intercept and override the isEqual check to something custom. Which would for example match strings with objects in the switch... Or .. stuffz

little eagle
#
_array = [1,2];

switch (_array) do {default {false}; case [1,2]: {true}}

Poor mans isEqualTo.

still forum
#

in the main scope no. What is main scope by your definition @atomic epoch

atomic epoch
#

e.g. The first line of an sqf file

still forum
#

that may not necessarly be main scope

atomic epoch
#

It will be if I use execVM

still forum
#

yes

#

main scope is the first SQF function right after the engine.
so your eventhandler's code. or init.sqf without any sub scope

#

In that case there is no performance profit. And nothing you could overwrite by accident. So yeah. In that case. no reason to use private besides visual/design preferences.

#

Stop using execVM and use CfgFunctions though...

atomic epoch
#

I thought so, thanks

little eagle
#

You can refer to the functions main scope as main scope, you just don't have to go bonkers with breakOut/To.

still forum
#

execVM compiles the function everytime == performance killer

atomic epoch
#

I do execVM for iteration and fixes then Cfgfunctions for finalisation

still forum
#

use execLUA instead #Intercept
It also compiles the function everytime tho ๐Ÿ˜„

queen cargo
#

actual mainscope should not even be reachable
the famous all scope

still forum
#

Oh... Hm... Maybe... There is one callstack item above the first SQF code that get's executed if your SQF is a function call. I think..

little eagle
#

I define main scope as the scope that when used exitWith in, ends the whole script instance.

still forum
#

so there might be one scope above you even in main scope..
But I am very tired and hungry and I'm very not sure. So.. Don't take that as truth

little eagle
#

So every time you use spawn or execVM you got yourself a main scope

#

Or every time an eventhandler runs.

still forum
#

main scope is when the only thing above you is Engine. Not SQF.

little eagle
#

Yes.

queen cargo
#

that is the magic all scope

#

the sole reason why BIS_fnc_halt is working

still forum
#

Isn't that just going to a non-existend scope?

queen cargo
#

uses breakOut "all"

#

so ... i do not know

still forum
#

breakout "#all";
//--- (breaking out from non-existing scope does the trick)

little eagle
#

It just ends the main scope then.

still forum
#

it even says that scope doesn't exist.

#

right there in the script file

queen cargo
#

it is magic scope

#

believe

#

๐ŸŒˆ

little eagle
#

You could trick it by using scopeName "#all".

#

You shouldn't do that.

tame portal
#

Then report BIS_fnc_halt as broken to BI

little eagle
#

But it isn't

tame portal
#

Just meant as a joke

little eagle
#

OK

tame portal
#

I just love the way you write ๐Ÿ˜„

little eagle
#

How so?

still forum
#

Hauso ein Haus mit O

little eagle
#

Gesundheit.

still forum
#

Why are these people that need script help always here when I'm not. Timezones are evil!

little eagle
#

You bored?

#

How about you release TFAR v1.0?

tame portal
#

Like, you always make sure to put a dot behind a sentence, you say OK in capital letters, I don't know man, just very rare when it comes to internet chat rooms ^^

still forum
#

No I'm not bored. I'm making a pizza and will then go to bed

little eagle
#

They told me proper punctuation makes you look smarter and I do have to compensate.

tame portal
#

LOL

waxen tide
#

I very much concur, Dedmen. I lost my sanity last night without you.

tame portal
#

Like, when you said "I'm laughing." I assumed you were saying that in like a sarcastic manner ๐Ÿ˜„

little eagle
#

Also this way I can complain about other people being stupid and/or lazy when they say something I disagree with without me having to address their actual point.

still forum
#

My pizza is boiling :u
I like sanity

#

I'd love to tell people that they are stupid.. But everyone would just think I'm rude

little eagle
#

Thanks.

#

FYI I actually laughed when I wrote that.

waxen tide
#

So while you guys are still here, you can maybe tell me why spawning an aircraft carrier at ASL altitude 0 and then setPos'ing people onto it a few seconds later with fixed offset works just fine in MP editor but leads to people spawning inside the carrier on dedicated server?

#

I know that i'm stupid so i'm usually not offended.

tame portal
#

How deep into the carrier

waxen tide
#

deep. meters.

tame portal
#

So on the water?

waxen tide
#

sometimes fall thru entirely

#

yeah

tame portal
#

What's the position you're using for setPos?

waxen tide
#

thinking of this ... the carrier i try to spawn for a cutscene does the same thing, it spawns too deep, seems to be glued to ASL 0

#

it is a position i figured out by try and error. just a fixed value i entered

still forum
#

@waxen tide setPosASL? or setPos ?

waxen tide
#

yes

#

ASL

tame portal
still forum
#

If you just spawn them half a meter higher just to make sure?

tame portal
#

setPosASL2

waxen tide
#

yes dedmen, 2 meters even

still forum
#

model center stuff.

#

I dunno :u

waxen tide
#

i actually ran the same script on server and local, and works fine local dozens of times

tame portal
#

Enlighten us commy

little eagle
#

setPosASL2 is setPosWorld essentially, but not functional.

tame portal
#

Great name they came up though

#

Hope they release a trailer next time for the new commands with the suffix "2"

little eagle
#

Both names suck. This one at least mentions that it's actually ASL.

waxen tide
#

also i tried createvehiclelocal vs createvehicle on MP editor and dedicated server. on MP editor i can setpos the local vehicle how i want, on the dedi server setpos is ignored, can't do jack shit to the local vehicle altitude wise. Z height is just always 0

#

and i tried every single setPos command

tame portal
#

Are any of the vehicles modded?

waxen tide
#

no, vanilla

little eagle
#

You should definitely stick with setPosASL over water...

waxen tide
#

oh and it only applies to the USS freedom i might add, and yes i copied the BIS_fnc_Carrier01PosUpdate function, removed the if (!isServer) exitwith and still, no bueno

#

i am commy, i figured from the start on water ASL is a safe bet

queen cargo
#

SQF = mind blown

#

sanity is nothing one has to maintain in the SQF world

little eagle
#

You just don't have to take the command names seriously.

waxen tide
#

i spend 6 hours on that yesterday, trying to get something to work on a dedi server that i tested for DAYS locally on MP editor -.-

little eagle
#

So you're spawning a carrier and then you're spawning AI on it?

waxen tide
#

oh and the weirdest thing? i have a camera i point at the carrier object. and it follows nicely a non-visible object.

#

well i spawn a carrier as local vehicle for a cutscene, and while the cutscene is running i spawn a carrier for people to actually use, and teleport them onto the carrier. i want to create the illusion that people actually move with the carrier from point A to B. both things work fine local but have huge issues in MP

#

cutscene carrier is invisible, and the carrier i want to put people on has the issue that people don't spawn on the correct height

#

discord ate a message.

little eagle
#

Could maybe attachTo the people and free them when they're ready.

#

I guess it's a MP race condition thing where the player objects set their position before the carrier position is updated or something like that.

waxen tide
#

i figured as much, i put a generous sleep 5 in there since the cutscene easily covers that.

#

maybe i should locally check if the new carrier i spawned exists?

#

and then have a local script handle the setPos?

little eagle
#

So I guess you can't just place the carrier with the real players on it at the start because that would interfere with the fake carrier and the cutscene, right?

waxen tide
#

oh you mean just attachTo the carrier they're already on and the move the carrier + people

#

well currently people spawn on a carrier in the middle of the ocean, no land in sight. then they choose a deploy point on the coast, cutscene, and then the carrier stands right next to the coast.

little eagle
#

You could do that or just hideObject the real carrier during the cutscene.

waxen tide
#

oh the cutscene takes place in the middle of the ocean without the real carrier in sight.

#

i made the cutscene 100% local with createvehicle local to avoid timing issues.

little eagle
#

Yeah, but the real carrier can appear in various places.

#

i made the cutscene 100% local with createvehicle local to avoid timing issues.
Very good idea.

#

Then it also might work for JIP...

queen cargo
#

does one wants to check if breakTo and breakOut are case sensitive?

little eagle
#

I can do that.

waxen tide
#

well, now my carrier is hovering in the air. its okay, i'll just give the story a little spin and claim NATO has hovercarriers now.

little eagle
#
systemChat "test begin";

call {
    scopeName "MAIN";

    call {
        breakTo "main";
    };

    systemChat "MAIN"; 
};

systemChat "test end";
still forum
#

no it's not

#

stricmp internally

little eagle
#

What I posted prints "MAIN", so not case sensitive.

queen cargo
#

MAIN should be printet with breakTo Oo

#

breakOut on the other hand should prevent that print ๐Ÿ˜›

still forum
#

Again another BI dumbness.
They store the scope in original case. and tolower everytime they check it. Instead of tolowering once inside scopeName

little eagle
#

retest with breakOut?

#
systemChat "test begin";

call {
    scopeName "MAIN";

    call {
        breakOut "main";
    };

    systemChat "MAIN"; 
};

systemChat "test end";
#

Does NOT print "MAIN" this time.

peak plover
#

So, to make a function without functions library, I just

_myfnc = {blabla};
missionNamespace setVariable ["myfnc",_myfnc,true];
#

remoteExec ["myFnc",_target];

#

That's gonna work, right ?

still forum
#

looks right

#

but.. CfgFunctions?

peak plover
#

this is just an idea

#

To change missions on - the - fly

#

a few quick fly functions

sullen robin
#

So we've been adding showcase mission to our mod and we can't figure out how to add a working overview picture. Thing we use right now:

class CfgPatches
{
    class WW2_MissionsWW2_p_WW2_Showcases_p
    {
        units[] = {};
        weapons[] = {};
        requiredVersion = 0.1;
        requiredAddons[] = {};
    };
};
class CfgMissions
{
    class Showcases
    {
        class WW2_MissionsWW2_p_WW2_Showcases_p_German_Engineering
        {
            displayName = "[WW2] Tanks - German engineering";
            overviewText = "Try out IFA3 Battle Tanks through the eyes of Wehrmacht tank crew.";
            overviewPicture = "WW2\MissionsWW2_p\WW2_Showcases_p\German_Engineering.Baranow\img\view.paa";
            author = "Jaki";

            briefingName = "[WW2] Tanks - German engineering";
            directory = "WW2\MissionsWW2_p\WW2_Showcases_p\German_Engineering.Baranow";
        };
    };
little eagle
#

Does it complain about the picture not being found?

sullen robin
#

no, just not showing. for example if I push mission from editor to SP, its showing just fine

#

but as if it was part of the mod its not

spice kayak
#

Well, guessing some people will like this. Still reading through the notes now.
Added: A "Recompile Selected" button is now available in the Functions Viewer

sullen willow
#

Where do I find the classnames of things? I tried using the config viewer but what it gave me isn't working?

spice kayak
sullen willow
#

Exactly, but the only thing is, I'm looking for the class names of magazines from mods

spice kayak
#

Ha, I don't know why this one is funny to me. Damn bushes. Tweaked: The mass value of the b_leucaena_f bush was reduced in order to deal less damage to vehicles

#

Ah, sorry then.

#

I'm not sure where you'd find that. Which mod?

sullen willow
#

It's a few different ones. Two of them are the LAGO weapons, the Biken and KU5K.

spice kayak
#

Apart from opening the CfgWeapons from the function viewer, I'm not entirely sure. Maybe someone else would know! I'm waiting for the game to update, so :(

waxen tide
little eagle
#

You could try teleporting everyone with attachTo first.

tough abyss
#

Anyone got info / example of CfgDebugConsole thanks

little eagle
#
private _attachObjects = _carrier nearObjects ["CAManBase", 50];
{
     _x attachTo [_carrier];
} forEach _attachObjects;

_carrier setPosASL blah;

{
    detach _x;
} forEach _attachObjects;
#

I am on 1.76 and there is no CfgDebugConsole.

tough abyss
#

Arma Update pushed, its on the change logs

subtle ore
#

The need for signatures is going to be more important now. Because without any verification, any joe smho can enable the debug console via addon

little eagle
#

Just set your mission to enableDebugconsole = 0

#

It overwrites any addon.

subtle ore
#

Ah, good to know. I will do that asap

sullen willow
#

Man, I'm silly.

#

I was looking at CfgAmmo

#

rather than CfgMagazines

cloud thunder
#

"The need for signatures is going to be more important now. Because without any verification, any joe smho can enable the debug console via addon" This was already true.

little eagle
#

Yeah, I though 1.74 had this already.

#

1.76 just fucks up the watch fields...

#

And has this mysterious CfgDebugConsole

distant egret
little eagle
#
if (isServer) then {
    [this, "HE"] call BIS_fnc_fire;
};

What now?

distant egret
#

You are entering a dangerous territorium here...

subtle ore
#

@little eagle yes, i was forgetting that this was the case in 1.74

little eagle
#
[cursorTarget, currentMuzzle cursorTarget] remoteExecCall ["BIS_fnc_fire", cursorTarget];
distant egret
#

Tweaked: Double slash comments in code in the Debug Console are now ignored Hurray!!

cloud thunder
#

handy

#

does it retain formating?

distant egret
#

doesn't matter as you wouldn't get a return from it

#

unless you mean the whole code

cloud thunder
#

whole code block. I'd be nice to copy // commented code to debug, beable to edit from there then copy back to script and maintain formating...

little eagle
#

It doesn't fuck up strings containing //

distant egret
#

Ah I see. let me test.

little eagle
#

They changed some stuff around, so the prev / next is borked, but that will be fixed soon.

cloud thunder
#

fix required with CBA?

distant egret
#

Yea, it's CBA addition the next prev

#

at least I think, haven't played vanilla Arma for a while so xD

#

Also @cloud thunder it looks like formatting stays when you copy from the debug console.

little eagle
#

It's already fixed on github and CBA will update once vipermaul awakes.

distant egret
#

only annoying thing is that enter and tab don't work, so when pressing enter the code run's had that happen some times in live actions...

little eagle
#

Shift enter

cloud thunder
#

nice ones

distant egret
#

yea know about shift enter there is no one for tab tho ๐Ÿ˜ฆ

little eagle
#

The Tab thing could maybe be fixed with mod.

#

I see no reason to have tab be tab out for this.

distant egret
#

maybe CBA ^^

little eagle
#

That's what I'm talking about.

distant egret
#

๐Ÿ˜›

quasi rover
#

Is it true that house is sunk into the ground and replaced with wreck model when it is destroyed ? ๐Ÿ˜ฒ

little eagle
#

Yes.

cloud thunder
#

don't they get deleted shortly after though since many updates?

little eagle
#

hue

quasi rover
#

That's why our mission searching object is under the ground and failed to find, if the wreck model is deleted when our new mission is started. right?

little eagle
#

I remember A2 when it created one ruin for each client

cloud thunder
#

hefner

#

don't know what you mean @barnes#7447 but object can get buried in the damage model..

little eagle
#

Destroyed building will not be deleted.

#

Ruin is a new one on top.

#

getPos test_b

#

[2003.42,2718.12,-100.301]

#

100 meters below ground. Not deleted after 10 minutes.

cloud thunder
#

So what = more frames on server and client. Leaving the original building uder ground and deleting damage model or replacing damaged model with original model?

#

JIP syncronization considered?

little eagle
#

No idea, better not mess with it.

cloud thunder
#

Well I have noticed slight fps improvement deleting ruins when no players on server as oppsed to leaving everything as is..

peak plover
#

If your performance is bad, then destroyed buildings are usually not the issue

cloud thunder
#

Bad performance is not an issue. The question was reguarding optimization

peak plover
#

Ohh, yeah when buildings get destroyed, the turn into objects you can edit with zeus....

#

You'd get more gains from making cars into simple objects when there is no one around them

little eagle
#

I get the helos with all their sections in the model, but what's up with the submarines?!

subtle ore
#

Some don't have selections at all. Despite what is configured for it. None you can acess at least

#

I had the same thing occur with the tent hangars and the regular metal hangars

peak plover
#

I tried deleting / hiding all buildings on malden and there was no increase in fps, by getting rid of everything that is on the other side of the island. Buildings need no optimizations.

Fish aiโ„ข
Underwater stuff is an overloocked gimmick. I doubt anyone goes under the water at all...

subtle ore
#

@peak plover What?!?!? I go diving all the time

little eagle
#
addMissionEventHandler ["BuildingChanged", {
    params ["_old", "_new", "_isRuin"];

    if (_isRuin) then {
        _old spawn {
            sleep 5;
            deleteVehicle _this;
        };
    };
}];
#

Agreed, the fish are really bad.

#

But that only matter near the sea.

peak plover
#

@little eagle any data witht that? does it help?

little eagle
#

idk, I just wrote it because.

peak plover
#

I'll save it. I'll give it a go when I do my clean up stuff again

#

Any new scripting stuff with new update?

ionic orchid
#

awesome, drawTriangle made it in

#

time to see how it performs

little eagle
#

^^

subtle ore
peak plover
#

ohh snapparoonie

ionic orchid
#

hah that's cool

subtle ore
#

I can only imagine how many dick leaflets we are going to get in random missions

ionic orchid
#

message for you, sir dickbutt leaflet

waxen tide
#

can someone tell me what the differences are in hosting a local server and "joining" it with the editor in MP mode and connecting to a remote, dedicated server, scripting wise?

subtle ore
#

Jeez. Civies already have enough to worry about

#

@waxen tide remote, you are not local to the server. Editor you are local to the server

#

Afaik

peak plover
#

(isServer) command and also more than 1 instances of the engine, meaning if you global execute a function that will add 5 magazines, and there are 2 instances(serv+client), there will be 10 mags. But if you are local hosting you are 1 instance and only spawn 5.

waxen tide
#

I think i understand

#

ohhhh

#

thanks you two

peak plover
#

You usually want to avoid running code on all clients/instances

subtle ore
#

Yep

ionic orchid
#

drawTriangle runs pretty damn well

subtle ore
#

Good to know.

ionic orchid
#

(now to start begging for a drawTriangle3D)

peak plover
#

You can do that yourself, can't you?

subtle ore
#

drawIcon should suffice for that situation

peak plover
#

You can draw lines, lik the 3d editor bounding boxes

ionic orchid
#

I want to draw custom shapes, without having to make a model for it

#

fill shapes, that is

subtle ore
#

Physx traces yeah

ionic orchid
#

I already use drawLine3D but that isn't so hot for what I want

subtle ore
#

You can return the bounds for an object and draw the lines

ionic orchid
#

Yeah, but I don't need to do that

subtle ore
#

Ooohh..i see.

ionic orchid
#

I could do so many cool things :[

subtle ore
#

Yeah Physx traces have never looked really quality anyways.

#

Or at least in whatever dx version a3 is. Dx11?

ebon nymph
#

Any way to maintain control of my unit/player after createCamera?

subtle ore
#

@ebon nymph selectPlayer command

ebon nymph
#

ill check that out. thanks @subtle ore

subtle ore
#

@ebon nymph yep, you can also do _yourcam switchCamera 'Internal'

ebon nymph
#

Tried some sort of combinations like that. With no success. But will try these 2.
Wanna do some FlyBy etc. cameras for jets without hitting the ground ๐Ÿ˜‰

subtle ore
#

I see, that'll probably work for you.

#

Another useful command for what you are trying to achieve

ebon nymph
#

Yeah. I was worried about the switchCamera that is mandatory here.
But "It is not needed to switchCamera to the unit to be able to control it - it is needed to be able to fire with" should help ๐Ÿ˜‰

subtle ore
#

Yeah its not needed. But switching between plane camera and custom camera functionality is there

sullen willow
#

So I've got this trigger that plays sound. How do I make it play to only the person who sets off the trigger?

ebon nymph
#

Still no success

_cam = "camera" camCreate (player modelToWorld [0,400,2]); 
_cam cameraEffect ["External", "Back"];
_cam camSetTarget (vehicle player);
_cam camCommit 0;
player remoteControl driver jet;
sleep 5.0;      
objNull remoteControl driver jet;
_cam cameraEffect ["Terminate", "Back"];
camDestroy _cam;```
waxen tide
little eagle
#

That is basically nothing.

#

You sure you didn't short circuit it with nil?

ebon nymph
#

@sullen willow Shouldn't it be sufficient to make the trigger local?
!(isServer) && (player in thisList)

waxen tide
#

kinda?

#

mkay i dun goofed, now its the expected 1700ms ๐Ÿ˜„

little eagle
#

player in thisList ?

#

asdfghj. nil right?

waxen tide
#

if (!isDedicated) exitWith {}; ๐Ÿ˜ณ

little eagle
#

haha

ionic orchid
ebon nymph
#

right @little eagle

waxen tide
#

testing single functions locally because testing on dedi took my sanity last night.

little eagle
#

Debug console function performance testing is borked.

#

It only allows one iteration. No way to measure it reliably.

waxen tide
#

well if a single execution takes 1.7 seconds, i kinda know the ballpark don't i?

#

so how do i do it properly?

little eagle
#

SP I guess.

waxen tide
#

I'm not a religious person but i know what hell looks like. I've seen a glimpse of the abyss.

#

its called SQF.

little eagle
#

Try finding the anti derivative of sqrt(tan(x)) if you want to know what hell looks like.

waxen tide
#

i'm the wrong guy to ask, i cheated on every single math exam.

rotund cypress
#

@little eagle they fixed it now in 1.76

#

If you have some shit in config

little eagle
#

Debug console in MP?

ionic orchid
#

Yeah, I think I tried to make a chat head like that - like I used an NPC head and put it in the corner of the screen with some text (but it didn't always load the textures so I removed it)

#

But the thing I'm looking for is a way to put arbitrary 3d shapes in world space

#

the lines are great, I just wish you could do triangles and fill them with a solid colour, too

#

Yeah :/

astral tendon
#

getMarkerPos "marker2","marker2_2"

#

i need a car to follow multiples markers, how i do it?

indigo snow
#

AI setDriveOnPath ([array,of,markers] apply {getMarkerPos _x}), barring phone mistakes

astral tendon
#

car2 setDriveOnPath (["marker2","marker2_2"] apply {getMarkerPos _x})

#

is this right?

rotund cypress
#

Yes @little eagle

indigo snow
#

Test it, i cant check precise syntax on my phone atm, @astral tendon

#

Looks good tho

astral tendon
#

there is a command to units do not follow formations?

#

btw that scipt seens to work

winter rose
#

not to follow formation, not really-really.
you can set them in speedMode "FULL", that will make them rush/sprint to the destination

or you can use "unit move getPos destination" and only this one unit will move away from the group

ebon nymph
rose hatch
#

LoW DLC seems to have broken something, not entirely sure where to start...
Getting an occasional CBA-related error when using CBA keybinds for my addon:

18:36:31 Error in expression <s;
_params pushBack _x;

_blockInput = ([_params call _code] param [0, false] is>
18:36:31   Error position: <[_params call _code] param [0, false] is>
18:36:31   Error Generic error in expression
18:36:31 File x\cba\addons\events\fnc_keyHandlerDown.sqf, line 69
#

Thoughts?

peak plover
#

post code

#

ohh

rose hatch
#

Related code from cba_fnc_keyHandlerDown.sqf:

        // check if either holding down a key is enabled or if the key wasn't already held down
        if (_execute && {_allowHold || {GVAR(keyUpActiveList) pushBackUnique _xUp != -1}}) then {
            private _params = + _this;
            _params pushBack + _keybindParams;
            _params pushBack _x;

            _blockInput = ([_params call _code] param [0, false] isEqualTo true) || {_blockInput};
        };
#

The keybinds worked fine before this game update, haven't changed anything in my addon and I don't believe CBA's been updated... Speraking of that, does cba have a discord?

peak plover
#

try ace 3 slack

rose hatch
#

Sorry, thanks, & gotcha

peak plover
#

Yeah that code must suck if somone is on a phone or <1080

#

Try reseting your .vars file

#

see if it still happens after that...

#

I'm still downloading update, so can't check myself ๐Ÿ˜ฆ

rose hatch
#

Hmm... Still happening w/ reset vars file. I skimmed through the engine changlog, mostly still scratching my head atm

ionic orchid
#

drawTriangles is pretty good up until 100k triangles

#

and crashes the game at around 300k \o/

peak plover
#

lmao

#

can you compare that to normal markers for ex?

ionic orchid
#

erk I deleted all my test stuff for that

#

I was using drawRectangle with .paa textures to emulate non-rects and the difference between this and that is intense

#

I love drawTriangle ๐Ÿ˜ฆ

#

I want to marry it

peak plover
#

Nice!

#

What do you use that for even? I've never needed drawRect/tri

ionic orchid
#

I've seen people use it for marking out play bounds for missions

#

Like marking off places you can't go if you're just using a small part of a larger map

peak plover
#
private _car = "b_car_01";

nig_myStuff = {
    missionNamespace setVariable ["test1",_car];
};

[] spawn {
    call nig_mystuff;
    systemChat str test1;
};
#

My question is

#

What happesn

#

Does _car get replaced by a string?

#

Or will it check for value of _car when it calls the function

ionic orchid
#

I don't think _car is visible from that scope

#

(from nig_myStuff that is)

peak plover
#

hmm

#

so if i want it to replace _car i have to use a global var or a macro

#

hmm

#

kinda ok, kinda bad ๐Ÿ˜ฆ

polar folio
#

anyone getting weird behavior of the debug console after the patch?

peak plover
#

They changed somthing about it

polar folio
#

for me it's like the length of the code matters. same code works only after removing all tabs

#

very strange

peak plover
#

:S

#

how bad is it to use global variables in a few scripts?

#

Better off using a new namespace?

tough abyss
#
_pod = ( [ position player, 0, "C_IDAP_UAV_06_antimine_F", CIVILIAN ] call BIS_fnc_spawnVehicle ) select 0;
player connectTerminalToUAV _pod;
{ _pod removeWeapon _x } forEach weapons _pod;
_pod addMagazine "1Rnd_Leaflets_West_F";
_pod addWeapon "Bomb_Leaflets";``` to fly the new drone around
blissful wind
#

blessed may be the new hide objects module

waxen tide
#

I have a problem.

#

I think it is a simple problem.

#
{
    _eval = (([(AGLToASL _x),true,true] call Ivan_fnc_eval_position_cover) select 1);
    diag_log format ["should be number %1", typeName _eval];
    diag_log format ["should occasionally be 100 %1", _eval];
    if (_eval isEqualTo 100) then
    {
        _spawn_pos_array pushBack _x;
    };
} forEach _building_pos_array;
#

The if never equals to true, thus never being executed

#
 3:04:46 "should occasionally be 100 75"
 3:04:46 "should be number SCALAR"
 3:04:46 "should occasionally be 100 0"
 3:04:46 "should be number SCALAR"
 3:04:46 "should occasionally be 100 93.3333"
 3:04:46 "should be number SCALAR"
 3:04:46 "should occasionally be 100 100"
 3:04:46 "should be number SCALAR"
 3:04:46 "should occasionally be 100 100"
 3:04:46 "should be number SCALAR"
 3:04:46 "should occasionally be 100 98.8889"
 3:04:46 "should be number SCALAR"
 3:04:46 "should occasionally be 100 87.5"
 3:04:46 "should be number SCALAR"
 3:04:46 "should occasionally be 100 50"
#

thats what the log throws out, so _eval occasionally equals 100

#

i was suspecting a type error or something ?! but to me the output looks just fine

ebon nymph
#

@hasty violet can't keep up with everything ๐Ÿ˜‰

waxen tide
#

(_eval > 99) gets me close, it equals true in 19 out of 241 cases. thats what i would expect.

#

but why the hell doesn't (_eval isEqualto 100) or (_eval == 100) work?

ionic orchid
#

what happens if you

_eval = 100;

does the isEqualTo pass?

#

thaaaats odd

waxen tide
#

it equals true

#

i was mistaken

#

is there maybe some rounding error going on?

ionic orchid
#

then it's probably a float precision issue... if it were me I'd have something like

if (abs (_eval - 100) < 0.01) then {
waxen tide
#

is it like 100.0000000000000001

#

why not _eval > 99.99 ?

ionic orchid
#

that's up to you, I don't know if _eval will ever be bigger than 100

#

it all depends how far away from 100 you'll willing to accept as 'good enough'

waxen tide
#

well i wrote a function that evaluates building positions

#

it does ~90 checks for surface intersections

#

and returns a value between 0 and 100

#

100 means total cover

#

a value of like 99 means that ~1 check failed of 90

#

shrugs

#
private _result = 0;
{
    _check2 = [_size,30,_x] call Ivan_fnc_circle_check;
    _result = _result + (_check2 select 1);
    if (_abort)    then {if (_result < (30*_foreachindex)) exitWith {
        systemChat format ["%1", [_check_ceiling,((100/(30*_foreachindex))*_result)]];
        [_check_ceiling,((100/(30*_foreachindex))*_result)]};};
} forEach [0.75,1.25,1.75];

[(_check_ceiling select 0), ((100/90)*_result)]
#

thats where the "100" comes from

ionic orchid
#

you could try a round or ceil on _eval to smooth out that potential imprecision

waxen tide
#

mmhm yeah rather thinking if all 90 checks pass, i'll just straight output a 100 without math.

#

so any value below 100 might be nasty float, so not 100% cover

#

but 100 is 100.

ionic orchid
#

yeah, that sounds good

waxen tide
#

thats kinda what i need from that function

#

in this case i want to place enemies in buildings that for certain can't be seen

#

1 failed check could be a window or something.

#

thanks for the help

ionic orchid
#

no problemo

#

sometimes it's just good to type out the problem and the solution will come to you by itself

waxen tide
#

if (_result = 90) exitWith [(_check_ceiling select 0), 100];

#

that should do it

#

yeah kinda

#

i didn't even think of float since the log output was straight 100 ๐Ÿ˜

waxen tide
#

dozens of smashed bugs later i got something to work. yay!

#

todo list still getting longer rather than shorter each day.

waxen tide
#

actually not really. its just that when you think of a simple feature and implement it, it creates problems. problems that require new functions you need to write to check new things.

#

also, of course, feature creep.

spice kayak
#

Oh hey, @still forum, you'd be happy to know I finally figured out Github and got my mission scripts up there :D

still forum
#

*happy*

spice kayak
#

Can't remember who else was interested in them, but hey, it's there now. Took a while, and a few repository restarts.

#

But yeah, now you can see how messy my code is on GitHub :D

still forum
#

I will write tons of comments pointing out all your errors :3

spice kayak
#

Ha, thank you. I mean, it works for now, but any refinements or corrections / optimizations would be great.

still forum
#

I already have a couple.. But that code runs in scheduled so these minimal optimizations wouldn't be worth the effort of pressing a button on your keyboard

spice kayak
#

Ha, it's all good. I'm still not even sure how I'd see the comments, which is currently what I'm looking for. Was just happy to get it up and out there. I should actually release this mission some time soon, though I'm not sure if anyone was really wanting anything like this.

spice kayak
#

Oh, that makes sense. Thanks.

#

Oooh, I can comment on your comments!

#

Bit odd that they visually break the code and take up space, but I don't mind it too much. You're going to town though.

still forum
#

Done I think

#

Also operator2script and operator1script are essentially the same.
Consider turning these scripts into one and passing the operator into it via _this

spice kayak
#

Yeah, that has kind of bugged me for a while, needing to have two scripts for that. There's just so much at play here I couldn't be bothered wrapping my head around it, especially with how many different things need to happen. Just figured that was easier for now. Also, not sure, can the same script be run, while it's already running?

#

Yeah, I realize most of my issues come with the transition from me only knowing about publicVariable, and me learning about setVariable xD

still forum
#

Also, not sure, can the same script be run, while it's already running? dumb question :U

#

If you execVM twice.. Does the game instantly crash?

#

Sure it does! It's forbidden to do the same thing twice in SQF

rancid ruin
#

@still forum is your avatar some furry related thing?

still forum
#

Maybe

rancid ruin
#

๐Ÿ˜ณ

peak plover
spice kayak
#

Damn forbidden scripts :(

spice kayak
#

Aw, BIS_fnc_VRSpawnEffect is rather disappointing looking :(

#

Just a lil' zappy sound and instant (in)visible state.

peak plover
#

Expectations were had, that's where you went wrong ๐Ÿ˜„

spice kayak
#

Ha, too true. Was thinking, instead of an EMP, how about a cloak?! I mean, this works, but it doesn't look so good. Would love that glimmer effect from the new DLC, the one used on the memories.

peak plover
#

Can't wait when they unEncrypt orange, there is much to learn ๐Ÿ˜„

spice kayak
#

Ha, shouldn't take too long :P I have a feeling they just used the particle system, but I know nothing about that, so xD

still forum
#

What would you want to learn?

peak plover
#

Memory effect

#

How they seemlessly change scenarios, etc.
I've not played the dlc, but I've been told there's cool shit

#

some particle effects
I'd like to find out which one

still forum
#

Maybe I'll have time on the weekend.

peak plover
#

All I've got, maybe if you own dlc, you get more?

#

Yeah these functions are a lot more readable and better than some for ex. tasks

still forum
#

@peak plover PM me Mission name please. Best would be the classname of the mission if you can get at that.

peak plover
#

Can't, don't have dlc

still forum
#

.-.

peak plover
#

I'll just assume they don't want us to get it until they have made the files into pbo

still forum
#

ebo is intended to prevent people that don't own the DLC from getting access to the content without paying.
It's not made to prevent modding or learning.

peak plover
#

Yeah, but it seems like most stuff makes it to pbo in a few months or whenever next dlc is released

still forum
#

So if someone wants to know how something works. I happily help.

peak plover
#

I'd like to know eventually, but I don't need/will use anything right now

#

I'm fine with it, because they have not kept it locked down indefinately...

still forum
#

I'm sure BIS would share all that data to people with good intentions. But how would they know/manage so many people.. That's why they don't

waxen tide
#

i have not looked into it at all, but i would guesstimate that arma decrypts the files with a key at runtime, so that key eventually makes its way to your computer. obviously smart people can decrypt the files if they want to.

#

i'm not interested.

#

but you guys are discussing it at length by now

still forum
#

I was only talking about ๐Ÿช'S

waxen tide
#

i'm more interested why arma thinks that a balcony is a location totally enclosed by walls despite me doing 99 checks to avoid that

#

only occasionally tho

#

jeez. i bet it is detecting transparent rails as wall or something.

still forum
#

are you Intersecting on VIEW lod?

#

or FIRE?

peak plover
#

What r u doing @waxen tide ๐Ÿค”

waxen tide
#

hiding enemies. for easter!

still forum
#

shooting fire

#

FIRE intersects with everything a bullet would intersect with.

waxen tide
#
lineIntersectsSurfaces [
    _centerpos,
    _offsetpos,
    objNull,
    objNull,
    true,
    1,
    "VIEW",
    "FIRE",
    true
    ];
still forum
#

I'm using that for TFAR's object interception. So a closed Window intercepts but a open one doesn't

#

That should detect the railings of the railing.. but not detect anything if you go through the gaps

#

maybe you are only hitting railings by accident

waxen tide
#

I must say i'm happy with the optimisation aid from dedmen on this. the script evaluated 367 positions, 43 of which were deemed suitable, in 3 seconds.

#

well i get like 1% false positives

#

i can't see a systematical error

still forum
#

You could do some additonal checks after the first wave.

waxen tide
#

well the story goes like: players patrol a town, question civilians. certain conditions trigger an ambush. so i kinda need to spawn hidden enemies and have them sneak up on the enemies.

peak plover
#

whoa bro

#

sweet

waxen tide
#

dedmen, i already do a 3 stage check. stage 1: ceiling. stage 2: 8 checks around in a circle. stage 3: 3x30 checks in 3 heights in a circle

#

obviously if i get a single fail, i abort checking for the pos

#

i also fetch the boundingboxreal value for the first encountered object, and calculate the max required check distance from that.

#

its precompiled functions but i do the check on-demand since its random towns. i thought about creating lookups and storing them in the server profilenamespace tho.

#

ah no i rely on the provided town center as input

still forum
#

you could also calculate at mission start and store the result on a variable on that building

waxen tide
#

well not sure that would work dedmen. what if there is a second building blocking a window?

#

then the check passes

#

i would do the check for every town in my town array and save the results i guess

still forum
#

But you could first filter out the 100% unsuitable positions. Like the ones on the balcony or on the outside of the building. I guess

waxen tide
#

true

#

but honestly atm the script seems performant enough to just be called live on demand

#

but i'm already using the profilenamespace of the server as a cache for map-dependent data i precalculate, so i might as well add that.

#

i can already envision it, my mission spawns and needs like 2ms total execution time because everything is in predefined lookup tables and my server profile file is 2gb

still forum
#

#Intercept

#

:3

#

+SQLite Database

#

Woah.. That would be awesome...

waxen tide
#

actually my lookup tables don't interfere with dynamics, quiksilver. i've indexed every single town on the map with a function and i precalculate data for each town

#

so it is as randomized as possible, i just save executing some stuff on runtime.

#

my beta tester found the house in question

#

the "balcony" on streetlevel?

#

just above the crosshair.

#

it is recognized as covered position.

#

weirdly i think he's having fun.

#

i think the rails are detected wrongly

#

probably i need to adjust checking heights

#

but the ceiling check should totally fail?

still forum
#

Not if it hit's the AC or the Antenna above.. I guess

waxen tide
#

here it works just fine

#

1 failed check, abort.

still forum
#

Could it be that your position is a little bit into the ground? So the ceiling check actually hit's the floor?

waxen tide
#

no the indexed buildingpos'ses are always a bit above ground

#

like, half a soldier height?

#

ceiling check works fine on multiple other buildings. must be the AC or antenna or something

#

one check function to rule them all. i shall not rest until perfection was achieved.

#

my idea was to basically keep the map empty. no editor placed objects. no manually placed markers. just have a script molest the cfg and the map until i got all the data needed for mission spawns etc.

#

i tested a few community maps, so far it seems they comply surprisingly well with the same standards of the BI maps

#

sooo i hope to throw just any map at the mission without changes.

rancid ruin
#

my server profile file is 2gb wuuuuut. does that not cause problems?

waxen tide
#

that was me joking about how it will be in the future

#

i'm currently storing 350kb in the profile. it was 1 .5mb but i optimised it a bit

rancid ruin
#

golly gosh, i was going to say..

#

you should make your profile file 2gb though just to see what happens

#

i'm curious now

waxen tide
#

coughs

#

๐Ÿ˜’

#

if (object == "big_ass_barracks") exitWith {true};

#

would save at least a second execution time!

#

well i check if the house has doors, and only consider houses with doors. then i lock the doors, check the concealment of the positions, spawn my enemies, strip them of all guns and gear, set them passive and stop them, and then setpos them. then when the ambush is triggered, i equip them and set them loose.

#

_unit setUnitPos "DOWN"; ?

#

yeah sure, but works out for me so far.

#

i'm spawning the enemies before the players enter the town, yeah.

#

hence why i'm looking for buildings without windows/doors etc

#

i guessed thats the safest bet

#

hey lets make an ambush

#

1 week scripting later

peak plover
#

haha

#

๐Ÿ˜„

little eagle
#

one issue with "checkVisibility" that i encountered, is that you cant check from the players camera position, only their body.
Did you use eyePos?

waxen tide
#

nahhh to be honest i smashed most bugs, its like 99% reliable which is already "good enough"

#

i'll also dress them nicely as civilians to blend in with the others.

#

i'll actually leave this feature as it is right now and focus on the next one for the next mission part.

little eagle
#

eyePos doesn't care about 3rd person, since it also works for remote machines and they don't know if you are in 3rd person or not.

#

Also fuck 3rd person.

waxen tide
#

i'm a realism fan but 1st person isn't all that realistic to me. you just lack the feedback from your body touching your surroundings, also your FOV is too small ...

#

not that 3rd person is perfect but......

peak plover
#

waitUntil {cameraView == "EXTERNAL" || cameraView == "GROUP"};
player setDamge 1;
systemChat 'Die nerd';
waxen tide
#

i mean 1st person with like VR googles? great! 1st person with a monitor and small FOV ? meh.

little eagle
#

plebs

waxen tide
#

1v1 me newb!

peak plover
#

@little eagle I've always had vehicle drivers with 3rd person ๐Ÿ˜ญ

still forum
#

just increase FOV then

peak plover
#

you just lack the feedback from your body touching your surroundings
Why do you play cs:go in first person then?

#

st00ped ๐Ÿ˜ƒ

waxen tide
#

i emulate 1st person vehicle driving by driving over every bush and street sign while following an S path.

#

i've never played cs:go in my life.

peak plover
#

My point is, that's a bullshit argument for 3rd person

waxen tide
#

well i have no issues flying helicopters and putting them down in tight spots in 1st person, but infantry combat while utilizing cover? meh.

rancid ruin
#

back to politics troll channel where he belongs

waxen tide
#

yes. yes yes. back to sqf.

#

eez. generate a full circle, then substract the smaller one in the middle.

#

don't delete mines, delete generated mine spawn positions. then foreach thru what is left and spawn mines on the coordinates.

rancid ruin
#

bit of sin and should be easy surely

waxen tide
#

_perimeter True to return only positions on the area perimeter (optional, default: false) <BOOLEAN>

#

๐Ÿ˜ฎ magic

#

but if it is exactly on the perimeter, then you need to generate multiple.

peak plover
#

cba shit is cash, because you can define your own area, example 4

waxen tide
#

safepos seems to check lots of stuff, might be slow?

#

maybe do it like that, and randomize the number of points on the circle a bit, and generate multiple circles.

#

its simple math, so should be fast?

#

zero checks done to the map

rancid ruin
#

....or just use sin for it's intended purpose

waxen tide
#

heresy!

rancid ruin
#

yea that ADMM3 is exactly it right

waxen tide
#

its a function to calculate points on a circle. because you need that literally ALL THE TIME.

#

vectoradd seems surprisingly performant.

daring pawn
#

Is the debug console bork? Anything with multiple lines is not functioning for mme

still forum
#

might be... Lot's of debug console borking going on since KK started doing stuff on it.

daring pawn
#

lol gg