Jump to content

thy_

Member
  • Content Count

    377
  • Joined

  • Last visited

  • Medals

Everything posted by thy_

  1. Hey, I help some help to improve this: The script does: for dedicated and hosted servers, a multiplayer playable area control based on a trigger area (with Y, X, Z) dropped through Eden Editor, where, if some player leaves that area, that specific player is punished immediately and, if there is a vehicle with them, the vehicle must be destroyed too. Improvement desired: as the script is loaded by description.ext | cfgFunctions and the script checks all players alive (they are able to respawn) as long the match goes, the desire is to improve those lines, remembering my dedicated server runs, sometimes, til 30 players. Ps.: for now, the target is just human players, not considering AI units out there. Here we go: fn_PAC_init.sqf: if (!isServer) exitWith {}; private ["_playersAlive", "_isPlayableArea"]; [] spawn { while { true } do { _playersAlive = (allPlayers - (entities "HeadlessClient_F")) select {alive _x}; { // forEach _isPlayableArea = _x inArea PAC_playableAreaControl; // Eden trigger if !(_isPlayableArea) then { [_x, 1] call THY_PAC_fnc_setDamage; }; } forEach _playersAlive; sleep 5; }; }; fn_PAC_globalFunctions.sqf: THY_PAC_fnc_setDamage = { params ["_target", "_damage"]; ["You left the playable zone!"] remoteExec ["systemChat", _target]; sleep 0.1; if !(isNull objectParent _target) then // checking if the player is in vehicle { vehicle _target setDamage [_damage, false]; }; _target setDamage _damage; }; On Eden Editor: Dropped a trigger and name it as "PAC_playableAreaControl". Share your thoughts, it will be very much appreciated. thy
  2. Btw... Trying to fix two bugs related to ACE and the repairing service: 1) When a vehicle is cooking-off inside the repair station service range Expected: vehicle be unavailable for any service; Today: the vehicle gets repaired meanwhile its turret is burning; As I did not find out a bool in ACE Cook Off Framework documentation that tells me if the vehicle is cooking-off, I gave a go with the lines below but of course, it doesn't work well for many reasons. // ACE Compatibility: if ( VO_isACErun ) then { _veh setVariable ["ace_cookoff_enable", false, true] }; // cook off disabled. // Repairing code... // ACE Compatibility: if ( VO_isACErun ) then { _veh setVariable ["ace_cookoff_enable", true, true] }; // cook off enable. 2) Looking for how ACE vehicle damages work Expected: when the vehicle gets hit by loose wheels/tracks/turrets, it should be enough to get repair service; Today: the APC loses all its wheels and the turret gets red color however the vehicle doesn't start repairing when close to the station; ACE Vehicle Damage Framework One of the conditions when ACE is not running: damage _veh > VO_minRepairService // vanilla Vo_minRepairService = 0.1 Any clue?
  3. interesting idea @pierremgi, sure it can bring light to some modification. The VO script shows those asset lists just as suggested options for the editor and not as mandatory. For example, the ground refuel service is configured just with two assets in my last mission, turning off all other services and doctrines. VO_grdRefuelAssets = [ "B_T_Truck_01_fuel_F", "B_Truck_01_fuel_F" ]; And about this: For script focus, VO is aiming at vehicle needs only.
  4. In the last two weeks, I spent A LOT of my days off to understand programming (I'm not a true one) and Arma scripts syntaxes and etc... Of course, lots of questions came over and some of them that are not clear at all is how to call (in each case) an external piece of code (.sqf) through the init files (init.sqf / initServer.sqf / initPlayerLocal.sqf). Yeap, I've read about them also... and init.sqf is the priority when the mission starts, meanwhile initServer and initPlayerLocal has no guarantees of execution order. Got it, but and how and why call some external scripts like these down below? // init.sqf null=[] execVM "myScript.sqf"; execVM "mySecondScript.sqf"; "andAnotherScript.sqf" remoteExec ["BIS_fnc_execVM"]; What I'm trying to get: https://community.bistudio.com/wiki/Event_Scripts https://community.bistudio.com/wiki/execVM
  5. Hey me from the past, you got wrong. That time was your first time set attention over "FUNCTIONS" topic so that was confusing, but today is a bit clearer. When you use CfgFunctions through Description.ext, you will use while-looping as well, but sometimes we create a file like "fn_PAC_globalFunctions.sqf" or something like that where we set ONLY FUNCTIONS, passing a wrong idea that you are not using while-looping or for-looping but in another file (where you are calling FUNCTIONS) you are. hehe. Cheers. You from the future.
  6. How can I identify only land vehicles when they approach specific class names from an array? I wouldn't like to use given ID names to identify objects as "obj01", but use the object class name as "Land_RepairDepot_01_civ_F". My idea is just to drag and drop in Eden Editor that kind of object and the script does what it must do. I'm reading about these things but I need some kickoff help from you guys. typeOf - https://community.bistudio.com/wiki/typeOf isKindOf - https://community.bistudio.com/wiki/isKindOf BIS_fnc_objectType - https://community.bistudio.com/wiki/BIS_fnc_objectType I've found this relationship somewhere: "CfgVehicles" "All" "AllVehicles" "Land" "LandVehicle" "Car" "Car_F" "Wheeled_APC_F"
  7. Here I am back! Finally, I have finished the idea and built it as an applicable script for everyone: There, you will get how I am identifying kinds of objects automatically, with no code on Eden Editor, even triggers. Hope it might help someone.
  8. I just forgot to tell you, guys. Here is the final script, (recently updated) working as gold for multiplayer (hosted and dedicated) and single-player missions. 😉 Cheers.
  9. I need some help: my code is stuck in my own (low) understanding around array and forEach when they need/should work together. Below, may you kindly point out the mistakes and show the fixes? I already read a lot of BIS wiki looking for how to code forEach inside forEach, even it doesn't look so clever, feeling... private _drivers = [driver01, driver02, driver03]; private _cars = [car01, car02, car03]; While {true} do { // DRIVERS { // forEach _drivers start... if (alive _x) then // if the driver is alive, so... { if ((_x distance _targetMarker) <= 30) then // DONT KNOW BUT IM NOT SURE THIS IS RIGHT. ISN't IT? { if (lifeState _x == "HEALTHY") then // if the driver is healthy, so... { _x directSay _sound1; // the driver screams. if (!isNull objectParent _x) then // if the driver is onboard a vehicle, so... { hint "driver has a veh"; // show text on screen. }; }; }; }; } forEach _drivers; // repeat that for each driver. // CARS { // forEach _cars start... if (alive _x) then // if the cars alive, then... { if ((_targetMarker distance _x) <= 30) then // DONT KNOW BUT IM NOT SURE THIS IS RIGHT. ISN't IT? { <HERE EACH DRIVER> directSay _sound2; // I DONT KNOW HOW TO CALL ANOTHER ARRAY+FOREACH HERE. sleep 0.3; _something createVehicle getPos _x; // DONT KNOW BUT IM NOT SURE THIS IS RIGHT. ISN't IT? }; if ((damage _x) >= 0.1) then // if the car get damage, then... { hint "car got damage!"; // show the text on screen. }; }; } forEach _cars; // repeat that for each car. sleep 1; // a looping breath. }; // while next looping.
  10. Oh, the final script (and solution for this topic) is here. Topic solved. 😉
  11. How can I simplify these three functions without losing their purpose? I get itchy hands when I find myself coding like this, without how to improve my time coding yet. If you'll suggest a functions merge, I will appreciate it if you also explain how should I call it. I have not enough experience with params yet (studying in progress...) THY_fnc_VO_checkPlayerVehRepair = { params ["_eachVeh"]; (alive _eachVeh) AND (speed _eachVeh < 2 AND speed _eachVeh > -2) AND (!underwater _eachVeh) AND ((getPos _eachVeh) select 2 < 0.1) AND (_serviceInProgress == false) AND (!isEngineOn _eachVeh) AND (damage _eachVeh > VO_minRepairService) }; THY_fnc_VO_checkPlayerVehRefuel = { params ["_eachVeh"]; (alive _eachVeh) AND (speed _eachVeh < 2 AND speed _eachVeh > -2) AND (!underwater _eachVeh) AND ((getPos _eachVeh) select 2 < 0.1) AND (_serviceInProgress == false) AND (!isEngineOn _eachVeh) AND (fuel _eachVeh > VO_minRefuelService) }; THY_fnc_VO_checkPlayerVehRearm = { params ["_eachVeh"]; (alive _eachVeh) AND (speed _eachVeh < 2 AND speed _eachVeh > -2) AND (!underwater _eachVeh) AND ((getPos _eachVeh) select 2 < 0.1) AND (_serviceInProgress == false) AND (({getNumber (configFile >> "CfgMagazines" >> _x select 0 >> "count") != _x select 1} count (magazinesAmmo _eachVeh)) > 0) };
  12. After all these months, here I am back. Since last March, I'm studying programming through Python in my free time and, gosh, that helps me to get functions and params. Next step will be OOP/classes hehe. But for now, here is the result: I already launched the script we were debating here. Thanks for @7erra and @Larrow support as usual. thy
  13. Script has been updated 😉 Jul, 8th 2022: Fixed vehicles spawn problems when a lot of them; Fixed infantry could not walk properly if in "safe" behavior; A bunch of performance improvements; Documentation has been included; initServer.sqf has been removed. The first post was updated as well!
  14. I'm working on it. The script is called "Vehicles Overhauling" (VO) where you can turn the ACE Rearming, Refueling, and Repairing OFF to use a proximity system of VO, more dynamic and compatible with other ACE features.
  15. Hello again, everyone. I'm doing my first steps into functions and parameters. Everything in this matter is new for me so here is my idea: For studies purposes, I want to put a helmet in each unit I get close. To set the target units for the function, all I would like to do is set a "call" in each unit-target. That said, my try (not working): myFunctions\TAG_fnc_addingHelmet.sqf: if (!isServer) exitWith {}; TAG_fnc_addingHelmet = { params ["_unit"]; if ( ((player01 distance _unit) < 3) AND (headgear _unit != "H_HelmetB") ) then { removeHeadGear _unit; _unit addHeadgear "H_HelmetB"; hint "Oh, thanks for the helmet!"; }; }; [] spawn { while { alive player01 } do { // Do I need to call the TAG_fnc_addingHelmet function in here somehow? sleep 5; }; }; And all I would like to do is put it (below) in unit init for this call my function: Init of any random unit: [this] call TAG_fnc_addingHelmet; Where are my mistakes, folks? More info: description.ext: class cfgFunctions { #include "myFunctions\TAG_fnc_functions.hpp" }; myFunctions\TAG_fnc_functions.hpp: class TAG { class init { class TAG_addingHelmet { file = "myFunctions\TAG_fnc_addingHelmet.sqf"; preInit = 1; }; }; };
  16. Got it! I already extended these amends on my end. Thanks. Love that abs command to simplify the speed condition. Functions and params are driving me crazy in my early steps into them. For example, even with your orientation and @Larrow inbox example (about another topic but around the same script), I'm struggling to get the rules behind params and how to call them properly. Look at this example where I am stuck in fn_VO_coreGrd.sqf: THY_functions.hpp fn_VO_coreGrd.sqf private [ /* a lot of variables */ ]; [] spawn { // CODE... While { /* condition */ } { { if ( [_eachVeh, _x, VO_grdServiceRange] call THY_fnc_VO_checkStation ) then // <--- "Error Undefined variable in expressian THY_fnc..." { // CODE... }; } forEach _fullAndRepairStations; // CODE... }; }; fn_VO_globalFunctions.sqf
  17. @Larrow, not sure if I am implementing correctly but here is nothing besides an error that I even can describe accurately. Much easier I show you what is going on. It's the same example that I show you on another topic (about isTouchingGround - btw that is fixed already). I don't know why, but truck-technicals with fixed .50 turret have 3 mags capacity, but if we spent some OR all of them, the rearming has an odd behavior, rearming just one mag or, if we spent all bullets, it doesn't rearm at all (because I don't know how to code to fill all mags capacity). VR map: https://drive.google.com/file/d/1yDAiZ6hquSdTCFzFs7qb5ov2_9czitJp/view?usp=sharing This is the last error I got before releasing a cool script to the community. Thanks for your usual support.
  18. 🙂 // checking the mobile stations are in good conditions to work: // _eachGrdStation = _x; if ( (underwater _x) OR !((getPos _x) select 2 < 1) OR (speed _x > 0) ) exitWith // <<---- "!(isTouchingGround)" is not working reliable! { ["The station doesn't meet the conditions to work! Try later..."] remoteExec ["systemChat", _eachHumamPlayer]; }; What's happening above: if the ammo container ("a rearm station") is under the water.... or .... it is flying ..... or ..... it is moving, a message comes to the specific player. This worked pretty well in hosted server. Tonight I'll test on the dedicated server and later I come back with the results.
  19. Good to know. Below, it's my case (even in not dedicated server but focused on a dedicated server) and some other information from the forum mates:
  20. Hey, @pierremgi No. It's a container being transported by helicopter. @Larrow, probably I did something wrong because it didnt work adapted in my script. To make it easier, here is the issue in VR map: https://drive.google.com/file/d/1yDAiZ6hquSdTCFzFs7qb5ov2_9czitJp/view?usp=sharing When the ammo box/container is under the water (or almost completely under the water), it must be NOT available. When the ammo box/container is flying for any reason, it must be NOT available. the main file: fn_VO_coreGround.sqf
  21. Context: on Dedicated Server / not tested in hosted server Hello again, This is my first script with function structure and I'm facing a hard time learning the syntaxes and the logic needed to make this work properly when with more than one player in-game. My mistakes are potentially in fn_VO_globalFunctions.sqf file and how I am calling that in fn_VO_coreGround.sqf file. Btw, this mission is not using any init file. Bad behaviors: Only repairing is working for everyone. Refueling and rearming are not working at all. Nobody can't see the systemChat feedback messages. description.ext class cfgFunctions { // VEHICLE OVERHAULING: REPAIR, REARM, REFUEL #include "vehiclesOverhauling\THY_functions.hpp" }; THY_functions.hpp class THY_functions { tag = "THY"; class vehiclesOverhauling { file = "vehiclesOverhauling"; class VO_parameters { preInit = 1 }; class VO_globalFunctions { preInit = 1 }; class VO_coreGround { preInit = 1 }; //class VO_coreAir { preInit = 1 }; //class VO_coreNautic { preInit = 1 }; }; }; fn_VO_parameters.sqf // EDITOR'S OPTIONS: VO_debugMonitor = false; // true = turn on the editor hints / false = turn it off. VO_feedbackMsgs = true; // true = the station shows service messages in-game for the player (highly recommended) / false = turn it off. // GROUND SERVICES groundVehiclesOverhauling = true; // true = the station accepts ground vehicles / false = doesn't accept. VO_groundServRepair = true; // true = repairing for ground veh is available / false = not available / highly recommended turn it on if you want also to refueling. VO_groundServRefuel = true; // true = refueling for ground veh is available / false = not available. VO_groundServRearm = true; // true = rearming for ground veh is available / false = not available. VO_grdActRange = 10; // in meters, the area around the station that identifies the ground vehicle to be serviced. Default 10. VO_grdCooldown = 10; // in seconds, time among each available ground services. Default 10. VO_grdStationAssets = // which assets (classnames) will be automatically ground stations on mission. [ "Land_RepairDepot_01_green_F", "Land_RepairDepot_01_tan_F" ]; // AIR SERVICES airVehiclesOverhauling = true; // true = the station accepts air vehicles / false = doesn't accept. VO_airServRepair = true; // true = repairing for air veh is available / false = not available / highly recommended turn it on if you want also to refueling. VO_airServRefuel = true; // true = refueling for air veh is available / false = not available. VO_airServRearm = true; // true = rearming for air veh is available / false = not available. VO_airActRange = 20; // in meters, the area around the station that identifies the air vehicle to be serviced. Default 10. VO_airCooldown = 10; // in seconds, time among each available air services. Default 10. VO_airStationAssets = // which assets (classnames) will be automatically air stations on mission. [ "Land_HelipadRescue_F", "Land_HelipadSquare_F", "Land_HelipadCircle_F", "Land_HelipadCivil_F" ]; // NAUTIC SERVICES nauticVehiclesOverhauling = true; // true = the station accepts nautic vehicles / false = doesn't accept. VO_nauticServRepair = true; // true = repairing for nautic veh is available / false = not available / highly recommended turn it on if you want also to refueling. VO_nauticServRefuel = true; // true = refueling for nautic veh is available / false = not available. VO_nauticServRearm = true; // true = rearming for nautic veh is available / false = not available. VO_nauActRange = 25; // in meters, the area around the station that identifies the nautic vehicle to be serviced. Default 10. VO_nauCooldown = 10; // in seconds, time among each available nautic services. Default 10. VO_nauStationAssets = // which assets (classnames) will be automatically nautic stations on mission. [ "Land_TBox_F" ]; true fn_VO_globalFunctions.sqf THY_fnc_VO_humanPlayersAlive = { private ["_headlessClients"]; _headlessClients = entities "HeadlessClient_F"; VO_humanPlayersAlive = (allPlayers - _headlessClients) select {alive _x}; true }; THY_fnc_VO_debugMonitor = { //WIP true }; fn_VO_coreGround.sqf //if (!isServer) exitWith {}; private ["_arrayGroundStations","_groundVehicles","_serviceInProgress","_eachGroundStation",/*"_grdRepairNeeded","_grdRefuelNeeded","_grdRearmNeeded",*/"_eachHumamPlayer"]; [] spawn { // arrays that will be populated only with the objects classnames listed by VO_grdStationAssets. _arrayGroundStations = []; // initial services condition _serviceInProgress = false; // if ground services is allowed... finding out only the objects of classnames listed in VO_grdStationAssets through the allMissionsObjects. if ( groundVehiclesOverhauling == true ) then { { _arrayGroundStations = _arrayGroundStations + allMissionObjects _x } forEach VO_grdStationAssets }; // check whether or not run this while-looping / if some or all services are on, bota pra foder... while { groundVehiclesOverhauling == true } do { // check who's human here: call THY_fnc_VO_humanPlayersAlive; { // VO_humanPlayersAlive forEach starts... _eachHumamPlayer = _x; if ( VO_debugMonitor == true ) then { call THY_fnc_VO_debugMonitor }; // defining the ground veh of _eachHumamPlayer (_x) into XXm radius: _groundVehicles = _x nearEntities [["Car", "Motorcycle", "Tank", "WheeledAPC", "TrackedAPC"], 10]; { // forEach of _arrayGroundStations starts... _eachGroundStation = _x; { // forEach of _groundVehicles starts... if ( (_x distance _eachGroundStation) < VO_grdActRange ) then { sleep 3; // a breath before the any ground service. // GROUND REPAIR if (VO_groundServRepair == true) then { if ( (alive _x) AND (damage _x > 0.1) AND (isEngineOn _x == false) AND (speed _x < 2) AND (_serviceInProgress == false) ) then { _serviceInProgress = true; sleep 3; if (VO_feedbackMsgs == true) then { systemChat "Checking the damages..."; }; playSound3D ["a3\sounds_f\characters\cutscenes\dirt_acts_carfixingwheel.wss", _eachGroundStation]; sleep 3; playSound3D ["a3\sounds_f\sfx\ui\vehicles\vehicle_repair.wss", _x]; // if player inside the vehicle: if (!isNull objectParent _eachHumamPlayer) then { addCamShake [1, 5, 5]; // [power, duration, frequency]. }; _x setDammage 0; sleep 3; if (VO_feedbackMsgs == true) then { systemChat "Ground vehicle has been repaired!"; sleep 2; if ( ( (VO_groundServRefuel == true) OR (VO_groundServRearm == true) ) AND ( (fuel _x < 0.8) OR ( ({getNumber (configFile >> "CfgMagazines" >> _x select 0 >> "count") != _x select 1} count (magazinesAmmo _x)) > 0 ) ) ) then { systemChat "Preparing to the next service..."; }; }; sleep VO_grdCooldown; _serviceInProgress = false; // station is free for the next service! }; }; // GROUND REFUEL if (VO_groundServRefuel == true) then { if ( (alive _x) AND (fuel _x < 0.8) AND (isEngineOn _x == false) AND (speed _x < 2) AND (_serviceInProgress == false) ) then { _serviceInProgress = true; sleep 3; if (VO_feedbackMsgs == true) then { systemChat "Checking the fuel..."; }; playSound3D ["a3\sounds_f\characters\cutscenes\concrete_acts_walkingchecking.wss", _eachGroundStation]; sleep 3; playSound3D ["a3\sounds_f\sfx\ui\vehicles\vehicle_refuel.wss", _x]; if (!isNull objectParent _eachHumamPlayer) then { addCamShake [0.3, 5, 2]; }; _x setFuel 1; sleep 3; if (VO_feedbackMsgs == true) then { systemChat "Ground vehicle has been refueled!"; sleep 2; if ( ( (VO_groundServRepair == true) OR (VO_groundServRearm == true) ) AND ( (damage _x > 0.1) OR ( ({getNumber (configFile >> "CfgMagazines" >> _x select 0 >> "count") != _x select 1} count (magazinesAmmo _x)) > 0 ) ) ) then { systemChat "Preparing to the next service..."; }; }; sleep VO_grdCooldown; _serviceInProgress = false; }; }; // GROUND REARM if (VO_groundServRearm == true) then { if ( (alive _x) AND ( ({getNumber (configFile >> "CfgMagazines" >> _x select 0 >> "count") != _x select 1} count (magazinesAmmo _x)) > 0 ) AND (speed _x < 2) AND (_serviceInProgress == false) ) then { _serviceInProgress = true; sleep 3; if (VO_feedbackMsgs == true) then { systemChat "Checking the ammunition..."; }; playSound3D ["a3\sounds_f\characters\cutscenes\concrete_acts_walkingchecking.wss", _eachGroundStation]; sleep 3; playSound3D ["a3\sounds_f\sfx\ui\vehicles\vehicle_rearm.wss", _x]; if (!isNull objectParent _eachHumamPlayer) then { addCamShake [1, 5, 3]; }; _x setVehicleAmmo 1; sleep 3; if (VO_feedbackMsgs == true) then { systemChat "Ground vehicle has been rearmed!"; sleep 2; if ( ( (VO_groundServRepair == true) OR (VO_groundServRefuel == true) ) AND ( (damage _x > 0.1) OR (fuel _x < 0.8) ) ) then { if (isEngineOn _x == false) then { systemChat "Preparing to the next service..."; } else { systemChat "For the next service, turn off the engine!"; }; }; }; sleep VO_grdCooldown; _serviceInProgress = false; }; }; }; } forEach _groundVehicles; } forEach _arrayGroundStations; } forEach VO_humanPlayersAlive; sleep 5; }; }; // spawn ends. Editable mission download: https://github.com/aldolammel/arma-3-vehicles-overhauling
  22. Working fine, but the line below just work properly when we set it in init.sqf 😞 There's a way to use briefing and avoid the init.sqf without set the briefing as a function (via description.ext/CfgFunctions)? [] call compile preProcessFileLineNumbers "briefing.sqf";
  23. Gotcha: player is not for Dedicated Server so I am looking for a way to start a few functions files where the target is the multiplayer/coop through hosted and dedicated servers. Some ideas, but not what I'm looking for (already read!): And this older one (already read!): That said, just to start, this is a init.sqf template I've seen and used: // INIT.SQF HEADER (TARGET IS MISSONS IN HOSTED AND DEDICATED SERVERS / NEVER SINGLEPLAYER): if (!isDedicated) then { // checking player in hosted servers / and avoid JIP issues (?): waitUntil { !isNull player; }; // mission briefing available for all clients: [] call compile preProcessFileLineNumbers "briefing.sqf"; }; if (hasInterface) then { [] spawn { waitUntil { sleep 0.1; !isNull player; // <--------------------------------- It doesnt look right! It should watch for _x of allPlayers, right? }; }; }; // AND CUSTOM CODE HERE... About the code above, shouldn't that be like this one below? // NOT TESTED! if (!isDedicated) then { // checking player in hosted servers / and avoid JIP issues (?): waitUntil { !isNull player; }; // mission briefing available for all clients: [] call compile preProcessFileLineNumbers "briefing.sqf"; }; if (hasInterface) then { [] spawn { waitUntil { sleep 0.5; count allPlayers < 0; systemChat "You're a human player!"; }; }; }; // IF IT HAS PASSED BY ONE OF THOSE LOOPINGS ABOVE, CUSTOM CODE TO BE READED HERE... A model will impact positively in, at least, 18 multiplayer missions I've built in the last 3 years.
×