Statistics #1 (Player Stats)

This commit is contained in:
He-Man 2019-05-12 00:58:33 +02:00
parent a66743ac94
commit 4cf01824aa
20 changed files with 192 additions and 36 deletions

View File

@ -23,7 +23,7 @@
5 createVehicleLocal !="\"Sign_Arrow_Direction_Yellow_F\" createVehicleLocal" !="\"#particlesource\" createVehicleLocal" !="\"#lightpoint\" createVehicleLocal" !="\"BloodSplat\" createVehicleLocal" !="[\"lightning1_F\", \"lightning2_F\"] call BIS_fnc_selectRandom;\n_lighting = _class createVehicleLocal" !="SLX_XEH_DUMMY createVehicleLocal [0, 0, 0];" !="CBA_eventHandlers = \"Logic\" createVehicleLocal [0, 0];" 5 createVehicleLocal !="\"Sign_Arrow_Direction_Yellow_F\" createVehicleLocal" !="\"#particlesource\" createVehicleLocal" !="\"#lightpoint\" createVehicleLocal" !="\"BloodSplat\" createVehicleLocal" !="[\"lightning1_F\", \"lightning2_F\"] call BIS_fnc_selectRandom;\n_lighting = _class createVehicleLocal" !="SLX_XEH_DUMMY createVehicleLocal [0, 0, 0];" !="CBA_eventHandlers = \"Logic\" createVehicleLocal [0, 0];"
5 createUnit !="_driver = _grp createUnit[\"I_UAV_AI\", position _unit, [], 0, \"CAN_COLLIDE\"];" !="axeGeneral = grpVIPGeneral createUnit [\"I_officer_F\", axeGeneralPos, [], 1, \"CAN_COLLIDE\"];" !="bis_functions_mainscope = _grpLogic createunit [\"Logic\",[9,9,9],[],0,\"none\"];" !="_unit = _grp createUnit[selectRandom _arrUnits, _pos, [], 0, \"FORM\"];" !="_driver = (group player) createUnit[\"I_UAV_AI\", position axeUAV, [], 0, \"CAN_COLLIDE\"];" 5 createUnit !="_driver = _grp createUnit[\"I_UAV_AI\", position _unit, [], 0, \"CAN_COLLIDE\"];" !="axeGeneral = grpVIPGeneral createUnit [\"I_officer_F\", axeGeneralPos, [], 1, \"CAN_COLLIDE\"];" !="bis_functions_mainscope = _grpLogic createunit [\"Logic\",[9,9,9],[],0,\"none\"];" !="_unit = _grp createUnit[selectRandom _arrUnits, _pos, [], 0, \"FORM\"];" !="_driver = (group player) createUnit[\"I_UAV_AI\", position axeUAV, [], 0, \"CAN_COLLIDE\"];"
5 createAgent !="bis_revive_ratioLethal = createAgent [\"Logic\", [10,10,0], [], 0, \"CAN_COLLIDE\"];" !="_unit = createAgent[_unitClass, _targetPos, [], 256, \"FORM\"];" !="_unit = createAgent [_unitClass, _targetPos, [], 120, \"FORM\"];" !="_animal = createAgent[_randomAIClass, _animalPos, [], 5, \"NONE\"];" !="_unit = createAgent [\"Epoch_Cloak_F\", _pos, [], 0, \"CAN_COLLIDE\"];" !="_unit = createAgent [\"Epoch_Sapper_F\", _targetPos, [], 180, \"FORM\"];" !="_sapper = createAgent [\"Epoch_Sapper_F\", getPos _cage2, [], 0, \"FORM\"];" !="_unit = createAgent[_unitClass, position player, [], _zRange, \"FORM\"];" !="_animal = createAgent[_randomAIClass, _animalPos, [], 0, \"CAN_COLLIDE\"];" !="_axeSapper = createAgent [\"Epoch_Sapper_F\", _pos, [], 12, \"FORM\"];" !="_nestMate = createAgent [\"Epoch_Sapper_F\", _garrPos, [], 0, \"FORM\"];" 5 createAgent !="bis_revive_ratioLethal = createAgent [\"Logic\", [10,10,0], [], 0, \"CAN_COLLIDE\"];" !="_unit = createAgent[_unitClass, _targetPos, [], 256, \"FORM\"];" !="_unit = createAgent [_unitClass, _targetPos, [], 120, \"FORM\"];" !="_animal = createAgent[_randomAIClass, _animalPos, [], 5, \"NONE\"];" !="_unit = createAgent [\"Epoch_Cloak_F\", _pos, [], 0, \"CAN_COLLIDE\"];" !="_unit = createAgent [\"Epoch_Sapper_F\", _targetPos, [], 180, \"FORM\"];" !="_sapper = createAgent [\"Epoch_Sapper_F\", getPos _cage2, [], 0, \"FORM\"];" !="_unit = createAgent[_unitClass, position player, [], _zRange, \"FORM\"];" !="_animal = createAgent[_randomAIClass, _animalPos, [], 0, \"CAN_COLLIDE\"];" !="_axeSapper = createAgent [\"Epoch_Sapper_F\", _pos, [], 12, \"FORM\"];" !="_nestMate = createAgent [\"Epoch_Sapper_F\", _garrPos, [], 0, \"FORM\"];"
5 createDialog !="createDialog 'server_info_picture'" !="createdialog 'epoch_tablet_gui'" !="createdialog 'Epoch_CamDialog'" !="createDialog \"rmx_dynamenu\";" !="createDialog \"rmx_craftingUI\";" !="createDialog \"QuickUpgrade\";" !="createDialog \"QuickTake\";" !="createDialog \"InteractBank\";" !="createdialog \"SelectGender\";" !="_handled = createdialog _dialog;" !="if !(createdialog \"InteractItem\") exitWith {};" !="createDialog _tapDiag;" !="if !(createdialog \"Trade\") exitWith {};" !="_ok = createdialog \"Interact\";" !="_ok = createdialog \"TradeNPCMenu\";" !="createDialog \"Epoch_myGroup\";" !="createDialog (if ((Epoch_my_GroupUID == \"\") && (Epoch_my_Group isEqualTo [])) then {\"EPOCH_createGrp\"} else {\"Epoch_myGroup\"});" !="createDialog \"GroupRequests\";" !="_ok = createdialog \"MissionSelect\";" !="createDialog 'Skaronator_AdminMenu';" !="createDialog \"Epoch_myTempGroup\";" !="createDialog (if ((Epoch_my_tempGroupUID == \"\") && (Epoch_my_tempGroup isEqualTo [])) then {\"EPOCH_createTempGrp\"} else {\"Epoch_myTempGroup\"});" !="createDialog \"tempGroupRequests\";" !="createdialog 'EPOCH_SimpleInput';" 5 createDialog !="createDialog 'server_info_picture'" !="createdialog 'epoch_tablet_gui'" !="createdialog 'Epoch_CamDialog'" !="createDialog \"rmx_dynamenu\";" !="createDialog \"rmx_craftingUI\";" !="createDialog \"QuickUpgrade\";" !="createDialog \"QuickTake\";" !="createDialog \"InteractBank\";" !="createdialog \"SelectGender\";" !="_handled = createdialog _dialog;" !="if !(createdialog \"InteractItem\") exitWith {};" !="createDialog _tapDiag;" !="if !(createdialog \"Trade\") exitWith {};" !="_ok = createdialog \"Interact\";" !="_ok = createdialog \"TradeNPCMenu\";" !="createDialog \"Epoch_myGroup\";" !="createDialog (if ((Epoch_my_GroupUID == \"\") && (Epoch_my_Group isEqualTo [])) then {\"EPOCH_createGrp\"} else {\"Epoch_myGroup\"});" !="createDialog \"GroupRequests\";" !="_ok = createdialog \"MissionSelect\";" !="createDialog 'Skaronator_AdminMenu';" !="createDialog \"Epoch_myTempGroup\";" !="createDialog (if ((Epoch_my_tempGroupUID == \"\") && (Epoch_my_tempGroup isEqualTo [])) then {\"EPOCH_createTempGrp\"} else {\"Epoch_myTempGroup\"});" !="createDialog \"tempGroupRequests\";" !="createdialog 'EPOCH_SimpleInput';" !="createdialog 'PlayerStatsDialog'"
5 createDisplay !="createDisplay \"rmx_dynamenu\";" !="createDisplay \"rmx_moveDynamicHUD\";" !="_parent createdisplay _displayClass;" !="finddisplay 151 createdisplay 'RscDisplayOptionsLayout'" !="_display createdisplay \"RscDisplayDLCPreview\";" 5 createDisplay !="createDisplay \"rmx_dynamenu\";" !="createDisplay \"rmx_moveDynamicHUD\";" !="_parent createdisplay _displayClass;" !="finddisplay 151 createdisplay 'RscDisplayOptionsLayout'" !="_display createdisplay \"RscDisplayDLCPreview\";"
5 deleteMarker !="deleteMarkerLocal _mName;" 5 deleteMarker !="deleteMarkerLocal _mName;"
5 setMarker !="CBA_fnc_setMarkerPersistent\"" !="\\fnc_setMarkerPersistent" !="\"setMarkerPersistent" !="_mName setMarkerShapeLocal _mShape;" !="_mName setMarkerTypeLocal _mType;" !="(_x select 0) setMarkerPosLocal (position player);" !="_zoomMarker setMarkerSizeLocal" 5 setMarker !="CBA_fnc_setMarkerPersistent\"" !="\\fnc_setMarkerPersistent" !="\"setMarkerPersistent" !="_mName setMarkerShapeLocal _mShape;" !="_mName setMarkerTypeLocal _mType;" !="(_x select 0) setMarkerPosLocal (position player);" !="_zoomMarker setMarkerSizeLocal"

