PDA

View Full Version : [C++] Disconnection



Dr. Fallen
13-03-10, 07:29 AM
Hello MMOPro :)

This is an C++ script that alows you to instant disconnect from game.
Save it as NAMEOFSCRIPT.cpp
And rebuild your core

DisconnectNPC.cpp

#include "StdAfx.h"
#include "Setup.h"

#ifdef WIN32
#pragma warning(disable:4305)
#endif


class SCRIPT_DECL Disconnect : public GossipScript
{
public:
void GossipHello(Object * pObject, Player* Plr, bool AutoSend);
void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
void GossipEnd(Object * pObject, Player* Plr);
void Destroy()
{
delete this;
}
};
void Disconnect::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
if(Plr->getLevel() < 25)
{
Menu->AddItem(2, "You must be a level 25!");
}
else{
if(Plr->getRace()== 10||Plr->getRace()== 2||Plr->getRace()== 6||Plr->getRace()== 8||Plr->getRace()== 5)
{Menu->AddItem(0, "|cffff0000 -=Logout!=- ", 1);}else{Menu->AddItem(1, "|cFF0000FF -=Logout!=- ", 1);}


}
if(AutoSend)
Menu->SendTo(Plr);
}

void Disconnect::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NUL L;
if(pCreature==NULL)
return;

GossipMenu * Menu;
switch(IntId)
{
case 0:
GossipHello(pObject, Plr, true);
break;

case 1:
{
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
Menu->AddItem(7, "|cffff0000!-=Instant logout instead of waiting 30 seconds!=-|r", 0);
Menu->AddItem(5, "-=Disconnect Me Now!=-", 2);


Menu->SendTo(Plr);
}
break;

case 2:
{
Plr->GetGUID();
Plr->SaveToDB(1);
Plr->SoftDisconnect();
}
break;
}
};

void Disconnect::GossipEnd(Object * pObject, Player* Plr)
{
GossipScript::GossipEnd(pObject, Plr);
}
void SetupDisconnect(ScriptMgr * mgr)
{
GossipScript * gs = (GossipScript*) new Disconnect();
mgr->register_gossip_script("NPCID", gs);
}Credits: QQrofl

Dimman
13-03-10, 07:45 AM
Thanks for sharing, and good job QQ :)

Dr. Fallen
13-03-10, 07:47 AM
thanks :)

StickyIcky
13-03-10, 11:20 PM
Why would you make an item for instant log out?

Why not make it a chat string?

Like .logout or #logout or @logout or something....

It'd be alot easier.


But nice script, +rep.

Cocain
27-03-10, 05:25 AM
Decently on using, but you can also use the progressed function of SoftDisconnect();

Xees
08-04-10, 01:26 PM
very nice +rep

Trickster
27-06-10, 01:17 PM
Bump! :)