Hello! I've just started coding in lua and i have a few questions, first of all how do i get an entity's owner?
I've tried some things with set and getOwner but then i just get a null error
also how do i read the input in the [lua]Derma_StringRequest[/lua]
and then send it to init.lua file?
Entity.GetOwner or Entity.GetCreator -- depends on the entity.
And i put this in the init.lua file right?
at ENT:Initialize()
[editline]14th January 2017[/editline]
Also how would i add money to the entity creator if the entity is used?
this is what i currently have [lua]function ENT:Use ( activator, caller )
if not (caller.LastArmor) then
caller.LastArmor = 0
caller.LastPrint = 0
end
if not (caller:canAfford(100)) then
if (caller.LastPrint < CurTime()) then caller:ChatPrint("Can't afford it") caller.LastPrint = CurTime() + 1 end
return
end
if (caller:Armor() >= 100) then
if (caller.LastPrint < CurTime()) then caller:ChatPrint("Full armor already") caller.LastPrint = CurTime() + 1 end
return
end
if (caller.LastArmor < CurTime()) then
caller:addMoney(-100)
self:GetCreator(addMoney(10))
caller:SetArmor(caller:Armor() + 1)
caller.LastArmor = (CurTime() + .01)
self:SetUses(self:GetUses() - 1)
end
if (self:GetUses() < 1)
then
self:Remove()
end
end[/lua]
but then i get this error
[ERROR] lua/entities/armorcharger/init.lua:53: attempt to call global 'addMoney' (a nil value)
1. unknown - lua/entities/armorcharger/init.lua:53
self:GetCreator(addMoney(10))
to
self:GetCreator():addMoney(10)
Thank you so much!
Sorry, you need to Log In to post a reply to this thread.