#arma3_scripting
1 messages ยท Page 509 of 1
But you can create and move it to position on server then remoteExec the unit reference to player and selectPlayer into that unit locally on players pc
Plus it's much better at preventing memory leaks
@tough abyss I see. Thanks for the insight
I have a memory leak in my head ๐ค
Honey whiskey usually helps with those
Is there a way to get the vehicle init? like the one we put in the editor?
Just use remoteExecCall with target 0 and JIP true and you got your vehicle init.
how?
Wait are you asking how to do a vehicle init on the fly or how to get the one you set in the editor?
Read the vehicle Init that was set in the editor
Pretty sure it's not possible, but why would you need that anyway?
To get the missions maker custom sethings
Like, locked seats, textures, animations, them aplie on the new vehicle created
basicly I already have a custom respawn system
You could write a function that should be used by the mission maker, when he wants to make part of his code in the init line compatible with your respawn system.
Im trying to make as automated as possible
requiring less imput of the mission maker
Well, but what you want is not possible, so you will have to look for an alternative
@astral tendon You can probably include unbinarised mission sqm into description ext and browse it like it was config, but it is a lot of hassle for nothing
I have the following problem:
I want to check whether a unit is ffv. Not in a ffv turret, but really - weapon in hands, ready to shoot - firing from vehicle. Until now I just iterated fullCrew and checked if the personTurret for the given unit is true.
This worked fine so far but now I realized that this is not the full solution, because slots which can turn out like the loader or commander of a tank and can also ffv when turned out also have personTurret = true. So I tried using isTurnedOut to catch if the unit actually is ffv at the moment. This worked fine for the before mentioned slots, but for ffv only slots (like the ones on the cargo bed of the pickup) not so much, because they always return false for isTurnedOut.
I also thought about checking the currently available weapons and compare them with the primary / secondary weapon, but haven't found a way to get those (weapons to switch to) yet.
Does anyone have an idea how to make this work?
Thanks in advance ๐
yeah, I was trying to play around with that but no juice
there is a class Attributes/init in the mission.sqm, I did not figured how to read that
the mission maker can include the mission.sqm in a description.ext and then you can read it with missionConfigFile
#include a mission.sqm with a billion placed objects all with a ton of attributes ๐
and unbinarized ...
any exemple for the missionConfigFile?
type utils 2 in debug console
select mission config from dropdown menu
you can see all attributes
and browse to the one you want
then copy path and voila
I stoped at MissionSQM/Mission/Entities/
because they are named item0,item1
and so on
how to do a foreach on they?
BIS_fnc_returnChildren
[ (missionConfigFile >> "MissionSQM" >> "Mission" >> "Entities"), 0, false, false ] call BIS_fnc_returnChildren;
returns nothing
toughm there is a was then to seach elements inside that item0?
my apc is the Item44
inside class Attributes there is name="APC_Test";
class Item44
{
dataType="Object";
class PositionInfo
{
position[]={23905.676,5.7293777,18337.158};
angles[]={-0,4.7084274,0};
};
side="Empty";
flags=4;
class Attributes
{
init="call{[this, 3, 999] spawn TG_fnc_vehicleRespawn;" \n "this setObjectTexture [0, ""#(rgb,8,8,3)color(1,0,0,1)""];" \n "this animate [""HideTurret"",1];" \n "systemChat (str _this);}";
name="APC_Test";
textures="Sand";
};
id=113;
type="B_APC_Wheeled_01_cannon_F";
class CustomAttributes
here is a exemple
so how do I seach for it?
Hmm, not sure why BIS_fnc_returnChildren doesn't work. What about a for-loop using _config select _i and count _config to iterate over the items?
or there is also configClasses, which might work with forEach or findIf refering to your last question.
is there any way i can automaticly (by an ai/bot) shot an artillery or morser shot to a players location if they're on there position for too long (except if they are on there spawn) for an anti camp mechanic ( for every side ) ?
commandArtilleryFire or doArtilleryFire will do the job for you
is there a efficient way to check if the player is camping (my idee is to log the player pos every minute and compare it with the old position ) but is there an better way ?
@astral tendon I think you will have a much better time if you rely on the mission makers creating their own templates, that way you can grab info like the init of a unit within the 3den space with just a simple get3denattribute "init" . You can grab and compile all the information for a group/object and spawn it later by calling a spawn function that takes that compiled info as a param
I guess it's fine. Just check the distance between current position and previous position every XXX seconds you like. @quartz oracle
Or collect a few in an array and replace the oldest by the newest. You can calculate the standard deviation for instance ๐
Calculating std dev based on two samples is the same as I have suggested ๐ค
@astral tendon Are you in the editor or in a mission?
I meant a few more than just two. You don't do statistics with two data points ๐
In mission
Sadly those commands dont work outside of the editor. What I am suggesting if that you create array templates within the editor using those commands and spawning them via a function in mission
"(missionConfigFile >> 'MissionSQM' >> 'Mission' >> 'Entities'>> _x) type == "B_APC_Wheeled_01_cannon_F";" configClasses (missionConfigFile >> "MissionSQM" >> "Mission" >> "Entities");
I done that in a rush
configClasses returns configs...
I will have to go to work now, but if you guys can message me about this code to keep testing this I would love it
can i just do ```
difference = new player pos - olf player pos
AND
how can i check the distance every xxx time , just with
``` while (playerNotOnSpawn) {
sleep 60;
check distance;
do more stuff;
}```
or is there an better way ?
I think it will do for now... make it work first, optimize later
Don't you just want to check if the player is within a certain distance over time, not the actual distance?
_pos distance _pos2
Use these for distances between coordinates:
https://community.bistudio.com/wiki/distance
https://community.bistudio.com/wiki/distance2D
while (alive player) do {
...
};
spawn it when player spawns ๐ค
I mean, there must be some event handler in arma which triggers when player actually spawns... not sure. When it triggers, you spawn this script
can i do it in OnPlayerSpawn.SQF ?
but as far as i know there should be an event handler for it
whats a good way to check if an units inside a house these days?
lineIntersectsWith upwards and then check whether the unit is within the BoundingBox?
Well, even boundingBoxReal isn't really accurate. It's the box you see as Zeus when the item is selected...
But lineIntersectsWith is certainly a good way to start.
@quartz oracle But you should really investigate these aspects:
If sample rate is small (1 minute) there might be a situation when the player has moved somewhere and back to the previous position, you script will think that the player was actually camping
Therefore you should reduce sample rate and probably do as @languid tundra suggested. Or use some counter 'if player hasn't moved far from his previous place N times in a row', again with a proper sample rate.
Also note locality. Probably this script should rather be executed on server, because in the end the server will command artillery? ๐ค
_private = if (_first) then {["_classes"]} else {[]};
private _private;
if (_first) then {_classes = [];};
wtf
BIS_fnc_returnChildren
When creating a new unit then adding some variables to this unit through setVariable and then using selectPlayer _unit on that created unit - the namespace of _unit is not applied to player right? That's how it looks like atm. That's why I wanna be sure
oops false info it seems it does apply the variables
No it applies to object of the unit
the namespace of _unit is not applied to player right
no. But player references to _unit
so player getVariable will retrieve the variables
Alright - ye just found out after writing sane code again
when you selectPlayer into the unit, then you can refer to the unit as player hence player getVariable whatever will work
stupid question -where do i find triggers ?
usually between magazine and the grip
not those kind of trigger ... ๐
lol
somethink that activates if an player goes inside / outside of a secific area
They are flag icon in assets in 3den
https://community.bistudio.com/wiki/Eden_Editor:_Trigger i mean those triggers, i dont find them
Press F3 when in eden
was that always there ..?
from day 1
i think im blind or someyhink
(sorry if its the wrong hub)
hello everyone
_playerweapon = currentWeapon player;
_itemclass = (getText(configFile >> "cfgWeapons" >> _playerweapon >> "displayName"));
_itemimg = (getText(configFile >> "cfgWeapons" >> _itemclass >> "picture"));
hint parseText format [" Weapon Image: <img image='%1' size='1'></img>",_itemimg];
where is problem ? this weapon image why don't workin ?
This code result : ```sqf
Weapon Image:
_playerweapon = currentWeapon player;
_itemclass = getText(configFile >> "cfgWeapons" >> _playerweapon >> "displayName");
_itemimg = getText(configFile >> "cfgWeapons" >> _playerweapon >> "picture");
hint parseText format [" Weapon Image: <img image='%1' />",_itemimg];
try that
you're using the weapons display name to get the picture but it still needs to use the classname (_playerweapon).
@rancid pecan because </img> is wrong https://community.bistudio.com/wiki/Structured_Text
using </img> doesnt prevent the image from being shown. Just tested it.
@robust hollow and @tough abyss thanks it's working
is there a way to get the rendering resolution? (I know about getResolution)
All I was able to find was was a VBS command. Doesn't look like an equivalent exists for Arma 3. https://sqf.bisimulations.com/display/SQF/getVideoSetting
maybe read the text from ui? Hacky, but doable?
I changed my TV (4K now), and I want to know the render resolution (not percentage) as it seems 50% seems a bit blurry, and I don't know why
maybe I should simply put the UI resolution at 1K instead
Does anyone know an alternative command to ctrlDelete?
@still forum Are you the TFAR developer?
If anyone is able to help I am trying to make key binds for swapping TFAR frequencies
_channel = (call TFAR_fnc_ActiveLRRadio) call TFAR_fnc_getLRChannel;
_channel = _channel + 1;
[(call TFAR_fnc_activeLrRadio), _channel, _freq] call TFAR_fnc_SetChannelFrequency;
_title = "None";
if(playerSide isEqualTo west || playerSide isEqualTo independent) then {
switch (_freq) do {
case 33.1: { _title = "Military Arms Corp 1"; };
case 33.2: { _title = "Military Arms Corp 2"; };
};
};
["Radio",format ["You are now on %1 %2 frequency.",_title, _freq]] call UPM_fnc_showNotification;```
I get the notification working fine but it snot swapping chnanel
@brave rain From 5 seconds of Google, either your switch statement is in error, or you're trying to pass _freq as a number when setChannelFrequency requires a string
Is _freq a string or a number? If it's a string, your switch statement is incorrect. If it is a number, it needs to be a string.
Based on the fact that you're not changing frequencies, my bet is that it's a number
@languid tundra and @slim oyster thanks for the help I got what I need. now I can get the vehicle init in the editor and apply to a new one
//test is another vehicle
_object = str cursorObject;
_configWithName = ((missionConfigFile >> "MissionSQM" >> "Mission" >> "Entities" ) call BIS_fnc_returnChildren select {getText (_x >> "Attributes" >> "name") == _object});
_ObjectInitString = getText ((_configWithName select 0) >> "Attributes" >> "init");
_Init = "this = " + (str test)+ ";" + _ObjectInitString;
call compile _Init;
Still gonna need some enhance. to make it better, but the main objective is done, and also, that is slow at 1.76367 ms
and this had to be added at description.ext
class MissionSQM
{
#include "mission.sqm"
};
clever!
@brave rain you maybe should've read the rules of TFAR discord before getting banned.
Yes I am the TFAR dev. And I know what's wrong with your code. But if you don't care to read my rules then I don't care to help you either.
@still forum You're a rude person who really shouldn't have the power he does sorrounding TFAR. Shame on you.
I got it working myself from the help of some comptent polite people anyway.
Wow you even sent me a friend request. Did you want to spam via PM too? ๐คฃ
I'd say I'm known for paying lots of attention to the rules, I don't plan to change that.
Where did I spam?
@open vigil Which rule have I broken just so I know for next time, I have read through them mate ๐
Rule 1 in the messages you just deleted
Sorry I asked -FM-
Since you state you've read them, you've obviously not abided by them (I've seen your deleted posts)
!quickban @brave rain
*fires them railguns at @brave rain* ร_ร
@still forum Who is attacking you? Tell me! I will protect one of my precious sources of SQF knowledge at all cost
noone anymore
yea better is that
I have lots of sqf sauce to spare. Just grab a straw
would be odd for the game to track that
extension could certainly do it. Never heard of a script command that does
there is something for dlc usage time. But that's only in current session I think
I have seen people read it from the map screen display
but a manual remoteExec ping might be easier
yeah but the display is written by engine. no sqf command
just diag_ticktime with remoteExec
just execute code that answers back to remoteExecutedOwner. Bam. You have a ping pong
Though not really reliable. Depends on the fps of both participants and on the stage they are currently at in the frame
But I guess 20-30ms difference doesn't matter that much right?
In some cases thats 100% deviation ๐
maybe remoteExecCall then? Will it be better? Or it still sits in the same queue as remoteExec on the receiving side?
And might further be diluted by heavy scripting cause that'll bump execution time, some servers run at like 10 fps on average
same queue no difference
at 10fps you are already at 100ms deviation.. Kinda bad. You could also send along diag_fps to compensate for that
Well... given that distribution is uniform, you could send the ping 10 times and take minimum value
Also it wil be affected by FPS of both computers as I understand
to get such a check semi-relyable, one would need to pass local diag_tickTime and get it synced somehow
best way in the end though is to just tell BI to give us diag_ms
hmm... I know ๐ Make a control loop with feedback to make it nullify your ping error... but that's an overkill
chances are: you would be best off with a custom extension
I already have ping measurement in TFAR. I store the time when a radio request is made to the server, and log the elapsed time when the result comes back
chances are: you would be best off with a custom extension and how do you make that send a ping to a client? You'd need the clients IP
ping 123.456.789```
numbers higher than 255 dont exist in an IP ๐
though ... probably gets blocked by router ๐คท so client extensions would be required too
Seems highly impractical to ask your clients to install an extension just so you can check their latency
Don't see the problem with the remoteExec variant. Just send fps along and maybe substract 1/3rd of frame time
What do you need to know the latency for? If only for technical aspects of your scripts, the measured delay by this method will indeed be the perceived latency by your script from your computer to his and back, I mean it will depend on FPS of both machines anyway.
Suppose you could do that and run a real ping on a server you own and then just approximate the math you gotta do on the return value
Theres a big difference between actual latency and perceived
Real latency has nothing to do with fps
What I mean is, does he need to know only the network latency, or both his game + network + the remote game latency, affected by both engines in this case
And while I'm not sure how exactly arma works I almost have a suspicion that high latency players drag down the performance of everyone else
yea
if you remonte exec you just save the time it takes
same as ping
private _players = allUnits select {isPlayer _x};
missionNamespace setVariable ['mission_civ_sent',CBA_missionTime];
{
//--- runs on the client
// make sure player exists
if (isNull player) exitWith {};
[[player,(diag_fps)],{
//--- runs on the server
params ['_unit','_fps'];
private _sent = missionNamespace getVariable ['mission_civ_sent',0];
private _ping = CBA_missionTime - _sent;
_unit setVariable ['unit_civ_fps',_fps];
_unit setVariable ['unit_civ_ping',_ping];
}] remoteExec ['call',2];
} remoteExec ['call',_players];
You could query BE with extension and get ping from there
or get IP and do it with other tools
If you're adding a custm mod
At that point
I assume it's a private server for a private community
You can manually ban everyone who has high ping
Save the hustle
if you wanted to remove high ping you can just use the serverconfig entry for that
What's neat? The non-fix by BI?
If someone ran scripts to lag players or just createVehicleLocal to the point that their fps is <10 and then checked the fps on another player who still has normal fps.
Maybe the interpolation or whatever causes lag if there is too much missing or sth
at least that explains the constant restarts required by life servers ๐คท
a diag_clearcache command also would have been sufficient if you would ask me (+ the alt syntax obviously)
And this "fix" won't change anything on that. People will need to update their scripts.
And they already chose not to update to parseSimpleArray, so they won't update this time either
just give em the regex for it and be done with it
though ... not like i care what life dudes do
Why are you even using compile?
maybe i will proof how life missions should be written ... once i get around my own database client extension
but fuck sake ... adding a bloody sql connector to c/c++ and get it linked statically is more hazzle then iti s worth it
Just use Intercept. And return arrays directly. No parsing rubbish anywhere.
ahh okay
A database addon was actually something I always thought of as a example use for intercept.
There are some already but none are public afaik
unless you use sqlite, that shit is complicated AF for some reason
or i am just too stupid
probably both
Yeah. Used that too in some project. It's not that nice
@queen cargo you aren't me -> therefore not stupid
yes and no @tough abyss
I wish people could stop asking me "does it affect this"
EVERY compiled script is affected
every script compilation is cached
so yes.. Of course it does
execVM, addAction, eventhandlers. Everything that compiles a string to code
I wish they would fix eventhandlers properly. that's maybe 1 or 2 hours of work. tops.
just use SQF-VM
no memory leaks yet
could add them just for your convenience
and sideload it into the game using intercept
Would be bad if it were recycled
what if action1 tries to remove itself after it has already been removed. It breaks other actions. That's bad
Also unless you know the inner workings, that might not be a memory leak at all.
It might be a map instead of an array internally
I'll check
theoretically, yes @tough abyss
practically, no
you no want more caching
at least your wish is just granted in a matter of time ...
try to find any documentation about how to connect to any big database without "just link against our connector and use that" and rather with "this is the way the handshake is done and that is how data is received"
You don't want to implement your own database connector really
uncached compile is slow, those life database quires will be a drag
i do not want to spend hours to link against theirs either
they should use parse simple array or fuck off
Should just make a proper implementation with git submodule and a proper cmake script for the linking.
I wrote my own database extension for Arma some years back, it wasn't that hard to get the linking correct.. Though.. I don't know where my source code for that went ๐ค
got linking working once with mysql ... but only dynamic
static linking was out of question completely
well we found some issues, not all of them ^^
git submodule also is not really possible iirc (at least for those i tried using)
static linking was out of question completely
Same as dynamic.. But you link mysqlclient.lib instead of libmysql.lib
Quite easy actually
Memory leak doesn't explain performance degredation
ye ... just that the linker had some problems
it has been quite some time
cannot really remember anymore
those are different things
yeah I have static linked C connector for mysql, wasn't straight forward but in the end it worked well
Okey userActions ID's being left is not a memory leak.
just a glorious int counter that gets ++ed?
struct useraction {
int id;
}
array<useractions>
int lastUserActionID;
new action
return lastUserActionID++;
delete action
array find useraction where ID=IdIWant
Wasn't obvious that Arma does it correctly tho. They do many things wrong ๐
So do I get it right: I should not disable caching for functions which are event handlers because then they will not be cached, which will make their compilation longer? ๐ซ
removeallactions doesnt reset counter to 0 <- stupid
@tough abyss no. No condition means empty. And it has a check to skip condition checks if empty
i mean myEventHandlerFnc = compile "myEH.sqf"
oh nvm it will compile anyway
<- stupid no. If you reset it. Some idiot with his bad script comes along 5 minutes later, trying to delete his action but he will delete yours
That's terrible
You have enough space for 3 million actions per object. I don't think that's a problem
if you cater for idiots then you might as well work in the mental asylum and not IT
as pretty much all popular missions require a server restart all X hours, no, never
@astral dawn depends on how you use it in the eventhandler. But it will all compile anyway yes
@tough abyss wrong
it is the general job of the IT to actually make the idiots kings
just try not to hire those same idiots to write the programs
Just think about it. Do you want some idiot to be able to break your stuff by accident?
@queen cargo No you cannot prevent idiots doing idiot things
there is the old theorem: If your old idiot is not capable of breaking your stuff anymore, get a new one
You only waste time and money and make your product restricted and dull
You don't though
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning
yeah I agree to that @queen cargo
you don't know what other mods someone might use if you are a modder or mission maker. You don't know what other scripts he would use in missions if you are a modder
@tough abyss still: you do not end up with "dull" programs
actually, if an idiot is incapable of using your program without consulting your manual, your program is shit
though having added and removed action 1000million times is an idiotic thing to do as well
because that means everybody is required to consult the manual
Generally. If I remove an action with the ID of an action I added previously. I expect either my action to be removed, or if it was already removed nothing to happen.
No one expects that you delete someone elses action. People use the actionID like a handle. A handle that just points to one specific action
A handle doesn't suddenly point to something different
Same thing with removeEventhandler. Actually don't know if it has the ID reuse problem, I think it does
removeAllEventHandlers resets handler to 0, lemmie check
^ this is correct
Eventhandles use the same "nextEventhandlerID" thing like useractions do. That's good atleast.
The ID's being reset to 0 is actually an accident kind of.
Yes it does, what do you say to the idiot that comes with his handler id and removes EH by accident @still forum ?
I cannot say anything to him because I won't know he deleted it. I will just be staring at my screen in awe with a smoking head wondering how this could've possible every happened
the nextHandlerID is stored on the vehicle in addAction, delete and recreate the vehicle you start from 0 again.
with eventhandlers it's stored in the eventhandler type. If you removeAllEventhandlers that type is removed too. And it will be recreated once you create the first handler for that type. That's why the ID is reset.. Not that nice..
wat
where are my glasses
Why do you mix _QS_player and player? Shouldn't you be using the same?
Also won't this cause lag until the action shows up? You'll be there looking at the target, and have to wait half a second till the action apears?
{(_cursorDistance < 1.9)} you can set the action reach in addAction why do you need to check it separately? If your action has limited radius your action condition will not execute until you are in that radius
This is why real-time menus are annoying. So much nicer to only hsve to check anything after a button is pressed
actually ... the trick is to just get told when an update is available
@austere granite I agree, menu ondemand
but that is not possible with arma
Well you could use global vars and then events to set it x39
Unless I'm misunderstanding you
You could check some simple things in a PFH and make your own eventhandlers. Like cursorTargetChanged would come to mind here.
And then split the checks up into smaller checks. If the cursorTarget doesn't match, you don't need to recheck until cursorTargetChanged fires again
you do @austere granite
essentially, disconnecting the actual "display" and the "code"
allowing you to do M V VM
Model being in this case whatever required, view your dialog (+ the impossible observing layer) and viewmodel just some variables
though ... ๐ค such a framework might be possible with a lot of fancy methods
I'm more thinking about scripted events like dedmen said
https://community.bistudio.com/wiki/inGameUISetEventHandler you can add action menu visibility into condition, no visibility no condition evaluation, this would safe shit load of power on long conditions
Thinking about actually making a intercept database thingy..
How to make building queries make sense. I'm thinking about this
DB_Cache_InsertQuery = db_prepareQuery 'INSERT INTO positions (name, x, y, z) VALUES (?,?,?,?)';
private _insertQuery = db_copyQuery DB_Cache_InsertQuery; //Such that you can prepare queries that you often reuse, maybe even with values already bound to the query
_insertQuery db_bindValue (name player); //Binds value to next available placeholder
_insertQuery db_bindValueArray (position player); //foreach value {Binds value to next available placeholder}. So this sets x,y and z
private _errorcode = db_queryAsync _insertQuery;
for the caching you could for example prepare a query with the name of the player already bound to it. And then just copy it and add the position everytime you need to update the players position
That's what mysql can do too https://dev.mysql.com/doc/refman/5.7/en/sql-syntax-prepared-statements.html
if you want to do it, do it proper though ๐คท
not like this weird "bindvalue" bla
also you lack the db connection currently there
Also feels MUCH easier to use than glueing stuff together with format
What do you propose instead of bindValue?
Mh. I could provide the db connection at the queryAsync command, or at the prepareQuery stage ๐ค
I think providing connection at execution makes more sense
can give you a list in a few mins
But in general, if you are using action menu, you are not doing yourself a favour, Arma 3 went lightyears ahead of Arma 2 in terms of available commands for making UIs you should abandon that piece of shit no good ancient system for noobs and make your own
currently busy at work
Could do it like mysql does _insertQuery db_queryAsync [(name player), (position player)];
like mysql's EXECUTE stmt1 USING 1, 2;
there is not only mysql true dat
Most people use mysql or sqlite I'd say?
Me doing it that way in scripting doesn't mean you are forced to use mysql in backend.
It's just for convenience. The backend can plug things together to work with any db
postgre is as popular
you can redo doors with own UI, you can pretty much disable HUD and make own UI for almost everything or make a mod
Types:
- DBCONNECTION
- DBSET
- DBCMD
Commands:
- createConnection STRING -> DBCONNECTION
- DBCONNECTION createCommand STRING -> DBCMD
- DBCMD addParameter [Name:STRING, Content:ANY] -> NIL
- execute DBCMD -> SCALAR (Affected records)
- executeQuery -> DBSET
- isReady DBSET -> BOOL
- next DBSET -> NIL
- headers DBSET -> ARRAY (strings)
- row DBSET -> ARRAY
should be sufficient
unless i missed out on something
might as well invest those 100 hours in learning Enforce
100 hour time sink wat?
but they have fixed some of the worst issues with it (selecting the correct door) for instance
Was there an update Im not aware of?
I'm confused now
I thought more like "dbvalue" type inside the result set. a value can be string or number or array of values.
And there is a function to turn it to array of script values directly. Like parseSimpleArray would do
๐คท @still forum
both is possible
not really matters
that is just generic enough for all systems
Oh! And i didn't even think about async queries with callbacks!
If you gonna do db integration I would think big and plan for a central backend DB and server local DBs to talk to the backend
can you explain that? Don't quite understand
technically, there would still be "close connection" etc.
but due to garbage collection, that should not be required (just close as something moves out of scope)
RAII in SQF ๐
one could go even nitpickier by saying eg. there is no "get row" and rather "DBSET getvalue SCALAR"
so that you have all stats and whatnot kept at the central database and all immediate stats related to player playing on a particular server on the local server db. So 100 players on the server have direct quires to local server DB and 100 servers have direct quires to the backend DB
@still forum you may also want to dive into this lil class tree https://docs.microsoft.com/de-de/dotnet/api/system.data.common.dbconnection?view=netframework-4.7.2
I'd say that's outside of my realm. If people wanna set up big cluster like things they can do that seperately
the actual database connection has nothing to do with load balancing btw
that is a database side thing
I'd just build the game->database
What you are proposing is game->database->central database
The user can implement the second part himself
In MySQL you can have Federated tables but it looks like a huge pain in the ass
I moved to #arma3_tools as that makes more sense
Anyone can help?
I create one AI and try to move inside heli. But it isn't working.
Here is code
_man = "B_Competitor_F" createVehicle [10,10,10];
_man moveInCargo [(vehicle player), 3];
_man assignAsCargoIndex [(vehicle player), 3];
use createUnit not createVehicle
or createAgent
oh my god
dear lord
still in Zeus mode @frigid raven ?
{
_unit = _this select 0;
_UnitIsInSpawn = true;
_OldUnitPos = [9999, 0, 9999];
while !(_UnitIsInSpawn) do
{
_OldUnitPos = _unitPos;
sleep 30;
_unitPos = getpos _unit;
if(_unitPos distance2D _OldUnitPos <= 10) do
{
AntiCampArti doArtilleryFire [_unitPos, "HE", 1];
hint "Arti Fire";
}
else { hint "no Arti Fire"; }
};
}];```
there is an error in the first line
```Unknow enum value: "MPRespawn"```
while CODE is expected
you pass while BOOL @quartz oracle
so how too fix it ?
Here's the example from biki while {a < b} do {a = a + 1};
do it correctly
instead of passing some bool, pass a code type that evaluates your bool ๐
so i have to change ( ) with { } ?
it is not a "simple change"
it is important that you realize the difference
{} is a code block
and returns "roughly" a set of instructions
on the other hand () is just to group stuff (like in math esentially)
yeah o know i just dont know (until now) that you have to do { } in while loop (in other languages i used ( ) for while too )
Is there a way to get and add vehicle modifications like the cages in the APCs?
add no. They are embedded into the model
So, some one have a vehicle editing function handy?
{
_OldUnitPos = _unitPos;
sleep 30;
_unitPos = getpos _unit;
if(_unitPos distance2D _OldUnitPos <= 10) then
{
AntiCampArti doArtilleryFire [_unitPos, "HE", 1];
hint "Arti Fire";
}
else { hint "no Arti Fire"; }
};```
there is somethink wrong with sleep but i dont know what it says
```Generic error in expression```
i dont know whats wrong and how to fix it
is the _unitPos variable in third line defined?
not really
i added this line _unitPos = getpos _unit; befor the _OldUnitPos = _unitPos; but the error still occurs
Well is _unit defined?
would someone be willing to point me in the direction of how to do the following
id like to have it so that when a player joins and after they select a role and connect to server, have their map open and the briefing item that i create for their role be open.
just check if all your variables are valid
_unit = _this select 0; hope this is enough (comes befor the while loop)
like i said its says the error is in the sleep line
ill try it
also the code does massive amount of lag ( low fps ) for me
{
_unit = _this select 0;
_UnitIsInSpawn = false;
_unitPos = getpos _unit;
_OldUnitPos = [9999, 0, 9999];
while {!_UnitIsInSpawn} do
{
_OldUnitPos = _unitPos;
[] spawn { sleep 15; };
_unitPos = getpos _unit;
if(_unitPos distance2D _OldUnitPos <= 10) then
{
AntiCampArti doArtilleryFire [_unitPos, "HE", 1];
hint "Arti Fire";
}
else { hint "no Arti Fire"; };
};
}];```
this code does massive lag
and i dont know why, please help
@quartz oracle do you know what while do construct does?
yes i think so
Tell me
execute the code over and over as long as the condition are right
any help would be appreciated on how to forcibly open a briefing item on a player client via script
So it creates endless loop inside your event handler right?
So EH cannot finish its code and since it is unscheduled it will not let any other process start until it is finished
See where Iโm getting at?
there is no other code
@quartz oracle that while will be re fired and keep running every time the player respawns. also you need to wrap your code in the eventhandler in a spawn so you can use a sleep in the while loop so that its not checking every micro second. i would add something to the loop so that it doesnt generate another while loop run everytime the player respawns. you need to have a condition in it to stop it from running on the next time the player respawns.
Clever programmers from BI however foresaw this idiotic use and added limit on how many times the loop can run in unscheduled of 10000 iterations so your game gets frozen for 10000 iterations every time EH fires
Luckily it only fires on 1 PC - yours, so no damage is done, carry on
hint this is not a blocking call hint
any help would be appreciated on how to forcibly open a briefing item on a player client via script from a server side addon
{
_unit = _this select 0;
_UnitIsInSpawn = false;
_unitPos = getpos _unit;
_OldUnitPos = [9999, 0, 9999];
while {!_UnitIsInSpawn} do
{
_OldUnitPos = _unitPos;
[] spawn { sleep 15; };
_unitPos = getpos _unit;
if(_unitPos distance2D _OldUnitPos <= 10) then
{
AntiCampArti doArtilleryFire [_unitPos, "HE", 1];
hint "Arti Fire";
}
else { hint "no Arti Fire"; };
};
}];``` there is an sleep
you clearly did not understood what spawn is actually doing
Thats better you just spawned 10000 scripts
there is an spawn befor the sleep but i know what zou mean srz
a lil research will tell you, that spawn actually is like you tell the engine to run this code later
๐
@quartz oracle
player addMPEventHandler ["MPRespawn",
{
[_this select 0] spawn {
_unit = _this select 0;
_UnitIsInSpawn = false;
_unitPos = getpos _unit;
_OldUnitPos = [9999, 0, 9999];
while {!_UnitIsInSpawn} do
{
_OldUnitPos = _unitPos;
_unitPos = getpos _unit;
if(_unitPos distance2D _OldUnitPos <= 10) then
{
AntiCampArti doArtilleryFire [_unitPos, "HE", 1];
hint "Arti Fire";
}
else { hint "no Arti Fire"; };
sleep 1;
};
};
}];
any help would be appreciated on how to forcibly open a briefing item on a player client via script from a server side addon
can you just open a briefing item on your own computer already?
@exotic tinsel you need to open map and hack tasks control
Maybe there is a command I wouldnโt swear
Look in BI scripts for Apex missions
does someomne know what causes the bug where i cant respawn (the map get shown but not the think where i can change respawn position, loadout and where the repsawn button is ) ?
if someone know what causes this pleas say how i can fix it, thanks
happens randomly. Killing yourself fixes it most of the time
player setDamage 1.
Executing that code is not so easy though
i cant open menu via esc
Yep.. I have a hotkey to execute scripts.
If someone else is on the server and already spawned he can kill you
@still forum he have problem with code in respawn EH. I try to help him now ๐ ๐
@quartz oracle send error screen here
the error on the screen had nothink to do with it
I think you have error with expression in that EH
also i cant send pics here
You can give link on it.
{
[_this select 0] spawn {
_unit = _this select 0;
_UnitIsInSpawn = false;
_unitPos = getpos _unit;
_OldUnitPos = [9999, 0, 9999];
while {!_UnitIsInSpawn} do
{
_OldUnitPos = _unitPos;
_unitPos = getpos _unit;
if(_unitPos distance _OldUnitPos <= 1000) then
{
AntiCampArti doArtilleryFire [_unitPos, "HE", 1];
hint "Arti Fire";
}
else { hint "NO Arti Fire"; };
sleep 30;
};
};
}];```
this code dont give any errors but still dont work :/ someone know why ?
((allMissionObjects "") select {_x isKindOf "Box_C_IDAP_UAV_06_medical_F"}); //73.1429 ms
is there a equivalent with the same result but faster?
Can you limit it to a radius? If so, try nearObjects instead.
Nope, need to check all maps placed objects
try nearObjects anyways with the radius being the worldsize
player nearObjects ["Box_C_IDAP_UAV_06_medical_F", 10000]; //53.5789 ms
meh, still slow
Yeah I got pretty much the same results. Except even slower.
Can you analize classes in mission.sqm, @astral tendon?
Im sorry?
class Item44
{
dataType="Object";
class PositionInfo
{
position[]={23905.676,5.7293777,18337.158};
angles[]={0,4.7084274,0};
};
side="Empty";
flags=4;
class Attributes
{
init="call{[this, 3, 999] spawn TG_fnc_vehicleRespawn;" \n "this setObjectTexture [0, ""#(rgb,8,8,3)color(1,0,0,1)""];" \n "this animate [""HideTurret"",1];" \n "}";
name="APC_Test";
textures="Sand";
};
id=113;
type="B_APC_Wheeled_01_cannon_F";
seems possible
but using that code I have posted is also slow
Hmm
Can you checking all classes by "for" cycle?
like
for "_i" from 0 to 1000 do {
if (configFile (fromat ["class Item%1", i]>>type) == "B_APC_Wheeled_01_cannon_F") then {
//do something
}
}
something like that
Nah, cant figure it
What if there are more or less than 1000 objects? Doesn't make sense to be using for loop
also, you could just use getText,
if(getText(configFile >> "type") == "B_APC_Wheeled_01_cannon_F") then
{
};
_currentObject = _x;
_actionFarp = ["tg_farpAction", "Repair All", "\a3\ui_f\data\IGUI\Cfg\simpleTasks\types\repair_ca.paa", {[_target] spawn TG_fnc_farpAction;}, {true}, {}, [], [0,0,2],10] call ace_interact_menu_fnc_createAction;
[_x, 0, ["ACE_MainActions"], _actionFarp] call ace_interact_menu_fnc_addActionToObject;
Does anyone knows in ACE the Distance argument for me here is not working (10) and distance still the default of 2(?)?
@high marsh 1000 is not principal number. for cycle in A3 is very fast and i think, that we can use it for this task ๐ต
but that's hundreds of useless checks...
unless you were able to get the array length of the object array
then there would be no point in using the for loop anyways, because then you can just itterate through the entire array
_perf = ["allMissionObjects """" findIf {typeOf _x isEqualTo ""Box_C_IDAP_UAV_06_medical_F""};"] call BIS_fnc_codePerformance;
//13.68 ms
@astral tendon allMissionObjects "Box_C_IDAP_UAV_06_medical_F"
@tough abyss 71.2 ms
that is impossible Oo
unless BI fucked up in a way that i could not even imagine, that is not possible
nope
I think that's his entire script.
allMissionObjects "Box_C_IDAP_UAV_06_medical_F" being slower then allMissionObjects "" findIf {typeOf _x isEqualTo "Box_C_IDAP_UAV_06_medical_F" is logical?
yep
Ok enlighten please
how on earth is that possible?
allMissionObjects "" does no filtering. Meaning it just copies the array of all objects.
findIf stops at first object that matches.
allMissionObjects "Box_C_IDAP_UAV_06_medical_F" Does filter. It has to iterate through all objects and compare each one, without stopping early once it found the first
worst case. findIf stops after the first comparison. And allMissionObjects is always O(n)
It also defeats the purpuse if I need to find more than 1 box.
use apply then
Hold on what was the objective, get all objects if that type or one object?
actually ... i kinda missed the point that the first only looked for a single entry ... think it is bed time
How could it be slower that the one with select
simple allocate & copy vs iterate and allocate & copy
and iirc https://community.bistudio.com/wiki/allMissionObjects with "" is not returning "all" objects
Okie, so allMissionObjects "type" should be used when needing more than one box
apply, select, all same perf with it
It returns all types and some
Would it be more performant to just do that in a CBA class EH and spawn the box afterwards?
Yes yes yes good good good join my cult
@digital hollow That's what I was thinking, so that you always have a list of them no matter the situation
@astral tendon do both methods return equal amount of results? Could you add count (....) to see how many results are returned to compare?
Anyway, back to the allMissionObjects. it is weird that there is no significant improvement over using direct filter, but hey, Arma is Arma. Here are my times for 100 randomly placed objects on Tanoa:
`Result:
7.14286 ms
Cycles:
140/10000
Code:
allMissionObjects "Box_C_IDAP_UAV_06_medical_F"
Result:
7.41481 ms
Cycles:
135/10000
Code:
((allMissionObjects "") select {_x isKindOf "Box_C_IDAP_UAV_06_medical_F"})
Result:
7.38971 ms
Cycles:
136/10000
Code:
((allMissionObjects "") select {typeof _x isEqualTo "Box_C_IDAP_UAV_06_medical_F"})
Result:
0.0385 ms
Cycles:
10000/10000
Code:
entities "Box_C_IDAP_UAV_06_medical_F"`
Basically use entities
Been wondering about this @tough abyss, it seems like the use of entities or XEH is always better than allMissionObjects. I believe allMissionObjects detects things that the other two cannot right? That might be the only benefit
is there any good way to check if an player is near his spawn ?
distance
savedplayerposvar = getpos player on a postInit or waituntil, then query player pos again and distance/distance2d to that original pos.
maybe an easear way with triggers or ?
player in thislist in a trigger that checks player side presence repeatedly
@tough abyss That seems to be the way to go.
Just repeating a question:
_currentObject = _x;
_actionFarp = ["tg_farpAction", "Repair All", "\a3\ui_f\data\IGUI\Cfg\simpleTasks\types\repair_ca.paa", {[_target] spawn TG_fnc_farpAction;}, {true}, {}, [], [0,0,2],10] call ace_interact_menu_fnc_createAction;
[_x, 0, ["ACE_MainActions"], _actionFarp] call ace_interact_menu_fnc_addActionToObject;
in ACE the Distance argument for me here is not working (10) and distance still the default of 2(?), am I missing something?
how do i do & in if statements
if(((_unitPos distance _OldUnitPos) + (_OldUnitPos distance _OldOldUnitPos)) / 2 <= 1000) && !(_unit in BlueforSpawnPlayerList) then this is how it looks currently
if ( bool && bool) then {}
thanks
https://community.bistudio.com/wiki/Operators
Check logical operators here
is the texture global and persistent?
@still forum , @peak plover got a code handy for the vehicle modifications
_VehicleModifications = [_thisVehicle,""] call BIS_fnc_exportVehicle;
_instalVehicleModifications = ("_this = " + (str _newVehicle)+ ";"+_VehicleModifications);
call compile _instalVehicleModifications;
This is from my vehicle respawn, it takes the modifications from the old vehicle and place in the new one
BIS_fnc_exportVehicle get the modifications+code it and then I did that trick to add those modifications to a new vehicle
If you guys can, add some notes in the BIS_fnc_exportVehicle about this feature and maybe make a better exemple, it will also help people with my same problem
How to open "ebo" files?
you dont, they arent meant to be opened.
wiki says the effect is global so should be persistent.
just need to execute it on the client where the turret is local
Got it
{
_object = _x;
_animationsArry = animationNames _x;
{_object animateSource [_x,0,true]} forEach _animationsArry;
} foreach (nearestObjects [player, ["all"], 50]);
``` does not work
```sqf
{
_object = _x;
_animationsArry = animationNames _x;
{_object animate [_x,0]} forEach _animationsArry;
} foreach (nearestObjects [player, ["all"], 50]);
```Works
why is the biki recomending the use of animateSource if that does not work?
and "Door_1_sound_source" is unreliable because some double doors opem only one of they
animationNames returns names for use with animate so unless the source name is the same it wont work.
double doors may have a source for each door.
Is there a way to get those other souces? and also, what is it with animate reliability?
i dont know of a command for returning source animation names, however you can see what the available names are in cfgvehicles: configfile >> "CfgVehicles" >> _className >> "AnimationSources"
it has stuff in it but how to get all strings sinde each?
im not sure what you mean. all the class names from "AnimationSources" ?
to make stuff easy for me
{
_object = _x;
_animationsArry = animationNames _x;
{
_object animateSource ["Door_1_sound_source",0,1];
_object animateSource ["Door_2_sound_source",0,1];
} forEach _animationsArry;
} foreach (nearestObjects [player, ["all"], 50]);
``` takes 1.74216 ms
```sqf
{
_object = _x;
_animationsArry = animationNames _x;
{_object animate [_x,1]} forEach _animationsArry;
} foreach (nearestObjects [player, ["all"], 50]);
``` takes 1.18182 ms
animate is faster, so is there any other reason to use animateSource?
it is apparently more efficient and optimized for multiplayer
What problens I can run into with animate?
idk? animate works fine but animateSource is better for mp scenarios.
https://community.bistudio.com/wiki/animateSource imo this explains the difference well if anyone bothers to read it all
Why not ask taro how he did it?
He said how he did it
That is why its a hack of the pilot camera rather than some camera object attached to the plane
It's not a camera object.
I dont see any event handlers for closing the arsenal in a similar fashion to InventoryClosed, is there anything else I can use?
Currently on really bad internet, I'll check it out once it loads
So only with cba :/ alright, thanks
uh no
no cba in there
//onArsenal PostClose event
[missionNamespace,"arsenalClosed", {
<stuff>
}] call bis_fnc_addScriptedEventhandler;
Ah yea that works, thanks
np
where do i have to put scripts so that they get executet for every player, for example ```
player addMPEventHandler ["MPRespawn",
{
[_this select 0] spawn {
_unit = _this select 0;
_UnitIsInSpawn = false;
_unitPos = getpos _unit;
_OldUnitPos = [9999, 0, 9999];
while {!_UnitIsInSpawn} do
{
_OldOldUnitPos = _OldUnitPos;
_OldUnitPos = _unitPos;
sleep 5;
_unitPos = getpos _unit;
_ArtiAmmo = getArtilleryAmmo[AntiCampArti] select 0;
if((((_unitPos distance _OldUnitPos) + (_OldUnitPos distance _OldOldUnitPos)) / 2 <= 1000)) then
{
AntiCampArti doArtilleryFire [_unitPos, _ArtiAmmo, 1];
hint format [ "%1", name _unit];
}
else { };
};
};
}];``` i already tried init, initoplayerlocal, initserver
initPlayerLocal.sqf will run on every client when the join the server. How did you add that to your initPlayerLocal?
if you want to make one or multiple remote machines execute something, use remoteExec or remoteExecCall
it is just one arti who should fires on all player who are too long on the same position
MPRespawn doesnt sound like the correct event for that
Got another issue myself
addMissionEventHandler ["HandleDisconnect", {
_unit = _this select 0;
_UID = _this select 2;
_gear = getUnitLoadout _unit;
_persistentDB = ["new", _UID] call OO_INIDBI;
["write", ["Player Info", "Gear", _gear]] call _persistentDB;
}];
Never fires
No error message, it just never happens
Its in initServer.sqf where it supposedly belongs
i now pastet the code into onPlayerRespawn ```[_this select 0] spawn {
_unit = _this select 0;
_UnitIsInSpawn = false;
_unitPos = getpos _unit;
_OldUnitPos = [9999, 0, 9999];
while {!_UnitIsInSpawn} do
{
_OldOldUnitPos = _OldUnitPos;
_OldUnitPos = _unitPos;
sleep 5;
_unitPos = getpos _unit;
_ArtiAmmo = getArtilleryAmmo[AntiCampArti] select 0;
if((((_unitPos distance _OldUnitPos) + (_OldUnitPos distance _OldOldUnitPos)) / 2 <= 1000)) then
{
AntiCampArti doArtilleryFire [_unitPos, _ArtiAmmo, 1];
hint format [ "%1", name _unit];
}
else { };
};
};```this code i deletet the event handelr
is there a way to rerun the init on an object?
That aircraft camera is shite why would anyone want to repeat it?
Plane looks like RscPicture at the bottom of the screen
Is there a maximum length for ropes? I can't seem to create one longer than 100m
Trying to get better at scripting, and wanted to know if the following is possible...
I want to check if 2 array constrains the same things, NO MATTER the order.
So ["1","2","3"]; would be the same as ["3","2","1"] and would return true.
Been trying to use BIS_fnc_areEqual but that also check the order
anyone is using armadev app for visualstudio code?
That wasn't quite it
We had that conversation a week ago @cobalt charm https://discordapp.com/channels/105462288051380224/105462984087728128/531525352657387521
What kind of values do you have? Are there always the same number of elements?
It's strings
ACE arsenal is a different arsenal, thus different eventhandler which needs cba
I thought using CBA XEH, but turns out not needed in this case
Could someone be very nice and explain event handlers? and yes, I'm looking at the wiki.
this addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
}];``` What is `this` in terms of: if I was to have the player shoot an entity. Would the player or the entity, be `this`?
Sounds like it needs to be attached to the entity, if you want to avoid that you could use EntityKilled
What about this? sqf allUnits addEventHandler ["Killed", { params ["_unit", "_killer", "_instigator", "_useEffects"]; if (_killer isEqualTo player) then { player getVariable ["money", 0]; private _cost = 50; private _balance = _money + _cost; player setVariable ["money", _balance, false]; }; }];
I'm not sure if thats more effective than simply using a addMissionEventHandler
mission event handler with entitykilled simply triggers whenever something is killed, allunits EH will be attached to every single unit
Okay.
Why would I be getting: scalar NaN error with _balance: ```sqf
{
_x addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
if (_killer isEqualTo player) then {
_killer getVariable ["money", 0];
private _cost = 50;
private _balance = _money + _cost;
_killer setVariable ["money", _balance, false];
hint format["%1, has now got a balance of: %2",name _killer,_balance];
};
}];
} forEach allUnits;```
Whats the false doing there?
making it ~not~ public
you never define _money in that event
Oh lol
Would this satisfy it? ```sqf
{
_x addEventHandler ["Killed", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
if (_killer isEqualTo player) then {
private _money = _killer getVariable ["money", 0];
private _cost = 50;
private _balance = _money + _cost;
_killer setVariable ["money", _balance, false];
hint format["%1, has now got a balance of: %2",name _killer,_balance];
};
}];
} forEach allUnits;```
Hey if I do sqf _closeguys = nearestObjects [player, ["Man"], 50]; is there an easy way to parse out group leaders from the _closeguys array?
_closeguys = _closeguys - ['B_Soldier_SL_F']; should work?
I can't guarantee the classname of the group leader though
Ah
nearestObjects[player, ["Man"], 50] select {_x isEqualTo (leader group _x)};
something like this maybe?
Ok cool I see where you're going,
How would EntityKilled and Killed be different @minor needle ? I can see your logic of it's use.
nvm
Killed is an eventhandler you attach to every unit entitykilled is more like a watchdog
Found it
They both work, and I'm not sure about the performance difference and if it even matters, it just seems like entitykilled is more efficient
Also consider _killedSide = (side group _killed);
if (_killedSide == east) then etc. ๐
I wrote something pretty similar just recently, except with xp and levels instead of money
addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
if (_killer isEqualTo player) then {
private _money = _killer getVariable ["money", 0];
private _cost = 50.00;
private _balance = _money + _cost;
_killer setVariable ["money", _balance, false];
systemChat format["%1, has killed: %2. Faction has gained: ยฃ%3", name _killer, name _unit, _cost];
systemChat format["Current Faction Balance is: ยฃ %1",_balance];
};
if ((side _unit) isEqualTo west || (side _unit) isEqualTo civilian) then {
private _money = _killer getVariable ["money", 0];
private _cost = 100.00;
private _balance = _money - _cost;
_killer setVariable ["money", _balance, false];
systemChat format["%1, has killed: %2. Faction has lost: ยฃ %3", name _killer, name _unit, _cost];
systemChat format["Current Faction Balance is: ยฃ %1",_balance];
};
}];```
You'll wanna check the side on the first if case too otherwise you reward 50 and then subtract 100
hmm. Sometime's it is defining the dead units as Civilian... when they where east.
Fixed it by placing the side check first. sqf addMissionEventHandler ["EntityKilled", { params ["_unit", "_killer", "_instigator", "_useEffects"]; if ((side _unit) isEqualTo west || (side _unit) isEqualTo independent) then { private _money = _killer getVariable ["money", 0]; private _cost = 100.00; private _balance = _money - _cost; _killer setVariable ["money", _balance, false]; systemChat format["%1, has killed: %2. Faction has lost: ยฃ %3", name _killer, name _unit, _cost]; systemChat format["Current Faction Balance is: ยฃ %1",_balance]; }; if (_killer isEqualTo player) then { private _money = _killer getVariable ["money", 0]; private _cost = 50.00; private _balance = _money + _cost; _killer setVariable ["money", _balance, false]; systemChat format["%1, has killed: %2. Faction has gained: ยฃ%3", name _killer, name _unit, _cost]; systemChat format["Current Faction Balance is: ยฃ %1",_balance]; }; }];
oh wait
lol
fuck me
Are there any invisible objects that are affected by physics?
@vapid drift What do you mean by invisible?
not visible by players?
That would be pretty inefficient by the engine if that existed
Well. you can make texture's hidden, that would be able to be physics
So nothing natively then?
no
alright, thanks
@minor needle Does this make sense? ```sqf
addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
switch (side _unit) do {
case west : {
};
case east : {
};
case independent : {
};
case civilian : {
};
};
}];```
And probably compare side _unit with side _killer so you dont reward tking
Assuming east and west are both playable factions
it's just fool proofing it. ๐ It's intended as just blufor.
Ah ๐
Might as well do it this way. So it doesn't matter what side the player is on.
So... I don't understand.
What dont you understand?
No I mean if (side _killer isEqualTo side _unit) then {};
I think the syntax is side group, not sure if just side works too
addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
switch (side _unit) do {
case west : {
if (side _killer isEqualTo side _unit) then {
private _money = _killer getVariable ["money", 0];
private _cost = 100.00;
private _balance = _money - _cost;
_killer setVariable ["money", _balance, false];
systemChat format["%1, has killed: %2. Faction has lost: ยฃ %3", name _killer, name _unit, _cost];
systemChat format["Current Faction Balance is: ยฃ %1",_balance];
} else {
private _money = _killer getVariable ["money", 0];
private _cost = 50.00;
private _balance = _money + _cost;
_killer setVariable ["money", _balance, false];
systemChat format["%1, has killed: %2. Faction has gained: ยฃ%3", name _killer, name _unit, _cost];
systemChat format["Current Faction Balance is: ยฃ %1",_balance];
};
};
case east : {
};
case independent : {
};
case civilian : {
};
};
}];```
yea pretty much
Kay.
Oh also
if (isplayer _killer) dont forget that
Otherwise you reward the money to every player of the faction for a kill
I think
Or maybe not, idk
Good to have it in anyway otherwise you run unnecessary code on everyone when it only needs to run on one person
Then you shouldnt reward money to _killer but faction _killer
or side _killer to stick with the syntax
either side group _killer or faction _killer?
o yea that works lol
The _balance is sometimes undefined.... wtf man lol
Had to `diag_log it: 2:23:20 "Chrystophoros Moraiti, has killed: Abdul-Basir Bahadur. Faction, GUER. has gained: ยฃ50" 2:23:20 "Current Faction Balance is: ยฃ scalar NaN" 2:23:22 "Michalis Lara, has killed: Abdul-Qadir Amin. Faction, GUER. has gained: ยฃ50" 2:23:22 "Current Faction Balance is: ยฃ scalar NaN" 2:23:22 "Michalis Lara, has killed: Idris Nazari. Faction, GUER. has gained: ยฃ50" 2:23:22 "Current Faction Balance is: ยฃ scalar NaN" 2:23:22 "Michalis Lara, has killed: Farid Habibi. Faction, GUER. has gained: ยฃ50" 2:23:22 "Current Faction Balance is: ยฃ scalar NaN"
oh that's just me...
nvm
Looks like its always undefined
Why _cost?
Heres mine if thats any help lol
Though I initialize all the variables in an inidbi function
I'm having an issue defining this variable.sqf _money = eastMoney getVariable ["money", 0]; diag_log format["Current Faction Balance is: ยฃ%1",_money];
The variable needs to be attached to an entity I believe
It is. a Game Logic
hm
,0 ended up giving me "false" in my inidbi, try initializing it with setvariable
Just to debug
Before you do getvariable
private _money = eastMoney getVariable ["money", 0];
private _cost = 50.00;
private _amount = _money + _cost;
eastMoney setVariable ["money", _amount, false];
diag_log format["%1, has killed: %2. Faction, %3. has gained: ยฃ%4", name _killer, name _unit, side _killer, _cost];
_money = eastMoney getVariable ["money", 0];
diag_log format["Current Faction Balance is: ยฃ%1",_money];```
Why don't I just have the Variable...
and define it..
I have a feeling it assumed a boolean data type if you pass 0 as default since that never worked for me either
maybe.
addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
switch (side _unit) do {
case west : {
if (side _killer isEqualTo side _unit) then {
private _money = westMoney;
private _cost = 100.00;
private _amount = _money - _cost;
westMoney = _amount;
diag_log format["%1, has killed: %2. Faction, %3. has lost: ยฃ%4", name _killer, name _unit, side _killer, _cost];
diag_log format["Current Faction Balance is: ยฃ%1",westMoney];
} else {
private _money = westMoney;
private _cost = 50.00;
private _amount = _money + _cost;
westMoney = _amount;
diag_log format["%1, has killed: %2. Faction, %3. has gained: ยฃ%4", name _killer, name _unit, side _killer, _cost];
diag_log format["Current Faction Balance is: ยฃ%1",westMoney];
};
};
case east : {
if (side _killer isEqualTo side _unit) then {
private _money = eastMoney;
private _cost = 100.00;
private _amount = _money - _cost;
eastMoney = _amount;
diag_log format["%1, has killed: %2. Faction, %3. has lost: ยฃ%4", name _killer, name _unit, side _killer, _cost];
diag_log format["Current Faction Balance is: ยฃ%1",eastMoney];
} else {
private _money = eastMoney;
private _cost = 50.00;
private _amount = _money + _cost;
eastMoney = _amount;
diag_log format["%1, has killed: %2. Faction, %3. has gained: ยฃ%4", name _killer, name _unit, side _killer, _cost];
diag_log format["Current Faction Balance is: ยฃ%1",eastMoney];
};
};
};
}];```
ffs lol
Stil doesnt work.. ๐ฆ
oooo
the dead peeps are returning as civilian....
in your init.sqf try initializing westMoney with westMoney setVariable ["money", 0];
I'm gunna sleep and try again tomorrow. ๐
Might be a good idea
Its like 4 am here so I'm not at my brightest either lol
Could just give you all my stuff and let you figure out how it works
xD
you suddenly figured you wanted the money faction wide and then everything broke and I cant tell u why
Whatever game logic you added isn't an MP feature though
Yea you too, good luck tomorrow ๐
I did some testing and this works all you need is an object/game logic called MoneyLogic to hold the money variables
addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
_sUnit = side group _unit;
_sKill = side _killer;
switch (_sKill) do {
case west : {
if (_sUnit isEqualTo west) then {
private _money = MoneyLogic getVariable ["westMoney",0];
private _cost = 100;
private _amount = _money - _cost;
MoneyLogic setVariable ["westMoney",_amount, true];
} else {
private _money = MoneyLogic getVariable ["westMoney",0];
private _cost = 50;
private _amount = _money + _cost;
MoneyLogic setVariable ["westMoney",_amount, true];
};
};
case east : {
if (_sUnit isEqualTo east) then {
private _money = MoneyLogic getVariable ["eastMoney",0];
private _cost = 100;
private _amount = _money - _cost;
MoneyLogic setVariable ["eastMoney",_amount, true];
} else {
private _money = MoneyLogic getVariable ["eastMoney",0];
private _cost = 50;
private _amount = _money + _cost;
MoneyLogic setVariable ["eastMoney",_amount, true];
};
};
};
_eastBal = MoneyLogic getVariable ["eastMoney",0];
_westBal = MoneyLogic getVariable ["westMoney",0];
systemChat format["Current Faction Balances are: WEST:%1 EAST:%2",_westBal,_eastBal];
}];
What is the best way to end a mission on a server without an actual mission complete or mission failed screen
As admin, type #missions to go straight to missions list?
It might be a good idea to get an admin tools mod for this sort of thing
I was thinking more script wise
Basically I'm having a custom end screen using cameras and text and stuff
So it's not actually ending the mission, just going through a cinematic sequence (and then coincidentally ending the mission).
Never touched this before, but it's been possible since OFP, so good luck
Well it is ending the mission in the sense that everyone should be booted back to lobby. But currently the only options for BIS_fnc_endMissionServer come up with their own cinematics and WIN or LOSE
just run endMission after your custom screen has displayed what you want it to
Local command
That still pulls up a "Mission Completed" screen
serverCommand kick then ?
@drowsy axle What is this in terms of: if I was to have the player shoot an entity. Would the player or the entity, be this?
The eventhandler is "Has been killed" not "has just killed someone else". Thus this is the guy that will be killed.
What about this? addEventHandler doesn't take array.
Why would I be getting: scalar NaN error with _balance because _money is undefined.
(Oops accidentally pressed enter)
Would this satisfy it? yeah. But _killer setVariable ["money", _balance, false]; the false at the end is useless.
Fixed it by placing the side check first. not really, now you subtract 100 and then add 50. That's the same as adding 100 and subtracting 50.
Otherwise you reward the money to every player of the faction for a kill no.
I have a feeling it assumed a boolean data type if you pass 0 no, but the variable might already be defined as boolean
@radiant needle I think just calling endMission serverside, not the bis fnc.
cool manually calling Achilles_fnc_suppressiveFire on a loop with randomized firemode and randomized target selection creates an awesome effect
Also full auto M107s are ridiculous
Hi everyone! How i can add compatibility with JIP into my function? Function is defined in CfgFunctions class.
What do you mean? I don't think you need to do anything to make them compatible with JIP executions o_O or am I wrong?
correct. you don't
Hmm. I have a function, which creates teleport points on the map. It looks like a object with "Land_InfoStand_V1_F" classname and i add actions by addAction function to all of them. So i want to create this objects in postInit, but every JIP player can't see actions on teleports ๐ซ
You are supposed to do addAction to your object on JIP. I mean you should remoteExec your addAction on all computers with a JIP flag.
But I don't quite get what you are currently doing. nvm i think i've got this
So if i add actions with remoteExec - is it a good idea?
That's how you typically do it. Remote exec your addAction globally with a JIP flag.
Ok, i try to do that. Thank you ๐
So I have this
if ((typeName _FireMode) == "ARRAY") then {_FireModeSelect = selectRandom _FireMode} else {_FireModeSelect = _FireMode};
systemChat (typeName _FireMode);
systemChat is ARRAY
but yet _FireModeSelect is undefined
when I systemChat _FireMode I get [0,1,1,2,2,2] which is correct
_FireModeSelect = if ((typeName _FireMode) == "ARRAY") then {selectRandom _FireMode} else {_FireMode};
try that
That seems to work, thanks
I'm just fixing the problem before optimizing anything, seems easier to see mistakes that way instead of trying to tell optimization apart from what fixed the script ๐คท
It's not even optimizing, it's using an out dated method
just do it the right way
ยฏ_(ใ)_/ยฏ
Is there some vehicle seat ID which works both with driver, gunner, turret, cargo seats? assignAs..., moveIn... commands are not convenient to work with, because cargo have their ID, turrets have their path, also driver and gunner are special >_< Maybe I am missing something?
Thank you @verbal saddle
You could also do ```sqf
//Ignore this, I'm retarded
//[_FireMode, selectRandom _FireMode] select (_FireMode isEqualType []);
๐
But that will only work if firemod is array
and then.. it doesn't really make sense to select at all does it?
Personal preference over an if-then-else to see if it's an array or not an array
Ahhh, my bad. Didn't realize the selectRandom ran even if not chosen. My dumb
What I get for only checking halfway before posting
you could wrap code and do call.. but that's probably worse than the if
If i close a gate, a gate with a single door, and when it is half closed (half done animation) i run this code ```_gateObj animateSource ["Door_1_sound_source",1,true]; //Instantly open the gate
_gateObj animateSource ["Door_1_sound_source",0]; //close the gate
Are you allright? @viral canyon
I wouldn't even blame a catโฆ maybe an octopus ๐
sorry cat was walking on my keyboard...
@viral canyon tell us the truthโฆ you host an octopus, don't you?
nope one of my gf's cat's comes in my room looking for food at night walks over my keyboard knocks down my cup and everything
the mixer remains an option
As I recall there was a program which can tell if a cat is walking on your keyboard.
โ yes ๐
So we can feed it with the string and we will find out if it was a cat or not ๐ค Sadly the message is gone
Can we somehow animate turrets via script?
What the hell... ๐คฆ
Executing fullcrew [cursorObject, "", true] on a base game static HMG I get this: [[<NULL-object>,"driver",-1,[],false],[<NULL-object>,"gunner",-1,[0],false]] as if it has a driver
Getting value from config configFile >> "cfgVehicles" >> "B_GMG_01_high_F" >> "hasDriver"; I ge 0, like it doesn't have a driver
...
statics are special like that
UAVs too i believe
private _allSeats = fullCrew [_vehicle, "", true];
if (count _allSeats > 0) then {
if (unitIsUAV _vehicle) exitWith { }; // -- lol
_menuOptions pushBack [
1,
"Get in",
{ [_this select 0, _this select 1] call FUNC(getInAvailable) },
{ [_this select 0, _this select 1, "ANY"] call FUNC(canEnterSeat) }
];
if !(_isStaticWeapon) then {
{
_x params ["_role", "_priority"];
private _roleName = _role;
private _seatExists = ({ _x select 1 == _role } count _allSeats) > 0;
if (_role == "driver") then { // Workaround for some things having a driverSeat, although there isn't actually one
_seatExists = getNumber (configFile >> "CfgVehicles" >> (typeOf _vehicle) >> "hasDriver") > 0;
if (_vehicle isKindOf "Air") then { _roleName = "pilot"; };
};
some random code related to that
same config lookup in there ๐
FUNC(getInAvailable) what are you doing here? ๐
That is what's called a "macro"
I guess you meant "what are you doing in there" ?
(Discord doesn't let me edit :U)
I meant 'what does this macro expand to' ๐
mod_module_fnc_getInAvailable usually
or mod_fnc_module_functionName if you want to use BI's function framework ๐
thx. thought might be something more interesting
Hello, how can I set this texture "fresnel" to a vehicle ? thank you
#(ai,64,64,1)Fresnel(1.3,7)
mb I figured it out
@neon snow yes and no
I found a way on the forums. The way is to define animations for Maingun and turret with sources "turret_maingun" and "turret_main" and then anims with same selection but user sources. In the config define AnimationSources and it works(just cant define this in turret as it will override defined sources) :
//body="mainturret";
//gun="maingun";
//animationSourceBody="gunnerCameraRotX_source";
//animationSourceGun="gunnerCameraRotY_source";
But what do you mean by yes and no?
In UGV you can in a tank you canโt
I did it in copilot seat in jet, dont know why it works then
anyone on the seat?
Yep
AI?
no, player
can post turret config if you like
well sure. I did mess around with it a year back or so with my walker torso
not sure if I ended up using that method tho
https://pastebin.com/xA1MckBz Disregard includes
I wanted to add pilotCamera for copilot but since it isnt possible we had to use normal turret
Is there a way to draw circles in 3D or is a polygon via drawLine3D the only feasible approach?
could always draw icon3d with circle
Well, an icon will keep its orientation, which is undesired.
If nothing else works you can make multiple icon pictures with different orientations
But it'll look ugly, rotations will be in too big steps
hi guys. is it possible to set a "time to live" value when using createVehicle or createVehicleLocal? I'd like them do be deleted after a period of time and I want to avoid spawning a script thats sleeps before it deletes them if its possible
Never heard of such feature. Probably you'll have to rely on some scripted solution.
yeah ok
You can spawn one script which will sleep for 10 seconds or more, then check which vehicles have reached their timeout threshold
having one script suspended is fine, having a hundred suspended is probably not so good ๐คท
Would take a lot of pictures to capture all orientations, but you got me an idea. In principle one could place a RscPicture of a filled circle on the screen and resize it accordingly.
yeah I've done it like that before. I dont like having lots of running scripts like that
I spawning footprint objects
What accuracy of your timeout do you need? Probably 2 minutes or more is going to be fine? If your script is sleeping for 99.999% of your time, its impact is around zero. Probably you can attach other non-frequent checks to such 'timer' script as well if you have them. @nocturne basalt
Im running a loop that controls walking animations of a bipedal walker. Im spawning cracks in the road for each step. I guess I can store all objects in an array and delete the oldest between each cycle ๐ค
keeping 20 before they are deleted maybe
only problem then is if the script is terminated, I will loose track of all the roadcrack objects
Wow ๐ Probably that's best, yes. If you examine how bullet holes behave in some video games, that's how they work.
Good idea. Just have a fixed amount of cracks shared by all walkers?
hmm.. using a global counter you mean?
one that cycles with modulo operation
Something like this, yes. You have an array of them. And a counter 'next object to use'. When you take an object, you do counter++ and handle its overflow. Or use the % operator which is the same.
@nocturne basalt Just add trigger with timeout
createTrigger ["EmptyDetector", [0,0,0], false] call { _this setTriggerTimeout [TIMEOUT,TIMEOUT,TIMEOUT,false]; _this setTriggerStatements ["true", "deleteVehicle thisTrigger; deleteVehicle CAR", ""] };
Considering that he needs to spawn cracks on the road for his bipedal walker, maybe he could use the arma's mechanisms of making bomb explosions, bullet holes, etc, just with a custom texture?
it is easier to delete from front and add to back
_el = arr deleteAt 0; arr pushBack _el;
Would be surprised when it's faster than with a cyclic counter, but it's SQF ๐
Shouldn't be an issue if you put the part in unscheduled.
hmm, how about putting the critical part in isNil {} or using CBA_fnc_directCall for more readability?
There is no real race conditions in sqf...
Are you sure about that?
in scheduled there are
exactly
well from engine's point of view there are not ๐ but from my code's there are, so ๐คท
lol
Engine is running sqf only in one thread
So yes, no real race conditions
But asynchronous programming has many properties that you also have with multithreading...
I could argue that there is no race condition in my single core processor because it executes one stream of instructions... race condition is in code, not in in processor itself, I think.
Oh well, I think we've been arguing about schedulers so much lately, I should go to bed.
Well, we do have multiple threads when we take multiple clients into account.
Indeed, the remote computer is asynchronous to your code.
Synchronization is an interesting topic. As I've learned, in chip design it's even more important. The difference is, in integrated circuits events happen at insane frequency (at clock rate) compared to our typical event rate in our code. So average time between race conditions is much lower, so chip can work for milliseconds and then lock up or smth like that, while our multithreaded code can potentially run for seconds...hours until breaking.
can someone please explain why
1 hour real life time isEqualTo 10_mins_scripting || gaming;
Is this a question mixed with SQF syntax? ๐
@leaden hill and why when at work, you close your eyes for 5 minutes and only 30s were spent? I assure you, it's all a big plan from corporationsโฆ
(my personal theory: I don't see weekends' mornings because they shorten my days off so I get back to work faster)
Hey guys, does anyone know why this won't work?
The objects get deleted... but they're not created again.
_x params ["_classname","_position"];
line 76
you dont use _x so its essentially doing _this params ...
Also, why set so many broadcasted variables to nil when if you don't do that they're nil anyway? (you're also missing a } there, so that's broken anyway.)
yea, that inner foreach would be trying to set objNull as a variable name too.
@tough abyss oh thats a nice approach. I was thinking.. Since Im spawning footprints on the ground, maybe its better to make a crater from a bomb explosion since it will fade out over time
Make a custom bomb with 0 damage, no sound and no explosion effects.
Or is it possible to spawn a bomb crater directly instead? ๐ค
there are crater statics, not sure what you're looking for in specific.
I basically need to spawn a crater effect that fades away over time
so I cant use createVehicle for that approach
Seems spawning a bomb is the best way. Not only is it spawning a fadable footprint, but I will get smoke, sounds and shake from it aswell ๐ ๐
How to remove a weapon from a pylon by using a script?
What's the easiest way to add a check to a script that will turn off a sound if an user selects a user action in a vehicle?
Currently have this for a siren:
while {alive _vcl} do
{
while {_vcl getVariable ['siren',0] == 1 && !isNull driver _vcl} do
{
if(!isNull driver _vcl) then {
_vcl say3D "Siren1";
sleep 10;
};
if(!isNull driver _vcl) then {
_vcl say3D "Siren2";
sleep 4;
};
if(!isNull driver _vcl) then {
_vcl say3D "Siren3";
sleep 4;
};
};
sleep 1;
};```
So I am having rather bizarre issue right now. i am getting this error right now
Error in expression <diwako_dui_colors getVariable (assignedTeam player)>
Error position: <getVariable (assignedTeam player)>
Error getvariable: Type String, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location
diwako_dui_colors is a string, hence why it errors. However I not written such code anywhere in my mod. assignedTeam is written once in the whole mod and it is this part
private _assignedTeam = assignedTeam _x;
private _color = _colorNameSpace getVariable [_assignedTeam, "#FFFFFF"];
_x setVariable ["diwako_dui_color", _color];
private _compassColor = _colorNameSpace getVariable [(format ["%1_compass", _assignedTeam]), [1,1,1]];
_x setVariable ["diwako_dui_compass_color", _compassColor];
it is being read and applied to a control later like this
if (_distance > 3 || {vehicle _unit == vehicle _player || {_unit == _player}}) then {
_color = + (_unit getVariable ["diwako_dui_compass_color", [1,1,1]]);
};
_color pushBack _fade;
_ctrl ctrlSetTextColor _color;
I have no idea how arma coobles together the code that errors, anyone knows what the cause could be?
oh yeah, teh variable in question is used in this context
private _colorNameSpace = missionNamespace getVariable format["diwako_dui_color_%1", diwako_dui_colors];
it is for getting the correct namespace during runtime
diwako_dui_colors vs diwako_dui_color ?
diwako_dui_color is nil and does not exist
it doesn't tell you which script file the error is in?
nope
did you check script strings in ui configs?
ye
these use this "prefix" diwako_dui_Rsc also write a variable into uiNamespace instead
oh my god.i just found out why. I think I need an eye check
the error only happens when i pause the game to use watchers or the debug console
mwa mwa mwaaa
https://i.imgur.com/BOLcZHk.png
it was in a watcher and i am just an idiot
cue the Curb Your Enthusiasm Theme now
Add a eventhandler to all vehicles and cancel damage if a projectile is not defined (is equal to "") is what i'm trying now to "fix" Arma bug related to vehicle collision with objects.
What bug? @tough abyss Do you mean them colliding with everything?
You can attach this one to dammage event handler of units to make then receive no dammmage when some friendly tank decides to drive over them
private _unit = _this select 0; //: Object - Object the event handler is assigned to.
private _source = _this select 3; //: Object - The source unit that caused the
private _instigator = _this select 6; //: Object - Person who pulled the trigger
if ((side _source == side _unit) && /*(_projectile == "") &&*/ (isNull _instigator)) then
{
0
};
@astral dawn some player are ranting because their vehicles are trowed hundred meters away and explode or explode when they gentlly colide with some objects.
Oh yeah, like when someone's connection is bad and your vehicles glitch into each other, failing the whole mission ๐
@astral dawn Arma space programm? ๐
@lost copper Why?
Well yes except that everyone instantly dies xD before lithobreaking
@astral dawn use isNull _instigator is better than use _projectile == ""?
Honestly I don't remember, but i've spent a lot of time to figure out how to filter dammage when a car drives over a "human vehicle" a year ago or so, thought might be useful for you
Thanks
hooman
I have invented another useless macro:
#define RETURN
It reminds me of home C/C++ ... Gonna use it when I'm about to return something from my function call
Makes it more readable yeah.
ACE/CBA just leave away the semicolon on returns. You know that it has to be a return, cuz otherwise missing semicolon would error
i also created that macro but made it actually usable
Actually it made me think, maybe it's possible to make a return macro which will behave like the C return? So that it performs an exitWith, but on the nearest call {} block, no matter other if statements or loops?
if (true) exitWith {value}
breakout
But it will break out the current while loop for example, not the most recent call {}
Or use exceptions ^^
Yes i've thought of a similar approach but I'd have to include such a header into every myFunc = {__header.hpp__ ... code ...}
There is no sorry to not using cfgfunctions
ACE/CBA has that in their compile functions, they just flip one macro and every compiled function get's a header which makes it possible to collect callstacks
Is there some workaround for not specifying the whole path in include, and make it work like in C?
Of course I could write a batch to copy every .hpp into every folder or something like that
#include "../" works was what i wanted to say
You mean #include "..\..\MyPreciousDefinitions.hpp", right?
for example
if you feel funny, you could create a "build" script that uses sqfvm to pre-parse those scripts for you
But sqf-vm will also follow arma's rules about #include paths?
yup
only thing is: you have to tell it where what stuff is
explained it once in the discord
I could do it like this:
Have one folder with my project
Have a batch that copies my project folder to a 'release' directory, plus finds all .hpp files in it and copies every hpp file into every folder of 'release'. 'release' is then what arma loads up. ...
But then SQDev will say 'I can't find these includes!'... oh well why is everything so painful in arma ๐ฅ
mhh? why is sqdev saying that?
Well because if I develop my stuff in 'project' folder while the .hpp files are not copied to every directory, it won't be able to #include "myDefinitions" because they are at this point of time at "..\..\..\..\myDefinitions\myDefinitions.hpp", however arma will handle everything fine because I'll give it the 'release' folder where all the "hpp" files I have created are copied everywhere
@astral dawn Why not using a fixed location from root instead of bunch of ups from current folder like it is described within missionConfigFile (i suppose that is a mission structure you have)?
Do you mean, why don't I put all scripts in the root folder together with all .hpp files?
Ehm, no that's definitely not what I've meant
Then I misunderstand you
Yes I have a mission. Inside mission I have folders like, for example:
- Location
- AI
- Message
- Message.hpp
AI and Location might have some other structure inside them. I might want to include Message.hpp inside scripts which are inside Location.
- Message.hpp
He did explain it pretty explicitly
You basically can __EXEC it within description.ext and then pick it with whatever SQF or pre-processor after.
So it will be like:
...
#include ROOT/hpp/myConfig.hpp
...
Since any variable declared with __EXEC is written to a parsingNamespace. So you can pick it up with __EVAL
If im not mistaken it's even gonna be looking like:
#include __EVAL(MISSION_ROOT/hpp/myConfig.hpp)
Hmm that's a good read, thanks
So you suggest that I use not relative #include path, but an absolute?
I didn't know that #include can do that. I thought that #include works only with a fixed string-path. I will try it.
It says on wiki:
Preprocessor does not support the use of macros for pre-defined file names.
#define path "codestrip.txt"
#include path //this will cause an error
Are you absolutely sure that it will work?
I have never seen that working
__EVAL and __EXEC are not preprocessor thingies I think?
They are in the config parser, not preprocessor
๐ค
I think because #define has lesser priority, so #include is in priority. Not sure of that now.
Gonna try it myself now.
Thanks!
Yep, it seems #include doesn't like eating __EVAL after it. Pity.
So this is only useful for absolute path inside SQF only, my bad.
would have surprised me if it was
Np, thanks for trying out anyway ๐
Well another sloppy workaround is to include bare mission path itself.
But this is where it gets nasty.
Yes, then I decide to rename my mission xD
I think my batch file idea is so far the best :p
Or X39 idea just to use the GCC preprocessor
Is there something insanely obvious I'm missing here?
playSound3D ["sounds\hum.ogg", this];```
Because it's not generating any sound. The file is in sounds/hum.ogg. The script is in a transformer object's init line
is the sound defined?
Yeah, the sound plays with playSound
playSound "TFR_energyHum"
Just renamed it for simplicity sake:
class CfgSounds {
sounds[] = {};
class TFR_energyHum {
name="tfr_energyhum";
sound[] = { "sounds\tfr_energyhum.ogg",1,1.0 };
titles[] = { 0, "" };
};
};```
`playSound "TFR_energyHum"` still works, `playSound3D ["sounds\tfr_energyhum.ogg", this];` does not. Tried swapping `this` with `player` just for testing purposes... that doesn't work either
Just by pure coincidence, the problem we were discussing above seems to correlate with yours, @vapid drift . @unborn ether referenced a link which mentions different aspects of arma root: http://killzonekid.com/arma-scripting-tutorials-mission-root/
@vapid drift
myClient_ROOT = call {
private "_arr";
_arr = toArray str missionConfigFile;
_arr resize (count _arr - 15);
toString _arr
};
you could put that in your init if you dont have something set already
ohhh ok, I don't think I've ever encountered this before. Thanks
myClient_ROOT + "tsounds\tfr_energyhum.ogg"
so
playSound3D [myClient_ROOT + "tsounds\tfr_energyhum.ogg", this];
So something to keep in mind there is that init.sqf is executed AFTER init line on objects but I should still be able to call this from a script
ive had no probs
when I run it is get an Undefined variable in expression: mission_root error and when I checked here: https://community.bistudio.com/wiki/Initialization_Order it says that they're run right before init.sqf. How is that you've run that without problems?
sorry didnt read above... im guessing your using map placed objects?
yeah