Darkrp NPC

Dear Scripters,

I’m building a script when a player walk in the npc with a entity

the entity wil remove and the player get his money



AddCSLuaFile( "cl_init.lua" ) -- This means the client will download these files
AddCSLuaFile( "shared.lua" )

include('shared.lua') -- At this point the contents of shared.lua are ran on the server only.


function ENT:Initialize()

self.Entity:SetModel("models/nater/weedplant_pot_dirt.mdl")

self.Entity:PhysicsInit(SOLID_VPHYSICS)

self.Entity:SetMoveType(MOVETYPE_VPHYSICS)

self.Entity:SetSolid(SOLID_VPHYSICS)

self.Entity:SetUseType(SIMPLE_USE)

local phys = self.Entity:GetPhysicsObject()

if phys and phys:IsValid() then phys:Wake() end

self.Entity:SetNWBool("Usable", false)

self.Entity:SetNWBool("Plantable", true)

self.damage = 10

local ply = self.Entity:GetNWEntity("owning_ent")

end

function ENT:OnTakeDamage()
	return false -- This NPC won't take damage from anything.
end 

function ENT:Touch(hitEnt)

if hitEnt:GetClass() == "money_printer" then
ply:AddMoney(800)
hitEnt:Remove()
end
end




error: [gamemodes/darkrp/entities/entities/buyer/init.lua:40] attempt to index global ‘ply’ (a nil value)
my script is not working can you guys help me or create 1 for me

[editline]18th January 2012[/editline]



local function gravpickup( ply, ent )
	ent.picker = ply
end
hook.Add("GravGunOnPickedUp", "setpicker", gravpickup)

local function gravdrop(ply,ent)
	if ent.picker then ent.picker = nil end
end
hook.Add( "GravGunOnDropped", "removepicker", gravdrop)


[editline]18th January 2012[/editline]

[gamemodes/darkrp/entities/entities/buyer/init.lua:49] attempt to index global ‘ent’ (a nil value)
ent.picker:AddMoney(800)

ply:AddMoney(800)

hitEnt.picker:AddMoney(800)

Don’t use self.Entity, it’s outdated, using self is how one does it now.

Agreed.