Jump to content

pawelisus

Member
  • Content Count

    14
  • Joined

  • Last visited

  • Medals

Everything posted by pawelisus

  1. 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.
  2. ["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
  3. When I was using your way same thing happened, Maybe I'm doing something wrong, I'll try second time. In my code when player went to lobby it worked fine, If i understood him correctly
  4. 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
  5. I think I made it to work like i wanted but I cant figure why endMission "END1"; frezees my character in place and ends entire mission except of kicking only one player. It's propably very obvious why but I'm new to sqf
  6. 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.
  7. What does the _this spawn do? I mean I've read what it do in the docs but what does it do specificaly to fix the problem
  8. 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
  9. Ohhh, I didnt saw that one.. you've not replied so I asked about the problem
  10. 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
  11. I think you've made it clear for me. I'll try to make it, in case of problems I won't hesitate to ask. Thanks
  12. Ohhh, that makes a lot of sense, Thanks for the response sarogahtyp. Is there a way to store some data for example integers to user that wont get deleted until server restart?
  13. How long variables assigned to players are existing. I mean do they get removed when player leaves or they are stored to the momment when server restarts?
×