• Страница 1 из 1
  • 1
Модератор форума: Dimitro  
Скрипт на Гильд хаусы + SQL Query
GonZZo
[Zlo_MasteR]
Версия 2.0
Работает на Aspire Hearthstone.

Описание автора

Quote
What it does:
Guild Houses
Will query the Guild ID of player and cross check with entries in the character database (house table posted below)
checks if players guild owns an area
checks if player has enough gold
if no gold no port to house
enters in coords based on players gps location (i have some future plans for this - change to actual coords instead of gps function if you want to limit locations)
Ports to guild house cost 100 gold (1000 * 1000 = 100 gold)

Q_RESULTS_1 and Q_RESULTS_2 now check to see if Guilds own a Zone
Q_RESULTS_G_LEADER now checks guild_data table in character DB for guildid, guid, and guildrank
if all 3 are proper, Only Guild Masters can purchase
Guilds can now purchase multiple zones
If a zone is already owned - you cannot purchase
Now checks correctly in various ways if you are -
level 10
in a guild
Guild Master
what Zone
Guild ID
Player GUID
In Combat

Now teleports you to nearest Housing Area if in a Zone that
Your Guild Controls - If not in a Guild Controlled Zone you cannot port there
-- Next Stop
On Owned Zone Entry - If players own a Zone there will be
an announcement to players if they own / if its available
and what options are allowed

Everybody say yay for ownable zones

G_House.CPP

Code
/*  
   * Written by Tekkeryole / AKA / WHOS / Galv  
   * Copyright (C)2009 <http://wowtek.servegame.org/> WoWTek Realms  
   * Feel free to modify as you wish - Give Credits if you  
   * Repost this anywhere else and/or modify and re-release.  
   * I will not tolerate Leechers and / or code stealers  
   * So for the sake of Open Source, give Credits please.  
   * Cheers <img src="http://s8.ucoz.net/sm/1/smile.gif" border="0" align="absmiddle" alt="smile">  
   */  

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

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

#endif  

#define HOUSE_MANAGER 40014//< Duh, NPC ID >  
#define REQ_COIN 1000 * 1000//< 1000 * 1000 = 100 Gold   
#define GUILD_MASTER_RANK 0  

class SCRIPT_DECL H_MANAGER : public GossipScript  
{  
public:  
   void GossipHello(ObjectPointer Ob, PlayerPointer Plr, bool AutoSend);  
   void GossipSelectOption(ObjectPointer Ob, PlayerPointer Plr, uint32 Id, uint32 IntId, const char * Code);  
   void GossipEnd(ObjectPointer Ob, PlayerPointer Plr);  
   void Destroy()  
   {  
   delete this;  
   }  
};  
     
void H_MANAGER::GossipHello(ObjectPointer Ob, PlayerPointer Plr, bool AutoSend)  
   {  
   GossipMenu * Menu;  
   objmgr.CreateGossipMenuForPlayer(&Menu, Ob->GetGUID(), 1, Plr);  
     
   if(  
   Plr->CombatStatus.IsInCombat())  
   {  
   Plr->BroadcastMessage("You are in Combat!");  
   return;  
   }  
   if(  
   Plr->GetGuildId() == NULL)  
   {  
   Plr->BroadcastMessage("You are not in a Guild!");  
   return;  
   }  
   if(  
   Plr->getLevel() < 10)  
   {   
   Plr->BroadcastMessage("You must be level 10.");  
   }else{  
    Menu->AddItem(1, "Buy this Area.", 1);  
    Menu->AddItem(2, "Port me to the nearest Guild Area.", 2);  
    Menu->AddItem(3, "Area Options", 3);  
   }  
   if(AutoSend)  
    Menu->SendTo(Plr);  
   }  
