Anti PvP guard
error says: unexpected symbol near '/'
Code:
/******************************************************/
/* Anti PVP guard */
/* By optical */
/* Redistribution prohibited */
/******************************************************/
#include "StdAfx.h"
void OnEnterCombat(Player *pPlayer, Unit *pTarget); //Function Header
extern "C" SCRIPT_DECL uint32 _exp_get_version()
{
return MAKE_SCRIPT_VERSION(SCRIPTLIB_VERSION_MAJOR, SCRIPTLIB_VERSION_MINOR);
}
extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
::sScriptMgr.register_hook(SERVER_HOOK_EVENT_ON_ENTER_COMBAT, OnEnterCombat);
}
#ifdef WIN32
BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}
#endif
#define NOPVPGUARD 1 //ID for the anti PVP creature
#define MAX_DISTANCE 70.0 //Distance they must be within for the guard to agro
#define KILL_SPELL 5 //The spell used when they get agro - death touch
#define UNIT_INSTANT true //Instant cast spell? true or false
unsigned Zones[4] = { 33,440,618,3523,130 }; //STV,Tanaris,winterspring,netherstorm, Pyrewood Village
void OnEnterCombat(Player *pPlayer, Unit *pTarget)
{
bool InZone = false;
for (int C = 0; C < 4; C++)
{
if (pPlayer->GetZoneId() == Zones[C]) {InZone = true;}
}
if (InZone == false) {return;}
Creature *pCreature = pPlayer->GetMapMgr()->GetSqlIdCreature(NOPVPGUARD);
if (!pCreature) {return;} //No creature found, handle gracefully and return
float dist = pCreature->CalcDistance(pPlayer->GetPositionX(),pPlayer->GetPositionY(),pPlayer->GetPositionZ());
if (dist <= MAX_DISTANCE)
{
Unit *pUnit = (Unit *)pPlayer; //Cast the pointer to a Unit object
pCreature->GetAIInterface()->AttackReaction(pUnit,0,0); //Attack! (not sure about the second and third params here, set to 0 to be safe
if (KILL_SPELL != NULL)
pCreature->CastSpell(pUnit,KILL_SPELL,UNIT_INSTANT);
}
}