Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Guild forge and rename system
- Scripted by Grandelf
- ]]--
- GUILDS = {}
- GUILDS.NPCID = 4315 -- Put your npc id here.
- function GUILDS.GuildForgeOnTalk(pUnit, event, player)
- if (player:IsInGuild() == true) and (player:GetGuildLeader() == player:GetName()) then
- pUnit:GossipCreateMenu(50, player, 0)
- pUnit:GossipMenuAddItem(0, "Enter the guildname to forge with.", 1, 1)
- pUnit:GossipMenuAddItem(0, "Change my guild name.", 2, 1)
- pUnit:GossipMenuAddItem(0, "Nevermind", 3, 0)
- pUnit:GossipSendMenu(player)
- else
- player:SendBroadcastMessage("You have to be the guildmaster of a guild in order to use this.")
- end
- end
- function GUILDS.GuildForgeOnGossip(pUnit, event, player, id, intid, code)
- if (intid == 1) then
- if (CharDBQuery("SELECT guildName FROM guilds WHERE guildName = '"..code.."'", 0) ~= false) then
- local GuildId = player:GetGuildId()
- if (string.lower(CharDBQuery("SELECT guildName FROM guilds WHERE guildId = '"..GuildId.."'", 0)) ~= string.lower(code)) then
- if (GUILDS[player:GetName()] == nil) or (GUILDS[player:GetName()].IsForging == 0) then
- local GuildIdB = CharDBQuery("SELECT guildId FROM guilds WHERE guildName = '"..code.."'", 0)
- local LeaderGuid = CharDBQuery("SELECT leaderGuid FROM guilds WHERE guildId = '"..GuildIdB.."'", 0)
- local plr = GetPlayer(CharDBQuery("SELECT name FROM characters WHERE guid = '"..LeaderGuid.."'", 0))
- if (plr ~= nil) then
- plr:SendBroadcastMessage(""..player:GetName().." wants to forge guilds with you. Typ #yes to accept and #no to decline. You have 20 seconds.")
- GUILDS[player:GetName()] = {}
- GUILDS[plr:GetName()] = {}
- GUILDS[player:GetName()].IsForging = 1
- GUILDS[plr:GetName()].IsForging = 1
- GUILDS[plr:GetName()].MsgAllowed = 1
- GUILDS[plr:GetName()].GuildId = player:GetGuildId()
- GUILDS[plr:GetName()].GuildIdB = GuildIdB
- GUILDS[plr:GetName()].ForgingWith = player:GetName()
- RegisterTimedEvent("GUILDS.Time", 20000, 1, player, plr)
- player:SendBroadcastMessage("Sending offer...")
- player:GossipComplete()
- else
- player:SendBroadcastMessage("The guildmaster of this guild is not online at this moment.")
- player:GossipComplete()
- end
- else
- player:SendBroadcastMessage("You are already forging")
- player:GossipComplete()
- end
- else
- player:SendBroadcastMessage("You cannot forge your own guild with your guild.")
- player:GossipComplete()
- end
- else
- player:SendBroadcastMessage("This guild does not exist.")
- player:GossipComplete()
- end
- end
- if (intid == 2) then
- if (GUILDS[player:GetName()] == nil) or (GUILDS[player:GetName()].IsForging == 0) then
- CharDBQuery("UPDATE guilds SET guildName = '"..code.."' WHERE guildId = '"..player:GetGuildId().."'", 0)
- player:SendBroadcastMessage("Your guildname is succesfully changed to "..code..". It will take effect after the next server restart.")
- player:GossipComplete()
- else
- player:SendBroadcastMessage("You cannot do this while forging your guild. Try again after next server restart.")
- player:GossipComplete()
- end
- end
- if (intid == 3) then
- player:GossipComplete()
- end
- end
- function GUILDS.OnForgeGuildChat(event, player, message, type, language)
- if (GUILDS[player:GetName()] == nil) or (GUILDS[player:GetName()].MsgAllowed == 0) then
- else
- if (message == "#yes") then
- local GuildId = GUILDS[player:GetName()].GuildId
- local GuildIdB = GUILDS[player:GetName()].GuildIdB
- local LeaderGuid = CharDBQuery("SELECT leaderGuid FROM guilds WHERE guildId = '"..GuildId.."'", 0)
- local plr = GetPlayer(CharDBQuery("SELECT name FROM characters WHERE guid = '"..LeaderGuid.."'", 0))
- GUILDS.ForgeGuilds(GuildId, GuildIdB)
- player:SendBroadcastMessage("You have succesfully forged your guild. After the next server restart your guilds are forged")
- plr:SendBroadcastMessage("You have succesfully forged your guild. After the next server restart your guilds are forged")
- GUILDS[player:GetName()].IsForging = 2
- elseif (message == "#no") then
- player:SendBroadcastMessage("You have declined to forge guilds")
- local GuildId = GUILDS[player:GetName()].GuildId
- local LeaderGuid = CharDBQuery("SELECT leaderGuid FROM guilds WHERE guildId = '"..GuildId.."'", 0)
- local plr = GetPlayer(CharDBQuery("SELECT name FROM characters WHERE guid = '"..LeaderGuid.."'", 0))
- plr:SendBroadcastMessage(""..player:GetName().." has declined your offer.")
- GUILDS[plr:GetName()].IsForging = 0
- GUILDS[player:GetName()].IsForging = 0
- GUILDS[player:GetName()].MsgAllowed = 0
- end
- return 0
- end
- end
- function GUILDS.Time(player, plr)
- if (GUILDS[plr:GetName()].IsForging == 1) then
- GUILDS[player:GetName()].IsForging = 0
- GUILDS[plr:GetName()].IsForging = 0
- GUILDS[plr:GetName()].MsgAllowed = 0
- player:SendBroadcastMessage(""..plr:GetName().." did not respond. Try to forge your guild later.")
- end
- end
- function GUILDS.ForgeGuilds(GuildId, GuildIdB)
- local LeaderGuid = CharDBQuery("SELECT leaderGuid FROM guilds WHERE guildId = '"..GuildIdB.."'", 0)
- CharDBQuery("UPDATE guild_data SET guildRank = '4' WHERE guildid = '"..GuildIdB.."'", 0)
- CharDBQuery("UPDATE guild_data SET guildRank = '0' WHERE playerid = '"..LeaderGuid.."'", 0)
- CharDBQuery("UPDATE guild_data SET guildid = '"..GuildId.."' WHERE guildid = '"..GuildIdB.."'", 0)
- CharDBQuery("DELETE FROM guilds WHERE guildId = '"..GuildIdB.."'", 0)
- CharDBQuery("DELETE FROM guild_ranks WHERE guildId = '"..GuildIdB.."'", 0)
- CharDBQuery("DELETE FROM guild_logs WHERE guildid = '"..GuildIdB.."'", 0)
- CharDBQuery("DELETE FROM guild_banktabs WHERE guildId = '"..GuildIdB.."'", 0)
- CharDBQuery("DELETE FROM guild_bankitems WHERE guildId = '"..GuildIdB.."'", 0)
- CharDBQuery("DELETE FROM guild_banklogs WHERE guildid = '"..GuildIdB.."'", 0)
- end
- RegisterUnitGossipEvent(GUILDS.NPCID, 1, "GUILDS.GuildForgeOnTalk")
- RegisterUnitGossipEvent(GUILDS.NPCID, 2, "GUILDS.GuildForgeOnGossip")
- RegisterServerHook(16, "GUILDS.OnForgeGuildChat")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement