Jump to content

daniel-davies

Member
  • Content Count

    31
  • Joined

  • Last visited

  • Medals

Everything posted by daniel-davies

  1. daniel-davies

    MapSingleClick problem

    I ended up figuring it out, but coming back to this topic and seeing Larrow once again being a godsend is so nice. Thank you so much Larrow! Some of these scripting commands I didn't even realize existed actually haha
  2. Hi guys! I want to create a script where the player clicks on a marker on the map (taken from the array "availableBuildings") in order to confirm their "base location". They have to click the same marker location twice in order to confirm. This is what I got so far: /////////////////////////////////////// // Click on map to choose base location /////////////////////////////////////// _blds = nearestObjects [[worldSize / 2, worldSize / 2, 0], ["Land_i_Shed_Ind_F"], 15000]; missionNamespace setVariable ["availableBuildings", _blds, true]; _markerArray = []; playSound "BIS_WL_Sector_WEST"; { _markerName = format ["marker_%1", _forEachIndex]; _markerstr = createMarker [_markerName, position _x]; _markerstr setMarkerShape "ICON"; _markerstr setMarkerText ""; _markerstr setMarkerType "loc_Tourism"; _markerstr setMarkerSize [0.85, 0.85]; _markerstr setMarkerColor "ColorOrange"; _markerArray pushBack _markerName; } forEach (missionNamespace getVariable "availableBuildings"); markerstr = createMarker ["marker_confirmation", [0,0,0]]; _handleMarker = ["marker_confirmation", 0, 1] spawn BIS_fnc_blinkMarker; markerstr setMarkerShape "ICON"; markerstr setMarkerText " Selected Starting Zone - close map to confirm"; markerstr setMarkerType "Select"; markerstr setMarkerSize [1.8, 1.8]; markerstr setMarkerColor "ColorBlue"; markerstr setMarkerAlpha 0; addMissionEventHandler ["MapSingleClick", { params ["_units", "_pos", "_alt", "_shift"]; _nearestMarker = [allMapMarkers, _pos] call BIS_fnc_nearestPosition; markerstr setMarkerPos (getMarkerPos _nearestMarker); markerstr setMarkerAlpha 1; if (isNil _nearestMarker) then { if (getMarkerPos _nearestMarker distance _pos >= 300) then { playSound "BIS_WL_Selected_WEST"; markerstr setMarkerColor "ColorGreen"; { deleteMarker _x } forEach (missionNamespace getVariable "availableBuildings"); }; }; }]; Obviously this isn't completely functional yet. I need help to make it fully functional. Can anyone please help? Thanks for your time!
  3. daniel-davies

    MapSingleClick problem

    Right, my bad. I was indeed. Could either of you, or anyone else, help me figure out how to allow for a two-click verification of the choice that the player selects?
  4. daniel-davies

    MapSingleClick problem

    I was using it in other scripts in my mission (this code is currently run in initServer.sqf)
  5. daniel-davies

    Utilization of the marker/map briefing

    Hey M. Glade, I was also as interested as you in the new animation map/briefings added in the Tac-Ops DLC. I sifted through the Functions in the Functions Viewer and found the functions that are used by the briefings: Filter your Functions Viewer by A3_TacOps and check the Map and System tabs out! There's some pretty damn cool functions added :) If you need help with the application of some of the functions, let me know!
  6. Hi, I know there's been topics created about this issue in the past but I'm having issues even after looking at previous solutions. I'm creating three warehouses in my function. The loop loops 3 times and each time it creates two triggers: private _threeWarehouses = []; private _warehouseList = ["marker_warehousesite1","marker_warehousesite2","marker_warehousesite3","marker_warehousesite4","marker_warehousesite5","marker_warehousesite6","marker_warehousesite7","marker_warehousesite8","marker_warehousesite9","marker_warehousesite10","marker_warehousesite11"]; for "_i" from 1 to 3 do { private _trg = _warehouseList call BIS_fnc_selectRandom; _warehouseList = _warehouseList - [_trg]; _threeWarehouses pushBack _trg; _trg setMarkerType "mil_unknown"; _msg = format ["Warehouse location %1", _i]; _trg setMarkerText _msg; _trg setMarkerColor "ColorRED"; _msg2 = format ["markerWarehouseZone%1", _i]; _zoneMarker = createMarker [_msg2, getMarkerPos _trg]; _zoneMarker setMarkerShape "ELLIPSE"; _zoneMarker setMarkerSize [125,125]; _zoneMarker setMarkerColor "ColorOPFOR"; _zoneMarker setMarkerBrush "FDiagonal"; [getMarkerPos(_trg), (ceil (random 2)), 150] call DAN_fnc_spawnRandomInfantry; _buildings = nearestObjects [getMarkerPos _trg, ["Land_i_shed_ind_F"], 100]; //object array _enemies = nearestObjects [getMarkerPos _trg, ["Man"], 150]; _nul = [getMarkerPos _trg,_enemies, 150] execVM "scripts\shk_buildingpos.sqf"; {[_x] joinSilent grpNull; doStop _x; _x setDir random 360; if ((random 1) > 0.5) then { _x setUnitPos "UP"; } else { _x setUnitPos "MIDDLE"; }; } forEach _enemies; [getMarkerPos(_trg), (ceil (random 2)), 60] call DAN_fnc_spawnRandomInfantry; _loopRandom = 1 + (ceil (random 4)); private _flagPos = [(getMarkerPos _trg), 2, 6, 3, 0, 20, 0] call BIS_fnc_findSafePos; _flag = "Flag_AAF_F" createVehicle _flagPos; for "_j" from 1 to _loopRandom do { private _safeLoc = [(getMarkerPos _trg), 4, 60, 3, 0, 20, 0] call BIS_fnc_findSafePos; private _veh = ["I_MRAP_03_F","I_Truck_02_Transport_F","I_Truck_02_Covered_F"] call BIS_fnc_selectRandom; _ambientVehicle = _veh createVehicle _safeLoc; _ambientVehicle setVehicleLock "LOCKED"; _ambientVehicle setDir (random 360); _nearRoads = _safeLoc nearRoads 10; if(count _nearRoads > 0) then { _road = _nearRoads select 0; _roadConnectedTo = roadsConnectedTo _road; _connectedRoad = _roadConnectedTo select 0; _direction = [_road, _connectedRoad] call BIS_fnc_DirTo; }; clearBackpackCargoGlobal _ambientVehicle; clearItemCargoGlobal _ambientVehicle; clearWeaponCargoGlobal _ambientVehicle; clearMagazineCargoGlobal _ambientVehicle; }; _newtrg = createTrigger ["EmptyDetector", getMarkerPos _trg]; _newtrg setTriggerArea [125, 125, 0, false]; _newtrg setTriggerActivation ["WEST", "PRESENT", true]; _newtrg setTriggerStatements ["this", "{if ((side _x) == INDEPENDENT) then { if ((leader (group _x))==_x) then { [group _x, getPos _x, 250] call bis_fnc_taskPatrol; }; }; } forEach thisList;", ""]; _newtrg2 = createTrigger ["EmptyDetector", getMarkerPos _trg]; _newtrg2 setTriggerArea [125, 125, 0, false]; _newtrg2 setTriggerActivation ["GUER", "NOT PRESENT", true]; _newtrg2 setTriggerStatements ["this",(format ["%1 setMarkerColor ""ColorRed""; %2 setMarkerColor ""ColorRed"";",_trg,_zoneMarker]),""]; }; This doesn't work - the marker is correct (I used a hint to check) but nothing happens (the colour is not changed). Could anyone help?
  7. Hi guys, I'm creating a function ran by the server for my multiplayer mission which will update a variable with an array containing details about the highest ranked player currently alive and in the mission. The object 'COMMAND_officer' is the highest possible ranking officer (he is the Platoon commander and the rank of Captain). However if the commander dies, I need to check each playable unit to see if it is the highest ranking officer left alive on the field. This is what I've wrote so far. I'm not sure if it is the best way of doing things however. 'TOUR_core' is the name of a game logic ingame. fn_getHighestRankingOfficer.sqf: if (!isNil { COMMAND_officer } ) then { exitWith { TOUR_CORE setVariable ["DAN_var_highestRankingOfficer",[COMMAND_officer, rank COMMAND_officer, name COMMAND_officer],true]; }; }; //ALIVE LIEUTENANTS { if (_foundhighestOfficer == false) then { _rank = (rank _x); _myProfileName = name _x; _foundHighestOfficer = false; if ((rank _x) == "LIEUTENANT") exitWith { _foundHighestOfficer = true; _unitsName = (vehicle _x)}; }; } forEach (playableUnits+switchableUnits); if (_foundHighestOfficer == true) then { TOUR_CORE setVariable ["DAN_var_highestRankingOfficer",[_unitsName, _rank, _myProfileName],true]; _bypassOtherRankChecks = true; }; //////////////////////////////////////////////////////////////// //ALIVE SERGEANTS? //////////////////////////////////////////////////////////////// if (_bypassOtherRankChecks == false) then { { if (_foundhighestOfficer == false) then { _rank = (rank _x); _myProfileName = name _x; _foundHighestOfficer = false; if ((rank _x) == "SERGEANT") exitWith { _foundHighestOfficer = true; _unitsName = (vehicle _x)}; }; } forEach (playableUnits+switchableUnits); if (_foundHighestOfficer == true) then { TOUR_CORE setVariable ["DAN_var_highestRankingOfficer",[_unitsName, _rank, _myProfileName],true]; _bypassOtherRankChecks = true; }; }; //////////////////////////////////////////////////////////////// //ALIVE CORPORALS? //////////////////////////////////////////////////////////////// if (_bypassOtherRankChecks == false) then { { if (_foundhighestOfficer == false) then { _rank = (rank _x); _myProfileName = name _x; _foundHighestOfficer = false; if ((rank _x) == "CORPORAL") exitWith { _foundHighestOfficer = true; _unitsName = (vehicle _x)}; }; } forEach (playableUnits+switchableUnits); if (_foundHighestOfficer == true) then { TOUR_CORE setVariable ["DAN_var_highestRankingOfficer",[_unitsName, _rank, _myProfileName],true]; _bypassOtherRankChecks = true; }; }; //////////////////////////////////////////////////////////////// //ALIVE PRIVATES????? //////////////////////////////////////////////////////////////// if (_bypassOtherRankChecks == false) then { { if (_foundhighestOfficer == false) then { _rank = (rank _x); _myProfileName = name _x; _foundHighestOfficer = false; if ((rank _x) == "PRIVATE") exitWith { _foundHighestOfficer = true; _unitsName = (vehicle _x)}; }; } forEach (playableUnits+switchableUnits); if (_foundHighestOfficer == true) then { TOUR_CORE setVariable ["DAN_var_highestRankingOfficer",[_unitsName, _rank, _myProfileName],true]; _bypassOtherRankChecks = true; }; }; Could this be made better in any way? Thanks
  8. Hi guys, I'm back again! I have another problem - essentially, my mission is for thirty players, and uses two Huron helicopters (each with 20 passenger seats) to transport players from the base to the AO, piloted by AI. I'd like to check whether there are no passengers within the second Huron, so I don't have to make it take off and fly the insertion route when it doesn't need to (kinda looks a bit stupid for the players). I'm not sure how I'd go about doing so however, I know I have to use crew and I'm assuming I get the fourth element from the array [driver,gunner,commander,turrets,cargo]? But I'm not sure about writing a condition to check against an empty array. Any help would be appreciated.
  9. Amazing guys, thank you all so much! Issue is resolved :)
  10. That's far better than the code I wrote! Haha I didn't even realise there was such a thing as rankId! Thank you very much! EDIT: How would I get the _candidate variable to return from the function?
  11. Hello all, I'm trying to create an action for an MP mission that simulates the lighting of a fuel can (which will then light oil on fire, leading to some explosives). The script will still run, but I receive an error. I'm really struggling to fix it, any help will be greatly appreciated. From my RPT file: 20:54:57 Error in expression <) do { case (Fuel_Can_04) : { {[(_this select 1)] execVM "Mission\Fuel_Can_Ligh> 20:54:57 Error position: <select 1)] execVM "Mission\Fuel_Can_Ligh> 20:54:57 Error Zero divisor initPlayerLocal: if (!isNil { Explosives_B }) then { Fuel_Can_04 addAction ["Light fuel can", "mission\runFuelCanScript.sqf", nil,8,true,true,"","((_this distance _target) < 1.5)"]; }; runFuelCanScript: (_this select 1) playMove "AinvPercMstpSrasWrflDnon_Putdown_AmovPercMstpSrasWrflDnon"; switch ((_this select 0)) do { case (Fuel_Can_04) : { [(_this select 1)] execVM "Mission\Fuel_Can_Light_A.sqf" remoteExec ["bis_fnc_call", 2]; }; case (Fuel_Can_06) : { [(_this select 1)] execVM "Mission\Fuel_Can_Light_B.sqf" remoteExec ["bis_fnc_call", 2]; }; case (Fuel_Can_05) : { [(_this select 1)] execVM "Mission\Fuel_Can_Light_C.sqf" remoteExec ["bis_fnc_call", 2]; }; case (Fuel_Can_01) : { [(_this select 1)] execVM "Mission\Fuel_Can_Light_D.sqf" remoteExec ["bis_fnc_call", 2]; }; case (Fuel_Can_02) : { [(_this select 1)] execVM "Mission\Fuel_Can_Light_E.sqf" remoteExec ["bis_fnc_call", 2]; }; }; Thanks in advance. From my RPT file: {[(_this select 1)] execVM "Mission\Fuel_Can_Ligh> 20:54:57 Error position: <select 1)] execVM "Mission\Fuel_Can_Ligh> 20:54:57 Error Zero divisor
  12. daniel-davies

    Zero divisor error in addAction

    That worked! Thank you Fiddi! :)
  13. daniel-davies

    Creating custom marker on map for a town?

    This is exactly what I was looking for, thank you sir!
  14. Hello, I'd like to make a marker on the map that has the Purista font which is used in the towns on the map, along with the correct colour and lack of icon next to the marker. However, I don't know how to go about doing this. This is what I'd like the marker to look like on the map: I know it's possible, as it is working in Sa-Matra's Wasteland. However, I don't know how to do it myself, so if anyone could help that'd be fantastic! Thank you in advance.
  15. Ah ha, got it Larrow! Thank you very much, fixed it now :)
  16. Hello. Bit of a newbie coder here - I'm trying to script a money system for my multiplayer mission whereby the amount of money is SHARED between all players. This means that they have a shared money pool and a transaction would affect all online players. I've got the script working - sort of - in that it will display the correct amount of money to the server host, ie. locally, but I can't seem to make it so that it works completely for all players. JIP players also seem to reset the amount of money the players have accumulated to 0 (the starting value) so if someone could explain to me how to go about fixing my issues that would be extremely appreciated. Also, I'm really sorry if the scripts below make you want to slam your face into the table - like I said previously, I'm new to SQF scripting. Here are my scripts: init.sqf money = "InitialMoney" call BIS_fnc_getParamValue; publicVariable "money"; DAN_fnc_initupdateMoney = { ((_this select 0) displayCtrl 1102) ctrlSetText format ["%1", money] }; DAN_fnc_setMoney = { _amount = _this select 0; money = _amount; publicVariable "money"; ((uiNamespace getVariable "dan_Hud") displayCtrl 1102) ctrlSetText format ["%1", money]; }; DAN_fnc_updateMoney = { publicVariable "money"; ((uiNamespace getVariable "dan_Hud") displayCtrl 1102) ctrlSetText format ["%1", money]; }; DAN_fnc_say2D = { _source = (_this select 0); _sound = (_this select 1); _source say2D _sound; }; DAN_fnc_addMoney = { _amount = _this select 0; if (_amount == nil) then { _amount = 0 }; money = money + _amount; publicVariable "money"; ((uiNamespace getVariable "dan_Hud") displayCtrl 1102) ctrlSetText format ["%1", money]; //[[player,"cashAdd"],"DAN_fnc_say2D",true] call BIS_fnc_MP; }; DAN_fnc_removeMoney = { _amount = _this select 0; if (_amount == nil) then { _amount = 0 }; money = money - _amount; publicVariable "money"; ((uiNamespace getVariable "dan_Hud") displayCtrl 1102) ctrlSetText format ["%1", money]; [[player,"cashAdd"],"DAN_fnc_say2D",true] call BIS_fnc_MP; }; null = [] spawn { while {true} do { [[[],"Scripts\callResource.sqf"],"BIS_fnc_execVM",true,true] call BIS_fnc_MP; [[],"DAN_fnc_updateMoney",true,true] call BIS_fnc_MP; sleep 30; }; }; initPlayerLocal.sqf: /* @filename: initPlayerLocal.sqf Author: Daniel G. Davies Last modified: 29/05/2015 ArmA 1.32 by DGD Description: Client scripts and event handlers. ______________________________________________________*/ //------------------- client executions [[[],"Scripts\callResource.sqf"],"BIS_fnc_execVM",true,true] call BIS_fnc_MP; [[],"DAN_fnc_updateMoney",true,true] call BIS_fnc_MP; callResource.sqf (this is called in the initPlayerLocal.sqf file): /* @filename: callResource.sqf Author: Daniel G. Davies Last modified: 29/05/2015 ArmA 1.32 by DGD Description: Setup / Initialization for the HUD. ______________________________________________________*/ disableSerialization; 1 cutRsc["dan_Hud", "PLAIN"]; _funds = money; waitUntil {!isNull (uiNameSpace getVariable "dan_Hud")}; _display = uiNameSpace getVariable "dan_Hud"; _setText = _display displayCtrl 1102; _setText ctrlSetText (parseText format ["%1",_funds]); Thanks in advance for any help, it's really appreciated :)
  17. Okay, so your method of displaying the hud via BIS_fnc_RSClayer caused some problems... it meant that when I added money, the initial value of 0 stayed on the screen, and a 100 for example was added on top of it causing them to overlap. I tried replacing it with the previous way of displaying the hud and am now testing it.
  18. Thank you too, Das Attorney! :)
  19. Thank you so much for your time taken to rewrite my scripts! I'll test them tomorrow hopefully with better results (I need to get things working by then as I am using it in a group mission :p ) Also thanks to everyone else for their input, really appreciate everything, I am learning a lot from what you guys have posted - I've virtually never worked with MP scripting before :)
  20. Is anyone able to help? :(
  21. Actually - I lied... when I go run a server with my money-related script running on the mission, it causes everyone on the server to get 100000 desync (tested with 11 players on two different servers)... I don't know why but it's really affecting perfomance, perhaps it's to do with this loop in init.sqf? null = [] spawn { while {true} do { //[[[],"Scripts\callResource.sqf"],"BIS_fnc_execVM",true,true] call BIS_fnc_MP; [[],"DAN_fnc_updateMoney",true,true] call BIS_fnc_MP; sleep 10; }; }; Could someone help?
  22. Thanks a ton! It's now fully working - thank you both for your help!
  23. Sweet, I'll test this out later, thank you so much Austin!
  24. Right I think I see what you mean! So if I wanted to display the current value of the money variable which is defined in the initserver sqf to all clients, then could you please explain how I can achieve this? Right now all I can see I need to change is adding that JIP check and making sure when I change the value of 'money' through my DAN_fnc_addMoney function then it is updated to all clients, which at the moment is not the case.
  25. When I previously defined the money variable in initServer, when I joined as a player the variable showed as <any> on screen. Am I using public variables in the correct way in the above scripts? I feel like I am calling the HUD to be reset way too many times, and I'm using an infinite loop as well - I feel the code could be a lot better but I don't know how to refine it..
×