View File

@ -0,0 +1,17 @@
disableSerialization;
_display = findDisplay -1200;
_UsedStats = ["CfgEpochClient", "PlayerStatsDialogEntries", []] call EPOCH_fnc_returnConfigEntryV2;
_ctrlNo = 1100;
{
_ctrl = _display displayCtrl _ctrlNo;
_txt = '';
{
_x params ["_stattype","_entrytext",["_calc","%1"]];
_value = missionNamespace getVariable [format ['EPOCH_total%1',_stattype],0];
_value = format [_calc,_value];
_value = call compile _value;
_txt = _txt + format ['<t color=''#ffff00''> %1:</t> %2 <br />',_entrytext,_value];
} foreach _x;
_ctrl ctrlSetStructuredText parseText _txt;
_ctrlNo = _ctrlNo + 1;
} foreach _UsedStats;

View File

@ -26,7 +26,7 @@
_toServer - BOOLEAN: (OPTIONAL): false by default _toServer - BOOLEAN: (OPTIONAL): false by default
*/ */
params [ ["_statType",""], ["_adjust",0], ["_toServer",false] ]; params [ ["_statType",""], ["_adjust",0], ["_toServer",false], ["_isTotal",false]];
if(_statType isEqualTo "")exitWith{ if(_statType isEqualTo "")exitWith{
diag_log "EPOCHDebug: updatePlayerStats -2- stat type not defined"; diag_log "EPOCHDebug: updatePlayerStats -2- stat type not defined";
@ -38,8 +38,11 @@ if(_adjust isEqualTo 0)exitWith{
private _statVarName = format["EPOCH_total%1",_statType]; private _statVarName = format["EPOCH_total%1",_statType];
private _currentStat = missionNameSpace getVariable[_statVarName,0]; private _currentStat = missionNameSpace getVariable[_statVarName,0];
private _newStat = _currentStat + _adjust; private _newStat = _currentStat + _adjust;
if (_isTotal) then {
_newStat = _adjust;
};
missionNameSpace setVariable[_statVarName,_newStat]; missionNameSpace setVariable[_statVarName,_newStat];
if(_toServer)then{ if(_toServer)then{
[player, objNull, _statType, _adjust, false, Epoch_personalToken] remoteExec ["EPOCH_fnc_updatePlayerStats",2]; [player, ObjNull, _statType, _adjust, false, Epoch_personalToken, _isTotal] remoteExec ["EPOCH_fnc_updatePlayerStats",2];
}; };

View File

@ -202,3 +202,18 @@ _playerNuisance = [_playerNuisanceKey,-1,_playerNuisanceMax,_playerNuisanceMin]
// calculate max stamina // calculate max stamina
EPOCH_playerStaminaMax = (100 * (round(_playerAliveTime/360)/10)) min 2500; EPOCH_playerStaminaMax = (100 * (round(_playerAliveTime/360)/10)) min 2500;
if (_isOnFoot) then {
_Walkdist = _lastPlayerPos2 distance (getposATL player);
if (_Walkdist < 150) then {
_TotalWalkDist = _TotalWalkDist + _Walkdist;
["WalkDist",_TotalWalkDist,false,true] call EPOCH_client_updatePlayerStat;
};
};
_lastPlayerPos2 = getposATL player;
if (_playerAliveTime > _MaxAliveTime) then {
_MaxAliveTime = _playerAliveTime;
["MaxAliveTime",_MaxAliveTime,false,true] call EPOCH_client_updatePlayerStat;
};
_PlayTime = _PlayTime + diag_ticktime - _PlayTimeTimer;
["PlayTime",_PlayTime,false,true] call EPOCH_client_updatePlayerStat;
_PlayTimeTimer = diag_ticktime;

View File

@ -95,7 +95,13 @@ _fnc_forceUpdate = {
if !(isNil "_varNameTmp") then {_varName = _varNameTmp}; if !(isNil "_varNameTmp") then {_varName = _varNameTmp};
_customVars pushBack (missionNamespace getVariable [_varName,_defaultVarValues select _foreachindex]); _customVars pushBack (missionNamespace getVariable [_varName,_defaultVarValues select _foreachindex]);
} forEach _customVarNames; } forEach _customVarNames;
[player,_customVars,Epoch_personalToken] remoteExec ["EPOCH_fnc_savePlayer",2]; _stats = [
["WalkDist",round _TotalWalkDist,true],
["MaxAliveTime",_MaxAliveTime,true],
["PlayTime", round _PlayTime, true],
["LootedObjs",missionnamespace getvariable ["EPOCH_totalLootedObjs",0], true]
];
[player,_customVars,Epoch_personalToken,_stats] remoteExec ["EPOCH_fnc_savePlayer",2];
}; };
// disable fuel sources client side. // disable fuel sources client side.
@ -222,6 +228,12 @@ _lootClassesIgnore = ['Default'];
'_cN = configName _x;if !(_cN in _lootClassesIgnore)then{_lootClasses pushBackUnique (toLower _cN)}; true' configClasses _masterConfig; '_cN = configName _x;if !(_cN in _lootClassesIgnore)then{_lootClasses pushBackUnique (toLower _cN)}; true' configClasses _masterConfig;
_lastPlayerPos = getPosATL player; _lastPlayerPos = getPosATL player;
_lastPlayerPos2 = getPosATL player;
_TotalWalkDist = missionnamespace getvariable ["EPOCH_totalWalkDist",0];
_MaxAliveTime = missionnamespace getvariable ["EPOCH_totalMaxAliveTime",0];
_PlayTime = missionnamespace getvariable ["EPOCH_totalPlayTime",0];
_PlayTimeTimer = diag_ticktime;
_pushbacklootedbld = { _pushbacklootedbld = {
private ["_lootCheckBufferLimit"]; private ["_lootCheckBufferLimit"];
_lootCheckBufferLimit = 333; _lootCheckBufferLimit = 333;

View File

@ -28,7 +28,7 @@ if !(false call EPOCH_crafting_checkResources) exitWith {};
//craft button //craft button
[] spawn { [] spawn {
private ["_GiveBackRounds","_TotalroundsIn","_TotalMaxRoundsIn","_roundsCheck","_maxMagrnd","_maxMagRndTmp","_roundsCheckTmp","_magsammosearched","_craftReturn","_needBench","_craftCount","_fnc_UILock","_itemCraftTime","_selection","_craftItem","_item","_itemName","_itemCraftTime","_itemRecipeItems","_itemType","_nearbyReq","_hasNearby","_canCraft","_wH","_nearByHolder","_wHPos"]; private ["_GiveBackRounds","_TotalroundsIn","_TotalMaxRoundsIn","_roundsCheck","_maxMagrnd","_maxMagRndTmp","_roundsCheckTmp","_magsammosearched","_craftReturn","_needBench","_craftCount","_fnc_UILock","_itemCraftTime","_selection","_craftItem","_item","_itemName","_itemCraftTime","_itemRecipeItems","_itemType","_nearbyReq","_hasNearby","_canCraft","_wH","_nearByHolder","_wHPos","_craftedcount"];
disableSerialization; disableSerialization;
_fnc_UILock = { _fnc_UILock = {
@ -55,6 +55,8 @@ if !(false call EPOCH_crafting_checkResources) exitWith {};
_craftReturn = _craftItem param [16,[]]; _craftReturn = _craftItem param [16,[]];
_BulletCalculateOnCraft = ["CfgEpochClient", "BulletCalculateOnCraft", false] call EPOCH_fnc_returnConfigEntryV2; _BulletCalculateOnCraft = ["CfgEpochClient", "BulletCalculateOnCraft", false] call EPOCH_fnc_returnConfigEntryV2;
_craftedcount = 0;
for "_c" from 1 to rmx_var_craftQTYOut do { for "_c" from 1 to rmx_var_craftQTYOut do {
false call _fnc_UILock; false call _fnc_UILock;
@ -131,6 +133,10 @@ if !(false call EPOCH_crafting_checkResources) exitWith {};
} forEach _craftReturn; } forEach _craftReturn;
call EPOCH_crafting_LB_click; call EPOCH_crafting_LB_click;
_craftedcount = _craftedcount + 1;
};
if (_craftedcount > 0) then {
["CraftedItems",_craftedcount,true] call EPOCH_client_updatePlayerStat;
}; };
call EPOCH_crafting_LB_defaults; call EPOCH_crafting_LB_defaults;
true call _fnc_UILock; true call _fnc_UILock;

View File

@ -54,6 +54,7 @@ class CfgClientFunctions
class DefibrillatorUse {}; class DefibrillatorUse {};
class CamUse {}; class CamUse {};
class DefuseBomb {}; class DefuseBomb {};
class PlayerStatsDialog {};
}; };
class building class building
{ {

View File

@ -285,5 +285,17 @@ class e_pad_config
ToggleVar = ""; ToggleVar = "";
ToggleAble = "false"; ToggleAble = "false";
}; };
class PlayerStats
{
ButtonText = "";
Description = "Player Statistic";
icon = "x\addons\a3_epoch_code\Data\UI\epad\PlayerStats.paa";
color[] = {1,1,1,1};
colortoggled[] = {0,1,0,1};
action = "if (isnull (finddisplay -1200)) then {createdialog 'PlayerStatsDialog'};";
Tooltip = "Player Statistic";
ToggleVar = "";
ToggleAble = "false";
};
}; };
}; };

View File

@ -194,8 +194,51 @@ class CfgEpochClient
{"TraderMissions",0,{}}, {"TraderMissions",0,{}},
{"AIKills",0,{}}, {"AIKills",0,{}},
{"AntagonistKills",0,{}}, {"AntagonistKills",0,{}},
{"ZombieKills",0,{}} {"ZombieKills",0,{}},
{"WalkDist",0,{}},
{"MaxAliveTime",0,{}},
{"NPCTrades",0,{}},
{"PlayTime",0,{}},
{"LootedObjs",0,{}},
{"CraftedItems",0,{}},
{"ConnectCount",0,{}},
{"BuildingsSet",0,{}},
{"AIDeaths",0,{}},
}; };
PlayerStatsDialogEntries[] = {
{
{"ConnectCount","Times connected"},
{"PlayTime","Playtime (hours)","%1/3600 toFixed 2"},
{"MaxAliveTime","Max Alivetime (hours)","%1/3600 toFixed 2"},
{"Walkdist","Distance Walked (Km)","%1/1000 toFixed 2"}
},
{
{"LootedObjs","Objects Looted"},
{"NPCTrades","Trades at Trader"},
{"BuildingsSet","Placed Buildings"},
{"CraftedItems","Crafted Items"}
},
{
{"Karma","Karma"},
{"Revives","Player Revived"},
{"TraderMissions","Tradermissions"}
},
{
{"Murders","Player Kills"},
{"AIKills","AI Kills"},
{"AntagonistKills","Antagonist Kills"},
{"ZombieKills","Zombie Kills"}
},
{
{"Deaths","Deaths by Player"},
{"AIDeaths","Deaths by AI"},
{"Suicides","Suicides"}
},
{
{"","K/D PvP","(Epoch_totalMurders/(Epoch_totalDeaths max 1)) toFixed 1"},
{"","K/D PvE","(Epoch_totalAIKills/(Epoch_totalAIDeaths max 1)) toFixed 1"}
}
};
group_upgrade_lvl[] = {4,"1000",6,"1500",8,"2000",10,"2500",12,"3000",14,"3500",16,"4000",32,"8000",64,"16000"}; // controls max group limit and cost group_upgrade_lvl[] = {4,"1000",6,"1500",8,"2000",10,"2500",12,"3000",14,"3500",16,"4000",32,"8000",64,"16000"}; // controls max group limit and cost
// Event handler code // Event handler code
displayAddEventHandler[] = {"keyDown","keyUp"}; displayAddEventHandler[] = {"keyDown","keyUp"};

