#arma3_scripting
1 messages ยท Page 350 of 1
https://gyazo.com/4fbfe99696d83cc34b97badfaa466089 this is what i mean, the actual controls group is now being create behind the background .. could it be because the main dialog is using a controls group ?
oh man control groups are fun
i bet you're having a really nice time doing complicated UIs in arma
Does it not like controlsGroups being made over the top of ControlGroups ?
Yeah.... no xD
im going to take the main dialog out of a group, and see what happens.
im guess either idc issue or it doesnt like controlsGroups over controlsGroups.
i could never get control groups working in the way i wanted
what i ended up always doing was just adding different controls to my own imaginary "group" via script and just animating them or whatever that way
Mine are working ok, the only thing i dont like is each message needs 2 controls ... so if i want 100 messages to be store... need 200 controls xD
why? use pages
show 5 message templates at once or whatever, load in next 5 messages each time you click next page
that kinda thing
i just got mine scrolling xD
Im gunna do a notification system using the same idea as this messaging system tho ๐
ok, so I have narrowed down the issue to 2 things.
Idc issue, or ControlsGroups over ControlsGroups
@indigo snow so does the example
lineIntersects [ eyePos player, aimPos chopper, player, chopper]
that would check if theres something between the player and the chopper
the command itself just checks if anything intersects the line between two positions
and you can give it up to two objects to ignore
it also wouldnt change output if you turn around in place, since eyePos would (almost) not change
I think what you actually want is if the player is looking directly at jerry's head, @simple solstice ?
Why i has to do mine hard way
_MessageBox = _display ctrlCreate ["Lega_Tablet_Messaging_MessagesGroup",9999];
``` why not use
_MessageBox = _display displayCtrl 9999;
@indigo snow yes indeed
Slightly unrelated question; what music does everyone here listen to when scripting / mission making?
We splinter cell now bois http://i.imgur.com/2fH4uN5.png
vocalDubstep
Any specific favorites / recommendations?
Ha, that's what I've been doing lately too.
ADT_RefreshList = {
_display = uiNamespace getVariable ["Lega_CustomTablet_Messaging",displayNull];
_MessageBox = _display displayCtrl 9999;
_config = "true" configclasses(missionconfigfile >> "Lega_CustomTablet_Messaging" >> "Controls" >> "Lega_Tablet_Messageging" >> "controls" >> "Lega_Tablet_Messaging_MessagesGroup" >> "Controls");
_CtrlAmount = count(_config);
{
_idc = getNumber(_x >> "idc");
_ctrl = _MessageBox controlsGroupCtrl _idc;
_ctrl ctrlSetStructuredText parseText "";
_ctrl ctrlSetBackgroundColor [0,0,0,0];
}forEach _config;
};
``` would there be a better way of clearing my controls ?
Sorry man, can't really help you there, but good luck!
Hmm, Land_PortableLight_Double_F wouldn't fall under Lamps_Base_F, would it? To add both portable lights, would PortableLight_Base_F work?
Making a multiplayer script to find how many Independent-side players are in one of three zones (north, central, or south Stratis) every 3 minutes. What's the best way to do this? I am planning on finding locations of all Independent players with a server side script, then comparing the values to find which values put them in one of the three regions. I could probably do this client-side to make the code cleaner, but...
I mean, there is only two of them, so I can just add them both.
@spice kayak
"PortableLight_Base_F" isKindOf "Lamps_Base_F"
@tepid pollen inArea
This is how you can check.
thank you! I think that is exactly what I am looking for
private _indepUnits = [];
{
_indepUnits append _x;
} forEach (allGroups select {side _x isEqualTo independent});
_indepUnits = _indepUnits inAreaArray _marker;
This will list all independant units in the markers area
Ah, thanks man. forgot about isKindOf.
Prefix_CheckInArea = {
params ["_markerName","side"];
_return = [];
{if((_x inArea _markerName) && ((side _x) isEqualto _side))then{_return pushback _x}}foreach _playableUnits;
_return;
};
Lightning, if you call that with a markerName it should return all the units in that area.
Wouldn't that be all units, not just the independents?
Sorry, typed that before seeing your last comment.
private _indepUnits = allUnits inAreaArray _marker select {side group _x isEqualTo independent};
Can't beat this ^
Rip i didnt read that part
I wish there was a
allUnitsSide west
allUnitsSide independent
etc. command
Huh, that worked. I figured I'd just load into the mission and use the EMP. If it turned out the lights, then they were part of the Lamps_Base_F group, and they turned off \o/
Oh god, yes.
I was looking for that last night.
#define ALL_UNITS(var) call {private _r = []; {_r append _x;} forEach (allGroups select {side _x isEqualTo var}); _r}
ALL_UNITS(west)
You could use a macro.
One thing I hate about Arma is how lights shine 'through' things. Like, if there was a bright light on the other side of the building, it'll still illuminate the ground and everything on the other side of it.
Yeah, it's pretty cheap.
I actually don't remember that, even though I did play during the alpha.
One thing I do notice has changed would be Chemlights. Man, I remember when one of them could light up at least 3 or 4 meters. Now you'll be lucky to get half of one.
Throw smoke on them
Anyone knows the addAction priority for entering the vehicle?
Oh yeah, smoke on chem is amazing.
Actually took a standing break during one of our coop nights to admire how that looked.
found it 0 is get out
Like, we all just stopped what we were doing, ran into a shed, and just sat around chemlights / smoke grenades while the HQ /Zeus guys were asking what on earth we were doing. Was great fun.
_MessageBoxTextCtrl ctrlSetStructuredText parseText format["<t size='0.8px'>%1</t>",_struct];
_newH = ctrlTextHeight _MessageBoxTextCtrl;
_xPos = _MessageBoxTextCtrlPos select 0;
_yPos = _MessageBoxTextCtrlPos select 1;
_zPos = _MessageBoxTextCtrlPos select 2;
if(_position == 0)then{
_position = (_23 + (10 * pixelH));
_MessageBoxTextCtrl ctrlSetPosition [_xPos,_position,_zPos,_newH];
_MessageBoxBackgroundCtrl ctrlSetPosition [_xPos,_position,_zPos,_newH];
}else{
_position = _position + _newH + (5 * pixelH);
_MessageBoxTextCtrl ctrlSetPosition [_xPos,_position,_54,_newH];;
_MessageBoxBackgroundCtrl ctrlSetPosition [_xPos,_position,_zPos,_newH];
};
_MessageBoxTextCtrl ctrlCommit 0;
_MessageBoxBackgroundCtrl ctrlCommit 0;```
_23 _34 _54
๐คข
xD just random vars xD
not sure which one was which xD
with smaller messages, it works fine, but with bigger messages, it bugs out
Reminds me of Dedmen's number namespace
0 = "banana";
missionNamespace getVariable str 0 // "banana"
//These shouldnt change.
_yPos = _MessageBoxTextCtrlPos select 1;
_width = _MessageBoxTextCtrlPos select 2;
_newH = ctrlTextHeight _MessageBoxTextCtrl;
//If there isnt already a message, we cant get the last message pos.
if(_xposNew isEqualTo 0)then{
_xPos = _MessageBoxTextCtrlPos select 0;
_xPos = (_xPos + (10*pixelH));
}else{
_xpos = (_xposNew + (10*pixelH));
};
_MessageBoxTextCtrl ctrlSetPosition [_xPos,_yPos,_width,_newH];
_MessageBoxBackgroundCtrl ctrlSetPosition [_xPos,_yPos,_width,_newH];
_xposNew = (ctrlPosition _MessageBox)select 0;//Get the Xpos to calculate against next time
_MessageBoxTextCtrl ctrlCommit 0;
_MessageBoxBackgroundCtrl ctrlCommit 0;
``` is this better ?
what are you trying to achieve ?
how to do the code box in discrod?
```sqf
//code
```
Should be pinned or channel description
^^ nope
no im not
Wrong backticks
under escape, the tilde key
Now im doing sqf :sunglasses:
```sqf
private _imDoing = sqf;
```
๐
You didnt define sqf! Fool!
private _imDoing = sqf;
private _imDoing = "sqf";
private _emjoi = "sunglasses";
_sqfV2 = "Highlighting";
public static class SQF {
public static void Run(string code) {
Exception up = new Exception("Learn C#");
throw up;
}
}
super_complex_fnc = {systemChat 'I'm the best'};
You fucked up, Renz.
wow
Error: Expected string
" '?
I like it when you do something like this
private _a = 1:
it will say
ERROR IN EXPRESSION, EXPECTED switch
:(
_code = format ["side %1", player];
will not work, since it returns "side B Alpha 1-1:1 (Renz)"
Any ideas?
?
anyone know if setPlayable is working in a3 yet?
can i detect by script if a player is looking thru his scope?
works for rifle optics?
thanks Midnight!
@atomic epoch
_code = format ["side %1", side player];
@copper raven is this exclusively for the teamswitch mechanisim or is it for playable as well?
@waxen tide no problem
"SP Only? ๐
what are you trying to do?
@copper raven Thanks, but that's not what im looking for
Create Player Object - > Set Playable - > Flexable max players
I've already solved it
https://community.bistudio.com/wiki/setPlayable USED, to do this.
yeah i see
GlobalVar = player;
_code = format ["side GlobalVar" ];
Returns code I can compile
just because it doesn't have a underscore doesn't mean it's global by the way.
@subtle ore Example?
have you ever experienced controls closing your dialog on click, without MouseButtonClick EH ?
no script error, no log
just another quick one, is there a way of searching through listboxes and changing the text whilst the dialog is open, or would i need to refresh the list ?
in Surface Painter i made a search field, i did it by refreshing the list and it works fine
it crawls the CfgVehicles config instantly
_modelInfo = getModelInfo _x;
_modelName = _modelInfo select 0;
_modelClass = "BTHBC_A3EM_" + _modelName;
_modelArray = _modelClass splitString ".";
_modelString = _modelArray select 0;
hint str _modelString;
I have managed to get this so far with my goal of removing ".p3d" from a model name and adding the prefix to it.
Are there any obvious issues I am missing?
you can drop most of the assignments since you never use them again. the last str before the hint is also kinda uneccesary
I just couldn't figure out how to use splitstring properly so I just did it in a way I actually understand lol
_string = format ["BTHBC_A3EM_%1",getModelInfo _x select 0 splitString "." select 0]
but yea i cant think of a more direct way of doing it so youre not missing anything
its basically just putting all of your lines into 1 long line
@slender halo I can make a function to refresh the list, so I dont need to have 15~ lines of code in each file that i need to refresh it in ๐
Thanks ๐
@tame portal Woops, made a mistake. I thought this was supposed to be broadcasted to all clients.
@subtle ore I thought you meant global across the namespace, didn't know the context was global aka over network
@tame portal In any script, variables without an underscore will be global to anything on that machine afaik. I thought the intentions was global over every machine on the network. Not sure ๐คท
global != public
... unless its a command with global arguments and global effect ๐
What is the difference between local and global arguments. I understand effect but not arguments.
If the object is local to another client, the command wont work
Every object is local to either a client or the server
So player objects are local to the players client, and say they drive a vehicle the vehicle is local to them, too
Global argument doesnt care if its on another client, at all
Stupid and overly complicated.
Ah got it, thanks.
how do i get a plane to fly in a straight line where i want it? i've tried AI commands, waypoints, setdir, setpos in various combinations for 2 hours.
vectoradd maybe?
I don't need AI it is just a 5 second intro i want to script to look good.
will try nigel
I think he means looping a setVectorDirAndUp for those 5 seconds
gonna look very jittery in MP though
i'll run it local?
you can always try, i havent really hear anyone doing ti that way, though
i know for sure that had issues in MP
i see
You want a plane to do a 5 second fly-by?
setposATL
Then enableSimulationGlobal false
I mean for 5 secs, how much is it gonna deviate?
and then setvelocity, nigel?
fuel as 0 ?
well i would like engine sound
@indigo snow i know for sure that had issues in MP
since i made a lot of test on this function, here are two ways to get it to work in MP
createVehicleLocalthenBIS_fnc_unitPlayon every machines
problem: if players get in the vehicle there are pos sync glitchs
- transfer the ownership of the group of the driver of the vehicle to a player then
BIS_fnc_unitPlayon owner's machine, this way players can get in the vehicle without positions glitch
thanks for sharing
How would i script a plane to lay out a gun run? DoFire and ForceWeaponFire do a single burst with almost no accuracy (doTarget TGT), while FireAtTarget doesnt seem to work at all.
https://pastebin.com/KtS32TpL From about L155
This is the function BIS uses for the CAS module in zeus
could it be that align = 'left' and valign = 'bottom' don't work at all for BIS_fnc_dynamicText
BIS_fnc_ambientFlyBy
good to know.
Any ideas into detecting an incapacitated player with an eventhandler?
Try animChanged
what are they incapacitated by?
Anything that puts someone into incapcitated state
is this with the new A3 revive system added with Tanoa?
@long trail I was hoping to avoid animChagned. I guess its the way to go
if there's no other option :/
@atomic epoch https://community.bistudio.com/wiki/lifeState
You could use "hit" with a check for lifeState as suggested
Fires after damage is dealt so might catch the change in lifestate. Not sure though, not tried it personally
isUnconcious = false;
player addEventHandler ["Hit", {
last_instigator = (_this select 3);
if (lifeState player == "INCAPACITATED" && !isUnconcious) then {
isUnconcious = true;
};
}];
player addEventHandler ["KILLED", {isUnconcious = false}];
it works ๐
Cool beans ๐
I was messing about with dynamic Simulation and on wiki it says there's some debug modes. I can't see them in debug console. Is this on the diagnostic dev branch build?
@indigo snow public across the network? That wouldn't make sense, especially when something is executed locally, unless of course like you said it has global effects versus the client only changes.
public as in publicVariable, or the public flag of setVariable
Wait a sec, is it automatically a public variable if not specified? 0_0
no usage of setVariable in that piece of code anyways.
im not sure what youre talking about anymore
you talked about global as in across client, i was making the point thats normally referred to as public
I see what you are saying now, sorry for the confusion.
array = array pushback (array deleteAt 0)?
Could even append and save an assignment
array append [array deleteAt 0]
Is there a list of icons drawIcons accepts?
drawicon3d accepts "path\filename.paa"
Id presume the drawIcon accepts it too
there is a list somewhere too I think
but couldnt find it with quick search
is RscLine a line you can draw from one 2d position to another? and if so, does anybody know the commands for that type fo control?
thanks HorribleGoat
@badbenson#0154 i think so yes. there is also https://community.bistudio.com/wiki/drawLine if you want to draw on a map ctrl
Any reliable method to prevent death of a player?
I'd assume handledamage does the job, however does anyone know what critical parts of the player will result in death?
what do you mean by what critical parts of the player will result in death??
damage EH checking if dealt damage will kill unit - that works fine yeah
afaik death in arma just happens when your damage hits 1.00, that's it
Yeah, but your damage consists of all your different body parts
I know that I can prevent death of a player by not letting his overall damage reach 1
but the question is which specific body parts have to stay < 1 to not make the player die
I'd guess head, neck, torso
I just need to make the player not die ^^
ah, i see. good question
i'm sure i read a post about this once, or maybe it was just a long conversation in this channel
@indigo snow Thanks for the move to back array stuff. Very nice.
Is there a setVehicleVarName alternative for groups?
In mission sqm it says
class Attributes
{
name="blu_1";
};
And How do I retrive the name of the group?
*varName
allGroups does a good job at keeping the groups, BUT, I have no way to check if the group would have playable units in it...
Is there a way to check unit ID based on missionSQM
...
does postInit have any ordering at all?
or are all scripts spawned ?
is postInit in 1 thread, or are all functions with postInit = 1 in separate threads?
im pretty sure post init functions are called from within a scheduled script, and they execute in the order they are in the cfg.
๐ That's perfect
I require that this script runs after groups are initialized, but before everything in postInit
hey guys, just wondering... is it possible to use "waitUntil" in a loop whilst the rest of the script continues on?
yes and no
because I don't want to have to use a while loop
while {true} do {
if (myBool) then {
[] spawn {
waitUntil {myBool2};
//stuff after waitUntil
};
};
//stuff now
};
if we use sleep 1; in both, waitUntil takes more resources
in theory
yes my thoughts exactly
They have separate uses/functionality
basically I'm wanting to write a small snippet to refuel a UAV every 4 hours
a 4 hour loop?
using waitUntil instead of while. thannks for that snippet, will help heaps
im not sure how else I will do it
im not sure how else I will be able to do it
I looked at that event handler... if it refuels when empty won't it crash still?
Why would it?
I just haven't tested it yet, I was under the assumption it would just go for a dive bomb
if you have an ai in a helicopter, cursorObject spawn {_this setFuel 0;sleep 3; _this setFuel 1;}
whereas refuelling it before it is empty will keep it on a continuous waypoint?
And since it's a eventhandler, it means that it runs instantly, when event fires, so it would be exactly like this:{_this setFuel 0; _this setFuel 1;}
ah I see
running out of fuel should not affect waypoints
I remember playing a mission and couldn't finish it in 3 hours, left mission running on server, tried again next day, ALL ai had run out of fuel ๐
yeah well I need th UAV to run for about 2 weeks non stop lol
a bit exaggerated, but you know what I mean lol
^^ im obviously missing something else lol.... what do you mean?
ops in progress, 1 week in (2 weeks total) > ACE3 updates > server out of date > how do you save progress in order to restart server?
"inside the wire"
Inside the what now?
as in its not being run online
aah ๐
sorry just diff terminology :/
I still need to find a way to setVehicleVarName alternative for groups
groupID kind of works, but not exactly...
oh thought I had come accross that problem already... seems I haven't unless my seaching skills through my scipts are bad tonight
@indigo snow
You made a mistake:
array = array pushback (array deleteAt 0)
pushBack manipulates the array just like append and afterwards reports the size of the array.
It should be:
array pushBack (array deleteAt 0);
Which is slightly better than append [...].
I think you confused pushBack with +.
Well, it was during a 3am toilet visit ๐
This is also how you can shuffle an array.
for "_" from 1 to count _array do {
_array pushBack (_array deleteAt floor random count _array);
};
returning to my yesterday's issue, how do I check if player is looking at a given position?
linesintersect didn't really work for me
Any player or the local player?
local
Worldtoscreen the position and check the distance to screen center in screen coords?
That has issues if the background isnt ground, though
But ignores (terrain) objects.
Well if it reports nothing or whatever the fallback is, then you know that the player isn't looking at whatever position.
i.e. looking into the sky
I need to check if player is looking at a wheel for example
I get the selection position, modeltoworld and then use screentoworld
am I thinking right?
That will be very difficult, because a wheel could have any selection / proxy name depending on what vehicle.
It will be different for any vehicle class.
after checking with many mods they usually have wheel_1_1_unhide/hide
Dont they need hardcoded names because physX, or are they just convention?
I can't remember
haven't seen anything other than wheel_*
RHS is weird is all I'm saying.
not using it :D
Is this for changing tyres?
oh, thanks!
There is no line intersect etc. here, because that is all done by the interaction menu.
But it should give you the selectionName stuff.
thanks, will experiment with screen to world
So figured that getting a position of the wheel and checking if player is https://community.bistudio.com/wiki/inArea would be better
position player inArea [(van modelToWorldWorld (van selectionPosition "wheel_1_1_hide")),1.5, 2, 45, false]
At that point you should just use distance
oh.. right
Is there an elegant way or a function even to draw icons on a map that are highlighted on mouseover and give me a return on click?
Hey all, is it possible to turn Jet radar off via script without the use of mods ?
Ohh this is giving me a headache. After destroying the wheel, the selectionposition changes.
To the center of the car. WTF
@cinder night https://community.bistudio.com/wiki/setVehicleRadar
How do I select values from both arrays in a multi-array in forEach?
[["HitLFWheel","HitLF2Wheel","HitRFWheel","HitRF2Wheel"],["wheel_1_1_steering","wheel_1_2_steering","wheel_2_1_steering","wheel_2_2_steering"]]
Does anyone happen to know where one would find the inner workings of the ArtilleryComputer?
@simple solstice maybe like that but if both arrays aren't the same length you will have issues
_wheel_array = [["HitLFWheel","HitLF2Wheel","HitRFWheel","HitRF2Wheel"],["wheel_1_1_steering","wheel_1_2_steering","wheel_2_1_steering","wheel_2_2_steering"]];
{
_x = _item1; // item from subarray 1
((_wheel_array select 1) select _foreachIndex) = item2; // item from subarray 2
} forEach (_wheel_array select 0);
they always will be same lenght, thanks
also, _item should be at the begging ๐
ehh its early morning cut me some slack
hey guys, just wondering... would it somehow be possible to get a hold of this mod https://www.youtube.com/watch?v=HQ27YtjC9DQ ... then break it get the code and add more to it?
would it be easy enough to get the code and add more to it/customize more or?
Thats not a mod, its the A3 high command system
@little eagle - how much did you hate Arma from 1 to 10 while writing that?
i just solved my problem so i'll drop the solution here in case it happens to someone someday
never use 1 or 2 as IDC, they are reserved and will close your dialog on click
Looking for help to use Ace3 slide show module. Can't seem to get it to work. Anyone know how to use it?
i cant get systemChat to work in briefing screen, has that changed recently?
Works for me, use uiSleep 1 to make sure you don't call it too early
Because systemchat seems to clense at one point
Why do you need it?
You could use diag_log if debug
I
I've used AI DONE SPAWNING and just use sqf [] spawn {uiSleep 1;systemChat 'AI DONE SPAWNING' }
Otherwise it would make loading screen longer if using uiSleep
If I have an array, and I want to pushBack another array, which I set a var as true, is it done like this?
myarray pushBack [my_var = true;, my_othervar = false;];
Sorry for no proper sqf syntax, on my phone so can't get the right symbols
You cant do assignments like that, nor use == with true or false
or append
you have to use [{my_var = true;},{my_othervar = false;}]
myArray append [{my_var = true;},{my_othervar = false;}];```
Those semicolons are superfluous and eat milliseconds during compile time ;)
Except for the final one, of course
I didn't think it would work honestly, but thanks, and nick you mean the ; found in Nigel's {}?
Ye
Aight thanks, getting those millisecond performance boosts lol
Its mostly me poking fun at nigel
It sounds a bit wierd what youre soing there tho, what are you trying to do?
And say I wanna pop another array at the back, just popping ,my_otherarray
For now it's just me messing with stuff, if I finish it when I'm home at my PC I'll be back here ๐
On my phone so it's a bit awkward to do all this
Glueing arrays together is normal, i was just very confused by whats in them
*0.001 ms ๐
Yes but i was unsure if the question was about glueing arrays or the contents you showed
Glueing an array, then popping a variable at the end ๐
Or variables in my first case
What do you mean with popping? Either way, the assignment operator = doesnt return the assigned value in arma, if thats closer to your question about that
So you have to assign first and then put them into your array
@tough abyss
I LOVED EVERY MINUTE OF IT.
[getPosATL MYT_startPoint] remoteExec ["MYT_fnc_setPlayerPos", 0, true]; this doesn't have any effect when called on dedi from init.sqf (within if (isServer) then {}) but it works just fine if I execute it on the server from console a few seconds later
any idea why would that be?
@little eagle - late stage SQF.
@digital pulsar The remote script is executed before the players exist
the function spawns a piece of code with waitUntil {!isNull player} shouldn't that mitigate it?
Maybe you can't set the position of the player at mission start, because the game or another script resets it.
Why is this remoteExec'd anyway? Please don't tell me this is another one of these server only mods.
works in hosted though
MYT_startPoint is randomized
alternatively i could just pubVar this variable and handle the rest locally
which sounds much simpler
I was about to suggest that.
Timing on dedi vs local hosted is very different, because the server in loca hosted has to do all the client / interface stuff too.
is there a way to remove the "take" action on items that can be picked up?
yeah
simple object / disable simulation?
i don't want a player to pick it up
action still shows even with simulation off
hmm any way to place simple object in editor or put a script on it to turn it into simple object?
class TakeItem: None
{
textDefault="<br/>";
textSimple="<br/>";
showIn3D=0;
showWindow=0;
};
This for ex. gets rid of the action from the middle of screen, but you could also disable it completly like this
But requires mod
theres a tick box in special states, not sure if thats for every object
Or just use onnextaction etc evhs
A buddy of mine is building stuff in the editor for the same project i'm writing scripts for and he asked me, so if he can just do it in editor - the better. But thanks i'll remember for later.
quiet channel today. scary.
BOO!
AHHHH
are there more handlers, or is "draw" the only one?
I can't find a list
Also event handlers confuse me.
okay i somehow looked at this page like 20 times today and managed to ignore the yellow box.
๐คฆ
i'm sure someone added it seconds ago.
do you mean the user interface event handlers? Lol.
Pretty sure they've been there for a while
well the "onDraw" text didn't make too much sense to me, hence i thought that list is for something different.
When the control is drawn?
well i found example code and was trying to figure out exactly what is going on and i somehow expected ctrlAddEventHandler ["Draw", ... to do something else than fire on map drawn.
i'm entirely de-confused now.
Yep.
_deploy_marker1 = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler
["Draw", "_this select 0 drawIcon ['iconVehicle',[0.25,0.7,0.25,1],[26250,25450],30,30,0,'DEPLOY',1,0.06,'TahomaB','right']"];
waitUntil {!(isNull (findDisplay 12))};
openMap [true, false];
_index = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler
[
"MouseMoving",
{
_map_coor = (_this select 0) ctrlMapScreenToWorld [_this select 1,_this select 2];
_size = 50;
if (
((_map_coor select 0) > 26200) && ((_map_coor select 0) < 26300) &&
((_map_coor select 1) > 25400) && ((_map_coor select 1) < 25500)
) then {hintSilent str "Molos";
((findDisplay 12) displayCtrl 51) ctrlRemoveEventHandler ["Draw", _deploy_marker1];
_deploy_marker1 = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler
["Draw", "_this select 0 drawIcon ['iconVehicle',[1,0.25,0.25,1],[26250,25450],30,30,0,'DEPLOY',1,0.06,'TahomaB','right']"];
}
else
{
_deploy_marker1 = ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler
["Draw", "_this select 0 drawIcon ['iconVehicle',[0.25,0.7,0.25,1],[26250,25450],30,30,0,'DEPLOY',1,0.06,'TahomaB','right']"];
};
}
];
sleep 20;
((findDisplay 12) displayCtrl 51) ctrlRemoveEventHandler ["Draw", _deploy_marker1];
((findDisplay 12) displayCtrl 51) ctrlRemoveEventHandler ["Draw", _index];
'...los";
((findDisplay 12) displayCtrl 51) |#|ctrlRemoveEventHandler ["Draw", _deploy_...'
Error Type Any, expected Number
the code to draw the icon works, the code to delete the event handler works, too. I think me nesting it inside that if is the problem? variable in wrong scope? but i don't know how to fix it. if i put the code block to delete the evh in the very bottom only, works like a charm and deletes them after the sleep 20;
yea it wont know the private variable cause its inside the evh code
just so i get that correctly, it will not know _deploy_marker1, yes?
correct
is there an elegant solution to this?
the easiest way is to use global variables instead.
maybe if i create it right in the eventhandler?
then it should be in the correct scope
no that wouldnt work. i dont know how to explain it properly but ill try.
every time the evh code is called its in its own scope stack. so it wont know any local variables set before the evh was set and wont share any variables it sets inside the evh between calls.
i see
but if i create and delete the evh "_deploy_marker1" inside the evh code block of the mousemoving evh?
you would need to define _deploy_marker1 inside mousemoving to delete it. if you set it in one evh call it wont know it on the next.
is why i say global variable would be easier
this is a script i intend to run shortly on the client only, to give the player an option to pick one of a few pre-defined map locations and send that to the server. idk how dangerous a global var is in that context.
i wouldnt think itd be that bad, its just a number.
you set the global var at the start when you first set the draw evh outside of mouse moving. you use that same var inside mosuemoving and again at the end of your script. then set it to nil after it removes the evh if you're worried about it just sitting there.
okay. thanks!
so is anyone else aware that select command is capable of returning null, even if the index is supposedly out of range?
but only by + 1
if you try + 2 then it will throw index out of range error
wonder if there is BIS code relying on this quirk.
Now i got it semi-working, but i can only see one of the 3 icons i draw. it is like i overwrite the others ... can't i draw 3 icons in parallel with 3 different event handlers?
if i remove the 3 if with the ctrlSetEventHandler , it draws all 3 icons just fine
my systemchat and hint stuff fires as it should
The whole purpose of this is to draw 3 icons on the map that change color on mouseover
if (_once) then
{
_once = false;```
what is the point of this?
nobody can tell you if you only post 4 lines of a bigger script
its in his pastebin
oh, it looks quite pointless
chaps is there a way to waitUntil on a function? For example I need to make sure the function has completed before continuing? I could try just time it with a sleep but its not ideal.
I considered a variable in it, but the function runs on the server and can be run by multiple clients simultaenously
waituntil {scriptdone _s};```
If i did this for example:
_s = [] spawn {[_objet] remoteExecCall ["ObjectFromDB",2];};
is that going to correctly wait until the function it calls is done or wait until its spawned the function?
no, itl wait until the remoteexeccall finishes, not the code it is remote executing.
if that makes sense
Yea it does. problem now is how can I get my _objet to exist inside the [] spawn scope
[_objet] spawn ...?
woops
i think thats a leftover from a brainfart connor
ah, no.
I wanted to draw the icons once, and then just set them. but i just realise, thats oneachframe in the evh basically?
i'm an idiot.
doesn't change the function tho.
it only draws and sets marker 2
it ignores 1 and 3
the way i think of it is: event handlers are for calling some code when an event happens, and the event for eachframe EH's happens each frame.
i think i understood that and changed my code accordingly, still behaves unintended
you could use "_cursorPos distance _markerPos" since your marker is round?
distance would differ depending on the map zoom i would think
yeah wait, wtf is this
if (((_map_coor select 0) > 26100) && ((_map_coor select 0) < 26400) &&
((_map_coor select 1) > 25300) && ((_map_coor select 1) < 25600)
) then {hintSilent str "Molos";
you can just use distance like you would with any positions
ctrlMapScreenToWorld converts the position of your mouse in a map ctrl to a world position
Hypothetically: if you remoteexec to a target that is local, does it still send over the network?
Theoretically no. But I'm not sure if that is prooven/tested
you can just use distance like you would with any positions
Weak. The correct way is to turn your coordinates into a polynomial, obviously.
_map_coor params ["_x", "_y"];
if ((_x - 26100) * (_x - 26400) <= 0 && {(_y - 25300) * (_y - 25600) <= 0}) then {
๐๐ฟ
I wish vectorXXX functions let me use arrays of 2 elements
if (_map_coor inArea [[26250, 25450], 150, 150, 0, true]) then {
Would inarea be a good replacement for distance
Well, this is for a rectangle, so...
Yea, but in theory. It coudl be a circle
Idk, distance seems very simple. But isn't it also using AGL? This one is purely 2D with z being omitted.
Hmm, good point, I'm thinking far into future, I want to redo some of my ai script
and it's obviously running in a endless loop, so constantly checking shit, so every 0.0001 ms ACTUALLY matters
so every 0.0001 ms ACTUALLY matters
I don't believe you. If it did, then you actually would replace all ; with ,
If every millisecond matters.. You would stop using SQF and save yourself years of time
All
{a} else {b}
be
[{a},{b}]
That is actually a reasonable thing to do.
More context?
All
while {true} do
be
for "_" from 0 to 1 step 0 do
if () [{a},{b}];
missing then
loop = for "_" from 0 to 1 step 0;
0 spawn {
loop do {
sleep 1;
systemChat str time;
};
};
I'll convert some of my physical notepad notes to computer notes and add those ^
Should make a gist of all the stupid SQF shit I can think of.
๐
ahhhh
so frustrating! I can not for the life of me get my functions library to work -_-
Check the file names and the folder theyre in
If you placed your functions into a functions folder you need to specify it
Etc
Considering the other options and distance not working for cartesian coordinates - yes, inArea is the fastest for this problem.
Should make a gist of all the stupid SQF shit I can think of.
private _ternary = ["if false", "if true"] select (_var > 13);
@little eagle what do you think about this one ?
inArea basically says, here is one SQF command instead of ~8 and do this all in C++ land instead.
zgmrvn, weak
private _ternary = "if " + str (_var > 13);
yeah, i mean in this case it fits, but according to BIS, this is faster than a
private _ternary = if (_var > 13) then {"if true"} else {"if false"};
Sure, the problem is that if-then-else only executes the code blocks if the condition is true. With select BOOL, the two array elements are always executed.
So it only works for simple assignments.
sure
I like it and try to use it when possible. It's way nicer than _var = if
B-but headless client.
What? Where is my head?! *runs around looking for his head*
Suspicious.
interlessClient
The Faceless Men
interFaceClientlessHead
is it somehow possible to add/remove radar/sensor to vehicles like in a way adding weapons, magazines to a vehicle? ```C
_vehicleObject removeWeaponTurret ["missiles_DAR",[-1]];
_vehicleObject addWeaponTurret ["LMG_Minigun_Transport",[0]];```
is it somehow possible to add/remove radar/sensor to vehicles
maybe
like in a way adding weapons, magazines to a vehicle?
certainly not like this
this?
https://community.bistudio.com/wiki/listVehicleSensors
Doesn't seem like you can add them with commands. Only config. There are no command to add them.
yeh was tryin it thru enableVehicleSensor bust sadly not working, dang. Config not a option, since it's not possible to define in description.ext yet, huwm?
no
@robust hollow if you remoteExec to a target that is local, it does indeed send it over to the network; if you set BE's remoteexec.txt to 5 "" and do [] remoteExec ["stuff", player], you get kicked.
Atleast with BE enabled.
If you have BE enabled any script that is executed on your PC is sent over the Network.
So if you want to optimize Network usage.. disable BE.
๐
This is because this stuff is done with the same logic the owner command uses. Everything has to go through the server, because only the server knows which object belongs to which machine.
The clients only know what they own, but that shortcut is not taken by remoteExec.
the shortcut is not taken because the command string still has to be filtered thru the server's CfgRemoteExec
Nah.
The remoteExec thing is used to execute stuff on other machines, so this shortcut would be pointless. Clients don't know which machine it is. All messages must go through the server.
as silly as it sounds, the Debug console's Local Exec button relies on remoteExec, this is what the button does: [[], _inputCode] spawn {_this remoteExec ["call", [player, clientOwner] select isNull player]}, so it's not always used to execute stuff on other machines
That's just because KK tinkered with it.
He thinks this is a good idea to force unscheduled. It just doesn't matter for the debug console, because no one uses it in actual missions.
no one
I do
u r a no 1
Got me there ๐ญ
โช
โซ
โฝ
๐๐ฟ
Wash your hands.
Jaundice.
๐๐๐
I've seen that face somewhere...
@still forum I can't figure out which function gives the default radios to players...
TFAR_fnc_requestRadios ?
I think the serverside of requestRadios.. actually
TFAR_fnc_radioToRequestCount
TFAR_fnc_getDefaultRadioClasses
My goal is to have a button for admin menu that allows to set another players radios to whatever they were supposed to start with
I like cookies ยฏ_(ใ)_/ยฏ
I thought I culd just run a function that's like tfar_fnc_addDefRadios
I'll just write my own func for that
TFAR_fnc_radioToRequestCount just reads from modifyable variables
TFAR_DefaultRadio_<Personal/Backpack/Rifleman/Airborne>_<West/East/Independent>
Yeah, so for example on respawn, player is given default radio (vanilla), it's converted into ^
Into what ever is inside that variable
godcha
Hi, I'm trying to create a clock that hints at game time but it hints "any" instead of time. https://gyazo.com/a1e9b78650b6bb232d801a6adf08f1e0
You need to define _time24 in the main scope
Local vars travel down scopes, but not up
thanks lol
@native cypress fyi
a private "_time24 is enough
best would be: private ["_hour", "_minute", "_time24"]
to ensure all those variables never can leak to an upper scope
@little eagle - in the mirror?
@queen cargo please private ARRAY is superseded with the keyword variant for _hour and _minute
so what?
So why say thats best / recommend it?
less mixing stuff
/shrug maybe
Is there a way to pre-set the size of an array?
As an example in Java,
int[] x = new int[size]();
@tough abyss https://community.bistudio.com/wiki/resize
Thank you.
I would like to make a mission about lifting containers in the ocean that fell off from a passing cargo vessel. How do you make containers stay afloat in water? I've tried some solutions with above sea level with no joy.
@weary turret setVelocity ?
seems like a better solution to setVelocity in that case
containers just sink with the door side going down first
yeah take a look at the first syntax of setVelocityTransformation.
I tried setPosASL
Sure, but this will keep pushing it over the water line
hopefully. it goes by the center point of the prim box. I'll give it a go
just need it so I can air lift containers
I also tried this setPosASL [getposASL this select 0, getposASL this select 1, 0]
@weary turret have you just tried doing that in a loop?
yeah, nothing
once set initially, it's free to roam after it'sb een set
Is there any way to return a controls base class? ctrlClassName can return what you name a control's class, but not the base class like RscEdit or whatever
@weary turret attach it to something that floats and make the floater invisible
setMass!!!
Quick question. Let's say I want to have a vehicle run a script until the vehicle is destroyed. Is that possible?
Yea
Specifically I need it to call a function every 10 seconds
(I'm a serious noob at this.)
How would I have it initialize the script when you get into the vehicle?
then you can have a while loop that checks if the vic is alive and the player inside and sleeps for 10 seconds
spawn your loop and then add a event handler mpKilled and terminate the loop, that you spawned earlier
if you use a while loop, it keeps it simpler
id recommend that
especially for someone relatively new
But some code inside the loop might rely on the vehicle being alive and error
Doing alive check after every line might not always be good
hence checking that state in the while condition
depends on what you are doing
ah i get what you mean
obviously a CBA_directCall inside it ๐
in unscheduled itd error silently and kill itself when it errors anyway iirc
It ususally is not an issue when it dies, rather when it's deleted.
Ohh yes, that would work as well.
@sullen willow I hope you are getting all of this ๐
yes no more asking questions now!!! ๐
I'm not. I mean, I know WHAT I should be doing, but not how to flesh it out. When I said I'm a noob, I meant it. Lol.
its cool you can ask shit
This is my first real mission and so far it's been a really wild ride lol.
Ok, have you done any coding before or used google ?
maybe bing
I can google lol. I'm reading up on Event Handlers right now
very good, you will get far
yea start with that. just a simple thing that gives a hint when you get inside the vehicle
then extend from there
That might make things a bit easier
its how i code too and ive written thousands of lines by now
get something small working asap so you have less chance of going mental ๐
I dun fugged up
Show me where I went wrong, O Masters
this addEventHandler GetIn systemChat "Test.";
syntax
look at the wiki page for addEventHandler, the right side of it
especially example 1
Quick load order question, would a server initialized missionEventerHandler call before OnPlayerRespawn.sqf or after? How would one find load order of this sort of thing?
Basically is the PlayerConnected eventhandler going to load before or after OnPlayerRespawn? The answer should be obvious but i'd like to check if theres some load order heirachy somewhere for similar things?
keep in mind server initialization is very fuzzy
But it doesn't mention a mission eventhandler . Object event handlers are mentioned however
This is what I came out with on 2nd attempt, said something about expecting a string
this addEventHandler [GetIn, systemChat "Test."];
Yea this is assuming the mission/server is already going
Dangit
["getIn", {systemChat "test"}];
observe the differences and the wiki
it should be obvious
{ ... } contain code
"..." is a string, or text
all 'words' not inside "" are commands or variables
๐คฆ๐ผ I don't know how I didn't see that
so the array [ ... ] first contains a string with the type of event handler and then a bit of code to execute
@daring pawn You'll have to test it or hope someone with some more experience chimes in. I'd personally guess the order isn't guaranteed.
Gonna play around with this a little, will report back if I hit a brick wall.
@indigo snow yea no worries, cheers mate
It's tricky because they both fire so early
All right. So. Say I want the event handler to call a script.
["getIn", {ExecVM "xyz.sqf"}]; ?
that's the syntax for execVM, yes
you probably want to pass over the vehicle the player is getting into, however
so _this execVM "myScript.sqf"
and then there will be a bunch of handy values in _this
which is a magic variable passed along
Fuck me this gets deep
stacking bricks
yep
rofl
what would be the syntax for the vehicle being alive
not alive LandVehicle, right?
for '_i' from 0 to 1000000 do {
not(true)
};
//517.5 ms
for '_i' from 0 to 1000000 do {
!(true)
};
//480.333 ms
sleep 5; hint "You gain 500 USD";
[500,0] call HG_fnc_addOrSubCash;```
I don't need the systemchat, but yes, it did work.
What I have there so far doesn't seem to be working
is landVehicle the name of the car?
youre also missing a bracket in there
Does it need a unique name?
the vehicle will be in _this
from the event handler
_this contains: the vehicle, the position, the unit getting in, and the turret theyre getting in
sleep 5; hint "You gain 500 USD";
[500,0] call HG_fnc_addOrSubCash;```
?
I feel like I'm an inch away from getting it
getting an error about an undefined variable in line 1
_this is undefined
you need to pass the vehicle to the script
show us what you event handler code looks like atm?
yea but ideally this would work for any arbitrary vehicle right?
sleep 5;
systemChat "You gain 500 USD";
[500,0] call HG_fnc_addOrSubCash;
},
It's working just fine.
Put the sleep to the end
Ok
actually nvm
Also
it does not matter in that case
add this before the while-line:
params ["_vehicle"];, then you can use _vehicle for the vehicle name
Now I need it to stop the script when the vehicle dies.
your while already does that
Oh, gotcha.
when its dead it stops
you can waitUntil it's !alive, too ๐
I learned a shitload today
myLoop = [] spawn {
while {alive car1} do {
sleep 5;
systemChat "You gain 500 USD";
[500,0] call HG_fnc_addOrSubCash;
},
},
then you do
terminate myLoop;
For educational purposes
But yea, it stops if car is dead so, this is not needed
This is pretty damn sexy.
You should probably do
while {!isNil "car1" && {!isNull car1} && {alive car1}} do {
Because if someone deletes the car, your script will throw an error
Or somethingdeletes it
Ohh nice @indigo snow
i still propose you dont hardcode the car name for further learning but thats up to you
Oh, shit.
Yeah I didn't think of this.
I need the script to stop when I get out.
Is the difference between remoteExec and remoteExecCall the fact the one is in the unscheduled environment and the other in scheduled.?
Technically yes, however remoteExecCall wont always neccesarily be executed straight away. Read about remote execuation @ https://community.bistudio.com/wiki/Arma_3_Remote_Execution
Cheers ๐
is there a trigger to detect if a player join in a vehicle as a gunner?
a litteral trigger or would an evh do? you can use the getinman evh to see what seat someone got into (im pretty sure)
remoteExecCall and remoteExec are the same for commands, but different for functions.
yes a trigger, i need the vehicles to start move when all 4 of they have gunners
@astral tendon
// initPlayerLocal.sqf
params ["_unit"];
_unit addEventHandler ["GetInMan", {
systemChat str _this;
}];
hmm
Roque, what vehicle? They usually only have 1 gunner each.
yea hes saying he has 4 vehicles and each needs a gunner before they move out
Oh
Any unit or specific ones?
trigger condition field:
{isNull gunner _x} count [tank1, tank2, tank3, tank4] == 0
another thng, this is a coop setup, that means i may not have all 4 players in the server, so i still can make this trigger work even with less players?
With a bit of algebra and logic...
if its a max of 4 players couldnt you do something to the effect of
{isNull gunner _x} count [tank1, tank2, tank3, tank4] == (4-count playableunits)```
oh i dont think thats right
This is confusing to put in one line xP
{isNull gunner _x} count [tank1, tank2, tank3, tank4] <= (4 - count playableUnits) max 0
???
{!isNull gunner _x} count [tank1,2,3,4] = (count ([switchableUnits, playableUnits] select isMultiplayer)) min 4?
Its toss up i guess
If this was a script that is run by an addAction, would this just run on the person who used the action?
_display = [params... ] remoteExec ["BIS_fnc_StrategicMapOpen", clientOwner, false];
yea that would be run only by the person using the action, although remoteexecuting that wouldnt return a display, and you're sending it to yourself so is there any sense in remoteexecuting it at all?
@grand berry Yes*. But then the whole remoteExec setup would be pointless.
- not in a resumed local hosted MP game, because
clientOwneris bugged.
It's for a dedi - using the Strat Map as quick travel around the base. Why would the remote exec be pointless?
cause you're executing it on yourself. might as well just call it
Would be the same
Also, remoteExec does not return a display. It returns nothing, so _display will be undefined.
Only the JIP version reports a string no? This is the not-JIP version (false as arg2)
Yea ok thanks, that all makes sense.
no jip is empty string
ok
Related question - if a script is run on a client that spawns new AI units does that client then take the overhead for the AI?
So in that case using remoteExec to spawn the AI on the sever would be the correct thing to do.
Yes unless you immediately set the owner to be the server but thats buggy iirc
grpOfAI setOwner 2 or something
Breaks the danger.fsm or something
To avoid that can I not just run the code that initially spawns them on the server or is that what breaks it? As opposed to setting owner after spawn.
yea spawning them from the server would avoid that problem.
[] remoteExec ["spawn here", 2]; So that would work and not break the FSM?
Since locality never gets transferred, sure
Awesome, thanks for the help guys.
@indigo snow How do I get my earlier script to terminate if I exit the vehicle?
SimZor, bad advice.
nil spawn {...};
does nothing. If a command receives nil / undefined as input, it is ignored.
Hmm alright
this addEventHandler ["GetOut",{terminatescript "CPM.sqf"}];```
(edited)
Does that look about right?
No
Should be:
0 spawn {...};
or
[] spawn {...};
Because the argument is mandatory for spawn (but not execVM).
You have to terminate the script handle (SCRIPT type) and not a filepath.
Don't understand why people keep using execVM
@sullen willow ```sqf
myHandle = execVM "scriptPath.sqf";
terminate myHandle;
Yeah, and terminate is the command name, not "terminateScript".
However, I do recommend you to make a function variable
And then spawn that (if you want to run scheduled)
Keep in mind, that execVM always creates a new thread @sullen willow
Doesn't terminate it when I exit the vehicle.
Code snippet? @sullen willow
sleep 5;
systemChat "You gain 500 USD";
[500,0] call HG_fnc_addOrSubCash;
},
vehicleVar addEventHandler ["GetIn", {Harmont_scriptHandle = [] spawn Harmont_myScriptVar}];
vehicleVar addEventHandler ["GetOut", {terminate Harmont_scriptHandle}];
That should work
@sullen willow
That event has to be added to a vehicle. You're thinking of getInMan
What's with my name being in it
Good practise to have a OFPEC tag
Like HMT_ or whatever
Keep it short
The BIS functions uses BIS_fnc_whateverFnc
That's not seeming to work
you could just exit the loop with the condition?
๐คท๐ผ I don't know enough of about any of this to figure that out. I'm still a nooblet.
I thought I had it figured out how to terminate something but I was wrong.
What are you trying to terminate?
while {alive car1 && {vehicle player isequalto car1}} do {```
if you're just wanting that loop to end try this^
I want it to end when I step out of the vehicle
The script fires when you get in
I need it to terminate when you get out
yea, try that while condition then. it would probs still pay you once more cause your sleep is at the start of the loop, but that would end the loop once you get out
where do I place that
while {alive car1 && {vehicle player isequalto car1}} do {
sleep 5;
if !(vehicle player isequalto car1) exitwith {};
systemChat "You gain 500 USD";
[500,0] call HG_fnc_addOrSubCash;
},```
its the condition at the top
@peak plover give diag_codePerformance a higher iteration count. the for loop removing a lot of precision.
Anyone else had issues with ctrlSetBackgroundColor not working for some controls? Ie RscListBox and RscButton
I know that there was stuff about button.
Yeah just found a bug report for that, but am experiencing it with lists now ๐ฆ
Yeah, button does not work
Is there something like a wildcard for strings in Arma?
@still forum Just saw your note on the command saying ""Only affects Comboboxes, Static Text, Structured Text or Maps. " Which really sucks. I could put a feedback ticket up, but what are the chances of it getting fixed lol. Someone already did 3 years ago
@simple solstice Depends on what you're trying to do. Most likely no.
@little eagle yeah, that would be too beautiful
do you guys know how to use the follow waypoint?
i put a car to follow another but he just dont move
@astral tendon doesnt work afaik
wait, it never did?
mmmm
brain fart lol
trying to figure out how to generate a hypotenuse output
from an aircraft to the ground (slant range)... like as in how to build it to get measurements from aicraft to ground and the point on the ground which the camera is looking at....
distance command doesn't calculate slant range
as in it doesn't take altitude into consideration
Thats distance2D
Distance uses the AGL format, so it's weird depending on what you do.
Z=0 has a different position depending on the height of the map at X,Y.
i'm trying to use drawIcon to put an icon on an object on a map and change said icon based on properties selected in said dialog. I have this working with drawIcon3D as it works within an onEachFrame EH but drawIcon doesn't play nice in that EH, it apparently needs to be in a "Draw" control event handler.
Issue here is I can't pass an argument (the properties that dictate icon style) in ctrlAddEventHandler as you can with other event handlers , am I wrong? Is there another way?
ctrlAddEventHandler ["Draw",{call myFnc}] and then in your myFnc use the drawIcon command.
and then i can pass arguments to the function. nice, thanks that should do it.
i'm working on coding this now to give it a try still, but as i think of it, I'm affraid the passed variable may be out of scope of the EH and not pass properly to the function.
_control setVariable ["commy_args", _args];
_control ctrlAddEventHandler ["Draw", {
params ["_control"];
(_control getVariable "commy_args") params ["_arg1", "_arg2"];
}];
Does this help?
yes
should have thought of that, i can just set a variable on the map control that i already am manipulating. thanks dude
Alternatively:
[_control, "draw", {
systemChat str _thisArgs;
}, _args] call CBA_fnc_addBISEventHandler;
Which does essentially the same.
oooooo ^^^^ I'm saving that... interesting
@indigo snow no need to call the fnc in the code
ctrlAddEventHandler ["Draw", myFnc] is enough
Something something then the entire function ends up in there and that takes up more space
Because the function ends up in there as a string in the engine
are spawned scripts added to any lists?
I guess I need to do that manuelly ๐ญ
I want to see if all my scripts that are looping have any performance impact ๐
I was wondering how do I solve the issue of locality and setHitPointDamage. The vehicle has to be local to the client issuing the command, so that means no other player can repair the vehicle. Is there any way that a non-local player to the vehicle could issue this command with effects?
Use remoteexec and use the vehicle has the target
It's better to use
ctrlAddEventHandler ["Draw", {call myFnc}]
over
ctrlAddEventHandler ["Draw", myFnc]
Especially for Draw and EachFrame handlers, because the game stores the functions as strings and has to recompile them for every execution.
myFnc could be very long while {call myFnc} is probably as short as you can get.
Well, my mission is like 90% done. That script is still kicking my ass in multiple different fashions, though.
// init.sqf
0 spawn {
while {true} do {
sleep 5;
if (player in car1) then {
systemChat "You gain 500 USD";
[500,0] call HG_fnc_addOrSubCash;
};
};
};
???
forgot the loop part.
Why not like this?
There was another problem as well
The other problem is that the script is firing for everyone on the server rather than just the person entering the vehicle.
I'm writing a script that lets each player vote, so i need to send the vote result to the server. instead of sending lots of public vars, can't i just attach the vote to the player as a var and then fetch it from the server?
Do it like I said and it will work. GetIn doesn't seem to be the right approach for this imo
I have an idea that may make this very easy, asdfghj
Do you use any mods?
Is there a way to detect who destroyed building when the addMissionEventHandler :"buildingChanged" is used ?
@little eagle what you posted up there, does go in the vehicle's init?
could one quickly check what happens when one does this: "foo" == []
error
yea prob type bla expected bla type of error
^
probably is not knowing
And a long list of stuff that == accepts. Everything besides BOOL and ARRAY and some weird ones
i never use this so i dont know exactly. maybe just go look it up yourself later?
never use because it doesn't work
It reports nothing and writes an error to the RPT file.
because it doesn't work that is the reason i need to know :3
you got your answer. i jsut added "prob" so you nerds dfont shit all over me if i'm wrong ๐
@little eagle I have 6 cars to do this for. Would I just repeat that for each of them with their respective name?
stupidity in arma ... check types first, then handle each type separate
19:32:08 Error in expression <isNil {"" == []}>
19:32:08 Error position: <== []}>
19:32:08 Error ==: Type Array, expected Number,String,Not a Number,Object,Side,Group,Text,Config entry,Display (dialog),Control,Network Object,Team member,Task,Location
@tough abyss remoteexec on every client (-2)?
Nope you pass the vehicle object as the target. it will get remove executed were its local
if (vehicle player in [car1, car2, etc]) then {
Gotcha
what is "not a number"? nil but expected number?
Nan is a type for infinte etc.
@tough abyss oh wow, thanks!