This is my first release on MMOwned, I have done many other things and released other stuff. But this is the first script im giving to the public
This is a GM Event System, It works by have a OnChat hook that checks for certain messages
The Commands Are:
GM Commands
Code:
#start - It Initiates an Event, sends a WorldText, gets your position and writes it to the corresponding variables
#end - Obviously ends the event, clears the variables
#remind - Sends a World Text reminding players of an event
#setpos - remaps the variables to your current position
#setspec on - Turns spectating mode on
#setspec off - turns off spectating mode
Player Commands
Code:
#join - Teleports the player to the event coordinates the gm set when he started the event
#leave - teleports the player to their respective mall
#spec - teleports the player to the coordinates that the gm set to for spectating, the players will be rooted
#stuck - This is a command for if a player gets stuck, it will revive them, and teleport them to Shattrath
You have to set the Mall Coordinates!!!!
Code:
#include "StdAfx.h"
#include "Setup.h"
#include <string>
#include <iostream>
using namespace std;
static string infoHelp, gmEventStart, gmEventEnd, gmRemind, gmSetPos, gmSpecOn, gmSpecOff, plrJoin, plrLeave, plrSpectate, plrStuck;
float x,y,z,sx,sy,sz;
uint32 mapid,smapid;
bool EventStarted, CanSpectate;
void EventOnChat(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc)
{
//GM Commands
gmEventStart = "#start";
gmEventEnd = "#end";
gmRemind = "#remind";
gmSetPos = "#setpos";
gmSpecOn = "#setspec on";
gmSpecOff = "#setspec off";
//Player Commands
plrJoin = "#join";
plrLeave = "#leave";
plrSpectate = "#spec";
plrStuck = "#stuck";
if(pPlayer->GetSession()->HasGMPermissions() )
{
if(Message == gmEventStart)
{
char Msg[255];
sprintf(Msg, "[Event System] %s has started an event! Type #join to join.", pPlayer->GetName());
sWorld.SendWorldText(Msg);
EventStarted = true;
x = pPlayer->GetPositionX();
y = pPlayer->GetPositionY();
z = pPlayer->GetPositionZ();
mapid = pPlayer->GetMapId();
}
if(Message == gmEventEnd)
{
char Msg[255];
sprintf(Msg, "[Event System] %s has ended the event!", pPlayer->GetName());
sWorld.SendWorldText(Msg);
EventStarted = false;
x = 0.0;
y = 0.0;
z = 0.0;
mapid = 0;
}
if(Message == gmRemind)
{
sWorld.SendWorldText("[Event System] There is an event going! Type #join to join.");
}
if(Message == gmSetPos)
{
if(EventStarted)
{
char msg[255]
sprintf(msg, "[Event System] New Event Summon Position. Type #join to Join")
sWorld.SendWorldText(msg);
x = pPlayer->GetPositionX();
y = pPlayer->GetPositionY();
z = pPlayer->GetPositionZ();
mapid = pPlayer->GetMapId();
}
else
{
pPlayer->BroadcastMessage("[Event System] You cannot remap event coordinates when there is no event going on!");
}
}
if(Message == gmSpecOn)
{
CanSpectate = true;
sWorld.SendWorldText("[Event System] Spectating has been enabled. Type #spec to watch.");
sx = pPlayer->GetPositionX();
sy = pPlayer->GetPositionY();
sz = pPlayer->GetPositionZ();
smapid = pPlayer->GetMapId();
}
if(Message == gmSpecOff)
{
CanSpectate = false;
sWorld.SendWorldText("[Event System] Spectating has been Disabled.");
sx = 0.0;
sy = 0.0;
sz = 0.0;
smapid = 0;
}
}
else
{
if(Message == plrJoin && EventStarted)
{
pPlayer->BroadcastMessage("[Event System] Joining current event.");
pPlayer->EventTeleport(mapid, x, y, z);
}
else
{
pPlayer->BroadcastMessage("[Event System] No Event is currently going on, you must wait for a GM to start one!");
}
if(Message == plrLeave && EventStarted)
{
pPlayer->UnRoot();
if(pPlayer->GetTeam() == 1)
{
pPlayer->BroadcastMessage("[Event System] Leaving event and teleporting to Horde Mall.");
pPlayer->EventTeleport(MAPID, X, Y, Z);
}
else
{
pPlayer->BroadcastMessage("[Event System] Leaving event and teleporting to Alliance Mall.");
pPlayer->EventTeleport(MAPID, X, Y, Z);
}
else
{
pPlayer->BroadcastMessage("[Event System] You cannot leave an event that is currently not underway!");
}
if(Message == plrSpectate && EventStarted)
{
if(CanSpectate)
{
pPlayer->EventTeleport(smapid, sx, sy, sz);
pPlayer->SetMovement(MOVE_ROOT,1);
}
else
{ // IF spectating is disabled then ...
pPlayer->BroadcastMessage("[Event System] Spectating has been disabled.");
}
}
if(Message == plrStuck)
{
//let's revive them before we teleport them
pPlayer->ResurrectPlayer(NULL);
pPlayer->EventTeleport(530, -1835.797852, 5423.517578, -12.427971);
pPlayer->BroadcastMessage("[Stuck System] Initiated, Sending to Shattrath.");
}
}
}
void SetupEventCmd(ScriptMgr * mgr)
{
EventStarted = false;
CanSpectate = false;
mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, (bool *) EventOnChat);
}
in Setup.cpp add:
Code:
SetupEventCmd(mgr);
in Setup.h add:
Code:
void SetupEventCmd(ScriptMgr * mgr);
I'm aware that it can be improved, i'll improve it tomorrow maybe...or i might just leave it up to you all to improve it yourself...