Skip to content

Instantly share code, notes, and snippets.

@AMD-NICK
Last active April 7, 2020 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AMD-NICK/31519fb351f6869e0ee6 to your computer and use it in GitHub Desktop.
Save AMD-NICK/31519fb351f6869e0ee6 to your computer and use it in GitHub Desktop.
Скрипт, позволяющий настроить кол-во переносимого оружия конкретного типа. Легко модифицируется (например, без малейших проблем вы можете добавить возможность изменять лимиты пушек для конкретных проф или добавить новые группы, типа дробовиков) и очень легковесен. Здесь не используются тяжелые функции типа table.HasValue, а pairs с исключительны…
-- ██████╗ ██████╗ ██████╗ ███████╗██████╗ ██████╗ ██╗ ██╗ █████╗ ███╗ ███╗██████╗
-- ██╔════╝██╔═══██╗██╔══██╗██╔════╝██╔══██╗ ██╔══██╗╚██╗ ██╔╝ ██╔══██╗████╗ ████║██╔══██╗
-- ██║ ██║ ██║██║ ██║█████╗ ██║ ██║ ██████╔╝ ╚████╔╝ ███████║██╔████╔██║██║ ██║
-- ██║ ██║ ██║██║ ██║██╔══╝ ██║ ██║ ██╔══██╗ ╚██╔╝ ██╔══██║██║╚██╔╝██║██║ ██║
-- ╚██████╗╚██████╔╝██████╔╝███████╗██████╔╝ ██████╔╝ ██║ ███████╗██║ ██║██║ ╚═╝ ██║██████╔╝███████╗
-- ╚═════╝ ╚═════╝ ╚═════╝ ╚══════╝╚═════╝ ╚═════╝ ╚═╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═╝╚═════╝ ╚══════╝
-- Скрипт в едином лице написан _AMD_ и принадлежит кодерам TRIGON.IM
-- Коммерческая реализация скрипта запрещена свободной лицензией Apache 2.0
-- Вы можете использовать скрипт на своих проектах бесплатно.
-- Платная поддержка скрипта через стим: http://steamcommunity.com/id/AMD-NICK/
-- Если хотите отблагодарить, то можете просто сказать спасибо на почту mail@qweqwe.ovh
SW = {} -- Single Weapon Script: Main Table
SW.CFG = {} -- settings table
local c = SW.CFG
c.WGroups = {}
-- Config Below
------------------------------------------------------------------------------------------------------------------------------------------------
c.ENABLED = true -- Is the single weapon script enabled?
c.ErrT = "%s не может носить оружие" -- team restriction error message %s = e.g. Mayor
c.ErrL = "%s уже не влезают в вашу кобуру" -- limit error message. %s would be like "Pistols"
-- pistol weapon table
-- you can find classes in the spawn menu by right-mouse click on several weapon
c.WGroups["pistols"] = {
name = "Пистолеты",
limit = 2, -- max allowed amount of pistols weapons that normal player can wear
items = {
["weapon_pistol"] = true,
["weapon_357"] = true,
["weapon_alyxgun"] = true, -- нету в спавн меню
-------------------------
["fas2_ragingbull"] = true,
["fas2_ots33"] = true,
["fas2_p226"] = true,
["fas2_m1911"] = true,
["fas2_deagle"] = true,
["fas2_glock20"] = true,
},
--lmessage = "Здесь вы можете ввести кастомное сообщение, которое будет выводиться при достижении лимита",
}
c.WGroups["submachines"] = {
name = "Автоматы",
limit = 1,
items = {
["weapon_ar2"] = true,
-------------------------
["fas2_ak12"] = true,
["fas2_ak47"] = true,
["fas2_ak74"] = true,
["fas2_an94"] = true,
["fas2_famas"] = true,
["fas2_g36c"] = true,
["fas2_g3"] = true,
["fas2_galil"] = true,
["fas2_m4a1"] = true,
["fas2_pp19"] = true,
["fas2_rpk"] = true,
["fas2_sg550"] = true,
["fas2_sg552"] = true,
}
}
c.WGroups["semiauto"] = {
name = "Полуавтоматы",
limit = 1,
items = {
["weapon_smg1"] = true,
-------------------------
["fas2_uzi"] = true,
["fas2_mac11"] = true,
["fas2_mp5a5"] = true,
["fas2_mp5k"] = true,
["fas2_mp5sd6"] = true,
}
}
c.WGroups["shotguns"] = {
name = "Дробовики",
limit = 1,
items = {
["weapon_shotgun"] = true,
-------------------------
["fas2_ks23"] = true,
["fas2_m3s90"] = true,
["fas2_rem870"] = true,
["fas2_toz34"] = true,
}
}
c.WGroups["rifles"] = {
name = "Винтовки",
limit = 1,
items = {
["weapon_crossbow"] = true,
-------------------------
["fas2_m14"] = true,
["fas2_m21"] = true,
["fas2_m24"] = true,
["fas2_m82"] = true,
["fas2_rk95"] = true,
["fas2_sks"] = true,
["fas2_sr25"] = true,
}
}
c.WGroups["extra"] = {
name = "Доп. оружие",
limit = 3,
items = {
["weapon_frag"] = true,
["weapon_rpg"] = true,
["weapon_slam"] = true,
-------------------------
["fas2_m67"] = true, -- Руч. граната
["fas2_ammobox"] = true, -- ловушка
["fas2_dv2"] = true, -- меч
["fas2_ifak"] = true, -- медкит
["fas2_m79"] = true, -- гранатомет
["fas2_machete"] = true, -- мачете
}
}
-- restricted for picking weapons up teams
-- if ply at this team have license and "IgnoreWhenLicense" setted to true
-- then this setting will be ignored
c.RTeams = {
["Бомжик"] = true,
["Медик"] = true,
["Аптекарь"] = true,
["Банкир"] = true,
}
c.IgnoreWhenLicense = true
-- players with this jost can bypass max allowed weapons amount
c.UTeams = {
["Exorcist"] = true,
["Министр"] = true,
}
-- players in this groups can pick up weapons over the limit
c.UGroups = {
["prosecutor"] = true,
["minister"] = true,
["governor"] = true,
["admin"] = true,
["superadmin"] = true,
}
-- Do Not Tounch Any Staff Below The Line
------------------------------------------------------------------------------------------------------------------------------------------------
if !c.ENABLED then return end
-- Присваеваем пушкам в главной таблице их классы типа pistols или rifles
timer.Simple(.5,function()
for g,t in pairs(c.WGroups) do
for class,_ in pairs(t.items) do
local wTable = weapons.GetStored(class)
if wTable then wTable.SW_class = g end
end
end
end)
function SW.CanPickWep( ply, wep )
if c.UGroups[ply:GetNWString("usergroup")] then return end
local ptName = team.GetName(ply:Team()) -- Citizen
if c.UTeams[ptName] then return end
local tmpdat = {}
if wep.SW_class then
tmpdat.class = wep.SW_class -- pistols
tmpdat.count = 1
else
for g,t in pairs(c.WGroups) do
if t.items[wep:GetClass()] then
wep.SW_class = g
tmpdat.class = g
tmpdat.count = 1
break
end
end
end
-- если пушки нету в таблицах, значит эта пушка, скорее всего, типа кейпад чекера, т.е. техническая
if !tmpdat.class then return end
-- если выполняется код ниже, значит пушка есть в таблицах
local pWeps = ply:GetWeapons()
for i = 1, #pWeps do -- a bit optimized pairs
local wp = pWeps[i]
if !wp then continue end
if tmpdat.class == wp.SW_class then
tmpdat.count = tmpdat.count + 1
end
end
if c.RTeams[ptName] and tmpdat.count > 0 then
if !(c.IgnoreWhenLicense and ply:getDarkRPVar("HasGunlicense")) then
DarkRP.notify( ply, 1, 4, string.format(c.ErrT, ptName) )
return false
end
end
if tmpdat.count > c.WGroups[tmpdat.class].limit then
DarkRP.notify( ply, 1, 4, c.WGroups[tmpdat.class].lmessage or string.format(c.ErrL, c.WGroups[tmpdat.class].name) )
return false
end
end
hook.Add( "PlayerCanPickupWeapon", "SW.PickCheck", SW.CanPickWep )
------------------------------------------------------------------------------------------------------------------------------------------------
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment