Player disconnected

  • Multiplayer

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • OK. Ich habe das jetzt mit 2 Mission Eventhandlern und einer globalen Variable (array) gelöst.
    Der dazugehörige Code, welcher nur serverseitig ausgeführt wird, schaut wie folgt aus:

    Quellcode: initServer.sqf

    1. // ADD EVENTHANDLER
    2. addMissionEventHandler ["PlayerConnected", {
    3. _this spawn {
    4. params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
    5. _date = date;
    6. _day = _date select 2;
    7. _hour = _date select 3;
    8. _min = _date select 4;
    9. // TIMEOUT
    10. sleep 12;
    11. // SEARCH PLAYER IN ARRAY
    12. {
    13. // GET VARIABLES
    14. _x params ["_nameDB", "_dateDB"];
    15. // IF PLAYER FOUND
    16. if (_nameDB == _name) then {
    17. // VARIABLES
    18. private _dayDB = _dateDB select 2;
    19. private _hourDB = _dateDB select 3;
    20. private _minDB = _dateDB select 4;
    21. private _safeTime = _minDB + 2;
    22. // IF ILLEGAL RECONNECT
    23. if (_day == _dayDB && {_hour == _hourDB} && {_min < _safeTime}) then {
    24. ["Reconnect"] remoteExec ["iV_fnc_hintUser", _owner, false];
    25. };
    26. };
    27. } forEach iV_ServerConnections;
    28. };
    29. }];
    30. // ADD EVENTHANDLER
    31. addMissionEventHandler ["PlayerDisconnected", {
    32. _this spawn {
    33. params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
    34. private ["_value"];
    35. _date = date;
    36. private _found = false;
    37. // CHECK IF PLAYER EXIST IN ARRAY
    38. {
    39. // GET VARIABLES
    40. _x params ["_nameDB", "_dateDB"];
    41. private _dayDB = _dateDB select 2;
    42. private _hourDB = _dateDB select 3;
    43. private _minDB = _dateDB select 4;
    44. private _index = iV_ServerConnections find _x;
    45. // IF PLAYER FOUND
    46. if (_nameDB == _name) then {
    47. // DELETE FROM ARRAY, HANDLE NUMBERS & SET AS FOUND
    48. iV_ServerConnections deleteAt _index;
    49. _value = [_name, _date];
    50. _found = true;
    51. };
    52. } forEach iV_ServerConnections;
    53. // TIMEOUT
    54. sleep 3;
    55. // IF PLAYER NOT IN ARRAY
    56. if !(_found) then {
    57. _value = [_name, _date];
    58. };
    59. // PUSHBACK INTO ARRAY & MAKE PUBLIC
    60. iV_ServerConnections pushBack _value;
    61. publicVariable "iV_ServerConnections";
    62. };
    63. }];
    Alles anzeigen