void H_MANAGER::GossipSelectOption(ObjectPointer Ob, PlayerPointer Plr, uint32 Id, uint32 IntId, const char * Code)  
   {  
   CreaturePointer    pCreature = (Ob->GetTypeId()==TYPEID_UNIT) ?TO_CREATURE(Ob):NULLCREATURE;  

   uint32 PLR_COIN = Plr->GetUInt32Value(PLAYER_FIELD_COINAGE);  
     
   if(pCreature==NULLCREATURE)  
    return;  
   GossipMenu * Menu;  
    switch(IntId)  
   {  
   case 0:  
   GossipHello(Ob, Plr, true);  
    break;  

     
//CASE ONE - BUYING THE HOUSE - DO YOU HAVE THE PRE-REQUISITES FILLED OUT?  
   case 1:  
   {  
    //    SQL HACK CHECK TO SEE IF YOU ARE A GUILD MASTER UNTIL I FIGURE OUT HOW  
    //    TO CALL FUNCTION GETGUILDLEADER PROPERLY  
   QueryResult * Q_RESULTS_G_LEADER = CharacterDatabase.Query("SELECT * FROM guild_data WHERE guildid = %u AND playerid = %u AND guildRank = %u", Plr->GetGuildId(), Plr->GetGUID(), GUILD_MASTER_RANK);  
   if(Q_RESULTS_G_LEADER == GUILD_MASTER_RANK)  
    {  
    Plr->BroadcastMessage("You are not the Guild Master.");  
    Plr->Gossip_Complete();  
   return;  
   }  
   QueryResult * Q_RESULTS_1 = CharacterDatabase.Query("SELECT * FROM House_system WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());  
   if(Q_RESULTS_1 != NULL)  
   {    //ARE YOU SERIOUSLY TRYING TO BUY PROPERTY TWICE?  
    Plr->BroadcastMessage("This area has already been purchased.");  
    Plr->Gossip_Complete();  
   return;  
   }  
   if(PLR_COIN < (REQ_COIN))  
    //REMINDER FOR LATER - ADD IN OPTION TO TELE TO OTHER GUILDS  
    //OWNED HOUSE IF ON ZONE - EXTRA CHARGE APPLIES FOR NON OWNERS  

   {    //YOU NEED TO HAVE A SUBSTANTIAL BREAD FLOW OR THIS HAPPENS  
    Plr->BroadcastMessage("You don't have enough gold to Teleport to nearby Guilds Land.");  
    Plr->Gossip_Complete();  
   return;  
   }  
   if(Q_RESULTS_1 == NULL)  
   {    //MMMM, DATA INSERTION  
    //NOW GIVE ME MY MONEY!  
    CharacterDatabase.Execute("INSERT INTO House_system VALUES('%u', '%f', '%f', '%f', '%u', '%u')", Plr->GetGuildId(), Plr->GetPositionX(), Plr->GetPositionY(), Plr->GetPositionZ(), Plr->GetMapId(), Plr->GetZoneId());  
    Plr->SetUInt32Value(PLAYER_FIELD_COINAGE, (PLR_COIN - (REQ_COIN)));//GOLD REMOVAL  
    Plr->BroadcastMessage("Gratz! Your Guild now Owns this area.");    //PLAYER SEES THIS IN CHAT  
    Plr->Gossip_Complete();  
    }  
   }break;  

//CASE TWO - READ ALL THE FINE PRINT AND GET ACCESS  
   case 2:  
   {  
   QueryResult * Q_RESULTS_2 = CharacterDatabase.Query("SELECT * FROM House_system WHERE guild_id = %u AND zoneid = %u", Plr->GetGuildId(), Plr->GetZoneId());  
   if(Q_RESULTS_2 == NULL)  
   {    //EITHER YOU ARE TRYING TO OUTBUY SOMEONE ELSES HOUSE  
    //OR YOUR GUILD ALREADY OWNS A HOUSE  
    Plr->BroadcastMessage("Your Guild does not own any Land Nearby.");  
    Plr->Gossip_Complete();  
   return;  
   }  
   if(Q_RESULTS_2->GetRowCount() > 1)  
   {    //OH BEJESUS, ANOTHER MYSQL ERROR  
    //BTW - ERROR 421 = BETTER THEN SOBER  
    //AND YOU THOUGHT 4:20 WAS SO COOL  
    //BY THE TIME 4:21 ROLLS AROUND IM BETTER THEN SOBER  
    Plr->BroadcastMessage("Error 421 - Please Report this on the Forums - ");  
    Plr->Gossip_Complete();  
   return;  
   }  
   if(PLR_COIN < (REQ_COIN))  
   {    //ZOMG NO GOLD?  
    Plr->BroadcastMessage("You don't have enough gold to teleport to your house.");  
    Plr->Gossip_Complete();  
   return;  
   }  
    float x, y, z;  
    uint32 MapID;  
    Field * F_RESULT = Q_RESULTS_2->Fetch();  
    x = F_RESULT[1].GetFloat();  
    y = F_RESULT[2].GetFloat();  
    z = F_RESULT[3].GetFloat();  
    MapID = F_RESULT[4].GetUInt32();  
    Plr->EventTeleport(MapID, x, y, z);  
    Plr->Gossip_Complete();  
   }break;  

//CASE THREE - AVAILABLE HOUSE OPTIONS  
case 3:  
   {  
   objmgr.CreateGossipMenuForPlayer(&Menu, Ob->GetGUID(), 1, Plr);  
    Menu->AddItem(0, "This menu is under construction");  
    //WILL FINISH CREATURE SPAWNS AND OBJECT SPAWNS  
    //ONCE HOUSE LOCATIONS IN EACH ZONE ARE SET UP  
    //UNLESS I CAN FIGURE OUT A BETTER WAY  
    Menu->AddItem(1, "Purchase Repair Bot", 4);  
    Menu->AddItem(2, "Purchase Furniture", 5);  
    Menu->AddItem(3, "Purchase Armor Vendor", 6);  
    Menu->AddItem(4, "Purchase Weapon Vendor", 7);  
    Menu->AddItem(5, "Teleport List", 8);  
    Menu->SendTo(Plr);  
     }break;  
   //BEGINNING OF CASES  
//case OPEN:  
//    {  
//  Plr->FUNCTION(PARAMETERS);  
//      }break;  

   }  
};  
     
void H_MANAGER::GossipEnd(ObjectPointer Ob, PlayerPointer Plr)  
{  
   GossipScript::GossipEnd(Ob, Plr);  
}  
     
void SetupH_MANAGER(ScriptMgr * mgr)  
{  
   GossipScript * H_M = (GossipScript*) new H_MANAGER();  
   mgr->register_gossip_script(HOUSE_MANAGER, H_M);  
}

SETUP.CPP

Code
#include "StdAfx.h"  
#include "Setup.h"  
#define SKIP_ALLOCATOR_SHARING 1  
#include <ScriptSetup.h>  

extern "C" SCRIPT_DECL uint32 _exp_get_script_type()  
{  
          return SCRIPT_TYPE_MISC;  
}  

extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)  
{  
   SetupH_MANAGER(mgr);  
}  

