So erm .... can someone help me ? Why does this not work ?
It compiles perfectly fine :s
This is an old script I tried to fix :S ... but I cant .... please help ....
Code:
void OnEnterCombat(Player *pPlayer, Unit *pTarget); //Function Header
#define NOPVPGUARD 800000 //ID for the anti PVP creature {YES !!! U CHANGE THIS TO THJE GUARDS ID!!!}
#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 {THOSE WHO DONT KNOW ... Death touch ... you can change this to anything :D ... net spell works nice
#define UNIT_INSTANT true //Instant cast spell? true or false
#define ZONE 357 //
void OnEnterCombat(Player *pPlayer, Unit *pTarget)
{
bool InZone = false;
if (pPlayer->GetZoneId() == ZONE) {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());
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);
}
void SetupPVP(ScriptMgr * mgr)
{
mgr->register_hook(SERVER_HOOK_EVENT_ON_ENTER_COMBAT, (void*) OnEnterCombat);
}
I really gotta get people to stop PvPing in the shoping centre :s Thanx alot guys