So I was going through the toybox when I found a portable spawn point and thought to myself, "hey, this would be a great addition to my DarkRP server. It would stop spawn killing and etc.!" I've added the lamp from the toybox to my DarkRP server before so I kinda know what I'm doing, but the lamp didn't require any information from the client in order to function unlike the portable spawn point. I just need to know which functions to put in the init file and which ones to put in the cl_init file. Any help is appreciated.
Here's my init file:
[code]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
function ENT:Initialize()
self:SetModel("models/props_combine/combine_mine01.mdl")
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
phys:EnableMotion(false)
end
local ply = self.dt.owning_ent
self.Entity.Owner = ply
hook.Add("PlayerSpawn", "ChangeSpawnLocation", SpawnFunc)
end
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos
local ent = ents.Create( ClassName )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Think()
NSpawnPos = self.Entity:GetPos()
end
function SpawnFunc( ply )
ply:SetPos(NSpawnPos + Vector(0,0,20))
end
function ENT:OnRemove()
hook.Remove("PlayerSpawn", "ChangeSpawnLocation")
end[/code]
Note: I added the line that creates a local ply and sets it to the owner to give ownership to the person that buys the spawnpoint from the f4 menu. It works fine, I use it on the lamp entity too so people could move it around with the physgun.
Here's the cl_init file:
[code]include("shared.lua")
function ENT:Draw()
self.Entity:DrawModel()
end[/code]
Note: I've tried moving all the functions sans the initialization function to the cl_init file from the init file, but it still didn't work.
And here's the original code for the entity directly from the toybox:
[code]ENT.Type = "anim"
ENT.Base = "base_anim"
ENT.PrintName = "Portable Spawn"
ENT.Author = "SweeneyPaul"
ENT.Contact = "Sweeney999"
ENT.Purpose ="To change spawn point"
ENT.Instructions ="Put entity for new spawn point"
ENT.Spawnable = true
ENT.AdminSpawnable = true
function ENT:Initialize()
if ( SERVER ) then
self:SetModel("models/props_combine/combine_mine01.mdl")
self:PhysicsInit( SOLID_VPHYSICS )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
phys:Wake()
phys:EnableMotion(false)
end
end
hook.Add("PlayerSpawn", "ChangeSpawnLocation", SpawnFunc)
end
function ENT:SpawnFunction( ply, tr )
if ( !tr.Hit ) then return end
local SpawnPos = tr.HitPos
local ent = ents.Create( ClassName )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
return ent
end
function ENT:Think()
NSpawnPos = self.Entity:GetPos()
end
function SpawnFunc( ply )
ply:SetPos(NSpawnPos + Vector(0,0,20))
end
function ENT:Use( activator, caller )
hook.Remove("PlayerSpawn", "ChangeSpawnLocation")
self.Entity:Remove()
end
function ENT:OnRemove()
hook.Remove("PlayerSpawn", "ChangeSpawnLocation")
end[/code]
Currently, the spawn point spawns and it is owned by the player rather than being a world prop, but it doesn't actually make you spawn on top of it.
Thank you to anyone who is willing to help!
Sorry, you need to Log In to post a reply to this thread.