View File

@ -68,6 +68,7 @@ if (isText _staticClassConfig) then {
if (isDamageAllowed _storageObj) then { // Only needed, if damage is allowed if (isDamageAllowed _storageObj) then { // Only needed, if damage is allowed
_storageObj call EPOCH_server_storageInit; _storageObj call EPOCH_server_storageInit;
}; };
[_player,"BuildingsSet",1,true] call EPOCH_server_updatePlayerStats;
diag_log format["Epoch: STORAGE: %1 created storage %2 at %3 with slot %4", _playerUID, _staticClass, _vehiclePos, _slot]; diag_log format["Epoch: STORAGE: %1 created storage %2 at %3 with slot %4", _playerUID, _staticClass, _vehiclePos, _slot];
}; };
@ -111,6 +112,7 @@ if (isText _staticClassConfig) then {
publicvariable "EPOCH_Plotpoles"; publicvariable "EPOCH_Plotpoles";
}; };
_newVehicle call EPOCH_saveBuilding; _newVehicle call EPOCH_saveBuilding;
[_player,"BuildingsSet",1,true] call EPOCH_server_updatePlayerStats;
}; };
} else { } else {

View File

@ -39,6 +39,7 @@ if (alive _object) then {
_config = (configFile >> "CfgMainTable" >> _payout); _config = (configFile >> "CfgMainTable" >> _payout);
if (isClass _config) then { if (isClass _config) then {
[_player,"LootedObjs",1,true] call EPOCH_server_updatePlayerStats;
if (random 1 < getNumber(_config >> "chance")) then { if (random 1 < getNumber(_config >> "chance")) then {
[_item, _payout] call EPOCH_serverLootObject; [_item, _payout] call EPOCH_serverLootObject;
// force player to open gear on this object. // force player to open gear on this object.

View File

@ -24,6 +24,8 @@ if (_player distance _object > 20) exitWith{};
if !(_object in EPOCH_cleanupQueue) then { if !(_object in EPOCH_cleanupQueue) then {
[_player,"LootedObjs",1,true] call EPOCH_server_updatePlayerStats;
EPOCH_cleanupQueue pushBack _object; EPOCH_cleanupQueue pushBack _object;
_type = typeOf _object; _type = typeOf _object;

View File

@ -12,7 +12,11 @@
Github: Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_fnc_savePlayer.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_fnc_savePlayer.sqf
*/ */
params ["_player","",["_token","",[""]]]; params ["_player","",["_token","",[""]],["_stats",[]]];
if([_player,_token] call EPOCH_server_getPToken)then{ if([_player,_token] call EPOCH_server_getPToken)then{
{
_x params ["_statType","_adjust","_isTotal"];
[_player, _statType, _adjust, false,_isTotal] call Epoch_server_updatePlayerStats;
} foreach _stats;
_this call EPOCH_server_savePlayer; _this call EPOCH_server_savePlayer;
}; };

View File

@ -12,15 +12,18 @@
Github: Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_fnc_updatePlayerStats.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_fnc_updatePlayerStats.sqf
*/ */
params ["_player","_killer","_statType","_adjust","_toClient",["_token","",[""]]]; params ["_player",["_killer",ObjNull],["_statType",""],["_adjust",0],["_toClient",false],["_token","",[""]],["_isTotal",false]];
if(isNull _player)exitWith{ if(isNull _player)exitWith{
diag_log "EPOCHDebug: fnc_updatePlayerStats -1a- player is Null"; diag_log "EPOCHDebug: fnc_updatePlayerStats -1a- player is Null";
}; };
if(isNull _killer)exitWith{ if(!isplayer _player)exitWith{
diag_log "EPOCHDebug: fnc_updatePlayerStats -1b- non local killer is Null"; diag_log "EPOCHDebug: fnc_updatePlayerStats -1b- is not a player";
}; };
if([_player,_token] call EPOCH_server_getPToken)then{ if([_player,_token] call EPOCH_server_getPToken)then{
[_killer, _statType, _adjust, _toClient] call EPOCH_server_updatePlayerStats; if (!isnull _killer) then {
_player = _killer;
};
[_player, _statType, _adjust, _toClient, _isTotal] call EPOCH_server_updatePlayerStats;
}; };

View File

@ -13,7 +13,7 @@
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_checkPlayer.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_checkPlayer.sqf
*/ */
//[[[cog import generate_private_arrays ]]] //[[[cog import generate_private_arrays ]]]
private ["_apperance","_arr","_class","_communityStatsArray","_dead","_deadPlayer","_defaultData","_instanceID","_isMale","_medical","_playerUID","_response","_return","_vars"]; private ["_apperance","_arr","_class","_dead","_deadPlayer","_defaultData","_instanceID","_isMale","_medical","_playerUID","_response","_return","_vars"];
//[[[end]]] //[[[end]]]
params [["_playerObj",objNull],["_fsmHandle",0]]; params [["_playerObj",objNull],["_fsmHandle",0]];
if (_playerObj isEqualType objNull) then { if (_playerObj isEqualType objNull) then {
@ -50,12 +50,6 @@ if (_playerObj isEqualType objNull) then {
}; };
}; };
// check status of community stats to prevent load / save issues
_communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE;
if((_communityStatsArray select 1) isEqualTo []) then{
_return = ["CommunityStats", _playerUID, EPOCH_expiresCommunityStats, [EPOCH_defaultStatVars]] call EPOCH_fnc_server_hiveSETEX;
};
/* true => New Char /* true => New Char
false => load old Char */ false => load old Char */
[_fsmHandle,['_checkPlayer_PVC', _dead]] remoteExecCall ['setFSMVariable', _playerObj]; [_fsmHandle,['_checkPlayer_PVC', _dead]] remoteExecCall ['setFSMVariable', _playerObj];

View File

@ -63,7 +63,7 @@ if (_playerObj != _killer) then {
if(_playerIsNeutral)then{_playerKarmaAdj = abs((-_playerKarma) * 0.03)}; if(_playerIsNeutral)then{_playerKarmaAdj = abs((-_playerKarma) * 0.03)};
if(_playerIsBandit)then{_playerKarmaAdj = abs((-_playerKarma) * 0.055)}; if(_playerIsBandit)then{_playerKarmaAdj = abs((-_playerKarma) * 0.055)};
if(_playerIsHero)then{_playerKarmaAdj = abs((-_playerKarma) * 0.025)}; if(_playerIsHero)then{_playerKarmaAdj = abs((-_playerKarma) * 0.025)};
_deathType = 0;
if!(_killerUID isEqualTo "")then{ if!(_killerUID isEqualTo "")then{
[_killer, "Murders", 1, true] call EPOCH_server_updatePlayerStats; [_killer, "Murders", 1, true] call EPOCH_server_updatePlayerStats;
@ -89,18 +89,21 @@ if (_playerObj != _killer) then {
if(_playerIsHero)then{_killerKarmaAdj = abs((-_killerKarma) * 0.25) + _playerKarmaAdj}; if(_playerIsHero)then{_killerKarmaAdj = abs((-_killerKarma) * 0.25) + _playerKarmaAdj};
}; };
[_killer, "Karma", _killerKarmaAdj, true] call EPOCH_server_updatePlayerStats; [_killer, "Karma", _killerKarmaAdj, true] call EPOCH_server_updatePlayerStats;
_deathType = 1;
}; };
_deathType = 1;
}; };
switch(_deathType)do{ switch(_deathType)do{
case 666: { case 666: {
[_playerObj, "Suicides", 1] call EPOCH_server_updatePlayerStats; [_playerObj, "Suicides", 1, true] call EPOCH_server_updatePlayerStats;
[_playerObj, "Karma", _playerKarmaAdj] call EPOCH_server_updatePlayerStats; [_playerObj, "Karma", _playerKarmaAdj, true] call EPOCH_server_updatePlayerStats;
}; };
case 1: { case 1: {
[_playerObj, "Deaths", 1] call EPOCH_server_updatePlayerStats; [_playerObj, "Deaths", 1, true] call EPOCH_server_updatePlayerStats;
[_playerObj, "Karma", _playerKarmaAdj] call EPOCH_server_updatePlayerStats; [_playerObj, "Karma", _playerKarmaAdj, true] call EPOCH_server_updatePlayerStats;
};
case 0: {
[_playerObj, "AIDeaths", 1, true] call EPOCH_server_updatePlayerStats;
}; };
}; };
_defaultVars = call EPOCH_defaultVars_SEPXVar; _defaultVars = call EPOCH_defaultVars_SEPXVar;
@ -114,6 +117,9 @@ if (_current_crypto > 0) then{
diag_log format["Epoch: ADMIN: Crypto added to dead body for %1 with %2 at %3", getPlayerUID _playerObj, _current_crypto, _pos]; diag_log format["Epoch: ADMIN: Crypto added to dead body for %1 with %2 at %3", getPlayerUID _playerObj, _current_crypto, _pos];
}; };
// save community stats (skipped in EPOCH_server_savePlayer for dead Players)
["CommunityStats", _playerUID, EPOCH_expiresCommunityStats, [_playerObj getVariable["COMMUNITY_STATS", EPOCH_defaultStatVars]]] call EPOCH_fnc_server_hiveSETEX;
[_playerObj, _defaultVars] call EPOCH_server_savePlayer; [_playerObj, _defaultVars] call EPOCH_server_savePlayer;
// death cost // death cost

View File

@ -243,6 +243,23 @@ if (!isNull _player) then {
// load community stats // load community stats
_communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE; _communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE;
_communityStats = (_communityStatsArray param [1,[]]) param [0,[]]; _communityStats = (_communityStatsArray param [1,[]]) param [0,[]];
if (_communityStats isEqualTo []) then {
_communityStats = EPOCH_defaultStatVars;
};
if (count _communityStats < EPOCH_communityStatsCount) then {
{
private _check = _communityStats select _foreachindex;
if (isnil '_check') then {
_communityStats pushback _x;
};
} foreach EPOCH_defaultStatVars;
};
_Index = EPOCH_communityStats find "ConnectCount";
if (_Index > -1) then {
_currentStat = _communityStats select _Index;
_communityStats set[_Index, _currentStat + 1];
};
_newPlyr setVariable["COMMUNITY_STATS", _communityStats]; _newPlyr setVariable["COMMUNITY_STATS", _communityStats];
// Flag new body as ready for use. // Flag new body as ready for use.

View File

@ -157,6 +157,7 @@ if (!local _player) then {
_vars set[_cIndex, _PlayerCrypto]; _vars set[_cIndex, _PlayerCrypto];
_newPlyr setVariable['VARS', _vars]; _newPlyr setVariable['VARS', _vars];
}; };
_newPlyr setvariable ["COMMUNITY_STATS",_player getVariable["COMMUNITY_STATS", EPOCH_defaultStatVars]];
// send to player // send to player
[_newPlyr, _token, _loadabs] remoteExec ['EPOCH_clientRevive',_player]; [_newPlyr, _token, _loadabs] remoteExec ['EPOCH_clientRevive',_player];

View File

@ -31,7 +31,7 @@
by setting this true the client will receive the stat update. by setting this true the client will receive the stat update.
Use true when the stat change originates from the server and not the client. Use true when the stat change originates from the server and not the client.
*/ */
params [ ["_playerObj",objNull], ["_statType",""], ["_adjust",0], ["_toClient",false] ]; params [ ["_playerObj",objNull], ["_statType",""], ["_adjust",0], ["_toClient",false], ["_isTotal",false]];
if(isNull _playerObj)exitWith{ if(isNull _playerObj)exitWith{
diag_log "EPOCHDebug: playerUpdateStats -1- player is null object"; diag_log "EPOCHDebug: playerUpdateStats -1- player is null object";
@ -46,22 +46,33 @@ _playerUID = getplayerUID _playerObj;
if(_playerUID isEqualTo "")exitWith{ if(_playerUID isEqualTo "")exitWith{
diag_log "EPOCHDebug: playerUpdateStats -4- player UID is empty"; diag_log "EPOCHDebug: playerUpdateStats -4- player UID is empty";
}; };
if(!isplayer _playerObj)exitWith{
diag_log "EPOCHDebug: playerUpdateStats -5- is not a player";
};
//get this playerObj stats //get this playerObj stats
_playerStats = _playerObj getVariable["COMMUNITY_STATS", EPOCH_defaultStatVars]; _playerStats = _playerObj getVariable["COMMUNITY_STATS", EPOCH_defaultStatVars];
//get this stats index # //get this stats index #
_sIndex = EPOCH_communityStats find _statType; _sIndex = EPOCH_communityStats find _statType;
//get this stat value if (_sIndex > -1) then {
_currentStat = _playerStats select _sIndex; //get this stat value
//set the new stat value _currentStat = _playerStats select _sIndex;
_playerStats set[_sIndex, _currentStat + _adjust]; //set the new stat value
//set the new stats array back onto this playerObj if (_isTotal) then {
_playerObj setVariable["COMMUNITY_STATS", _playerStats]; _playerStats set[_sIndex, _adjust];
}
else {
_playerStats set[_sIndex, _currentStat + _adjust];
};
//set the new stats array back onto this playerObj
_playerObj setVariable["COMMUNITY_STATS", _playerStats];
//send to hive //send to hive
["CommunityStats", _playerUID, EPOCH_expiresCommunityStats, [_playerStats]] call EPOCH_fnc_server_hiveSETEX; // ["CommunityStats", _playerUID, EPOCH_expiresCommunityStats, [_playerStats]] call EPOCH_fnc_server_hiveSETEX;
// Prevent saving to DB too much often, as it is already saved on Player Save Loop / Disconnect / Kill
//send to player //send to player
if(_toClient)then{ if(_toClient)then{
[_statType,_adjust] remoteExecCall ["EPOCH_client_updatePlayerStat",(owner _playerObj)]; [_statType,_adjust,false,_isTotal] remoteExecCall ["EPOCH_client_updatePlayerStat",(owner _playerObj)];
};
}; };

View File

@ -334,6 +334,12 @@ if (_slot != -1) then {
_current_crypto remoteExec ['EPOCH_effectCrypto',_player]; _current_crypto remoteExec ['EPOCH_effectCrypto',_player];
_vars set[_cIndex, _current_crypto]; _vars set[_cIndex, _current_crypto];
_player setVariable["VARS", _vars]; _player setVariable["VARS", _vars];
// Update Player Stats
_kIndex = EPOCH_communityStats find "NPCTrades";
if (_kIndex > -1) then {
[_player, "NPCTrades", 1, true] call EPOCH_server_updatePlayerStats;
};
}; };
}; };