#arma3_scripting

1 messages ยท Page 483 of 1

solar coyote
#

Well, the condittion statement will be executed prety much every frame, it will fill your your chat with rapidly

frigid raven
#

ha yea saw that

solar coyote
#

Still, why do you need that?

frigid raven
#

Atmosphere

#

similar to RPGs where ppl around you chatter while u pass by

#

u know?

solar coyote
#

As far as i underatand if there is a person that can oerform action must say something before going for it?

#

Or alert player or hint, that action is awailible?

elder prawn
#

Hi, can someone help me with this? :
i want to reduce the reloading time of a tank im sitting in.

"player addEventHandler ["FiredMan",{
params ["","_weapon","_muzzle"];
private _type = _weapon call BIS_fnc_itemType;
private _time = -1;
switch (_type select 1) do {
case 'SniperRifle' : {_time = 0.1};
case 'AssaultRifle' : {_time = 0.1};
case 'Handgun' : {_time = 0.1};
case 'Rifle' : {_time = 0.1};
case 'SubmachineGun' : {_time = 0.1};
case 'MachineGun' : {_time = 0.1};
case 'Mortar' : {_time = 0.1};
case 'GrenadeLauncher' : {_time = 0.1};
case 'BombLauncher' : {_time = 0.1};
case 'MissileLauncher' : {_time = 0.1};
case 'RocketLauncher' : {_time = 0.1};
case 'Cannon' : {_time = 0.1};
case 'Throw' : {_time = 0.1};
};
if (_time isEqualTo -1) exitWith {};
(vehicle player) setWeaponReloadingTime [(vehicle player), _muzzle, _time];
}];

//not working and i dont know why.

unborn ether
#

@elder prawn Well, hitting every weapon type is not the best idea to start with, secondary, you seek for Cannon if you are not talking about MG, which is MachineGun AFAIR. And im not sure what's that " before player since no markup used.

high marsh
#

Honestly, I would use a mission config defining each reload time and then make a macro to grab it from config and then apply it from there.

#

The names would have to be case sensitive in config, but it'd work okay.

solar coyote
#

He wants to reduce reload time only in vehicle he is in. So there is nice example in wiki:
_done = _vehicle setWeaponReloadingTime [gunner (vehicle player), currentMuzzle (gunner (vehicle player)), 0.5];

high marsh
#

Yes, that is understood. The method of iterating through each of the names is not optimal

solar coyote
#

Its not completely unecessery if hes fring from tank

#

Unless its a turret

#

Even then i dont think you can throw a nade so "Throw" is still redundant

high marsh
#
#define getConfigReload(r,c) private r = getNumber(missionConfigFile >> reloadTimes >> #c)
unborn ether
#

Note that setWeaponReloadingTime is only having effect on a current weapon state (loaded projectile) so since the projectile is fired the next one will be reverted to a weapon config defaults.
Don't forget that

#

Otherwise yes, you can remove unused cases

solar coyote
#

Guys, wanna real mind wrapper?

unborn ether
#

nil = 0 spawn {nil} <- ๐Ÿ˜„

#

That's a mind wrapper

#

Nothing comes from nowhere and goes to nothing.

solar coyote
#

I want to make competitive zeus vs player mode. In advance i want to ask not to suggest "hideObject". So my idea is to to make one player play an rts while retaining curators cameras flexibility, but i also want to make some kind of fog of war alternative. Basicily i want to hide players in any way or form from zeus view, and make them vissible once controlled AI finds them. Just to make sure zeus doesnt zoom in and search them manualy, but tatther send scouts. It especialy needed for situatio when zeus can use artilery. He might just insta win. Would not like to reside that on hight command becouse seeing your soldoiers in action is huge part of the fun i imagine.

Solutions?

obsidian kiln
#

why no hideobject with neartargets?

solar coyote
#

AI cannot reviel them or interact with them in any way if its local to zeus. If hiden with hideObject player might just stand in front of AI and they wouldnt even know

obsidian kiln
#

but executing setGroupOwner to zeus units?

#

locality would break only if zeus use remote control...

solar coyote
#

My first thouht was to try change Textures to alpha value 0, then change back once revealed.l, but not all model textures can be changed so...

#

I want it also be hosting friendly. One my thoughts was to change AI locality to server or to players even, but i want cleaner way

unborn ether
#

@solar coyote if MP then hideObjectGlobal from server. It doesn't care of locality of a hidden object.

obsidian kiln
#

i think the problem with hideobject is that hidden objects aren't registered by the AI?

solar coyote
#

I'm sorry @unborn ether, but you have completely missed my point. I want only zeus not being able to see player from skies unless knowsAbout is over 3.5

obsidian kiln
#

well

#

you could always do some

#

eyepos lineintersects with

#

but that's far more performance unfriendly than just setgroupowner and sheneanigans

solar coyote
#

As far as i understand hideObject removes model mesh from the game, i dont want that. I want only the visual part of it make it transperant in other words. Make any object - a house hiden, and you can walk through it and shout through it. And as ai detection of enemies relies on detecting meshes its out of question

obsidian kiln
#

i think AI still register hideobject units

#

but im not sure

solar coyote
#

I've tested it, they dont

unborn ether
#

They do register them but not taking actions, since VIEW LOD is off, they have no visuals on it, just backend.

solar coyote
#

Made my self hiden and started runing in between AI, shoting them and they were all confused

obsidian kiln
#

but then neartargets should show them up

unborn ether
#

@solar coyote You can't make anything just transparent. There are no such scripting commands.

obsidian kiln
#

did you test if neartargets showed them up?

unborn ether
#

Hiding a selection wouldn't help.

solar coyote
#

Any other workarounds then? I want fog of war effect of rts genre

obsidian kiln
#

create the mission with a heavy fog that makes only 300m visible

#

then you only hideobject if they are further than 300m visible of any troop

solar coyote
#

I think i saw desired effect on getTactical mod. Enemies would apear and disapear based on your guys vision

obsidian kiln
#

yeah, i mean, you can do it with eyepos lineintersect

#

but it won't be performance friendly

solar coyote
#

Hmmm...

obsidian kiln
#

maybe do that only on group leaders

solar coyote
#

I want rely only on AI ability to detect BLUFOR to reveal them

obsidian kiln
#

i think your only option is to make AI local to the server and just hideobject for zeus

solar coyote
#

I'm starting to think its the onky option. A3 engine seems to be incapable of that what i want

#

What hapens to AI local to player when he dc?

obsidian kiln
#

goes to the server

#

i think ai local to the server is not a bad option

#

since AI local to zeus will act wrong and slow

#

and it will be messy to deal with in a rts type of game

#

also make sure to run disableAI autocombat on all the units that zeus controls so he can actually move them in a firefight

solar coyote
#

Is in vanilla zeus missions AI placed local to server or to zeus?

obsidian kiln
#

im not really sure

#

i think it's local to zeus

#

all units that are remote controlled become local to zeus though

#

all units spawned in zeus if there is no other scripts are local to zeus

solar coyote
#

Makes scence

obsidian kiln
#

but units from the editor added to zeus... i think they are local to the server

#

but that was before setgroupowner

#

nowadays you can use that to switch ai locality without losing things like waypoints or AI target info

solar coyote
#

Neat

obsidian kiln
#

from my tests it's always better to have the AI on the server

#

or to a HC that's in LAN with the server

#

otherwise you run into bad hit reg, sniper riflemen AI

#

bad fps for everyone

solar coyote
#

I might just pass AI to non Zeus players in hosted situations. Poor souls will have to lift all that weight

eager prawn
#

Anyone know of a way to filter an array of objects based on height (create an array of all objects in an array if they are between elevation x and elevation y?)

ruby breach
eager prawn
#

@ruby breach I was hoping for a more convenient way than selecting everything and putting it one by one into a new array. Is there no other function that could do this?

robust hollow
#

the alt syntax of select would be easiest tho.

#

*alt 5

eager prawn
#

Yeah that's what I'm looking at rn

robust hollow
#
allMissionObjects "" select {
    private _z = getPos _x select 2;
    _z > 5 && _z < 10
}

something like this you know?

eager prawn
#

Yeah - so what I'm really trying to do is make a more accurate version of loading all objects in a cargo aircraft

#

So you carry/drive everything on

#

when you drop it, it autoattaches by the aircraft doing findnearobjects, attaches, etc

#

I'd like to make it so it doesn't grab anything from outside by ensuring that the objects it finds are at cargo deck height

#

Alternative would be to define some sort of box around the aircraft hold and define offset limits, but that just seems like a lot of trial and error lol

queen cargo
#

what exactly is the problem with findnearobjects?

#

or nearestObjects

eager prawn
#

Say you have a car parked next to the aircraft

#

car gets attached to aircraft

#

even if it's not inside

#

because nearobjects uses a radius, not a sector

#

and nearestobjects only returns one, so u could only load one at a time

queen cargo
ruby breach
#

nearestobjects does not return 1 object

queen cargo
#

also, specify what exactly you try to archive

eager prawn
#

nearestobject*

queen cargo
#

attach stuff into cargo? what?

eager prawn
#

attach everything that is in the cargo hold, yeah

queen cargo
#

to what? and why?

eager prawn
#

but without any of the scroll menu crap - writing it with the ACE framework so that when you drop something, it autoattaches, and when you pick it up, it disattaches

queen cargo
#

what you say literally is missing 90% of the information

#

what you attach where automatically when you pick somethiong how up?

#

also, vehicle cargo is not managed via some attach stuff but via xxxVehicleCargo commands

eager prawn
#

I believe I said it - but,

What: Vehicles, boxes, entities, etc
Where: Automatically as in ACE carry feature, if you drop crate it attaches to aircraft if in cargo hold
When: You pick it up with ACE carry feature...

#

The vehicle cargo scripting would not work with this modded aircraft.

queen cargo
#

so you try to create a feature that is horrible by design? you did noticed that most vehicles you cannot walk into?

eager prawn
#

What?

#

Modded aircraft

#

You can walk into it

queen cargo
#

๐Ÿคท so you want to enable it only for a single vehicle

eager prawn
#

A few aircraft, but yes, specifically created for the aircraft that you can walk into.

queen cargo
#

this is how you get the bounding box

#

the script is essentially what you already have been shown

#

just that you should obviously not just take random numbers

#

at best, you check it for the vehicles and adjust as needed

eager prawn
#

That looks interesting, it would be more accurate than just doing findnearestobjects I suppose, but it would still have the problem that the bounding box includes the exterior (vehicles around wings, etc) - I figure the best way would be to filter by vehicles/objects at height of cargo deck

queen cargo
#

chances are btw. that moving vehicles into the other vehicle will destroy said vehicle on drop

#

especially if they do not fit in size

eager prawn
#

Nah, they work

#

I already have this whole script working, it's just not as accurate as I would like. All I'm trying to fix is the accuracy of the object array.

#

