Server Done I Think

This commit is contained in:
icomrade
2016-02-29 00:29:23 -05:00
parent b96cd2d971
commit 58acf95dc7
37 changed files with 3919 additions and 1200 deletions

View File

@@ -1,5 +1,5 @@
private ["_isInfected","_doLoop","_hiveVer","_isHiveOk","_playerID","_playerObj","_primary","_key","_charID","_playerName","_backpack","_isNew","_inventory","_survival","_model","_mags","_wpns","_bcpk","_config","_newPlayer"];
#include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
#ifdef DZE_SERVER_DEBUG
diag_log ("STARTING LOGIN: " + str(_this));
#endif
@@ -7,7 +7,7 @@ diag_log ("STARTING LOGIN: " + str(_this));
_playerID = _this select 0;
_playerObj = _this select 1;
_playerName = name _playerObj;
_worldspace = [];
if (_playerName == '__SERVER__' || _playerID == '' || local player) exitWith {};
if (isNil "sm_done") exitWith {
@@ -15,6 +15,10 @@ if (isNil "sm_done") exitWith {
diag_log ("Login cancelled, server is not ready. " + str(_playerObj));
#endif
};
// Cancel any login until server_monitor terminates.
// This is mandatory since all vehicles must be spawned before the first players spawn on the map.
// Otherwise, all vehicle event handlers won't be created on players' client side.
if (isNil "sm_done") exitWith { diag_log ("Login cancelled, server is not ready. " + str(_playerObj)); };
if (count _this > 2) then {
dayz_players = dayz_players - [_this select 2];
@@ -23,10 +27,17 @@ if (count _this > 2) then {
//Variables
_inventory = [];
_backpack = [];
_items = [];
_magazines = [];
_weapons = [];
_medicalStats = [];
_survival = [0,0,0];
_isInfected = 0;
_tent = [];
_state = [];
_direction = 0;
_model = "";
_newUnit = objNull;
if (_playerID == "") then {
_playerID = [_playerObj] call FNC_GetPlayerUID;
};
@@ -41,6 +52,35 @@ if ((_playerID == "") || (isNil "_playerID")) exitWith {
diag_log ("LOGIN ATTEMPT: " + str(_playerID) + " " + _playerName);
#endif
_endMission = false;
_timeleft = 0;
{
//if ((_playerID select _i) in activePlayers) exitWith { diag_log ("Login cancelled, player has logged out within the past 2 mins. " + str(_playerObj)); };
_0 = _x select 0;
_1 = _x select 1;
_timeleft = diag_ticktime - _1;
if (_playerID == _0) then {
//If players last logoff is about the ghost timer remove player from ghost que.
if ((_timeleft > dayz_ghostTimer) or (_timeleft < 0)) then {
dayz_ghostPlayers = dayz_ghostPlayers - [_0];
dayz_activePlayers set[_forEachIndex, _0];
dayz_activePlayers = dayz_activePlayers - [_0];
} else {
//if player is in died allow them passage.
if (_playerID in dayz_died) then {
dayz_died = dayz_died - [_playerID];
dayz_ghostPlayers = dayz_ghostPlayers - [_0];
dayz_activePlayers set[_forEachIndex, _0];
dayz_activePlayers = dayz_activePlayers - [_0];
} else {
// Logoff time is not beyond ghost time and player didn't die
_endMission = true;
};
};
};
}forEach dayz_activePlayers;
//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
@@ -70,7 +110,7 @@ if ((_primary select 0) == "ERROR") exitWith {
_newPlayer = _primary select 1;
_isNew = count _primary < 7; //_result select 1;
_charID = _primary select 2;
_randomSpot = false;
#ifdef DZE_SERVER_DEBUG
diag_log ("LOGIN RESULT: " + str(_primary));
#endif
@@ -114,7 +154,7 @@ if (!_isNew) then {
_mags = getArray (_config >> "magazines");
_wpns = getArray (_config >> "weapons");
_bcpk = getText (_config >> "backpack");
_randomSpot = true;
if(!isNil "DefaultMagazines") then {
_mags = DefaultMagazines;
};
@@ -146,5 +186,23 @@ if (worldName == "chernarus") then {
([4654,9595,0] nearestObject 145260) setDamage 1;
};
dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
(owner _playerObj) publicVariableClient "dayzPlayerLogin";
//dayzPlayerLogin = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
PVCDZ_plr_Login = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
#ifdef DZE_SERVER_DEBUG
diag_log format["%1, %2, %3, %4, %5, %6, %7, %8, %9, %10",_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer,_isInfected];
#endif
(owner _playerObj) publicVariableClient "PVCDZ_plr_Login";
//Make player wait till ghost timer is up.
if (_endMission) exitwith {
_remaining = dayz_ghostTimer - _timeleft;
diag_log format["LOGIN CANCELLED: player: %1 is in ghost mode. Time remianing: %2 before login!!",_playerObj,_remaining];
PVCDZ_plr_Ghost = [_remaining];
(owner _playerObj) publicVariableClient "PVCDZ_plr_Ghost";
};
[_playerID,_charID,1] call dayz_recordLogin;
PVCDZ_plr_PlayerAccepted = [_playerName,diag_ticktime];
(owner _playerObj) publicVariableClient "PVCDZ_plr_PlayerAccepted";