-
Notifications
You must be signed in to change notification settings - Fork 7
/
Spectator.hpp
53 lines (46 loc) · 1.72 KB
/
Spectator.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#pragma once
#include <iostream>
#include <vector>
#include <array>
#include "Player.hpp"
#include "LocalPlayer.hpp"
struct Spectator {
// Variables
LocalPlayer* Myself;
std::vector<Player*>* Players;
int TotalSpectators = 0;
std::vector<std::string> Spectators;
std::chrono::milliseconds LastUpdateTime = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
Spectator(std::vector<Player*>* Players, LocalPlayer* Myself) {
this->Players = Players;
this->Myself = Myself;
}
void Update() {
std::chrono::milliseconds Now = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::system_clock::now().time_since_epoch());
if (Now >= LastUpdateTime + std::chrono::milliseconds(1500))
{
int TempTotalSpectators = 0;
std::vector<std::string> TempSpectators;
for (int i = 0; i < Players->size(); i++)
{
Player* p = Players->at(i);
if (!mem.IsValidPointer(p->BasePointer))
continue;
if (p->BasePointer == Myself->BasePointer)
continue;
if (!p->IsPlayer())
continue;
if (p->ViewYaw == 0 || Myself->ViewYaw == 0)
continue;
if (std::fabs(p->ViewYaw - Myself->ViewYaw) < 0.1f && p->IsDead)
{
std::cout << "Spec: " << p->ViewYaw << ", Play: " << Myself->ViewYaw << std::endl;
TempTotalSpectators++;
}
}
TotalSpectators = TempTotalSpectators;
Spectators = TempSpectators;
LastUpdateTime = Now;
}
}
};