Hi lads,
I'm close to end my first addon but I have a last problem. When I run my addon, there is an entity file which is read before my cl_addon file. So it gives me an error.
[ERROR] addons/myaddon/lua/entities/pharmaceutic shower/init.lua:25: attempt to call method 'SendLua' (a nil value)
1. unknown - addons/myaddon/lua/entities/pharmaceutic shower/init.lua:25
To resolve this error, I have to go to my pharmacy, save it and it works properly. But I would like to end to solve by this way. So I tried to use a loop but i didn't manage to do it, it gives me an error as if the model is missing.
AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
local refresh = {}
local pl = Entity( 1 )
for k, v in pairs ( refresh ) do
function ENT:Initialize()
self:SetModel( "models/jaanus/aspbtl.mdl" )
self:PhysicsInit(SOLID_VPHYSICS)
self:SetMoveType(MOVETYPE_VPHYSICS)
self:SetSolid(SOLID_VPHYSICS)
self:GetPhysicsObject():Wake()
self:SetColor(Color(161, 20, 62, 255))
end
function ENT:Use(a)
self:Remove()
pl:SendLua("shower = shower + 25")
pl:SendLua("surface.PlaySound('vo/k_lab/kl_relieved.wav')");
if a:Health() <= 80 then
a:SetHealth(a:Health() + 20)
end
end
end
You are calling SendLua on 'pl', a variable that doesn't exist in scope of Use function.
Change the pl:SendLua to a:SendLua.
You are godlike !
Sorry, you need to Log In to post a reply to this thread.