Jump to content

Larrow

Member
  • Content Count

    2646
  • Joined

  • Last visited

  • Medals

Community Reputation

1393 Excellent

About Larrow

  • Rank
    Warrant Officer

Profile Information

  • Gender
    Male
  • Location
    LAR setpos (you getpos [-2,getdir you]);LAR say3d["BOO!"]

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. And use the containerClosed EH instead of the while loop. _spawnedCrate = "Box_NATO_Wps_F" createVehicle _cratePosition; _crateContents = getItemCargo _spawnedCrate; clearWeaponCargoGlobal _spawnedCrate; clearMagazineCargo _spawnedCrate; _spawnedCrate addWeaponCargo [ _selectedWeapon, 1 ]; _spawnedCrate setVariable[ "rndWeapon", _selectedWeapon ]; _spawnedCrate addEventHandler [ "ContainerClosed", { params[ "_container" ]; _contents = magazineCargo _container + weaponCargo _container + itemCargo _container + backpackCargo _container; if ( _contents isEqualTo [] ) then { hint format[ "The weapon you got is %1", _container getVariable "rndWeapon" ]; }; }];
  2. Works fine for me? TEST_MISSION tested both SP, MP (hosted and dedicated)
  3. If you are just after the type of object then you should just store its type, rather than an object reference. Of which an object reference cannot be stringified and converted back. If you do actually want a reference to the specific synced object then you really should be getting the references at runtime in your modules init function. The only other way during Eden is to call BIS_fnc_objectVar on the object and update the entities name attribute and your attribute with the returned string. This is potentially a bad way to handle this as 1. A mission designer will not be able to name their synced vehicles 2. If they do it will break your module. (unless you monitor for this and update your attribute accordingly). Again if you need object references of synced objects then you should really do it at runtime (see BIS_fnc_moduleSector for instance on how it at runtime, via its module function, gets references to all the synced objects (locations, triggers, flags, etc) ).
  4. First sentence can be read as only the people present at the sector when captured? So I have provided two options... A player who is present at the sector when captured A player who belongs to the side that captured the sector, no matter their location //initServer.sqf //Sector Expression only happens on the server _h = [] spawn { //Wait unitl the mission has started so all sectors have been initialised waitUntil{ time > 0 }; //***** //For all players of capturing side //***** { [ _x, "ownerChanged", { params[ "_sector", "_owner", "_ownerOld" ]; //Sectors fire at mission start. //If no default owner is set then the expression will fire against sideUnknown //Otherwise the expression will fire against the default owner if !( _owner isEqualTo sideUnknown || _owner isEqualTo _ownerOld ) then { //Call client function to add points, on all clients that have a player of the capturing side [] remoteExec[ "TAG_fnc_addCapturePoints", _owner ]; }; }] call BIS_fnc_addScriptedEventHandler; } forEach ( true call BIS_fnc_moduleSector ); //***** //For all players of capturing side who are present at sector when captured //***** { [ _x, "ownerChanged", { params[ "_sector", "_owner", "_ownerOld" ]; //Sectors fire at mission start. //If no default owner is set then the expression will fire against sideUnknown //Otherwise the expression will fire against the default owner if !( _owner isEqualTo sideUnknown || _owner isEqualTo _ownerOld ) then { //Get sectors capture trigger areas _sectorAreas = _sector getVariable[ "areas", [] ]; //Find all players of _owner side that are in the sectors areas _playersInSector = allPlayers select { _x params[ "_player" ]; side _player isEqualTo _owner && { { _player inArea _x }count _sectorAreas > 0 } }; //If we have some players if !( _playersInSector isEqualTo [] ) then { //Call clients function to add points, on all clients of _playersInSector [] remoteExec[ "TAG_fnc_addCapturePoints", _playersInSector ]; }; }; }] call BIS_fnc_addScriptedEventHandler; } forEach ( true call BIS_fnc_moduleSector ); //***** //For all players or AI with player leader of capturing side who are present at sector when captured //***** { [ _x, "ownerChanged", { params[ "_sector", "_owner", "_ownerOld" ]; //Sectors fire at mission start. //If no default owner is set then the expression will fire against sideUnknown //Otherwise the expression will fire against the default owner if !( _owner isEqualTo sideUnknown || _owner isEqualTo _ownerOld ) then { //Get sectors capture trigger areas _sectorAreas = _sector getVariable[ "areas", [] ]; //Include players and AI lead by a player _capturedBy = allUnits select{ _x params[ "_unit" ]; ( isPlayer _unit || { isPlayer leader group _unit } ) && { side _unit isEqualTo _owner && { { _unit inArea _x }count _sectorAreas } } } apply{ [ leader group _x, _x ] select isPlayer _x }; //Make sure player is only listed once _capturedBy = _capturedBy arrayIntersect _capturedBy; //If we have some players if !( _capturedBy isEqualTo [] ) then { //Call clients function to add points, on all clients of _playersInSector [] remoteExec[ "TAG_fnc_addCapturePoints", _capturedBy ]; }; }; }] call BIS_fnc_addScriptedEventHandler; } forEach ( true call BIS_fnc_moduleSector ); }; //initPlayerLocal.sqf pointsPlayer = 0; TAG_fnc_addCapturePoints = { pointsPlayer = pointsPlayer + 1000; hint format ["You got 1000 points for capturing a cartel, you have %1 points", pointsPlayer]; }; UNTESTED
  5. //Specifically to backpack backpackContainer _unit addMagazineCargoGlobal [ "20Rnd_762x51_Mag", 20 ]; //Any where in units inventory _unit addMagazines [ "20Rnd_762x51_Mag", 20 ];
  6. Why do you want to sync a unit to a trigger? this has no effect as is (unless your specifically looking for the triggers synced objects). If your expecting the trigger to be only activated by the synced player, then syncing has no effect. You need to set the triggers attached vehicle and change its activation. THE_TRIGGER triggerAttachVehicle [ player ]; THE_TRIGGER setTriggerActivation [ "VEHICLE", "PRESENT", true ]; The above is the same effect as syncing the player to the trigger in the editor.
  7. There is really no need to save the "GUI Editor" string. Once you have your basic ui defined in the description.ext you can load your created dialog straight from its description.ext definition (you can also do this for any of the BI ui's) Open gui editor Press CTRL + I Enter dialogs config path (below as per @Mr H.'s example) missionConfigFile >> "MyDialog" Same for a BI dialog, for example the inventory configfile >> "RscDisplayInventory"
  8. You cannot setVariable inside the editor and have it preserve across preview/mission. Either... Retrieve your connections at runtime, instead of in the editor Or Create an attribute for your module and store types in there, where the attributes code populates setVariable at runtime. Which is a STRING representation of an array and also has the added benefit of allowing the user to add types without connection, much like you can supply vehicles for the SupportProvider_Virtual_Drop module in its "Vehicle Types" attribute.
  9. Larrow

    Local Variable in Global Space

    See alternative syntax 5 on the select commands wiki page.
  10. Open the configViewer and look under CfgVehicles for your building type. Then look at its AnimationSources and UserActions to get an idea of what animation sources are available and what functions the default user actions use. Open the functions viewer and look at the functions under Configfile, A3_Structures. Maybe Door OR LockedDoorOpen
  11. Larrow

    Trigger When Sector Captured

    Use the expression field in the properties of the sector module in the editor. Or from code [ SECTOR, "ownerChanged", { params[ "_sector", "_owner", "_ownerOld" ]; /*your code here*/ } ] call BIS_fnc_addScriptedEventHandler; Where SECTOR is a reference to the sector. This is the same thing the expression field does to the code you give it.
  12. No need to add anything to your triggers activation code, the script already does that. Recheck code, I noticed a mistake (function name in trigger statement) shortly after posting and updated code.
  13. You cannot save an object by its object reference and expect it to be the same on mission reload. Instead save them by their vehicleVarName. #define DEBUG true #define RESET false //Only on server, do not want multiple clients setting persistance( possibly different states ) if !( isServer ) exitWith {}; private _persTriggers = ["trigger_01","trigger_02"]; //Reset triggers if (RESET) then { profileNamespace setVariable ["actTriggers_var",nil]; saveProfileNamespace; }; //Get activated triggers TAG_actTriggers = profileNamespace getVariable ["actTriggers_var",[]]; TAG_fnc_updateActivatedTriggers = { params[ "_trig" ]; //Store the triggers vehicleVarName private _nul = TAG_actTriggers pushBackUnique vehicleVarName _trig; profileNamespace setVariable[ 'actTriggers_var', TAG_actTriggers ]; saveProfileNamespace; if ( DEBUG ) then { hint format[ "Persistent trig: %1 was activated and stored", vehicleVarName _trig ]; }; }; { //Get reference to trigger object from it vehicleVarName _trig = missionNamespace getVariable [ _x, objNull ]; //If we found an object AND it is a trigger if ( !isNull _trig && { typeOf _trig isKindOf "EmptyDetector" } ) then { //Get the triggers statements _statements = triggerStatements _trig; //If the trigger was previously activated if ( _x in TAG_actTriggers ) then { //Set its condition to true( causing it to activate ) or whatever you need to do _statements set[ 0, "true" ]; }else{ //Else, Add code to its onActivation to call TAG_fnc_updateActivatedTriggers _statements set[ 1, "[ thisTrigger ] call TAG_fnc_updateActivatedTriggers;" + ( _statements select 1 ) ]; }; //Update triggers statements //Remember this is only effecting the servers trigger statement, command is AG EL //If this needs to be done globally then you will need to either... //1. RemoteExec this command, with JIP //2. ( If statement has a lot of code ) // Think about remoteExec'ing a function to change a specific part of the statement, with JIP _trig setTriggerStatements _statements; }; }forEach _persTriggers; if (DEBUG) then { hint format ["Persistent triggers:\n%1\n\nActivated triggers:\n%2",_persTriggers,TAG_actTriggers]; };
  14. When TAG_fnc_getHCUnitCount remoteExec's TAG_fnc_count on the HC, !isServer will be true. In which case it counts its local units and calls on the server the same function( TAG_fnc_count ). TAG_fnc_count !isServer will then be false, so the else part will be executed. Where the HC_Clients index that is currently the HC client ID is updated to be an array of [ ownerID, units count ]. It then checks if all indexes of HC_Clients are an array( has received a count back from all HC;s ) and if so formats a message which is sent to the original count requestor( HCCountRequestor ). Now this was meant as more of a example on how to remoteExec and pass around information, as you where trying to get a value back from remoteExecCall. There should be no need to ask the HC how many units are local as the server is quite capable of doing this. TAG_fnc_getHCUnitCount = { //If this function was called remotely then set requestor as RE-Owner //Otherwise set to all player clients _HCCountRequestor = [ allPlayers - entities "HeadlessClient_F", remoteExecutedOwner ] select isRemoteExecuted; //Get a array of all HC client owner IDs [ owner ID , array of units ] _HC_Clients = entities "HeadlessClient_F" apply{ [ _x, [] ] }; //For all non player units { _x params[ "_unit" ]; //For each HC { //If the owner of the unit is the same as the owner of the HC if ( owner _unit isEqualTo owner( _x select 0 ) ) exitWith { //Push unit into HC units array private _nul = ( _x select 1 ) pushBack _unit; }; }forEach _HC_Clients; }forEach ( allUnits - allPlayers ); //Format a message _message = ""; { _x params[ "_HC", "_units" ]; _message = format[ "%1\nHC id-%2: %3, NumUnits: %4", _message, owner _HC, vehicleVarName _HC, count _units ]; get }forEach _HC_Clients; //Remote exec hint to requestor _message remoteExec[ "hintSilent", _HCCountRequestor ]; }; //On server, will hint count to all players [] call TAG_fnc_getHCUnitCount; //From client, will hint back to this client [] remoteExec[ "TAG_fnc_getHCUnitCount", 2 ]; TEST_MISSION - mission includes one player slot and two headless clients. The server will ask the HC's to spawn groups of five units up until there is a total count of fifty units. The player has an addAction that will call the function( as above ) on the server, where it will count the units belonging to each HC and hint back to the player the unit counts for each HC.
  15. Unless this is a ui element inside a controlsGroup then you are not using the whole screen. The screen goes from safezoneX to safezoneX + safezoneW in the horizontal and safezoneY to safezoneY + safezoneH in the vertical 0 is not the left hand side OR the top(unless your UI size is VLarge) of the screen. Left and Top (safezoneX and safezoneY respectively) are both negative numbers. That is not positioning anything. That is the size of the element w/h, being 30% of the screens width and 47.8% of the screens height. x = safeZoneX + ( safeZoneW * yourValueX ); y = safeZoneY + ( safeZoneH * yourValueY ); Where yourValueX/Y is 0-1 (percentage of screen / 100). This will place the top left of the image at this position. If you wish to place the centre of the image at the position then you need to minus half the picture width/height from the x/y of the position. #define PIC_WIDTH 512 * pixelW //Picture width in pixels #define PIC_HEIGHT 512 * pixelH //Picture height in pixels x = safeZoneX + ( safeZoneW * yourValueX ) - ( PIC_WIDTH / 2 ); y = safeZoneY + ( safeZoneH * yourValueY ) - ( PIC_HEIGHT / 2 ); w = PIC_WIDTH; h = PIC_HEIGHT; The above will cause the image to be different sizes visually dependant on the users resolution. Although always 512 x 512 pixels, if the users resolution is say 1920 x 1080 then the image will be roughly 1/4 of the width and 1/2 the height of the screen. If the users resolution is 1280 x 720 then the image will be roughly 2/5th's the width and 2/3rd's the height of the screen. #define PIC_WIDTH 10 * pixelW * pixelGridNoUIScale //Picture width in grids #define PIC_HEIGHT 10 * pixelH * pixelGridNoUIScale //Picture height in grids x = safeZoneX + ( safeZoneW * yourValueX ) - ( PIC_WIDTH / 2 ); y = safeZoneY + ( safeZoneH * yourValueY ) - ( PIC_HEIGHT / 2 ); w = PIC_WIDTH; h = PIC_HEIGHT; The above will keep the picture size roughly the same size visually on all machines no matter the resolution or ui size. A grid (1 * pixelH * pixelGridNoUIScale) is roughly your vertical screen space divided by 60. The width is then divided by a vertical grids screen size so as to make a grid space square. So the image will always be 10/60th's of the screen height and the same dimensions in width. TEST_MISSION use actions on player
×