So iam making an Entity that gives you armor and sets your player model and when you run out of armor it sets your playermodel back to what it used to be
But iam currently getting this lua error.
AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )
include('shared.lua')
util.PrecacheModel ("models/items/battery.mdl")
function ENT:Initialize()
self.Entity:SetModel("models/items/battery.mdl")
self.Entity:PhysicsInit( SOLID_VPHYSICS ) -- Make us work with physics,
self.Entity:SetMoveType( MOVETYPE_VPHYSICS ) -- after all, gmod is a physics
self.Entity:SetSolid( SOLID_VPHYSICS ) -- Toolbox
self.Entity:PhysWake()
end
function ENT:Use( activator, caller )
if ( activator:IsPlayer() ) then
// Give the collecting player some free health
local armor = activator:Armor()
if not ( armor == 100 ) then
local sound = Sound("items/battery_pickup.wav")
self.Entity:EmitSound( sound )
self.Entity:Remove()
activator:SetArmor( armor + 20 )
if ( 100 < armor + 20 ) then
activator:SetArmor( 100 )
end
end
end
player:SetModel( fun )
self:Remove()
if ( activator:IsPlayer() ) then
OriginalModel=Ply:GetModel()
end
function ENT:OnRemove()
if CLIENT then
player:SetModel( OriginalModel )
end
end
end
function ENT:PostEntityPaste(pl, Ent, CreatedEntities)
self:Remove()
end
And the LUA ERROR Iam Getting is this:
[ERROR] gamemodes/base/entities/entities/hp_battery/init.lua:34: attempt to call method 'SetModel' (a nil value)
1. unknown - gamemodes/base/entities/entities/hp_battery/init.lua:34
you sent lua code, no error
[QUOTE=tyguy;50313409]you sent lua code, no error[/QUOTE]
Yeah,I edited it and added the error.
[QUOTE=laithqakeesh;50313416]Yeah,I edited it and added the error.[/QUOTE]
player isn't defined
[QUOTE=tyguy;50313433]player isn't defined[/QUOTE]
Ah alright well i just started doing this
activator:SetModel( fun )
But its giving the same error.
Define player
[code]
local player = LocalPlayer()
[/code]
Add me on steam and Ill help you out. Better than going back and fourth on a forum lol
Sorry, you need to Log In to post a reply to this thread.