Jump to content

dupa1

Member
  • Content Count

    51
  • Joined

  • Last visited

  • Medals

Everything posted by dupa1

  1. I have a Draw EH displaying icons on GPS. When the GPS is in default mode, all is good. When I set the GPS to follow the player (with "Ctrl + [" or "Ctrl + ]"), the icons maintain the same direction regardless of the map rotation. I would like them to rotate together with the map. To do that, I would need the direction of the map, which is basically the direction of the player. Now I just need to tell if the GPS is in "follow" mode or not. Video of the problem:
  2. You don't need a script. Press Ctrl+F to switch gunner weapon. Select laser designator. Tell the AI to target something. Toggle laser on/off with Mouse1. When laser is active, it will appear as a red mark on your radar. Edit: The above will work if you are the pilot of the helicopter.
  3. I like the built in revive system, but: 1. When player is incapacitated, is it possible to prevent the AI from taking command and bossing around giving ridiculous orders? (I had this issue with all the revive scripts I tried). 2. Is it possible to give points for reviving players?
  4. I get the idea. Thanks for the help.
  5. 2. I mean execute my code when a player is being revived. Of course to add score I would need to know who did the revive. Edit: I want to add score. Edit2: "EntityRespawned" gets called when a player gets revived?
  6. I am trying to save player scores into profileNamespace, so they can be restored after server restart. The main loop constantly updates scoresArr with player scores. The saveScores function saves is into profileNameSpace. The main loop seems to work fine. When I call the saveScores function, any subsequent updates to scoresArr seem to affect the saved data in the profileNameSpace. Here is a video of this: And the code: //initServer.sqf scoresArr = []; saveScores = { profileNameSpace setVariable ["saveData", scoresArr]; saveProfileNameSpace; "Done!"; }; while {true} do { { _scoreInfo = getPlayerScores _x; _uid = getPlayerUID _x; _uids = scoresArr apply {_x select 0}; _i = _uids find _uid; if (_i == -1) then {scoresArr pushBack [_uid, _scoreInfo]} else {scoresArr set [_i, [_uid, _scoreInfo]]}; } forEach allPlayers; sleep 1; };
  7. Well, I've been messing around with ArmA coding for a long time, since SQS days. The mission I'm making now is my first serious project. I feel as if I just discovered what my schlong is for at the age of 30.
  8. And again, big thanks!
  9. Thank you for replying. I am not certain you are correct. a = 1; b = a; b = b + 1; The above code should not modify A. There should be 2 instances of the same data, one of each is later modified. I would expect the same from profileNamespace variables. I did quite a lot of testing on this. I tried using a temporary variable, with the same result. From my observations, using the set command specifically causes this problem. I managed to build the array without using the set command and now it seems to work OK.... (the second version of the code has some mistakes) Edit: I just tried your code in the console, and it did what you said. I tried my code in the console, and it did what I said. So, it seems that arrays and scalar values are treated differently. This is new to me. Thanks for the help.
  10. Update: This happens when I use the "set" command, this must be some kind of a bug. I rewrote the main loop without using the "set" command and it seems to work... for now... //initServer.sqf scoresArr = []; saveScores = { profileNameSpace setVariable ["saveData", scoresArr]; saveProfileNameSpace; "Done!"; }; while {true} do { _tempArr = []; { _uid = getPlayerUID _x; _scoreInfo = getPlayerScores _x; _found = false; {if (_x#0 == _uid) then {_tempArr pushBack [_uid, _scoreInfo]; _found = true} else {_tempArr pushBack _x}} forEach scoresArr; if !_found then {_tempArr pushBack [_uid, _scoreInfo]}; } forEach allPlayers; scoresArr = _tempArr; sleep 1; };
  11. I want to save player scores through server restart. I have an idea how to save the scores, but I don't have an idea how to actually access them. I know about the getPlayerScores command, but it receives a unit as argument, so it would only work for connected players. So, basically, what I'm looking for is a way to access the data from the score table by script. I did have an idea of tracking the scores manually, but before doing that I decided to ask if there is a more simple way to do it.
  12. I tried the HandleDisconnect EH. Querying the player scores from the _unit argument returns an empty array. Guess it's plan B.
  13. Thanks, I didn't know about this one, I only knew about playerDisconnected EH, which has no unit argument. This will definitely make my life easier.
  14. dupa1

    Effects on cannon muzzle

    I am not sure I correctly understand what you are trying to achieve, but if I'm guessing right, you want something like this: The only way I can think of is using the "drop" command and creating a particle circle manually. https://community.bistudio.com/wiki/drop
  15. _object = _this select 0;
  16. 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; }; }];
  17. By default, when you open the map, it's centered around the player. I would like the map to stay at the position where it was when it was closed. I've set up a mission event handler to fire when the map is opened and closed, but I need some help finding out out how to save/restore the coordinates. Thanks in advance.
  18. 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 { }; }];
  19. 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.
  20. I made a video. It's janky and the sound is crappy, but it demonstrates the problem.
  21. 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.
  22. 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
  23. 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.
  24. 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]; }]; }; }];
×