generated from YimMenu/YimMenuV2
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bump RDR-Classes, Features, Protection Improvements, Casing Changes (#…
…163) * Bump RDR-Classes, Features, Protection Improvements, * Update increase bounty * Update * Casing fixes, removed duplicate autotp command * Ticker event * Update, not done * Add missing command to menu * Fix horrid indention (thank you github) * Added some more stuff * Removed double include * Fix indent * Untested pool overflow protection * fix githubs mistakes * uh. fix ci? * fix ci
- Loading branch information
Showing
52 changed files
with
609 additions
and
187 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#pragma once | ||
#include <chrono> | ||
|
||
namespace YimMenu | ||
{ | ||
class RateLimiter | ||
{ | ||
uint32_t m_AttemptsAllowedInTimePeriod; | ||
std::chrono::milliseconds m_TimePeriod; | ||
std::chrono::system_clock::time_point m_LastEventTime{}; | ||
uint32_t m_NumAttemptsAllowed = 0; | ||
|
||
public: | ||
RateLimiter(std::chrono::milliseconds period, uint32_t numAllowedAttempts) : | ||
m_AttemptsAllowedInTimePeriod(numAllowedAttempts), | ||
m_TimePeriod(period) | ||
{ | ||
} | ||
|
||
// Returns true if the rate limit has been exceeded | ||
bool Process() | ||
{ | ||
if (std::chrono::system_clock::now() - m_LastEventTime < m_TimePeriod) | ||
{ | ||
if (++m_NumAttemptsAllowed > m_AttemptsAllowedInTimePeriod) | ||
return true; | ||
} | ||
else | ||
{ | ||
m_LastEventTime = std::chrono::system_clock::now(); | ||
m_NumAttemptsAllowed = 1; | ||
} | ||
return false; | ||
} | ||
|
||
// Check if the rate limit was exceeded by the last process() call. Use this to prevent the player from being flooded with notifications | ||
bool ExceededLastProcess() | ||
{ | ||
return (m_NumAttemptsAllowed - 1) == m_AttemptsAllowedInTimePeriod; | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "game/backend/ScriptMgr.hpp" | ||
#include "game/backend/Self.hpp" | ||
#include "game/commands/PlayerCommand.hpp" | ||
#include "game/rdr/Enums.hpp" | ||
#include "game/rdr/Scripts.hpp" | ||
|
||
namespace YimMenu::Features | ||
{ | ||
void ParlayEnd(Player player) | ||
{ | ||
uint64_t data[7]{}; | ||
data[0] = static_cast<uint64_t>(ScriptEvent::SCRIPT_EVENT_PARLAY); | ||
data[1] = player.GetId(); | ||
data[4] = 5; | ||
data[5] = 11; | ||
data[6] = 9; | ||
Scripts::SendScriptEvent(data, 9, 10, 1 << player.GetId()); | ||
} | ||
|
||
class EndParlay : public PlayerCommand | ||
{ | ||
using PlayerCommand::PlayerCommand; | ||
|
||
virtual void OnCall(Player player) override | ||
{ | ||
ParlayEnd(player); | ||
} | ||
}; | ||
|
||
static EndParlay _EndParlay{"endparlay", "End Parlay", "End a parlay with the player", 0, false}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#include "game/backend/ScriptMgr.hpp" | ||
#include "game/backend/Self.hpp" | ||
#include "game/commands/PlayerCommand.hpp" | ||
#include "game/rdr/Enums.hpp" | ||
#include "game/rdr/Scripts.hpp" | ||
|
||
namespace YimMenu::Features | ||
{ | ||
void AddBounty(Player player) | ||
{ | ||
uint64_t data[13]{}; | ||
data[0] = static_cast<uint64_t>(ScriptEvent::SCRIPT_EVENT_NOTORIETY_PRESS_CHARGES); | ||
data[1] = player.GetId(); | ||
data[4] = 2; | ||
data[5] = 5; | ||
data[6] = 9; | ||
data[11] = 1; | ||
data[12] = 1; | ||
|
||
for (int i = 0; i < 10; ++i) | ||
{ | ||
for (int j = 0; j < 10; ++j) | ||
{ | ||
Scripts::SendScriptEvent(data, 13, 7, 1 << player.GetId()); | ||
} | ||
|
||
ScriptMgr::Yield(); | ||
} | ||
} | ||
|
||
class IncreaseBounty : public PlayerCommand | ||
{ | ||
using PlayerCommand::PlayerCommand; | ||
|
||
virtual void OnCall(Player player) override | ||
{ | ||
AddBounty(player); | ||
} | ||
}; | ||
|
||
static IncreaseBounty _IncreaseBounty{"increasebounty", "Increase Bounty", "Increase the players bounty", 0, false}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.