And it's not a script for combat drops or anything - just flying supplies from one airfield to another.

#

Just consider it a Fedex Simulator script ๐Ÿ˜†

queen cargo
#
_arr select {
    private _z = getPos _x select 2;
    _z > 5 && _z < 10
}```
as you already have been shown, this is what it more or less comes down
however, in the end it will be the same work as if you would just use a full box simply because this also requires manual adjustment for every thing
eager prawn
#

I'll give it a go, thanks.

queen cargo
#

thus i again, recommend you to draw the bounding box first

#

then continue to adjust it until it fits

#

and use that instead

#

the moment you got the correct box setup

eager prawn
#

Aha, that looks perfect

abstract sinew
#

Hey, need a bit of help updating some scripts from an old Insurgency mission from Arma 2. Somebody else modified and updated it for Arma 3, but that was back in 2013-2014. Now it's severely out of date, seems to have a lot of recursion going on. I'm a rather amateur mission maker (in terms of scripting), I depend heavily on mods and scripts already out there, but have been with the Arma community in general since back in OFP. I made a post about this in #arma3_scenario but unfortunately the text got messed up so I deleted it. Figured here was more relevant anyway.

For context, Insurgency is a gametype where players have to clear areas on the map to find intel that reveals hostile ammo cache positions somewhere on the map that must be destroyed. The scripts of my interest currently are the ones directly responsible for the areas that players need to clear, which are marked as red squares, and only in these red areas can can intel spawn. These red square markers spawn only on towns. The intel spawn script seems to run a similar script as the red square script, to find the same data or function, to spawn briefcases and laptops inside or outside buildings, walls etc.

Here's the problem: Both the red marker script that tries to find towns has variables that I'm unable to or don't know how to adjust, thus leading to a town like elektro barely having any red markers, and the spawn intel script is in fact supposed to spawn intel off of enemies killed in these red areas, instead of spawning them on/inside buildings.

Here's a sample of what the script puts on Elektro: https://cdn.discordapp.com/attachments/279085450608771072/487210344973074437/unknown.png

#

The scripts are as follows, hopefully this formats right:

`_cities = call SL_fnc_urbanAreas;

{

_markers = [];
_markers_cnt = 0;

_cityName = _x select 0;
_cityPos = _x select 1;
_cityRadA = _x select 2;
_cityRadB = _x select 3;
_cityType = _x select 4;
_cityAngle = _x select 5;

if(_cityRadB > _cityRadA) then {
    _cityRadA = _cityRadB;
};

_buildings = [_cityPos,_cityRadA] call SL_fnc_findBuildings;

{

    if ( [_x] call SL_fnc_buildingPositions >= 2 ) then {


        _pos = _x call getGridPos;
        _mkr = str _pos;

        if (getMarkerPos _mkr select 0 == 0) then {
            _mkr = createMarkerLocal[_mkr, _pos];
            _mkr setMarkerShapeLocal "RECTANGLE";
            _mkr setMarkerTypeLocal "SOLID";
            _mkr setMarkerSizeLocal [50,50];
            _mkr setMarkerColor "ColorRed";
            _mkr setMarkerAlphaLocal 0.8;

            _markers set [_markers_cnt, _mkr];
            _markers_cnt = _markers_cnt + 1;
        };

    };


} forEach _buildings;

_trigE = createTrigger ["EmptyDetector", _cityPos ];
_trigE setTriggerActivation ["WEST", "PRESENT", false];
_trigE setTriggerArea [_cityRadA, _cityRadA, 0, false];
_trigE setTriggerStatements ["this", format["%1 call SL_fnc_createTriggers",_markers], ""];

} forEach _cities;`

#

and the other one is a bit bigger, so I'll make two posts

#

`SL_fnc_urbanAreas = {
private ["_locations","_cityTypes","_randomLoc","_x","_i","_cities"];
_i = 0;
_cities = [];

_locations = configfile >> "CfgWorlds" >> worldName >> "Names";
_cityTypes = ["NameVillage","NameCity","NameCityCapital"];

for "_x" from 0 to (count _locations - 1) do {
    _randomLoc = _locations select _x;
    // get city info
    private["_cityName","_cityPos","_cityRadA","_cityRadB","_cityType","_cityAngle"];
    _cityName = getText(_randomLoc >> "name");
    _cityPos = getArray(_randomLoc >> "position");
    _cityRadA = getNumber(_randomLoc >> "radiusA");
    _cityRadB = getNumber(_randomLoc >> "radiusB");
    _cityType = getText(_randomLoc >> "type");
    _cityAngle = getNumber(_randomLoc >> "angle");
    if (_cityType in _cityTypes) then {
        _cities set [_i,[_cityName, _cityPos, _cityRadA, _cityRadB, _cityType, _cityAngle]];
        _i = _i + 1;
    };
};
_cities;

};

SL_fnc_findBuildings = {
private ["_center","_radius","_buildings"];
_center = _this select 0;
_radius = _this select 1;
_buildings = nearestObjects [_center, ["house"], _radius];
_buildings;
};`

#

`SL_fnc_buildingPositions = {
private ["_cbpos"];
_house = _this select 0;
_cbpos = 0;
for "_x" from 1 to 100 do {
if (format ["%1",(_house buildingPos _x)] != "[0,0,0]") then {
_cbpos = _cbpos + 1;
};
};
_cbpos;
};

getGridPos = {
private ["_pos","_x","_y"];

 _pos = getPosATL _this;
 _x = _pos select 0;
 _y = _pos select 1;
 _x = _x - (_x % 100);
 _y = _y - (_y % 100);
[_x + 50, _y + 50, 0]

};

