Здравствуйте, появился у меня вопрос: Можно ли как-то сделать, что бы при выполнении команды sam выполнялась другая команда?
Пример: если я пишу срок jail = 0, то выполняется команда ban для указанного игрока
Здравствуйте, появился у меня вопрос: Можно ли как-то сделать, что бы при выполнении команды sam выполнялась другая команда?
Пример: если я пишу срок jail = 0, то выполняется команда ban для указанного игрока
В файле lua/sam/modules/fun.lua меняешь код на тот что прикрепил снизу.
Если хочешь бан не 30 минут, то меняешь переменную time
local function jail(executor, ply, time)
if not IsValid(ply) then return end
if time == 0 then
time = 30--minutes
if executor:GetBanLimit() ~= 0 then time = executor:GetBanLimit() end
ply:sam_ban(time, reason, executor:SteamID())
end
if not isnumber(time) or time < 0 then
time = 0
end
if ply:sam_get_nwvar("frozen") then
RunConsoleCommand("sam", "unfreeze", "#" .. ply:EntIndex())
end
if not ply:sam_get_nwvar("jailed") or (not ply.sam_jail_props or not IsValid(ply.sam_jail_props[1])) then
ply:ExitVehicle()
ply:SetMoveType(MOVETYPE_WALK)
ply.sam_jail_pos = ply:GetPos()
ply:sam_set_nwvar("jailed", true)
ply:sam_set_exclusive("in jail")
if ply.sam_jail_props then
for k, v in ipairs(ply.sam_jail_props) do
if IsValid(v) then
v:Remove()
end
end
end
local ply_jail_props = {}
for i = 1, #jail_props, 2 do
local jail_prop = ents.Create("prop_physics")
jail_prop:SetModel("models/props_building_details/Storefront_Template001a_Bars.mdl")
jail_prop:SetPos(ply.sam_jail_pos + jail_props[i])
jail_prop:SetAngles(jail_props[i + 1])
jail_prop:SetMoveType(MOVETYPE_NONE)
jail_prop:Spawn()
jail_prop:GetPhysicsObject():EnableMotion(false)
jail_prop.CanTool = return_false
jail_prop.PhysgunPickup = return_false
jail_prop.jailWall = true
table.insert(ply_jail_props, jail_prop)
end
ply.sam_jail_props = ply_jail_props
end
local steamid = ply:SteamID()
if time == 0 then
timer.Remove("SAM.Unjail." .. steamid)
else
timer.Create("SAM.Unjail." .. steamid, time, 1, function()
if IsValid(ply) then
unjail(ply)
end
end)
end
timer.Create("SAM.Jail.Watch." .. steamid, 0.5, 0, function()
if not IsValid(ply) then
return timer.Remove("SAM.Jail.Watch." .. steamid)
end
if ply:GetPos():DistToSqr(ply.sam_jail_pos) > 4900 then
ply:SetPos(ply.sam_jail_pos)
end
if not IsValid(ply.sam_jail_props[1]) then
jail(ply, timer.TimeLeft("SAM.Unjail." .. steamid) or 0)
end
end)
end
command.new("jail")
:SetPermission("jail", "admin")
:AddArg("player")
:AddArg("length", {optional = true, default = 0, min = 0})
:AddArg("text", {hint = "reason", optional = true, default = sam.language.get("default_reason")})
:GetRestArgs()
:Help("jail_help")
:OnExecute(function(ply, targets, length, reason)
for i = 1, #targets do
jail(ply, targets[i], length * 60)
end
sam.player.send_message(nil, "jail", {
A = ply, T = targets, V = sam.format_length(length), V_2 = reason
})
end)
:End()
Спасибо