DZ_spawnpass3params = [
30.0, // S3T_minDist2Zombie
70.0, // S3T_maxDist2Zombie
25.0, // S3T_minDist2Player
70.0, // S3T_maxDist2Player
0.5, // SPT_minDist2Static
2.0 // SPT_maxDist2Static
];
// DZ_spawnpointsfile = "spawnpoints_players.bin";
_createPlayer =
{
// check database
diag_log format ["CONNECTION: _id:% 1 _uid:% 2 _name:% 3", _ id, _uid, _name];
_savedChar = dbFindCharacter _uid;
_isAlive = _savedChar select 0;
_isOnline = _savedChar select 1;
_pos = [_savedChar select 2, _savedChar select 3, _savedChar select 4];
_idleTime = _savedChar select 5;
if (! _isOnline) then
{
diag_log format ["WARNING: No connection to HIVE. Player% 1 could not be loaded.", _ uid];
};};
// process client
[_id, _isAlive, _pos, overcast, rain, _isOnline, _idleTime] spawnForClient {
titleText ["", "BLACK FADED", 10e10];
diag_log str (_this);
_id = _this select 0;
_alive = _this select 1;
0 fadeSound 0;
0 fadeSpeech 0;
0 fadeMusic 0;
// create camera
_position = _this select 2;
_wait = _this select 6;
_wait = -10;
if (! (_ this select 5)) then
{
statusChat ["WARNING!" The server can not be disconnected from the server. "," ColorImportant "];
};};
0 setOvercast (_this select 3);
0 setRain (_this select 4);
simulWeatherSync;
if (_wait <0) then
{
while {_wait <0} do
{
titleText [format ["Welcome to Main Server% 1", -_ wait], "BLACK FADED", 10e10];
_wait = _wait + 1;
sleep 1;
};};
};};
titleText ["Wait for connection to the server", "BLACK FADED", 10e10];
/ *
myCamera = "camera" camCreate _position;
myCamera cameraEffect ["internal", "back"];
myCamera camPrepareDir 120;
myCamera camPreparePos _position;
myCamera camCommitPrepared 0;
* /
// waitUntil {preloadCamera _position};
if (! _alive) then
{
// load data
_top = getArray (configFile >> "cfgCharacterCreation" >> "top");
_bottom = getArray (configFile >> "cfgCharacterCreation" >> "bottom");
_shoe = getArray (configFile >> "cfgCharacterCreation" >> "shoe");
_format = getText (configFile >> "cfgCharacterCreation" >> "format");
// find selected skin
_charType = profileNamespace getVariable ["defaultCharacter", ""];
_charTypeN = DZ_SkinsArray find _charType;
if (_charTypeN <0) then {_charTypeN = floor random (count DZ_SkinsArray)};
// generate inventory array
_topN = floor random (count _top);
_bottomN = floor random (count _bottom);
_shoeN = floor random (count _shoe);
_array = profileNamespace getVariable ["defaultInventory", []];
{
switch true do
{
case (_x isKindOf "TopwearBase"): {
_topN = (_top find _x);
};};
case (_x isKindOf "BottomwearBase"): {
_bottomN = (_bottom find _x);
};};
case (_x isKindOf "FootwearBase"): {
_shoeN = (_shoe find _x);
};};
};};
} forEach _array;
clientNew = [_charTypeN, [_ topN, _bottomN, _shoeN], _ id];
publicVariableServer "clientNew";
statusChat ['Creating a new character!', ];
waitUntil {isSceneReady};
// statusChat ['scene ready ...', ];
}
else
{
clientReady = _id;
publicVariableServer "clientReady";
statusChat ['ready!', ];
};};
5 fadeSound 0;
5 fadeSpeech 0;
5 fadeMusic 0;
};};
};};
// DISCONNECTION PROCESSING
_disconnectPlayer =
{
if (! isNull _agent) then
{
call dbSavePlayer;
_vm = [_uid, _agent] spawn
{
_uid = _this select 0;
_agent = _this select 1;
_connected = diag_tickTime - (_agent getVariable ["starttime", diag_tickTime]);
diag_log format ["DISCONNECT: Player% 1 agent% 2 after% 3 seconds", _ uid, _agent, _connected];
_hands = itemInHands _agent;
// _ vs = DBSetQueue [_uid, 33]; // 33 sec default queue for disconnecting
// sleep 1;
// _ agent playAction "SitDown";
// sleep 30;
call dbSavePlayer;
if (alive _agent) then
{
if (! isNull_hands) then
{
moveToGround _hands;
deleteVehicle _hands;
};};
deleteVehicle _agent;
};};
};};
};};
};};
// Create player on connection
onPlayerConnecting _createPlayer;
onPlayerDisconnected _disconnectPlayer;
/ *
"CLIENT request to respawn [" respawn ", SurvivorPartsMaleWhite: 2: 11874] (UNCONSCIOUS)"
WARNING: Function 'name' - Hicks_206 is dead
WARNING: Function 'name' - Hicks_206 is dead
"Player Hicks_206 was killed by Hicks_206"
Saving array to database: type Any is not supported
"CLIENT 3 request to spawn [" clientNew ", [7, [1,0,0], 3]]"
"CLIENT 3 spawn request rejected as already alive character"
* /
"clientReady" addPublicVariableEventHandler
{
_vm = _this spawn {
_id = _this select 1;
_uid = getClientUID _id;
_wait = (dbFindCharacter _uid) select 5;
_wait = (-_wait) max 0;
diag_log format ["Player% 1 ready to load previous character, waiting% 2 seconds", _ uid, _wait];
sleep _wait;
_handler =
{
if (isNull _agent) then
{
// this should never happen!
diag_log format ["Player% 1 has no agent on load, kill character", _ uid];
_id statusChat ["The system administrator has been notified." Please reconnect to continue. "," ColorImportant "];
dbKillCharacter _uid;
}
else
{
call init_newBody;
};};
};};
_id dbServerLoadCharacter _handler;
};};
};};
"respawn" addPublicVariableEventHandler
{
_agent = _this select 1;
diag_log format ["CLIENT request to respawn% 1 (% 2)", _ this, lifeState _agent];
if (lifeState _agent! = "ALIVE") then
{
// get details
_id = owner _agent;
_uid = getClientUID _id;
_agent setDamage 1;
dbKillCharacter _uid;
diag_log format ["CLIENT killed character% 1 (clientId% 2 / Unit% 2)", _ uid, _id, lifeState _agent];
// process client
[_id, false, position _agent, overcast, rain, true, -30] spawnForClient {
titleText ["Respawning ... Please wait ...", "BLACK FADED", 10e10];
diag_log str (_this);
// playerQueueVM = _this call player_queued;
_id = _this select 0;
_alive = _this select 1;
0 fadeSound 0;
0 fadeSpeech 0;
0 fadeMusic 0;
// create camera
_position = _this select 2;
_wait = _this select 6;
_wait = -5;
if (! (_ this select 5)) then
{
statusChat ["WARNING!" The server can not be disconnected from the server. "," ColorImportant "];
};};
0 setOvercast (_this select 3);
0 setRain (_this select 4);
simulWeatherSync;
if (_wait <0) then
{
while {_wait <0} do
{
titleText [format ["Welcome \ n Expect to connect to the server through% 1", -_ wait], "BLACK FADED", 10e10];
_wait = _wait + 1;
sleep 1;
};};
};};
titleText ["Wait for connection to the server", "BLACK FADED", 10e10];
/ *
myCamera = "camera" camCreate _position;
myCamera cameraEffect ["internal", "back"];
myCamera camPrepareDir 120;
myCamera camPreparePos _position;
myCamera camCommitPrepared 0;
* /
// waitUntil {preloadCamera _position};
if (! _alive) then
{
// load data
_top = getArray (configFile >> "cfgCharacterCreation" >> "top");
_bottom = getArray (configFile >> "cfgCharacterCreation" >> "bottom");
_shoe = getArray (configFile >> "cfgCharacterCreation" >> "shoe");
_format = getText (configFile >> "cfgCharacterCreation" >> "format");
// find selected skin
_charType = profileNamespace getVariable ["defaultCharacter", ""];
_charTypeN = DZ_SkinsArray find _charType;
if (_charTypeN <0) then {_charTypeN = floor random (count DZ_SkinsArray)};
// generate inventory array
_topN = floor random (count _top);
_bottomN = floor random (count _bottom);
_shoeN = floor random (count _shoe);
_array = profileNamespace getVariable ["defaultInventory", []];
{
switch true do
{
case (_x isKindOf "TopwearBase"): {
_topN = (_top find _x);
};};
case (_x isKindOf "BottomwearBase"): {
_bottomN = (_bottom find _x);
};};
case (_x isKindOf "FootwearBase"): {
_shoeN = (_shoe find _x);
};};
};};
} forEach _array;
clientNew = [_charTypeN, [_ topN, _bottomN, _shoeN], _ id];
publicVariableServer "clientNew";
statusChat ['Creating a new character!', ];
waitUntil {isSceneReady};
// statusChat ['scene ready ...', ];
}
else
{
clientReady = _id;
publicVariableServer "clientReady";
statusChat ['ready!', ];
};};
5 fadeSound 0;
5 fadeSpeech 0;
5 fadeMusic 0;
};};
};};
};};
"clientNew" addPublicVariableEventHandler
{
_array = _this select 1;
_id = _array select 2;
diag_log format ["CLIENT% 1 request to spawn% 2", _ id, _this];
_id spawnForClient {statusChat ['testing 1 2 3', ]};
_savedChar = dbFindCharacter (getClientUID _id);
if (_savedChar select 0) exitWith {
diag_log format ["CLIENT% 1 spawn request rejected as already alive character", _ id];
};};
_charType = _array select 0;
_charInv = _array select 1;
// _ pos = findCachedSpawnPoint [DZ_spawnpointsfile, DZ_spawnpass3params];
// spawn points
_pos = [6838.8394, 8199.9473, 0];
// load data
_top = getArray (configFile >> "cfgCharacterCreation" >> "top");
_bottom = getArray (configFile >> "cfgCharacterCreation" >> "bottom");
_shoe = getArray (configFile >> "cfgCharacterCreation" >> "shoe");
_myTop = _top select (_charInv select 0);
_myBottom = _bottom select (_charInv select 1);
_myShoe = _shoe select (_charInv select 2);
_mySkin = DZ_SkinsArray select _charType;
_uid = getClientUID _id;
_res1 = dbCreateCharacter _uid;
diag_log format ["SERVER: Creating% 1 at% 2 for clientId% 3 (DB result% 4)", _ mySkin, _pos, _id, _res1];
_agent = createAgent [_mySkin, _pos, [], 6500, "NONE"];
{null = _agent createInInventory _x} forEach [_myTop, _myBottom, _myShoe];
_v = _agent createInInventory "tool_flashlight";
_v = _agent createInInventory "consumable_battery9V"; _ v setVariable ["power", 30000];
// Connecting Individual Players
getClientUID _id;
_agent call init_newPlayer;
call init_newBody;
diag_log format ["SERVER: Created% 1 for clientId% 2", _ agent, _id];
};};
wtf ??