Enable flags to have time limits, regardless if they are good or bad, give indicators for the duration of a powerup, set time limits for in game goals/races, show different countdowns depending on team objectives..etc
Here's how to do it:
Include bzfs.h and StateDatabase.h in addition to the standard bzfsAPI.h header. The way I compile plug-ins means it looks like this, but your results may vary.
Code: Select all
#include "bzfsAPI.h"
#include "../src/bzfs/bzfs.h"
#include "StateDatabase.h"
This one sends an individual timer for a single player:
Code: Select all
void sendPlayerTimerUpdate(int playerID, int timerUpdate)
{
bufStart = getDirectMessageBuffer();
buf = nboPackInt(bufStart, (int32_t)timerUpdate);
directMessage(playerID, MsgTimeUpdate, (char*)buf-(char*)bufStart, bufStart);
}
Code: Select all
void sendAllTimerUpdate(int timerUpdate)
{
void *buf, *bufStart = getDirectMessageBuffer ();
buf = nboPackInt (bufStart, (int32_t) timerUpdate);
broadcastMessage (MsgTimeUpdate, (char *) buf - (char *) bufStart, bufStart);
}
Example: sendAllTimerUpdate(30); will send a timer of 30 seconds. sendAllTimerUpdate(-1);[/b] will pause any active timer.
In short the following grant timers of 60 seconds:
Code: Select all
sendAllTimerUpdate(60);
sendPlayerTimerUpdate(playerID, 60);
Code: Select all
sendAllTimerUpdate(-1);
sendPlayerTimerUpdate(playerID, -1);
The only slight issue may be issues with replays, but this is relatively minor compare to most problems:
From the code, it appears that Direct messages in terms of packets aren't recorded.
This may be seen in the void directMessage(int playerIndex, uint16_t code, int len, void *msg) compare to void broadcastMessage(uint16_t code, int len, void *msg) which appears to contain methods for recording packets.
Hopefully someone finds this fun and useful!
-Zehra