#arma3_scripting
1 messages · Page 498 of 1
no problem
Is there a key bind to opem the editor and select the mission intead of me have to make a new mission frist to be able to select my missions I am working?
You can possibly change the center main menu spotlight to open a particular mission in editor.
How?
https://github.com/ampersand38/Server-Spotlight/tree/master/amp_spotlight basically using the spotlight button to run a script, which uses onEachFrame to navigate the menu controls.
lmao that is a usefull function https://community.bistudio.com/wiki/BIS_fnc_switchLamp
https://github.com/ampersand38/Server-Spotlight/blob/master/amp_spotlight/joinServer.sqf#L35
These nested eachFrames,
. Is this taken from bis code? it's from KK blog.
Absolutely. I source it in the readme. This is packaged into the menu spotlight.
So, setCustomSoundController have been removed or what?
If I delete a object that has AttachTo objects on it, will it automatically take those out as well or do I need to write a additional set up in the script to get rid of them as well?
The attached objects will have disabled simulation until moved. So a crate on a truck will stay in the air, while the truck is deleted.
You should detach and delete all attached objects and delete the object afterwards.
What would be the recommended way of getting all the objects for deletion after de-attach? Like get them all within a certain radius? Or could I delete them before the vehicle is deleted?
{
detach _x;
deleteVehicle _x;
} forEach (attachedObjects myObjectWithAttachedObjects);
deleteVehicle myObjectWithAttachedObjects;
Great Commy did us a thing
https://i.imgur.com/h5jbtuI.png
Use lazy eval bois!
lol, so && {bool} has worse result than && bool at some point? Interesting.
if all are true yes
Always target your lazy eval code after what you expect will most likely happen
question on eventhandlers, i want an eventhandler to remove itself on execution. i can get the index of the EH via _thisEventHandler in the code? its mentioned on the wiki but i dont see examples about it
yes you can
what kind of eventhandler though?
with UI Eventhandlers you could crash the game
no you can't
And I'm not sure if removing MPHit also removes it on every other machine
so i guess i have to remove it with remoteexec on every machine to be sure?
hm im either making some mistake or MPHit does nit fire when simulation is disabled? i thought units still take damage
apparently they dont...
@still forum If you spawn to ctrlDelete or to remove eventhandler by itself - its fine. Just throw that to schedule.
yep
so Ik I can attach a particle effect from cfgCloudlets with
_source01 = "#particlesource" createVehicleLocal getpos _u;
_source01 setParticleClass "NameOfParticleEffect";
_l1 attachTo [_unit, [0,0,0], "Spine3"];
but is there a way I can attach a light effect from cfgLights like I would do for particle effect by setting a class for the createVehicle or do I have to recreate it via script like so
_l1 = "#lightpoint" createVehicleLocal getpos _unit;
_l1 setLightDayLight true;
_l1 setLightColor [5, 2.5, 0];
_l1 setLightBrightness 0.1;
_l1 setLightAmbient [5, 2.5, 0];
_l1 lightAttachObject [_unit, [0, 0, 0]];
_l1 setLightAttenuation [3, 0, 0, 0.6];
attachTo works for (almost) any CfgVehicles.
even for a cfgLights class? maybe Ill go try it again
hallo again. im still playing with CBA keybinds and achilles modules. I want to make sure that i can later include my stuff in a server side addon. Keybind and modules need to initialize client side of course.
["fez\fez_core\fez_Keybinds.sqf"] remoteexec [execvm, -2, true];
would this kind of do the job?
at the moment im still working with scripts in mission files
but at leats this is how i would do it to be able to initialize everything from the initserver.sqf?
ah well... found my answer
hey guys... i need to know if its possible to make an exception for a specific classname within nearestObjects car/air/ship so it gives back all vehicles except the ones i explicitly dont want to
_nearVehicles = nearestObjects[_sp,["Car","Air","Ship"],10];
Is ```sqf
BIS_fnc_Camera;
@carmine abyss why you don't create a own camera on the position from the main camera and then do what you wan't
I'm trying that now but the positioning isnt working at all. I have ```sqf
_cam = "camera" camCreate (getPos player);
_cam camSetRelPos [0,-3,10];
_cam cameraEffect ["External", "Back"];
_cam camCommit 0;
do you switched the camera?
you can get your maincamera position with positionCameraToWorld [0,0,0] i think
It switches to camera, but all I see is my feet or nothing at all
do you used positionCameraToWorld [0,0,0]
let me try
@remote monolith you can do this :
nearestObjects[_sp,["Car","Air","Ship"],10] select {(typeOf _x) != "BADCLASSNAME"};
I'm just trying to get the camera to look at my own guy
yeah, does it work with positionCameraToWorld [0,0,0]?
No sir
ah now i understand what you mean, you can target a object with camSetTarget
_camera camSetTarget player; ```
yes and camCommit
_cam = "camera" camCreate (getPos player);
_cam camSetTarget player;
_cam camCommit 0;``` This is what I have and nothing changes now
Okay this works sqf _cam = "camera" camCreate (player modelToWorld [0,100,10]); _cam camSetTarget player; _cam camSetRelPos [-1, 1.5, 1.5]; _cam cameraEffect ["internal", "back"]; _cam camCommit 0;
okay
Not sure why the other one wouldnt work though
@pure blade thnx man... will try that
i have a function with onMapSingleclick. how do i "unload" it when the player closes the map, without clicking?
i mean when that function is called, it waits for that mapclick, and even if you click much later it will fire unwantedly
if you know what i mean...
basically like onMapSingleClick '';, only that it should do it when not clicked before closing the map....
onMapClose....
wait both map closed and click
i could waituntil visibleMap is false, but that wnt work in unscheduled
and exit if map closed
"if map closed " is the bit that i cant figure out
blafnc = {
openMap true;
onMapSingleClick {
bla;
onMapSingleClick '';openMap false;
bla;
}
};
don't use command from OFP, use stacked EH and remove it when map closed
There are links to new approach.
But if you old fashion man, you can try something like:
blafnc = {
openMap true;
[] spawn { waitUntil { visibleMap }; waitUntil { !visibleMap }; onMapSingleClick ""; };
onMapSingleClick {
bla;
onMapSingleClick '';openMap false;
bla;
}
};
ahyes, that is the direction that i was thinking. but also i was not aware about the eventhandler
thanks
works nicely
@pure blade question camDestroy _cam; works fine in editor, but not during gameplay. no script errors. I also tried cancelling it in debug console still wont exit the camera
i just run camDestroy _cam;
player switchCamera "EXTERNAL"; camDestroy camB;``` not working either
I got it
_cam cameraEffect ["terminate","back"];
ah you don't need to switchCamera but you must destory the camera effect with
_cam cameraEffect ["terminate","back"];
lol
😉
Thank you glow you da man!
I read it earlier but for some reason it didnt sink in
https://community.bistudio.com/wiki/camDestroy Reading helps..
yes
Thank you Dedmen for your kind words
@still forum spit on you 😄
spits on @unborn ether
is there a way to reload the current weapon of a player including launchers directly without reload?
basically the guys now want a faster way to test weapons and damage
just in case anyone has a quick answer to this...
I think.. If the weapon doesn't have a magazine. You can addPrimaryWeaponItem a magazine to have it insta loaded
or drop the weapon and a magazine next to it. When you pick it up the magazine get's automatically loaded
hmmm for i guess i could check if the magazine is empty and if thtas the case delete the gun and add a new one
but on the other hand, what if they want to test different ammo...
I think something like
player setAmmo [currentWeapon player, 10000];
in some loop will make it shoot infinitely.
hmm i figure for a solution that makes me kind of happy ill have to figure out all compatible ammo types and then maybe add an action or so that lets them keep the gun filled fith that type of ammo, or at least makes sure they dont run out of ammo....
oh i would have thought thats too easy
works for guns but not launchers
launchers return magazines though
but only while loaded
i would also like to hang people from drones and swing them around like wrecking balls. how do i attach players to the end of a carg rope under a drone?
actually maybe i can just attach them to the drone itselfn and suspend them for a while
its for misbehaving players
simple. make invisible vehicle that is liftable, put player in vehicle...
@unborn ether yea he did.😉😄
Well thats how attachTo works, you can't change that.
too bad
setpos on a eachframe handler
@peak plover Kill it with fire after, please.
Hello. I'm trying to figure out how to hide a map object on all clients ( and on clients that join later on ) executed locally.
{ _x hideObject true } foreach (nearestTerrainObjects [player,["BUSH"],5]);
Executing it globally works for the clients on the server, but not for players that reconnect/connect. HideObjectGlobal doesn't seem to work because it can't be executed locally. Is there a way to execute this code with remoteExec? I'm pretty bad at this.
@unborn ether attachto runs every frame too
It does something that affects performance
fast moving vehicles run every frame too
vehicle physx simulation step is 30 fps
Or does it calculate what the bullet moved every frame?
simulation step for bullets and projectiles is smaller otherwise it would be extremely glitchy
So it moves independent of framreate
idk if independant, but at least it is calculated much more often than framerate.
no idea. Test it i guess
how? 😄
idk... with something clever. If you cant think of a way to test it, why does it matter to know anyway? 😛
It doesn't
Do bullets move outside of the frame? wat? no. every frame
So it moves independent of framreate no
@twin steppe you can use the Hide Terrain Objects module and in the module settings you can tick a checkbox to run the module locally
@pure blade I'm trying to remove the objects from all clients on a Zues server. I can't load in a created mission file. I wouldn't know but maybe there is a way to create the module with a script? Edit: Yes there is - "BIS_fnc_moduleHideTerrainObjects" I have no clue how to create the module though.
you can try it with createVehicle or createUnit idk if this works or use remoteexec with jip
"{ _x hideObject true } foreach (nearestTerrainObjects [player,["BUSH"],5]);" - How would I make this into a remoteexec though?
create a function and then you can run it with remoteexec
take a look : https://community.bistudio.com/wiki/remoteExec
and you need jip
no all you need is remoteexec
Yeah sorry I see that now.
So this? _function = { _x hideObject true } foreach (nearestTerrainObjects [_newObject,[],4]);
[] remoteExec ["_function", 0, true];
how do u script in vehicle acre radio racks for vehicles that dont have them from the outset?
@peak plover attachTo is bad but at least it has an engine solution for setting positions, which I cant say about setPos in that application.
if i am not sure where my target object (in this case a unit or maybe a group) is local, can i do this to make sure remoteexec targets to execute where object is local?
[_object] remoteexec ["FEZ_FNC", groupOwner (group _object)];
and could i just use owner?
just to have it working also when its not a group?
should work i guess... just have no way to really test now
and if i execute a function on the client that changes unit stances for example, do i have to remote execute that too?
take a look at this litte boxes:
https://i.imgur.com/2vyVWIv.png
case toLower "Rif1": { //Rynnäkkökivääri
_ase = selectRandom ["rhs_weap_akm", "rhs_weap_akms", "rhs_weap_m70ab2", "rhs_weap_m70b1", "rhs_weap_pm63", "rhs_weap_savz58p", "rhs_weap_akm"];
_magazines append [["rhs_30Rnd_762x39mm",1],["rhs_30Rnd_762x39mm_tracer",1]];
_weaponitems append [["rhs_acc_dtkakm","primary"]];
does anyone have any idea why my soldiers aren't getting any weapons or ammo? I've made missions before and they've worked fine but I've never used SelectRandom
Without full code is not possible i guess
(Ad time) Use my dzn gear its already has randomization of everything just from loadout definition
@errant timber provide piece of code where items are assigned, please
if (_unit isKindof "Man") then {
private ["_OTTO_Kypara", "_OTTO_Puku", "_OTTO_Liivi", "_OTTO_Reppu", "_OTTO_Aseistus", "_OTTO_Sinko", "_OTTO_Perustavarat", "_OTTO_Kiikari", "_OTTO_Medikaali"];
Switch toLower(_type) do {
////////////
//Johtajat//
////////////
Case toLower "SL": { //Ryhmän johtaja
//Vaatteet
_OTTO_Kypara = "";
_OTTO_Puku = "";
_OTTO_Liivi = "";
_OTTO_Reppu = "";
//aseet
_OTTO_Aseistus = "GL";
_OTTO_Sinko = "";
//varusteet
_OTTO_Perustavarat = "Johtaja";
_OTTO_Kiikari = "Kiikari";
_OTTO_Medikaali = "";
};
Case toLower "TL": { // Partion johtaja
//Vaatteet
_OTTO_Kypara = "";
_OTTO_Puku = "";
_OTTO_Liivi = "";
_OTTO_Reppu = "";
//aseet
_OTTO_Aseistus = "Rif1";
_OTTO_Sinko = "";
//varusteet
_OTTO_Perustavarat = "VaraJohtaja";
_OTTO_Kiikari = "Kiikari";
_OTTO_Medikaali = "";
};
Do you mean that?
or would want me to just send the whole file?
Dunno, is it some framework?
Ehm, I don't think I can explain my code in English
I'll just redo the thing and see it then works
@errant timber
```sqf
<code>
```
Where had I written that?
my dumb logitech mouse sometimes types the ´ symbol, that's probably it
No. You didn't write that. That's the problem
sorry man but I don't know what you mean
wrap you code in what he typed.
just edit your code... stop spamming.
I don't know what that means though
also tagging your private variables is unnecessary.
i'll just leave and re-do the whole code. no hablo inglés
OI VITTU SAATANA
Ok, just share you file, cuz piece you shown means nothing (it's making things with an array but HOW you want to use it is not clear)
What would be the easiest way to find the nearest OPFOR member in relation to another unit?
if it helps I am using CBA and Achillies
https://community.bistudio.com/wiki/findNearestEnemy Works only if the units knows about the enemy.
If you need to find it no matter if the unit knows I think:
https://community.bistudio.com/wiki/nearestObjects
- filter found objects by side.
Also you should limit the search distance, the command is perf heavy.
Since I am trying to make a basic attack dog script, as long as the dog is on the blufor side/ in a units group, will it 'know about the enemy'
for the NearestEnemy part
if anyone of the dogs group will spot enemy, it will know.
ah that was my problem, I didn't group the dog to a unit
Some more info about target knowledge:
https://community.bistudio.com/wiki/knowsAbout
so if im not mistaken, _DogNearestEnemy = _dogUnderCursorBlu findNearestEnemy _dogUnderCursorBlu; would work to find the nearest enemy to the dog?
Think so.
Wiki examples are kinda strange. they say <object> findNearestEnemy <object> but the command syntax says it's <object> findNearestEnemy <position>
oh nvmnd it's either object or position
yeah that should work (if enemy known to unit/unit group).
Thanks it works!
https://github.com/mmcmd/apd-training-server/blob/beb0ea710bbc8788a5ea409689124342a54661f1/addaction.sqf anybody know why the scroll wheel options arent showing up
you do not addAction?
line 152-158
this is my first script in sqf
interesting language, i come from powershell & python so I see similarities especially with posh
no info in your switch: you should do:
switch (_param_) do
{
// actions
}```
an empty param var?
in the launcher, activate "Show script errors" to have error feedback 😉
thanks, couldnt make vscode debugging w/ sqf work properly with the extension
add at the top of your file:
params ["_parameter"];
if _parameter is not provided, it will be objNull, therefore not matching any of your switch cases
in the default case (warning! no semicolon) put your addactions. (else it will trigger everytime)
also,
[
"<t color='#FF0000'>Teleport to Drug peninsula</t>";
{
comment "Teleport to Drug";
player setPos [14257.2,13032.5,0];
},
];``` format won't do anything; go directly to the part under "comment" to do the stuff
ok so I would move the addaction into the do switch
but what would happen with this
gearupStand addAction ["MK1 loadout", "addaction.sqf", 1];
gearupStand addAction ["MK18 loadout", "addaction.sqf", 2];
gearupStand addAction ["OG arms teleport", "addaction.sqf", 3];
gearupStand addAction ["Drug peninsula teleport", "addaction.sqf", 4];
gearupStand addAction ["ARCO scope", "addaction.sqf", 5];
gearupStand addAction ["MRCO scope", "addaction.sqf", 6];
gearupStand addAction ["RCO scope", "addaction.sqf", 7];
what you are currently writing is a recursive script, meaning it will call itself with the parameter you give (1..7)
if you 1st time call your script with execVM "addAction.sqf";, no parameter will be given. place the "addaction"s in the "default" case of the switch
Hello!
I have a particle source with water, I would like to know if the water collides with some object in its way
is it possible¿?
I would like to check the line in wich the particle is and if there is a object do somthing
I have read this "You can get position of a particle in onTimer script in particle array" But dont know how
Position of the particle is stored in "this" variable.OnTimer - ```
I just used Arma 3 Tools and its Options to define my P drive. After that I used the action "Mount the Project Drive". No files were created in that directory tho. Before continuing to follow a setup tutorial I would kinda verify that mounting worked. Any ideas how to do so as easy as possible?
No files are created until you install bulldozer or extract game files
I found that in my windowns explorer the new drive P: was created
is that a good sign?
ok things seem to work now
Yes
Yikes, hey there! I am running a script over initServer.sqf (execvm) and ... it does its work. Yet i have to make sure JIP works so the result is for everyone there. I am a bit clueless at the current state.
well… we may need more details 😁
haha, i guess so ^^ What should i post? I could deliver all the (dirty) details. Or should i post the whole script as pastebin?
Well, here is the whole script:
https://pastebin.com/Sn4a8Gyv
I execute it with (on initServer.sqf) with [] execVM "script";
firstly, isServer is a useless check because isDedicated will always be a server.
Noted, was very unsure about it.
[] execVM "script";
try "script.sqf"! 😄
and check all global vars initialized in scripts - maybe it works, but you configured it wrong. Type in "WATCH" fields and ensure that vars has any values (e.g. unlimited , merc_arsenal_box, weapon_cache_temp, etc.)
the script iself does its work. But as a client, i dont see the weapons in the arsenal, and still "ghost" weapons in the merc_arsenal_box inventory
Without the execVM it will update on all currently online clients and/or jip clients? @short trout
You are adding the weapons in the server, the effect of https://community.bistudio.com/wiki/addWeaponCargo is local, you'll need https://community.bistudio.com/wiki/addWeaponCargoGlobal
ooooh
execVM is not the reason, yeah )
omg... global, yes -.-" embarrasing
i will rewrite a bit and then i will hurt the table with my head 😄
thanks all! trying to test it again 😄
[merc_arsenal_box, [_weaponname], true] call ace_arsenal_fnc_addVirtualItems; the ],true] should be the 'add globally' boolean of ace's arsenal framework, right? (done, and yes ^^)
is it possible to display variables with BIS_fnc_typeText together with remoteexec in a text? Whenever i try to put a variable in [["text %1", variable, "formatstuff"] remoteExec ["fnc"]; it does not work. Still not too comfy with scripting yet.
I tried [["text","format"], variable] remoteExec ["fnc"]; as well.
@keen bough do you mean plain text formatting?
https://community.bistudio.com/wiki/format
format ["%1", varStuff] remoteExec ["typeText"];
?
wonder if remoteExec needs prefix to use functions?
i thought more like
"one","formatoptions" + stringvariable + "two","formatoptions" typetext. Somehow that would be that what i kinda like. Currently i use something with 'systemChat'
nolo_fncb_logInChecker = {
blah
};
_result remoteExecCall ["nolo_fncb_logInChecker", owner _player];
on inline declared functions, nop
what's one/two ?
Actually something like this:
"Offshore Bank Account","<formatoptions><br>","Transaction done.","<formatoptions><br>","Balance: ","<formatoptions>" + variable + " Dollar.","<formatoptions") spawn bis_fnc_typetext;
Nop, first param for BIS_fnc_typeText expects array.
@compact maple inline functions will not work sadly.
It does work, I tried it before, why ?
Hm? My mistake.
@keen bough could you paste your actual systemChat ?
yep, sec
well inline function work as long they're in CfgRemoteExec
_textMoney = str (mercMoney);
"Operator: A transaction to our offshore account is done. Balance: " + _textMoney + " Dollar." remoteExec ["systemChat", -2, true];
[
[
["Operator: A transaction to our offshore account is done.","<t align = 'center' shadow = '1' size = '0.7' font='PuristaBold'>%1</t>"],
[format ["Balance: %1 + Dollar", _textMoney],"<t align = 'center' shadow = '1' size = '0.7'>%1</t><br/>"]
]
] spawn BIS_fnc_typeText;
you should put that in a function and remote exec that function
oh god, right. I put that into "test.sqf" and call that via remoteExec, yes?
yep
like
_variable = [code] spawn function;
_variable remoteExec ["bix_fnc_typetext", -2, false/true];?
erf, still not awake. Woke up 8 minutes ago ^^
more like
["first params", "second param"] remoteExec ["fnc_test"];
Ah, do you have a tutorial somewhere i could see/watch to learn to make functions? It seems a bit different for me. Still very very new to arma mp scripting.
awesome, thank you
don't get confused, a function can be something trivially simple. it's basically just code in a box, and you pass it arguments which then can be accessed inside the function with param,params _this magic variable. the simplest function you can do should be like this:
simplefunction =
{
systemchat format ["%1", _this];
};
_var = "test";
[_var] call simplefunction;
but you can also register them with cfgFunctions in description.ext, or you can use CBA functions, or you can do your own system
^everything you need to know
so i actually dont have to register a function and could use a global, lets say, sqf file where it passes its argument in it, like, for example, an array or whatever i want?
nope.
the bit of code i posted can be in 1 file
you CAN do that, but you don't have to
but on inline declared functions, client need to "read it" at least one time otherwise it will be undefined
oh yeah right remoteexec? never used that. no clue 😄
for the text i want to use. Is it better to use a remoteexec style of setup, where i call/spawn it like
"test.sqf" remoteExec ["bis_fnc_typetext", number, boolean];?
ah blep, i see my mistake
and in that function, you do your stuff
need to look it up quickly how it was done with remotexec, sec
params remoteExec [functionName, targets, JIP]
found it :D
<params> remoteExec ["fnc_someScriptedFunction", targets, JIP]; //Works
Each connected client, except the server (-2) that i know already. Yet i will have to test how i can write a function properly. Its todays learning lesson ^^
so much help from all of you guys :3 thank you so much. Now its time for breakfast, documenting everything what i wrote yesterday and then stuff to attend. After that its coding time again ^^
i think if you register a function with cfgfunctions in description.ext (that should be described in the 2 links above somewhere) you get the advantage of it being compiled once ,which improves performance if you call it a lot. the little example i posted will probably compile every time. you could add compile preprocessfilelinenumbers on the function declaration and make sure you only execute that code once, and achieve the same i guess. also there is CBA functions https://cbateam.github.io/CBA_A3/docs/files/xeh/fnc_compileFunction-sqf.html but i have never worked with those yet. cfgFunctions has some drawbacks Dedmen explained here (to me) like 1-2 weeks ago maybe?
sweet. When should i use functions? I have currently my save-script, money-script that both run on timers like 15 minutes and 5 minutes.
when you want to re-use code multiple times, i always find it a good idea to stuff it into a function.
especially if it's basically the same code, but with different input values
perfect, like the text's i have in mind. I want to see first with the save, unlock and money script if it will be too much if i have typetext spawned all the time while playing or if i keep the systemChat output.
Nothing hurts more if you think something is extremely awesome and cool but annoys you while gaming since its only cool 1 - 3 times ^^
one final question before breakfast:
If i want use pictures. Is it better to transform them to paa (or whatever the file format was) or use jpg when i want to use dialogs with pictures (next thing is a garage. I can store everything i need in a database but yet i am unable to put a specific vehicle out, spawn it and delete the entry in the garage)
i put everything in so many differend sqf's document it out (nearly every line of code is documented what it does, why it is used and so on)
blep, i have one final question that bugs me - not really important but somewhow it bugs me. With getCargo (weapons etc) i get an array with the classname(s) and amount. Is there a way to use the classname and figure out the real name of the gun as example? Just need a general direction where to look (functions or so). Currently i have no clue.
Question, how intensive would Reveal be if broadcasted to all units on the map?
Sure you can
_weapon = "myWeaponClassname";
hintSilent str getText (configFile >> "CfgWeapons" >> _weapon >> "DisplayName")
``` @keen bough
awesome!
well you can access nearly everything with the config system
you can even create your own config for what ever you want
nice, all that will help me a lot. Thanks.
why store it in var if it's not being used outside of getText config reference?
dont know, just to make it clear
I'm still getting used to using extDB3. Is there a way to get rid of all triple layered array stuff?
private _query = format ["0:ADMMSQL:admm_get_mapID:%1",worldname];
private _mapID= parseSimpleArray ("extDB3" callExtension _query);
systemChat str _mapID; // [1,[["1"]]]
private _map_ID = (((_mapID select 1) select 0) select 0);
systemChat _map_ID; // 1
I had that problem too
give it a look https://bitbucket.org/torndeco/extdb3/wiki/extDB3 - General
I don't follow
4 = Get (Retrieve Single Part Message)
5 = Get (Retrieves Multi-Msg Message)
I still don't follow
well 4 return [["1"]] and 5 return [[["1"],["blah"],["blah"]]]
anyone can confirm ?
I think it require a test im unsure
private _query = format ["0:ADMMSQL:admm_get_mapID:%1",worldname];
So i would replace the 0 with a 4, right? I've tried 2 yesterday, didn't work out. Now tried 4, also doesn't work out. Seems only to work in mode 0 ?
I dont remember very well
I dont think its bothering if you have to select your data ?
it's an OCD thing.
ocd ?
oh yea lmao
Does someone know how to handle auto_increment columns with extDB3? I took this post as an example https://armaworld.de/index.php?thread/3153-extdb3-tutorial-wie-man-aus-arma3-auf-mysql-daten-zugreift/&postID=24865#post24865 (second spoiler, line 48 to 52)
[jgkp_loadout_insert]
SQL1_1 = INSERT INTO `po_loadout`
SQL1_2 = VALUES (
SQL1_3 = '',?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);
SQL1_INPUTS = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22
But it does not work. Here is my ini file entry:
[admm_insert_location]
SQL1_1 = INSERT INTO `map_locations` VALUES ('',?,?,?,?,?,?,?,?);
SQL1_INPUTS = 1,2,3,4,5,6,7,8
And here is my query:
private _querycmd1 = format ["0:ADMMSQL:admm_insert_location:%1:%2:%3:%4:%5:%6:%7:%8",_angle,_name,(_position select 0),(_position select 1),_radiusA,_radiusB,_type,_mapID];
diag_log format ["_querycmd: %1", _querycmd1]; // "_querycmd: 0:ADMMSQL:admm_insert_location:0:no_name:3123.89:20498.7:300:250:Hill:1"
private _query = parseSimpleArray ("extDB3" callExtension _querycmd1);
And this is my error log from extDB3
[13:11:24:839853 +01:00] [Thread 1696] extDB3: Output to Server: [0,"Error MariaDBStatementException1 Exception"]
[13:11:24:857622 +01:00] [Thread 1696] extDB3: Input from Server: 0:ADMMSQL:admm_insert_location:0:no_name:3123.89:20498.7:300:250:Hill:1
[13:11:24:857646 +01:00] [Thread 1696] extDB3: SQL_CUSTOM: Trace: UniqueID: 1 Input: admm_insert_location:0:no_name:3123.89:20498.7:300:250:Hill:1
[13:11:24:857858 +01:00] [Thread 1696] extDB3: SQL: Error MariaDBStatementException1: Incorrect integer value: '' for column 'locationID' at row 1
[13:11:24:857874 +01:00] [Thread 1696] extDB3: SQL: Error MariaDBStatementException1: Input: admm_insert_location:0:no_name:3123.89:20498.7:300:250:Hill:1
has nothing to do with extdb3 @waxen tide
auto increment is a database level feature
I'd specifically list the columns in the query, and omit the auto increment column
also i again have to say ... somebody should take the time to develop some proper db extension
From one of my projects:
[addAttendance]
SQL1_1 = INSERT INTO analytics_attendance (op, player, jip, role, group_name) VALUES (?,?,?,?,?);
SQL1_INPUTS = 1,2,3,4,5
extdb is just ... urgh
depending on the backend, you either need to do what @chilly wigeon did, or just pass NULL
or, for fog's sake, a way to persistant save ^^
yeah, its too attackable from what i heard
everything in arma is "attackable"
Not the sun ^^
the moment i have some way to enter scripts, you are screwed
its typical that, yeah.
To clarify, this is what the table structure looks like: https://i.imgur.com/HCX9ZPY.png
german words? you german jcd?
So Theo if i do it like you did it, i would end up with
[admm_insert_location]
SQL1_1 = INSERT INTO `map_locations` VALUES (?,?,?,?,?,?,?,?);
SQL1_INPUTS = 1,2,3,4,5,6,7,8
Instead of
[admm_insert_location]
SQL1_1 = INSERT INTO `map_locations` VALUES ('',?,?,?,?,?,?,?,?);
SQL1_INPUTS = 1,2,3,4,5,6,7,8
That wouldn't work because you're not specifically defining your columns names
you got a link for me that i should read?
Not particularly, it's just part of MySQL insert syntax
If he wants to insert without defining column name, he can
Ah, ok, so the extDB3 guy didn't invent anything, he's just straight passing SQL syntax and i can look up any SQL tutorial. I missed that.
more or less
well i'm using extdb3 too and I never deal with that kind of thing
["0:ADMMSQL:admm_insert_location:%1:%2:%3:%4:%5:%6:%7:
i googled extDB3, found 4 or 5 pages, read them all and picked that up from one of them.
How do you do it?
@queen cargo I know that it is a database level feature. I don't get what you're trying to tell me. I still need to pass it thru the extDB3 extension and declaring stuff wrong in the ini probably isn't the way to go.
Now i get what you meant with "I'd specifically list the columns in the query, and omit the auto increment column" Theo. Still a bit curious why the '' placeholder? i got from that example code isn't working. Maybe outdated tutorial? Or i made a mistake that is not obvious to me right now.
@waxen tide check how AL works https://github.com/AsYetUntitled/Framework/tree/master/life_server/Functions/MySQL
chances are that it is a different db then you are using @waxen tide
as said, mysql IIRC should be that you need to pass NULL on auto_increment fields
the auto_increment is handle by mysql, no need to put it in a query
3rK, the sql custom of extDB3 isn't used there at all, right?
I initially asked my question the way i asked it because i think the issue lies withhin my sql custom ini definition of the auto_increment field.
I changed the sql custom ini by listing each column specifically, but i still get that error due to colum count mismatch. so i obviously need a placeholder or pass something. Still don't know what and how exactly.
[13:56:13:469296 +01:00] [Thread 1696] extDB3: SQL: Error MariaDBStatementException1: Incorrect integer value: 'NULL' for column 'locationID' at row 1
i guess if i generated the ID and pass it, it would work splendid but i kinda want auto_increment
I have no clue
I dont know how extdb3 works
I just know how to query something
and use the result
So looking at this: https://github.com/AsYetUntitled/Framework/blob/master/altislife.sql#L144
I understand the table has auto_increment on the first column
yep thats the id
And here is an insert, with the column names specifically written out, and it is a partial insert where some columns, specifically the first one with auto increment, are obmitted
and i guess this stuff works?
of course it does 😄
So either it is a difference in SQL server (i use MariaDB) or it is the sql custom vs writing SQL statements directly in sqf
idk i'm allergic to life stuff my doctor advised me against playing it.
i'm strongly guessing the issue is with sql custom which you don't use so i'm not really making progress
well I dont know why, life bring a lot of players on a3, even if some people dont like it.
thats probably it. I've never dealt with that sql custom
btw I use mariaDB too
and thats pretty cool
yeah then i'm certain it must be the SQL custom
Like I said, you must define your column names, omitting the auto increment
Your query keeps trying to put invalid data into the locationID column
yeah i tried that, still spits out an error complaining about the mismatch in colums
[admm_insert_location]
SQL1_1 = INSERT INTO `map_locations` VALUES (angle,name,positionX,positionY,radiusA,radiusB,type,mapID);
SQL1_INPUTS = 1,2,3,4,5,6,7,8
[14:07:16:173661 +01:00] [Thread 1696] extDB3: Input from Server: 0:ADMMSQL:admm_insert_location:0:Javorje:29393.4:6121.89:300:250:NameVillage:1
[14:07:16:173678 +01:00] [Thread 1696] extDB3: SQL_CUSTOM: Trace: UniqueID: 1 Input: admm_insert_location:0:Javorje:29393.4:6121.89:300:250:NameVillage:1
[14:07:16:173710 +01:00] [Thread 1696] extDB3: SQL: Error extDB3Exception: Config Invalid Number Number of Inputs Got 8 Expected 9
[14:07:16:173721 +01:00] [Thread 1696] extDB3: SQL: Error extDB3Exception: Input: admm_insert_location:0:Javorje:29393.4:6121.89:300:250:NameVillage:1
[14:07:16:173731 +01:00] [Thread 1696] extDB3: Output to Server: [0,"Error extDB3Exception Exception"]
Your query in SQL custom is wrong
it should be
SQL1_1 = INSERT INTO `map_locations` (angle,name,positionX,positionY,radiusA,radiusB,type,mapID) VALUES (?, ?, ?, ?, ?, ?, ?, ?);
🤦 Thanks a lot, that now works like a charm.
should i bother replacing the actual name of a map with a shorter ID if i'm going to save it millions of times, or is SQL clever enough to do that itself internally?
you could create a new table with maps, and join it in your query
yeah i kinda did it awkwardly, join is a better idea. thanks!
😄
Damn, thats a typical unclear thing. Do i need to createCenter or not? "Arma creates center for you" Now what? Do i have to do it myself or not? 😄
Or i rephrase: I want a single unit created, and stay at a position, casually doing nothing dumb ^^ My working thing is with createVehicle. But i want to use createGroup and createUnit if that is better (waypoints and such things)
i think i read about "createCenter" that it's some old stuff from either flashpoint or arma 1/2, and it isn't needed for arma 3 anymore.
alright. Still a bit unclear. When i create a group "_group1 = code;" and then a unit to fill into that group. How can _group1 stay that way? How does the game still know that the created group _group1 is still there?
ok so a vehicle can be a trashcan, a house, a butterfly, a soldier or a car. that's basically just an object. a unit is a soldier (alive) which is represented in the game by a vehicle of the type soldier_something_something. That unit is (should be) part of a group. so what you should do if you want to do it properly:
- create a group
- spawn a vehicle (soldier)
- assign that vehicle (the soldier) to the group
then you can give that group an order, like a waypoint of the type "guard this shit"
note: This entire topic is on my long-term todo list and i'm far from an expert.
🤔
hmhmmm, yep no worrie i learn 'to go' ^^ right on the spot when i need something. Easier for me. Dislike theoretical learning that i may or may not use later ^^ when i learn it when i need it, i normally never forget it again.
So __group1 will always be _group1 until i re-use it? because _ _says its local. I want it to be deleted when empty, that i understand.
_group1 is a reference to the group you created
it's the name of the group inside your code
dang, discord messing up. So, when the script is done, creating the group and unit with its desired waypoints n 'shit. Does "underscore"group still exist?
since _group is currently used as kind of a "group name"?
already did XD left me clueless
_group = createGroup [east, true];
_soldier = "B_Soldier_F" createUnit [[0,0,0], _group];
this would create a group, and then spawn a unit of the type "B_Soldier_F" and make it member of the group
(see how _group is in both lines)
https://i.imgur.com/6687KmT.png (//by commy2)
This is genius!
cond1 && cond2 && {<thencode>} > if (cond1 && cond2) then {<thencode>}
XD
Sorry for interrupting. sits down and watches you guys doing stuff
omg, a wild confusion appeared! 😄
_group = createGroup [east, true];
_soldier1 = "B_Soldier_F" createUnit [[0,1,0], _group];
_soldier2 = "B_Soldier_F" createUnit [[0,2,0], _group];
_soldier3 = "B_Soldier_F" createUnit [[0,3,0], _group];
you could also do this
which would spawn 3 soldiers
and make them all part of the same group
Can i call back to the _group anytime i want or just, because its a local variable, when the script that has to do with that group?
if you then give an order to the group, they'll all stick together (try to, at least) and do what you told them to do (try to, at least)
if i want to delete it manually with another script?
🤔
i mean, yes, i can bring in that group [] style but isnt _group then the group's name itself? i am sooooo confused ^^
If you simply want to reference the group by "_group" you have to make sure that variable is available wherever you want to use it
I think it would help if you explained a bit more in detail what you want to do with that group.
yeah, i want to use _group only for specific missions. I always will do a safe-strategy to delete the group again if a new mission is generated.
I dont use random-mission generation. the mercs can choose a mission (there will be random generated ones of course) most of the time.
well i guess a very easy way would be to stuff your group and whatnot you want to cleanup into a global variable
thought about that, yah
and when your conditions are met, loop thru them and delete them all ?
That would've been the thing i would do when i am too unsure ^^ globalvariables are bit easier for me to use.
i myself haven't yet really figured out how to handle that nicely.
i have sort of a mission template file which basically just creates a task, calls half a dozen functions to spawn an AO (each function returns the spawned stuff) and then the cleanup just does {deleteVehicle _x} forEach basically.
I think we should always consider the arma way. Shooting a tank in the air, make it bounce around on the map, kill someone that runs over a stone and then script something like that with the end result that the server is burning.
datacenters have fire suppression systems.
arma scripter uses a script to spawn in a tank. Server explodes, distant sirens, kids crying.
you can just retrieve your group by doing
_group1 = group player;
but lets be clear
once you created a _localVariable, when the script exit, the variable is destroyed
thats why i am curious why i should use _group for units. That would make no sense. It should be then a global variable. Or is there a way to call a group by call-sign or create a call-sign you could refer to?
You need a global variable when you want to keep an information available
if you want to get the group of someone
just use the code i gave u above
i actually know a way to code it. I was just very curious if a local variable can be a continous group name (like a call-sign) i think the answer was/is no. That way i would use globalvariables because i would need to call it steadily as long the mission runs (2 - 3 script files)
what's a call sign ?
alpha 1-1
oh okay
but I dont think you need a global var for group, as it can be access anytime
meh.
A call sign is a sign you call out loudly. For example "THAT SPEEDLIMIT SIGN SAID 30 YOU DEGENERATE"
XD
@waxen tide space after the end of the link
lmao
just search my first link with "group" and look at everything it finds
got me good XD i am laughing hard ^^
seems to me https://community.bistudio.com/wiki/setGroupId sets the actually displayed name
hmmm, so i can create stuff with _local and then give it an id (all id's under 21 are not suitable for alcohol) and it could be possible that, over the id, you could alter the group?
ok so variables can be limited in scope. say a variable that only exists inside a loop, or inside a script. that's 1. good for performance 2. good for security
hi
hayhay
obviously you can't keep that variable limited if you need it elsewhere. there are two ways i'm aware of around that:
- make it a less limited variable that is available where you need it
- pass it to the script that needs it at a parameter
or, kinda, 3rd: use some existing arma mechanic
does i need AA in 4k?
like if you set the groupID to something specific, you can check the groupID of any group anywhere you want because arma syncs it over network for you to everyone.
@tough abyss wrong channel
so, over the groupid i can manage the group and say, delete the unit and then the group? Does the id have any informations as array in it (dont see any information in the wiki)
🤔
Ah, no you cant
the group name is either short (local) or permanent (global) and only when its global (variable) you can alter it.
well i think, the final answer is probably, as long you want to make use of a group, you have to make the group a global variable (use it in other scripts) or hand it over to a loop scirpt to keep a variable local and use it later when you actually need it. I think the global-variant is better.
no
with allGroups you get all groups
with GroupID you can check the group's ID
with https://community.bistudio.com/wiki/units you get all units in a group
hmhmmmm right, yeah, makes the script a tad longer but that would work too without global variables.
what about https://community.bistudio.com/wiki/BIS_fnc_dynamicGroups ? Is it just for players?
{
if (groupId _x == "group123") exitWith // find the group with the right ID
{
{
deleteVehicle _x; // delete each unit
} forEach units _x; // find all units in the group and loop thru them
deleteGroup _x; // delete the group
};
} forEach allGroups;
i think you CAN do that. idk if it's a good idea tho.
if you have 144 groups, which is the max, i guess that could take a while, a couple seconds i would say.
Ah and you might run into trouble with _x not being available in the loops inside the loops 🤦 so you might need to do:
{
private _current_group = _x;
if (groupId _current_group == "group123") exitWith // find the group with the right ID
{
{
deleteVehicle _x; // delete each unit
} forEach units _current_group; // find all units in the group and loop thru them
deleteGroup _current_group; // delete the group
};
} forEach allGroups;
t. noob
hehe ^^ ya.
no worries, i had such things already often enough happen to me. "Why does freaking _weaponname not show the weapons name?! oh... oh... OH! oh... it was not created" haha
Pfft. amateurs
🍿
i tend to forget to every - single - hint the ;
looks at Dedmen
@waxen tide delete each unit check that line again
imagine me going crazy why a script does not work and i am looking all over it dozen times until i figure out it was the hint again ^^
I-I'm trying to avoid writing SQL statements
alright, now to the police-units watching to catch the bacon before the players can deliver it.
Last thing that really Fuffed my brain up.. Was a array that invisibly modified itself.
Like.. I know I'm caching that array, but how is the cached value being modified even though I don't have a setVariable for it anywhere 😄
arma happens everywhere ^^
Hint: use + to copy arrays and not modify them by ref
@keen bough stop making witty remarks and get coding ☝
yes yes, i am on it, i am writing ^^
// Let the player know there is police
"Woop Woop! Thats the sound of the police!" remoteExec ["hint"];
_waypoint = _group1 addWaypoint [_finalpos, 0];
[_group1, 0] setWaypointType "HOLD";
_group1 setCurrentWaypoint [_group1, 0];
Hmmm, is this correct to add a waypoint, make that waypoing be a hold waypoing and set is as current?
edit:
yes ^^
Hello everyone I’m looking for someone that knows how to script a mod/body shop for vehicles so players can go to repair, paint and modify their car. If you can do it just message me and let’s talk more
halla
so today i have this one
private _coordinate = _this select 0;
if ((isNil "_coordinate") or (_coordinate isEqualTo [])) exitWith {};
if (!(isNil "_coordinate") ) then {
private _staticweapons = ("true" configClasses (configFile >> "CfgVehicles")) select {"StaticWeapon" in ([_x] call FEZ_fnc_Config_Parents)} apply {configName _x};
private _mines = ("true" configClasses (configFile >> "CfgVehicles")) select {"MineBase" in ([_x] call FEZ_fnc_Config_Parents)} apply {configName _x};
private _blacklist = _staticweapons+_mines;
{
if ((!isSimpleObject _x) && (!(_x isEqualTo ObjNull)) && (!((typeof _x) in _blacklist))) then {
[_x] call BIS_fnc_replaceWithSimpleObject;
};
} foreach ((allMissionObjects "All") select {((getpos _x) distance2d _coordinate) <= 50});
};
what it is supposed to do is replace objects in a range of 50m with simpleobjects
but exclude mines and staticweapons
the exclusion of staticweapons works, but for some reason it does not do the job for mines
actually it delets the mines
it seems that a= BIS_fnc_replaceWithSimpleObject delets mines for whatever reason
and b) that my script theere does not properly esclude mines
So a few things before we even get into the functionality
Why use if (!(isNil "_coordinate") ) then { if you just did an exitWith check for nil one line above?
You'd also likely be better off using some command other than allMissionObjects. Particularly since you're only looking in a 50 meter radius
I would think https://community.bistudio.com/wiki/nearObjects would return the same list
Other general recommendations would be to ensure that _staticweapons and _mines contain what you think they do, and to check for case sensitivity issues with (typeof _x) in _blacklist
"MineBase" in ([_x] call FEZ_fnc_Config_Parents) but.... Why?
https://community.bistudio.com/wiki/isKindOf
^ That too
yea so the part there with isnil _coordinate apparently has to show up in Achilles custom modules i had errors without that stuff
so ignore that bit for the moment
allMissionObjects vs nearobjects, right, that was more part of the testing process. id used nearobjects before... also ignore
results are even a bit weireder then i thought
if i use replacewithsimple on a mine directly, it deletes the mines
if i do it via my function, they remain visible but still do get turned into simple objects
Is it possible to disable the function of not being able to go into someone elses car, when the rating is below -2000?
i switched to this but i believe the result was the same, for the fraction of a secorn, before arma crashed
@simple solstice Use a getInMan EVH to force eject the player if rating player < -2000
make a condition (rating player <= -2000) in the getinman eventhandler and if the condition true kick him out with moveOut
private _coordinate = _this select 0;
if ((isNil "_coordinate") or (_coordinate isEqualTo [])) exitWith {};
if (!(isNil "_coordinate") ) then {
{
if ((!isSimpleObject _x) && (!(_x isEqualTo ObjNull)) && (!(_x isKindOf "MineBase")) && (!(_x isKindOf "StaticWeapon"))) then {
[_x] call BIS_fnc_replaceWithSimpleObject;
};
} foreach (_coordinate nearObjects 50);
};
@ruby breach what I mean is that when civ's rating is below a certain point, he cannot go into vehicles where the other civ is the driver
You can't stop them from trying to get in
You can, however, kick them out if they do get in
yeah, you can use (driver vehicle) to check if the car has a driver
player addEventHandler ["GetInMan", {
params ["_unit", "_role", "_vehicle", "_turret"];
if (rating _unit < -2000) then {
if (side _vehicle == civilian && side _unit == civilian) then {
player action ["Eject", vehicle player];
};
};
}];
``` or similar
so yes. that last function that i have there reliable crashes my arma
i have never managed to produce such results before, and ive done a lot of crappy stuff
everything works, but it crashes when mines are around
this alone makes mines disappear
[_object] call BIS_fnc_replaceWithSimpleObject;
and this makes my game crash ONLY IF mines are in the 50m range
if (!(isNil "_coordinate") ) then {
{
if ((!isSimpleObject _x) && (!(_x isEqualTo ObjNull)) && (!(_x isKindOf "StaticWeapon")) && (!(_x isKindOf "MineBase"))) then {
[_x] call BIS_fnc_replaceWithSimpleObject;
};
} foreach (_coordinate nearObjects 50);
};
crashes also without the check for ines
its rather weird
maybe it has to do with the fact that i use these achiles modules?
https://community.bistudio.com/wiki/ArmA:_Event_Handlers#IncomingMissile
This doesn't seem to work when players fire unguided rockets at a vehicle?
now it crashed without the mine... damnit
@waxen tide you have multiple locations with the same ID? Shouldn't locationID be the primary key?
in your roadblocks table
Also in the locations table the type should probably be enum to save space
no there is multiple roadblocks belonging to the same location.
and roadblocks do not have an ID because i don't need one.
Ah.. hmpf. okey
☝
@solemn swan Triggered when a guided missile locked on the target or unguided missile or rocket aimed by AI at the target was fired.
That says exactly what you said.
You could severely reduce the size of your "houses" table by moving all the classnames into a second table. And just storing the ID of the classname. To get rid of all duplicate names
yeah but whats a few thousand houses among friends when you got 4 million positions in another table :/
Sorry I posted the wrong link. https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#IncomingMissile
This one says it should work for the player. That or I'm illiterate.
i'll add it to the todo list tho.
@dim terrace might you have insight on how the backpackContainer and and vestContainer differ from each other?
I tested it out a bit and backpackContainer seems to return the actual backpack object strapped on the player and that can be retextured with the setObjectTexture commands but vestContainer returns a dummyweapon that then can not be accessed with setObjectTexture.
the data including the houses was like 4MB, the empty positions is about 1gb by now. (per map)
oof
hence why i moved to a db 😛
eh c'mon what's 1gb in 2018.
yesterday i had my thoughts wander off and i thought about what M242? said, that i should speed this up with a dll and do it on runtime. wtf? i don't even know where to start. I got this caching to work with SQF and SQL in like 2? weeks. My time is the bottleneck to get the mission done, so it has to take priority over elegance there. I wouldn't even know where to start.
I sort of have a similar problem where I want to take positions on the terrain to data and have certainly considered doing it via DLL so I can store the cached values externally so I can distribute precomputed ones as well. ACE seems to also be doing something substantial for about a minute at the beginning as well, so an ever increasing list of mods are having to cache large amounts of data around the terrain for what they are now doing
@waxen tide how many entries in the largest table?
roughly 4 million
several restarts later it does apparently not crash anymore, but delets the mines on both commands.... this is messed up
i haven't run it over the entire map for a while, but i've done percentages of the map and done an extrapolation
i've divided the map into sectors (1x1km) and subsectors
(100x100m)
🤔
Is that your buildingpos table?
no safepos
6x 32bit int?
That's 96MB for 4 million entries
My hobby projects table with 16 million entries of text messages is 1500MB.
And your 4 million little numbers are already that big?
it's a tinyint for mapID, a smallint for mainsector, a tinyint for subsector, and 2x float for X/Y and a tinyint for radius.
uhm i suck at math and the critical number was "above 10MB" so i copytoclipboard didn't work out anymore that neatly.
tinyInt is one byte.
so 1+ 2 + 1 + 4 + 4 + 1
that's 13byte per line.
last test i did extrapolated to roughly 1gb
So it should be ALOT more efficient now with the DB
Run this query
SELECT
table_schema as `Database`,
table_name AS `Table`,
round(((data_length + index_length) / 1024 / 1024), 2) `Size in MB`
FROM information_schema.TABLES
ORDER BY (data_length + index_length) DESC;
It'll give you the sizes of all your tables
It's 128kb for a sector, and i got 1681 sectors on this map, so that would be 210MB.
not complaining ¯_(ツ)_/¯
so it turns out that this bit lead to the crashes "(_coordinate nearObjects 50)"
dont know why
function still deletes mines, which it shouldnt because it should get to do shit with mines in the first place
hello. Do you guys think this makes sense?
if (!local _object) then {_object remoteexec ['functions',_object,false]}
nah
if (!local _object) exitWith {
_object remoteExec [_fnc_scriptName,_object]
};
Usually when I use sth like that
It's better to use exitWith
Also
'functions' doesn't look like a function name
I did a small enscript benchmark.
int test = 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1;
int test2 = 1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1;
in Enscript.
0.029007ms for 10k iterations
0.266997ms for 100k iterations.
And in SQF.
_test = 1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1+1;
_test2 = 1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1*1;
0.0334ms in... ONE ITERATION.
One single iteration in SQF is already slower than 10k iterations in enscripts. And I don't even include the for loop on the SQF side.
So Enscript is about.. 10000x as fast?
Enscript like in Enfusion ?
Hopefully it's that much faster for... well, basically everything
Yes. And yes 😄
Well they better fucking massively improve it when they break compatibility with shit that survived 4 games in a row.
Hm, plopping in. Is this correct?
_nearestPlayer = _baconManPos nearEntities ["isPlayer", 5];
ok sorry may be i have made wrong accent, i mean does remoteexec runs global if sqf _object remoteExec [_fnc_scriptName,_object] _object is local?
remoteExec alone runs on all machines including server afaik
i mean does remoteexec runs global if no
if you let it execute on _object then it will execute where _object is local
nowhere else
@keen bough No. "isPlayer" is not a typeName
@ruby breach Hmm, still working on how i figure out when a player is in the radius of my spawned npc (named baconMan).
((_position nearEntities ["CAManBase", 5]) select {isPlayer _x}) param [0, objNull];
or some derivation thereof
hmmmmmmm
You can do less if you don't want to return a specific player unit there
Does this work?
_playerDistance = allPlayers distance baconMan;
@ruby breach - Else i would have to use foreach, sort it and find the nearest one ^^
does {allPlayers distance Object} work? https://community.bistudio.com/wiki/distance / https://community.bistudio.com/wiki/allPlayers 🤔
@tough abyssmen so there is completely no traffic on network in that case?
yeah, allplayers gives me all players included the headless back as an array. So, it should be working with distance to another object, right? ^^ I am freaking lazy so that would be great if that really works haha. Gonna test it ^^
you have always network traffic when you use remoteExec @calm bloom
yep that is exactly the thing i am wonder
https://community.bistudio.com/wiki/distance
Syntax:
param1 distance param2
Parameters:
param1: Object or Array in format PositionAGL or Position2D
param2: Object or Array in format PositionAGL or Position2D
``` > Tries to use `[Array of Objects] distance [Object]`
select thing made me believe in smart functions in arma)
I've already given you the solution you're looking for. Don't remember offhand if nearEntities is sorted by distance though, but nearestObjects would be just as good (except slightly worse)
waaa... ouf course it does not work... why did i expect something else while everything i saw, read and have been told says "nope, does not work" ...
Yes, of course a big thank you to you @ruby breach - But also, i only learn when i practically use something to get to the solution myself. Script that others give me, are helping me figuring out how to achieve my goal ^^
i would just copy my weapon-unlock script and rewrite it to sort players distance, so i can actually have, as an idea, make the npc respond differently. Like when 2 players are near and so on.
Use nearEntities or nearestObjects coupled with select to return a list of player units near a desired position. Then use param to select the first element from that list if you want the nearest player unit
No reason to cycle through allPlayers
It selects automatically the nearest one?
For sure if you use nearestObjects
meant the script here:
((_position nearEntities ["CAManBase", 5]) select {isPlayer _x}) param [0, objNull];
nearestobjects is sorted
Don't remember offhand if nearEntities is sorted by distance though, but nearestObjects would be just as good
@waxen tide No one expects backwards compatibility. Nor should it be a focus really, if you can't manage to rebuild your mod for new tech, then that's your fault. The laxyness of people should not compromise progress.
So, technically i have just to write
if (((_position nearEntities ["CAManBase", 5]) select {isPlayer _x}) param [0, objNull];) then {}else{};
?
no
Because you're returning an object, not a boolean
Which brings into question why you even need a sorted list in the first place
If i have a couple mercs with me, anyone can do this mission, eventually, alone. So i need somehow to check via "if" if there is any player near the baconman, followed by if the delivery truck is there too, as well no enemies within 50 metres.
((_position nearEntities ["CAManBase", 5]) select {isPlayer _x} isEqualTo []) //returns true if no players are within 5 meters of given position
this is what i have so far:
https://pastebin.com/Xm38UN64
{
if(_x distance baconman <= 5) then
{
};
} forEach allPlayers;
?
Again, why cycle through allPlayers?
You have a defined position and radius. There are better commands to return objects near that position
okay,
allPlayers select{_x distance baconman <= 5};
Why would you use nearEntities and check if player? Both are valid methods in my mind. Less checks.
aye, right. So, gnashes just hands out the object of the nearest player. I am still very new. So, the object i get back is an array of informations or what do i get as a final result? Please :3
that is the same 😄
I write code assuming allPlayers is going to have 75+ units in it. Often better for performance to use other commands
there multiple anwser with nearentites, where is the problem?
. You could always bench this
oooofff i guess if we are around 10 players, its alot 😄
A iteration through 10 player positions should be next to nothing perf wise
yeah, but always code performance friendly, so you can learn it
No, write what works. Then go back and refine.
nah, two opinions 😄
75 players plus is an extreme example.
i hardly understand this currently, could one explain it to me eventually?
((_position nearEntities ["CAManBase", 5]) select {isPlayer _x} isEqualTo []) //returns true if no players are within 5 meters of given position
I mean, _position, nearEntities i do understand. Likewise the camanbase as well as 5. But after that it gets confusing for me.
select is also understandable. players _x and isequalto is confusing actually
(_position nearEntities ["CAManBase", 5]) //returns an array of all "Man" objects within 5 meters of _position
select {isPlayer _x} //return a list of elements from the previous array that returns true when checked with isPlayer
isEqualTo [] //returns true/false as to whether the list of players is empty
omg! _x is a magic variable!
select {bool} is the same as a foreach loop so _x is the current looped item
i nearly made my head smoke to think what is _x
So, based on the function i am using _x does the foreachloop, right?
(wrong phrasing, but i think i got it now)
So with variable = thecode; i get a true/false statement only? (script from gnashes)
yeah after select you create a code that return a boolean if the boolean becomes true then the current looped item will be added in the new created array what you get from array select {}
it returns true as long no player is near and false as soon a player is near. Awesome
isnt camanbase and man the same, eventually?
Ah, thanks @ruby breach - And the whole script runs now like a charm. On fire. With a flying tank.
does anyone know why extDB3 returns a wacky table when using SELECT? i have to do ((_arr select 1) select 0) select 0 just to get to my data.
Hello!
I have a particle source with water, I would like to know if the water collides with some object in its way
is it possible¿?
I would like to check the line in wich the particle is and if there is a object do somthing
I have read this "You can get position of a particle in onTimer script in particle array" But dont know how
Position of the particle is stored in "this" variable.OnTimer -```
@minor lance If you create a particle with createVehicle - it does return a particle as an object.
how hard is it to add custom ammo types to a base game weapon? specifically, I'd love to make a mod to add lethal loads for the starter pistol. (I'm asking in scripting because I don't think it would require new models or anything... sorry if this is the wrong place)
#arma3_config would be correct place 😄 "how hard" not hard at all.
Weapon has a "magazines" config entry. Just add your own magazines to that. Done.
wow... ok, thanks!
Particle as createvehicle?
Out of the blue: Can i check all the cities via script? I mean, do they exist in any form i could "talk" to or do i have to make the 'talk'-points to each city myself?
I plan to make only mission-templates, those mission spawn in the nearest city where the merc-base is.
Look into locations
perfect, thanks @proven crystal
I have a question regarding the abillity to reset knocked down walls.
I have tried the following code:
{
_x setDamage 0;
}
forEach nearestTerrainObjects [player, [], 50, false]
This works as it resets all the knocked down walls which is good. However the effect appears to be local. What I noticed is that if I execute this on everyone, then leave and rejoin the server, the walls will still be knocked down. The effect will be local for everyone and is not persistant
Please note the paramaters in nearestTerrainObjects are placeholder as I was testing this using the debug console!
So how can I make it persistant so that anybody who rejoins will also see the correct state of the wall?
is there a way to tell arma to play a random sound file from a folder with a bunch of diff sounds in it?
hm, idk if you can get content from a folder but you can count up you sound files and write the numbers at the end and then you can generate a random number in sqf or you make a array with all soundfile names and select one with selectrandom
@autumn swift try to run setDamage on serverside
@minor moth can you show us the script that you use to get the data from the database
@pure blade serverside was tried as well (through the debug console)
but not with these parameters or? 😄
What’s the fastest way to add an element to the front of an array? 🤔
remoteExec globally for everyone?
@cold pebble append i think
@keen bough how do you mean? it depends on the target you given
i meant for the wall problem @pure blade ^^
ah okay haha
@pure blade
// Format the query to send to the database
_query = format["INSERT INTO `vehicles` (`ClassName`, `Position`, `Direction`, `Damage`) VALUES ('%1','%2','%3','%4'); SELECT LAST_INSERT_ID();",
typeOf _x,
str (getPos _x),
str (getDir _x),
str _damage
];
// Send the query to the database.
[1, _query, "SQL"] call SD_fnc_databaseCall;
doesnt really matter anyways, going to switch to a prepared query because extDB3 doesnt have allowMultiQuery enabled in its database connections
have to use sql_custom
yeah i know, but it didnt matter in that case because it wasnt handling any data sent from a client
i used prepared queries all the time in gmod
Is it possible to #include a file in an sqf? Also pass local variables through it?
@carmine abyss Yes it is possible to include a file in sqf. Pass local variables? Why?
#include is a "copy-paste" of target file into yours, you don't pass anything there, its just entire file pasted as is (with other preprocessor # executed)
#include "BlaHBlaAhhhh.sqf"
useMacroBlaaah();
@high marsh I was trying to make a loot table in a separate sqf to keep it clean
Might be easier to make cfg
i'm sure it would be. I'm just a newb
As said. A #include literally copy-pastes the other file into yours. You can do with that whatever you want
ok thank you
@pure blade this is my current code:
{
_x setDamage 0;
}
forEach nearestTerrainObjects
[
getMarkerPos "NameOfMarker",
[],
75,
false
];
Executing it on server side seems to reset the wall on everbody as it should, but the issue remains that new player that connect after this is called will still see the walls in their old state.
Turn it into a function and remoteExec it with the JIP parameter set to true?
Alright, one more question about remoteExec.
Say I execute the following: [] remoteExec ["fnc_resetWalls", 0, true];
This will execute fn_resetWalls for everybody. with JIP set to true, now if JIP happens, will resetWalls be executed again for every client or only on the JIP client?
sorry for the basic questions, this is my first attempt at creating a MP scenario
only for the jip client
Ah ok. Thanks for the assistance gents!
as target you can write -2, so it will be executed on every client, but not on the server
Yeah true, wasn't sure if it would make a difference so I just went with 0
-(number) denotes the inverse of the value you specify. so -2 is all clients, not server. if you were to use something like a clientowner id, you could do -(clientowner) to specify broadcast to everyone except that client
Also, general note. tag your functions. alty_fnc_function
The functionname I gave was just a example.
When i have a object, created via script named 'object_01' and i create it again, will the second one be named 'object_02' ?
not sure what you mean
no, that only works in 3den
If you define it that way, sure. Otherwise the second object is now 'object_01'
that i wanted to know, thanksies.
if you would script a distance checker to cities/etc. Would you use markers instead or use the namecity/citycapital/marine/village/local? I am currently thinking of using empty markers so i dont have to worry what may or may not be a city, village, main city and so on
do i have to execute enableAI where the unit is local?
ie on the headless client if that is involved
yes
locality is always needs to be accounted for
@keen bough markers or just a position array
markers would be easier to go back and edit
i thought of an array first too. But i guess markers would be really easy. Do they impact performance (empty) markers? Or is it neglectable?
its neglectable
super neglectable
but you can place your markers in editor and loop the position of every marker than you have your array very easy
negligible
so i can work out a way to move the merc-box finally as soon i lay down the foundation for dynamic mission spawning
[[_object],
{
private _object = _this select 0;
{
_x disableAI "AUTOTARGET";
_x disableAI "TARGET";
_x disableAI "SUPPRESSION";
_x disableAI "AUTOCOMBAT";
_x disableAI "FSM";
_x enableAI "Move";
} foreach units (group _object);
(group _object) setVariable ["Vcm_Disable",true];
}] remoteexec ["BIS_fnc_call", _object];
this will do?
Definitely not
crap
private object = _this select 1; isn't going to really do much for you
object > _object
oh indeed
_this select 1 > _this select 0 (or even better, param[0,objNull];)
right.... fuck me for copy pasting stuff
but the way to call the code in general with the _object argument there should work i mean?
Looks right. But why use BIS_fnc_call and not just... call?
if you create a public mission then i would create a function for this, allow bis_fnc_call in remoteexec is not a good idea
^ That too
Actually, does [param1,{param2}] remoteExecCall ["call",_target]; even work?
yeah i guess thats simpler...
well im locally testing....
i do get an eror now for the select 0 bit...
type object expect array
Because you're passing _object, not [_object]
ahyes, now works
yeah should work but then you need to use only _this
param and params ignores that convention by the way
1 call {_this select 0}; //error type Scalar expected Array
1 call {_this}; //returns 1
[1] call {_this select 0}; //returns 1
[1] call {_this}; //returns [1]
1 call {_var = param[0]}; //returns 1
[1] call {_var = param[0]}; //returns 1
1 call [params["_var"]}; //returns 1
[1] call [params["_var"]}; //returns 1
😄
Figured I might as well edit it to include all examples
tl;dr: If you're inconsistent in how you pass single variables, use param/params to save yourself errors later.
make sure all your work there ends up somewhere on the wikis ^^
on that note i used remoteexec ["BIS_fnc_call", _object]; because that is on the wiki
but i suppose it does the came if i just use call or spawn or whatever?
why does "BIS_fnc_call" exist?
to execute code
so you pass a code object
or you can pass a compiled code object as well
How do I get the vectorDir and vectorUp that points from one position to another. I'm trying to create a bullet and point it at a position with setVectorDirAndUp and make it fly forward with setVelocityModelspace [0,500,0];. 3-Dimensional Vector math is beyond my expertise so it would be nice if I could get some help.
Thank you
Hey guys. Anybody of you wrote an extension without Visual Studio? I am using CLion cause I am used to Jetbrains IDEs and using the Cygwin Toolchain. I tried to follow Killzone_Kid's tutorial but it has too much stuff that depends on VS and I am not very used to C++ to find my own way with CLion now
ah forget it I just found the wiki
How can i transform the outpot i get from [2031fd29f60# 1779919: truck_02_transport_f.p3d] this to a usable configname? I seem to cant find a way. Anyone a idea or knows how to?
found it. typeOf 😃
i tried to give the found vehicle a name. Script looks like this:
_findVehicle = nearestObjects [testCargo, ["LandVehicle"], 25];
_selectVehicle = _findVehicle select 0;
_vehName = typeOf _selectVehicle;
_vehName setVehicleVarName "transportTruck";
transportTruck = _vehName;
testCargo attachTo [transportTruck, [0, -1.3, 0]];
Currently for testing purpose only. But it throws a generic error. Any clues?
I find a lot of these errors in my server rpt file. sqf Server: Object 4:55 not found (message Type_121) Error: Object(4 : 22) not found Client: Object 4:22 (type Type_121) not found. Server: Object 4:21 not found (message Type_121) Server: Object 4:21 not found (message Type_93) Server: Object 4:20 not found (message Type_93) Server: Object 4:54 not found (message Type_121) Can someone tell me where I can find more info on these errors?
@carmine abyss From what i know and have read, you can ignore those, because they dont have any impact. There seems to be no way to get rid of that as well.
Ty
Is there a way to get the Ace Arsenal export, but without ace, so I can just use the setUnitLoadout
@keen bough _vehName is a string, setVehicleVarName is a method of unit objects
object setVehicleVarName name
that is why you are throwing generic error
i also dont know why you'd need setVehicleVarName. its does not creates a variable that stores a reference to the object, like you are using it. all you'd need to do in order to attach the closest object to testCargo is this:
_findVehicle = nearestObjects [testCargo, ["LandVehicle"], 25];
_selectVehicle = _findVehicle select 0;
testCargo attachTo [_selectVehicle, [0, -1.3, 0]];
Oh, neat, thanks @minor moth another thing i learned.
@minor moth so you pass a code object or you can pass a compiled code object as well
Code == compiled code.
@proven crystal BIS_fnc_call exists because BIS_fnc_MP only supported script function names in the beginning. With remoteExec it became kinda useless.
There is a difference though. Script commands are executed unscheduled. Script functions are executed scheduled.
Meaning if you remoteExec BIS_fnc_call it's actually equivalent to executing the spawn command.
@carmine abyss where I can find more info on these errors -> google.
@kindred lichen getUnitLoadout
when ```sqf
(player distance object) > (objectViewDistance # 0)
for this object used hideObject?
English?
Well I don't understand what you are trying to ask
i try'ing make better client fps. But on my mission i have a lot of objects. I really need all this objects and can't delete them.
For now i have idea - move objects from mission.sqm to script and create them when player near this objects.
Maybe hide + disable simulation + move to [0,0,0] will be better then re-create objects each time, but not sure :3
something like this```sqf
[] spawn {
private _cfg = ["marker1","marker2"];
while {true} do {
{if ((player distance (getMarkerPos _x))<1000) then {[_x,1] spawn spawnObjs;};} forEach _cfg;
sleep 3;
};
};
Objects can be dynamically simulated, can't they?
@west venture i was read about dynamic simulation, bot still don't understand how it works
I'm almost certain that's the case, actually, considering there's an objects distance bar in the dynamic simulation tab of performance settings.
An object that has been specifically set to be Dynamically Simulated stops being simulated when a player - or an activator AI (which can turn on dynamic sim objects) gets out of range.
It is essentially exactly what you're trying to script.
I think AI default to being able to activate dynamic simulation, though, but it might be a mod.
Find Dynamic sim stuff in unit Attributes, find Dynamic Simulation options in Performance on the top bar.
I thought that the constant checking of the player’s distance from each object would make the game harder and affect the performance
No worse than your script would do, I expect, and Dynamic Sim apparently works well enough that BI added it into the game directly.
Dynamic simulation does all distance checking stuff in engine. Much more efficiently than you could ever do
@west venture @still forum Thanks for the help!
so he only need to play with activationDistance, right ?
No scripting at all.
There's a distance slider in the performance options in the editor.
but it's static and not related to actual viewDistance, isn't it?
Dynamic sim isn't related to viewdistance, no - but units that are not being simulated will simply freeze in place in full view of high viewdistance players. This is most notable for air units, so you shouldn't dynamically simulate those.
as i understand - is works good only with mission.sqm? Or i can use script to createObjects?
How do you mean?
So maybe it's needed to update https://community.bistudio.com/wiki/dynamicSimulationDistance to correspond to player's viewObjectDistance for better expirience. For MP - maybe some average viewobjectdistance should be used or viewobjectdistance should be forced to all player =\
i want move objects to script
It's easier for me to work with the script. But if the solution with the editor is better and easier to use - I will still use mission.sqm
@west venture This is what I'm talking about, this is the activationDistance
Since Dusin linked that DynamicSimulationDistance command, which relates easily to https://community.bistudio.com/wiki/enableDynamicSimulation, I imagine you can handle it in a script if you like.
Activation Distance Different distance values for given entity types. Distance is approximate, slider snaps to multiples of 50m. Default values set for infantry mission where players do not have large magnitude scopes or binoculars at their disposal. If such devices are available, try multiply the ranges for Characters and Manned Vehicles by 2x-3x.
From what I understand, objects who have enableSimulation checked will be "active" only if something that can interect with them enter the activation distance
yes
so if you have 6000 of objectViewDistance and 3000 of activation distance - you will see freezed objects outside 3000 m
yup
(or won't see any object, don't know actually)
got it
Unsimulated objects will be visibly frozen.
Combine it with hideObject for best results if you want a high view distance and don't care about long range recon, but you'll get the performance hit from a script trying to emulate the dynamic simulation.
Just to share my outdated expirience:
HideObject + diableSimulation was still less effective than hideObject + disableSimulation + setPos [0,0,0]
So if you won't be pleased with vanilla dynamic simulation - maybe you should try to move objects out of map, it can give you additional FPS
@short trout for setPos i use script?
yeah, but try vanilla dynamic simulation first, my expirience is related to times when engine didn't has in-build feature
@short trout
Sorry for a lot of questions, but how best to make the object move? I do not want to use a trigger, because he eats fps.
You can use loop - https://community.bistudio.com/wiki/BIS_fnc_loop
but again -- dynamic simulation by itself may be effective enough for your needs
@short trout thank you!
I'm in the middle of debugging process.
If I get this value <null> for _randomPos array variable , which one is true for _randomPos? if (count _randomPos == 0) or if (isNil _randomPos)
i choose "isNil _randomPos"
thx
neither
isNull _randomPos
You didn't give enough info though. <null> doesn't look correct. There should be more specific info in there
@still forum thx, here is the code and rpt file.
private _randomPos0 = _this select 0;
_randomPos = _randomPos0 findEmptyPosition [0,20,"B_MRAP_01_F"];
diag_log format["*************: _randomPos: %1, _randomPos0: %2", _randomPos, _randomPos0];
17:28:40 "*************: _randomPos: <null>, _randomPos0: [7062.42,16472.1,0]"
but BIKI for findEmptyPosition says, if not found then [] returned.
I try to use my test extension (only 64bit for now).
Placing the .dll into my Arma3 root C:\Program Files (x86)\Steam\steamapps\common\Arma 3\myext_x64.dll
Starting Arma 3 (64bit)
Going into a mission
Running Debug Console and execute "myext" callExtension ""
to call this stub func
void RVExtension(char *output, int outputSize, const char *function)
{
std::strncpy(output, function, outputSize - 1);
}
.rpt yields therefore: 10:06:59 Call extension 'myext' could not be loaded: Module could not be found.
ℹ I deactivated BattleEye
Maybe your dll requires other libraries that are not in arma directory
You can use this http://www.dependencywalker.com/ to find out what other dll's your's depends on.
Find the non-system dll's that are required and missing. And you know what your problem is
For infantry
Handledamage shows damage AFTER armour, right?
And hitPart BEFORE armour
Help me with the use of the function of the missing body, it does not work.
player setVariable ["Cloak_on", true];
SystemChat "Cloak : Engaged";
player setCaptive true;```
What are the variables that make it disappear?
@still forum i was trying to convey that you can use the compile command to turn string into a code object
For testing i have it currently like this
_nearestBench = nearestObjects [player, ["Land_Workbench_01_F"], 25000];
Now i have questions: Can i still use 'player' in mp and can i expect it uses the player who initialized the script? I could write a script-starter for every single workbench that exists (5) but somehow i want it for general use.
Can i write a bigger code into [?, ["workbench"], 25000] to test each and every workbench against every player and figure out the two nearest to each other?
i didn't explain it the best but i understand it's the same thing
@keen bough depends on what locality you are executing the script. if it's on the server, no. if you are running it on a client, yes
diseapper? @ebon sparrow hideObject?
The script will be running on the server. So should i trie to do a search and test each other out to find the nearest to each other or just write the script to each and every workbench which is just using the workbenches names - no big deal. @minor moth
hideObjectGlobal
player is always the local player. objNull on server because there is no player on server.
Otherwise if it's running on the players computer. Then player of course is player
@still forum character
@keen bough if you are going to use remoteExec to tell the server to do something from the client, you can use RemoteExecutedOwner
to tell what player sent the request
I'm editing server apex farmwork compatibility with mods cysis
Oh, i did not know about that @minor moths Nice, that could work just fine. So 'player' is then the one who called/started the script?
player is the entity of the client that 'player' is executed on. as dedman explained above, it'll be objNull on the server
because it's the server
But with the remoteexecuteowner?
i'd have to know exactly how you are executing your script to tell if it's on the client or the server
remoteExecutedOwner returns the client id of the player making the request to the server
it returns 0 if there is no client making the request
Oversaw that. Is the id usable to be used in nearestobjects actually?
not directly. there is probably a script command i don't know about that takes the client id and turns it into a reference to the unit the client is controlling. i currently loop through allPlayers and compare the owner id of the unit, which isn't very efficient
but i don't know of any script command to do it for me, @still forum probably knows though
My name is dedmen. Not dedman.
sorry lol
You can just iterate through allPlayers. Find the nearest object to each player
and then filter out the closest one
I didnt knowremoteExecutedOwner, what a usefull command, i'm actually sending the player as param then I use owner lol
i wouldn't trust the client with providing itself like that
hmmm, that could work out. I also could execute the script on the client, since the only important thing at the end is the global variable that saves the ressources. @minor moth
if the client isn't doing something like creating vehicles or setting variables, etc. you're probably good to do it all clientside
yah, they have to stay in the vicinity of the workbench, else the script stops automatically.
theres no possible way to createvehicles or anything else haha ^^
by setting variables i mean like setVariable with the global argument set to true, and you never know the environment that you're scripting for. atm i'm currently working on some database mysql stuff where the client can basically do anything, which is bad juju but i do what i can to make it relatively secure
isn't gonna stop anyone from just bis_fnc_call with remoteExec and calling extDB3
i can't use CfgRemoteExec either cus of mod conflicts
why are you using bis_fnc_call ? this is so old
i don't use it
So when i execute the script on a client, the global variable(s) used have to be set via setVariable globally?
anyone can use it though because i'm not using CfgRemoteExec
if you want to access them on other localities yes
but if it's client only, no
aye thanks, i think i can work with the new informations :3 Tank you a lot :3
player setVariable ["lol", lol]; // others player cant access it via getVariable
player setVariable ["lol", lol, true]; // others players can access it
exactly
(∩`-´)⊃━☆゚.*・。゚
Well, i came up with this, am i correct on this one?
storedRawRessources = _miningWork;
missionNamespace setVariable ["storedRawRessource", (+ storedRawRessources), true];
_mineTimerStart = serverTime;
in case multiple players work on different ways to generate the rawRessources?
🤔 wut
- copies an array
Which is useless. As it's copied anyway when it's sent off to others
can there be a problem when two work at the same time?
Don't know what you mean
When you do that setVariable. The variable is set to that value for everyone
Aye, its a script for basically working in a mine, where mercs can generate the ressource "Raw Ressource". Basically, every Dump, Quarry and/or Mine are producing Raw Ressources
As it's copied anyway when it's sent off to others
Intresding. As for code like:
_myArray = obj getVariable "ObjRelArray"; // [1,2,3]
_myArray pushBack 4;
at this point both _myArray and obj getVariable "ObjRelArray" becomes [1,2,3,4]
then what happens if obj getVariable "ObjRelArray" was defined as global true?
🤔
The same thing happens
but the variable only updates locally
it doesn't magically update everywhere else
so i will need setVariable [...,..., true] each time. ok, i was making this already, but was not sure is it necessary or magic exists
Magic does exist. But it only sends moving tanks to the sky.
Well, i came up with this now
missionNamespace getVariable "storedRawRessources";
_miningWork = storedRawRessources + 4;
storedRawRessources = _miningWork;
missionNamespace setVariable ["storedRawRessource", storedRawRessources, true];
_mineTimerStart = serverTime;
That should run on a client and working just fine in multiplayer environment, right?
No you cannot edit the file
it's not meant to be edited
@keen bough That should run on a client and working just fine in multiplayer environment
Well.. If you're fine that everyones storedRawRessources get's overwritten every so often. And if two people set it at the same time, one of the updates will be ignored. Meaning you loose "4" resources
when i have set a variable public once with setVariable, do i have to do it again when ichange it?
_object setVariable ["lol", lol, true]; everytime or is it enough to do it once like that when i initialize some vars?
ah i didnt see that
Is there a way i can "add" it to the current ressources? Like doing "old ressources + new ressources"? @still forum
you are already doing that
Yeah, but i overwrite it with the new value, instead of adding it to the old value?
i first thought i could do it with "oldressource", (+ newressource)
you can't
storedRawRessources = 10;
Player1: storedRawRessources = storedRawRessources + 4;
Player2: storedRawRessources = storedRawRessources + 4;
Player1: missionNamespace setVariable ["storedRawRessource", storedRawRessources, true];
Player2: missionNamespace setVariable ["storedRawRessource", storedRawRessources, true];
Result: 14. But should be 18
You simply cannot do it reliably this way
you can let the server add up the numbers and re-publish the variable
that would be safe
If i would make an array, lets say "alltheressources" i could simply add every single ressource produced from every player to be added to the array and do a simple timed script that deletes the array every so often and add its content to the main rawRessources. Right?
But again. If you publicVariable that array from the client. You'll overwrite other clients data
<sighs> dang. I dont see a way currently not messing up instead of making every ressource-generating place unique.
remoteExec to the server
tell the server you mined 4 resources. Let the server handle it
That works, even when multiple persons are doing the same thing at the same time?
yes
the server cannot do multiple things at the same time
as scripts cannot run in parallel
Nice. I am not sure about how to write it with remoteexec but i came up with this:
[(("storedRawRessource", storedRawRessources, true), missionNamespace)] remoteExec ["setVariable"];
for one. Syntax error
second. another syntax error
third. You are doing the exact same thing that you are doing now. Just in a convoluted and way more expensive way.
hmm, i dont see a solution right now.
run a function on the server