Likes: 0
Results 1 to 10 of 11
Thread: [Lua] Guild zone system
-
15-03-10, 02:51 AM #1
[Lua] Guild zone system
Register to remove this adGuild zone system!
After a few guild systems got released, 0 worked for me, I decided to make one. I have tested this, and it worked 100%.
What this script does:
You can buy and sell zones. For an amount of copper you decide. You can have up to 5 zones. You can't buy zones in instances or restricted area's. You can add restricted areas in the script. In those zones you own you and your guild members can do some things listed down here:
#buy zone - To buy a zone. (Guild Master only.)
#sell zone zoneid - To sell a zone. (Guild Master only.)
#add tele - Add a place players can teleport to, have to be in one of the zones you own. (Guild Master only.)
#area tele - Teleport to the place the guildmaster set.
#zone info - Displays zone id and the status of the zone.
#owned zones - Displays zones your guild currently owns.
#buff - Buffs you while in a zone your guild owns.
#commands - Shows a list of commands available for you. Note: This script is using Areas not zones. Reason behind this is because zones are way to big.
You have to import this into your char DB:
Code:DROP TABLE IF EXISTS `guild`; CREATE TABLE `guild` ( `GuildId` int(19) default NULL, `Zone1` int(19) default NULL, `Zone2` int(19) default NULL, `Zone3` int(19) default NULL, `Zone4` int(19) default NULL, `Zone5` int(19) default NULL, `Map` int(8) default NULL, `PosX` float default NULL, `PosY` float default NULL, `PosZ` float default NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;
Code:<LuaHypArc AllowCharDBQueries="1">
PHP Code:GUILD = {}
local BuyZone = "#buy zone"
local SellZone = "#sell zone"
local AddTele = "#add tele"
local TeleMsg = "#area tele"
local ZoneInfo = "#zone info"
local OwnedZones = "#owned zones"
local Buff = "#buff"
local Commands = "#guild commands"
local BUYPRICE = 50000 -- Money needed to buy a zone, in copper.
local SELLPRICE = 50000 -- Money player gets when he sells a zone.
-- Add AREA ID's here players can't buy. So not the zone id, but the area id. You dont have to added instances, they are all blocked.
local NotBuyableAreas = {
1741, -- Gurubashi Tribune
2177, -- Gurubashi Ring
}
function GUILD.ZoneCommands(event, player, message, type, language)
local msg = message:lower(player)
if (msg == BuyZone) and (player:IsInGuild() == true) and (player:GetGuildLeader() == player:GetName()) then
if (GuildAreaCheck(player) == true) then
if (AreaCheck(player) == true) then
if (RestrictedArea(player) == true) and (player:GetInstanceID() == nil) then
if (player:GetCoinage() >= BUYPRICE) then
AddArea(player)
player:DealGoldCost(BUYPRICE)
player:SendBroadcastMessage("You succesfully bought this zone!")
else
player:SendBroadcastMessage("You dont have enough gold to buy this zone.")
end
else
player:SendBroadcastMessage("This zone is not for sale.")
end
else
player:SendBroadcastMessage("This zone is already bought by a guild.")
end
else
player:SendBroadcastMessage("Your guild already owns the maximum of allowed zones.")
end
return 0
end
if (msg:find(SellZone.." ") == 1) and (player:IsInGuild() == true) and (player:GetGuildLeader() == player:GetName()) then
local AreaId = msg:gsub(SellZone.." ", "")
if (OwnsArea(player, AreaId) == 1) then
CharDBQuery("UPDATE guild SET Zone1 = '0' WHERE GuildId = '"..player:GetGuildId().."'", 0)
player:SendBroadcastMessage("You succesfully sold zone "..AreaId..".")
player:DealGoldMerit(SELLPRICE)
elseif (OwnsArea(player, AreaId) == 2) then
CharDBQuery("UPDATE guild SET Zone2 = '0' WHERE GuildId = '"..player:GetGuildId().."'", 0)
player:DealGoldMerit(SELLPRICE)
player:SendBroadcastMessage("You succesfully sold zone "..AreaId..".")
elseif (OwnsArea(player, AreaId) == 3) then
CharDBQuery("UPDATE guild SET Zone3 = '0' WHERE GuildId = '"..player:GetGuildId().."'", 0)
player:SendBroadcastMessage("You succesfully sold zone "..AreaId..".")
player:DealGoldMerit(SELLPRICE)
elseif (OwnsArea(player, AreaId) == 4) then
CharDBQuery("UPDATE guild SET Zone4 = '0' WHERE GuildId = '"..player:GetGuildId().."'", 0)
player:SendBroadcastMessage("You succesfully sold zone "..AreaId..".")
player:DealGoldMerit(SELLPRICE)
elseif (OwnsArea(player, AreaId) == 5) then
CharDBQuery("UPDATE guild SET Zone5 = '0' WHERE GuildId = '"..player:GetGuildId().."'", 0)
player:SendBroadcastMessage("You succesfully sold zone "..AreaId..".")
player:DealGoldMerit(SELLPRICE)
else
player:SendBroadcastMessage("This zone is not yours!")
end
return 0
end
if (msg == AddTele) and (player:IsInGuild() == true) and (player:GetGuildLeader() == player:GetName()) then
local AreaId = tostring(player:GetAreaId())
if (OwnsArea(player, AreaId) == 1) or (OwnsArea(player, AreaId) == 2) or (OwnsArea(player, AreaId) == 3) or (OwnsArea(player, AreaId) == 4) or (OwnsArea(player, AreaId) == 5) then
CharDBQuery("UPDATE guild SET Map = '"..player:GetMapId().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
CharDBQuery("UPDATE guild SET PosX = '"..player:GetX().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
CharDBQuery("UPDATE guild SET PosY = '"..player:GetY().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
CharDBQuery("UPDATE guild SET PosZ = '"..player:GetZ().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
player:SendBroadcastMessage("You and your guildmembers can now teleport here by using "..TeleMsg..".")
else
player:SendBroadcastMessage("This zone is not yours!")
end
return 0
end
if (msg == TeleMsg) then
if (player:IsInGuild() == true) then
if (CharDBQuery("SELECT PosX FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") then
player:Teleport(CharDBQuery("SELECT Map FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0), CharDBQuery("SELECT PosX FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0), CharDBQuery("SELECT PosY FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0), CharDBQuery("SELECT PosZ FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0))
else
player:SendBroadcastMessage("Your guild does not have a zone or the guildmaster did not set a teleport position.")
end
else
player:SendBroadcastMessage("You have to be in a guild in order to use this command.")
end
return 0
end
if (msg == ZoneInfo) then
if (RestrictedArea(player) == false) or (player:GetInstanceID() ~= nil) then
player:SendBroadcastMessage("AreaId: "..player:GetAreaId()..".")
player:SendBroadcastMessage("Status: Cannot be bought.")
elseif (AreaCheck(player) == false) then
player:SendBroadcastMessage("AreaId: "..player:GetAreaId()..".")
player:SendBroadcastMessage("Status: Currently not for sale.")
else
player:SendBroadcastMessage("AreaId: "..player:GetAreaId()..".")
player:SendBroadcastMessage("Status: For sale.")
end
return 0
end
if (msg == OwnedZones) then
if (CharDBQuery("SELECT Zone1 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") or (CharDBQuery("SELECT Zone2 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") or (CharDBQuery("SELECT Zone3 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") or (CharDBQuery("SELECT Zone4 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") or (CharDBQuery("SELECT Zone5 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") then
player:SendBroadcastMessage("Area's your guild currently owns are:")
if (CharDBQuery("SELECT Zone1 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") then
player:SendBroadcastMessage(""..CharDBQuery("SELECT Zone1 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0).."")
end
if (CharDBQuery("SELECT Zone2 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") then
player:SendBroadcastMessage(""..CharDBQuery("SELECT Zone2 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0).."")
end
if (CharDBQuery("SELECT Zone3 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") then
player:SendBroadcastMessage(""..CharDBQuery("SELECT Zone3 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0).."")
end
if (CharDBQuery("SELECT Zone4 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") then
player:SendBroadcastMessage(""..CharDBQuery("SELECT Zone4 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0).."")
end
if (CharDBQuery("SELECT Zone5 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) ~= "0") then
player:SendBroadcastMessage(""..CharDBQuery("SELECT Zone5 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0).."")
end
else
player:SendBroadcastMessage("Your guild does not own any zones.")
end
return 0
end
if (msg == Buff) then
local AreaId = tostring(player:GetAreaId())
if (OwnsArea(player, AreaId) == 1) or (OwnsArea(player, AreaId) == 2) or (OwnsArea(player, AreaId) == 3) or (OwnsArea(player, AreaId) == 4) or (OwnsArea(player, AreaId) == 5) then
player:CastSpell(56525) -- Blessing of Kings
player:CastSpell(48162) -- Prayer of Fortitude
player:CastSpell(48074) -- Prayer of Spirit
player:CastSpell(48470) -- Gift of the Wild
player:CastSpell(53307) -- Thorns
else
player:SendBroadcastMessage("You can only use this in the areas your guild owns.")
end
return 0
end
if (msg == Commands) then
if (player:IsInGuild() == true) and (player:GetGuildLeader() == player:GetName()) then
player:SendBroadcastMessage("Commands available for you:")
player:SendBroadcastMessage(""..BuyZone.." - To buy a zone.")
player:SendBroadcastMessage(""..SellZone.." AreaId - To sell a zone.")
player:SendBroadcastMessage(""..AddTele.." - To add a teleport you and your guild members can use.")
player:SendBroadcastMessage(""..TeleMsg.." - Teleport to the place your guildmaster set.")
player:SendBroadcastMessage(""..ZoneInfo.." - Displays the status + area id of the area you are at.")
player:SendBroadcastMessage(""..OwnedZones.." - Displays the zones your guild currently owns.")
player:SendBroadcastMessage(""..Buff.." - Buffs you while in an area your guild owns.")
elseif (player:IsInGuild() == true) then
player:SendBroadcastMessage("Commands available for you:")
player:SendBroadcastMessage(""..TeleMsg.." - Teleport to the place your guildmaster set.")
player:SendBroadcastMessage(""..ZoneInfo.." - Displays the status + area id of the area you are at.")
player:SendBroadcastMessage(""..OwnedZones.." - Displays the zones your guild currently owns.")
player:SendBroadcastMessage(""..Buff.." - Buffs you while in an area your guild owns.")
end
return 0
end
end
function GuildAreaCheck(player)
if (CharDBQuery("SELECT Zone5 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == false) then
CharDBQuery("INSERT INTO guild(GuildId, Zone1, Zone2, Zone3, Zone4, Zone5, Map, PosX, PosY, PosZ) VALUES ('"..player:GetGuildId().."', '0', '0', '0', '0', '0', '0', '0', '0', '0')", 0)
return true
elseif (CharDBQuery("SELECT Zone1 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") or (CharDBQuery("SELECT Zone2 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") or (CharDBQuery("SELECT Zone3 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") or (CharDBQuery("SELECT Zone4 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") or (CharDBQuery("SELECT Zone5 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") then
return true
else
return false
end
end
function AreaCheck(player)
if (CharDBQuery("SELECT Zone1 FROM guild WHERE Zone1 = '"..player:GetAreaId().."'", 0) == false) and (CharDBQuery("SELECT Zone2 FROM guild WHERE Zone2 = '"..player:GetAreaId().."'", 0) == false) and (CharDBQuery("SELECT Zone3 FROM guild WHERE Zone3 = '"..player:GetAreaId().."'", 0) == false) and (CharDBQuery("SELECT Zone4 FROM guild WHERE Zone4 = '"..player:GetAreaId().."'", 0) == false) and (CharDBQuery("SELECT Zone5 FROM guild WHERE Zone5 = '"..player:GetAreaId().."'", 0) == false) then
return true
else
return false
end
end
function AddArea(player)
if (CharDBQuery("SELECT Zone1 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") then
CharDBQuery("UPDATE guild SET Zone1 = '"..player:GetAreaId().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
elseif (CharDBQuery("SELECT Zone2 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") then
CharDBQuery("UPDATE guild SET Zone2 = '"..player:GetAreaId().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
elseif (CharDBQuery("SELECT Zone3 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") then
CharDBQuery("UPDATE guild SET Zone3 = '"..player:GetAreaId().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
elseif (CharDBQuery("SELECT Zone4 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") then
CharDBQuery("UPDATE guild SET Zone4 = '"..player:GetAreaId().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
elseif (CharDBQuery("SELECT Zone5 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == "0") then
CharDBQuery("UPDATE guild SET Zone5 = '"..player:GetAreaId().."' WHERE GuildId = '"..player:GetGuildId().."'", 0)
end
end
function RestrictedArea(player)
for k, v in pairs(NotBuyableAreas) do
if (player:GetAreaId() ~= v) then
return true
else
return false
end
end
end
function OwnsArea(player, AreaId)
if (CharDBQuery("SELECT Zone1 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == AreaId) then
return 1
elseif (CharDBQuery("SELECT Zone2 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == AreaId) then
return 2
elseif (CharDBQuery("SELECT Zone3 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == AreaId) then
return 3
elseif (CharDBQuery("SELECT Zone4 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == AreaId) then
return 4
elseif (CharDBQuery("SELECT Zone5 FROM guild WHERE GuildId = '"..player:GetGuildId().."'", 0) == AreaId) then
return 5
else
return false
end
end
RegisterServerHook(16, "GUILD.ZoneCommands")
Credits:
Grandelf
› See More: [Lua] Guild zone systemLast edited by Dr. Fallen; 15-03-10 at 04:23 PM.
-
15-03-10, 01:01 PM #2
Would be nice if you gave credits to me at least.. because I see you remove the "Made by Grandelf" part of the script. Lua | --[[ Guild zone system. - Anonymous - 8y0xhP49 - Pastebin.com.
-
15-03-10, 01:09 PM #3
- Rep Power
- 0
- Reputation
- 87
-
15-03-10, 04:22 PM #4
Last edited by Dr. Fallen; 15-03-10 at 04:25 PM.
-
15-03-10, 04:24 PM #5
-
15-03-10, 04:27 PM #6
-
15-03-10, 04:27 PM #7
please
/flame off
-
15-03-10, 04:29 PM #8
-
15-03-10, 04:32 PM #9
Wasn't flaming =]. I never flame actually, I just asked him kindly to check that again. Also MysteriousSoul asked me to post Lua scripts here and then you tell me to GTFO? Besides, I am not just on there, I spend time at all forums =].
-
15-03-10, 04:35 PM #10
Register to remove this adNo touching please.