SL_fnc_createTriggers = {
private ["_markers","_pos","_trigE"];

{
    _pos = getMarkerPos _x;
    _trigE = createTrigger ["EmptyDetector", _pos ];
    _trigE setTriggerActivation ["ANY", "PRESENT", false];
    _trigE setTriggerArea [50, 50, 0, true];
    _trigE setTriggerStatements ["{(side _x) == east} count thisList == 0 AND {(side _x) == west } count thisList >= 1", format["""%1"" setMarkerColor ""ColorGreen"";",_x], ""];

} foreach _this;

};`

#

`SO_fnc_randomCity = {

private ["_randomLoc", "_cityName", "_cityPos", "_cityRadA", "_cityRadB", "_cityType", "_cityAngle", "_cityTypes","_found"];

_cityName = "";

// Stuff we need
_locations = configfile >> "CfgWorlds" >> worldName >> "Names";
//_cityTypes = ["Name","NameLocal","NameVillage","NameCity","NameCityCapital"];
_cityTypes = ["NameVillage","NameCity","NameCityCapital"];
_found = 0;


while { _found == 0 } do {

        _randomLoc = _locations call BIS_fnc_selectRandom;

        // get city info
        _cityName = getText(_randomLoc >> "name");
        _cityPos = getArray(_randomLoc >> "position");
        _cityRadA = getNumber(_randomLoc >> "radiusA");
        _cityRadB = getNumber(_randomLoc >> "radiusB");
        _cityType = getText(_randomLoc >> "type");
        _cityAngle = getNumber(_randomLoc >> "angle");

    if (_cityType in _cityTypes) then { _found = 1; };
};

[_randomLoc, _cityName, _cityPos, _cityRadA, _cityRadB, _cityType, _cityAngle];

};

SO_fnc_findHouse = {

private ["_found","_houses","_house","_cpos","_range","_bpos"];

_cpos = _this select 1;
_range = _this select 2;

_houses = nearestObjects [_cpos, ["house"], _range];
_houses;

};`

#

If this isn't the right place, please inform me.

#

What I'm trying to get it to do is two-fold. Part 1: Get more areas covered in Red Square Markers, I don't understand it's current detection algorithm for where it's placing the markers right now, but I need it to be looser, and place them pretty much anywhere there's a building, enterable or not, civilian or not. Part two: Any "east" hostiles in these red areas, when killed should have a chance to drop/spawn intel in the form of a suitcase/laptop, etc. (Instead of intel being spawned at buildings/near buildings.)

The intel script is separate, but I can link/upload/direct copy+paste it. I'm not sure what the established practice is here. If anyone could read through and help with this, it'd be greatly appreciated. I have only an inkling of an idea of what I need to do.

still forum
#

@abstract sinew please just pastebin big scripts... Also use
```sqf
<script>
```

If you wanna paste scripts

#

What first meets my eye is the overload of crappy private ARRAY and the missing params

abstract sinew
#

Let me know how else I could help. @still forum

still forum
#
    _cityName = _x select 0;
    _cityPos = _x select 1;
    _cityRadA = _x select 2;
    _cityRadB = _x select 3;
    _cityType = _x select 4;
    _cityAngle = _x select 5;

-> _x params ["_cityName", "_cityPos", "_cityRadA", "_cityRadB", "_cityType", "_cityAngle"]

#

use private _var = stuff when you declare NEW variables.

#

private ["_locations","_cityTypes","_randomLoc","_x","_i","_cities"]; remove that completely and just write private before the variable names when you create them the first time

#
            _cities set [_i,[_cityName, _cityPos, _cityRadA, _cityRadB, _cityType, _cityAngle]];
            _i = _i + 1;

->
_cities pushBack [_cityName, _cityPos, _cityRadA, _cityRadB, _cityType, _cityAngle]

#
SL_fnc_findBuildings = {
    private ["_center","_radius","_buildings"];
    _center = _this select 0;
    _radius = _this select 1;
    _buildings = nearestObjects [_center, ["house"], _radius];
    _buildings;
};

->

SL_fnc_findBuildings = {
    params ["_center", "_radius"];
    nearestObjects [_center, ["house"], _radius]
};
#
getGridPos = {
    private ["_pos","_x","_y"];
 
    _pos = getPosATL _this;
    _x = _pos select 0;
    _y = _pos select 1;
    _x = _x - (_x % 100);
    _y = _y - (_y % 100);
    [_x + 50, _y + 50, 0]
};

->

getGridPos = {
    (getPosATL _this) params ["_x", "_y"];
    _x = _x - (_x % 100);
    _y = _y - (_y % 100);
    [_x + 50, _y + 50, 0]
};
#

in SL_fnc_createTriggers you have _markers in your private but that doesn't even exist

#

SO_fnc_findHouse is exactly the same as SL_fnc_findBuildings besides that it ignores the first parameter

abstract sinew
#

This is not my scripting work. It's some scripts from written back in 2013-2014, updated from an old arma 2 mission by somebody else. That context I wrote in #arma3_scenario last night but it got messed up and I forgot to rewrite it for this post.

still forum
#

Well sorry but I just skipped past your huge wall of text.

abstract sinew
#

Understandable.

#

My apologies, I'm trying my best not to be ignorant and learn what I need to do to create a better mission. I appreciate all the help.

quasi rover
#

how to insert code <execute expression="Code to execute">Text</execute> to hyperlink website url in createDiaryRecord ?

still forum
#

Get more areas covered in Red Square Markers, I don't understand it's current detection algorithm for where it's placing the markers right now
Currently areas are placed at locations. Locations are hardcoded into the map. You'd really need to rewrite the whole algorithm to get something different out of it

abstract sinew
#

It's not even covering the whole city. Some smaller cities have one or two grids, and that's it. Meanwhile a whole bunch of blocks next to them have buildings. But because these don't fall within the algorithm for whatever reason, it won't spawn intel nor make a red marker.

I need to know how to increase the area, or radius, from the city name/location, that it searches for buildings or calculates into it's algorithm, or make the parameters looser for what it considers acceptable as creating a marker for. Because currently, if I understand it correctly:

        _cityRadA = _cityRadB;
    };

Means that it calculates certain areas to be too big to fit into it's algorithm, and

Is dictating that the marker can only be created in the area the algorithm deems a certain size.

#

I'm sure I must be missing something, and I'm just too inexperienced to understand what must be done.

still forum
#

if ( [_x] call SL_fnc_buildingPositions >= 2 ) then { That line I'd say. That counts AI positions in buildings

#

Only counts enterable buildings and only if there are more than 2 positions

#

You can just remove that if/then check. And EVERY building will get a marker. Even if no AI positions inside it

abstract sinew
#

Thanks, much appreciated. I will try it.

hollow thistle
#

Insurgency creates dozens of triggers? Doesn't this kill performance?

abstract sinew
#

So far as I've seen, the performance drop is manageable if the ALiVE modules aren't spawning insane amounts of AI. I'll be looking out for performance issues much as I can, and if things don't work out, I'll keep an eye out for alternatives.

frigid raven
#

I would like to write a script where the player goes into a jail building (via teleport) if he shoots friendlies. A 24h Cooldown will release him when playing on a server. Does this sound trivial to implement? Rejoining the Server should have the player still in the prison.

Question here is, do players have some kind of ID to recognize them regardless of connection. The thing how whitelisting does work?

References to wikis describing exactly this would help a lot. Cannot google for it since I do not find the right terms/keywords

hollow thistle
#

save this in some array along the remaining "jail time" in profileNamespace.

meager heart
#

or create global namespace and store your variables there

queen cargo
#

Or just use Profile namespace

errant jasper
#

Yeah, you want persistent storage (such as profile namespace) in case server/mission restart.

meager heart
#

btw i think there was a lot of "jail" scripts...

errant jasper
#

But you still need an extension to get the real date

meager heart
#

to make it real persistent probably db is de wey ๐Ÿ˜ƒ

queen cargo
#

Profilenamespace...
No need for DB @meager heart

#

Not even the crap life does requires DB

meager heart
#

yeah.. but what if you will set X39.vars.Arma3Profile file properties to "read only" ๐Ÿค”

still forum
#

Can't go to jail anymore ยฏ_(ใƒ„)_/ยฏ

meager heart
#

tadam

tough abyss
#

What if you set it server side ๐Ÿค”

meager heart
#

imo that is the only way ^ but with namespace, or db for real persistence

still forum
#

What if you set it HC side? ๐Ÿค”

tough abyss
#

What if someone crashes HC on purpose ๐Ÿค”

meager heart
#

sounds like we are not safe anymore... ๐Ÿ˜ฎ

#

hides

queen cargo
#

@meager heart Server also has profilenamespace

meager heart
#

yeah... probably better option then client one

frigid raven
#

profileNamespace rly sounds interesting - thx buddies

#

I am not keen with server side scripts just yet. What do I need to do to have it on the server side?

#

simply the if(isServer) stuff? nah eh?

still forum
#

Your script has to execute serverside..

#

If it executes everywhere you can use if (isServer) to prevent your code block from running on clients

#

but if your script doesn't run on server at all then if (isServer) won't do anything

#

init.sqf or initServer.sqf run on server for example

frigid raven
#

init.sqf is executed automatically on the server? Without need to calling it explicitly? Simply because of the naming convention?

still forum
#

yes

frigid raven
frigid raven
#

meh feel noobish

#

awesome docs thank you

unborn ether
#

Tip of the day: never use persisent in the same phrase with profileNamespace

late gull
#

guys, it's that ok?

cursorTarget isEqualTo player
#

to check if the cursor target it's a player? :p

#
isPlayer cursorTarget
errant jasper
#

Both are fine, but they don't do the same

late gull
#

i want to check if the target it's a player

#

to execute an action

errant jasper
#

You want the second one

late gull
#

oki

still forum
#

it's a player? :p no
The second one yes. First checks if cursorTarget is local player.

errant jasper
#

Can't remember, but you may also want to look into cursorObject

#

One of them requires you to "know" about the target. So you have to reveal them, which can be annoying.

late gull
#

it's better cursor object?

errant jasper
#

I think cursorObject is the one that does not care what you "know".

still forum
#

correct

#

but cursorObject is ultra accurate. You have to really aim onto the object and not just slightly near it

errant jasper
#

Also you may want a distance check too. Believe both have pretty good distance, at least 50m.

#

Don't know what you are doing, but you might want to look into just using an action.

late gull
#

doing that

#
player addAction ["<t color='#ff6b00'> -- QUITAR ARMAS</t>", {
    [] spawn YEIIJ_fnc_DYWSearchForWeapons;
}, nil, 0, false, false, "", "(side _originalTarget isEqualTo WEST) && (isPlayer cursorTarget)", -1, false, "", ""];
#

is an action for the "cops"

errant jasper
#

Use isPlayer _target instead

#

Then you can avoid having to be laser-accurate as Scriptmen says.

still forum
#

no _this is the unit that's trying to execute the action

late gull
#

it works like that

still forum
#

_target is the target

errant jasper
#

Ah, yeah my bad

late gull
still forum
#

cursorTarget works too. Because the action object needs to be on your cursor to show the action.

late gull
#

i think _target wont work in this case

still forum
#

_target == cursorObject

late gull
#

_target: Object - the object to which action is attached or, if the object is a unit inside of vehicle, the vehicle

still forum
#

It won't work if a AI tries to execute that action though. Because cursorTarget is your target

#

if you aim onto a vehicle then cursorTarget will also be the vehicle

#

Ahh the action is attached to the player ๐Ÿค”

late gull
#

yes, to the "cop" (west)

still forum
#

side _originalTarget isEqualTo WEST is equal to side player isEqualTo WEST then

#

And you can just check that one before adding the action. No reason to add the action to civilians or such if that condition can never be true

late gull
#

true, this is for test

errant jasper
#

I mean you can remove the condition completely and only add it for player if side is west.

late gull
#

i will include this into Altis Life :p

errant jasper
#

Though, you may have an edge condition if side of player changes during gameplay.

late gull
#

thx for info and suggestions guys ๐Ÿ˜ƒ

#

btw

#

i have my addon in server side

#

so the addon has the function YEIIJ_fnc_DYWSearchForWeapons;

#

and the action it's in client side, inside the mission

#

my "solution" was doing publicVariable "YEIIJ_fnc_DYWSearchForWeapons";

#

any suggestion on that?

#

it's that the correct way?

gray summit
still forum
#

I personally would use CBA_missionTime. Which is obviously CBA and thus modded

gray summit
#

k ty will take a look

tough abyss
#

@late gull i suggest you read documentation on player

#

because it may not behave the way you think it does in MP environment

#

you may be best off using

([switchableUnits, playableUnits] select isMultiplayer);```
errant jasper
#

Here is a quick attempt at time (that will be offset my the latency), same approach as CBA except only for multiplayer. It is untested:
https://paste.ee/p/l7q9b

meager heart
tough abyss
#

pastebin has SQF highlighting as well if that's what you're referring to

meager heart
austere granite
#

Sharex also supports it ๐Ÿ˜ƒ

#

can't set the default upload syntax for it though, can't do that either with github but pastebin supports that

#

ah autodetect works for SQF on paste.ee, nice

meager heart
#

full screen mode also

shadow sapphire
#

How might I run a gear script for an entire editor placed group from just the group leader's init field?

So rather than execVM "Gear\AAF.sqf"; in every unit's init field, just have that neatly in the group leader's init field.

tough abyss
#

don't use execVM

#

make a function

shadow sapphire
#

That's not helpful.

tough abyss
#

i wasn't finished but i guess i'm not being helpful enough

#

so i'll leave you to your devices

digital hollow
#

Pass the group leader in the arguments and use units group _groupLeader to loop through all the units.

still forum
#

Your question is also not helpful at all

#

Are they players?

#

There are no arguments to your execVM that doesn't make sense

shadow sapphire
#

Ampersand solved the issue.

digital hollow
#

Vauun and Dedmen are raising valid points though =)

still forum
#

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

tough abyss
#

execVM compiles the file when you tell it to during the game, which may cause performance problems

#

pre-defined functions are compiled when the mission is started afaik

still forum
#

at preInit

tough abyss
#

yeah

#

saves on performance

shadow sapphire
#

It's an incomplete script in a testing environment, it will be adapted to a function when it's time.

tough abyss
#

and with arma 3 you need to fight for every frame

#

it takes 2 seconds to make a function but ok

#

even still you have debug console ยฏ_(ใƒ„)_/ยฏ

meager heart
#

it takes 2 seconds to make a function but ok
sometimes it takes few month ((ใคยฐ_ยฐ)ใค๐Ÿ’Š)... /s

unborn ether
#

Arma takes lifes.

#

Sounded strange

high marsh
#

๐Ÿ”ซ ๐Ÿ’€

unborn ether
#

Woah no spam in scripting?

tough abyss
#

So im coming from Arma 2. Did a lot of custom vehicles using attachto commands. The attached objects never had any physics when the main object moved. Theyโ€™d clip through walls and bullets would pass through. Do think itโ€™s changed at all and handled better? Would the attached objects have a โ€œskeletonโ€?

young current
#

attached objects handle pretty much the same as they have always done

#

excessive use of it is not adviced

#

and what do you mean by skeleton?

#

they are the objects they are

#

and if they have animations etc those can work

tough abyss
#

Why excessive use not advised? Server drain?

#

Modeled objects have a skeleton, like it architecture that abides by the physics in game. I get some errors on the server from some mods and their lack of skeleton or something to@that effect.

young current
#

if an object is done correctly then it should have a skeleton too. Cant say about your mod objects though, not all people create stuff correctly.

#

attachto and skeletons are not related

tough abyss
#

Ok well@forgive me I donโ€™t know the proper way to articulate this exactly. But again, why advise against using a lot of attachto objects?

young current
#

no need to take offence, I just clarified the non relation. depends on what kind of other stuff you run but yes they can cause network strain.

#

but you will notice if there are problems so try it out

tough abyss
#

not offended friend. Thanks for your time. Iโ€™ll do a little experimenting.

unborn ether
#

@tough abyss Easy experiment, attach an object, to your unit which has a few more attached objects like 1-2-3-4. Then move on your MP server - see it die.

#

Creating a chains like 1-2 only will not kill a server, but still not good to use.

#

So less attachTo - better.

gray summit
#

@tough abyss 2010 bug, dont get any hopes up. I'm aware of the timeframe where its ureliable

tough abyss
#

Is there a way to get all IDDs and IDCs used the by the game (including some addons)?

winter rose
#

@unborn ether less chained attachTo right?
if I were to make a battle bus, everything would be relative to the bus itself, not relative to object relative to object relative to(โ€ฆ) ?

meager heart
hidden topaz
#

Is there still a limitation of not being able to set the animation phase of mainGun and mainTurret?

meager heart
#
_tank doWatch (_target getPos [0, _tank getDir _target]);
```๐Ÿค”
tough abyss
#

@hidden topaz if it is limited in config then yes, UGV is not limited like that

neon snow
#

Could worldToScreen be affected by something from the aircraft config? I am asking becouse with jet starting to move the returned position shifts

hidden topaz
#

@tough abyss _vehicle animateSource["mainGun", rad 15]; That doesn't work on any vehicle ive tried; even the UGV. Is there other ways of setting gun elevation of a player controlled vehicle ?

tough abyss
#

You can always put AI in vehicle order it to aim at something then remove AI

meager heart
#

afaik if the turret config class don't have > animationsource with > source="user" type, there are no way to animate it with the scripts

winter rose
#

@meager heart I meant performance-wise, what is killing servers

meager heart
#

never tested that ^ i can't say something about it with 100%, Lou ๐Ÿคท

hidden topaz
#

That UGV example did work, Ill try play with the animation sources and see if that does anything, Cheers @tough abyss and @meager heart

meager heart
#

gl

slim trout
#

Hi. Got a question. Im figuring out the CBA's scheduler environment. I wrote my own function and i want to call it via the earlier mentioned CBA_fnc_waitAndExecute;. Is it even possible to run functions inside functions? Im having issues understanding the example provided by CBA.

[{player sideChat format ["5s later! _this: %1", _this];}, ["some","params",1,2,3], 5] call CBA_fnc_waitAndExecute;

still forum
#

CBA's scheduler environment it not being scheduler at all is the most important feature of it ๐Ÿ˜„

#

Is it even possible to run functions inside functions? The command for that is called call

slim trout
#

https://pastebin.com/3dPAAsE6

If i do it like that, it doesn't work. I think i misunderstood something somewhere. That's my fn_suppresiveFire.sqf file.

still forum
#
private ["_unit", "_target"];
 
_unit = param[0]; // _this select 0
_target = param[1]; // _this select 1

->
params ["_unit", "_target"]

#

Also you need to take the parameter inside the function

#

your _unit is undefined

slim trout
#

ignore the double "call", copy paste typo. Yeah - taking the parameters inside the CBA's function is my main problem

still forum
#

Everything that's now executed "right now and right here" your variables don't automatically carry over

#

because these are always new script instances

cosmic lichen
#

Has anyone got an idea why cbChecked always returns false? ```private _display = findDisplay 190000;
private _window = ctrlChecked (_display displayCtrl 1409);
private _hide = ctrlChecked (_display displayCtrl 1410);
private _unconscious = ctrlChecked (_display displayCtrl 1411);

systemChat str _hide;
systemChat str _window;
systemChat str _unconscious;```

#

The checkbox eventhandler returns the state correctly.

still forum
#

You are confusing.. You are asking about cbChecked but post code with ctrlChecked

cosmic lichen
#

oh fuck

#

Never code in the middle of the night...

still forum
#

always code in the middle of the night

#

But you need to change your sleep rythm around

slim trout
#

array container in a separate .sqf, Scriptmen?

cosmic lichen
#

And how do I explain that to my employer?

still forum
#

That question doesn't make sense in my brain. Can you rephrase that?

slim trout
#

i think i don't understand it at all myself.

#

[[[_unit, _target] call ADI_fnc_suppresingFire]; [_unit,_target], 7] call CBA_fnc_waitAndExecute; ?

still forum
#

no

#

code is wrapped in {}

#

and I already told you what you need to do

#

and even if you wrap that in {} your _unit and _target would still be undefined

slim trout
#

I guess my knowledge is too small yet to understand what you're trying to explain to me. I'll have to do more research and take a step back on complexity.

still forum
#

yeah you don't even have the basics.. You shouldn't start with "advanced" CBA stuff

meager heart
#

@cosmic lichen there was some weirdness with controls groups (like always lol) and ctrlChecked/ctrlSetChecked
it returns/sets only the first control "state"... so > ctrlEH on/CheckBoxesSelChanged ๐Ÿคท

slim trout
#

But Im saving our conversation to come back later to. Still, thanks for the help, Scriptmen.

velvet merlin
#

how to detect if a vehicle lays sideways or is 40-60 up in the air by its barrel?

still forum
#

There is a BIS function wit... BIS_fnc_pitchBank I think. Dunno if that is a getter or setter

velvet merlin
still forum
#

essentially get upvector and do math

#

and the angle of the surface beneath it.. There is a command for that

velvet merlin
#

trying via
surfaceNormal getPos ct
vectorup ct

tough abyss
#

there's a getter and a setter

velvet merlin
#

ty

meager heart
#

maybe just

vectorUp _vehicle select 2 < 0
```need some offset there ^... ๐Ÿค”
velvet merlin
#

current design works alrightish. suggestions to improve are welcome

#

if (((getPos _vehicle) select 2) > 3) then
{
    _vehicle setPos [(getPos _vehicle) select 0,(getPos _vehicle) select 1,0.1];
    _vehicle setVelocity [(((velocity _vehicle) select 0) * (sin (direction _vehicle))),(((velocity _vehicle) select 1) * (cos (direction _vehicle))),0];
}
else
{
    if (((velocity _vehicle) select 2) > 5) then
    {
        _vehicle setPos [(getPos _vehicle) select 0,(getPos _vehicle) select 1,((getPos _vehicle) select 2) - 0.1];
        _vehicle setVelocity [(((velocity _vehicle) select 0) * (sin (direction _vehicle))),(((velocity _vehicle) select 1) * (cos (direction _vehicle))),((velocity _vehicle) select 2) - 0.1];
    }
    else
    {
        if ((((vectorUp _vehicle) select 2) < 0.3) || ((abs ((_vehicle call BIS_fnc_getPitchBank) select 1)) > 60)) then
        {
            _vehicle setVectorUp [((vectorUp _vehicle) select 0),((vectorUp _vehicle) select 1),((vectorUp _vehicle) select 2) + 0.1];
        };
    };
};```
still forum
#

suggestions to improve don't call getPos a bazillion times if you really only need it once

#

[(getPos _vehicle) select 0,(getPos _vehicle) select 1,((getPos _vehicle) select 2) - 0.1];
->
(getPos _vehicle) vectorAdd [0, 0, -0.1]

#

you can use also use (getPos vehicle) params ["_x", "_y" ,"_z"]

#

vehicle setVectorUp [((vectorUp _vehicle) select 0),((vectorUp _vehicle) select 1),((vectorUp _vehicle) select 2) + 0.1];
-> vehicle setVectorUp ((vectorUp _vehicle) vectorAdd [0, 0, 0.1])

neon snow
#

Just wondering is there a way to see codes of ARMA vanilla scripting Commands? Asking becouse worldToScreen doesnt work well with modelToWorldVisual

still forum
#

They are not scripts

neon snow
#

Sorry my bad

still forum
#

no you can't. But you can read the wiki

#

What does doesnt work well mean?

neon snow
#

When used together in some aircraft for example, when the aircraft starts to move, modelToWorldVisual gives correct values as it is executed in render time scope. When these values are then converted using worldToScreen it only works correctly as long as vehicle doesnt move. If it moves worldToScreen introduces shift to those coordinates . The example I am talking about is interaction with cockpit

tough abyss
neon snow
#

@tough abyss thank you very much for that ๐Ÿ˜ƒ

frigid raven
#

Within my init.sqf I want to execute other .sqf scripts to declutter the init.sqf itself. I know there are many ways to do so (right?) but am not sure what is the proper one.
The scripts being called are also init type scripts like adding event handlers and stuff.

still forum
#

execVM
cfgFunctions
call

frigid raven
#

I found this fn CBA_fnc_addWeapon and wonder why it should be preferred to the addWeapon command? I would guess it is because the CBA fn is not prone to error if the weapon or unit does not exist...where the addWeapon command would simply throw and error?

And... should I always prefer CBA functions?

still forum
#

command would simply throw and error? no. It would do nothing if you pass a nullobj

#

should I always prefer CBA functions? There isn't a CBA function for every engine command

#

CBA functions are made to make some specific use cases easier

frigid raven
#

yea but if there is one... would you prefer using it?

still forum
#

Just look at it

#

do you need that? use it. If you don't need it, don't use it.

frigid raven
#

Ah sry I did not realized there comes some special functionality with it

#

like dropping the item on the ground if iventory is full etc.

still forum
#

Otherwise it wouldn't make sense at all to be a function

#

There are some functions without special functionality. But these only exist because they were made when the script command for that didn't exist and they only exist now for backwards compatibility with 5 year+ old mods.

frigid raven
#

aye aye

tough abyss
#

@frigid raven you should avoid using init.sqf

#

what are you putting in it?

#

there's almost no reason you should be using init.sqf over initServer.sqf and initPlayerLocal.sqf

frigid raven
#

@tough abyss I see. So it is always better to have the scripts executed by those CfgFunction hooks like PreInit etc.?

tough abyss
#

wat

#

no, you can put code in init files fine

#

but the reason i don't suggest using init.sqf is because it executes every time a JIP joins

#

if you want something that needs to be local to the player, use initPlayer.sqf

#

else you can just use initServer.sqf for all server stuff

#

missionFlow.fsm master race

neon snow
#

Can I disable and enable Radar via script?(I mean like CTRL+R kind of disable not remove and add)

tough abyss
neon snow
#

It doesnt affect player driven vehicles

frigid raven
#

@tough abyss Ah okay sorry! Btw. when does initServer be executed? because I have an addAction on a NPC unit which I set a variable name. It seems this npc/variable is not set as the initServer script ran. I think I should put this perticular script into PostInit of CfgFunctions?

tough abyss
#

initServer is run after object variables are broadcasted

#

addAction is a local command

#

so you need to execute it globally

#

PARAMETERS HERE remoteExec ["addAction", 0];

#

I think I should put this perticular script into PostInit of CfgFunctions?
nani the fuck what

frigid raven
#

dude relax I am new to this - I am sure I just misunderstand things ๐Ÿ˜„

#

I just was triggered by the description in the wiki: postInit = 1; //1 to call the function upon mission start, after objects are initialized. Passed arguments are ["postInit", didJIP] and they said something like after the objects are inited

tough abyss
#

you're not using a function

frigid raven
#

ah right it is just compiled

tough abyss
#

addAction is a command, not a function

#

functions are collections of commands compiled into a single file

#

they are compiled at preinit (one of the very first things the mission does when it's loaded)

frigid raven
#

alright

winter rose
#

does initPlayerLocal fire on hosting server (playing server)?

meager heart
#

yes

winter rose
#

oooh, great. Thanks!

meager heart
#

if i got it right that weirdness was only with init.sqf and that was looong time ago

cosmic root
#

Are there any commands to interact with polyline markers yet?

fringe yoke
#

I wish

sterile jolt
#

brett, im kinda board wana test you mission together? kust wondering

fringe yoke
#

I'm actually not creating a mission, working on a HUD mod and just testing the mod

sterile jolt
#

basically would you like to play together, im board.

fringe yoke
sterile jolt
#

alright thanks

frigid raven
#

Is there any way to kinda embed a HTML file, which lies within the mission dir into the game as a popup?

unborn ether
#

@frigid raven htmlLoad

frigid raven
#

ah wtf awesome. thx dude

supple vine
#

is there any script I can use to track memorypoint movement via debug console?

frigid raven
#

@unborn ether but there is no way to bring a click on the html page back to the game to execute a script right? ๐Ÿ˜„ just asking

frigid raven
#

is initPlayer.sqf called for players are JIP as well? or only those who are in the lobby at mission start?

tough abyss
#

It is not called for players in the lobby, where did you get that from?

frigid raven
#

Nowhere - I am assuming things to get my head around it

#

Trial and Error ๐Ÿ˜„

#

initPlayerLocal.sqf is the init script I am looking for it seems

#

Where it runs for every player joining the mission

tough abyss
#

It is called for any player joining the mission JIP or not

frigid raven
#

got it

unborn ether
#

@frigid raven RscHTML represents just the HTML page, so no callback to engine is supported, for reasons. If you want to make scripted html, you can just build some GUI around it to simulate some kind of browser, but that's really big monkey work there.

frigid raven
#

yea I thought bout that

#

And I am a big monkey

late gull
#

guys, it's spossible to add hold action to a simple object?

#

and btw, it's possible to spawn p3d model not as simple object?

still forum
#

no

#

no

late gull
#

QQ ๐Ÿ”ซ

still forum
#

ACE is spawning invisible helper objects for where you need interaction on simple objects. Like fences

late gull
#

huh, interesting

#

but, how would i delete the simple object inside the hold action since inside on "completion" you can use only the magic vars huh?

#

will try something

still forum
#

use only the magic vars What? that's not true

#

you can use global vars or I'm sure you get the object inside there. Just store a variable on the object

hollow thistle
#

Is it possible to hack uav via scripting? Will assigning them to group of another side be enough?

#

Eg I assign blufor uav to opfor group, will it be connectable via opfor terminal?

Edit: joinSilent is enough to make the uav connectable for other side.

meager heart
#

also > player setUnitTrait ["UAVHacker", true];

hollow thistle
#

But this needs that you get close to UAV and hack it.

#

I needed to have VLS available to Opfor

meager heart
#

yeah, there will be action "Hack uav"

#

groups then, in your case ๐Ÿคท

hallow nest
#

Could someone help with addon prefix in AB?
(Sorry if it's not the appropriate channel)

still forum
#

"AB" ? "addon prefix" ?

hallow nest
#

Addon builder

#

And relative path to the files in the PBO

still forum
#

Explain your problem

hallow nest
#

Okay
So
I'm working on a SW mod and I was fine without prefixes so far
But now me and the team have lots of files and it would be great if I could get a working addon prefix
There is field in AB for it in the options
If I set up the path, it packs fine and the relative path is working but for some reason, it doesn't binarize the P3Ds then

still forum
#

You need to change the paths in the P3D's as they are absolute paths

hallow nest
#

Where?
The texture and rvmat references?

still forum
#

everywhere where there is a path

hallow nest
#

Every path is set to relative because we are doing tests on a server so there aren't any absolute paths in the files
I use absolute paths when I preview the materials in Buldozer but then I change everything to relative

still forum
#

"relative" doesn't make sense

hallow nest
#

Sorry if I'm confusing

still forum
#

as I said. Paths in p3d's and materials are absolute

#

not relative

#

you can't just make it take a relative path by thinking it should be

hallow nest
#

May I ask what happened?

#

Yeah
I see
Never mind then

#

I will delete it

open vigil
#

๐Ÿ‘

hallow nest
#

๐Ÿ˜•

neon snow
#

How to stop playSound ?
I have this

_dummy = "#particlesource" createVehicleLocal ASLToAGL getPosWorld PLAYER; 
while{alive _dummy}do{
    hint "Playing";
    _dummy say3D "FA18_foldwing_sound";
    sleep 3; //Atleast the length of your sound 
}```
and I am trying to kill it with setDammage but it wont stop playing
still forum
#

particleSource?

#

just delete it

tough abyss
#

PlaySound or say3D?

still forum
#

why are you using a particleSource to play sound? isn't there also a #soundsource?

neon snow
#

hmm didnt know that, just started with sound actually. All I want is script that will play sound in loop until I decide to kill it

#

Will try with soundsource

tough abyss
#

CreateSoundSource will play in a loop

neon snow
#

But I have to define the sound in different place than CfgSounds, correct?

tough abyss
#

Look up wiki it has everything you need and more

neon snow
#

Ok thanks ๐Ÿ˜‰

late gull
#

guys, doing my question again

#

i have functions compiled on server side, how is the correct way to use them on the client

#

i'm doing publicVar "asd_fnc_myFnc"

#

and then in the client i call it normally

#

it's that wrong? is there a better way?

austere granite
#

no, no

#

the way you call functions the best way, is by calling it ๐Ÿ˜„

frigid raven
#

I do not understand the _instigator parameter for a "killed" event. Wiki says instigator: Object - Person who pulled the trigger. When I shoot an AI I assume that my player object would be assigned to _instigator but it is not. isNull _instigator returns true. What am I misunderstanding here? I also tried to be the gunner of a vehicle but same behaviour.

meager heart
#

maybe you added that eh to a player ? ๐Ÿ˜ƒ

frigid raven
#

na I attached it to an npc

meager heart
#

locality issues, maybe

tough abyss
#

Works for me

frigid raven
#

Ok I think the problem is how I try to delegate the "killed" evnet to my event handler

tough abyss
#

IsNull false

frigid raven
#

{_x addEventHandler ["killed", "call X11_fnc_onAiKilled"];} forEach allUnits;

#

I think this is totally wrong eh?

#

how would you guys do this? My first idea was to extract all params and pass them to the X11_fnc_onAiKilled Function

tough abyss
#

No itโ€™s fine

frigid raven
#

But I thought there is a convenient way so I just have to tell the function name and the addEventHandler function would pass them through to the handler func

#

ah really?

#

So this is how I attach the handler to all units available (for testing): {_x addEventHandler ["killed", "call X11_fnc_onAiKilled"];} forEach allUnits;

#

and the handler is actually executed as my log msg tell me

#

but _unit == _killer // true

tough abyss
#

Are you testing this in mp?

still forum
#

_x addEventHandler ["killed", "call X11_fnc_onAiKilled"]; that is actually the perfect way to do it.
You could also _x addEventHandler ["killed", X11_fnc_onAiKilled]; But that would recompile your code everytime the EH is executed and probably wreck performance

frigid raven
#

@tough abyss yea

#

the scripts are invoked by initServer.sqf

tough abyss
#

Where do you observe the output? Locality of AI?

#

Dedicated or hosted?

#

Mission or Eden mp preview?

frigid raven
#

Eden MP preview

#

Wow hope it is not that complicated :/

tough abyss
#

Still canโ€™t reproduce

meager heart
#

X11_fnc_onAiKilled < something there ๐Ÿค”

tough abyss
#

Shut down and restart the game when you exhausted all options

frigid raven
#

Here is the fn_onAiKilled.sqf code

#

private _nameOfKiller = name _killer;
private _isBlueOnBlue = [_instigator, _unit] call X11_fnc_sameSide;

systemChat format ["killer is: %1", _killer == _unit];

if (_isBlueOnBlue) then {
    [playerSide, "HQ"] commandChat "Du hast einen Kameraden auf den Gewissen. Ab ins Cafe Viereck!";
    _killer setPos (getPos prison)
};```
#

Sorry hat no Git url to this yet

tough abyss
#

Whatโ€™s in sameSide?

frigid raven
#

just a convenient func which actually does side _first == side _second with some parameter type guards and defaults

tough abyss
#

Side of killed is always civ

frigid raven
#

... oh?

#

well that's odd

tough abyss
#

You need to compare side group unit

frigid raven
#

hm ok I will try this

neon snow
#

So I have to ask again, how could I stop say3d, say, or playSound instantly from loop?

while {alive _dummy} do
{
_dummy say3D ["FA18_foldwing_sound", 100, 1]:
sleep 4;
};```
I cant use createSoundSource as it makes sound incredibly quiet
#

setDammage _dummy or deleteVehicle _dummy doesnt work

tough abyss
#

Setdamage and deletevehicle both work

neon snow
#

Yeah I just found out, I have a problem with variable acces

tough abyss
#

If you have valid reference object

velvet merlin
#

anyone up for a little scripting challenge:

build a class tree of cfgVehicles showing a parameter has be set the first time (like most are in All, yet some start with AllVehicles/Man/CAManBase/Car/Tank, etc)

this would be quite useful to help commenting all config parameters, finding "unknown" parameters and such

basically a modified config dump script with a slightly different output logic

anyone up for it?

frigid raven
#

Sorry to interrupt your challenge offer but I have to ask a question again ๐Ÿ˜„

#

Consider this keymaster addEventHandler ["killed", {call X11_fnc_onAiKilled;}];

Now I am ingame and shoot the keymaster NPC.
The following handler script is run:


private _nameOfKiller = name _killer;
private _isBlueOnBlue = [group _killer, group _unit] call X11_fnc_sameSide;

systemChat format ["blueonblue is: %1", _isBlueOnBlue];
systemChat format ["killer is: %1", _killer];
systemChat format ["killed unit is: %1", _unit];
systemChat format ["_instigator is: %1", _instigator];

if (_isBlueOnBlue) then {
    [playerSide, "HQ"] commandChat "Du hast einen Kameraden auf den Gewissen. Ab ins Cafe Viereck!";
    _killer setPos (getPos prison)
};```

This is my output on systemChat:

blueonblue is: true
killer is: keymaster
killed unit is: keymaster
_instigator is: <Null>-object

#

now the dead keymaster went into prison ๐Ÿ˜„ that is not cool

winter rose
#

did you kill him by fall or bullets?

#

also, SP or MP :3

still forum
#

did you kill him by fall or bullets? -> Now I am ingame and shoot the keymaster NPC.

#

also, SP or MP :3 -> Eden MP preview

meager heart
#

just tried >

this addEventHandler ["killed", {
    params ["_unit", "_killer", "_instigator", "_useEffects"]; 
    hint str _instigator
}];
```and > https://gyazo.com/b97771db417bc47daac933ff6f293248 ๐Ÿ˜ƒ
winter rose
#

did you kill him by fall or bullets? -> Now I am ingame and shoot the keymaster NPC.
rubbing my eyes indeed

meager heart
#

๐Ÿ˜ƒ

frigid raven
#

gonna try that minimal example as well

#

drums

#

still <Null>-Object

#

ffs

tough abyss
#

Do you run mods?

#

Add handleDamage EH to keymaster so you could see what killed him, if he dies because of suicide then this would explain the weirdness

frigid raven
#

Yea I run ALiVE, ACE3, ACRE2, CBA, CUP and CFP

#

All mods I dont think they would screw up native addEventHandler... but you never know. I gonna try it on a modless environment now

#

and afterwards try your handleDamage analysis

#

works without mods

#

jeez that is not cool

hollow thistle
#
params ["_unit", "_killer"];
if (isNull _killer) then {
    _killer  = _unit getVariable ["ace_medical_lastDamageSource", objNull];
};
#

^ - should "fix" killed EH when running ace medical.

frigid raven
#

interesting - checking it out

frigid raven
#

ok weird well _unit and _killer are still the same. The dead keymaster npc. But _killer = _unit getVariable ["ace_medical_lastDamageSource", objNull]; actually gives me my players object

#

But that is kinda a weird way around. I try the dammaged event as suggested by @tough abyss (you meant keymaster addEventHandler ["dammaged',...] right?) to figure out who is the proxy between the native routine

tough abyss
#

HandleDamage, but you can try dammaged and see if it tells you anything

austere granite
#

Anyone happen to know where the vanilla death effects are? I have a custom scripted switch to a different unit when you die, but I got the shitty vanilla blurred out screen when that happens

unborn ether
#

@austere granite AFAIK if you remove all Killed EVH use your own Killed EVH that doesn't happen.

austere granite
#

I'd really prefer not to do a removeAllEventHandler thing, in regards to compat with other mods

frigid raven
#

Yea I think I want to keep the ace medical system intact

#

But I wonder if there is a deactive for AI - because I have no interest in aid NPCs atm

meager heart
#

death effects there > functions_f\Feedback and VR fx there > functions_f_bootcamp\VR

austere granite
#

It seems like the blur is present in feedbackMain

#

..... does playerKilledScript.sqf not worK?

#

i legit 100% ABSOLUTELY want dying to not do ANYTHING from a vanilla perspective lol

#

i don't waant their retarded templates, i dont want PP, etc

meager heart
#

does playerKilledScript.sqf not worK?
you mean > onPlayerKilled.sqf ?

austere granite
#

playerKilledScript.sqs*

#

i also tried onPlayerKilled.sqf, but that doesn't stop default behavior ๐Ÿ˜ฆ

meager heart
austere granite
#

No thanks, the less BIS code i use the happier i stay

#

I looked into respawn templates when they originally made them, staying far away from them

meager heart
#

no, that will be your code lol

#

90%

#

ish

#
// Function or script executed upon death. Parameters passed into it are the same as are passed into onPlayerKilled.sqf file
onPlayerKilled = "\myAddon\scripts\respawnBeacon.sqf";
// Function or script executed upon respawn. Parameters passed into it are the same as are passed into onPlayerRespawn.sqf file
onPlayerRespawn = "\myAddon\scripts\respawnBeacon.sqf";
austere granite
#

those are unfortunately just additions to other systems

#

no overrides or so

#

playerKilledScript.sqs should do it in theory, but it doesnt appear like it does

frigid raven
#

@tough abyss I used HandleDamage and _source and also _instigator was correctly my player this time

#

So it seems another killed handler is screwing up something eh?

tough abyss
#

No, this is because some mod added HandleDamage EH with override and it screwed default behaviour. By adding another HandleDamage on top you have overridden the last EH so it is back to default. If you keep it and add Killed EH now it should work too

frigid raven
#

yea well but... if this overriding of the HandleDamage EH is done by let's assume ACE medical system - wouldn't my override screw up the whole medic stuff?

austere granite
#

BIS_fnc_feedback_allowDeathScreen should solve the death PP

#

nvm, they just reset it, why allows vars to disable your shit

#

/rant

meager heart
#
if (isNil {player getVariable "BIS_fnc_feedback_respawnedHandler"}) then {
    player setVariable ["BIS_fnc_feedback_respawnedHandler", true];
    player addEventHandler ["respawn", "BIS_respawned = true"];
};
```tried that ^ looks like it works (copypasted from `fn_feedbackInit.sqf`)
tough abyss
#

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

meager heart
#

kinda

austere granite
#
BIS_fnc_feedback_allowPP = false;
[{
    [nil, true] call ada_snek_fnc_unitSwitch;
    BIS_fnc_feedback_allowPP = true;
}, 2] call ada_core_fnc_wait;

in a playerKilledScript.sqs with respawnType = "NONE"; seems to be good

#

(related to my thing, not to your handledamage)

tough abyss
#

TBH the fault is on mod creators, if they mess with damage they can at least setShotParents back to original values

unborn ether
#

@frigid raven According to EVH behaviour - the return of the latest EVH is the only used. Since you do not return anything in your EVH - it doesn't override previous one and don't follow that behavior.

meager heart
#

those vanilla feedbackPP are too stronk lol

#

(probably no way to disable them completely)

austere granite
#

BIS_fnc_feedback_allowPP = all, but i want to keep some of them

#

so just temp turning it off, and then reenabling works to get rid of the death one

meager heart
#

BIS_fnc_feedback_allowPP that's only health

austere granite
#

https://i.imgur.com/x3F70xf.png

Any ideas on this? Even though the group is local to me, when I run selectLeader on myself, it still has a habit of completely fucking up leader status

#

as in, it changes between me and the AI unit in the screenshot about every frame

#

That AI unit is also local to me btw

unborn ether
#

@austere granite AI has an ability to take command (leader) if they are higher rank than you or your group units. Usually that happens on FF and death and they tell that in chat, don't know if that happens to you.

austere granite
#

nah nothing happening outside me pressing that button, not in combat or anything like that

unborn ether
#

๐Ÿค”

austere granite
#

Even if he takes command, shouldn't he keep it till I exec again?

unborn ether
#

Are you sure there is no scripted influence on that?

vernal mural
#

If I want to play a sound locally, with a parameter influencing the volume of the played sound, what command should I use ? playSoubd3D has a volume argument, but it's global. playSound is local but has no volume arg.

tough abyss
#

The volume is in cfgSounds config

austere granite
#

You don't. Best bet would be playSound with the speech syntax and using fadeSpeech, obviously that will influence other things

#

] Demellion Dismal: Are you sure there is no scripted influence on that?
yes

unborn ether
#

Try to create a new group and move all units there, to see if it's not group related.

tough abyss
#

say2D has volume control

vernal mural
#

@tough abyss sound must be played at different volume following an ingame situation. say2D don't seems to have a volume control, only a distance parameter, but I have no object to play sound from. Should I create one specifically for this ?

knotty arrow
#

anyone know how to pause the arma process to execute some checks in c# or other lanaguare

#

language

tough abyss
#

If you donโ€™t return from extension call Arma will freeze until you do if this is what you mean

knotty arrow
#

sooo

#

if i don't return anything to the extension, the game will freeze until i do?

#

we can't stop return anything to the extension

#

is a external exe

#

its a launcher

#

custom launcher

tough abyss
#

@vernal mural you can use player as object and find distance range that you can use to attenuate the sound

knotty arrow
#

@tough abyss

tough abyss
#

No return from extension. Look up callExtension

vernal mural
#

@tough abyss does that imply this syntax [from, to] say2D sound ? If I use player as from, what should I use for to ?

tough abyss
#

No just player say2D ["sound", distance]

#

I tried 1 to 100 m it is ok, usable

frigid raven
#

Is there an event type for entering a marker like a rectangle area?

tough abyss
#

Use trigger with the same shape

austere granite
#

#scriptedevents

frigid raven
#

and how is the event type called? myTrigger addEventHandler ["activated", ... ] ?

tough abyss
#

No just set up a trigger and put your code in on activation

frigid raven
#

Ok I knew that one. But isn't there a way to make this happen outside the editor?

#

I'd like to keep my script code externally

tough abyss
#

Yeah createTrigger

frigid raven
#

hm I see - so no way to make this happen to an already placed one in the editor eh? Well thanks, gonna try this then

tough abyss
#

Yes you can setTriggerStatements

frigid raven
#

@tough abyss sweet thx!

vernal mural
#

@tough abyss I think you are misunderstanding... There is no such use of say2D. And when I try this in editor, as expected the sound is always played with the same volume. The second parameter, according to wiki, is the max distance at which the sound can be heard. This probably imply a volume lowering if an other object (not player) is used.

tough abyss
#

I just literally tried it myself and it worked

#

The distance controls how loud it is, not linear though

vernal mural
#

Well, we have a problem. player say2D ["mySound", 1] is producing the exact same sound effect than player say2D ["mySound", 1000]

#

(having the editor opened right now, and live trying what you said)

tough abyss
#

Try 0.5

#

Sorry my fault say3D

vernal mural
#

well for me, 1, 0.5, 0.1, 0.9, 10, 1000, is always producing the same sound with default volume. Should I mention that the sound is defined in mission config file ? Is the command reacting differently in this case ?

#

ohhh

tough abyss
#

Since you use it on player it doesnโ€™t matter that it is 3D not 2D

vernal mural
#

yeah I see. Indeed the parameter seems to wontrol volume, but I have to use very high numbers to get it to a decent volume. Maybe tweaking the default volume in CfgSounds will help.

#

By the way, thanks for help ๐Ÿ˜ƒ

tough abyss
#

Yeah thatโ€™s what I thought

#

You can make it loud there in config and increase distance as well

undone citrus
#

could someone help me with changing a vehicle's weapons through editor scripting?

vernal mural
#

@undone citrus weapons are defined in the vehicle's addon. I think there is script commands allowing you to "fake" weapons on nearly any vehicle, but it will not trully "add the weapon" to the vehicle (no turret, no gun, etc)

undone citrus
#

yeah that's what i was going for

cosmic root
#

For user created markers the format is

_USER_DEFINED #(NUMBER)/(MARKERINDEX)/(CHANNEL)

Does anyone know what that first number is? It doesn't appear to be the players UID, and it's too large to be clientOwner

meager heart
#

<PlayerID> - unique network id of the player (same as _id in onPlayerConnected)

cosmic root
#

Outstanding, thank you much ๐Ÿ‘Œ

unborn ether
#

@tough abyss It will freeze for~ 2000-3000ms or so and then resume with error saying ...took to long

tough abyss
#

@unborn ether if this true then this must be quite recent

rustic pendant
#

Hi guys! can anyone help me ? If I want to modify a script to play a sound when wearing a helmet what do I have to change here ?

#

waituntil {goggles _player == "Mask_M50" OR goggles _player == "Mask_M40" OR goggles _player == "Mask_M40_OD"};

#

This is from the ricks survival script

#

Do I have to change "googles" for "helmets" and change classnames ?

outer fjord
#

Can you detect what type of ammo hits a target?

cosmic kettle
#

@rustic pendant Depends on what item slot the object is in, I doubt a helmet would be in the goggles slot.
@outer fjord yes, using the Hit EH.

rustic pendant
#

Thanks, I changed googles for headgear and it works with helmets

#

The problem is that the sound goes away when your moving fast

cosmic kettle
#

Yeah, try attaching an object to your player and play it on that.

rustic pendant
#

I was trying to use the breath sound to simuleta the pilots oxygen mask

#

Any object ?

cosmic kettle
#

Yeah, like a redgull can or something, it just serves as a placeholder to play sounds. Not sure if this works for what you're trying to achieve, but I recall I used it for moving sound issues sometimes.

rustic pendant
#

this is what im using

#

_player = _this select 0;

if (isdedicated) exitwith {};

waituntil {headgear _player == "FIR_JHMCS" OR headgear _player == "FIR_JHMCS_II" OR headgear _player == "FIR_ScorpionHMCS"};

while {alive _player AND (headgear _player == "FIR_JHMCS" OR headgear _player == "FIR_JHMCS_II" OR headgear _player == "FIR_ScorpionHMCS")} do {
playsound3d ["A3\sounds_f\characters\human-sfx\other\diver-breath-2.wss", _player,false,getposASL _player, 0.8,1,15];
sleep 5;

        };

null = [_player] execVM "rick_survival\rick_helmet_breathe.sqf";

cosmic kettle
#

tip: use:
```sqf

// code
``` to mark code blocks

rustic pendant
#

So I need to name the object and put it where _player is?ยก

cosmic kettle
#

try:

player say3D _sound;

first.

austere granite
#

Can you script turning on lights? I got my lamposts on disable simulation and would like to keep it that way, however I do have a scripted event for SunOrMoon change, in which case i could loop through my lights real quick and turn them on through a script

#

was looking at the OFP commands which didnt work

frigid raven
#

Just to make things clear:

_unit addEventHandler ["killed", "call X11_fnc_onAiKilled"]; with call
vs.
_unit addEventHandler ["killed", "X11_fnc_onAiKilled"]; //without call

Sb. here told me that it would be bad practice to have this without call because of recompilation of the fnc (if I remember right). Is this true?

frigid raven
#

wait

#

I mean - what is the benefit of "recompiling" the func

#

when used without "call"

#

I do not understand this. Why should I have to "recompile" the func if it is compiled already?

#

Meaning why should I ever use it without a "call"

#

So going with "call" is always a better practice

#

When it is not better... that is what I want to figure out actually

#

I want to be sure to have the right approach in the future

#

Ahh you mean if it makes sense to actually have a func for a given code amount

#

Ok yea sure - Inline code is always better than a func call

#

Just was talking about having the func called with and without the call keyword

#

Ok I see

#

Well thx - things got clearer

#

๐Ÿ‘

late gyro
#

i guess change goggles into helemts

#

oops sry the chat didnt scroll, was responding to an old message

frigid raven
#

๐Ÿ˜„

#

profileNamespace does save stuff on the client machine right? How to bring it to the server, so it cannot be manipulated? Sb. told me a way here few days before. Can not find it anymore ๐Ÿ˜ฆ

#

Also want to keep the information between mission and server restarts. Similar to how DayZ hive is doing it a bit

#

But not that elegant - they use a DB connection I am sure. Don't want to get that far

hollow thistle
#

profileNamespace saves to profile file.

#

If you execute it on server it will be saved on server.

frigid raven
#

Ah alright nice

#

Where is it placed when checking out the server filesystem?

hollow thistle
#

depends how your server is configured.

#

<name>.vars.Arma3Profile

frigid raven
#

Ah fancy!

#

Thanks a heap bud

peak plover
#

@frigid raven B is only better for short stuff

#

The code is recompiled every time it runs

#

I can't find it right now

#

but there was a feedback tracker issue about it

drowsy axle
#

Does anyone have any GUI knowledge that I can pick your brain?

frigid raven
#

@peak plover kk

still forum
#

@frigid raven Sb. here told me that it would be bad practice to have this without call because of recompilation of the fnc (if I remember right). Is this true?
I told that and yes it's true.
Also your code doesn't make any sense. It doesn't work like that.
{X11_fnc_onAiKilled} returns the contents of that variable. It doesn't execute anything.
I mean - what is the benefit of "recompiling" the func There is none.
Why should I have to "recompile" the func if it is compiled already You don't. Arma does.

fossil yew
#

How to hide all elements of HUD for recording purposes (in-game cameraman aka on the field reporter)?

#

showHUD doesn't work completely

digital jacinth
#

try this one here

#

does a bit more then requested,

#

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

fossil yew
#

thanks. I doubt though it will work, it's based on showHUD. But will try

#

stui is relatively easy to hide with ["STHud_Settings_HUDMode",0] call CBA_settings_fnc_set;

digital jacinth
#

hud additions such as STHud/STUI need ot be turned of separately

fossil yew
#

trouble is, last time i checked showHUD did nothing for stamina/stance panels

digital jacinth
#

you are using advanced stamina, correct?

fossil yew
#

yes

digital jacinth
#

yep it is its own display

#

hence why it still renderns

#

check the cba settings for it

fossil yew
#

ok thanks

frigid raven
#

@still forum I thought it kinda acts like a function reference

still forum
#

no.

#

that's what the call func does

#

if you remove the quotes then you grab the functions code and pass it into there and let it be converted to a string

#

and as strings cannot be called. The engine has to compile it first before every execution

round scroll
#

what happens in a script like: ```ttt_toast = {
systemChat "A delicious toast";
};

while {alive player} do {
[] call ttt_toast;
};```

#

is ttt_toast compiled again and again? or not as it is considered code?

still forum
#

no

#

it's code.

#

code doesn't need to be compiled because code is already compiled

round scroll
#

for the mods I usually make ttt_toast a separate file with an entry in CfgFunctions so it is compiled at load time. For missions I often do the functions as above. Thanks for the clarification, @still forum

still forum
#

It's only engine eventhandlers that can only store code as strings

#

and thus need to compile everytime

round scroll
#

so it's more performant to just say "[args] call some_func;" in the event handler than write the verbatim function in the string?

hollow thistle
#

yeah

still forum
#

Leave the [args] away. _this is passed implicitly

hollow thistle
#

As it stores the function on object/missionNamespace it is attached too.

frigid raven
#

that was a insightful discussion ๐Ÿ”ฆ

austere granite
#

hey furry @still forum I think you posted something in regards to gaussian distributions in arma right?

#

like in regards to getting a random pos

still forum
#

commy

austere granite
#

All these blue names are the same

#

Yep that's exactly what i meant, thanks ๐Ÿ˜ƒ

#

That's your page though right?

still forum
#

kinda?

#

It's a github group

orchid saffron
#

Is there any script command to retrieve all vertices of a selection?

#

selectionPosition only returns one, if you have an axis and you want to retrieve both vertices you canยดt

mellow obsidian
#

So I have this to grab 3DEN object placed objects with some of their attributes

params [["_layerID", "ExportLayer"]];

private _array = [];
if (is3DEN) then {
    private _layerIndex = (all3DENEntities select 6) findIf { (_x get3DENAttribute "name") select 0 == _layerID };
    if (_layerIndex == -1) exitWith { _array };
    private _layer = (all3DENEntities select 6) select _layerIndex;
    private _entities = get3DENLayerEntities _layer;

    {
        private _className = (_x get3DENAttribute "itemClass") select 0;
        private _position = (_x get3DENAttribute "position") select 0;
        private _vectorDir = vectorDir _x;
        private _vectorUp = vectorUP _x;
        private _initCode = (_x get3DENAttribute "Init") select 0;
        _array pushBack [_className, _position,_vectorDir,_vectorUp,_initCode];
    } forEach _entities;
};

private _linebreak = toString [13,10];
private _nextLine = "," + _lineBreak;

private _allText = format ["[%1%2%1]", _lineBreak, ((_array apply { "    " + str _x }) joinString _nextLine)];
copyToClipboard _allText;
_array;

But when I have around 70 objects or more I believe copyToClipboard gets maxed out.
Result: https://pastebin.com/RcKTj9kg

Anyone have an idea on how to get around it or fix it?
diag_log is no good either

austere granite
#

diag_log will work for what you need tbh

#

like how many objects do you expect? You could round the positions, having them that accurate is pretty pointless in most cases but that'll only give you a little leeway, otherwise you'd have to split it up in different cycles

still forum
#
{ <code>
        _array pushBack [_className, _position,_vectorDir,_vectorUp,_initCode];
    } forEach _entities;

->

_array = _entities apply { <code>
        [_className, _position,_vectorDir,_vectorUp,_initCode];
    };
#

```sqf
<code>
```

For SQF syntax highlight

#

But when I have around 70 objects or more I believe copyToClipboard gets maxed out. nope.

#

NOTE that output of this command is limited to ~8Kb

#

use joinString to build your string

#

diag_log will work for what you need tbh no it won't

austere granite
#

I'd print it on each line there tbh :p

#

is what i meant

still forum
#

Then you have all the timestamps in the way

austere granite
#

ctrl+A, ctrl+L, left arrow, press delete 4 times

still forum
#

And he didn't say what he needs it for. Maybe he needs it to be clipboard

austere granite
#

save* in a .sqf and then recreate the objects using another snippet of code

still forum
#

private _allText = format ["[%1%2%1]", _lineBreak, ((_array apply { " " + str _x }) joinString _nextLine)];
->
private _allText = _lineBreak + ((_array apply { " " + str _x }) joinString _nextLine) + _lineBreak;

austere granite
#

_allText = "[" + _lineBreak + ((_array apply { " " + str _x }) joinString _nextLine) + _lineBreak + "]";

mellow obsidian
#

Oh look at that, had totally missed that format is limited to 8kb. So used to use it that I never thought about it

austere granite
#

muh bracket

mellow obsidian
#

Hats of to you guys

neon snow
#

Is say2D distance parameter working correctly?

dusky pier
#

hello, i getting problem. In multiplayer i use player addEventHandler["Take",{_this call fnc_onTakeItem}]; but on players is not working, script not starting ๐Ÿ˜ฆ

#

but on my unit is working nice

neon snow
#

Is there a command to lock vehicle control?

errant jasper
#

Terrano, sounds like it is running inside an if (isServer) {...}

dusky pier
#

@errant jasper no is running on client

#
// initPayerLocal.sqf
if (!hasInterface && !isServer) exitWith {};
player addEventHandler["Take",{_this call fnc_onTakeItem}];
meager heart
#

remove that > if (!hasInterface && !isServer) exitWith {};

still forum
#

if (!hasInterface && !isServer)
๐Ÿค”
isDedicated ๐Ÿค”

obsidian kiln
#

!isServer = !false = true so it exitswith nothing

#

same with !hasinterface

high marsh
#

What....?

dusky pier
#

but i use that for headless client is loading functions from his addon

#
if (!hasInterface && !isServer) then {
  execVM "init_HC.sqf";
};```
#

like on biwiki

meager heart
#

initPayerLocal.sqf != init.sqf btw

obsidian kiln
#

nevermind

#

i was wrong

meager heart
#

so in your example >if (!hasInterface && !isServer) exitWith {};
that will works only for local host

#

you are the server and player there, at the same time

high marsh
#

"initPlayerlocal.sqf"

#

if this was in init.sqf it would make a little more sense than not, but the server will never be loacal in the instance of initPlayerLocal.sqf

#

unless your machine is the host. In which case I don't think is going to be the most common

high marsh
#

^

dusky pier
#

@meager heart thank you! I move that code to init.sqf. I use dedicated host for test it. When i connect - it work fine. But when my friends connect to server and trying to take item - is not working for they.

#

@high marsh thank you for information, i will read more about this files on biwiki

high marsh
dusky pier
#

@high marsh ty

meager heart
#

I move that code to init.sqf
move it back

high marsh
#

init.sqf is both client and server.

#

excuted on

still forum
#

executed*

high marsh
#

in, on, with, without, is.

dusky pier
#

as i understand - code for headless client - i need run on init.sqf.

#

i will try now test, idk maybe will work

still forum
#

HC is also a player

#

so initPlayerLocal should run for him

meager heart
#
//--- initPlayerLocal.sqf
if (!hasInterface) then {
    //--- runs on headless client
};
high marsh
#

^ Poifect.

peak plover
#

!hasInterface && !isServer
// everywhere

still forum
#

except self hosted MP server

#

no wait

high marsh
#

isMultiplayerSolo?

still forum
#

ex..no.. uhh

#

yes

peak plover
#

If you do a lot with HC then I find it useful to make an object and set it's locality to the HC.
This way you can always remoteExec to the HC

{myCode} remoteExec ['call',headlessOwnedObject];
#

And this way if HC is not present, the object should be set local to the server

#

So your scripts still run

#

Maybe you'll find it useful ๐Ÿคท

dusky pier
#

thanks all for help, but headless client is working fine

#

i have troubles with event handlers

#
player addEventHandler["Take",{_this call fnc_onTakeItem}];
still forum
#

the _this there is useless (btw)

dusky pier
#

on multiplayer server working only for my client

still forum
#

what does the code do?

#

player is always the local client

#

if you run that in initPlayerLocal then every player will have that eventhandler added locally

meager heart
#

but there was >!isServer) exitWith {};

dusky pier
#

no, this start local, when client connecting

still forum
#

?

#

no, exactly what you said is true

#

why no then?

dusky pier
#

ahh, sorry my English is terrible

#

yes, another EH's is working fine local on every client. But that working only on part of clients. I try'ed to use systemChat for detect when fnc_onTakeItem is started. But on another clients chat is empty and log is clear

still forum
#

when the other client by himself causes the eventhandler to execute?

#

or he doesn't see in his chat when you execute the EH?

meager heart
#

try this >

// initPayerLocal.sqf
if (!hasInterface) then {
    //--- code here for headless
};

player addEventHandler ["Take", {call fnc_onTakeItem}]; 
dusky pier
#

@still forum yes, when other client take item

still forum
#

As I said. player is always the local player

dusky pier
#

@meager heart i understand. But all another functions works fine on all clients. Only this EH

still forum
#

the eventhandler only executes locally

dusky pier
#

@still forum i understand. Player send me log file. And i can't find that - data logged by script. When he run EH his systemChat was empty too

tough abyss
#

@dusky pier why bother with if (!hasInterface && !isServer) exitWith {};

#

you've already got it in initPlayerLocal

#

totally pointless to include that line

high marsh
#

We've already been over this

still forum
#

the !isServer part yeah. not the hasInterface part.

#

as said previously

meager heart
#

also maybe fnc_onTakeItem > TERRANO_fnc_onTakeItem and "cfgFunctions" ๐Ÿ˜ƒ

dusky pier
#

@meager heart ๐Ÿ˜„

#

no, is working for me, but only for me xD

meager heart
#

:sad:

tough abyss
#

@still forum the !hasInterface would be better served as a waitUntil rather than exitWith would it not?

still forum
#

what?

#

hasInterface never changes

tough abyss
#

oh

still forum
#

so waitUntil would either exit immediately or wait infinetly

tough abyss
#

i see

still forum
#

both make no sense ^^

tough abyss
#

i was under the impression of it being until player can see the game screen

#

but if that's the case then why have it all

#

initPlayerLocal only executes on player machines

still forum
#

until player can see the game screen that is actually a very complicated problem as any mod may start a loading screen at any time and prevent the player from seeing the game screen

dusky pier
#

changed to ```sqf
if (!hasInterface) exitWith {};

#

but nothing changed ๐Ÿ˜ฆ

tough abyss
#

because you didn't do anything

#

all you did was remove the redundant check to see if initPlayerLocal is being run on the server

#

which it never will be

#

remove that line entirely

#

because what's happening is your local machine is also considered "the server" in sp environment because "the server" is the same instance as "the client"

#

that's poorly worded but

#

basically, in an sp environment, that will not work

#

i think

#

i've never seen anyone put something like that in initPlayerLocal

dusky pier
#

@tough abyss all client scripts running from initPlayerLocal.sqf, but not working only one EH.

still forum
#

It removes headless clients which are also players but without interface.. Which i already explained half a hour before now

tough abyss
#

then that's a problem with the EH

#

trying to fix issue with EH by changing something completely unrelated
???????????????????

#

@still forum oh, interesting, i guess that makes sense given the way HCs are slotted

meager heart
#

where that fnc_onTakeItem defined ? ๐Ÿค”

dusky pier
#

yes

meager heart
#

yes what

high marsh
#

Where is it defined, not is it.

tough abyss
#

player addEventHandler ["Take", {call fnc_onTakeItem}];
Why isn't your function tagged?

#

like

#

TERRANO_fnc_onTakeItem

dusky pier
#

is defined function, no i defined it on file

#

@tough abyss no

tough abyss
#

thinking emoji

meager heart
#

and that file name is ?

tough abyss
#

show me your cfgFunctions

dusky pier
#
[] execVM "fnc_onTakeItem.sqf";
tough abyss
#

execVMing a defined function file

#

this is 200 IQ shit right here

#

that's not your cfgFunctions anyways

meager heart
#

where you have that ? [] execVM "fnc_onTakeItem.sqf"; < that

dusky pier
#
//fnc_onTakeItem.sqf
fnc_onTakeItem = {

systemChat "fnc_onTakeItem.sqf";
diag_log "fnc_onTakeItem.sqf";

params [
    ["_unit",ObjNull,[ObjNull]],
    ["_container",ObjNull,[ObjNull]],
    ["_item","",[""]]
];

if  !(getPlayerUID _unit in ADMINS_ARR) then {
    if (_item in HACKED_ITEMS) exitWith {
        [_item] call fnc_deleteItem;
};
};

playSound "click";
[] call fnc_saveGear;
};

#

@meager heart in initPlayerLocal.sqf before EH

austere granite
#

execVM is scheduled

dusky pier
#

used compileFinal but nothing changed

austere granite
#

i see about 10 prpoblems here

ruby breach
#

I vote we start with untagged functions and go from there

dusky pier
#

is still working for me, but not for another players

tough girder
#

you want quick solution? publicVariable the function
but there's too many issues with this approach

austere granite
#
  1. Tag your functions, learn to do it and just do it everywhere
  2. You are using execVM, that doesnt give a reliable init order so the fact that it is "in front of something" doesnt matter
  3. You are not passing any arguments { call fnc_onTakeItem }, how is onTakeItem supposed to know who the unit, container and item is?
tough abyss
#

@dusky pier i've already done this exact thing that you're looking to do, i'll just find the code and throw it at you

#

because it's way simpler than

#

whatever this is

#
VAN_bannedItems = [
//Put array of banned items here. They should be type "string".
];
player addEventHandler ["Take", {
    params ["_unitTaking", "_container", "_itemCN"];
    if (_itemCN in VAN_bannedItems) then {
        _unitTaking unlinkItem _itemCN;
        _unitTaking removeWeapon _itemCN;
        _unitTaking removePrimaryWeaponItem _itemCN;
        systemChat "It's against ROE to loot enemy weapons or gear!";
    };
}];```
#

it could stand for some optimization, particularly with these lines:

        _unitTaking unlinkItem _itemCN;
        _unitTaking removeWeapon _itemCN;
        _unitTaking removePrimaryWeaponItem _itemCN;```
#

but it'll work fine

#

i ran it in a mission with 40+ people

dusky pier
#

@tough abyss thank you a lot!

frigid raven
#

Is there something like weapons player but for grenades/throwables?

#

I saw functions that get a list of CfgWeapons >> "Throw" and it looked awful

#

was hoping for something more convenient

tough abyss
#

it's throw

#

the weapon is throw

meager heart
#

currentThrowable also

frigid raven
#

@tough abyss lol gonna steal that snippet, too. Need it later ๐Ÿ˜„

tough abyss
#

๐Ÿ‘Œ

#

the only thing is that array can get pretty hairy because you need to identify individual weapons

#

so if you wanted to you could re-write it to be all OPFOR weapons or something along those lines

#

but i didn't care to because i was on a time crunch when i wrote that

dusky pier
#

do you use debugger for work with scripts? Something like @still forum BI Debug Engine?

tough abyss
#

debug console

#

also RPT files

#

stored in your arma 3 temp folder

dusky pier
#

debug console on esc?

tough abyss
#

yes

still forum
#

I probably have the only useable interface for the debugger.. So I don't think that anyone else uses it

dusky pier
#

i see on youtube - people use your Debug Engine with Arma.Studio

still forum
#

People?

#

only video I've seen with that has been made by me

dusky pier
#

i don't remember author video ๐Ÿ˜ƒ

#

but is still actual?

still forum
#

no

dusky pier
#

:sad:

still forum
#

It will be back in alot better soonโ„ข

dusky pier
#

very nice ๐Ÿ‘

tough abyss
#

also @dusky pier forgot to mention but that code should be in initPlayerLocal.sqf if it wasn't obvious

frigid raven
#

is there something like isVehicle _unit or isSoldier _unit ?

ruby breach
frigid raven
#

hm na