I need help with a problem I'm having and I realy need a little help with it I do not get my foor to give hunger (energy) for hungermod on my server.
Here is the code:
[lua]AddCSLuaFile( "shared.lua" )
include( 'shared.lua' )
function ENT:SpawnFunction( ply, tr )
if !tr.Hit then return end
local SpawnPos = tr.HitPos + tr.HitNormal * 1
local ent = ents.Create( "SodaCola" )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Initialize()
self.Entity:SetModel("models/FoodNHouseholdItems/cola.mdl")
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )
self.Entity:SetSolid( SOLID_VPHYSICS )
self.Index = self.Entity:EntIndex()
local phys = self.Entity:GetPhysicsObject()
if phys:IsValid() then
phys:Wake()
end
end
function ENT:Use(activator)
activator:SetHealth(activator:Health()+15)
self.Entity:Remove()
end[/lua]
I basicly wanna make it so it adds hunger instead of health.
Why don't you use the built-in function "AddFoodItem(name, mdl, energy, price)" instead?
Anyways, adopt this code [url]https://github.com/FPtje/DarkRP/blob/master/entities/entities/spawned_food/init.lua[/url]
Because I also want the food to be spawned through the Q menu in entities.
Sorry, you need to Log In to post a reply to this thread.