Jump to content

Heeeere's johnny!

Member
  • Content Count

    899
  • Joined

  • Last visited

  • Medals

Everything posted by Heeeere's johnny!

  1. nearestBuilding is sort of buggy when it comes to non-default buildings. It also does not detect buildings which are placed on runtime. You may wanna post your information in this ticket: http://feedback.arma3.com/view.php?id=21422
  2. Heeeere's johnny!

    getVariable penformance

    Do you really write your code like that or do you obfuscate it before posting it in the forums?
  3. UI measures in ArmA are NOT pixels or inches or whatever. They are values between 0 and 1 where 0 is basically "nothing" and 1 is the height/width of the screen. There are some special things which make this statement not exactly true, but for ease of explanaition, let's keep say it was that way. Your lines to create _actX and _actY are very long. You shouldn't over complicate things when you don't know where the error is. If you want the top left corner of the image to be outside the screen, you need to use values smaller than 0 (as you already found out). I personally haven't had such problems yet, but I assume, you might get a senseful result, if you use ctrlPosition on the control containing the image, when the dialog is opened. Then you can do your calculation with these values, which come in form of an array [x, y, w, h].
  4. Well, you write your addon adds new units. I don't know what code your addon already consist of, so I can't really make a precise statement, but simply put this code where you would create/add the unit.
  5. _newGroup = createGroup blufor; _unit = _newGroup createUnit ["className", _somePosition, [], 0, "NONE"]; _allWeapons ["M16A2", "M16A2GL", "m16a4", "M4A1", "M4A1_AIM_CAMO", "G36A", "G36C"]; _weapon = _allWeapons select floor random count _allWeapons; _unit removeWeapon primaryWeapon _unit; _unit addWeapon _weapon; This code is untested though and I couldn't come up with a generic solution for adding the correct magazines, but I hope this helps as a starter. Also, if you're trying to do this in MP, notice that in ArmA 3 there are command called removeWeaponGlobal and addWeaponGlobal, so I wouldn't assume that removeWeapon and addWeapon remove/add the weapon globally in ArmA 2.
  6. I also believe it's the _forEachIndex since both count and forEach do pretty much the same, only that count expects nil or a boolean as return value (and is still faster) while forEach doesn't care. But if you don't like long inline efficient checks, use a constant (#define) like this: #define IN_ARRAY(ELEMENT,ARRAY) (1 isEqualTo {if(ELEMENT isEqualTo _x)exitWith{1}}count ARRAY) if (IN_ARRAY(123,[551,21,123,13435,121,6,13])) then { ... };
  7. Heeeere's johnny!

    Mast lights on Fishing Boat

    You can add this event handler to the player and shoot at the lamp/mast. If you're lucky and the bullet does not go through, the light will stick there and a hint will show you the position ATL of the light. You may then use that to get the position of the light relative to the ship using the modelToWorld command. light = objNull; eh_fired = player addEventHandler ["Fired", { _bullet = _this select 6; deleteVehicle light; light = "#lightpoint" createVehicleLocal getPosATL _bullet; light setLightBrightness 0.06; light setLightAmbient [0, 1, 0]; light setLightColor [0, 1, 0]; _bullet spawn { while {alive _this} do { light setPosATL getPosATL _this; }; hintSilent str getPosATL light; }; }]; I tried to add a "hit" event handler to the object I was shooting at, but it did not seem to work. Otherwise, I'd already have made the code so it gave you the model position, but I hope this helps you, too.
  8. Automated Doors - v2.5.a2 (ArmA 2 version) Download v2.5.a2 from Armaholic What? This is a backport of Automated Doors for ArmA 3 to ArmA 2. For each player on the map, this script creates and removes triggers on nearby buildings which open the door if a player intends to walk through it and closes it again, when he walks away. This script is configurable and customizable on both server and client side. Features: all doors open and close automatically usable in Singleplayer (client side) or in Multiplayer (server side only) support for dynamic locations where this script should only work support for side specific locations, where this script only works for players of the respective side actions for the following features:enable/disable automatically closing doors enable/disable "Automated Doors" completely irreversibly* remove all actions related to "Automated Doors" globally force doors to stay open, no matter what the player's actions say can be terminated and restarted without trigger-leftovers or action-leftovers minimized server load due to need-based dynamic object management *) Actions will be available again, if you rejoin the server (MP) or restart the mission (SP) respectively Supported maps: Altis/Stratis (combined in one file) Chernarus Takistan Zargabad Utes Why? At some point, I got annoyed of having to walk really close to a door and sometimes even having to scroll, if my default action is something different, to get the right action to finally open it. Maybe there's some people out there feeling similarly. How? Download the script here (Armaholic, same link as above). You need at least the following files: automatedDoors_a2.sqf or automatedDoors_a2oa.sqf removeAllActions.sqf setVariable.sqf one or more file(s) starting with "doors..." Execute one of the following lines depending on which file you're using: execVM "automatedDoors_a2.sqf" execVM "automatedDoors_a2oa.sqf" If you use Automated Doors on a map which is not listed above, but has buildings from one or more of these maps or if you want to override the script's default behavior, paste the respective map name(s) as parameter into the script like this: [["Chernarus", "Takistan", "Zargabad"]] execVM "automatedDoors_a2oa.sqf" If you don't do so, the script will automatically take into account all maps. Singleplayer: Execute the above line once upon mission start - that's it. Multiplayer: Execute this script server side once upon mission start. Client side execution is prevented by "isServer" check. After joining a mission running this script, it might take a few seconds until it actually works for you as new player, because the sever runs the "scan loop" regularly, not taking into account JIP or just spawned players. Further Information Note that there are two files, one compatible with ArmA 2 v1.06 or later and another one compatible with ArmA 2:OA v1.63 or later. The ArmA 2 version also works with OA, but not the other way around. Be aware that the version for OA is more efficient (faster) than the one for ArmA 2, so I'd recommend to use the version for the "normal" ArmA 2 only if necessary. "Automated Doors" has two optional parameters: maps -> (optional, default: "all") defines the buildings to be taken into account by this script - e.g. ["altis", "chernarus"] means, all buildings from Altis and Chernarus will be taken into account doorsStayOpen -> (optional, default: false) global definition of door closing behavior - if true, doors will have to be closed manually, player action "Don't keep doors open" has no effect - if false, doors will close automatically, player action "Keep doors open" has an effect You can easily customize important values, like the size of the area of the door triggers, the time between each scan for surrounding buildings or the area to scan on each loop. Do that by changing the defines at the beginning of the file (after the comment block). Define locations: If you want this script to only work in certain areas, create locations of type "Name" and set their name with the prefix "doors". This script will check on each scan loop if such locations exist. If so, it will only manage these areas. If all "doors" locations are deleted, this script will handle the whole map again. Side specific locations: If you create a location as described above and setVariable ["locationSide", any side here] to it, the doors inside that location automatically open and close only for players of that side. Changelogs will be posted in the original thread. Have a nice Play!
  9. Heeeere's johnny!

    Take an array through a function [easy ?]

    In addition to what KK said, floor will not reduce an integer number by 1, which you are trying to do in floor (count _array). That means, you're still gonna select a nil value behind the last value of _array which will result in an error. And why are you not doing your stuff in a forEach loop anyway? _all = [0.515342,0.515342,0.515342]; { _all set [_forEachIndex, floor (_x * 100) / 100]; } forEach _all; hintSilent str _all; //[0.51,0.51,0.51]
  10. Hi, I'm trying to get an addon to automatically run its fn_init.sqf when the player (or the server respectively) starts a mission. Now, in ArmA 3 this works with the "postInit" parameter in the CfgFunctions. The CfgFunctions for this script looks like this: class CfgPatches { class AutomatedDoors { version = "2.5.a2oa"; author = "Heeeere's Johnny!"; units[] = {}; weapons[] = {}; requiredAddons[] = {}; }; }; class CfgFunctions { class AutomatedDoors { class addon { file = "\automatedDoors"; class init { postInit = 1; }; }; }; }; class CfgMods { author = 76561198062118808; }; Afaik, "postInit" is a new thing in ArmA 3 which didn't exit in ArmA 2 yet. But there must be a possibility of running an addon after the game has started. I'd be glad if someone could point me into the right direction. Have a nice Play! Johnny
  11. Heeeere's johnny!

    vehicle damage

    This doesn't work, because the if-condition has assignments ("="), but must have comparisons ("=="). And just because I could, here's a slightly more efficient version of this: ^_^ if (1 == { if (1 == _vehicle getHit ("wheel_" + _x + "_steering")) exitWith {1}; } count ["1_1", "1_2", "2_1", "2_2"]) then { hintSilent "Vehicle does not have all wheels anymore."; } else { hintSilent "Vehicle still has all wheels."; };
  12. Put the following code into a file called "MyDisplay.hpp" (in this case): class Model3d { type = 80; //type 3D model direction[] = {0, 0, 0}; up[] = {0, 0, 0}; //position x = 0; y = 0; z = 0; model = "\core\Empty\empty.p3d"; //default model scale = 1.0; //size }; class MyDisplay { //best practise: file and display class should have the same name idd = 99990; //unique ID of the display enableSimulation = true; //game continues while the display is visible class Objects { class Model : Model3d { //colon means, class "Model" is derived from class "Model3d" idc = 99991; //unique ID of this control model = "myCustomModel.p3d"; }; }; }; Replace "myCustomModel.p3d" with your model file. I don't know though, if it works for anything else then p3d files. Finally, add the file in your Description.ext under the section "RscTitles", like this: class RscTitles { #include "MyDisplay.hpp" }; If the hpp file is in another folder than where the Description.ext is in, you need to specify the relative path in the #include line.
  13. Depending on what the condition is, you might find and Event Handler which could help you with the "when the condition changed" problem. Otherwise, you only have the options to either go with a loop which constantly checks if the condition has changed or you create a function which you call whenever you change the condition and which executes your above code.
  14. Heeeere's johnny!

    Help with custom loadouts

    In addition to what Davidoss said, if you execute this script in the init.sqf, it might be that the respective unit (e.g. player) is not initialized yet, when the script is called. So especially if you work with the player object in the init.sqf, I recommend to waitUntil {!isNull player}.
  15. You're missing a colon after the "http" in your Armaholic link: http://www.armaholic.com/page.php?id=30130
  16. Heeeere's johnny!

    Teleport to player

    OK, there were two errors I did not see right away. This here works when I execute it on the client in multiplayer: _object = createVehicle ["Land_Calvary_02_V1_F", screenToWorld [0.5, 0.5], [], 0, "NONE"]; _object setVariable ["unit", player, true]; [ [ _object, [format ["Teleport to %1", name player], {player setPosATL getPosATL ((_this select 0) getVariable "unit");}, [], 6, false, true, "", "!isNull (_target getVariable ['unit', objNull])"] ], "addAction", true, true, true ] call BIS_fnc_MP;
  17. Heeeere's johnny!

    Teleport to player

    Alright, when I get home, I'll be able to produce something which I can debug.
  18. Heeeere's johnny!

    Teleport to player

    Working example below. Does it say anything in the logs? Try this: snip If it works, add the action condition and see if the action is still visible.
  19. Heeeere's johnny!

    Teleport to player

    So, if I get it right, this might be what you want (untested code!): _object = createVehicle ["Land_Calvary_02_V1_F", screenToWorld [0.5, 0.5], [], 0, "NONE"]; _object setVariable ["unit", player, true]; [ [ _object, { _this addAction [format ["Teleport to %1", name player], {player setPosATL getPosATL ((_this select 0) getVariable "unit");}, [], 6, false, true, "", "!isNull (_target getVariable ['unit', objNull])"]; } ], "BIS_fnc_call", true, true, true ] call BIS_fnc_MP;
  20. Heeeere's johnny!

    Trigger Help?

    You're not an idiot. It just seems, you lack some knowledge, that's all. ^_^ But knowledge can be gained. So, your last line does not make sense. What you actually wanted to do was this: fnc_triggerListChanged = compileFinal preprocessFileLineNumbers "fn_triggerListChanged.sqf"; //initialize the function #define EH_DAMAGE "eh_handleDamage" #define EH_BULLET "eh_deleteProjectile" [ protectionZone, //same as the trigger name defined in the editor { _x setVariable [EH_DAMAGE, _x addEventHandler ["HandleDamage", {0}]]; _x setVariable [EH_BULLET, _x addEventHandler ["Fired", {deleteVehicle (_this select 6)}]]; }, { _x removeEventHandler ["HandleDamage", _x getVariable EH_DAMAGE]; _x removeEventHandler ["Fired", _x getVariable EH_BULLET]; } ] call fnc_triggerListChanged; //call the function
  21. Heeeere's johnny!

    Trigger Help?

    No, you don't need to change anything about the trigger's condition, that's all done by this function. Did you actually download the script and include it in your mission? https://forums.bistudio.com/?showtopic=179622 And secondly, I should have mentioned that "fnc_triggerListChanged" is just the way I call the function, because I don't use the function library. So, if you don't use the function library, you can put the fn_triggerListChanged.sqf into your mission root (the same folder as your init.sqf is in) and execute the following line in the init.sqf to create the function: fnc_triggerListChanged = compileFinal preprocessFileLineNumbers "fn_triggerListChanged.sqf"; Or, if you use the function library, you can put the fn_triggerListChanged.sqf into the folder where you have all your other functions are and call it with the function tag that all your other functions might have has well. Just like BIS functions all start with "BIS_fnc_", your functions might start with "DTJ_fnc_" when your tag is "DTJ".
  22. Heeeere's johnny!

    Trigger Help?

    If you created the trigger via script (as I did above) then yes. Since I assume you have placed the trigger in the editor and did not create it via script, you don't need the lines with the createTrigger, setTriggerActivation and setTriggerArea. Instead, all you need is this: #define EH_DAMAGE "eh_handleDamage" #define EH_BULLET "eh_deleteProjectile" [ protectionZone, //same as the trigger name defined in the editor { _x setVariable [EH_DAMAGE, _x addEventHandler ["HandleDamage", {0}]]; _x setVariable [EH_BULLET, _x addEventHandler ["Fired", {deleteVehicle (_this select 6)}]]; }, { _x removeEventHandler ["HandleDamage", _x getVariable EH_DAMAGE]; _x removeEventHandler ["Fired", _x getVariable EH_BULLET]; } ] call fnc_triggerListChanged; //source: https://forums.bistudio.com/?showtopic=179622 In the heat of the moment, I made a mistake in the removeEventHandler line, corrected it in both code snippets. Be aware that fnc_triggerListChanged will overwrite the trigger statements (condition, onAct., onDea.) so you don't need to set them.
  23. Heeeere's johnny!

    Trigger Help?

    Since safezones have been asked more than once in the younger past, here's another approach, similar to what I posted on other safezone questions: #define EH_DAMAGE "eh_handleDamage" #define EH_BULLET "eh_deleteProjectile" _protectionZone = createTrigger ["EmptyDetector", _position]; _protectionZone setTriggerActivation ["WEST", "PRESENT", true]; _protectionZone setTriggerArea [300, 300, 0, false]; [ _protectionZone, { _x setVariable [EH_DAMAGE, _x addEventHandler ["HandleDamage", {0}]]; _x setVariable [EH_BULLET, _x addEventHandler ["Fired", {deleteVehicle (_this select 6)}]]; }, { _x removeEventHandler ["HandleDamage", _x getVariable EH_DAMAGE]; _x removeEventHandler ["Fired", _x getVariable EH_BULLET]; } ] call fnc_triggerListChanged; //source: https://forums.bistudio.com/?showtopic=179622
  24. You don't need BIS_fnc_MP when you run a mission in the editor. BIS_fnc_MP only makes sense in a multiplayer environment. But afaik, it should work anyway. Since you are running the BIS_fnc_MP call in the init.sqf, it's of course senseful to put this missionNamespace statement before the BIS_fnc_MP statement into the init.sqf. Btw, missionNamespace setVariable is the same as declaring a global variable. You simply put the code into it's own .sqf file and call it using execVM. When you have it in a different folder than the init.sqf, you need to specify the path in the execVM string like this: execVM "someFolder\JSHK_fnc_Loading.sqf";
  25. Heeeere's johnny!

    correct array

    { if (isNull _x) then { _array deleteAt _forEachIndex; }; } forEach _array; This removes everything that is null, which does not only include objNull, but also grpNull, taskNull, controlNull, displayNull, locationNull and teamMemberNull.
×