Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×

serena

Member
  • Content Count

    335
  • Joined

  • Last visited

  • Medals

Everything posted by serena

  1. warbirdguy1, look: // how-to add number of magazines to player vest: vestContainer player addMagazineCargo ["HandGrenade", 100]; // how-to load magazine directly to player primary weapon: player addPrimaryWeaponItem "30Rnd_65x39_caseless_mag"; // replace with your weapon compatible magazine type
  2. serena

    basic script help

    // in init.sqf file inside mission directory // this script auto-executed by game when mission starts SquadControl = { // _this variable here references whole group, not leader unit { _x setunitpos "UP"; //_x disableAI "FSM"; // if you uncomment this line then units wont move _x disableAI "Cover"; _x disableAi "SUPPRESION"; } forEach units _this; // you can set speedmode and behavior once and for group, not individual unit _this setSpeedMode "FUll"; _this setBehaviour "CARELESS"; // check (alive leader _this) - bad idea, because, if leader die, another unit take command while {{alive _x} count units _this > 0} do // check if any alive unit in group { // do something sleep 1; }; // all units die, exit from script }; waitUntil {time > 0}; // wait until mission realy starts //grp variable defined in group leader init field as "grp = group this" grp call SquadControl; // launch squad control function. Sample mission: link
  3. You can define functions in script files: // myfile.sqf FunctionABC = { systemChat "Hello from function ABC"; // put other commands here }; FunctionDEF = { systemChat "Hello from function DEF"; // put other commands here }; Before use functions script must be compiled: // at this point our functions is not initialized call compile preprocessFileLineNumbers "myfile.sqf"; // at this point our functions initialized if script file contains no erros Special file init.sqf - this file auto-compiled and executed by game immediately after mission starts: // init.sqf // it is very useful to compile all code from init.sqf call compile preprocessFileLineNumbers "myfile.sqf"; call compile preprocessFileLineNumbers "myanotherfile.sqf"; call compile preprocessFileLineNumbers "myfunctions.sqf"; call compile preprocessFileLineNumbers "somethingelse.sqf"; // at this point all scrpts compiled and we can call functions defined in scripts Usage: // when functions defined we can call it from anywhere until missions ends: call FunctionABC; // Result: "Hello from function ABC"; call FunctionDEF; // Result: "Hello from function DEF"; Passing arguments to functions: X = { systemChat str _this; // _this variable always references argument(s) passed to function }; "Hello" call X; // Result (in chat): Hello [1, "black", false] call X; // Result (in chat): [1, "black", false] Accessing individual arguments: ABC = { params ["_a", "_b", "_xyz"]; // here we can operate with _a, _b, _xyz variables }; [1, "white", true] call ABC; // in this call inside ABC variable _a = 1, _b = "white", _xyz = true Functions can return results: ByeFunc = {"Bye"}; // function always return same string private _result = call ByeFunc; // Result: _result = "Bye"; SummFunc = { // function return summ of two arguments params ["_a", "_b"]; _a + _b; }; private _summ = [10, 5] call SummFunc; // Result: _summ = 15;
  4. serena

    basic script help

    scottdog62, this variable exists and points to the object only in object initialization field. In all other cases it has no value and meaning. Clear? // object initialization field this execVM "script.sqf" // OK, this variable references object // not in object initialization field this execVM "script.sqf" // ERROR, this variable references NOTHING terrorist execVM "killeveryone.sqf" // OK, terrorist variable references concrete unit policesquad execVM "eliminateterrorist.sqf" // OK, policesquad variable references concrete group
  5. serena

    How to remove arsenal action

    Description says: Returns: ARRAY of ARRAYs - all virtual items within the object's space in format [<items>,<weapons>,<magazines>,<backpacks>] [player, ["B_AssaultPack_mcamo_Ammo"], false, true] call BIS_fnc_addVirtualBackpackCargo; //Result: ["B_AssaultPack_mcamo_Ammo"] //Expected: [[], [], [], ["B_AssaultPack_mcamo_Ammo"]] Something went wrong?
  6. serena

    How to remove arsenal action

    This function deletes action as well [player, "B_AssaultPack_mcamo_Ammo", false, true] call BIS_fnc_addVirtualBackpackCargo; [player, "B_AssaultPack_mcamo_Ammo", false] call BIS_fnc_removeVirtualBackpackCargo;
  7. You do not necessarily have to take out the spaces, you can go the other way: // init.sqf RemoveActionByName = { params ["_object", "_name"]; {if (_object actionParams _x select 0 == _name) exitWith {_object removeAction _x}} forEach actionIDs _object; }; // greeting.sqf Guard1 addAction ["What do you do here", "Dialog\Guard1\JobDisc.sqf","((_target distance _this) <2"]; // JobDisc.sqf [Guard1, "What do you do here"] call RemoveActionByName; hint "I guard the entrance to Camp Bravo"; Guard1 addaction ["Anything happen lately?", "Dialog\Guard1\EnemyLoitering.sqf"];
  8. serena

    How to remove arsenal action

    In that case, your question might sound like this: how do I remove Arsenal action added by BIS_fnc_addVirtualBackpackCargo function. It is important, because the right question contains half the answer. RemoveArsenalActionFromGivenObject = { {if (_this actionParams _x select 0 == "Arsenal") exitWith {_this removeAction _x}} forEach actionIDs _this; }; // Test: [player, "B_AssaultPack_mcamo_Ammo", false, true] call BIS_fnc_addVirtualBackpackCargo; player call RemoveArsenalActionFromGivenObject;
  9. serena

    How to remove arsenal action

    Apparently now is the right time to ask how you open your arsenal? Or maybe we should guess it?
  10. WhatDoYouDoHere = Guard1 addAction ["What do you do here", "Dialog\Guard1\JobDisc.sqf","((_target distance _this) <2"]; Guard1 removeaction WhatDoYouDoHere; AnythingHappenLately = Guard1 addaction ["Anything happen lately?", "Dialog\Guard1\EnemyLoitering.sqf"]; Guard1 removeaction AnythingHappenLately;
  11. Try to enable console in description.ext (enableDebugConsole = 2) and manipulate/trace game state during mission progress.
  12. Just tested - AI shooting OK, as expected. Next time share your mission as not binarized/pboed archive please.
  13. notebook addAction ["Reveal Secret Location", { private _mrk = createMarker ["marker_name", [10000, 10000]]; _mrk setMarkerType "mil_box"; _mrk setMarkerColor "colorBLUFOR"; _mrk setMarkerText "WP1"; }];
  14. private _mrk = createMarker ["marker_name", getPos player]; _mrk setMarkerType "mil_box"; _mrk setMarkerColor "colorBLUFOR"; _mrk setMarkerText "WP1";
  15. player addAction ["Call Script", { private _caller = _this select 1; typeOf _caller call ExecuteScriptBasedOnUnitType}];
  16. Download and start demo mission In game control settings define key for command UseAction1 During mission, switch between switchable units and press key binded to UseAction1 - for each unit class will be executed corresponding script defined in ScriptsDictionary array
  17. celludriel, do you know about: uniformContainer player addmagazineCargo ["HandGrenade", 2000]
  18. Sounds like: I'm too lazy to walk on my own feet, so I choose to crutches and a wheelchair. Sorry XD
  19. // init.sqf waitUntil {time > 0}; ScriptsDictionary = [ ["O_Soldier_SL_F", "scripts\VA\squadLeaderArs.sqf"], ["O_Soldier_F", "scripts\VA\soldierArs.sqf"], ["O_Soldier_LAT_F", "scripts\VA\soldierLATArs.sqf"]]; ExecuteScriptBasedOnUnitType = { {if (_x select 0 == _this) exitWith {_x select 1}} forEach ScriptsDictionary call {execVM _this}; }; PollUserAction = { while {true} do { waitUntil {inputAction _this > 0}; typeOf player call ExecuteScriptBasedOnUnitType; waitUntil {inputAction _this == 0}; } }; "User1" call PollUserAction; Demo mission: link (define key for UserAction1, switch between units and press this key to activate corresponding scripts)
  20. Yes and yes. Result also can be ["", etc... ] when unit outside of any marker area.
  21. . Simple variant: // in init.sqf waitUntil {time > 0}; MarkerArea = { switch (markerShape _this) do { case "RECTANGLE": {getMarkerSize _this params ["_msw", "_msh"]; _msw * _msh}; case "ELLIPSE": {getMarkerSize _this params ["_msw", "_msh"]; _msw * _msh * 0.25 * pi}; default {0} } }; allMapMarkersOrderedByArea = [allMapMarkers,[],{_x call MarkerArea},"ASCEND"] call BIS_fnc_sortBy; // Somewhere in scripts (replace player with actual unit) private _marker = {if (player inArea _x) exitWith {_x}; ""} forEach allMapMarkersOrderedByArea; Wrapped variant: // add this to init.sqf SmallestMarkerUnitIsIn = { {if (_this inArea _x) exitWith {_x}; ""} forEach allMapMarkersOrderedByArea}; // Somewhere in scripts (replace player with actual unit) private _marker = player call SmallestMarkerUnitIsIn; * if unit is not in any marker area, an empty string is returned
  22. Anyway, we need for topic starter to clarify :)
×