#ifdef WIN32  

BOOL APIENTRY DllMain( HANDLE hModule, DWORD  ul_reason_for_call, LPVOID lpReserved )  
{  
      return TRUE;  
}  

#endif

SETUP.H

Code
#ifndef INSTANCE_SCRIPTS_SETUP_H  
#define INSTANCE_SCRIPTS_SETUP_H  

void SetupH_MANAGER(ScriptMgr * mgr);  

#endif

SQL Таблица. Заливать в Character Database

Code
DROP TABLE IF EXISTS "house_system";  

CREATE TABLE "house_system" (  
    "guild_id" int(6) unsigned NOT NULL DEFAULT '0',  
    "posX" float NOT NULL DEFAULT '0',  
    "posY" float NOT NULL DEFAULT '0',  
    "posZ" float NOT NULL DEFAULT '0',  
    "mapId" int(10) unsigned NOT NULL DEFAULT '0',  
    "zoneid" int(10) unsigned NOT NULL COMMENT 'zone id',  
    PRIMARY KEY ("zoneid")  
);

GUILD HOUSE MANAGER

Code
INSERT INTO `creature_names` (`entry`, `name`, `subname`, `info_str`, `Flags1`, `type`, `family`, `rank`, `unk4`, `spelldataid`, `male_displayid`, `female_displayid`, `male_displayid2`, `female_displayid2`, `unknown_float1`, `unknown_float2`, `civilian`, `leader`) VALUES ('40014', 'Housing Manager', 'Guild House Manager', '', '1', '7', '0', '4', '0', '0', '22220', '0', '0', '0', '1.0', '1.0', '0', '1');  
INSERT INTO `creature_proto` (`entry`, `minlevel`, `maxlevel`, `faction`, `minhealth`, `maxhealth`, `mana`, `scale`, `npcflags`, `attacktime`, `attacktype`, `mindamage`, `maxdamage`, `rangedattacktime`, `rangedmindamage`, `rangedmaxdamage`, `item1`, `item2`, `item3`, `RespawnTime`, `resistance1`, `resistance2`, `resistance3`, `resistance4`, `resistance5`, `resistance6`, `resistance7`, `combat_reach`, `bounding_radius`, `auras`, `boss`, `money`, `invisibility_type`, `death_state`, `walk_speed`, `run_speed`, `fly_speed`, `extra_a9_flags`, `auraimmune_flag`, `vehicle_entry`, `CanMove`) VALUES ('40014', '80', '80', '35', '50000', '50000', '0', '1.0', '3', '3000', '0', '20000.0', '20000.0', '0', '0.0', '0.0', '0', '0', '0', '30000', '1', '1', '1', '1', '1', '1', '0', '0.0', '0.0', '0', '1', '0', '0', '0', '2.5', '8.0', '14.0', '0', '0', '-1', '7');
Сообщение # 1 написано 10.10.2010 в 20:53
  • Страница 1 из 1
  • 1
Поиск: