hostage tie help

hey so i have this hostage tie on gmod im wondering how to add some code to it so it returns weapons after you untie him? this is code for untieing:


function SWEP:SecondaryAttack()
	if SERVER then
	
		local trace = self.Owner:GetEyeTrace( )
			
		if trace.StartPos:Distance( trace.HitPos ) < TIE_DISTANCE and trace.Entity:IsPlayer() and trace.Entity:IsTied() then
			trace.Entity:UnTiePlayer(self.Owner)
		elseif(trace.StartPos:Distance( trace.HitPos ) < TIE_DISTANCE and trace.Entity:IsPlayer() and not trace.Entity:IsTied()) then
			self.Owner:PrintMessage(HUD_PRINTTALK, trace.Entity:Nick().." does not need untying.")
		end
	end
end

function SWEP:Think()
end

[lua]
–This should be placed before you strip the weapons
local Hostage = trace.Entity
Hostage.strippedWeapons = Hostage:GetWeapons()

–This should be placed after you untie the person
for i, weapon in pairs (Hostage.strippedWeapons) do
Hostage:Give( weapon )
end[/lua]

thanks but umm how i place it like heres whole code?


if (SERVER) then
	AddCSLuaFile( "shared.lua" )
	include("config.lua")
	SWEP.Weight				= 5
	SWEP.AutoSwitchTo		= false
	SWEP.AutoSwitchFrom		= false
end

if ( CLIENT ) then
	SWEP.PrintName      = "Hostage Rope"
	SWEP.Author    = "Arctic"
	SWEP.Contact    = ""
	SWEP.DrawAmmo			= true
	SWEP.DrawCrosshair		= true
	SWEP.ViewModelFOV		= 70
	SWEP.ViewModelFlip		= false
end
 
SWEP.Spawnable      = false
SWEP.AdminSpawnable  = true
 
SWEP.ViewModel = Model("models/als/rope/v_rope.mdl")
SWEP.WorldModel = Model("models/als/rope/w_ropel.mdl")
SWEP.HoldType = "normal"
 

SWEP.Primary.ClipSize      = -1
SWEP.Primary.DefaultClip    = -1

SWEP.Primary.Automatic    = false
SWEP.Primary.Ammo = ""

SWEP.Secondary.ClipSize      = -1
SWEP.Secondary.DefaultClip    = -1

function SWEP:Reload()
	return
end

function SWEP:PrimaryAttack()
	if SERVER then
	
		local trace = self.Owner:GetEyeTrace( )
		
		if trace.StartPos:Distance( trace.HitPos ) < TIE_DISTANCE and trace.Entity:IsPlayer() and not trace.Entity:IsTied() then
			trace.Entity:TieUpPlayer(self.Owner, self)
			//print(tostring(trace.StartPos:Distance( trace.HitPos )))
		elseif(trace.StartPos:Distance( trace.HitPos ) < TIE_DISTANCE and trace.Entity:IsPlayer() and trace.Entity:IsTied()) then
			self.Owner:PrintMessage(HUD_PRINTTALK, trace.Entity:Nick().." is already tied up.")
		end

	end
end

function SWEP:SecondaryAttack()
	if SERVER then
	
		local trace = self.Owner:GetEyeTrace( )
			
		if trace.StartPos:Distance( trace.HitPos ) < TIE_DISTANCE and trace.Entity:IsPlayer() and trace.Entity:IsTied() then
			trace.Entity:UnTiePlayer(self.Owner)
		elseif(trace.StartPos:Distance( trace.HitPos ) < TIE_DISTANCE and trace.Entity:IsPlayer() and not trace.Entity:IsTied()) then
			self.Owner:PrintMessage(HUD_PRINTTALK, trace.Entity:Nick().." does not need untying.")
		end
	end
end

function SWEP:Think()
end

The code would be better placed inside the functions TieUpPlayer and UnTiePlayer. But you didn’t provide those.

thank you sir!