Drop weapon script broken

Could somebody fix this for me?

[lua]
function DropCurrentWeapon(ply)
local Currentweapon = ply:GetActiveWeapon()

     local NewWeapon = ents.Create(Currentweapon:GetClass())

     local currentweaponclip1 = Currentweapon:Clip1()
     local currentweaponclip2 = Currentweapon:Clip2()

     ply:StripWeapon(Currentweapon:GetClass())


     NewWeapon:SetPos(ply:GetShootPos() + (ply:GetAimVector() * 30))

     ply.AllowWeaponPickupFix = 0

     timer.Simple(1.5,PickupDelayFunc,ply)

     NewWeapon:Spawn()
     
     NewWeapon:SetClip1(currentweaponclip1)
     NewWeapon:SetClip2(currentweaponclip2)

end

function PickupDelayFunc(ply)
ply.AllowWeaponPickupFix = 1
end

if SERVER then
concommand.Add(“DropWeapon”,DropCurrentWeapon)
end

function AutoBindOnSpawn(ply)
ply.AllowWeaponPickupFix = 1
ply:ConCommand("bind g DropWeapon
")
end

hook.Add(“PlayerInitialSpawn”,“AutobindDropWeapon”,AutoBindOnSpawn)

function RePickupFix(ply,weapon)
if ply.AllowWeaponPickupFix == 0 then return false end
end

hook.Add(“PlayerCanPickupWeapon”,“FixForPickup”,RePickupFix)

[/lua]

It works, if you manually “bind g dropweapon”, but not automatically as the code suggests it should.

[editline]05:46PM[/editline]

server console says

concommand blocked! (bind g dropweapon)

Bind is a blocked console command in lua.

There’s a hook for when someone presses a bound key.

Give the people the information :stuck_out_tongue:

I don’t understand Lua. I just found this on GMod.org, the server printed the error, and I came here for help. Could somebody explain how I could add add code that would print a message (“Type bind g “dropweapon” to enable weapon dropping”) when the player initially spawns on the server? If it’s not easy then forget it it’s not important and I’ll just tell people myself.

[lua]local function DropWeapon(ply,cmd,args)
if !ply:Alive() then return end

local CurWeap = ply:GetActiveWeapon()

if IsValid( CurWeap ) then
	ply:DropWeapon( CurWeap )
end

end
concommand.Add( “drop”, DropWeapon )[/lua]

Something simple.

But what do I do with this? I’m sorry, I am totally new to Lua.



ENT.Type 			= "anim"
ENT.Base 			= "base_gmodentity"
ENT.PrintName			= "Snowball"
ENT.Author			= "NECROSSIN"

ENT.Spawnable			= false
ENT.AdminSpawnable		= false

if SERVER then

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )

function ENT:Initialize()
	
	self.Entity:SetModel("models/weapons/w_snowball_thrown.mdl")
	self.Entity:PhysicsInit( SOLID_VPHYSICS )
	self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
	self.Entity:SetSolid( SOLID_VPHYSICS )
	
	local phys = self.Entity:GetPhysicsObject()
	if (phys:IsValid()) then
		phys:SetMass(1)
		phys:Wake()
	end	
	
end

function ENT:PhysicsCollide( data, physobj )
		-- if it is a player
		if data.HitEntity and data.HitEntity:IsValid() and data.HitEntity:IsPlayer() and data.HitEntity != self.Entity:GetOwner() then
			
			--data.HitEntity = p
			self.Entity:EmitSound("player/footsteps/snow"..math.random(1,6)..".wav")
			
			data.HitEntity:ViewPunch(Angle(math.random(-1, 1), math.random(-1, 1), math.random(-10, 10)))
			data.HitEntity:TakeDamage( math.random(1,5), self.Entity:GetOwner() )
			
			umsg.Start( "SnowHit", data.HitEntity )
			umsg.End()
			
			local Pos1 = data.HitPos + data.HitNormal
			local Pos2 = data.HitPos - data.HitNormal
			util.Decal("PaintSplatBlue", Pos1, Pos2) 
			
			self.Entity:Remove()
		-- if it is an entity (not a player)	
		elseif data.HitEntity and data.HitEntity:IsValid() and !data.HitEntity:IsPlayer() then
		
			local Pos1 = data.HitPos + data.HitNormal
			local Pos2 = data.HitPos - data.HitNormal
			util.Decal("PaintSplatBlue", Pos1, Pos2) 
			self.Entity:EmitSound("player/footsteps/snow"..math.random(1,6)..".wav")
			self.Entity:Remove()
		-- if its a world	
		else
		
			local Pos1 = data.HitPos + data.HitNormal
			local Pos2 = data.HitPos - data.HitNormal
			util.Decal("PaintSplatBlue", Pos1, Pos2) 
			self.Entity:EmitSound("player/footsteps/snow"..math.random(1,6)..".wav")
			self.Entity:Remove()
			
		end
end

end

if CLIENT then

function ENT:Draw()

	self.Entity:DrawModel()
	--cool snow effect :p
	local Emitter = ParticleEmitter(self.Entity:GetPos())

	if self.Entity:GetVelocity():Length() > 28 and math.random(1,3) == 2 then
		local particle = Emitter:Add("effects/blood_drop", self.Entity:GetPos())
		particle:SetVelocity(VectorRand() * 15)
		particle:SetDieTime(3)
		particle:SetStartAlpha(255)
		particle:SetStartSize(10)
		particle:SetEndSize(1)
		particle:SetRoll(180)
		particle:SetColor(255, 255, 255)
		--particle:SetLighting(true)
	end
	
end

end


What that does is creates a server concommand that people can run to drop their current weapon. Put it in any server included file, most likely init.lua.