Jump to content

pawelisus

Member
  • Content Count

    14
  • Joined

  • Last visited

  • Medals

Posts posted by pawelisus


  1. 17 minutes ago, sarogahtyp said:

    you are ending the mission server side. This is the problem. I alreqdy showed how to do it on the client.

    Also the problem which @pierremgi described persists...

    ["end1", BIS_fnc_endMission] remoteExec ["call", _playerUnit]; works like a charm... I'm sorry for my ignorance and thanks a lot for giving me general idea and helping with my problems, Hope I didnt upset you much. Last thing is the @pierremgi problem. I dont think it exists. From my testing, EH PlayerConnected fires when player chooses unit in lobby AND clicks ok, EH PlayerDisconnected fires when he clicks abort in pause menu

    • Like 1

  2. InitServer.sqf

    SideLockArray = []; // Array storing data about lock [player Id, server time + for how long player is locked in seconds , player side];
    
    addMissionEventHandler ["PlayerDisconnected", {
    
    	private ["_playerUnit"];
    	_exist = false;
    	_playeruid = _this select 1;
    
    	_SLArrayLength = Count SideLockArray;
    
    	if (_SLArrayLength != 0) then    // Checks if array isn't empty to prevent making errors
    	{
    		for "_i" from 0 to _SLArrayLength -1 do {
    				_record = SideLockArray select _i;
    				_checkeduid = _record select 0;
    				if (str _checkeduid == str _playeruid) then {_exist = true};
    		};
    	};
    
    	if (_exist == false) then {  // If player not present in database we have to add him
    
    		// wait until the connected client is spawned as player object
      		waitUntil
      		{
      			sleep 1;
      			_playerUnit = _playeruid call BIS_fnc_getUnitByUID;
      			not isNull _playerUnit;
      		};
    
    		SideLockArray append [ [_this select 1, time + 30 , side _playerUnit] ];
    	
    	};
    		
    }];
    
    
    addMissionEventHandler ["PlayerConnected", {
    
    	_this spawn {
    
    
    	if (isNil {SideLockArray select 0} ) then
    	{
    		format ["Table contents: %1", SideLockArray] remoteExec ["hint"];
    	}
    	else
    	{
    		format ["Started with : %1", _this select 1] remoteExec ["hint"];
    
    		_playeruid = _this select 1; // player id who we are looking for
    		private ["_playerUnit"];
    
    		// wait until the connected client is spawned as player object
      		waitUntil
      		{
      			sleep 1;
      			_playerUnit = _playeruid call BIS_fnc_getUnitByUID;
      			not isNull _playerUnit;
      		};
    		
    
    		_playerside = side _playerUnit;
    		_servertime = time;
    
    		// Looking for a player if he's in the array
    
    		for "_i" from 0 to (Count SideLockArray) -1 do {
    			_record = SideLockArray select _i;
    			_checkeduid = _record select 0; 
    
    
    
    			if (str _checkeduid == str _playeruid) then
    			{
    				_checkedtime = _record select 1;
    				_checkedside = _record select 2;
    				format ["present in database: %1" ,_playeruid] remoteExec ["hint"];
    
    				if (_playerside != _checkedside && _checkedtime >= _servertime) then { // If he joined different side than his last one he'll get locked
    					format ["Player is locked: %1" ,_playeruid] remoteExec ["hint"];
    
    					// endMission "END1"; // - Ending entire mission **That's my problem**
    
    				}
    				else 
    				{
    					SideLockArray deleteAt _i; // Deleting him from Array if he rejoined his side
    				};
    			};
    		
    		};
    	
    	};
          
    	};
    }];

    Firstly i want to make something that works and then optimalise. I'll add for how long someone gets locked as a parameter and I need to add something to break for loops to save time or change it entirely f.e. to while loop but I focused on getting to work first. Of course hints are only there for debugging purposes


  3. 2 hours ago, Ibragim A said:

    I'm not good at multiplayer scripts at all, but I see that you're using a loop in unscheduled environment . Also, the brackets in the code are mixed up in places.

    May be try:

    
    addMissionEventHandler ["PlayerConnected", {
    
    _playerUnit = (_this select 1) call BIS_fnc_getUnitByUID;
    
    _playerside = side _playerUnit;
    
    }];

     

    In my original code brackets are fine, I made a mistake writing it to a topic but thanks. Unfortunately it wont work because if it will be called emediately it will just return side "UKNOWN" because player isn't spawned yet


  4. addMissionEventHandler ["PlayerConnected", {
    
    _playeruid = _this select 1;
    
    _playerUnit = 0;
    
    
            waitUntil
    
            {
    
                sleep 1;
    
                _playerUnit = _playeruid call BIS_fnc_getUnitByUID;
    
                not isNull _playerUnit;
    
            };
    _playerside = side _playerUnit;
    
    ]};

    Main problem is that the _playerside is equal to UNKNOWN. I've noticed that _playerUnit is <Null-Object>. I think BIS_fnc_getUnitByUID is called before player joined and I cant find a way to call it after him spawning.


  5. I was writing code for this and I think i've done it too but i have two small issues:

    1. When I'm trying to get player side it is always WEST whenever In blufor or Opfor. I was using playerSide function, but i've seen that you're doing it other way so i'll change to your way.

    2. function endMission "END1" ends whole mission. I think its happening because I didn't configured it propperly. I've noticed that when I call it my character freezes without any briefing screen for something like 15 seconds. I'm doing debugging of this code on clean mission and endMission "END1" works propperly on liberation that I'm working on so if I merge this script to liberation it should work fine

     

     


  6. I'm trying to create a script that would block players to their sides for a period of time who try to get more intel about enemy  positons. I've figured out how to get time for how long they are locked but i dont know how to store that information in such way that would prevent it from disappearing. The best way would be when that data dissapeared entirely after restart but most important for me is to find a way to store that data even if player leaves.

×