This commit is contained in:
lifestorm
2024-08-04 23:54:45 +03:00
parent 0e770b2b49
commit df294d03aa
7526 changed files with 4011945 additions and 15 deletions

View File

@@ -0,0 +1,149 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
function PLUGIN:CreateMenuButtons(tabs)
tabs["Grup"] = {
RowNumber = 4,
Width = 23,
Height = 17,
Icon = "willardnetworks/tabmenu/charmenu/faction.png",
Create = function(info, container)
local panel = container:Add("ixGroup")
ix.gui.group = panel
end
}
end
function PLUGIN:ShouldShowPlayerOnScoreboard(client, panel)
if (!panel.group and client.group and !client.group.hidden and !panel.faction.separateUnknownTab) then
return false
end
end
local function SyncGroup(group)
if (!group or table.IsEmpty(group)) then return end
local id = group.id
local stored = PLUGIN:FindGroup(id)
local groupTable = stored or table.Copy(ix.meta.group)
groupTable:FromTable(group)
if (!stored) then
PLUGIN.stored[id] = groupTable
end
local client = LocalPlayer()
local character = client.GetCharacter and client:GetCharacter()
if (character) then
local clientGroup = character:GetGroup()
if ((clientGroup and clientGroup.id == id or !clientGroup) and IsValid(ix.gui.group)) then
ix.gui.group:Rebuild()
netstream.Start("ixGroupRequestMembers", group.id)
end
if (IsValid(ix.gui.scoreboard)) then
ix.gui.scoreboard:Update()
end
end
end
local function SyncGroupThird(group)
if (!group or table.IsEmpty(group)) then return end
local id = group.id
local stored = PLUGIN:FindGroup(id)
local groupTable = table.Copy(ix.meta.group)
groupTable:FromTableThird(group)
PLUGIN.stored[id] = groupTable
local client = LocalPlayer()
local character = client.GetCharacter and client:GetCharacter()
if (character) then
local clientGroup = character:GetGroup()
if ((clientGroup and clientGroup.id == id or !clientGroup) and IsValid(ix.gui.group)) then
ix.gui.group:Rebuild()
netstream.Start("ixGroupRequestMembers", group.id)
end
if (IsValid(ix.gui.scoreboard)) then
ix.gui.scoreboard:Update()
end
end
end
netstream.Hook("ixGroupSync", function(group)
SyncGroup(group)
end)
netstream.Hook("ixGroupSyncNotOwned", function(group)
SyncGroupThird(group)
end)
netstream.Hook("ixGroupSyncAll", function(groups)
for _, v in pairs(groups) do
SyncGroup(v)
end
end)
netstream.Hook("ixGroupInvite", function(groupID, client)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local inviteUI = vgui.Create("ixGroupInvite")
inviteUI.groupID = groupID
inviteUI.nameText = group:GetName()
inviteUI.whoInvited = client:GetName()
end
end)
netstream.Hook("ixGroupSendMembers", function(members)
if (IsValid(ix.gui.group)) then
if ix.gui.group:IsVisible() then
ix.gui.group.receivedMembers = members
if ix.gui.group.lastSelected then
if ix.gui.group.buttonlist then
if ix.gui.group.buttonlist[ix.gui.group.lastSelected] then
if ix.gui.group.buttonlist[ix.gui.group.lastSelected].DoClick() then
timer.Simple(0.05, function()
ix.gui.group.buttonlist[ix.gui.group.lastSelected].DoClick()
end)
end
end
end
else
if ix.gui.group.buttonlist[2] then
timer.Simple(0.05, function()
ix.gui.group.buttonlist[2].DoClick()
end)
end
end
end
end
end)
function PLUGIN:GetPlayerESPText(client, toDraw, distance, alphaFar, alphaMid, alphaClose)
if (!ix.option.Get("groupESP")) then return end
local character = client:GetCharacter()
local groupID = character:GetGroupID()
if (groupID and groupID > 0 and self.stored[groupID]) then
toDraw[#toDraw + 1] = {alpha = alphaClose, priority = 21, text = "Group: "..self.stored[groupID].name}
end
end

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,138 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
DEFINE_BASECLASS("ix_combinelock")
AddCSLuaFile()
ENT.Type = "anim"
ENT.PrintName = "Group Lock"
ENT.Category = "HL2 RP"
ENT.Spawnable = true
ENT.AdminOnly = true
ENT.PhysgunDisable = true
ENT.bNoPersist = true
function ENT:SetupDataTables()
self:NetworkVar("Bool", 0, "Locked")
self:NetworkVar("Bool", 1, "DisplayError")
self:NetworkVar("Bool", 2, "Disabled")
self:NetworkVar("Int", 3, "GroupID")
if (SERVER) then
self:NetworkVarNotify("Locked", self.OnLockChanged)
end
end
if (SERVER) then
function ENT:SpawnFunction(client, trace)
local character = client:GetCharacter()
local group = character:GetGroup()
local door = trace.Entity
if (!IsValid(door) or !door:IsDoor() or IsValid(door.ixLock)) then
return client:NotifyLocalized("dNotValid")
end
if (!group or !group.active) then
return client:Notify("Etkin bir grupta olmadan kilit yerleştiremezsiniz.")
end
local role = group:GetRoleID(character:GetID())
if (role != GROUP_LEAD and role != GROUP_MOD) then
return client:Notify("Grup kilidi yerleştirme izniniz yok.")
end
local normal = client:GetEyeTrace().HitNormal:Angle()
local position, angles = self:GetLockPosition(door, normal)
local entity = ents.Create("ix_grouplock")
entity:SetPos(trace.HitPos)
entity:Spawn()
entity:Activate()
entity:SetDoor(door, position, angles)
entity:SetGroupID(group:GetID())
entity:SetHealth(100)
ix.saveEnts:SaveEntity(entity)
return entity
end
function ENT:OnRemove()
if (IsValid(self)) then
self:SetParent(nil)
end
if (IsValid(self.door)) then
self.door:Fire("unlock")
self.door.ixLock = nil
end
if (IsValid(self.doorPartner)) then
self.doorPartner:Fire("unlock")
self.doorPartner.ixLock = nil
end
end
function ENT:Toggle(client)
if (self:GetDisabled()) then return end
if (self.nextUseTime > CurTime()) then
return
end
local group = client:GetCharacter():GetGroup()
if (!client:HasActiveCombineSuit() and !ix.faction.Get(client:Team()).allowUseGroupLock and (!group or group:GetID() != self:GetGroupID())) then
self:DisplayError()
self.nextUseTime = CurTime() + 2
return
end
self:SetLocked(!self:GetLocked())
self.nextUseTime = CurTime() + 2
ix.saveEnts:SaveEntity(self)
end
else
local glowMaterial = ix.util.GetMaterial("sprites/glow04_noz")
local color_green = Color(0, 255, 0, 255)
local color_purple = Color(138, 43, 226, 255)
local color_red = Color(255, 50, 50, 255)
function ENT:GetLightColor()
local color = color_green
if (self:GetDisplayError()) then
color = color_red
elseif (self:GetLocked()) then
color = color_purple
end
color.a = 255 * self:Health() / 100
return color
end
function ENT:Draw()
self:DrawModel()
if (self:GetDisabled()) then return end
local position = self:GetPos() + self:GetUp() * -8.7 + self:GetForward() * -3.85 + self:GetRight() * -6
render.SetMaterial(glowMaterial)
render.DrawSprite(position, 10, 10, self:GetLightColor())
end
end

View File

@@ -0,0 +1,51 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
ITEM.name = "Group Lock"
ITEM.description = "A metal apparatus applied to doors. Requires a group to function."
ITEM.model = Model("models/willardnetworks/props_combine/wn_combine_lock.mdl")
ITEM.width = 1
ITEM.height = 2
ITEM.iconCam = {
pos = Vector(-0.5, 50, 2),
ang = Angle(0, 270, 0),
fov = 25.29
}
ITEM.functions.Place = {
OnRun = function(itemTable)
local client = itemTable.player
if !client.CantPlace then
local data = {}
data.start = client:GetShootPos()
data.endpos = data.start + client:GetAimVector() * 96
data.filter = client
local lock = scripted_ents.Get("ix_grouplock"):SpawnFunction(client, util.TraceLine(data))
if (IsValid(lock)) then
client.CantPlace = true
client:EmitSound("physics/metal/weapon_impact_soft2.wav", 75, 80)
timer.Simple(3, function()
if client then
client.CantPlace = false
end
end)
else
return false
end
else
client:NotifyLocalized("Bunu yerleştirmek için biraz beklemelisin!")
return false
end
end
}

View File

@@ -0,0 +1,17 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
local CHAR = ix.meta.character
function CHAR:GetGroup()
return PLUGIN:FindGroup(self:GetGroupID())
end

View File

@@ -0,0 +1,279 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
GROUP_LEAD = 0
GROUP_MOD = 1
GROUP_MEMBER = 999
local GROUP = ix.meta.group or {}
GROUP.id = GROUP.id or 0
GROUP.name = GROUP.name or "Undefined"
GROUP.color = GROUP.color or Color(math.random(1, 255), math.random(1, 255), math.random(1, 255))
GROUP.hidden = GROUP.hidden == nil and true or GROUP.hidden
GROUP.info = GROUP.info or ""
GROUP.lore = GROUP.lore or ""
GROUP.forum = GROUP.forum or ""
GROUP.active = GROUP.active == nil and false or GROUP.active
GROUP.roles = GROUP.roles or {}
GROUP.members = GROUP.members or {}
function GROUP:GetID()
return self.id
end
function GROUP:GetName()
return self.name
end
function GROUP:GetMemberCharacters()
return table.GetKeys(self.members)
end
function GROUP:GetMembersCount()
return table.Count(self.members)
end
function GROUP:GetOnlineMembers()
local members = {}
for _, v in ipairs(player.GetAll()) do
local character = v:GetCharacter()
if (character and self.members[character:GetID()]) then
table.insert(members, v)
end
end
return members
end
function GROUP:GetTable()
return {
id = self.id,
name = self.name,
color = self.color,
hidden = self.hidden,
info = self.info,
lore = self.lore,
forum = self.forum,
active = self.active,
roles = self.roles,
members = self.members
}
end
function GROUP:Save(bSync)
local query = mysql:Update("ix_groups")
query:Where("id", self.id)
query:Update("name", self.name)
query:Update("active", self.active and 1 or 0)
query:Update("hidden", self.hidden and 1 or 0)
query:Update("color_r", self.color.r)
query:Update("color_g", self.color.g)
query:Update("color_b", self.color.b)
query:Update("color_a", self.color.a)
query:Update("roles", util.TableToJSON(self.roles))
query:Update("members", util.TableToJSON(self.members))
query:Update("info", self.info)
query:Update("lore", self.lore)
query:Update("forum", self.forum)
query:Execute()
if (bSync) then
self:Sync()
end
end
function GROUP:CreateDB(character)
self.members[character:GetID()] = GROUP_LEAD
local query = mysql:Insert("ix_groups")
query:Insert("name", self.name)
query:Insert("active", self.active and 1 or 0)
query:Insert("hidden", self.hidden and 1 or 0)
query:Insert("color_r", self.color.r)
query:Insert("color_g", self.color.g)
query:Insert("color_b", self.color.b)
query:Insert("color_a", self.color.a)
query:Insert("roles", util.TableToJSON(self.roles))
query:Insert("members", util.TableToJSON(self.members))
query:Insert("info", self.info)
query:Insert("lore", self.lore)
query:Insert("forum", self.forum)
query:Callback(function(result, _, insertID)
self.id = insertID
PLUGIN.stored[insertID] = self
self:AddMember(character, GROUP_LEAD)
self:Sync()
end)
query:Execute()
end
function GROUP:FromDB(group)
self.id = group.id
self.name = group.name
self.color = Color(group.color_r, group.color_g, group.color_b, group.color_a)
self.hidden = group.hidden == 1
self.info = group.info
self.lore = group.lore
self.forum = group.forum
self.active = group.active == 1
self.roles = util.JSONToTable(group.roles)
self.members = util.JSONToTable(group.members)
PLUGIN.stored[self.id] = self
end
function GROUP:FromTable(group)
self.id = group.id
self.name = group.name
self.color = group.color
self.hidden = group.hidden
self.info = group.info
self.lore = group.lore
self.forum = group.forum
self.active = group.active
self.roles = group.roles
self.members = group.members
end
function GROUP:FromTableThird(group)
self.id = group.id
self.name = group.name
end
function GROUP:GetRole(characterID)
return self.roles[self.members[characterID]]
end
function GROUP:GetRoleID(characterID)
return self:GetRole(characterID).id
end
function GROUP:GetRoles()
return self.roles
end
function GROUP:GetRoleData(role)
return self.roles[role]
end
if (SERVER) then
function GROUP:Sync(client)
netstream.Start(client, "ixGroupSync", self:GetTable())
end
function GROUP:SyncThird(client)
local tbl = {}
tbl.id = self.id
tbl.name = self.name
netstream.Start(client, "ixGroupSyncNotOwned", tbl)
if client then
local character = client:GetCharacter() or nil
if character and self.members[character:GetID()] then
netstream.Start(client, "ixGroupSync", self:GetTable())
end
end
end
function GROUP:AddMember(character, role)
if (character) then
self.members[character:GetID()] = role or GROUP_MEMBER
character:SetGroupID(self:GetID())
character:Save()
self:Sync()
if (self:GetMembersCount() > 3 and !self.active) then
self.active = true
end
end
end
function GROUP:KickMember(characterID)
if (self.members[characterID]) then
local character = ix.char.loaded[characterID]
local deleting = false
if (self:GetRoleID(characterID) == GROUP_LEAD and !self.active) then
self:NotifyAll("Leader has disbanded your group.")
deleting = true
end
self.members[characterID] = nil
if (character) then
character:SetGroupID(-1)
character:Save()
self:Sync(character:GetPlayer())
else
local query = mysql:Update("ix_characters")
query:Update("group", -1)
query:Where("id", characterID)
query:Execute()
PLUGIN.cache[characterID] = nil
end
if (table.IsEmpty(self.members) or deleting) then
PLUGIN:DeleteGroup(self.id)
end
end
end
function GROUP:SetRole(characterID, role)
self.members[characterID] = self.roles[role] and role
end
function GROUP:AddRole(data)
if (data.id) then
self.roles[data.id] = data
else
local id = table.insert(self.roles, data)
self.roles[id].id = id
end
end
function GROUP:EditRole(role, data)
if (self.roles[role]) then
self.roles[role] = data
end
end
function GROUP:NotifyAll(text)
for _, v in pairs(self:GetOnlineMembers()) do
v:NotifyLocalized(text)
end
end
if (table.IsEmpty(GROUP:GetRoles())) then
GROUP:AddRole({
id = GROUP_LEAD,
name = "Group Lead"
})
GROUP:AddRole({
id = GROUP_MOD,
name = "Group Moderator"
})
GROUP:AddRole({
id = GROUP_MEMBER,
name = "Member"
})
end
end
ix.meta.group = GROUP

View File

@@ -0,0 +1,204 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
ix.command.Add("GroupInvite", {
description = "Invite a player you are looking at to join your group.",
arguments = ix.type.text,
OnRun = function(self, client, message)
local character = client:GetCharacter()
local group = character:GetGroup()
if (group) then
local role = group:GetRoleID(character:GetID())
if (role == GROUP_LEAD or role == GROUP_MOD) then
local data = {}
data.start = client:GetShootPos()
data.endpos = data.start + client:GetAimVector() * 96
data.filter = client
local target = util.TraceLine(data).Entity
if (IsValid(target) and target:IsPlayer()) then
local targetGroup = target:GetCharacter():GetGroup()
if (targetGroup) then
client:Notify(target:GetName().." zaten "..(targetGroup:GetID() != group:GetID() and "başka" or "sizin").." gruba ait.")
target:Notify(client:GetName().." sizi şu gruba davet etmeye çalıştı: '"..group:GetName().."'.")
return
end
if (target:IsBot()) then
group:AddMember(target:GetCharacter())
group:Sync()
for k, v in pairs(group:GetOnlineMembers()) do
v:Notify(target:GetName().." gruba katıldı "..group:GetName()..".")
end
else
netstream.Start(target, "ixGroupInvite", group:GetID(), client)
end
client:Notify(target:GetName().." grubunuza davet edildi.")
else
client:NotifyLocalized("plyNotValid")
end
else
client:Notify("Gruba birini davet etme izniniz yok.")
end
else
client:Notify("Herhangi bir gruba ait değilsiniz.")
end
end
})
ix.command.Add("SetGroupName", {
description = "Rename existing group name.",
privilege = "Manage Groups",
arguments = {
ix.type.string,
ix.type.text
},
OnRun = function(self, client, name, nameTo)
local group = PLUGIN:FindGroup(name)
if (group) then
for k, v in pairs(PLUGIN.stored) do
if (string.utf8lower(v.name) == string.utf8lower(nameTo) and v:GetID() != group:GetID()) then
client:Notify("Bu isme sahip grup zaten var.")
return
end
end
local oldName = group:GetName()
group.name = nameTo
group:Sync()
group:NotifyAll(client:GetName().." grubu "..oldName.." adından "..nameTo.." adına değiştirdi.")
end
end
})
ix.command.Add("DeleteGroup", {
description = "Delete existing group.",
privilege = "Manage Groups",
arguments = {
ix.type.text
},
OnRun = function(self, client, name)
local group = PLUGIN:FindGroup(name)
if (group) then
local activeGroup = group.active
if !activeGroup then
client:NotifyLocalized("Etkin olmayan bir grubu kaldıramazsınız.")
return
end
group:NotifyAll(client:GetName().." grubunuzu sildi.")
for k, v in pairs(group:GetMemberCharacters()) do
group:KickMember(v)
end
PLUGIN:DeleteGroup(group.id)
client:NotifyLocalized("Grup: "..group:GetName().." başarıyla silindi.")
else
client:NotifyLocalized("Bu grup yok.")
end
end
})
ix.command.Add("SetGroupLead", {
description = "Set new group lead.",
privilege = "Manage Groups",
arguments = {
ix.type.string,
ix.type.character
},
OnRun = function(self, client, name, target)
local group = PLUGIN:FindGroup(name)
if (group) then
local members = group:GetMemberCharacters()
for k, v in pairs(members) do
if (group:GetRoleID(v) == GROUP_LEAD) then
group:SetRole(v, GROUP_MOD)
break
end
end
local targetID = target:GetID()
if (members[targetID]) then
group:SetRole(targetID, GROUP_LEAD)
else
group:AddMember(target, GROUP_LEAD)
end
group:NotifyAll(client:GetName().." grup liderliğini aktardı: "..target:GetName()..".")
end
end
})
ix.command.Add("AdminJoinGroup", {
description = "Force any character to join certain group.",
privilege = "Manage Groups",
arguments = {
ix.type.character,
ix.type.string
},
OnRun = function(self, client, target, name)
local group = PLUGIN:FindGroup(name)
if (group) then
local targetID = target:GetID()
local prevGroup = target:GetGroup()
if (prevGroup) then
if (group:GetID() == prevGroup:GetID()) then
client:Notify(target:GetName().." zaten bu gruba ait.")
return
end
prevGroup:KickMember(targetID)
end
group:AddMember(target)
group:NotifyAll(client:GetName()..", "..target:GetName().." adlı kişiyi gruba ekledi.")
else
client:NotifyLocalized("Bu grup yok.")
end
end
})
ix.command.Add("AdminKickGroup", {
description = "Kick any character from the group they're in.",
privilege = "Manage Groups",
arguments = {
ix.type.character
},
OnRun = function(self, client, target, name)
local targetID = target:GetID()
local group = target:GetGroup()
if (group) then
group:KickMember(targetID)
group:NotifyAll(client:GetName()..", "..target:GetName().." adlı kişiyi gruptan attı.")
else
client:NotifyLocalized("Bu karakter herhangi bir gruba ait değil.")
end
end
})

View File

@@ -0,0 +1,109 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
PLUGIN.name = "Group Manager"
PLUGIN.author = "AleXXX_007, Fruity"
PLUGIN.description = "Allow players to create their own in-game groups with custom name and roles."
PLUGIN.stored = PLUGIN.stored or {}
CAMI.RegisterPrivilege({
Name = "Helix - Manage Groups",
MinAccess = "admin"
})
ix.option.Add("groupESP", ix.type.bool, true, {
category = "observer",
hidden = function()
return !CAMI.PlayerHasAccess(LocalPlayer(), "Helix - Observer", nil)
end
})
ix.char.RegisterVar("groupID", {
field = "group",
fieldType = ix.type.number,
default = -1,
bNoDisplay = true,
OnSet = function(self, value)
local client = self:GetPlayer()
if (IsValid(client)) then
self.vars.groupID = value
net.Start("ixCharacterVarChanged")
net.WriteUInt(self:GetID(), 32)
net.WriteString("groupID")
net.WriteType(self.vars.groupID)
net.Broadcast()
end
end,
OnGet = function(self, default)
local groupID = self.vars.groupID
return groupID or 0
end,
OnAdjust = function(self, client, data, value, newData)
newData.groupID = value
end
})
ix.util.Include("cl_hooks.lua")
ix.util.Include("sh_commands.lua")
ix.util.Include("sv_hooks.lua")
function PLUGIN:FindGroup(groupID)
if (isnumber(groupID)) then
return groupID != -1 and self.stored[groupID] or nil
elseif (isstring(groupID)) then
for k, v in pairs(self.stored) do
if (string.utf8lower(v:GetName()) == string.utf8lower(groupID)) then
return v
end
end
end
end
function PLUGIN:GetGroups()
return self.stored
end
properties.Add("grouplock_checkowner", {
MenuLabel = "Check Owner",
Order = 399,
MenuIcon = "icon16/user.png",
Filter = function(self, entity, client)
if (entity:GetClass() != "ix_grouplock") then return false end
if (!gamemode.Call("CanProperty", client, "grouplock_checkowner", entity)) then return false end
return true
end,
Action = function(self, entity)
self:MsgStart()
net.WriteEntity(entity)
self:MsgEnd()
end,
Receive = function(self, length, client)
local entity = net.ReadEntity()
if (!IsValid(entity)) then return end
if (!self:Filter(entity, client)) then return end
local groupID = entity:GetGroupID()
if (!groupID or !PLUGIN:GetGroups()[groupID]) then client:Notify("Bu kilit herhangi bir gruba ait değil.") return end
client:Notify("Bu kilit şu gruba ait: '" .. PLUGIN:GetGroups()[groupID]:GetName() .. "'.")
end
})

View File

@@ -0,0 +1,560 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local PLUGIN = PLUGIN
PLUGIN.cache = PLUGIN.cache or {}
local cache = PLUGIN.cache
function PLUGIN:DatabaseConnected()
local query = mysql:Create("ix_groups")
query:Create("id", "INT UNSIGNED NOT NULL AUTO_INCREMENT")
query:Create("name", "VARCHAR(50) NOT NULL")
query:Create("active", "TINYINT(1) NOT NULL")
query:Create("hidden", "TINYINT(1) NOT NULL")
query:Create("color_r", "TINYINT UNSIGNED NOT NULL")
query:Create("color_g", "TINYINT UNSIGNED NOT NULL")
query:Create("color_b", "TINYINT UNSIGNED NOT NULL")
query:Create("color_a", "TINYINT UNSIGNED NOT NULL")
query:Create("roles", "TEXT NOT NULL")
query:Create("members", "TEXT NOT NULL")
query:Create("info", "TEXT NOT NULL")
query:Create("lore", "TEXT NOT NULL")
query:Create("forum", "TEXT NOT NULL")
query:Callback(function()
local load = mysql:Select("ix_groups")
load:Callback(function(result)
if (!result) then return end
for _, v in ipairs(result) do
local group = table.Copy(ix.meta.group)
group:FromDB(v)
end
end)
load:Execute()
end)
query:PrimaryKey("id")
query:Execute()
end
function PLUGIN:RegisterSaveEnts()
ix.saveEnts:RegisterEntity("ix_grouplock", true, true, true, {
OnSave = function(entity, data) --OnSave
data.pos = entity.door:GetPos()
data.angles = nil
data.door = entity.door:MapCreationID()
data.localPos = entity.door:WorldToLocal(entity:GetPos())
data.localAngs = entity.door:WorldToLocalAngles(entity:GetAngles())
data.locked = entity:GetLocked()
data.group = entity:GetGroupID()
end,
OnRestore = function(entity, data) --OnRestore
local door = ents.GetMapCreatedEntity(data.door)
entity:SetDoor(door, door:LocalToWorld(data.localPos), door:LocalToWorldAngles(data.localAngs))
entity:SetLocked(data.locked)
entity:SetGroupID(data.group)
end,
ShouldSave = function(entity) --ShouldSave
return IsValid(entity.door) and entity:GetGroupID() != 0
end,
ShouldRestore = function(data) --ShouldRestore
local door = ents.GetMapCreatedEntity(data.door)
return IsValid(door) and door:IsDoor()
end
})
end
gameevent.Listen( "player_activate" )
hook.Add( "player_activate", "player_activate_example", function( data )
local id = data.userid
local client = Player(id)
local plugin = ix.plugin.Get("groupmanager")
plugin:SyncAllGroups(client)
end )
function PLUGIN:CharacterLoaded(character)
if (!table.IsEmpty(self.stored)) then
for k, v in pairs(self.stored) do
if (v:GetID() == k) then
local client = character:GetPlayer()
v:Sync(client)
end
end
end
end
function PLUGIN:DeleteGroup(groupID)
local group = self:FindGroup(groupID)
if (group) then
for _, v in pairs(group:GetMemberCharacters()) do
group:KickMember(v)
end
self.stored[groupID] = nil
local query = mysql:Delete("ix_groups")
query:Where("id", group.id)
query:Execute()
self:SyncAllGroups()
local messageQuery = mysql:Delete("ix_comgroupmessages")
messageQuery:Where("message_groupid", groupID)
messageQuery:Callback(function(result)
local replyQuery = mysql:Delete("ix_comgroupreplies")
replyQuery:Where("reply_groupid", groupID)
replyQuery:Execute()
end)
messageQuery:Execute()
end
end
function PLUGIN:SyncAllGroups(client)
if (!table.IsEmpty(self.stored)) then
for k, v in pairs(self.stored) do
if (v:GetID() == k) then
v:SyncThird(client)
end
end
end
end
function PLUGIN:OnCharacterBanned(character, time)
local group = character:GetGroup()
if (group and ix.config.Get("permakill") and character and character:GetData("permakilled")) then
group:KickMember(character:GetID())
group:Save()
end
end
netstream.Hook("ixGroupCreate", function(client, name)
if (!client:GetCharacter()) then return end
if (client:GetCharacter():GetGroup()) then return end
for _, v in pairs(PLUGIN.stored) do
if (string.utf8lower(v.name) == string.utf8lower(name)) then
client:Notify("Bu ada sahip grup zaten var.")
return
end
end
local group = table.Copy(ix.meta.group)
group.name = name
group:CreateDB(client:GetCharacter())
end)
netstream.Hook("ixGroupLeave", function(client)
local character = client:GetCharacter()
local group = character:GetGroup()
if (group) then
local charID = character:GetID()
if (group:GetRoleID(charID) == GROUP_LEAD and group.active) then
client:Notify("Lideri olduğunuz gruptan ayrılamazsınız.")
return
end
group:KickMember(charID)
group:Save(true)
client:Notify("Gruptan ayrıldınız: "..group:GetName()..".")
group:NotifyAll(client:GetName().." gruptan ayrıldı: "..group:GetName()..".")
end
end)
netstream.Hook("ixGroupInvite", function(client, groupID)
local group = PLUGIN:FindGroup(groupID)
local character = client:GetCharacter()
if (character:GetGroup()) then
client:Notify("Başka bir gruba katılamıyorsunuz.")
return
end
if (group) then
group:AddMember(character)
group:Save(true)
client:Notify("Gruba katıldınız: "..group:GetName()..".")
group:NotifyAll(client:GetName().." gruba katıldı: "..group:GetName()..".")
end
end)
netstream.Hook("ixGroupEditInfo", function(client, groupID, text)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD and role != GROUP_MOD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
group.info = text
group:Save(true)
group:NotifyAll(client:GetName().." grup bilgileri güncelledi.")
end
end)
netstream.Hook("ixGroupEditLore", function(client, groupID, text)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD and role != GROUP_MOD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
group.lore = text
group:Save(true)
group:NotifyAll(client:GetName().." grup hikayesini güncelledi.")
end
end)
netstream.Hook("ixGroupEditForum", function(client, groupID, text)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
group.forum = text
group:Save(true)
group:NotifyAll(client:GetName().." grup forumu bağlantısı güncelledi.")
end
end)
netstream.Hook("ixGroupEditName", function(client, groupID, text)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
for _, v in pairs(PLUGIN.stored) do
if (string.utf8lower(v.name) == string.utf8lower(text) and v:GetID() != group:GetID()) then
client:Notify("Bu ada sahip grup zaten var.")
return
end
end
local oldName = group:GetName()
group.name = text
group:Save(true)
group:NotifyAll(client:GetName().." grubu "..oldName.." adından "..text.." adına değiştirdi.")
end
end)
netstream.Hook("ixGroupEditColor", function(client, groupID, color)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
group.color = color
group:Save(true)
group:NotifyAll(client:GetName().." grup sekmesi rengini değiştirdi.")
end
end)
netstream.Hook("ixGroupRequestMembers", function(client, groupID)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local query = mysql:Select("ix_characters")
query:Select("id")
query:Select("name")
query:Select("description")
query:Select("steamid")
query:Select("last_join_time")
query:Where("group", group:GetID())
query:Where("schema", Schema and Schema.folder or "helix")
query:Callback(function(result)
if (istable(result) and #result > 0) then
local members = {}
for _, v in ipairs(result) do
local id = tonumber(v.id)
members[id] = v
members[id].online = ix.char.loaded[id] and IsValid(ix.char.loaded[id]:GetPlayer())
members[id].role = group.roles[group.members[id]]
end
for _, v in ipairs(player.GetAll()) do
if (v:IsBot() and v:GetCharacter() and v:GetCharacter():GetGroupID() == group:GetID()) then
members[v:GetCharacter():GetID()] = {
id = v:GetCharacter():GetID(),
name = v:Name(),
description = "This is a bot.",
steamid = v:SteamID(),
last_join_time = os.time(),
online = true,
role = group.roles[group.members[v:GetCharacter():GetID()]]
}
end
end
netstream.Start(client, "ixGroupSendMembers", members)
end
end)
query:Execute()
end
end)
netstream.Hook("ixGroupKick", function(client, groupID, charID)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local character = ix.char.loaded[charID]
local clientRole = group:GetRole(client:GetCharacter():GetID())
local targetRole = group:GetRole(charID)
if (targetRole) then
if (targetRole.id > clientRole.id) then
group:KickMember(charID)
group:Save(true)
if (character) then
if (character:GetPlayer():GetCharacter():GetID() == character:GetID()) then
character:GetPlayer():Notify("Gruptan atıldınız: "..group:GetName()..".")
end
group:NotifyAll(client:GetName()..", "..character:GetName().." adlı kişiyi gruptan attı.")
end
else
client:Notify("Bu üyeyi atamazsın.")
end
else
client:Notify("Üye bulunamadı.")
end
end
end)
netstream.Hook("ixGroupSetRole", function(client, groupID, charID, newRole)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local character = ix.char.loaded[charID]
local clientRole = group:GetRole(client:GetCharacter():GetID())
local roleData = group:GetRoleData(newRole)
if (roleData) then
if (newRole < clientRole.id or clientRole.id == GROUP_LEAD) then
if (newRole == GROUP_LEAD) then
group:SetRole(client:GetCharacter():GetID(), GROUP_MOD)
end
group:SetRole(charID, newRole)
group:Save(true)
local charName = false
if (!character and cache[charID]) then
charName = cache[charID].name
if (istable(cache[charID].role) and !table.IsEmpty(cache[charID].role)) then
cache[charID].role = roleData
end
end
if (character or charName) then
local textName = character and character.name or charName
if (textName) then
group:NotifyAll(client:GetName()..", "..textName.." adlı kişinin rolünü "..roleData.name.." olarak ayarladı.")
end
end
else
client:Notify("Bu rolü ayarlayamazsınız.")
end
else
client:Notify("Rol bulunamadı.")
end
end
end)
netstream.Hook("ixGroupEditRoleName", function(client, groupID, roleID, text)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD and role != GROUP_MOD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
local roleData = group:GetRoleData(roleID)
if (roleData) then
local oldName = roleData.name
group.roles[roleData.id].name = text
group:Save(true)
group:NotifyAll(client:GetName()..", "..oldName.." rolünün adını "..text.." olarak değiştirdi.")
else
client:Notify("Rol bulunamadı.")
end
end
end)
netstream.Hook("ixGroupDeleteRole", function(client, groupID, roleID)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD and role != GROUP_MOD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
local roleData = group:GetRoleData(roleID)
local memberRole = group:GetRole(GROUP_MEMBER)
if (roleData) then
if (roleData.id == GROUP_LEAD or roleData.id == GROUP_MOD) then
client:Notify("Bu grup silinemez.")
return
end
for _, v in pairs(group:GetMemberCharacters()) do
if (group:GetRoleID(v) == roleID) then
group:SetRole(v, GROUP_MEMBER)
local character = ix.char.loaded[v]
if (character and character:GetPlayer():GetCharacter():GetID() == v) then
character:GetPlayer():Notify("Rolünüz silindi ve şu seviyeye düşürüldünüz: "..memberRole.name..".")
end
end
end
-- table.remove doesn't know how to shift values when there's a 999 (member) value in the end so here goes
for key, roleTable in pairs(group.roles, true) do
if key == roleID then
group.roles[key] = nil
end
if ( key > roleID ) and key != 999 and key != roleID then
local newKey = key - 1
group.roles[newKey] = roleTable
group.roles[newKey].id = newKey
group.roles[key] = nil
end
end
group:Save(true)
group:NotifyAll(client:GetName()..", "..roleData.name.." rolünü sildi.")
else
client:Notify("Rol bulunamadı.")
end
end
end)
netstream.Hook("ixGroupAddRole", function(client, groupID)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD and role != GROUP_MOD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
local id = table.Count(group.roles)
table.insert(group.roles, id, {
id = id,
name = "New Role"
})
group:Save(true)
client:Notify("Yeni rol eklendi.")
end
end)
netstream.Hook("ixGroupDelete", function(client, groupID)
local group = PLUGIN:FindGroup(groupID)
if (group) then
if (group:GetRoleID(client:GetCharacter():GetID()) == GROUP_LEAD) then
group:NotifyAll(client:GetName().." grubunuzu sildi.")
for _, v in pairs(group:GetMemberCharacters()) do
group:KickMember(v)
end
PLUGIN:DeleteGroup(group.id)
client:Notify("Grup: "..group:GetName().." başarıyla silindi.")
else
client:Notify("Bunu yapmak için izniniz yok.")
end
end
end)
netstream.Hook("ixGroupHidden", function(client, groupID, value)
local group = PLUGIN:FindGroup(groupID)
if (group) then
local charID = client:GetCharacter():GetID()
local role = group:GetRoleID(charID)
if (role != GROUP_LEAD) then
client:Notify("Bunu yapmak için izniniz yok.")
return
end
group.hidden = value
group:Save(true)
group:NotifyAll("Grup üyeleriniz oyuncu listesinde ayrı bir sekmede "..(!value and "gözükecek" or "gözükmeyecek"))
end
end)