#include "engine.h"
#include "scripts.h"
#include "zbl.h"
void zbl_MVP_Script::Created(GameObject *obj)
{
timeLeft = The_Game()->TimeRemaining_Seconds;
Commands->Start_Timer(obj, this, 1.0f, 123); //every 30seconds check for time remaining
}
void zbl_MVP_Script::Timer_Expired(GameObject *obj, int number)
{
if (number == 123)
{
timeLeft = The_Game()->TimeRemaining_Seconds;
if (timeLeft <= 2) {
float score; int ID;
for (GenericSLNode* PlayerIter = PlayerList->HeadNode; (PlayerIter != NULL); PlayerIter = PlayerIter->NodeNext)
{
GameObject *Player = (GameObject *)PlayerIter->NodeData;
int i = Get_Player_ID(Player);
score = Get_Score(i);
if (Get_Score(i) > score) {
ID = i;
}
}
for (GenericSLNode* PlayerIter = PlayerList->HeadNode; (PlayerIter != NULL); PlayerIter = PlayerIter->NodeNext)
{
GameObject *Player = (GameObject *)PlayerIter->NodeData;
int i = Get_Player_ID(Player);
if (i == ID) {
Change_Team_By_ID(i, 1);
char Msg1[150];
sprintf(Msg1, "ppage %d You are being changed to team GDI for being the current MVP", i);
Console_Input(Msg1);
delete []Msg1;
}
else {
Change_Team_By_ID(i, 0);
char Msg1[150];
sprintf(Msg1, "ppage %d You are being changed to team Nod for not being the MVP for the current map.", i);
Console_Input(Msg1);
delete []Msg1;
}
}
}
else {
Commands->Start_Timer(obj, this, 1.0f,123);
}
}
}
ScriptRegistrant<zbl_MVP_Script> zbl_MVP_Script_Registrant("zbl_MVP_Script", "");
----------------------------------
class zbl_MVP_Script : public ScriptImpClass {
void Created(GameObject *obj);
void Destroyed(GameObject *obj);
void Timer_Expired(GameObject *obj, int number);
float timeLeft;
};
----------------------------------
**Note: Untested.
Usage: Create an invisible object or a dave's arrow on every map you want to use this script on and attach this script to it.
If it doesn't work, which I doubt , I'm sure reborn will help you out.
~Zack
[Updated on: Sat, 02 February 2008 10:32]
Report message to a moderator