Jump to content

sarogahtyp

Member
  • Content Count

    2494
  • Joined

  • Last visited

  • Medals

Posts posted by sarogahtyp


  1. 2 hours ago, pierremgi said:

    sequence: in game - return to lobby - change for another role seems to me difficult to trace. Not sure MEH "playerConnected" is firing here.

    Yeah, I missed this and did not cover it in my code...

    Hard to trace this server side only. 

    Maybe there is a smarter client side only solution by storing the chosen side in profile namespace but idk how client can detect if server actually runs the same mission session or if it was restarted. Maybe one could just use the mission time for this.


  2. Above code is ready to get tested and debugged. Im not able to do this because Ive no arma 3 pc for another week and also i think i dont like to set up a dedicated server just to test this. Therefore I can help with debugging but I ll not test the code myself.

     

    Possible problems I see:

    BIS_fnc_getUnitByUID - may not return objNull when player is not spawned yet

    "end1" call BIS_fnc_endMission; - idk if this is the corret end for sending player back to lobby.

     

    If you test the code and get any error or not intended behavior just post it here and I ll try to help.

    • Like 1

  3. I did not have tested anything but this is the way I would try it.

     

    initServer.sqf

    SARO_playerSideArray = [];
    
    addMissionEventHandler ["PlayerConnected", 
    {
     _this spawn
     {
      //time the player is forbidden to chose another side - in minutes
      private _restrictedChangeTime = 10;
    
      // all players with these sides chosen will get checked for side change
      private _restrictedSidesArray = [west, east, independent];
    
      params ["", "_uid", "_name"];
      
      private [ "_dummy", "_playerUnit", "_playerIndex", "_playerNotFound" ];
      
      // wait until the connected client is spawned as player object
      waitUntil
      {
       sleep 1;
       _playerUnit = _uid call BIS_fnc_getUnitByUID;
       not isNull _playerUnit
      };
       
      _playerSide = side _playerUnit;
    
      // exit if player did not choose a restricted side
      if !( _playerSide in _restrictedSidesArray ) exitWith {};
       
      _playerIndex = SARO_playerSideArray findIf { _x select 0 isEqualTo _uid };
      _playerNotFound = _playerIndex < 0;
    
      if (_playerNotFound) then
      {
       _dummy = SARO_playerSideArray pushBack [ _uid, _playerSide, diag_tickTime ];                         
      } else
      {
       private _priorSide = SARO_playerSideArray select 1;
       private _timeUntilChange = (diag_tickTime - SARO_playerSideArray select 2) / 60 - _restrictedChangeTime;
    
       if ( _playerSide isNotEqualTo _priorSide and _timeUntilChange > 0 ) then
       {
         private _string = format 
         [ 
         "%1, before choosing another side you have to play on side %2 for another %3 minutes!",
          _name,
          _priorSide,
          _timeUntilChange
         ];
         
         _string remoteExec ["hint", _playerUnit];
    
         sleep 3;
         ["end1", BIS_fnc_endMission] remoteExec ["call", _playerUnit];
       };
      };
     };
    }];

     

    • Like 2

  4. This should get done server side. You could just store the IDs of players together with their chosen side in an array or a hashmap.

    Every time a player reconnects you just look for the ID and can get its prior chosen side. 

     

    https://community.bistudio.com/wiki/Array

     

    https://community.bistudio.com/wiki/getPlayerUID

     

    https://community.bistudio.com/wiki/onPlayerConnected

     

    https://community.bistudio.com/wiki/Event_Scripts#initServer.sqf

    • Like 1

  5. Quote

    Returns a list of all units, except agents, dead units or units waiting for respawn, outside and inside vehicles that were created on the following sides east, west, independent and civilian.

    Its all about wiki reading:

    https://community.bistudio.com/wiki/allUnits

     

    Quote

    When the last unit leaves its group, the group usually gets immediately auto-deleted,

    https://community.bistudio.com/wiki/createGroup

    • Like 1
×