Simple Swep Help

I have no knowledge at all of making sweps or lua coding at all , so I was wondering if some one here would be able to help me edit/ make a hand cuff swep.Basicly I need the cuffs to be like this.When they hit you they remove all your weapons and prop spawning abilities, etc and when you hit them again it restores their phys gun back to them and the average abilites a player would have in a server. im ok when it comes to editing lua files to a point but im not good at making anything yet.Anyone here want to help me create this?

I was planning on basing it off of the zipties in tiramisu

[lua]if (SERVER) then
AddCSLuaFile( “shared.lua” )
SWEP.Weight = 5
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
end

if ( CLIENT ) then
SWEP.PrintName = “Zipties”
SWEP.Author = “FNox”
SWEP.Contact = “”
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
SWEP.ViewModelFOV = 70
SWEP.ViewModelFlip = false
SWEP.CSMuzzleFlashes = false
end

SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.ViewModel = “”
SWEP.WorldModel = “”
SWEP.HoldType = “normal”

SWEP.Primary.ClipSize = 1
SWEP.Primary.DefaultClip = 1
SWEP.Primary.Automatic = false

SWEP.Secondary.ClipSize = 0
SWEP.Secondary.DefaultClip = 0

function SWEP:Reload()
end

function SWEP:PrimaryAttack()
if SERVER then
if !self.Owner:GetNWBool( “arrested”, false ) then
local trace = self.Owner:GetEyeTrace( )
if trace.StartPos:Distance( trace.HitPos ) < 150 then
if trace.Entity:IsPlayer() then
CAKE.ArrestPlayer( self.Owner, trace.Entity )
elseif trace.Entity.ply and trace.Entity.ply:IsPlayer() then
CAKE.ArrestPlayer( self.Owner, trace.Entity.ply )
end
end
end
end
end

function SWEP:SecondaryAttack()
if SERVER then
if !self.Owner:GetNWBool( “arrested”, false ) then
local trace = self.Owner:GetEyeTrace( )
if trace.StartPos:Distance( trace.HitPos ) < 150 then
if trace.Entity:IsPlayer() then
CAKE.UnArrestPlayer( self.Owner, trace.Entity )
elseif trace.Entity.ply and trace.Entity.ply:IsPlayer() then
CAKE.UnArrestPlayer( self.Owner, trace.Entity.ply )
end
end
end
end
end

function SWEP:Think()
end[/lua]

But ofcourse I cant just slap that shit into my game mode and hope it will work, can anyone edit this to get it they way I need it or explain to me how to?


(User was banned for this post ("Read the sticky" - Grea$eMonkey))

Kind of need more information to help you at all.

First, you’re using Cakescript I’m assuming?
Second, do you want them to get the weapons back that you confiscated on arrest?

1.Im actually using Darkrp at the moment that ive made alot of minor changes to
,Might consider using tiramisu or cakescript but as of right now darkrp is what Ill be using

  1. Yes I would like them to get their weapons back after arrest

Why are you not using the default arrest stick, and just making modifications then?

Because the arrest stick is for servers owned by 12 year olds"Then again so is darkrp", using darkrp because its pretty easy to edit for me at this moment. Reason I want hand cuffs is because the current jail system consists of being hand cuffed and escorted to jail and being brought into solitary confinement or being tazered and brought to average jail etc.Ive remade a very old server ive played on and they had the same jail system , and I would like to have hand cuffs like in the past server rather than some kid hitting someone with a arrest baton

There are ConVars to turn off the teleporting to and from jail, you know. You could just get rid of that, and change the sweps model, and it’s practically all you would need.

Edit* What would I add to the code to do that.

[lua]if SERVER then
AddCSLuaFile(“shared.lua”)
end

if CLIENT then
SWEP.PrintName = “Cuffs”
SWEP.Slot = 1
SWEP.SlotPos = 3
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
end

SWEP.Base = “weapon_cs_base2”

SWEP.Author = “Rick Darkaliono, philxyz”
SWEP.Instructions = “Left or right click to arrest”
SWEP.Contact = “”
SWEP.Purpose = “”
SWEP.IconLetter = “”

SWEP.ViewModelFOV = 62
SWEP.ViewModelFlip = false

SWEP.Spawnable = false
SWEP.AdminSpawnable = true

SWEP.NextStrike = 0

SWEP.ViewModel = “”
SWEP.WorldModel = “”

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = 0
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “”

SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = 0
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “”

function SWEP:Initialize()
self:SetWeaponHoldType(“normal”)
end

function SWEP:PrimaryAttack()
if CurTime() < self.NextStrike then return end

self.NextStrike = CurTime() + .4

if CLIENT then return end

local trace = self.Owner:GetEyeTrace()

if ValidEntity(trace.Entity) and trace.Entity:IsPlayer() and trace.Entity:IsCP() and GetConVarNumber("cpcanarrestcp") == 0 then
	Notify(self.Owner, 1, 5, "You can not arrest other CPs!")
	return
end

if trace.Entity:GetClass() == "prop_ragdoll" then
	for k,v in pairs(player.GetAll()) do
		if trace.Entity.OwnerINT and trace.Entity.OwnerINT == v:EntIndex() then
			KnockoutToggle(v, true)
			return
		end
	end
end
	
if not ValidEntity(trace.Entity) or (self.Owner:EyePos():Distance(trace.Entity:GetPos()) &gt; 115) or (not trace.Entity:IsPlayer() and not trace.Entity:IsNPC()) then
	return
end

if not tobool(GetConVarNumber("npcarrest")) and trace.Entity:IsNPC() then
	return
end

if GetConVarNumber("needwantedforarrest") == 1 and not trace.Entity:IsNPC() and not trace.Entity.DarkRPVars.wanted then
	Notify(self.Owner, 1, 5, "The player must be wanted in order to be able to arrest them.")
	return
end

if FAdmin and trace.Entity:IsPlayer() and trace.Entity:FAdmin_GetGlobal("fadmin_jailed") then
	Notify(self.Owner, 1, 5, "You cannot arrest a player who has been jailed by an admin.")
	return
end

local jpc = DB.CountJailPos()

if not jpc or jpc == 0 then
	Notify(self.Owner, 1, 4, "You cannot arrest people since there are no jail positions set!")
else
	-- Send NPCs to Jail
	if trace.Entity:IsNPC() then
		trace.Entity:SetPos(DB.RetrieveJailPos())
	else
		if not trace.Entity.Babygod then
			trace.Entity:Arrest()
			Notify(trace.Entity, 0, 20, "You've been arrested by " .. self.Owner:Nick())
			
			if self.Owner.SteamName then
				DB.Log(self.Owner:SteamName().." ("..self.Owner:SteamID()..") arrested "..trace.Entity:Nick())
			end
		else
			Notify(self.Owner, 1, 4, "You can't arrest players who are spawning.")
		end
	end
end

end

function SWEP:SecondaryAttack()
self:PrimaryAttack()
end
[/lua]


Console commands:
rp_teletojail 0
rp_telefromjail 0

Run those two console commands, and teleporting will no longer be an issue.

You just made me feel like I was seven years old

You’re welcome? I’m not sure what to say to that.

Lol, It was a joke but ,Thank you for helping me.

[editline]24th October 2011[/editline]

Anyway to remove the giant “Blah has been arrested for 120 seconds” and could you also remove the the time that shows up at the botton of their screen or set it so its infinite?

[lua]function meta:Arrest(time, rejoin)
self:SetDarkRPVar(“wanted”, false)
self.warranted = false
self:SetSelfDarkRPVar(“HasGunlicense”, false)
self:SetSelfDarkRPVar(“Arrested”, true)
GAMEMODE:SetPlayerSpeed(self, GetConVarNumber(“aspd”), GetConVarNumber(“aspd”))
self:StripWeapons()

if tobool(GetConVarNumber("droppocketarrest")) and self.Pocket then 
	for k, v in pairs(self.Pocket) do
		if ValidEntity(v) then
			v:SetMoveType(MOVETYPE_VPHYSICS)
			v:SetNoDraw(false)
			v:SetCollisionGroup(4)
			v:SetPos(self:GetPos() + Vector(0,0,10))
			local phys = v:GetPhysicsObject()
			if phys:IsValid() then
				phys:EnableCollisions(true)
				phys:Wake()
			end
		end
	end
	self.Pocket = nil
end

-- Always get sent to jail when Arrest() is called, even when already under arrest
if GetConVarNumber("teletojail") == 1 and DB.CountJailPos() and DB.CountJailPos() ~= 0 then
	local jailpos = DB.RetrieveJailPos()
	if jailpos then
		self:SetPos(jailpos)
	end
end

if not RPArrestedPlayers[self:SteamID()] or rejoin then
	local ID = self:SteamID()
	RPArrestedPlayers[ID] = true
	self.LastJailed = CurTime()
	
	-- If the player has no remaining jail time,
	-- set it back to the max for this new sentence
	if not time or time == 0 then
		time = (GetConVarNumber("jailtimer") ~= 0 and GetConVarNumber("jailtimer")) or 120
	end

	self:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.youre_arrested, time))
	for k, v in pairs(player.GetAll()) do
		if v ~= self then
			v:PrintMessage(HUD_PRINTCENTER, string.format(LANGUAGE.hes_arrested, self:Name(), time))
		end
	end
end

end[/lua]

Replace your meta:Arrest() function in Player.lua, or remove lines 458-461
[lua] timer.Create(ID … “jailtimer”, time, 1, function() if ValidEntity(self) then self:Unarrest(ID) end end)
umsg.Start(“GotArrested”, self)
umsg.Float(time)
umsg.End()[/lua]

in Player.lua