Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_AnalyticsDataCollectionPlayerKicksModule.c
Go to the documentation of this file.
3{
6
7 //------------------------------------------------------------------------------------------------
8 protected override void Enable()
9 {
10 super.Enable();
11
12 SCR_VotingManagerComponent votingManager = SCR_VotingManagerComponent.GetInstance();
13 if (votingManager)
14 votingManager.GetOnVotingStart().Insert(OnVotingStart);
15 }
16
17 //------------------------------------------------------------------------------------------------
18 protected override void Disable()
19 {
20 super.Disable();
21
22 SCR_VotingManagerComponent votingManager = SCR_VotingManagerComponent.GetInstance();
23 if (votingManager)
24 votingManager.GetOnVotingStart().Remove(OnVotingStart);
25 }
26
27 //------------------------------------------------------------------------------------------------
28 protected override void OnGameModeEnd()
29 {
30 // TODO: Handle data to send them to analytics db
31 }
32
33 //------------------------------------------------------------------------------------------------
34 protected override void OnPlayerConnected(int playerId)
35 {
36 if (m_mPlayerVoteKickProposals.Contains(playerId) && m_mPlayerVoteKicks.Contains(playerId))
37 return;
38
39 m_mPlayerVoteKickProposals.Insert(playerId, 0);
40 m_mPlayerVoteKicks.Insert(playerId, 0);
41 }
42
43 //------------------------------------------------------------------------------------------------
47 protected void OnVotingStart(EVotingType type, int playerId)
48 {
49 // Only vote to kick player is relevant
50 if (type != EVotingType.KICK)
51 return;
52
53 int kickProposals = m_mPlayerVoteKickProposals.Get(playerId) + 1;
54 m_mPlayerVoteKickProposals.Set(playerId, kickProposals);
55
57 if (!sessionEvent)
58 return;
59
60 int allKickProposals;
61 foreach (int currentPlayerId, int playerKickProposals : m_mPlayerVoteKickProposals)
62 {
63 allKickProposals += playerKickProposals;
64 }
65
66 sessionEvent.num_players_kick_proposed = allKickProposals;
67 }
68
69 //------------------------------------------------------------------------------------------------
70 protected override void OnPlayerDisconnected(int playerId, KickCauseCode cause, IEntity controlledEntity = null)
71 {
72 if (!m_bIsEnabled)
73 return;
74
75 string groupId, reasonId;
76 KickCauseGroup2 groupInt;
77 int reasonInt;
78
79 // Only player kicks due to voting are relevant
80 GetGame().GetFullKickReason(cause, groupInt, reasonInt, groupId, reasonId);
81 if (groupInt != KickCauseGroup2.PLAYER_MANAGER || reasonInt != PlayerManagerKickReason.KICK_VOTED)
82 return;
83
84 int voteKicks = m_mPlayerVoteKicks.Get(playerId) + 1;
85 m_mPlayerVoteKicks.Set(playerId, voteKicks);
86
88 if (!sessionEvent)
89 return;
90
91 int allVoteKicks;
92 foreach (int currentPlayerId, int playerKicks : m_mPlayerVoteKicks)
93 {
94 allVoteKicks += playerKicks;
95 }
96
97 sessionEvent.num_players_kick_voted = allVoteKicks;
98 }
99
100 #ifdef ENABLE_DIAG
101 //------------------------------------------------------------------------------------------------
102 override void DrawContent()
103 {
104 if (!m_bIsEnabled)
105 {
106 DbgUI.Text("Module disabled!");
107 return;
108 }
109
110 string playerName;
111 int voteKicks;
112 foreach (int playerID, int voteKickProposals : m_mPlayerVoteKickProposals)
113 {
114 playerName = GetGame().GetPlayerManager().GetPlayerName(playerID);
115 voteKicks = m_mPlayerVoteKicks.Get(playerID);
116 DbgUI.Text(string.Format("Player %1 - %2 voted to be kicked %3 times and has been kicked %4 times", playerID, playerName, voteKickProposals, voteKicks));
117 }
118 }
119 #endif
120
121 //------------------------------------------------------------------------------------------------
123 {
124 Disable();
125 }
126}
EVotingType
Definition EVotingType.c:2
ArmaReforgerScripted GetGame()
Definition game.c:1398
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
EDamageType type
void SCR_VotingManagerComponent(IEntityComponentSource src, IEntity ent, IEntity parent)
Definition DbgUI.c:66
override void OnPlayerDisconnected(int playerId, KickCauseCode cause, IEntity controlledEntity=null)
Definition Types.c:486
KickCauseGroup2
Extends KickCauseGroup by adding game-specific groups.
PlayerManagerKickReason