Closed MeineZ closed 1 year ago
So you could just use the examples from ballchasing. It would probably look something like this
#include "bakkesmod/plugin/bakkesmodplugin.h"
#include "bakkesmod/plugin/pluginwindow.h"
class PowerslideTracker : public BakkesMod::Plugin::BakkesModPlugin
{
public:
void onLoad() override;
void onUnload() override;
void onPlayerTick(std::string eventName, PriWrapper player) override;
std::string GetPluginName() override { return "PowerslideTracker"; }
void SetImGuiContext(uintptr_t ctx) override { ImGui::SetCurrentContext(reinterpret_cast<ImGuiContext*>(ctx)); }
private:
float powerslideTime = 0.0f;
int powerslidesUsed = 0;
float timeElapsed = 0.0f;
};
void PowerslideTracker::onLoad()
{
cvarManager->log("PowerslideTracker plugin loaded!");
}
void PowerslideTracker::onUnload()
{
cvarManager->log("PowerslideTracker plugin unloaded.");
}
void PowerslideTracker::onPlayerTick(std::string eventName, PriWrapper player)
{
if (player.IsNull() || !player.GetCarComponent().HasInput()) {
return;
}
CarWrapper car = player.GetCar();
float deltaTime = car.GetGameEventAsServer().GetDeltaTime();
if (car.GetbIsInAir()) {
powerslideTime = 0.0f;
}
else if (car.GetCarComponent().GetInput().Powerslide()) {
powerslideTime += deltaTime;
powerslidesUsed++;
}
timeElapsed += deltaTime;
if (timeElapsed > 60.0f) {
ImGui::Begin("PowerslideTracker");
ImGui::Text("Powerslide Time: %.2f seconds", powerslideTime);
ImGui::Text("Powerslides Used: %d", powerslidesUsed);
ImGui::End();
powerslideTime = 0.0f;
powerslidesUsed = 0;
timeElapsed = 0.0f;
}
}
BAKKESMOD_PLUGIN(PowerslideTracker, "Powerslide Tracker", "0.2", PLUGINTYPE_FREEPLAY)
Wow, thanks for the snippet! I don't know where you got it from, but it seems to be a little outdated. It did help me out a lot though, so thanks for that!
It's awaiting approval by BakkesMod admins now, so you should see it in the next update!
I wrote it very quickly. Off the top of my head from what i remembered about bakkas. Figured If I wrote it out you could see exactly what I was asking for. I knew that the code wouldnt translate exactly to your base. I did know that it would give you an outline to use.
Also. I LOVE the way you comment your code. It's very similar to how I comment code. Keep up the good work!
Ha, yeah! It was really helpful! I'm quite surprised that you are able to write pretty accurate bakkes code off the top of your head. I suppose you have quite some experience in plugin development?
Thanks btw, Im glad you like it :)
I work in cyber security, but i have my hobbies!
What do you mean by 'counter'? The number of times that you pressed/released the powerslide button?