• My spawnpoints prints an error.
    5 replies, posted
[code]attempt to index local 'ply' (a nil value)[/code] I never get these, could someone help me get this working? LINE 19 and 20: [lua] ply:GetTable().maxspawn = ply:GetTable().maxspawn + 1 ply:GetTable().Spawnpoint = self.Entity [/lua] and ply are a local variable: [code] local ply = self.Owner [/code] Help, please... :)
Can we have all the function please?
self.Owner isn't valid. Also, you don't need to do ply:GetTable(). ply.maxspawn = ply.maxspawn + 1 would work. (self.Entity is the same as self, by the way.)
self.Owner should be valid as long as he sets the owner during the purchase function, assuming you're using basewars.
[QUOTE=Lerpaderp;39569251]self.Owner should be valid as long as he sets the owner during the purchase function, assuming you're using basewars.[/QUOTE] Nope, I am doing a spawnpoint in my darkrp.. lawl [editline]16th February 2013[/editline] [QUOTE=Didileking;39568097]Can we have all the function please?[/QUOTE] [lua] AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include('shared.lua') function ENT:Initialize() self.Entity:SetModel( "models/props_trainstation/trainstation_clock001.mdl") self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) self.Entity:SetAngles(Angle(-90, 0, 0)) local ply = self.Owner local phys = self.Entity:GetPhysicsObject() phys:EnableMotion(false) if(phys:IsValid()) then phys:Wake() end self.Entity:SetNWInt("damage",100) local spawnpointp = true ply:GetTable().maxspawn = ply:GetTable().maxspawn + 1 ply:GetTable().Spawnpoint = self.Entity end function ENT:Think( ) if (IsValid(self.Owner)!=true) then self.Entity:Remove() end end function ENT:OnRemove( ) local ply = self.Owner if IsValid(ply) then ply:GetTable().maxspawn = ply:GetTable().maxspawn - 1 end end [/lua]
[QUOTE=addemod;39608436]Nope, I am doing a spawnpoint in my darkrp.. lawl [editline]16th February 2013[/editline] [lua] AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include('shared.lua') function ENT:Initialize() self.Entity:SetModel( "models/props_trainstation/trainstation_clock001.mdl") self.Entity:PhysicsInit(SOLID_VPHYSICS) self.Entity:SetMoveType(MOVETYPE_VPHYSICS) self.Entity:SetSolid(SOLID_VPHYSICS) self.Entity:SetAngles(Angle(-90, 0, 0)) local ply = self.Owner local phys = self.Entity:GetPhysicsObject() phys:EnableMotion(false) if(phys:IsValid()) then phys:Wake() end self.Entity:SetNWInt("damage",100) local spawnpointp = true ply:GetTable().maxspawn = ply:GetTable().maxspawn + 1 ply:GetTable().Spawnpoint = self.Entity end function ENT:Think( ) if (IsValid(self.Owner)!=true) then self.Entity:Remove() end end function ENT:OnRemove( ) local ply = self.Owner if IsValid(ply) then ply:GetTable().maxspawn = ply:GetTable().maxspawn - 1 end end [/lua][/QUOTE] Are you setting the owner in the purchase or however the player is getting the spawnpoint?
Sorry, you need to Log In to post a reply to this thread.