Commit 70e58704 authored by Jonah's avatar Jonah

helper function time

parent 870ed53c
......@@ -25,10 +25,10 @@ function ulx.propban( calling_ply, target_ply, num_rounds, reason)
current_rounds = tonumber(target_ply:GetPData("propban_rounds")) or 0
if new_rounds > 0 then
target_ply:SetPData("propban_rounds", new_rounds)
target_ply:SetPData("reason", reason)
target_ply:SetPData("propban_reason", reason)
else
target_ply:RemovePData("propban_rounds")
target_ply:RemovePData("reason")
target_ply:RemovePData("propban_reason")
end
rounds_left = tonumber(target_ply:GetPData("propban_rounds")) or 0
......@@ -48,4 +48,70 @@ rmute:addParam{ type=ULib.cmds.PlayerArg }
rmute:addParam{ type=ULib.cmds.NumArg, max=15, default=1, hint="rounds", ULib.cmds.optional, ULib.cmds.round }
rmute:addParam{ type=ULib.cmds.StringArg, default="I'm a dummy and forgot a reason", hint="reason", ULib.cmds.optional}
rmute:defaultAccess( ULib.ACCESS_ADMIN )
rmute:help( "mutes target(s) for a number of rounds" )
rmute:help( "bans players from picking up props for a set number of rounds" )
--more helper Functions
local function propban_check()
local weapon_zm_carry = weapons.GetStored("weapon_zm_carry")
if istable(weapon_zm_carry) then
function weapon_zm_carry:canCarryProp()
local ply = self:GetOwner()
local rounds = ply:GetPData("propban_rounds") or 0
if rounds > 0 then
local ent = ply:GetEyeTrace().Entity
if not IsValid(ent) or ent:GetClass() ~= "prop_ragdoll" then
return false
end
end
return true
end
local old_SecondaryAttack = weapon_zm_carry.SecondaryAttack
function weapon_zm_carry:SecondaryAttack()
local rounds = self:GetPData("propban_rounds") or 0
if rounds == 0 then
old_SecondaryAttack(self)
end
end
end
local affected_plys = {}
for _,v in pairs(player.GetAll()) do
local rounds_left = tonumber(v:GetPData("rgag_gags")) or 0
if v:Alive() and rounds_left > 0 then
rounds_left=rounds_left -1
if rounds_left == 0 then
v:RemovePData("propban_rounds")
v:RemovePData("propban_reason")
v:ChatPrint("You are no longer prop banned")
else
v:SetPData("propban_rounds", rounds_left)
end
end
end
local prop_message
for i=1, #affected_plys do
local v = affected_plys[ i ]
local string_inbetween
if i > 1 and #affected_plys == i then
string_inbetween=" and "
elseif i > 1 then
string_inbetween=", "
end
string_inbetween = string_inbetween or ""
prop_message = ( ( prop_message or "") .. string_inbetween )
prop_message = ( ( prop_message or "") .. v:Nick() )
end
local prop_message_context
if #affected_plys == 1 then prop_message_context ="was" else prop_message_context ="were" end
if #affected_plys ~= 0 then
ULib.tsay(_, prop_message .. " ".. prop_message_context .." gagged.")
end
end
hook.Add("TTTBeginRound","propban checking", propban_check())
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment