I am working on customizing a DarkRP server. I have added a few jobs, and simple customizations. Right now I am working on setting up some Weed Plants. I found this Weed Plant [url]http://www.garrysmod.org/downloads/?a=view&id=99724[/url]
and I'm trying to customize it to my liking. For one I want to randomize the drops it provides. Right now it currently drops 1 weed every time.
[code]
local SpawnPos = self.Entity:GetPos()
local WeedBag = ents.Create("durgz_weed")
WeedBag:SetPos(SpawnPos)
WeedBag:Spawn()
[/code]
How would I be able to randomize it so it drops like 0 - 6 weed and maybe 0-5 seeds.
I would also like to set it so the weed spawns on top of the pot upon harvest. It currently randomly spawns around the pot. Thanks for your help.
I doubt I'm very qualified to answer your question, but I'll try anyway.
[lua]local SpawnPos = self.Entity:GetPos() + Vector( 0, 0, 10 )
local WeedBag = ents.Create("durgz_weed")
WeedBag:SetPos(SpawnPos)
local i = math.random( 0, 6 )
while i != 0 do
WeedBag:Spawn()
i -= 1
end[/lua]
Would something like that work?
[QUOTE=thejjokerr;29049202]I'd do something like this:
[lua]local SpawnPos = self.Entity:GetPos()
local amount = math.random( 0, 6 )
for i=1, amount do
local WeedBag = ents.Create("durgz_weed")
WeedBag:SetPos(SpawnPos + Vector( 0, 0, 5 * i ))
WeedBag:Spawn()
end[/lua][/QUOTE]
Fantastic! Thanks so much. Now I have two more requests. Would there be anyway I could also put in a possible seed dropping as well as the weed? The seed's ent is ("seed_weed").
Also, Can we move the vector of the spawns to the side of the plant? The current positioning either shoots it out or spawns it on top. Yes I wanted it on top but for some reason if the seed is on top you can't see it. It's like invisible.
Bump
OP since this is in questions why do you actually try and do some of the request then if you fail post the code you tried with and we will tell you were you are going wrong.
Glad to see someones finally using my weed plant, if im wrong I apologise.
(SpawnPos + Vector( 0, 0, 5 * i ))
the 0 0 5
is x y z
Just adjust that to what you want.
Also for the random seed I believe it is
[code]local seedspawn = ents.Create("seed_weed")(math.random(1,5)[/code]
then
[code]seedspawn:SetPos(SpawnPos + Vector( 0, 0, 5 * i ))
seedspawn:Spawn()[/code]
I am unsure if that is correct I will test it out for ya!
Sorry, you need to Log In to post a reply to this thread.