Code:
//---------------------
// Egg hunt Event
// Made by Spidey
//---------------------
#include "StdAfx.h"
#include "Setup.h"
Player * pCollector = NULL;
uint32 pCeggs = 0;
static map<uint32, uint32> eggs;
class Egg : public GameObjectAIScript
{
public:
Egg(GameObject* goinstance) : GameObjectAIScript(goinstance) {}
static GameObjectAIScript *Create(GameObject * GO) { return new Egg(GO); }
void OnActivate(Player * pPlayer)
{
if(pPlayer->GetSession()->HasGMPermissions())
{
pPlayer->BroadcastMessage("Silly GM, you can't participate in this event.");
return;
}
this->_gameobject->RemoveFromWorld(true);
uint32 p = pPlayer->GetGUIDLow();
eggs[p]++;
if(!pCollector || eggs[p] > pCeggs)
{
pCollector = pPlayer;
pCeggs = eggs[p];
}
char msg[1024];
snprintf(msg, 1024, "%c has found an egg! His score is %u. Leader is %c with %u eggs!", pPlayer->GetName(), eggs[p], pCollector->GetName(), pCeggs);
sWorld.SendWorldWideScreenText(msg);
}
};
void SetupEggs(ScriptMgr *mgr)
{
mgr->register_gameobject_script(99000, &Egg::Create);
}
Code:
INSERT INTO gameobject_names (entry,Type,DisplayID,Name) VALUES ('99000','10','1408','Event Egg')