Skip to content

Commit

Permalink
Create bwhitelist.lua
Browse files Browse the repository at this point in the history
Добавлена поддержка bWhitelist
  • Loading branch information
AMD-NICK committed Aug 27, 2021
1 parent 7eeb2f3 commit 64726f4
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions addons/igs-core/lua/igs/extensions/bwhitelist.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
IGS.ITEMS.Whitelist = IGS.ITEMS.Whitelist or {}

local STORE_ITEM = FindMetaTable("IGSItem")

local function team_id(team_cmd)
return DarkRP.getJobByCommand(team_cmd).team
end

function STORE_ITEM:SetWhitelist(team_cmd)
self:SetCategory("Вайтлисты")
self:SetCanActivate(function(pl)
if GAS.JobWhitelist:IsWhitelisted(pl, team_id(team_cmd)) then
return "Вы в вайтлисте"
end
end)
self:SetInstaller(function(pl)
GAS.JobWhitelist:AddToWhitelist(team_id(team_cmd), GAS.JobWhitelist.LIST_TYPE_STEAMID, pl:SteamID())
end)
self:SetValidator(function(pl)
return GAS.JobWhitelist:IsWhitelisted(pl, team_id(team_cmd))
end)

self.whitelist = self:Insert(IGS.ITEMS.Whitelist, team_cmd) -- not team_id из-за DarkRP = nil на этом этапе
return self
end

if SERVER then
hook.Add("IGS.PlayerPurchasesLoaded", "IGS.bWhitelist", function(pl)
for team_cmd,_ in pairs(IGS.ITEMS.Whitelist) do
GAS.JobWhitelist:RemoveFromWhitelist(team_id(team_cmd), GAS.JobWhitelist.LIST_TYPE_STEAMID, pl:SteamID())
end
end)
end

0 comments on commit 64726f4

Please sign in to comment.