Was wondering how I make it so my entity that I spawn can only be picked up by a gravity gun, currently I have it setup to be able to be picked up by a physgun but I rather have it picked up by a gravity gun. xP
cl_init:
[CODE]include("shared.lua")[/CODE]
shared:
[CODE]ENT.Type = "anim"
ENT.Base = "base_gmodentity"
ENT.PrintName = "Cocaine Plant"
ENT.Author = "Skashh"
ENT.Spawnable = true[/CODE]
init:
[CODE]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
hook.Add("InitPostEntity", "spawnplants", function()
local plant = ents.Create("coke_plant")
plant:Spawn()
end)
function ENT:Initialize()
self:SetModel( "models/props/cs_office/plant01.mdl" )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
if ( SERVER ) then self:PhysicsInit( SOLID_VPHYSICS ) end
local phys = self:GetPhysicsObject()
if ( IsValid( phys ) ) then phys:Wake() end
self:SetPos(Vector(-2268, -156, -132))
end
function PlayerPickup( ply, ent )
if (ply:IsValid()) then
return true
end
end
hook.Add( "PhysgunPickup", "Allow Player Pickup", PlayerPickup )[/CODE]
Maybe
[CODE]if ent == self then return false end[/CODE] in your PlayerPickup function? Also, please make it local!
Hey Skashh Use the same thing just change it to GravGunPickupAllowed and return false on the physgun pickup
Also [URL="https://wiki.garrysmod.com/page/GM/GravGunPickupAllowed"]Here's[/URL] the page
EDIT: I took out the GravgunPickup and PhysgunPickup functions and it seems that this entity spawns with the ability to be picked up by both so it's kind of inverted from what I thought. xP
[CODE]AddCSLuaFile("cl_init.lua")
AddCSLuaFile("shared.lua")
include("shared.lua")
hook.Add("InitPostEntity", "spawnplants", function()
local plant = ents.Create("coke_plant")
plant:Spawn()
end)
function ENT:Initialize()
self:SetModel( "models/props/cs_office/plant01.mdl" )
self:SetMoveType( MOVETYPE_VPHYSICS )
self:SetSolid( SOLID_VPHYSICS )
if ( SERVER ) then self:PhysicsInit( SOLID_VPHYSICS ) end
local phys = self:GetPhysicsObject()
if ( IsValid( phys ) ) then phys:Wake() end
self:SetPos(Vector(-2268, -156, -132))
end[/CODE]
Sorry, you need to Log In to post a reply to this thread.