Jump to content


  • Content Count

  • Joined

  • Last visited

  • Medals

Community Reputation

7 Neutral

About dupa1

  • Rank
    Private First Class

Recent Profile Visitors

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

  1. _object = _this select 0;
  2. So, I finally managed to get it working.... The end result is pretty simple actually.. well almost end result. There is one slight issue. When map lock is enabled, if you spam M, the map moves a bit down every time it's closed and opened. It's probably related to ctrlMapScreenToWorld[0.5, 0.5]. I think the map in ArmA 3 is not full screen, and the value of 0.5 needs to be adjusted. I think I'll figure it out, just wanted to say I got it working. EDIT: Value of 0.53 for vertical offset seems to work for me. Code below updated. mapLock = false; mapPos = [1,1,1]; mapScale = 0.1; waituntil {!(isNull (findDisplay 46))}; (FindDisplay 46) displayAddEventHandler ["keyDown", { //Ins key if (_this select 1 == 210) then { mapLock = !mapLock; systemChat format ["Map Lock: %1", mapLock]; playSoundUI ["Orange_PhoneCall_Accept"]; }; }]; waituntil {!(isNull (findDisplay 12))}; findDisplay 12 displayCtrl 51 ctrlAddEventHandler ["Draw", { params ["_map"]; if (visibleMap) then { mapScale = ctrlMapScale _map; mapPos = _map ctrlMapScreenToWorld [0.5, 0.53]; }; }]; addMissionEventHandler ["Map", { params ["_mapIsOpened", "_mapIsForced"]; if _mapIsOpened then { _pos = getPos player; _scale = missionNamespace getVariable ["mapScale", 0.1]; //Default value of 0.1 in case mapScale is nil if (mapLock) then {_pos = missionNamespace getVariable ["mapPos", getPos player]}; //Default value of player pos if mapPos is nil mapAnimAdd [0, _scale, _pos]; mapAnimCommit; }; }];
  3. Update: The code below had the same result, so it's not related to the "draw" EH. I reported the issue on the tracker like you recommended. I really really appreciate all your help. Big thanks!!! I think I'll leave it for now. mapLock = false; waituntil {!(isNull (findDisplay 46))}; (FindDisplay 46) displayAddEventHandler ["keyDown", { //Ins key if (_this select 1 == 210) then { mapLock = !mapLock; systemChat format ["Map Lock: %1", mapLock]; playSoundUI ["Orange_PhoneCall_Accept"]; }; if (mapLock) then { [] spawn { while {mapLock} do { if visibleMap then { mapPos = (findDisplay 12 displayCtrl 51) ctrlMapScreenToWorld [0.5,0.5]; mapScale = ctrlMapScale (findDisplay 12 displayCtrl 51); }; sleep .1; }; } }; }]; addMissionEventHandler ["Map", { params ["_mapIsOpened", "_mapIsForced"]; if _mapIsOpened then { if (mapLock) then { //private _map = ((uiNamespace getVariable "RscDiary") displayCtrl 51); private _map = findDisplay 12 displayCtrl 51; mapAnimAdd [ 0, missionNamespace getVariable ["mapScale", ctrlMapScale _map], missionNamespace getVariable [ "mapPos", _map ctrlMapScreenToWorld [0.5, 0.5] ] ]; mapAnimCommit; }; } else //If map is closed { }; }];
  4. The thing is, initPlayerLocal.sqf is executed on the client and not on the server. So I am really clueless about what's going on. However I am determined on making the "Map Lock" thingie work, so I will look for alternative methods of saving the map position and scale. If you have any suggestions, I'm all ears.
  5. I made a video. It's janky and the sound is crappy, but it demonstrates the problem.
  6. I'll make a video. It'll take some time because I need to charge my phone, but it will show exactly what I described in words.
  7. I understand the code. I understand it's difficult to believe, but again: initPlayerLocal.sqf: waitUntil {!isNull (findDisplay 12)}; (findDisplay 12 displayCtrl 51) ctrlAddEventhandler ["Draw", { params ["_map"]; // systemChat str (_map ctrlMapScreenToWorld [0.5, 0.5]); systemChat format ["scale: %1", ctrlMapScale _map]; }]; in editor I just put a player, exported to MP missions and uploaded to server. Running it locally works fine. Running it on dedicated server saves map position when reopening it. NO MAP ANIMATION CODE, just systemChat ctrlMapScale. As I said in my post yesterday, I suspect mentioning it in "draw" EH somehow interferes with the default map animation that is supposed to move the map to the player area. This is some voodoo, I would really like to understand wtf is going on. Edit: I've tried your latest code first thing when you replied
  8. Big thanks for the quick answer! I did this: waitUntil {!isNull (findDisplay 12)}; (findDisplay 12 displayCtrl 51) ctrlAddEventhandler ["Draw", { params ["_map"]; systemChat format ["scale: %1", ctrlMapScale _map]; }]; Locally, it works fine - the scale displays and the map works as usual. When I run it on a dediceted server and connect as client, the map scale is displayed, but when the map is reopened, the position is NOT returned to the players area - it remains where it was closed - basically what I was trying to achieve lol. But I'm trying to figure out what the hell is going on, or at least find a way to achieve the goal without voodoo stuff. Like I said before, just mentioning ctrlMapPosition or ctrlMapScale inside "draw" EH causes this to happen. So I assume that we would need to move the map pos/scale saving away from draw EH.
  9. Here comes a blast from the past: I've modified the code slightly. Now, pressing Insert key should enable/disable "Map Lock" - i.e. saving the map position. There is now a global variable called "mapLock", if it's true - map position is saved, if it is false - the map animation should be skipped and the map should be opened normally. The problem: When I start a game locally (MP), everything works fine. When I upload to a dedicated server (it's a laptop right next to me) and connect to it, the map position saves even when mapLock is false. Even if I completely remove the map animation code, map position still saves. I suspect that the default map animation that's supposed to bring the map to player's position is interrupted somehow. From my experiments, just mentioning "ctrlMapScreenToWorld" or "ctrlMapScale" inside map "draw" EH causes this. Also, is it necessary to add a new "draw" EH every time the map is opened or is one time enough? mapLock = false; waituntil {!(isNull (findDisplay 46))}; (FindDisplay 46) displayAddEventHandler ["keyDown", { systemChat format ["Key: %1", _this select 1]; //Ins key if ((_this select 1) == 210) then { mapLock = !mapLock; systemChat format ["Map lock : %1", mapLock]; playSoundUI ["Orange_PhoneCall_Accept"]; }; }]; addMissionEventHandler ["Map", { params ["_mapIsOpened", "_mapIsForced"]; if (_mapIsOpened) then { private _map = ((uiNamespace getVariable "RscDiary") displayCtrl 51); if (mapLock) then { mapAnimAdd [0,missionNamespace getVariable ["MapCurrentZoom",ctrlMapScale _map],missionNamespace getVariable ["MapCurrentPos",_map ctrlMapScreenToWorld [0.5, 0.5]]]; mapAnimCommit; }; _map ctrlAddEventhandler ["Draw", { params ["_map"]; if (mapLock) then { MapCurrentPos = _map ctrlMapScreenToWorld [0.5, 0.5]; MapCurrentZoom = ctrlMapScale _map; }; hintSilent format ["%1\nzoom:%2",MapCurrentPos,MapCurrentZoom]; }]; }; }];
  10. I'm trying to set up a ctrlAddEventHandler ["Draw", {..}]; to draw icons on the arty computer map. To find the map idc, I use the following code: waitUntil {sleep 1; shownArtilleryComputer}; _ctrl = controlNull; { if (!isNull (_x displayCtrl 500)) then { _ctrl = _x displayCtrl 500; }; } forEach (uiNamespace getVariable "igui_displays") + allDisplays; Next I set up the event handler and it works fine. When arty computer is closed, _ctrl becomes controlNull (just as it was before the arty computer was opened). The next time the arty computer is opened, the event handler no longer works and the process needs to be repeated. My question: Does this mean that the display is completely destroyed when closing the artillery computer? If I add event handlers every time the artillery computer is opened, do they stack up or are they destroyed together with the display? Should I consider using ctrlSetEventHandler instead?
  11. Generally, init lines in editor objects are run globally. If the unit is a player, I don't know what happens. I suspect the script could be run only on the local client. And then the script begins with: if (!isServer) exitWith {}; Maybe try calling it from init.sqf instead
  12. First piece of code: I've marked some code lines with numbers and below there are some comments. if (!isServer) exitWith {}; //*********** 1 *********** _veh = _this #0; call compile preprocessFileLineNumbers "plank\plank_init.sqf"; [_veh, [0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 40, 0, 0, 0, 0, 0, 0]] call plank_api_fnc_forceAddFortifications; _veh = _this #0; _veh addEventHandler ["killed",{ _bomb="ammo_Missile_Cruise_01" createVehicle (getPos (_this select 0)); (_this select 0)}]; _veh = _this #0; _veh addAction //*********** 2 *********** [ "Dispense AT mines : Fire slugs in driver seat,and to the right side of vehicle, mines will be covering a 40mradius 65 meters out ", {}]; dont work _veh = _this #0; _veh addEventHandler ["Fired", { flareN = "AT_Mine_155mm_AMOS_range" createvehicle ((player) ModelToWorld [65,0,150]); //*********** 3 *********** flareN setVelocity [0,0,-01]; }]; First of all, I repeat my question: If is VERY IMPORTANT to know where the script is called from. So I am asking again: Where is the SQF file called from? Where is the execVM command that runs it? Is it in an init line of an editor object? Is it in init.sqf? Or elsewhere? Remarks regarding the code: 1. This means that the script will run on server only. 2. AddAction should be used on clients, but your script runs on the server. This action is added on the server only, so clients won't be able to see it. Consider using remoteExec here. 3. In this line of code you mention "player". There is no player on dedicated server, so you should use some other object for position reference. You do have an array of all players, it's called: allPlayers. https://community.bistudio.com/wiki/allPlayers The second piece of code: nukeArt1 setVehicleAmmo 0.0313; Natohelipilot2 moveInGunner blackfoot1; blackfoot1 setVehicleLock "UNLOCKED"; I am not sure I completely understand your explanation: If I understand correctly, you have an Addaction in an init line of an object in the editor that calls this script. In the wiki setVehicleAmmo, moveInGunner and setVehicleLock all have a "LA" icon, which means "local argument" it means that these commands have to be run on the machines where the vehicle is local. When you use an action, the action code is executed on the players machine. By default, empty vehicles are local to server, but if a player enters them, they switch locality to the players computer. So try the following (not tested): [nukeArt1, 0.0313] remoteExec ["setVehicleAmmo", nukeArt1]; [Natohelipilot2, blackfoot1] remoteExec ["moveInGunner", Natohelipilot2]; [blackfoot1, "UNLOCKED"] remoteExec ["setVehicleLock", blackfoot1]; To make your mission work on the dedicated server, you will need patience. Try to concentrate on one problem at a time.
  13. Tested it, works amazingly. Thank you for helping!
  14. Thank you for replying, I can not test it right now, but it looks like exactly what I need.
  15. I can understand your frustration, but from your explanation, I really have no clue what the problem is. The code you posted looks ok. If it works on your PC, then the problem is not the code itself, but where it gets called from. To code MP missions, you should have an understanding of MP locality. Read this page carefully: https://community.bistudio.com/wiki/Multiplayer_Scripting As of your problem, let's be more clear: - What do you mean exactly by "doesn't work" - the code does not get called? - Where is the code written?- (init field, init.sqf etc....)