private ["_characterID","_playerObj","_playerID","_dummy","_worldspace","_state","_doLoop","_key","_primary","_medical","_stats","_humanity","_lastinstance","_friendlies","_randomSpot","_position","_debug","_distance","_hit","_fractures","_score","_findSpot","_pos","_isIsland","_w","_clientID","_spawnMC","_namespace"];
//diag_log ("SETUP: attempted with " + str(_this));
_characterID = _this select 0;
_playerObj = _this select 1;
_playerID = getPlayerUID _playerObj;
if (isNull _playerObj) exitWith {
diag_log ("SETUP INIT FAILED: Exiting, player object null: " + str(_playerObj));
};
//Add MPHit event handler
// diag_log("Adding MPHit EH for " + str(_playerObj));
_playerObj addMPEventHandler ["MPHit", {_this spawn fnc_plyrHit;}];
if (_playerID == "") then {
_playerID = getPlayerUID _playerObj;
};
if (_playerID == "") exitWith {
diag_log ("SETUP INIT FAILED: Exiting, no player ID: " + str(_playerObj));
};
private["_dummy"];
_dummy = getPlayerUID _playerObj;
if ( _playerID != _dummy ) then {
diag_log format["DEBUG: _playerID miscompare with UID! _playerID:%1",_playerID];
_playerID = _dummy;
};
//Variables
_worldspace = [];
_state = [];
//Do Connection Attempt
_doLoop = 0;
while {_doLoop < 5} do {
_key = format["CHILD:102:%1:",_characterID];
_primary = _key call server_hiveReadWrite;
if (count _primary > 0) then {
if ((_primary select 0) != "ERROR") then {
_doLoop = 9;
};
};
_doLoop = _doLoop + 1;
};
if (isNull _playerObj or !isPlayer _playerObj) exitWith {
diag_log ("SETUP RESULT: Exiting, player object null: " + str(_playerObj));
};
//Wait for HIVE to be free
//diag_log ("SETUP: RESULT: Successful with " + str(_primary));
_medical = _primary select 1;
_stats = _primary select 2;
_state = _primary select 3;
_worldspace = _primary select 4;
_humanity = _primary select 5;
_lastinstance = _primary select 6;
//Set position
_randomSpot = false;
if (count _worldspace > 0) then {
_position = _worldspace select 1;
if (count _position < 3) then {
//prevent debug world!
_randomSpot = true;
};
_debug = getMarkerpos "respawn_west";
_distance = _debug distance _position;
if (_distance < 2000) then {
_randomSpot = true;
};
_distance = [0,0,0] distance _position;
if (_distance < 500) then {
_randomSpot = true;
};
// Came from another server force random spawn
if (_lastinstance != dayZ_instance) then {
_randomSpot = true;
};
//random thingy start
_uGrid = mapGridPosition _position;
_gridBlack = ["005128","006128","007128","004129","005129","006129","007129","003130",
"004130","005130","006130","007130","008130","003131","004131","005131","006131","007131",
"008131","009131","003132","004132","005132","006132","007132","008132","009132","010132",
"003133","004133","005133","006133","007133","008133","009133","010133","011133","003134","004134",
"005134","006134","007134","008134","009134","010134","011134","012134","003135","004135","005135",
"006135","007135","008135","009135","010135","011135","012135","003136","004136","005136","006136",
"007136","008136","009136","010136","011136","012136","013136","003137","004137","005137","006137",
"007137","008137","009137","010137","011137","012137","013137","003138","004138","005138","006138",
"007138","008138","009138","010138","011138","012138","013138","003139","004139","005139","006139",
"007139","008139","009139","010139","011139","012139","013139","003140","004140","005140","006140",
"007140","008140","009140","010140","011140","012140","013140","003140","004140","005140","006140",
"007140","008140","009140","010140","011140","012140","013140","003141","004141","005141","006141",
"007141","008141","009141","010141","011141","012141","013141","004142","005142","006142","007142",
"008142","009142","010142","011142","012142","013142","005143","006143","007143","008143","009143",
"010143","011143","012143","013143","007144","008144","009144","010144","011144","012144","013144",
"008145","009145","010145","011145","012145","013145","009146","010146","011146","012146"];
if (_uGrid in _gridBlack) then {
_randomSpot = true;
};
//Random thingy end
//_playerObj setPosATL _position;
} else {
_randomSpot = true;
};
//diag_log ("LOGIN: Location: " + str(_worldspace) + " doRnd?: " + str(_randomSpot));
//set medical values
if (count _medical > 0) then {
_playerObj setVariable["USEC_isDead",(_medical select 0),true];
_playerObj setVariable["NORRN_unconscious", (_medical select 1), true];
_playerObj setVariable["USEC_infected",(_medical select 2),true];
_playerObj setVariable["USEC_injured",(_medical select 3),true];
_playerObj setVariable["USEC_inPain",(_medical select 4),true];
_playerObj setVariable["USEC_isCardiac",(_medical select 5),true];
_playerObj setVariable["USEC_lowBlood",(_medical select 6),true];
_playerObj setVariable["USEC_BloodQty",(_medical select 7),true];
_playerObj setVariable["unconsciousTime",(_medical select 10),true];
//Add Wounds
{
_playerObj setVariable[_x,true,true];
//["usecBleed",[_playerObj,_x,_hit]] call broadcastRpcCallAll;
usecBleed = [_playerObj,_x,_hit];
publicVariable "usecBleed";
} forEach (_medical select 8);
//Add fractures
_fractures = (_medical select 9);
_playerObj setVariable ["hit_legs",(_fractures select 0),true];
_playerObj setVariable ["hit_hands",(_fractures select 1),true];
------Code from the file delted bc its not neccesary for the script otherwise the post would be to long (YOU NEED THE COMPLETE FILE FOR A SERVER TO WORK)