From 396d0313b3ab07dcb7d3bd08482e81fd53cdb319 Mon Sep 17 00:00:00 2001 From: A Man Date: Wed, 13 May 2020 16:12:31 +0200 Subject: [PATCH] Update groups, add player name on group message --- SQF/dayz_code/groups/filter.sqf | 4 +-- SQF/dayz_code/groups/groupMarkers.sqf | 26 +++++++++---------- SQF/dayz_code/groups/groupTags.sqf | 20 +++++++-------- SQF/dayz_code/groups/handleInvite.sqf | 24 ++++++++++-------- SQF/dayz_code/groups/init.sqf | 6 ++--- SQF/dayz_code/groups/invite.sqf | 4 +-- SQF/dayz_code/groups/open.sqf | 28 ++++++++++----------- SQF/dayz_code/groups/server_updateGroup.sqf | 20 +++++++-------- 8 files changed, 68 insertions(+), 64 deletions(-) diff --git a/SQF/dayz_code/groups/filter.sqf b/SQF/dayz_code/groups/filter.sqf index c97bd222e..228bd85aa 100644 --- a/SQF/dayz_code/groups/filter.sqf +++ b/SQF/dayz_code/groups/filter.sqf @@ -2,9 +2,9 @@ private "_group"; _group = []; { - if (damage _x < 1 && isPlayer _x) then { + if (damage _x < 1 && {isPlayer _x}) then { _group set [count _group,_x]; }; } count (units group _this); -_group \ No newline at end of file +_group diff --git a/SQF/dayz_code/groups/groupMarkers.sqf b/SQF/dayz_code/groups/groupMarkers.sqf index cb4453e17..bd04f7c42 100644 --- a/SQF/dayz_code/groups/groupMarkers.sqf +++ b/SQF/dayz_code/groups/groupMarkers.sqf @@ -14,10 +14,10 @@ while {true} do { 8 cutText ["","PLAIN"]; localize "STR_EPOCH_LOST_RADIO_CONTACT" call dayz_rollingMessages; } else { - if (_inGroup && scriptDone dayz_groupTags) then { + if (_inGroup && {scriptDone dayz_groupTags}) then { dayz_groupTags = execVM "\z\addons\dayz_code\groups\groupTags.sqf"; }; - + if (!isNull _lastGroup && {"ItemRadio" in items player}) then { _oldGroup = group player; [player] joinSilent _lastGroup; @@ -27,18 +27,18 @@ while {true} do { publicVariableServer "PVDZ_Server_UpdateGroup"; _lastGroup = grpNull; }; - + if (visibleMap or !isNull (uiNamespace getVariable["BIS_RscMiniMap",displayNull])) then { _hasGPS = "ItemGPS" in items player; - _markBody = (dayz_markBody == 1 or (dayz_markBody == 2 && _hasGPS)); - _markGroup = (dayz_markGroup == 1 or (dayz_markGroup == 2 && _hasGPS)); - _markSelf = (dayz_markSelf == 1 or (dayz_markSelf == 2 && _hasGPS)); - + _markBody = (dayz_markBody == 1 or (dayz_markBody == 2 && {_hasGPS})); + _markGroup = (dayz_markGroup == 1 or (dayz_markGroup == 2 && {_hasGPS})); + _markSelf = (dayz_markSelf == 1 or (dayz_markSelf == 2 && {_hasGPS})); + _index = 0; { _self = _x == player; _vehicle = vehicle _x; - if ((_self or _markGroup) && (!_self or _markSelf) && (effectiveCommander _vehicle == _x)) then { + if ((_self or _markGroup) && {!_self or _markSelf} && {effectiveCommander _vehicle == _x}) then { _pos = [_x] call FNC_GetPos; deleteMarkerLocal format["groupMember%1",_index]; _marker = createMarkerLocal [format["groupMember%1",_index],_pos]; @@ -50,14 +50,14 @@ while {true} do { }; _index = _index + 1; } count _group; - + // Remove markers for group members that left _count = count _group; if (dayz_oldMemberCount > _count) then { for "_i" from _count to dayz_oldMemberCount do {deleteMarkerLocal format["groupMember%1",_i];}; }; dayz_oldMemberCount = _count; - + if (_markBody) then { _bodyCount = 0; _name = name player; @@ -74,7 +74,7 @@ while {true} do { }; }; } count allDead; - + // Remove markers for bodies that were deleted if (dayz_oldBodyCount > _bodyCount) then { for "_i" from _bodyCount to dayz_oldBodyCount do {deleteMarkerLocal format["MyBody%1",_i];}; @@ -85,6 +85,6 @@ while {true} do { }; }; }; - + uiSleep 1; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/groups/groupTags.sqf b/SQF/dayz_code/groups/groupTags.sqf index 9d57fb0c9..be03c18ec 100644 --- a/SQF/dayz_code/groups/groupTags.sqf +++ b/SQF/dayz_code/groups/groupTags.sqf @@ -1,22 +1,22 @@ -#define DRAW_TAGS (!visibleMap && count units group player > 1) //Use && cameraView != "GROUP" if tactical view is allowed (blocked by default) -private ["_display","_distance","_group","_icon","_index","_pos","_scale","_screen","_text"]; +#define DRAW_TAGS (!visibleMap && {count units group player > 1}) //Use && cameraView != "GROUP" if tactical view is allowed (blocked by default) +private ["_display","_distance","_group","_icon","_index","_pos","_scale","_screen","_text","_refresh"]; disableSerialization; _refresh = { _group = player call dayz_filterGroup; - + _display = uiNamespace getVariable "DZ_GroupTags"; _index = 0; { _pos = [_x] call FNC_GetPos; _distance = _pos distance player; _icon = _display displayCtrl (100 + _index); - if (_distance > 1 && _distance < 2500 && vehicle _x != vehicle player) then { + if (_distance > 1 && {_distance < 2500} && {vehicle _x != vehicle player}) then { _pos set [2,(_pos select 2) + 1.5]; _screen = worldToScreen _pos; _text = composeText [image "\ca\ui\data\igui_side_unknown_ca.paa"," ",if (dayz_groupNameTags) then {name _x} else {""}]; if (count _screen > 1) then { - _scale = if (_distance < 200) then {.3} else {1 min ((1 - (_distance - 3) / 15) max .3)}; + _scale = [1 min ((1 - (_distance - 3) / 15) max .3),.3] select (_distance < 200); _icon ctrlSetStructuredText _text; _icon ctrlSetPosition [(_screen select 0),(_screen select 1),.99,.65]; _icon ctrlSetScale _scale; @@ -31,22 +31,22 @@ _refresh = { }; _index = _index + 1; } count _group; - + if (dayz_oldGroupCount > count _group) then { _display displayCtrl (100 + _index) ctrlShow false; }; - + dayz_oldGroupCount = count _group; }; while {true} do { waitUntil {uiSleep 1; DRAW_TAGS}; 8 cutRsc ["DZ_GroupTags","PLAIN"]; - + while {DRAW_TAGS} do { call _refresh; //Must be called to finish in current frame uiSleep 0.01; }; - + 8 cutText ["","PLAIN"]; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/groups/handleInvite.sqf b/SQF/dayz_code/groups/handleInvite.sqf index 5051d23b3..769c38752 100644 --- a/SQF/dayz_code/groups/handleInvite.sqf +++ b/SQF/dayz_code/groups/handleInvite.sqf @@ -4,14 +4,14 @@ _add = _this select 0; _uid = _this select 1; if (typeName _add == "SCALAR") exitWith { - switch _add do { - case -1: { //Promote + call { + if (_add == -1) exitWith { //Promote (group player) selectLeader _uid; }; - case 1: { + if (_add == 1) exitWith { systemChat format[localize "STR_EPOCH_PLAYER_JOINED",_uid]; }; - case 2: { + if (_add == 2) exitWith { if (_uid == getPlayerUID player) then { localize "STR_EPOCH_GROUP_KICKED" call dayz_rollingMessages; terminate dayz_groupTags; @@ -20,14 +20,14 @@ if (typeName _add == "SCALAR") exitWith { systemChat format[localize "STR_EPOCH_PLAYER_KICKED",name (_uid call dayz_getPlayer)]; }; }; - case 3: { + if (_add == 3) exitWith { systemChat format[localize "STR_EPOCH_PLAYER_LEFT",_uid]; if (count (player call dayz_filterGroup) == 1) then { terminate dayz_groupTags; 8 cutText ["","PLAIN"]; }; }; - case 4: { + if (_add == 4) exitWith { localize "STR_EPOCH_GROUP_DISBANDED" call dayz_rollingMessages; terminate dayz_groupTags; 8 cutText ["","PLAIN"]; @@ -40,8 +40,12 @@ if (_add) then { _inviter = _uid select 0; _recipient = _uid select 1; dayz_activeInvites set [count dayz_activeInvites,_uid]; - if (!isDedicated && {_recipient == getPlayerUID player} && {!dayz_requireRadio or {dayz_requireRadio && "ItemRadio" in items player}}) then { - localize "STR_EPOCH_INVITE_NEW" call dayz_rollingMessages; + if (!isDedicated && {_recipient == getPlayerUID player} && {!dayz_requireRadio or {dayz_requireRadio && {"ItemRadio" in items player}}}) then { + private "_name"; + + _name = toString(_uid select 2); + + format[localize "STR_EPOCH_INVITE_NEW",_name] call dayz_rollingMessages; }; } else { // Remove all invites to this player @@ -60,9 +64,9 @@ if (isServer) then { PVDZ_groupInvite = _this; { _unit = getPlayerUID _x; - if (_unit != "" && ((!_add && _unit != _recipient) or (_add && _unit != _inviter))) then { + if (_unit != "" && {(!_add && {_unit != _recipient}) or (_add && {_unit != _inviter})}) then { // Don't use regular PV because JIP clients don't need it (dayz_activeInvites is synced to them in server_playerLogin) owner _x publicVariableClient "PVDZ_groupInvite"; }; } count allUnits; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/groups/init.sqf b/SQF/dayz_code/groups/init.sqf index 34fcafa4c..3522c7dff 100644 --- a/SQF/dayz_code/groups/init.sqf +++ b/SQF/dayz_code/groups/init.sqf @@ -8,7 +8,7 @@ if (count (units group player) > 1) then { _savedGroup = (PVCDZ_plr_Login select 10) - [getPlayerUID player]; -if (count _savedGroup > 0 && {!dayz_requireRadio or {dayz_requireRadio && "ItemRadio" in items player}}) then { +if (count _savedGroup > 0 && {!dayz_requireRadio or {dayz_requireRadio && {"ItemRadio" in items player}}}) then { { //Only auto join player into group if leader is in their savedGroup _leader = leader _x; @@ -17,7 +17,7 @@ if (count _savedGroup > 0 && {!dayz_requireRadio or {dayz_requireRadio && "ItemR [player] joinSilent _x; if (count (units _oldGroup) == 0) then {deleteGroup _oldGroup;}; format[localize "STR_EPOCH_REJOINED_GROUP",name _leader] call dayz_rollingMessages; - + // Update saved group in DB PVDZ_Server_UpdateGroup = [1,player]; publicVariableServer "PVDZ_Server_UpdateGroup"; @@ -48,4 +48,4 @@ dayz_groupDisbandThread = 0 spawn {}; dayz_groupLeaveThread = 0 spawn {}; dayz_groupTags = 0 spawn {}; -execVM "\z\addons\dayz_code\groups\groupMarkers.sqf"; \ No newline at end of file +execVM "\z\addons\dayz_code\groups\groupMarkers.sqf"; diff --git a/SQF/dayz_code/groups/invite.sqf b/SQF/dayz_code/groups/invite.sqf index 846fd90de..dce31b7b1 100644 --- a/SQF/dayz_code/groups/invite.sqf +++ b/SQF/dayz_code/groups/invite.sqf @@ -20,7 +20,7 @@ if (_hasInvite) exitWith { systemChat localize "STR_EPOCH_INVITE_PENDING"; }; -_invite = [getPlayerUID player,_uid]; +_invite = [getPlayerUID player,_uid,toArray(name player)]; //Update locally with change dayz_activeInvites set [count dayz_activeInvites,_invite]; @@ -29,4 +29,4 @@ dayz_activeInvites set [count dayz_activeInvites,_invite]; PVDZ_groupInvite = [true,_invite]; publicVariableServer "PVDZ_groupInvite"; -systemChat format[localize "STR_EPOCH_INVITE_TO",name _recipient]; \ No newline at end of file +systemChat format[localize "STR_EPOCH_INVITE_TO",name _recipient]; diff --git a/SQF/dayz_code/groups/open.sqf b/SQF/dayz_code/groups/open.sqf index 772516f10..ebb7cfc22 100644 --- a/SQF/dayz_code/groups/open.sqf +++ b/SQF/dayz_code/groups/open.sqf @@ -1,6 +1,6 @@ if (!isNull findDisplay 80000) exitWith {}; -private ["_disbandButton","_display","_group","_index","_inviteButton","_inviter","_inviterUID","_kickButton","_leader","_leaveButton","_myGroup","_newCount","_playerList","_promoteButton","_uid"]; +private ["_disbandButton","_display","_group","_index","_inviteButton","_inviter","_inviterUID","_kickButton","_leader","_leaveButton","_myGroup","_newCount","_playerList","_promoteButton","_uid","_joinButton","_rejectButton","_inviteText","_hasInvite"]; disableSerialization; createDialog "DZ_GroupDialog"; _display = findDisplay 80000; @@ -24,21 +24,21 @@ while {!isNull findDisplay 80000} do { _leader = leader _group; lbClear _myGroup; { - if (alive _x && isPlayer _x) then { + if (alive _x && {isPlayer _x}) then { _index = _myGroup lbAdd (name _x); _myGroup lbSetData [_index,getPlayerUID _x]; _myGroup lbSetPicture [_index, if (_x == _leader) then {"\ca\ui\data\icon_unit_teamleader_ca.paa"} else {"\ca\ui\data\map_bush_ca.paa"}]; }; } count (units _group); lbSort _myGroup; - + if (lbSize _myGroup > 1) then { if (scriptDone dayz_groupLeaveThread) then { _leaveButton ctrlShow true; } else { _leaveButton ctrlShow false; }; - if (player == _leader && scriptDone dayz_groupDisbandThread) then { + if (player == _leader && {scriptDone dayz_groupDisbandThread}) then { _disbandButton ctrlShow true; } else { _disbandButton ctrlShow false; @@ -46,7 +46,7 @@ while {!isNull findDisplay 80000} do { } else { {_x ctrlShow false} count [_disbandButton,_leaveButton,_kickButton,_promoteButton]; }; - + _hasInvite = false; { if (_x select 1 == _uid) then { @@ -54,33 +54,33 @@ while {!isNull findDisplay 80000} do { _inviterUID = _x select 0; //Take most recent invite }; } forEach dayz_activeInvites; - + if (_hasInvite) then { {_x ctrlShow true} count [_inviteText,_joinButton,_rejectButton]; - _inviter = _inviterUID call dayz_getPlayer; + _inviter = _inviterUID call dayz_getPlayer; if (!isNull _inviter) then { _inviteText ctrlSetStructuredText parseText (format ["%1
%2",localize "STR_EPOCH_INVITE_FROM",name _inviter]); }; } else { {_x ctrlShow false} count [_inviteText,_joinButton,_rejectButton]; }; - + _newCount = playersNumber west; - + if (dayz_oldPlayerCount != _newCount) then { //Refresh player list lbClear _playerList; { - if (isPlayer _x && _x != player) then { + if (isPlayer _x && {_x != player}) then { _index = _playerList lbAdd (name _x); _playerList lbSetData [_index, getPlayerUID _x]; _playerList lbSetPicture [_index, if (count (units group _x) > 1) then {"\ca\ui\data\ui_task_failed_ca.paa"} else {"\ca\ui\data\ui_task_done_ca.paa"}]; - }; + }; } count allUnits; lbSort _playerList; }; - + dayz_oldPlayerCount = _newCount; - + uiSleep 1; -}; \ No newline at end of file +}; diff --git a/SQF/dayz_code/groups/server_updateGroup.sqf b/SQF/dayz_code/groups/server_updateGroup.sqf index 97da91727..c1b8b6ba8 100644 --- a/SQF/dayz_code/groups/server_updateGroup.sqf +++ b/SQF/dayz_code/groups/server_updateGroup.sqf @@ -2,8 +2,8 @@ private ["_event","_groupUIDs","_kickedUID","_name","_newGroup","_player","_play _event = _this select 0; _player = _this select 1; -_kickedUID = if (count _this > 2) then {_this select 2} else {"0"}; -_name = if (alive _player) then {name _player} else {"unknown"}; +_kickedUID = ["0",_this select 2] select (count _this > 2); +_name = ["unknown",name _player] select (alive _player); _playerUID = getPlayerUID _player; if (_event < 3) then { @@ -22,29 +22,29 @@ if (_event == -1) exitWith { _groupUIDs = []; { - if (damage _x < 1 && isPlayer _x) then { + if (damage _x < 1 && {isPlayer _x}) then { _groupUIDs set [count _groupUIDs,getPlayerUID _x]; }; } count (units group _player); _newGroup = []; -_newGroup = switch _event do { +_newGroup = call { //Join - case 1: {_groupUIDs}; + if (_event == 1) exitwith {_groupUIDs}; //Kick (target was already kicked from group) - case 2: { + if (_event == 2) exitwith { _name = _kickedUID; format["CHILD:204:%1:%2:%3:",_name,dayZ_instance,[]] call server_hiveWrite; _groupUIDs }; //Leave - case 3: { + if (_event == 3) exitwith { dayz_groupLeft = true; (owner _player) publicVariableClient "dayz_groupLeft"; (_groupUIDs - [_playerUID]) }; //Disband - case 4: { + if (_event == 4) exitwith { _name = 0; //Not needed dayz_groupDisbanded = true; (owner _player) publicVariableClient "dayz_groupDisbanded"; @@ -54,7 +54,7 @@ _newGroup = switch _event do { //Update all group members' saved group in DB { - _save = if (_event == 3 && _x == _playerUID) then {[]} else {_newGroup}; + _save = [_newGroup,[]] select (_event == 3 && {_x == _playerUID}); format["CHILD:204:%1:%2:%3:",_x,dayZ_instance,_save] call server_hiveWrite; } count _groupUIDs; @@ -66,4 +66,4 @@ _groupUIDs set [count _groupUIDs,_kickedUID]; if (_unit in _groupUIDs && {_unit != _playerUID}) then { owner _x publicVariableClient "PVDZ_groupInvite"; }; -} count allUnits; \ No newline at end of file +} count allUnits;