attempt to call method 'SetNWInt' (a nil value)

trying to make a simpel beta drug plant

but …
…ndergroundrp\entities\entities\drug_plant\shared.lua:70: attempt to call method ‘SetNWInt’ (a nil value)

code here:

[lua]
ENT.Type = “anim”
ENT.Base = “base_entity”

ENT.PrintName = “Drug Plant”
ENT.Author = “Grunewald”

ENT.Spawnable = false
ENT.AdminSpawnable = true
ENT.RenderGroup = RENDERGROUP_OPAQUE

AddCSLuaFile( “shared.lua” )

/---------------------------------------------------------
Name: Initialize
---------------------------------------------------------
/
if(SERVER)then
function ENT:Initialize()

self:SetModel( "models/props_lab/cactus.mdl" )  	
self:PhysicsInit( SOLID_VPHYSICS )	
self:SetMoveType( MOVETYPE_VPHYSICS )	
self:SetSolid( SOLID_VPHYSICS )               
local phys = self:GetPhysicsObject()  	
if (phys:IsValid()) then  		
	phys:Wake()  	
end  
self.use = true

end

function ENT:AcceptInput( Name, Activator, Caller )
if Name == “Use” and Caller:IsPlayer() then

local drug_period = self:GetNWInt("drug_plant_period")

	if drug_period == 1 then
	
		Msg( "Hell yeah! drugs for me

" )

		self:SetNWInt("drug_plant_period", 0)
		
		timer.Create( "drug_plant_period" .. Activator:GetNWInt("drug_plant"), 20, 1, function()
		
		Msg( "Druuuuuuuugs!

" )

		self:SetNWInt("drug_plant_period", 1)
		
		end )
		
	else
	
		Msg( "Let your plant grow man

" )

	end
	
end

end

function ENT:SpawnFunction( pl, tr )

if ( !tr.Hit ) then return end 

local SpawnPos = tr.HitPos + tr.HitNormal * 16 
 
local ent = ents.Create( self.Classname ) 
ent:SetPos( SpawnPos )
ent:Spawn() 
ent:Activate()

DrugPlants=DrugPlants+1
self:SetNWInt("drug_plant", DrugPlants)
self:SetNWInt("drug_plant_period", 0)

Msg( DrugPlants .. "

" )

self:SetNWInt("drug_plants", DrugPlants)

self:SetNWInt("drug_plant_period", 0)

timer.Create( "drug_plant_period" .. DrugPlants, 10, 1, function()
self:SetNWInt("drug_plant_period", 1)
end )

return ent 

end

end

if(CLIENT)then

function ENT:Draw()
	self:DrawModel()
end

end
[/lua]

instead of self in the spawnfunction you should use ent

[lua]
function ENT:SpawnFunction( pl, tr )

if ( !tr.Hit ) then return end 

local SpawnPos = tr.HitPos + tr.HitNormal * 16 
 
local ent = ents.Create( self.Classname ) 
ent:SetPos( SpawnPos )
ent:Spawn() 
ent:Activate()

DrugPlants=DrugPlants+1
ent:SetNWInt("drug_plant", DrugPlants)
ent:SetNWInt("drug_plant_period", 0)

Msg( DrugPlants .. "

" )

ent:SetNWInt("drug_plants", DrugPlants)

ent:SetNWInt("drug_plant_period", 0)

timer.Create( "drug_plant_period" .. DrugPlants, 10, 1, function(ent)
ent:SetNWInt("drug_plant_period", 1)
end, ent )

return ent 

end

end
[/lua]