Search the Community
Showing results for tags 'variables'.
Found 16 results
-
Variables for Triggers in Multiplayer Mission File
EveMakya posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hey all, I'm relatively new to Arma 3 scripting and have run into an issue. I recently figured out that I could activate triggers synced to show/hide modules with a variable set with an add-action, essentially allowing me to control entire swaths of triggers with a button press, something I have found to be far more reliable than triggers activated by the physical presence of a unit. What I have is a set of triggers that simply have the variable and a semi-colon: StageOneActivated; And then with an add-action added with an init.sqf, I have: Controller addAction [ "Begin Phase One", {StageOneActivated = true; Controller removeAction (_this select 2); }]; Which sets the StageOneActivated to true which activates the trigger and removes the now-useless addaction from the list. Both locally and testing in local multiplayer via LAN this works flawlessly, but on the server the triggers simply don't respond. I know the init.sqf is working because the addAction's are present. And I know the addAction is working because it's removing the addaction after use. This implies the variables are whats not working correctly. I went into my init.sqf and decided to call the variables on mission start and set them, so I have the line: StageOneActivated = False; This has made no impact, neither in the locally tested version which still works, nor on the server which still fails. I've read through the documentation on global variables and I think this is probably what I need to do: to call the variables globally in the MP mission but I am struggling with the syntax. Do I just add publicVariable "StageOneActivated"; to the init.sqf after the line where I set the variable state as StageOneActivated = false; or do I need to call the public variable in the add-action as well? or is there another way to name and set these variables that I am missing entirely? Any help is appreciated. I want to start using variables more to really add some oomph into my missions and this is something that is going to come up a LOT.- 1 reply
-
- help requested
- variables
-
(and 4 more)
Tagged with:
-
Arma 3 scripting tutorials from gokitty1199/IM SORRY BUFFALO(both me)
gokitty1199 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Last content update: 6/13/2018 showing how to use the radius for addAction, using params instead of select, adding to arrays with various commands, altering arrays with various commands, get/setUnitLoadout Last content update: 6/10/2018 going through config files and getting details to sort what you want, using radius with addAction, params, and altering arrays with resize, pushBack, pushBackUnique, set, and append and going over to assist with resize count. Last content update: 5/27/2018 added GUI tutorial for how to make a weapon selector using cfgWeapon Last content update: 5/24/2018 added sector control tutorial Last content update: 5/21/2018 This is my arma 3 scripting tutorial series which is aimed to help both people getting into making their own scripts with fairly detailed simple tutorials as well as for the intermediate person looking to create their own features for their missions. The plans for this series is to almost fully cover everything behind the arma 3 missions that people play on a daily basis and have enough content provided in the videos where people can go off and make their own vision for their mission with the knowledge gained. Most of these videos are made on the fly at 1AM-4AM without any pretesting which should give someone the idea of what goes into finding syntax errors and narrowing down a bug that's causing your feature to not function properly. It is also an excuse for you to cut me some slack if you see mistakes :) . A lot of these tutorials are made with multiplayer in mind since I think most people want to play their missions online with their friends(which is why publicVariable has been utilized so much so new people can get a good grasp on the power those commands have). New videos are added to the playlist almost every day so if your stuck with something, maybe it has been covered in a video. If you have any requests on what you would like to see made then please suggest it here. topics covered so far Scripting tutorial playlist Database tutorials with INIDBI2 playlist GUI/Dialog tutorials playlist- 23 replies
-
- 19
-
variables Passing a global variable to a script then back again
chow86 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
This feels like an obvious question but my Googling has failed... I want to pass the name of a global variable to a script, e.g. [myVariableGlobal] execVM "myscript.sqf" (this script will deal with other global variables, hence why the name of the variable needs to be part of the argument to execute it) And in the script "myscript.sqf", e.g. _myVariableLocal = _this select 0; Say "myVariableGlobal" was previously defined globally as "false". I now want "myscript.sqf" to define it as true. Simply writing the following in "myscript.sqf" should not work, since the variable is now only local: _myVariableLocal = true; How, then, do I make it global again? -
Passing Variable Array to Description.ext
alpha993 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hey all, I've been trying to pass a variable containing an array into the mission parameters in my description.ext using preprocessor commands, but I've had no luck so far. I'm not very familiar with the preprocessor commands as it is, so I'd greatly appreciate if anyone could point me in the right direction. What I'm trying to do step-by-step: Create two 'string' arrays in a preInit function, one with just numbers, and the other with just strings. e.g. ALP_arrayNum = "0, 1, 2, 3, 4, 5" & ALP_arrayText = " 'zone0', 'zone1', 'zone2', 'zone3', 'zone4', 'zone5' " Store those 'string' arrays into two variables. see example above. Compile the variables so that they get the braces required by config arrays. ALP_arrayNum becomes {0, 1, 2, 3, 4, 5} ALP_arrayText becomes {'zone0', 'zone1', 'zone2', 'zone3', 'zone4', 'zone5'} Declare those variables in the description.ext using preProcessor commands. Using __EXEC or __EVAL? Define the values[] and texts[] attributes in the params class using those two variables. This way I can achieve a dynamic parameter that doesn't need to be rewritten by hand whenever the mission is modified or ported to other maps. // === PARAMETERS class Params { class ALP_selectedArea { title = "Main Zone"; values[] = {}; //<--------DEFINE THIS WITH VARIABLE CONTAINING ARRAY OF NUMBERS texts[] = {}; //<--------DEFINE THIS WITH VARIABLE CONTAINING ARRAY OF STRINGS default = 0; }; }; My attempts: #1 -- This one throws a "_ found, { expected" error // === PARAMETERS class Params { class ALP_selectedArea { title = "Main Zone"; values[] = __EVAL(ALP_arrayNum); texts[] = __EVAL(ALP_arrayText); default = 0; }; }; #2 -- This one doesn't throw an error, but returns 'any' in the params menu, presumably because it's actually duplicating the braces like values[] = {{0, 1, 2, 3, 4, 5}} // === PARAMETERS class Params { class ALP_selectedArea { title = "Main Zone"; values[] = {__EVAL(ALP_arrayNum)}; texts[] = {__EVAL(ALP_arrayText)}; default = 0; }; }; #3 -- This one behaves like #1, where it throws a "_ found, { expected" error // === PARAMETERS #define ZONEVAL values[] = __EVAL(ALP_arrayNum); #define ZONETXT texts[] = __EVAL(ALP_arrayText); class Params { class ALP_selectedArea { title = "Main Zone"; ZONEVAL ZONETXT default = 0; }; }; Again, any help would be greatly appreciated! -
Variable from editor placed props [Solved]
PortalGunner posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi, I'm creating a mission parameter that deletes all pre-placed props (under Empty) in case our Zeus wants to change our spawns occasionally. So far this is what I have in the script: What would I need to set as _objects to detect props? And will it detect and remove objects I've checked "Simple Object" on as well (if so that would be great)? I would like to be able to set a variable on objects in the editor to exclude them from this as well. Any help is appreciated, thanks! Edit: working code -
Hi all! I am trying to implement a sound on a specific building on my new map. (cf pmc wiki : https://pmc.editing.wiki/doku.php?id=arma3:terrain:environmental-sounds) But I do not understand the variables, I do not understand or the config will look for the object in question. Can you help me? Another question, is it possible to directly implement a smoke effect (cars exploded) directly on the map? Or do you have to do it via EDEN editor with the modules? Regards, Casseburne
-
How would you go about caching units only to be deleted later, but doing it all locally? Ive set up a nice script that populates towns with random patrols, now i just need a way for the patrols to get deleted once the player leaves the area. HNK_fnc_createVehPatrols does nothing, thats for later once i figure out how to delete the spawned units. :P Also i ment to type selectRandom instead of floor random.
-
I have 3 variables for heli's sarheli0, sarheli1 and sarheli2 imported from the mission. how would I put them into the near objects so I can assign an AI to get in the heli in the trigger zone (script is triggered from another script) this is my code casGroup = _this select 0; casPos = _this select 1; casSpawn = _this select 2; sarheli = _this select 3; sarheli1 = _this select 4; sarheli2 = _this select 5; _heliTypeSearch = casPos nearObjects [['sarheli0','sarheli1','sarheli2'],40]; _heliType = _heliTypeSearch select 0; casSpawn assignAsCargo _heliType; [casSpawn] orderGetIn true; Cheers.
-
Ok, that's a bit of a complex problem. As far as I know arma uses 2 kinds of variables: private and global and that will be the biggest problem here. I'm trying to call a script from a object (Data Transmiter) that will add a Hold Action to it. No problem for now and works as intended for a single Data Transmiter. But when I use the same script for a second Data Transmiter only the second one will work. Why that happens? Because some parts of the code requires global variables. So, how can I fix it? I honestly have no idea. That's the code for reference, just call it with a handle = [this] execvm "name of the file.sqf" and should work. //select object name and apply to global _datalinkname = this select 0; datalinkname = _datalinkname; //params ["_datalinkname"]; //Set Datalink Color [datalinkname,"blue","orange","red"] call BIS_fnc_DataTerminalColor; //open/arm function fn_potato = { [ datalinkname , "Hack DataLink", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", { systemChat "Start Hacking"; }, { playSound3D ["a3\sounds_f\sfx\beep_target.wss", datalinkname, false, getPosASL datalinkname, 1, 1, 0] }, { [datalinkname, 3] call BIS_fnc_DataTerminalAnimate; sleep 5; hint "after 5 sec..."; playSound3D ["A3\Sounds_F\sfx\alarm.wss", datalinkname, false, getPosASL datalinkname, 1, 1, 0]; datalinkname call fn_potato2 }, {}, [], 3, 0, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, datalinkname]; }; //close/disarm function fn_potato2 = { [ datalinkname , "Hack DataLink", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", { systemChat "Start Hacking"; }, { playSound3D ["a3\sounds_f\sfx\beep_target.wss", datalinkname, false, getPosASL datalinkname, 1, 1, 0] }, { [datalinkname, 0] call BIS_fnc_DataTerminalAnimate; sleep 5; hint "after 5 sec..."; playSound3D ["A3\Sounds_F\sfx\alarm.wss", datalinkname, false, getPosASL datalinkname, 1, 1, 0]; datalinkname call fn_potato }, {}, [], 3, 0, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, datalinkname]; }; //calls first function datalinkname call fn_potato;
-
Freezing a variable in another variable.
Omurice. posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
I currently have a script that tracks the velocity and distance traveled by a bullet. I have it set up currently to tell me these things in a hint box. After firing the weapon it displays the _velocity variable and the _distance variable and they update in real time through the hint. I want to know the distance at which the bullet becomes transonic (When the bullet drops beneath 343m/s). I need to get the _distance variables value when _velocity is equal to or less than 343 (something like if (_velocity < 343) then {_transonic = _distance};). The only problem is that if I set the new _transonic variable to be equal to _distance then in the hint box the variable will continue to update with _distance. I need a way to take the _distance variable at a given value of _velocity and take the exact value at that time and save it to another variable. I do know that I could just end the tracking when the _velocity reaches 343 but then the distance would no longer be tracked beyond that time. -
cutRsc and Updating Variables
complacent_lizard posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello! Last time I had an issue the BI community came to my aid, and I know how useful these forums are for everyone else, so here goes... I'm displaying a money variable for the player by using an RscTitle in the top left of the screen - that's all good. The problem is I'm not sure how to go about displaying a variable in that RscTitle that updates so that the amount of "money" the player has is displayed at all times. Here's my description.ext: class RscTitles { class CashDisplayTitle { idd = -1; duration = 1e+1000; class controls { class CashDisplayControl { idc = -1; type = 0; style = 0; x = safeZoneXAbs; y = safeZoneY - 0.45; w = 1; h = 1; font = "EtelkaNarrowMediumPro"; sizeEx = 0.05; colorBackground[] = {0,0,0,0}; colorText[] = {0,0.6,0,1}; text = "$"; }; }; }; }; So I've got 2 minor obstacles - how can I display the cashVariable in my CashDisplayControl, and how can I set up a script which updates that value? If you've got any pointers / links, I'd very much appreciate it! (I have read around, but the examples I've found are very case specific and get a little convoluted) Thanks for reading and for being an outstanding community! -
Passing an objects variable to a script (ExecVM help)
gavc posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
What i'm trying to do is determine the speed of a vehicle and then implement whatever code dependent on the value returned. I tried lots of different stuff but eventually just dropped all my code in order to just output hints, as i couldn't even get them working. I finally figured out which part was breaking my brain... and i think it's how i'm retrieving information.... So in the editor i place down a civilian car, give it no variable name, and call a script using EXecVm. _this = execVM "riggedcar.sqf" In RiggedCar.sqf i wanted to first find the car object so i used _car = nearestObject "Vehicle"; if (speed _car >= 50) then {hint "You're going too fast!"}; So in order to get the speed of the car, do i need to pass the speed from the execVM to the script, is "speed _car" recognised within the script or should i have defined the variable within the script itself... something like _carspeed = speed; I tried Velocity too, at least i got that to output 0,0,0 but it wouldn't change when the car moved. Also, as this is just an If statement and i want it to run over time should i be using a while loop, or an eventHandler in order to test the cars speed every second or so? Any help would be appreciated, even if it' to point me in the right direction, examples of passing information/variables or calling properties of a object etc. Gav -
Task description with variables
Sanchez Milsim posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi, I would like to create a task with a long description with location. for example something like this: _nearestCity = nearestLocation [ getPos _wounded, "nameCity"]; [ WEST, ["task", "We need MEDEVAC at _nearestCity ", "MEDEVAC", "MEDEVAC", getPos _wounded, "created"] ] call FHQ_TT_addTasks; Im using FHQ TT for tasks. I try a lot of options but nothing works. I think is usefull for dynamic tasks. Thanks!! -
Anyone know how to save some variable for a specific player before logging out from a multiplayer mission and load the same when connecting again?. The same variables assigned for a specific player. It could be something like this?: Variable1 = player setVariable ["Car",1,false]; Variable1 setVariable ["ownerUid", getPlayerUID player, True]; PublicVariableServer "Variable1"; It'd be nice if the variable1 is different for a player than other. So Variable1 [Car] is "1" for player1 ,but it's "0" for player2, and so. Any idea to load those stats like an inventory in DayZ but in Arma 2 using variables?. Thanks!
-
Hi, I'm trying to write a script but can't solve this puzzle/problem: 1. At the start of the script I create a variable e.x. _target 2. I pick a random alive player, the script is working with _target beautifully 3. when all players died and they respawn the variable _target is undefined I try to catch that information with something similar to this: if (isNil "_target") then { _target = selectRandom playableUnits; }; Yet the variable remains undefined and I can't figure out why. If anyone wants to look at complete code I can send them a link. cheers, Daishi
-
A little bit of background first. I am an amateur scripter with a decent amount of mission making under my belt. Because of my amateur status I've had to rely on awesome people in my community and the arma 3 community in general to do what I wanted to do for my missions and templates. This was my very first step into what I consider really trying to create something that is a little different. I'm sure there are better ways to do what I've done, and I would love to hear them! But I just wanted to share this to hopefully help anyone who has also started the journey into arma 3 scripting. To really get into things I'll start by saying that with the way my unit works in Arma 3 I make all of the mission templates for our operations. Which averages around 3-4 per week depending on mod updates, errors (on my part mostly!) module tweaks, etc. None of that really bothers me, what did bother me is when I got all of that out of the way and the mission works fine, and there is no need to update the template except for the fact that the unit has changed starting locations for a few players. ARGH! lol So with that in mind I went to youtube to try and figure something out and I cam across this nifty video: I thought cool that would work. I could place the initial spawn right inside of a teleport zone and immediately have the players that load in move to that zone. Zeus can move whatever object it is to the new starting point for the week and I'll be able to perhaps make a few less templates on average. (Still need have updates and stuff right? yep, no worries.) Well then I came up with a few more ideas to make it "better" which is certainly my own fault. So about a week and a half later, and lots of help from a few different people and a lot of browsing the wiki led me to this finally: The Features: - JIP Functional - Enable or Disable the Teleport Manually - Automatically Disable the Teleport if the Teleport Flag is deleted - Automatically Renable the Teleport if the Teleport Flag is rebuilt - Rebuild the Teleport Flag - Delete the Teleport Flag - Only Accessible by Zeus - Automatically Add the Teleport Flag to Zeus at map start, and if rebuilt - Spawn the players randomly around the flag (within 16 meters) How it works: 1. Placed on the Map: Player: controller Player: s3ops Player x 50: other names/players ModuleCurator_F, name: zeusmod, owner: #adminLogged ModuleCurator_F, name: zeusmod_1, owner: controller ModuleCurator_F, name: zeusmod_2, owner: s3ops flag named "s3_tf_spawn" marker named "s3_tf_spawn_marker" marker named "s3_tp_zone", size 16x16 "s3_tf_spawn" synced to ModuleCuratorAddEditableObjects ModuleCuratorAddEditableObjects synced to 3 x ModuleCurator_F trigger, size 0x0, activated repeatedly, blufor not present, condition "this && !alive s3_tf_spawn;", on act "s3_tf_spawn = nil;" object (Laptop), name: s3_spawn 2. In the init.sqf: s3_spawn addAction ["Enable Teleport to Flag", "scripts\s3_tp_enable.sqf"]; s3_spawn addAction ["Disable Teleport to Flag", "scripts\s3_tp_disable.sqf"]; s3_spawn addAction ["-----------",""]; s3_spawn addAction ["Rebuild Teleport Flag", "scripts\s3_spawn_s3_tf_spawn.sqf"]; s3_spawn addAction ["Delete Teleport Flag", "scripts\s3_delete_s3_tf_spawn.sqf"]; s3_spawn addAction ["-----------",""]; 3. in the initplayerlocal.sqf: waituntil {! isnull player}; if (player == player) then { null = execVM "scripts\s3_tp_init.sqf"; } else {}; Now the Scripts: 4. s3_tp_init.sqf: _run = true; while {_run} do { if(isNil "s3_tf_spawn") then { stopTeleporter = "yes"; publicVariable "stopTeleporter"; } else { if(isNil "stopTeleporter") then { stopTeleporter = "no"; publicVariable "stopTeleporter"; }; if(stopTeleporter == "yes") then { _run = false; }; if(player distance (getMarkerpos "s3_tp_zone") < 15) then { player setPos [(getPos s3_tf_spawn select 0)+((random 16)-8), (getPos s3_tf_spawn select 1)+((random 16)-8)]; }; }; sleep 2; }; 5. s3_tp_enable.sqf: _s3curators = allCurators; _s3logic = getAssignedCuratorLogic player; if(_s3logic in _s3curators) then { if(isNil "s3_tf_spawn") then { Hint "The Flag Does Not Exist, Please Rebuild it." } else { stopTeleporter = "no"; publicVariable "stopTeleporter"; ["scripts\s3_tp_init.sqf","BIS_fnc_execVM",true,true] call BIS_fnc_MP; Hint "Teleport Enabled"; sleep 2; }; } else { Hint "You are not in the Zeus Slot, Access Denied." }; 6. s3_tp_disable.sqf: _s3curators = allCurators; _s3logic = getAssignedCuratorLogic player; if(_s3logic in _s3curators) then { stopTeleporter = "yes"; publicVariable "stopTeleporter"; Hint "Teleport Stopped"; sleep 2; } else { Hint "You are not in the Zeus Slot, Access Denied." }; 7. s3_spawn_s3_tf_spawn.sqf: _s3curators = allCurators; _s3logic = getAssignedCuratorLogic player; if(_s3logic in _s3curators) then { if(isNil "s3_tf_spawn") then { s3_tf_spawn = "FlagCarrierWest" createVehicle markerPos "s3_tf_spawn_marker"; zeusmod addCuratorEditableObjects [[s3_tf_spawn],true]; zeusmod_1 addCuratorEditableObjects [[s3_tf_spawn],true]; zeusmod_2 addCuratorEditableObjects [[s3_tf_spawn],true]; publicVariable "s3_tf_spawn"; Hint "Teleport Flag Rebuilt"; } else { zeusmod addCuratorEditableObjects [[s3_tf_spawn],true]; zeusmod_1 addCuratorEditableObjects [[s3_tf_spawn],true]; zeusmod_2 addCuratorEditableObjects [[s3_tf_spawn],true]; Hint "The Flag Already Exists, Added to Zeus." }; } else { Hint "You are not in the Zeus Slot, Access Denied." }; 8. s3_delete_s3_tf_spawn.sqf: _s3curators = allCurators; _s3logic = getAssignedCuratorLogic player; if(_s3logic in _s3curators) then { deleteVehicle s3_tf_spawn; s3_tf_spawn = nil; publicVariable "s3_tf_spawn"; Hint "Teleport Flag Deleted"; } else { Hint "You are not in the Zeus Slot, Access Denied." }; If you have any questions on why, or how things worked feel free to ask and I shall answer to the best of my abilities.Good luck and have a great one!
-
- curator
- teleport zone
-
(and 3 more)
Tagged with: