Weed-Plant

Hi all!
I made a weed-plant entity for DarkRP, what makes weeds.
My problem is it works only in singleplayer mode.
When I put it on a hosted server, it doesn’t.
Do you know whats the problem?

Any errors?

[editline]02:30PM[/editline]

Maybe post cl_init and shared.

Dont use pastebin post the code in lua tags like so

[lua]
//code
[/lua]

No errors it just doesnt work.

[lua]
AddCSLuaFile(“cl_init.lua”)
AddCSLuaFile(“shared.lua”)
include(“shared.lua”)

function ENT:Initialize()
self:SetModel(“models/props/cs_office/plant01.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:SetNWBool(“weed_plant”, true)
self.sparking = false
self.damage = 100
self.IsWeedPlant = true
ply = self:GetNWEntity(“owning_ent”)
if not ply.maxplants then
ply.maxplants = 0
end
ply.maxplants = ply.maxplants + 1
timer.Simple(30, self.CreateWeed, self)
end

function ENT:OnTakeDamage(dmg)
self.damage = self.damage - dmg:GetDamage()
if self.damage <= 0 then
self:Remove()
end
end

local function PrintMore(ent)
if ValidEntity(ent) then
timer.Simple(3, ent.CreateWeed, ent)
end
end

function ENT:CreateWeed()
if not ValidEntity(self) then return end
if self:IsOnFire() then return end
local WeedPos = self:GetPos()

    local weed = ents.Create("durgz_weed")
    weed:SetNWString("Owner", "Shared")
    weed:SetPos(Vector(WeedPos.x, WeedPos.y, WeedPos.z + 15))
    weed.nodupe = true
    weed:Spawn()
    weed:GetPhysicsObject():Wake()
    timer.Simple(math.random(100, 350), PrintMore, self)

end

function ENT:OnRemove()
if not ValidEntity(ply) then return end
if not ply.maxplants then
ply.maxplants = 0
return
end
ply.maxplants = ply.maxplants - 1
end
[/lua]

What do you mean ‘doesn’t work’? What doesn’t work? Does the entity not spawn or something?

does cl and shared exist?

It spawns, but it doesn’t make weed.
Yes, they exist.

cl_init.lua:
[lua]
include(“shared.lua”)

function ENT:Initialize()
end

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

function ENT:Think()
end
[/lua]

shared.lua:
[lua]
ENT.Type = “anim”
ENT.Base = “base_gmodentity”
ENT.PrintName = “Weed Plant”
ENT.Author = “Anita”
ENT.Spawnable = false
ENT.AdminSpawnable = false
[/lua]

Your code will in a worst case scenario make you wait 353 seconds between each time the weed would spawn. That’s 5.883333333 ~ 5.9 ~ 6 minutes.

But it doesn’t spawn after half an hour, either.

I seriously don’t know what’s fucked up, sorry.

Not problem. But anyone else?:confused:

Funny how i release a noobie question about weed_plant and then a couple hours later someone else has released one.

Lol I didn’t see I copied the idea from a server :smiley:

Lol did you base this off the money printer by any chance.

P.S it might be because the function is “function ENT:CreateWeed()” but you call “ent.CreateWeed”

Oh, indeed. You should be passing ent as the first argument to ent.CreateWeed.

Why couldn’t you just do this, anyway:

[lua]
timer.Simple(math.random(100, 350), self.CreateWeed, self ) – Instead of PrintMore
[/lua]

You are doing it in Initialize, too!

Hehe I dont know i copied it from moneyprinter files:D

snip

He wants one that makes drugs, doesnt yours make money?