Code:
#include "StdAfx.h"
#include "Setup.h"
#include <string>
#include <iostream>
using namespace std;
//If set to true, will enable players to #event while in combat
static bool bypassCombat = false;
bool rezzon = false; //Will be switchable later ingame via GMCommand
static string evon = "#eventstart";
static string evoff = "#eventend";
static string evpPlayer = "#join";
static string rezzcmd = "#revive";
static string mall = "#leave";
//Default Values
static bool eon = false;
static uint32 emapid = 0;
static float ex = 0.0f;
static float ey = 0.0f;
static float ez = 0.0f;
void EventChat(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
if(Message == evon && pPlayer->GetSession()->HasGMPermissions())
{
eon = true;
ex = pPlayer->GetPositionX();
ey = pPlayer->GetPositionY();
ez = pPlayer->GetPositionZ();
emapid = pPlayer->GetMapId();
char message[200];
sprintf(message, "%s has started an event! Type #join to join!", pPlayer->GetName());
sWorld.SendWorldWideScreenText(message);
}
else if(Message == evoff && pPlayer->GetSession()->HasGMPermissions())
{
eon = false;
char message[200];
sprintf(message, "Summons to the event are now closed.", pPlayer->GetName());
sWorld.SendWorldWideScreenText(message);
}
else if(Message == evpPlayer)
{
if(eon)
if(bypassCombat || !pPlayer->CombatStatus.IsInCombat())
pPlayer->EventTeleport(emapid, ex, ey, ez);
else
pPlayer->BroadcastMessage("You can't port while in combat. Please leave combat and try again.");
else
pPlayer->BroadcastMessage("There is no event goin on at the moment.");
}
else if(Message == home)
{
if(pPlayer->getRace()== 10||pPlayer->getRace()== 2||pPlayer->getRace()== 6||pPlayer->getRace()== 8||pPlayer->getRace()== 5)
pPlayer->EventTeleport(1, 1502.709961, -4415.419922, 21.553234);
else
pPlayer->EventTeleport(0, -8913.230469, 554.632996, 93.795029);
}
//#rezz-Command - Start
if(Message == rezzcmd)
{
if(rezzon)
if( rezzon )
{ //You can add parameters where reviing is enabled here. e.g. for allowing it only on kalimdor and in Zone 123: (pPlayer->GetMapId() == 1 || pPlayer->GetZoneId() == 123)
if(bypassCombat || !pPlayer->CombatStatus.IsInCombat())
if (pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE)>=7500) //Will cost 75 Silver (check if enough money)
{
pPlayer->SetUInt32Value(PLAYER_FIELD_COINAGE,(pPlayer->GetUInt32Value(PLAYER_FIELD_COINAGE) - 7500)); //Here 75 Silver is removed
sEventMgr.AddEvent(pPlayer, &Player::RemoteRevive, EVENT_PLAYER_REST, 1, 1,0);
} else pPlayer->BroadcastMessage("You don't have 75 silver in your backpack.");
} else
pPlayer->BroadcastMessage("Your in combat!");
else
pPlayer->BroadcastMessage("You can't revive here!.");
}
//#rezz-Command end.
//#mall-Command - Start
if(Message == evpPlayer)
{
if(bypassCombat || !pPlayer->CombatStatus.IsInCombat())
pPlayer->EventTeleport(emapid, ex, ey, ez);
else
pPlayer->BroadcastMessage("You can't port while in combat.");
}
else if(Message == mall)
{
if( pPlayer->GetTeam() == 1 )
pPlayer->EventTeleport(530, -1722.58, 5382.7, 2.47504); //Shattrath
else
pPlayer->EventTeleport(530, -1722.58, 5382.7, 2.47504); //Shattrath
}
}
void SetupEvent(ScriptMgr * mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &EventChat);
}
Whoever finds out whats wrong and helps me correct it gets +Rep.