mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2024-12-24 22:43:34 +00:00
7a067e7b48
- Add score saving for races - Fix some bugs - Still work to do.
51 lines
1.6 KiB
C++
51 lines
1.6 KiB
C++
#include "BaseFootRaceManager.h"
|
|
#include "EntityManager.h"
|
|
#include "Character.h"
|
|
#include "Entity.h"
|
|
|
|
void BaseFootRaceManager::OnStartup(Entity* self) {
|
|
// TODO: Add to FootRaceStarter group
|
|
}
|
|
|
|
void BaseFootRaceManager::OnFireEventServerSide(Entity* self, Entity* sender, std::string args, int32_t param1,
|
|
int32_t param2, int32_t param3) {
|
|
const auto splitArguments = GeneralUtils::SplitString(args, '_');
|
|
if (splitArguments.size() > 1) {
|
|
|
|
const auto eventName = splitArguments[0];
|
|
const auto player = EntityManager::Instance()->GetEntity(std::stoull(splitArguments[1]));
|
|
|
|
if (player != nullptr) {
|
|
if (eventName == "updatePlayer") {
|
|
UpdatePlayer(self, player->GetObjectID());
|
|
} else if (IsPlayerInActivity(self, player->GetObjectID())) {
|
|
if (eventName == "initialActivityScore") {
|
|
auto* character = player->GetCharacter();
|
|
if (character != nullptr) {
|
|
character->SetPlayerFlag(115, true);
|
|
}
|
|
|
|
SetActivityScore(self, player->GetObjectID(), 1);
|
|
} else if (eventName == "updatePlayerTrue") {
|
|
auto* character = player->GetCharacter();
|
|
if (character != nullptr) {
|
|
character->SetPlayerFlag(115, false);
|
|
}
|
|
|
|
UpdatePlayer(self, player->GetObjectID(), true);
|
|
} else if (eventName == "PlayerWon") {
|
|
auto* character = player->GetCharacter();
|
|
if (character != nullptr) {
|
|
character->SetPlayerFlag(115, false);
|
|
if (param2 != -1) // Certain footraces set a flag
|
|
character->SetPlayerFlag(static_cast<uint32_t>(param2), true);
|
|
}
|
|
|
|
StopActivity(self, player->GetObjectID(), 0, param1);
|
|
SaveScore(self, player->GetObjectID(), param1, param2, param3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|