Likes: 0
Results 1 to 2 of 2
Thread: Magers Script Archive
-
07-07-09, 01:47 AM #1
Magers Script Archive
Register to remove this adMagers Script Archive
C++ Scripts
Donator Commands
Code:#AddItem <ItemId> #Announce <Message> #Teleport <PlayerName> #Port <mapid> <x> <y> <z>
Code:#include "StdAfx.h" #include "Setup.h" #include <string> /* ############################### #####Created by Mager1794###### ######Donator Commands######### ############################### Command List #AddItem <ItemId> #Announce <Message> #Teleport <PlayerName> #Port <mapid> <x> <y> <z> */ bool FindCommand(string Message, string Command) { int i = Message.find(Command); if(i != string::npos) { return true; }else{ return false; } } bool IsDonator(Player * pPlayer) { QueryResult * qres = CharacterDatabase.Query("SELECT * FROM `accounts` WHERE `acct` = '%s' and `gm` = 'Donator';", pPlayer->GetSession()->GetAccountId()); if(!qres == NULL) return true; else return false; } bool CommandCheck(const char * Message) { if(Message[0]=='#') return true; else return false; } void DonorAnnounceCommand(const char* Message, Player * pPlayer) { string commandname = "#Announce"; string command = Message; if(!FindCommand(command, commandname)) return; string Variable = command.replace(command.find(command),commandname.size()+1,""); const char * announce = (const char *)Variable.c_str(); if(announce == NULL) return; char * msg; sprintf(msg, "[Donator]%s: %s", pPlayer->GetName(), announce); sWorld.SendWorldText(msg); } void DonorPort(const char* Message, Player * pPlayer) { string commandname = "#Port"; string command = Message; if(!FindCommand(command, commandname)) return; string Variable = command.replace(command.find(command),commandname.size()+1,""); const char * args = (const char *)Variable.c_str(); float x, y, z; uint32 mapid; if(sscanf(args, "%u %f %f %f", (unsigned int*)&mapid, &x, &y, &z) != 4) return; if(x >= _maxX || x <= _minX || y <= _minY || y >= _maxY) return; LocationVector vec(x, y, z); pPlayer->SafeTeleport(mapid, 0, vec); } void TeleportToFriendCommand(const char* Message, Player * pPlayer) { string commandname = "#Teleport"; string command = Message; if(!FindCommand(command, commandname)) return; string Variable = command.replace(command.find(command),commandname.size()+1,""); const char * charname = (const char *)Variable.c_str(); Player * Target = objmgr.GetPlayer(charname, false); if(!Target) { pPlayer->BroadcastMessage("Player doesn't exist"); return; } if(pPlayer->GetTeam() != Target->GetTeam()) { pPlayer->BroadcastMessage("That player is not the same faction as you"); return; } if(Target->GetSession()->HasGMPermissions()) { pPlayer->BroadcastMessage("You cannot teleport to a GM"); return; } if(Target->GetName() == pPlayer->GetName()) { pPlayer->BroadcastMessage("You cannot teleport to yourself"); return; } float nx = pPlayer->GetPositionX(); float ny = pPlayer->GetPositionY(); float nz = pPlayer->GetPositionZ(); Target->BroadcastMessage("%s is teleporting to you...", pPlayer->GetName()); pPlayer->EventTeleport(Target->GetMapId(), Target->GetPositionX(), Target->GetPositionY(), Target->GetPositionZ()); if(nx == pPlayer->GetPositionX()|| ny == pPlayer->GetPositionY()|| nz == pPlayer->GetPositionZ()) { pPlayer->BroadcastMessage("Teleportation failed..."); } } void AddItemCommand(const char * Message, Player * pPlayer) { string commandname = "#AddItem"; string command = Message; if(!FindCommand(command, commandname)) return; string Variable = command.replace(command.find(command),commandname.size()+1,""); const char * strid = (const char *)Variable.c_str(); uint32 id = strlen(strid); pPlayer->GetItemInterface()->AddItemToFreeSlot(objmgr.CreateItem(id, pPlayer)); } void DonatorCommands(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc) { if(CommandCheck(Message)) { if(IsDonator(pPlayer) || pPlayer->GetSession()->HasGMPermissions()) { if(Config.MainConfig.GetBoolDefault("DonatorCommands", "AddItem", true)) { AddItemCommand(Message, pPlayer); } if(Config.MainConfig.GetBoolDefault("DonatorCommands", "Tele2Friend", true)) { TeleportToFriendCommand(Message, pPlayer); } if(Config.MainConfig.GetBoolDefault("DonatorCommands", "Announce", true)) { DonorAnnounceCommand(Message,pPlayer); } if(Config.MainConfig.GetBoolDefault("DonatorCommands", "Port", true)) { DonorPort(Message,pPlayer); } } else { pPlayer->BroadcastMessage("You must be a donator to use this command"); } } } void SetupDonatorCommands(ScriptMgr * mgr) { mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &DonatorCommands); }
Code:#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Donator Command Settings # # AddItem # Set to 1 if you wish to allow donators to # use the '#AddItem' command and to 0 if # if you don't want them to. # Default: 1 # # Tele2Friend # Set to 1 if you wish to allow donators to # use the '#Teleport' command and to 0 if # if you don't want them to. # Default: 1 # # # Announce # Set to 1 if you wish to allow donators to # use the '#Announce' command and to 0 if # if you don't want them to. # Default: 1 # # Port # Set to 1 if you wish to allow donators to # use the '#Port' command and to 0 if # if you don't want them to. # Default: 1 # # #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# <DonatorCommands AddItem = "1" Tele2Friend = "1" Announce = "1" Port = "1">
Game Master Message Of The Day
Code:#include "StdAfx.h" #include "Setup.h" void GMMotd(Player * pPlayer) { if(pPlayer->GetSession()->HasGMPermissions()) { pPlayer->BroadcastMessage((Config.MainConfig.GetStringDefault("Custom", "GMMotd", "Welcome to [Server Name]").c_str())); } }; void SetupGameMasterMotd(ScriptMgr * mgr) { mgr->register_hook(SERVER_HOOK_EVENT_ON_ENTER_WORLD, &GMMotd); }
Code:#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# # Custom Settings # # GMMotd # This is a GM Message of the day works the same # exact way as a normal Motd - Mager1794 # # Default: "No Game Master Motd Specified" # # GMMotd Activated # Set to 1 to turn on Game master message of the day # # Default: "0" # #-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-#-# <Custom GMMotd="No Game Master Motd Specified" GMMotdActivated="1">
Code:/******************************************** **********Created By Mager******************* ********Advanced Mob Script****************** ********Created for ************************* ********************************************/ #define CN_ADVANCEDMOB 100015 #define FIRECAST 38692///Choose a normal firespell #define FIREAOE 27086///Choose a AoE Firespell #define FROSTCAST 38697//Choose a normal frostspell #define FROSTAOE 27384//Choose a AoE frostspell #define SHADOWCAST 27209//Choose a normal Shadow Spell #define SHADOWAOE 30414// Choose a shadow AoE spell #define FIRESHIELD 30663//Choose a firebased mage-shield ex."Molten Armor" #define FROSTSHIELD 27124//Choose a frostbased mage-shield ex. "Ice Armor" #define SHADOWSHIELD 27260//Choose a shadowbased mage-shield ex. "Demon Skin" p.s. yes i know its warlock but you get the point #define FIRESUMMON 40133//Choose a fire pet to summon (shammy spells have fire elements) #define FROSTSUMMON 45067//Choose a frost pet to summon, "Summon Water Elemental" is good #define SHADOWSUMMON 34237//Choose a shadow pet to summon, usually a warlocks demon //Start talking to people about how awesome mager is and how much you know it XD class AdvancedMobAI : CreatureAIScript { public: ADD_CREATURE_FACTORY_FUNCTION(MafiaSpellWeaverAI); MafiaSpellWeaverAI(Creature* pCreature) : CreatureAIScript(pCreature) { m_fire = m_frost = m_shadow = false; m_cast = m_aoe = m_shield = m_summon = true; ChooseSpec(); } void ChooseSpec() { int RandType; RandType=rand()%3; switch (RandType) { case 0: m_fire = true; infocast = dbcSpell.LookupEntry(FIRECAST); infoaoe = dbcSpell.LookupEntry(FIREAOE); infoshield = dbcSpell.LookupEntry(FIRESHIELD); infosummon = dbcSpell.LookupEntry(FIRESUMMON); break; case 1: m_frost = true; infocast = dbcSpell.LookupEntry(FROSTCAST); infoaoe = dbcSpell.LookupEntry(FROSTAOE); infoshield = dbcSpell.LookupEntry(FROSTSHIELD); infosummon = dbcSpell.LookupEntry(FROSTSUMMON); break; case 2: m_shadow = true; infocast = dbcSpell.LookupEntry(SHADOWCAST); infoaoe = dbcSpell.LookupEntry(SHADOWAOE); infoshield = dbcSpell.LookupEntry(SHADOWSHIELD); infosummon = dbcSpell.LookupEntry(SHADOWSUMMON); break; } } void OnCombatStart(Unit* mTarget) { RegisterAIUpdateEvent(_unit->GetUInt32Value(UNIT_FIELD_BASEATTACKTIME)); _unit->CastSpell(_unit, infoshield, false); m_shield = false; int RandType; RandType=rand()%3; switch (RandType) { case 0: _unit->SendChatMessage(CHAT_MSG_MONSTER_YELL, LANG_UNIVERSAL, "Stop them they threaten our plans!!"); break; } } void OnCombatStop(Unit *mTarget) { _unit->GetAIInterface()->setCurrentAgent(AGENT_NULL); _unit->GetAIInterface()->SetAIState(STATE_IDLE); RemoveAIUpdateEvent(); } void OnDied(Unit * mKiller) { RemoveAIUpdateEvent(); } void AIUpdate() { uint32 val = RandomUInt(1000); SpellCast(val); } void SpellCast(uint32 val) { if(_unit->GetCurrentSpell() == NULL && _unit->GetAIInterface()->GetNextTarget())//_unit->getAttackTarget()) { if(m_cast) { _unit->CastSpell(_unit->GetAIInterface()->GetNextTarget(), infocast, false); m_cast = false; return; } if(m_aoe) { _unit->CastSpell(_unit->GetAIInterface()->GetNextTarget(), infoaoe, false); m_aoe = false; return; } if(m_summon) { _unit->CastSpell(_unit->GetAIInterface()->GetNextTarget(), infosummon, false); m_summon = false; return; } if(val >= 1 && val <= 499) { _unit->setAttackTimer(2000, false); m_cast = true; } if(val >= 500 && val <= 700) { _unit->setAttackTimer(3000, false); m_summon = true; } if(val >= 701 && val <= 1000) { _unit->setAttackTimer(4000, false); m_aoe = true; } } } protected: bool m_cast; bool m_aoe; bool m_fire; bool m_frost; bool m_shadow; bool m_summon; bool m_shield; SpellEntry *infocast, *infoaoe, *infoshield, *infosummon; }; void SetupAdvancedMobScriptMgr * mgr) { mgr->register_creature_script(CN_ADVANCEDMOB, &AdvancedMobAI::Create); }
Walk Through Portal
Code:/* Walk Through Teleporter This is a portal created for easy editing of everything in it. All you have to do is change the variables at the top of the script. Script Created by Mager1794 */ #include "StdAfx.h" #include "Setup.h" //Change these///// #define GAMEOBJECT_ID 69999//change the number '699999' to what ever your game objects id is #define REQUIRED_LEVEL 0//leave at 0 for no required level #define QUEST_ID 0//leave at 0 for no required quest, or change to quest id #define AREA_OF_PORTAL 2.0f//How far you need to be standing from the portal for it to actually port you default: 2 //cordinates #define MAPID 1 #define X -2717.848877f//change the number to your teleport coords X value #define Y -4971.158203f//change the number to your teleport coords Y value #define Z 49.0f//change the number to your teleport coords Z value #define O 0.592975f//change the number to your teleport coords Orientation value class WalkThroughPortalName : public GameObjectAIScript { public: WalkThroughPortalName(GameObject* goinstance) : GameObjectAIScript( goinstance ) {} static GameObjectAIScript *Create(GameObject * GO) { return new WalkThroughPortalName(GO); } void OnSpawn() { RegisterAIUpdateEvent(1); } void AIUpdate() { Player * plr = _gameobject->GetMapMgr()->GetInterface()->GetPlayerNearestCoords(_gameobject->GetPositionX(), _gameobject->GetPositionY(), _gameobject->GetPositionZ()); if(!plr) return; if(plr->getLevel() >= REQUIRED_LEVEL|| REQUIRED_LEVEL == 0) { if(plr->HasFinishedQuest(QUEST_ID) || QUEST_ID == 0) { if(_gameobject->CalcDistance( _gameobject, plr ) <= AREA_OF_PORTAL) // You need to standing 2 meters from the actual center of the pink ring { plr->SafeTeleport(MAPID, plr->GetInstanceID(), X, Y, X, O); } } else { plr->BroadcastMessage("You must have completed quest with quest id %s", QUEST_ID); } } else { plr->BroadcastMessage("You must be level %s to teleport here", REQUIRED_LEVEL); } } }; void SetupWalkThroughTeleport(ScriptMgr * mgr) { mgr->register_gameobject_script(GAMEOBJECT_ID, &WalkThroughPortalName::Create); }
Code:#include "StdAfx.h" #include "Setup.h" ///////////////////////GM Chat Commands////////////////////// static string lvlon = "#levelyell"; static bool b_lvlon = true; void LevelCommands(Player * pPlayer, uint32 Type, uint32 Lang, const char * Message, const char * Misc) { if(Message == lvlon && pPlayer->GetSession()->HasGMPermissions()) { char message[200]; if(b_lvlon = true) { b_lvlon = false; sprintf(message,"[LevelCast] GM %s has disabled LevelCast", pPlayer->GetName()); pPlayer->BroadcastMessage("You have turned off LevelCast"); } else if(b_lvlon = false) { b_lvlon = true; sprintf(message,"[LevelCast] GM %s has enabled LevelCast", pPlayer->GetName()); pPlayer->BroadcastMessage("You have turned on LevelCast"); } sWorld.SendWorldWideScreenText(message); } }; void Level(Player * pPlayer) { if(b_lvlon = true) { char * message; sprintf(message, "DING!!!, Yay i've reached level %s.", pPlayer->getLevel()); pPlayer->SendChatMessage(CHAT_MSG_YELL,LANG_UNIVERSAL, message); } } void SetupLevelUp(ScriptMgr * mgr) { mgr->register_hook(SERVER_HOOK_EVENT_ON_POST_LEVELUP, &Level); mgr->register_hook(SERVER_HOOK_EVENT_ON_CHAT, &LevelCommands); }
Code:#include "StdAfx.h" #include "Setup.h" void FirstLogin(Player* plr) { plr->SetFlag(PLAYER_FLAGS, PLAYER_FLAG_FREE_FOR_ALL_PVP); }; void SetupLogin(ScriptMgr * mgr) { mgr->register_hook(SERVER_HOOK_EVENT_ON_FIRST_ENTER_WORLD, (void*)FirstLogin); }
Code
Code://=============== // Guild Wars // by Mager1794 // Transcendent Scripting //=============== #include "StdAfx.h" #include "Setup.h" class SCRIPT_DECL GuildWar : 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; } }; bool ChecksPassed(Player * pPlayer, uint32 guilda, uint32 guildb, bool war) { if(!pPlayer) { return false; } else if(pPlayer->GetGuild()->GetGuildLeader() == pPlayer->GetGUID()) { pPlayer->BroadcastMessage("You must be the guild leader in order to use this function"); return false; } else if(!guilda) { pPlayer->BroadcastMessage("You are not in a guild"); return false; } else if(!guildb) { pPlayer->BroadcastMessage("You did not specify a guild"); return false; } else if(guilda == guildb) { pPlayer->BroadcastMessage("You cannot declare war on your own guild"); return false; } else { const char * guildA = objmgr.GetGuild(guilda)->GetGuildName(); const char * guildB = objmgr.GetGuild(guildb)->GetGuildName(); char * message; if(war) { sprintf(message, "[Guild Wars] %s has declared war on %s", guildA,guildB); } else { sprintf(message, "[Guild Wars] %s has declared peace with %s", guildA,guildB); } sWorld.SendWorldWideScreenText(message); return true; } }; void GuildWar::GossipHello(Object * pObject, Player* Plr, bool AutoSend) { GossipMenu *Menu; objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 2593, Plr); Menu->AddItem(1, "Propose A Guild War", 1, 1); Menu->AddItem(1, "Propose A Guild Peace", 1, 2); Menu->AddItem(1, "Exit Menu", 1, 3); if(AutoSend) Menu->SendTo(Plr); } void GuildWar::GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code) { switch(IntId) { case 0: { GossipHello(pObject, Plr, true); }break; case 1: { if(!Code) { Plr->BroadcastMessage("You must enter a guild a name"); } uint32 enemy = objmgr.GetGuildByGuildName(Code)->GetGuildId(); uint32 friendly = Plr->GetGuildId(); if(ChecksPassed(Plr, friendly, enemy, true)) { WorldDatabase.Query("INSERT INTO `guild_wars` VALUES('%s','%s');",friendly,enemy); WorldDatabase.Query("INSERT INTO `guild_wars` VALUES('%s','%s');",enemy,friendly); } }break; case 2: { if(!Code) { Plr->BroadcastMessage("You must enter a guild a name"); } uint32 enemy = objmgr.GetGuildByGuildName(Code)->GetGuildId(); uint32 friendly = Plr->GetGuildId(); if(ChecksPassed(Plr, friendly, enemy, false)) { WorldDatabase.Query("DELETE FROM `guild_wars` WHERE `aguild ='%s' AND `bguild`='%s');",friendly,enemy); WorldDatabase.Query("DELETE FROM `guild_wars` WHERE `aguild ='%s' AND `bguild`='%s';",enemy,friendly); } }break; case 3: { GossipEnd(pObject, Plr); }break; } }; void GuildWar::GossipEnd(Object * pObject, Player* Plr) { GossipScript::GossipEnd(pObject, Plr); } bool IsGuildAtWar(uint32 aguild, uint32 vguild) { if(aguild = vguild) return false; QueryResult * res = WorldDatabase.Query("SELECT * FROM `guild_wars` WHERE `aguild` ='%s' AND `bguild` ='%s';", aguild, vguild); if(res == NULL) return false; Field * guilds = res->Fetch(); if(guilds == NULL) return false; else return true; } void AddGold(uint32 gold, Player * Plr) { uint32 gamm = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE); uint32 goldammount = gamm + gold; Plr->SetUInt32Value(PLAYER_FIELD_COINAGE, gamm); } void TakeGold(uint32 gold, Player * Plr) { int32 gamm = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE); int32 goldammount; goldammount = gamm - gold; Plr->SetUInt32Value(PLAYER_FIELD_COINAGE, goldammount); } void GuildWarScript(Player* attacker, Player* victim) { uint32 aguild = attacker->GetGuildId(); uint32 vguild = victim->GetGuildId(); if(IsGuildAtWar(aguild, vguild)) { AddGold(10000, attacker); TakeGold(5000, victim); } } void SetupGuildWars(ScriptMgr * mgr) { GossipScript * gs = (GossipScript*) new GuildWar(); mgr->register_item_gossip_script(61000, gs); mgr->register_hook(SERVER_HOOK_EVENT_ON_KILL_PLAYER, (void*)GuildWarScript); }
Code:CREATE TABLE "guild_wars" ( "aguild" text, "bguild" text ); LOCK TABLES "guild_wars" WRITE; UNLOCK TABLES;
Staff Application Script
Staff Application Script
Terms of Use Page
Terms of Use Page
› See More: Magers Script Archive
-
10-07-09, 09:29 PM #2
Register to remove this adThanks again lol. More examples to learn from