Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Респавн - смерть бота при вылете игрока #26

Open
Zealot111 opened this issue Nov 4, 2015 · 4 comments

Comments

@Zealot111
Copy link
Owner

No description provided.

@Zealot111
Copy link
Owner Author

["deleteDisconnected", "onPlayerDisconnected", {

    [_name,_uid] spawn {

        private ["_name","_uid","_clientId","_unit"];

        _name = _this select 0;

        _uid = _this select 1;

        _clientId = -1;

        _unit = objNull;



        while {_clientId == -1} do {

            {

                if (getPlayerUID _x == _uid) exitWith {

                    _clientId = owner _x;

                    _unit = _x;

                    deleteVehicle _unit;

                };

            } forEach playableUnits;

            sleep .02;

        };

        deleteVehicle _unit;

    };

}] call BIS_fnc_addStackedEventHandler;

@Zealot111
Copy link
Owner Author

//Init.sqf (server):
if (isServer || isDedicated) then 
{
    "playableUnitOccupier_PV" addPublicVariableEventHandler {

        private "_playableUnit";

        _playableUnit = [_this,1,objNull] call BIS_fnc_param;

        if(!isNull _playableUnit) then 
        {
            missionNamespace setVariable[getPlayerUID _playableUnit,_playableUnit];
        }; 
    };

    ["deleteBodyOnPlayerDisccndId", "onPlayerDisconnected", {

       private "_body";

       _body = missionNamespace getVariable [_uid,objNull];

       if (!isNull _body) then 
       {
            deleteVehicle _body;
            missionNamespace setVariable[_uid,nil];
       };

    }] call BIS_fnc_addStackedEventHandler;


};

@Zealot111
Copy link
Owner Author

//Init.sqf (client) :
if(!isDedicated) then 
{
    waitUntil {Alive player};

    playableUnitOccupier_PV = player; publicVariableServer "playableUnitOccupier_PV";

    player addEventHandler ["Respawn", {
        playableUnitOccupier_PV = _this select 0; publicVariableServer "playableUnitOccupier_PV";
    }];
};

@Zealot111
Copy link
Owner Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant